* [PATCH v2 0/5] nvmet pci-epf fixes
@ 2025-05-08 23:24 Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 1/5] nvmet: pci-epf: Clear completion queue IRQ flag on delete Damien Le Moal
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:24 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
Five patches to fix and improve IRQ handling in the PCI endpoint target
driver. The issues fixed by the first 2 patches where discovered with
testing with polling queues set on the host side. The following 2
patches are small improvements/cleanup in the same IRQ handling area.
The last patch removes dead code.
Changes from v1:
- Fixed typos in patch 1 and 2
- Removed Fixes tag from patch 2 as a backport to 6.14 would lead to
compilation errors
- Added Review tags to patch 3 and 4
- Added patch 5
Damien Le Moal (5):
nvmet: pci-epf: Clear completion queue IRQ flag on delete
nvmet: pci-epf: Do not fall back to using INTX if not supported
nvmet: pci-epf: Cleanup nvmet_pci_epf_raise_irq()
nvmet: pci-epf: Improve debug message
nvmet: pci-epf: Remove NVMET_PCI_EPF_Q_IS_SQ
drivers/nvme/target/pci-epf.c | 39 +++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 16 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/5] nvmet: pci-epf: Clear completion queue IRQ flag on delete
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
@ 2025-05-08 23:25 ` Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 2/5] nvmet: pci-epf: Do not fall back to using INTX if not supported Damien Le Moal
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:25 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
The function nvmet_pci_epf_delete_cq() unconditionally calls
nvmet_pci_epf_remove_irq_vector() even for completion queues that do not
have interrupts enabled. Furthermore, for completion queues that do
have IRQ enabled, deleting and re-creating the completion queue leaves
the flag NVMET_PCI_EPF_Q_IRQ_ENABLED set, even if the completion queue
is being re-created with IRQ disabled.
Fix these issues by calling nvmet_pci_epf_remove_irq_vector() only if
NVMET_PCI_EPF_Q_IRQ_ENABLED is set and make sure to always clear that
flag.
Fixes: 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/nvme/target/pci-epf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index 7fab7f3d79b7..d5442991f2fb 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -1344,7 +1344,8 @@ static u16 nvmet_pci_epf_delete_cq(struct nvmet_ctrl *tctrl, u16 cqid)
cancel_delayed_work_sync(&cq->work);
nvmet_pci_epf_drain_queue(cq);
- nvmet_pci_epf_remove_irq_vector(ctrl, cq->vector);
+ if (test_and_clear_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
+ nvmet_pci_epf_remove_irq_vector(ctrl, cq->vector);
nvmet_pci_epf_mem_unmap(ctrl->nvme_epf, &cq->pci_map);
return NVME_SC_SUCCESS;
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/5] nvmet: pci-epf: Do not fall back to using INTX if not supported
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 1/5] nvmet: pci-epf: Clear completion queue IRQ flag on delete Damien Le Moal
@ 2025-05-08 23:25 ` Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 3/5] nvmet: pci-epf: Cleanup nvmet_pci_epf_raise_irq() Damien Le Moal
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:25 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
Some endpoint PCIe controllers do not support raising legacy INTX
interrupts. This support is indicated by the intx_capable field of
struct pci_epc_features. Modify nvmet_pci_epf_raise_irq() to not
automatically fallback to trying raising an INTX interrupt after an MSI
or MSI-X error if the controller does not support INTX.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/nvme/target/pci-epf.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index d5442991f2fb..bde7818c673d 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -636,14 +636,16 @@ static void nvmet_pci_epf_raise_irq(struct nvmet_pci_epf_ctrl *ctrl,
switch (nvme_epf->irq_type) {
case PCI_IRQ_MSIX:
case PCI_IRQ_MSI:
+ /*
+ * If we fail to raise an MSI or MSI-X interrupt, it is likely
+ * because the host is using legacy INTX IRQs (e.g. BIOS,
+ * grub), but we can fallback to the INTX type only if the
+ * endpoint controller supports this type.
+ */
ret = pci_epc_raise_irq(epf->epc, epf->func_no, epf->vfunc_no,
nvme_epf->irq_type, cq->vector + 1);
- if (!ret)
+ if (!ret || !nvme_epf->epc_features->intx_capable)
break;
- /*
- * If we got an error, it is likely because the host is using
- * legacy IRQs (e.g. BIOS, grub).
- */
fallthrough;
case PCI_IRQ_INTX:
ret = pci_epc_raise_irq(epf->epc, epf->func_no, epf->vfunc_no,
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/5] nvmet: pci-epf: Cleanup nvmet_pci_epf_raise_irq()
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 1/5] nvmet: pci-epf: Clear completion queue IRQ flag on delete Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 2/5] nvmet: pci-epf: Do not fall back to using INTX if not supported Damien Le Moal
@ 2025-05-08 23:25 ` Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 4/5] nvmet: pci-epf: Improve debug message Damien Le Moal
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:25 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
There is no point in taking the controller irq_lock and calling
nvmet_pci_epf_should_raise_irq() for a completion queue which does not
have IRQ enabled (NVMET_PCI_EPF_Q_IRQ_ENABLED flag is not set).
Move the test for the NVMET_PCI_EPF_Q_IRQ_ENABLED flag out of
nvmet_pci_epf_should_raise_irq() to the top of nvmet_pci_epf_raise_irq()
to return early when no IRQ should be raised.
Also, use dev_err_ratelimited() to avoid a message storm under load when
raising IRQs is failing.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
---
drivers/nvme/target/pci-epf.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index bde7818c673d..a6ccf3fcccc2 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -596,9 +596,6 @@ static bool nvmet_pci_epf_should_raise_irq(struct nvmet_pci_epf_ctrl *ctrl,
struct nvmet_pci_epf_irq_vector *iv = cq->iv;
bool ret;
- if (!test_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
- return false;
-
/* IRQ coalescing for the admin queue is not allowed. */
if (!cq->qid)
return true;
@@ -625,7 +622,8 @@ static void nvmet_pci_epf_raise_irq(struct nvmet_pci_epf_ctrl *ctrl,
struct pci_epf *epf = nvme_epf->epf;
int ret = 0;
- if (!test_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags))
+ if (!test_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags) ||
+ !test_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
return;
mutex_lock(&ctrl->irq_lock);
@@ -658,7 +656,9 @@ static void nvmet_pci_epf_raise_irq(struct nvmet_pci_epf_ctrl *ctrl,
}
if (ret)
- dev_err(ctrl->dev, "Failed to raise IRQ (err=%d)\n", ret);
+ dev_err_ratelimited(ctrl->dev,
+ "CQ[%u]: Failed to raise IRQ (err=%d)\n",
+ cq->qid, ret);
unlock:
mutex_unlock(&ctrl->irq_lock);
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/5] nvmet: pci-epf: Improve debug message
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
` (2 preceding siblings ...)
2025-05-08 23:25 ` [PATCH v2 3/5] nvmet: pci-epf: Cleanup nvmet_pci_epf_raise_irq() Damien Le Moal
@ 2025-05-08 23:25 ` Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 5/5] nvmet: pci-epf: Remove NVMET_PCI_EPF_Q_IS_SQ Damien Le Moal
2025-05-09 4:58 ` [PATCH v2 0/5] nvmet pci-epf fixes Christoph Hellwig
5 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:25 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
Improve the debug message of nvmet_pci_epf_create_cq() to indicate if a
completion queue IRQ is disabled.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
---
drivers/nvme/target/pci-epf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index a6ccf3fcccc2..94a908b2340e 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -1321,8 +1321,14 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
set_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags);
- dev_dbg(ctrl->dev, "CQ[%u]: %u entries of %zu B, IRQ vector %u\n",
- cqid, qsize, cq->qes, cq->vector);
+ if (test_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
+ dev_dbg(ctrl->dev,
+ "CQ[%u]: %u entries of %zu B, IRQ vector %u\n",
+ cqid, qsize, cq->qes, cq->vector);
+ else
+ dev_dbg(ctrl->dev,
+ "CQ[%u]: %u entries of %zu B, IRQ disabled\n",
+ cqid, qsize, cq->qes);
return NVME_SC_SUCCESS;
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/5] nvmet: pci-epf: Remove NVMET_PCI_EPF_Q_IS_SQ
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
` (3 preceding siblings ...)
2025-05-08 23:25 ` [PATCH v2 4/5] nvmet: pci-epf: Improve debug message Damien Le Moal
@ 2025-05-08 23:25 ` Damien Le Moal
2025-05-09 4:58 ` [PATCH v2 0/5] nvmet pci-epf fixes Christoph Hellwig
5 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-05-08 23:25 UTC (permalink / raw)
To: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
The flag NVMET_PCI_EPF_Q_IS_SQ is set but never used. Remove it.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/nvme/target/pci-epf.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index 94a908b2340e..7123c855b5a6 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -62,8 +62,7 @@ static DEFINE_MUTEX(nvmet_pci_epf_ports_mutex);
#define NVMET_PCI_EPF_CQ_RETRY_INTERVAL msecs_to_jiffies(1)
enum nvmet_pci_epf_queue_flags {
- NVMET_PCI_EPF_Q_IS_SQ = 0, /* The queue is a submission queue */
- NVMET_PCI_EPF_Q_LIVE, /* The queue is live */
+ NVMET_PCI_EPF_Q_LIVE = 0, /* The queue is live */
NVMET_PCI_EPF_Q_IRQ_ENABLED, /* IRQ is enabled for this queue */
};
@@ -1542,7 +1541,6 @@ static void nvmet_pci_epf_init_queue(struct nvmet_pci_epf_ctrl *ctrl,
if (sq) {
queue = &ctrl->sq[qid];
- set_bit(NVMET_PCI_EPF_Q_IS_SQ, &queue->flags);
} else {
queue = &ctrl->cq[qid];
INIT_DELAYED_WORK(&queue->work, nvmet_pci_epf_cq_work);
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/5] nvmet pci-epf fixes
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
` (4 preceding siblings ...)
2025-05-08 23:25 ` [PATCH v2 5/5] nvmet: pci-epf: Remove NVMET_PCI_EPF_Q_IS_SQ Damien Le Moal
@ 2025-05-09 4:58 ` Christoph Hellwig
5 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-05-09 4:58 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Chaitanya Kulkarni
Thanks,
applied to nvme-6.15.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-05-09 5:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 23:24 [PATCH v2 0/5] nvmet pci-epf fixes Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 1/5] nvmet: pci-epf: Clear completion queue IRQ flag on delete Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 2/5] nvmet: pci-epf: Do not fall back to using INTX if not supported Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 3/5] nvmet: pci-epf: Cleanup nvmet_pci_epf_raise_irq() Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 4/5] nvmet: pci-epf: Improve debug message Damien Le Moal
2025-05-08 23:25 ` [PATCH v2 5/5] nvmet: pci-epf: Remove NVMET_PCI_EPF_Q_IS_SQ Damien Le Moal
2025-05-09 4:58 ` [PATCH v2 0/5] nvmet pci-epf fixes Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.