Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jul 2016 21:01:04 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303512 - head/sys/ofed/drivers/infiniband/ulp/sdp
Message-ID:  <201607292101.u6TL1476068218@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Fri Jul 29 21:01:04 2016
New Revision: 303512
URL: https://svnweb.freebsd.org/changeset/base/303512

Log:
  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

Modified:
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c

Modified: head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h	Fri Jul 29 20:54:43 2016	(r303511)
+++ head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h	Fri Jul 29 21:01:04 2016	(r303512)
@@ -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,

Modified: head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	Fri Jul 29 20:54:43 2016	(r303511)
+++ head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	Fri Jul 29 21:01:04 2016	(r303512)
@@ -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 
 #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);
 

Modified: head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	Fri Jul 29 20:54:43 2016	(r303511)
+++ head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	Fri Jul 29 21:01:04 2016	(r303512)
@@ -701,25 +701,16 @@ sdp_rx_ring_create(struct sdp_sock *ssk,
 	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,
 	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;
 	}
 

Modified: head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	Fri Jul 29 20:54:43 2016	(r303511)
+++ head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	Fri Jul 29 21:01:04 2016	(r303512)
@@ -427,19 +427,11 @@ sdp_tx_ring_create(struct sdp_sock *ssk,
 	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,
 	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;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607292101.u6TL1476068218>