[openib-general] [PATCH] iser: use semaphore instead of spinlock for critical section

Or Gerlitz ogerlitz at voltaire.com
Mon Jan 16 23:38:00 PST 2006


use semaphore instead of spinlock for the adaptor lookup/creation critical
section, this should eliminate the case where the spinlock debug code 
wrong CPU assertion was activated.

Signed-off-by: Or Gerlitz  <ogerlitz at voltaire.com>
Signed-off-by: Dan Bar Dov <danb at voltaire.com>

Index: ulp/iser/iser_mod.c
===================================================================
--- ulp/iser/iser_mod.c	(revision 5032)
+++ ulp/iser/iser_mod.c	(revision 5033)
@@ -119,7 +119,7 @@ int init_module(void)
 		return -ENOMEM;
 
 	/* adaptor init is called only after the first addr resolution */
-	spin_lock_init(&ig.adaptor_list_lock);
+	init_MUTEX(&ig.adaptor_list_sem);
 	INIT_LIST_HEAD(&ig.adaptor_list);
 	ig.num_adaptors = 0;
 
Index: ulp/iser/iser_verbs.c
===================================================================
--- ulp/iser/iser_verbs.c	(revision 5032)
+++ ulp/iser/iser_verbs.c	(revision 5033)
@@ -235,7 +235,7 @@ struct iser_adaptor *iser_adaptor_find_b
 	struct list_head      *p_list;
 	struct iser_adaptor   *p_adaptor = NULL;
 
-	spin_lock(&ig.adaptor_list_lock);
+	down(&ig.adaptor_list_sem);
 
 	p_list = ig.adaptor_list.next;
 	while (p_list != &ig.adaptor_list) {
@@ -257,7 +257,7 @@ struct iser_adaptor *iser_adaptor_find_b
 		list_add(&p_adaptor->ig_list, &ig.adaptor_list);
 	}
 end:
-	spin_unlock(&ig.adaptor_list_lock);
+	up(&ig.adaptor_list_sem);
 	return p_adaptor;
 }
 
Index: ulp/iser/iser.h
===================================================================
--- ulp/iser/iser.h	(revision 5032)
+++ ulp/iser/iser.h	(revision 5033)
@@ -41,6 +41,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
+#include <asm/semaphore.h>
 
 #include <linux/mempool.h>
 #include <linux/uio.h>
@@ -126,8 +127,7 @@ struct iser_adaptor {
  */
 struct iser_global {
 	unsigned int num_adaptors;
-
-	spinlock_t	  adaptor_list_lock; /*			  */
+	struct semaphore  adaptor_list_sem;  /*                   */
 	struct list_head  adaptor_list;	     /* all iSER adaptors */
 
 	kmem_cache_t *dto_cache;	/* slab for iser_dto */




More information about the general mailing list