Skip to contentSkip to conversation

be2net: use semaphore instead of spin lock for mbox_lock

PATCH Applied Ivan Vecera 3 participants 4 messages Dec 14, 2010 – Dec 16, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 be2net: use semaphore instead of spin lock for mbox_lock

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a semaphore and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change the mbox_lock to a semaphore or a mutex.

---
 drivers/net/benet/be.h      |    2 +-
 drivers/net/benet/be_cmds.c |   75 +++++++++++++++++++++++++-----------------
 drivers/net/benet/be_main.c |    2 +-
 3 files changed, 47 insertions(+), 32 deletions(-)
drivers/net/benet/be.h +1 -1
index 4594a28..45d67cb 100644
@@ -234,7 +234,7 @@ struct be_adapter {
 	u8 __iomem *db;		/* Door Bell */
 	u8 __iomem *pcicfg;	/* PCI config space */
 
-	spinlock_t mbox_lock;	/* For serializing mbox cmds to BE card */
+	struct semaphore mbox_lock; /* For serializing mbox cmds to BE card */
 	struct be_dma_mem mbox_mem;
 	/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
 	 * is stored for freeing purpose */
drivers/net/benet/be_cmds.c +45 -30

255 lines not on this page · raw message

drivers/net/benet/be_main.c +1 -1
index 93354ee..974e806 100644
@@ -2677,7 +2677,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
 	}
 	memset(mc_cmd_mem->va, 0, mc_cmd_mem->size);
 
-	spin_lock_init(&adapter->mbox_lock);
+	sema_init(&adapter->mbox_lock, 1);
 	spin_lock_init(&adapter->mcc_lock);
 	spin_lock_init(&adapter->mcc_cq_lock);
 
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 4 lines · Ivan Vecera

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a semaphore and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change the mbox_lock to a semaphore or a mutex.

[...]

I see no reason for this to be a semaphore; use a mutex instead.

Ben

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw

Re: [PATCH net-2.6] be2net: use mutex instead of spin lock for mbox_lock

Quoted 10 lines · Ben Hutchings
Quoted 4 lines · Ivan Vecera

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a semaphore and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change the mbox_lock to a semaphore or a mutex.

[...]

I see no reason for this to be a semaphore; use a mutex instead.

Ben

Ok, Ben... the new version

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a mutex and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change mbox_lock to semaphore or mutex.

---
 drivers/net/benet/be.h      |    2 +-
 drivers/net/benet/be_cmds.c |   75 +++++++++++++++++++++++++-----------------
 drivers/net/benet/be_main.c |    2 +-
 3 files changed, 47 insertions(+), 32 deletions(-)
drivers/net/benet/be.h +1 -1
index 4594a28..d64313b 100644
@@ -234,7 +234,7 @@ struct be_adapter {
 	u8 __iomem *db;		/* Door Bell */
 	u8 __iomem *pcicfg;	/* PCI config space */
 
-	spinlock_t mbox_lock;	/* For serializing mbox cmds to BE card */
+	struct mutex mbox_lock; /* For serializing mbox cmds to BE card */
 	struct be_dma_mem mbox_mem;
 	/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
 	 * is stored for freeing purpose */
drivers/net/benet/be_cmds.c +45 -30

255 lines not on this page · raw message

drivers/net/benet/be_main.c +1 -1
index 93354ee..fd251b5 100644
@@ -2677,7 +2677,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
 	}
 	memset(mc_cmd_mem->va, 0, mc_cmd_mem->size);
 
-	spin_lock_init(&adapter->mbox_lock);
+	mutex_init(&adapter->mbox_lock);
 	spin_lock_init(&adapter->mcc_lock);
 	spin_lock_init(&adapter->mcc_cq_lock);
 
Signature · 1 line
1.7.2.2
maintainer Applied
#3 lore raw

Re: [PATCH net-2.6] be2net: use mutex instead of spin lock for mbox_lock

From: Ivan Vecera <[email protected]>
Date: Tue, 14 Dec 2010 16:43:19 +0100

Quoted 11 lines · Ben Hutchings
Quoted 10 lines · Ivan Vecera
Quoted 4 lines

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a semaphore and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change the mbox_lock to a semaphore or a mutex.

[...]

I see no reason for this to be a semaphore; use a mutex instead.

Ben

Quoted 8 lines

Ok, Ben... the new version

Since the mbox polling uses the schedule_timeout, the mbox_lock should be a mutex and not a spin lock.
The commit f25b03a replaced udelay() with schedule_timeout() but didn't change mbox_lock to semaphore or mutex.

Applied, thanks.