[openib-general] [PATCH applied] kill dead code around kmap_atomic

Michael S. Tsirkin mst at mellanox.co.il
Thu Dec 15 00:46:47 PST 2005


kmap_atomic never returns NULL.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>


Index: linux-2.6.14/drivers/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/ulp/ipoib/ipoib.h	2005-11-15 21:10:49.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/ulp/ipoib/ipoib.h	2005-12-07 21:23:33.000000000 +0200
@@ -78,6 +78,7 @@ enum {
 	IPOIB_FLAG_SUBINTERFACE   = 4,
 	IPOIB_MCAST_RUN 	  = 5,
 	IPOIB_STOP_REAPER         = 6,
+	IPOIB_MCAST_STARTED       = 7,
 
 	IPOIB_MAX_BACKOFF_SECONDS = 16,
 
Index: linux-2.6.14/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2005-12-07 17:42:56.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2005-12-08 20:28:02.000000000 +0200
@@ -203,16 +203,20 @@ static int ipoib_mcast_join_finish(struc
 {
 	struct net_device *dev = mcast->dev;
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	unsigned long flags;
 	int ret;
 
 	mcast->mcmember = *mcmember;
 
+	spin_lock_irqsave(&priv->lock, flags);
 	/* Set the cached Q_Key before we attach if it's the broadcast group */
-	if (!memcmp(mcast->mcmember.mgid.raw, priv->dev->broadcast + 4,
+	if (priv->broadcast &&
+	    !memcmp(mcast->mcmember.mgid.raw, priv->dev->broadcast + 4,
 		    sizeof (union ib_gid))) {
 		priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
 		priv->tx_wr.wr.ud.remote_qkey = priv->qkey;
 	}
+	spin_unlock_irqrestore(&priv->lock, flags);
 
 	if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
 		if (test_and_set_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags)) {
@@ -582,6 +586,10 @@ int ipoib_mcast_start_thread(struct net_
 		queue_work(ipoib_workqueue, &priv->mcast_task);
 	up(&mcast_mutex);
 
+	spin_lock_irq(&priv->lock);
+	set_bit(IPOIB_MCAST_STARTED, &priv->flags);
+	spin_unlock_irq(&priv->lock);
+
 	return 0;
 }
 
@@ -592,6 +600,10 @@ int ipoib_mcast_stop_thread(struct net_d
 
 	ipoib_dbg_mcast(priv, "stopping multicast thread\n");
 
+	spin_lock_irq(&priv->lock);
+	clear_bit(IPOIB_MCAST_STARTED, &priv->flags);
+	spin_unlock_irq(&priv->lock);
+
 	down(&mcast_mutex);
 	clear_bit(IPOIB_MCAST_RUN, &priv->flags);
 	cancel_delayed_work(&priv->mcast_task);
@@ -674,6 +686,9 @@ void ipoib_mcast_send(struct net_device 
 	 */
 	spin_lock(&priv->lock);
 
+	if (!test_bit(IPOIB_MCAST_STARTED, &priv->flags))
+		goto unlock;
+
 	mcast = __ipoib_mcast_find(dev, mgid);
 	if (!mcast) {
 		/* Let's create a new send only group now */
@@ -732,6 +747,7 @@ out:
 		ipoib_send(dev, skb, mcast->ah, IB_MULTICAST_QPN);
 	}
 
+unlock:
 	spin_unlock(&priv->lock);
 }
 
Index: linux-2.6.14/drivers/infiniband/ulp/sdp/sdp_send.c
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/ulp/sdp/sdp_send.c	2005-12-15 13:25:11.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/ulp/sdp/sdp_send.c	2005-12-15 13:25:49.000000000 +0200
@@ -639,11 +639,6 @@ static int sdp_send_data_iocb_src(struct
 		local_irq_save(flags);
 
 		addr = kmap_atomic(iocb->page_array[pos], KM_IRQ0);
-		if (!addr) {
-			result = -ENOMEM;
-			local_irq_restore(flags);
-			goto error;
-		}
 
 		memcpy(buff->tail, addr + off, len);
 
@@ -711,10 +706,6 @@ static int sdp_send_iocb_buff_write(stru
 		local_irq_save(flags);
 
 		addr = kmap_atomic(iocb->page_array[counter], KM_IRQ0);
-		if (!addr) {
-			local_irq_restore(flags);
-			break;
-		}
 
 		copy = min(PAGE_SIZE - offset,
 			   (unsigned long)(buff->end - buff->tail));
Index: linux-2.6.14/drivers/infiniband/ulp/sdp/sdp_recv.c
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/ulp/sdp/sdp_recv.c	2005-12-15 13:25:11.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/ulp/sdp/sdp_recv.c	2005-12-15 13:25:53.000000000 +0200
@@ -599,8 +599,6 @@ static int sdp_read_buff_iocb(struct sdp
 		local_irq_save(flags);
 
 		addr = kmap_atomic(iocb->page_array[counter], KM_IRQ0);
-		if (!addr)
-			break;
 
 		copy = min(PAGE_SIZE - offset,
 			   (unsigned long)(buff->tail - buff->data));

-- 
MST



More information about the general mailing list