public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable
@ 2025-05-08 14:57 Daniel Wagner
  2025-05-08 18:14 ` Keith Busch
  2025-05-09  4:58 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Wagner @ 2025-05-08 14:57 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke
  Cc: linux-nvme, linux-kernel, Daniel Wagner

From: Keith Busch <kbusch@kernel.org>

We need to lock this queue for that condition because the timeout work
executes per-namespace.

Reported-by: Hannes Reinecke <hare@kernel.org>
Closes: https://lore.kernel.org/all/20240902130728.1999-1-hare@kernel.org/
Fixes: a0fa9647a54e ("NVMe: add blk polling support")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
---
Changes in v2:
- disable irq first, then take the lock
- Link to v1: https://patch.msgid.link/20250508-nvme-pci-polling-v1-1-29ae900e793d@kernel.org
---
 drivers/nvme/host/pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 2e30e9be7408cba9dbb8918f066717b3a1c24010..c86af9e9211353d1713569c294899b0fde229020 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1202,7 +1202,9 @@ static void nvme_poll_irqdisable(struct nvme_queue *nvmeq)
 	WARN_ON_ONCE(test_bit(NVMEQ_POLLED, &nvmeq->flags));
 
 	disable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
+	spin_lock(&nvmeq->cq_poll_lock);
 	nvme_poll_cq(nvmeq, NULL);
+	spin_unlock(&nvmeq->cq_poll_lock);
 	enable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
 }
 

---
base-commit: 0ea9b1f7aabb8af08649048d04fa3cee44dac4ab
change-id: 20250508-nvme-pci-polling-a88ca70b7ada

Best regards,
-- 
Daniel Wagner <wagi@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable
  2025-05-08 14:57 [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable Daniel Wagner
@ 2025-05-08 18:14 ` Keith Busch
  2025-05-09  3:33   ` Christoph Hellwig
  2025-05-09  4:58 ` Christoph Hellwig
  1 sibling, 1 reply; 4+ messages in thread
From: Keith Busch @ 2025-05-08 18:14 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, Hannes Reinecke,
	linux-nvme, linux-kernel

On Thu, May 08, 2025 at 04:57:06PM +0200, Daniel Wagner wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> We need to lock this queue for that condition because the timeout work
> executes per-namespace.
> 
> Reported-by: Hannes Reinecke <hare@kernel.org>
> Closes: https://lore.kernel.org/all/20240902130728.1999-1-hare@kernel.org/
> Fixes: a0fa9647a54e ("NVMe: add blk polling support")
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> Signed-off-by: Daniel Wagner <wagi@kernel.org>

Looks good to me

Reviewed-by: Keith Busch <kbusch@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable
  2025-05-08 18:14 ` Keith Busch
@ 2025-05-09  3:33   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-05-09  3:33 UTC (permalink / raw)
  To: Keith Busch
  Cc: Daniel Wagner, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, linux-nvme, linux-kernel

On Thu, May 08, 2025 at 12:14:32PM -0600, Keith Busch wrote:
> On Thu, May 08, 2025 at 04:57:06PM +0200, Daniel Wagner wrote:
> > From: Keith Busch <kbusch@kernel.org>
> > 
> > We need to lock this queue for that condition because the timeout work
> > executes per-namespace.
> > 
> > Reported-by: Hannes Reinecke <hare@kernel.org>
> > Closes: https://lore.kernel.org/all/20240902130728.1999-1-hare@kernel.org/
> > Fixes: a0fa9647a54e ("NVMe: add blk polling support")
> > Signed-off-by: Keith Busch <kbusch@kernel.org>
> > Signed-off-by: Daniel Wagner <wagi@kernel.org>
> 
> Looks good to me
> 
> Reviewed-by: Keith Busch <kbusch@kernel.org>

This is originally attributed to you, so this review is a bit odd..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable
  2025-05-08 14:57 [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable Daniel Wagner
  2025-05-08 18:14 ` Keith Busch
@ 2025-05-09  4:58 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-05-09  4:58 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Hannes Reinecke, linux-nvme, linux-kernel

On Thu, May 08, 2025 at 04:57:06PM +0200, Daniel Wagner wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> We need to lock this queue for that condition because the timeout work
> executes per-namespace.

I've applied this to the nvme 6.15 branch, but I rewrote the commit
log as I can't find anything per-namespaces here, the CQ lock is
per-CQ.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-09  4:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 14:57 [PATCH v2] nvme-pci: lock per namespace in nvme_poll_irqdisable Daniel Wagner
2025-05-08 18:14 ` Keith Busch
2025-05-09  3:33   ` Christoph Hellwig
2025-05-09  4:58 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox