Skip to contentSkip to conversation

cxl/pci: Replace mutex_lock_io() w mutex_lock() for mailbox access

PATCH Applied [email protected] 4 participants 4 messages May 29, 2025 – Jun 9, 2025 CXL

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/pci: Replace mutex_lock_io() w mutex_lock() for mailbox access

From: Alison Schofield <[email protected]>

mutex_lock_io() differs from mutex_lock() in that it may call io_schedule() when a task must sleep waiting for the lock. This distinction only makes sense in block I/O or memory reclaim paths, where giving I/O a chance to make progress is useful.

At this call site, cxl_pci_mbox_send(), the mutex protects an MMIO mailbox. The task holding the lock is not blocking I/O progress, so calling io_schedule(), as mutex_lock_io() may do, has no practical effect.

Although there is no functional change, using the correct locking primitive, that more accurately reflects the semantics and intended use of the lock, improves code clarity and avoids misleading readers and tools.

---
 drivers/cxl/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/pci.c +1 -1
index 785aa2af5eaa..bd100ac31672 100644
@@ -379,7 +379,7 @@ static int cxl_pci_mbox_send(struct cxl_mailbox *cxl_mbox,
 {
 	int rc;
 
-	mutex_lock_io(&cxl_mbox->mbox_mutex);
+	mutex_lock(&cxl_mbox->mbox_mutex);
 	rc = __cxl_pci_mbox_send_cmd(cxl_mbox, cmd);
 	mutex_unlock(&cxl_mbox->mbox_mutex);
 

base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca

Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · alison.schofield@ wrote:

From: Alison Schofield <[email protected]>

mutex_lock_io() differs from mutex_lock() in that it may call io_schedule() when a task must sleep waiting for the lock. This distinction only makes sense in block I/O or memory reclaim paths, where giving I/O a chance to make progress is useful.

At this call site, cxl_pci_mbox_send(), the mutex protects an MMIO mailbox. The task holding the lock is not blocking I/O progress, so calling io_schedule(), as mutex_lock_io() may do, has no practical effect.

Although there is no functional change, using the correct locking primitive, that more accurately reflects the semantics and intended use of the lock, improves code clarity and avoids misleading readers and tools.

Quoted 5 lines

Looks good to me, I would suggest that Dave drop the Fixes: tag on applying since there is no need to backport this.

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 17 lines · On Thu, 29 May 2025, [email protected] wrote:

From: Alison Schofield <[email protected]>

mutex_lock_io() differs from mutex_lock() in that it may call io_schedule() when a task must sleep waiting for the lock. This distinction only makes sense in block I/O or memory reclaim paths, where giving I/O a chance to make progress is useful.

At this call site, cxl_pci_mbox_send(), the mutex protects an MMIO mailbox. The task holding the lock is not blocking I/O progress, so calling io_schedule(), as mutex_lock_io() may do, has no practical effect.

Although there is no functional change, using the correct locking primitive, that more accurately reflects the semantics and intended use of the lock, improves code clarity and avoids misleading readers and tools.

Quoted 5 lines

Yes, please.

maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 17 lines · On 5/29/25 1:51 PM, [email protected] wrote:

From: Alison Schofield <[email protected]>

mutex_lock_io() differs from mutex_lock() in that it may call io_schedule() when a task must sleep waiting for the lock. This distinction only makes sense in block I/O or memory reclaim paths, where giving I/O a chance to make progress is useful.

At this call site, cxl_pci_mbox_send(), the mutex protects an MMIO mailbox. The task holding the lock is not blocking I/O progress, so calling io_schedule(), as mutex_lock_io() may do, has no practical effect.

Although there is no functional change, using the correct locking primitive, that more accurately reflects the semantics and intended use of the lock, improves code clarity and avoids misleading readers and tools.

Quoted 5 lines

Applied to cxl/next with Fixes tag dropped.

Quoted 19 lines
---
 drivers/cxl/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/pci.c +1 -1
index 785aa2af5eaa..bd100ac31672 100644
@@ -379,7 +379,7 @@ static int cxl_pci_mbox_send(struct cxl_mailbox *cxl_mbox,
 {
 	int rc;
 
-	mutex_lock_io(&cxl_mbox->mbox_mutex);
+	mutex_lock(&cxl_mbox->mbox_mutex);
 	rc = __cxl_pci_mbox_send_cmd(cxl_mbox, cmd);
 	mutex_unlock(&cxl_mbox->mbox_mutex);
 

base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca