cxl/pci: Replace mutex_lock_io() w mutex_lock() for mailbox access
[email protected]
maintainerPATCH 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
@@ -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
Quoted 17 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
mutex_lock_io()differs frommutex_lock()in that it may callio_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 callingio_schedule(), asmutex_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
Reported-by Alok Tiwari <[email protected]>Suggested-by Dan Williams <[email protected]>Fixes 8adaf747c9f0 ("cxl/mem: Find device capabilities")Signed-off-by Alison Schofield <[email protected]>
Looks good to me, I would suggest that Dave drop the Fixes: tag on applying since there is no need to backport this.
Quoted 17 lines · On Thu, 29 May 2025, [email protected] wrote:
From: Alison Schofield <[email protected]>
mutex_lock_io()differs frommutex_lock()in that it may callio_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 callingio_schedule(), asmutex_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
Reported-by Alok Tiwari <[email protected]>Suggested-by Dan Williams <[email protected]>Fixes 8adaf747c9f0 ("cxl/mem: Find device capabilities")Signed-off-by Alison Schofield <[email protected]>
Yes, please.
Quoted 17 lines · On 5/29/25 1:51 PM, [email protected] wrote:
From: Alison Schofield <[email protected]>
mutex_lock_io()differs frommutex_lock()in that it may callio_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 callingio_schedule(), asmutex_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
Reported-by Alok Tiwari <[email protected]>Suggested-by Dan Williams <[email protected]>Fixes 8adaf747c9f0 ("cxl/mem: Find device capabilities")Signed-off-by Alison Schofield <[email protected]>
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@@ -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