[openib-general] [PATCH] sdp_kmap to kmap_atomic

Michael S. Tsirkin mst at mellanox.co.il
Thu Mar 31 06:10:24 PST 2005


Replace sdp_kmap by kmap_atomic. Use KM_IRQ0 slot, and
disable local interrupts to avoid kmap slot collision.
Incidentially, sdp_iocb.h is now free of stuff not related
to iocb.

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

Index: drivers/infiniband/ulp/sdp/sdp_send.c
===================================================================
--- drivers/infiniband/ulp/sdp/sdp_send.c	(revision 2096)
+++ drivers/infiniband/ulp/sdp/sdp_send.c	(working copy)
@@ -641,6 +641,7 @@ static int sdp_send_data_iocb_src(struct
 	SDP_BUFF_F_CLR_UNSIG(buff);
 
 	if (conn->send_mode == SDP_MODE_COMB) {
+		unsigned long flags;
 		void *addr;
 		int   pos;
 		int   off;
@@ -662,21 +663,22 @@ static int sdp_send_data_iocb_src(struct
 			result = -EFAULT;
 			goto error;
 		}
-		/*
-		 * map, copy, unmap.
-		 */
-		addr = sdp_kmap(iocb->page_array[pos]);
+
+		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);
 
-		sdp_kunmap(iocb->page_array[pos]);
-		/*
-		 * update pointers
-		 */
+		kunmap_atomic(iocb->page_array[pos], KM_IRQ0);
+
+		local_irq_restore(flags);
+
 		buff->data_size  = len;
 		buff->tail      += len;
 
@@ -731,14 +733,16 @@ static int sdp_send_iocb_buff_write(stru
 	counter = (iocb->post + iocb->page_offset) >> PAGE_SHIFT;
 	offset  = (iocb->post + iocb->page_offset) & (~PAGE_MASK);
 
-	while (buff->tail < buff->end &&
-	       iocb->len > 0) {
-		/*
-		 * map correct page of iocb
-		 */
-		addr = sdp_kmap(iocb->page_array[counter]);
-		if (!addr)
+
+	while (buff->tail < buff->end && iocb->len > 0) {
+		unsigned long flags;
+		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));
@@ -755,7 +759,8 @@ static int sdp_send_iocb_buff_write(stru
 		offset += copy;
 		offset &= (~PAGE_MASK);
 
-		sdp_kunmap(iocb->page_array[counter++]);
+		kunmap_atomic(iocb->page_array[counter++], KM_IRQ0);
+		local_irq_restore(flags);
 	}
 
 	return 0;
Index: drivers/infiniband/ulp/sdp/sdp_recv.c
===================================================================
--- drivers/infiniband/ulp/sdp/sdp_recv.c	(revision 2096)
+++ drivers/infiniband/ulp/sdp/sdp_recv.c	(working copy)
@@ -659,12 +659,11 @@ static int sdp_read_buff_iocb(struct sdp
 	counter = (iocb->post + iocb->page_offset) >> PAGE_SHIFT;
 	offset  = (iocb->post + iocb->page_offset) & (~PAGE_MASK);
 
-	while (buff->data < buff->tail &&
-	       iocb->len > 0) {
-		/*
-		 * map correct page of iocb
-		 */
-		addr = sdp_kmap(iocb->page_array[counter]);
+	while (buff->data < buff->tail && iocb->len > 0) {
+		unsigned long flags;
+		local_irq_save(flags);
+
+		addr = kmap_atomic(iocb->page_array[counter], KM_IRQ0);
 		if (!addr)
 			break;
 
@@ -682,7 +681,9 @@ static int sdp_read_buff_iocb(struct sdp
 		offset     += copy;
 		offset     &= (~PAGE_MASK);
 		
-		sdp_kunmap(iocb->page_array[counter++]);
+		kunmap_atomic(iocb->page_array[counter++], KM_IRQ0);
+
+		local_irq_restore(flags);
 	}
 	/*
 	 * restore tail from OOB offset.
Index: drivers/infiniband/ulp/sdp/sdp_iocb.h
===================================================================
--- drivers/infiniband/ulp/sdp/sdp_iocb.h	(revision 2096)
+++ drivers/infiniband/ulp/sdp/sdp_iocb.h	(working copy)
@@ -124,30 +124,4 @@ struct sdpc_iocb_q {
 	int size;               /* current number of IOCBs in table */
 };
 
-/*
- * Address translations
- */
-
-/*
- * sdp_kmap - map a page into kernel space
- */
-static inline void *sdp_kmap(struct page *page)
-{
-	if (in_atomic() || irqs_disabled())
-		return kmap_atomic(page, KM_IRQ0);
-	else
-		return kmap(page);
-}
-
-/*
- * sdp_kunmap - unmap a page into kernel space
- */
-static inline void sdp_kunmap(struct page *page)
-{
-	if (in_atomic() || irqs_disabled())
-		kunmap_atomic(page, KM_IRQ0);
-	else
-		kunmap(page);
-}
-
 #endif /* _SDP_IOCB_H */

-- 
MST - Michael S. Tsirkin



More information about the general mailing list