sdp: Use malloc(9) instead of the Linux compat layer.

SDP transmit and receive rings are always created in a sleepable context,
so we can use M_WAITOK and remove error checks.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Mark Johnston 2016-07-29 21:01:04 +00:00
parent f66ec15275
commit d3461164e0
4 changed files with 15 additions and 29 deletions

View File

@ -455,6 +455,8 @@ struct sdp_sock {
#define SDP_RLOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_RLOCKED)
#define SDP_LOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_LOCKED)
MALLOC_DECLARE(M_SDP);
static inline void tx_sa_reset(struct tx_srcavail_state *tx_sa)
{
memset((void *)&tx_sa->busy, 0,

View File

@ -64,6 +64,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include "sdp.h"
#include <net/if.h>
@ -86,7 +90,7 @@ RW_SYSINIT(sdplockinit, &sdp_lock, "SDP lock");
#define SDP_LIST_RLOCK_ASSERT() rw_assert(&sdp_lock, RW_RLOCKED)
#define SDP_LIST_LOCK_ASSERT() rw_assert(&sdp_lock, RW_LOCKED)
static MALLOC_DEFINE(M_SDP, "sdp", "Socket Direct Protocol");
MALLOC_DEFINE(M_SDP, "sdp", "Sockets Direct Protocol");
static void sdp_stop_keepalive_timer(struct socket *so);

View File

@ -701,25 +701,16 @@ sdp_rx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
struct ib_cq *rx_cq;
int rc = 0;
sdp_dbg(ssk->socket, "rx ring created");
INIT_WORK(&ssk->rx_comp_work, sdp_rx_comp_work);
atomic_set(&ssk->rx_ring.head, 1);
atomic_set(&ssk->rx_ring.tail, 1);
ssk->rx_ring.buffer = kmalloc(
sizeof *ssk->rx_ring.buffer * SDP_RX_SIZE, GFP_KERNEL);
if (!ssk->rx_ring.buffer) {
sdp_warn(ssk->socket,
"Unable to allocate RX Ring size %zd.\n",
sizeof(*ssk->rx_ring.buffer) * SDP_RX_SIZE);
return -ENOMEM;
}
ssk->rx_ring.buffer = malloc(sizeof(*ssk->rx_ring.buffer) * SDP_RX_SIZE,
M_SDP, M_WAITOK);
rx_cq = ib_create_cq(device, sdp_rx_irq, sdp_rx_cq_event_handler,
ssk, SDP_RX_SIZE, 0);
if (IS_ERR(rx_cq)) {
rc = PTR_ERR(rx_cq);
sdp_warn(ssk->socket, "Unable to allocate RX CQ: %d.\n", rc);
@ -732,7 +723,7 @@ sdp_rx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
return 0;
err_cq:
kfree(ssk->rx_ring.buffer);
free(ssk->rx_ring.buffer, M_SDP);
ssk->rx_ring.buffer = NULL;
return rc;
}
@ -746,8 +737,7 @@ sdp_rx_ring_destroy(struct sdp_sock *ssk)
if (ssk->rx_ring.buffer) {
sdp_rx_ring_purge(ssk);
kfree(ssk->rx_ring.buffer);
free(ssk->rx_ring.buffer, M_SDP);
ssk->rx_ring.buffer = NULL;
}

View File

@ -427,19 +427,11 @@ sdp_tx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
atomic_set(&ssk->tx_ring.head, 1);
atomic_set(&ssk->tx_ring.tail, 1);
ssk->tx_ring.buffer = kzalloc(
sizeof *ssk->tx_ring.buffer * SDP_TX_SIZE, GFP_KERNEL);
if (!ssk->tx_ring.buffer) {
rc = -ENOMEM;
sdp_warn(ssk->socket, "Can't allocate TX Ring size %zd.\n",
sizeof(*ssk->tx_ring.buffer) * SDP_TX_SIZE);
goto out;
}
ssk->tx_ring.buffer = malloc(sizeof(*ssk->tx_ring.buffer) * SDP_TX_SIZE,
M_SDP, M_WAITOK);
tx_cq = ib_create_cq(device, sdp_tx_irq, sdp_tx_cq_event_handler,
ssk, SDP_TX_SIZE, 0);
if (IS_ERR(tx_cq)) {
rc = PTR_ERR(tx_cq);
sdp_warn(ssk->socket, "Unable to allocate TX CQ: %d.\n", rc);
@ -452,9 +444,8 @@ sdp_tx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
return 0;
err_cq:
kfree(ssk->tx_ring.buffer);
free(ssk->tx_ring.buffer, M_SDP);
ssk->tx_ring.buffer = NULL;
out:
return rc;
}
@ -472,8 +463,7 @@ sdp_tx_ring_destroy(struct sdp_sock *ssk)
if (ssk->tx_ring.buffer) {
sdp_tx_ring_purge(ssk);
kfree(ssk->tx_ring.buffer);
free(ssk->tx_ring.buffer, M_SDP);
ssk->tx_ring.buffer = NULL;
}