mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: lock per namespace in nvme_poll_irqdisable
@ 2025-05-08 11:55 Daniel Wagner
  2025-05-08 14:28 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Wagner @ 2025-05-08 11:55 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>
---
Keith, I hope this is okay. I picked up your patch and added your SoB. As
mentioned in the thread, this fixed the problem reported by our customer.
And yes, it is a muliti-namespace controller.
---
 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..b07ee427c311d508a95ab730c0b875f21fe5cc43 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1201,9 +1201,11 @@ static void nvme_poll_irqdisable(struct nvme_queue *nvmeq)
 
 	WARN_ON_ONCE(test_bit(NVMEQ_POLLED, &nvmeq->flags));
 
+	spin_lock(&nvmeq->cq_poll_lock);
 	disable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
 	nvme_poll_cq(nvmeq, NULL);
 	enable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
+	spin_unlock(&nvmeq->cq_poll_lock);
 }
 
 static int nvme_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)

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

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


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

* Re: [PATCH] nvme-pci: lock per namespace in nvme_poll_irqdisable
  2025-05-08 11:55 [PATCH] nvme-pci: lock per namespace in nvme_poll_irqdisable Daniel Wagner
@ 2025-05-08 14:28 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2025-05-08 14:28 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 01:55:55PM +0200, Daniel Wagner wrote:
> +	spin_lock(&nvmeq->cq_poll_lock);
>  	disable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
>  	nvme_poll_cq(nvmeq, NULL);
>  	enable_irq(pci_irq_vector(pdev, nvmeq->cq_vector));
> +	spin_unlock(&nvmeq->cq_poll_lock);
>  }

I noticed disable_irq() contains a "might_sleep()", so the order needs
to have spin_lock() happen after disable_irq().

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

end of thread, other threads:[~2025-05-08 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-08 11:55 [PATCH] nvme-pci: lock per namespace in nvme_poll_irqdisable Daniel Wagner
2025-05-08 14:28 ` Keith Busch

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

all inboxes | Powered by JetHome®