Skip to contentSkip to conversation

nvmet: pci-epf: Move DMA initialization to EPC init callback

PATCH Applied Niklas Cassel 3 participants 4 messages Sep 9, 2025 – Oct 9, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: pci-epf: Move DMA initialization to EPC init callback

From: Shin'ichiro Kawasaki <[email protected]>

For DMA initialization to work across all EPC drivers, the DMA initialization has to be done in the .init() callback.

This is because not all EPC drivers will have a refclock (which is often needed to access registers of a DMA controller embedded in a PCIe controller) at the time the .bind() callback is called.

However, all EPC drivers are guaranteed to have a refclock by the time the .init() callback is called.

Thus, move the DMA initialization to the .init() callback.

This change was already done for other EPF drivers in commit 60bd3e039aa2 ("PCI: endpoint: pci-epf-{mhi/test}: Move DMA initialization to EPC init callback").

Fixes 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")
---
 drivers/nvme/target/pci-epf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/pci-epf.c +2 -2
index 2e78397a7373a..9c5b0f78ce8df 100644
@@ -2325,6 +2325,8 @@ static int nvmet_pci_epf_epc_init(struct pci_epf *epf)
 		return ret;
 	}
 
+	nvmet_pci_epf_init_dma(nvme_epf);
+
 	/* Set device ID, class, etc. */
 	epf->header->vendorid = ctrl->tctrl->subsys->vendor_id;
 	epf->header->subsys_vendor_id = ctrl->tctrl->subsys->subsys_vendor_id;
@@ -2422,8 +2424,6 @@ static int nvmet_pci_epf_bind(struct pci_epf *epf)
 	if (ret)
 		return ret;
 
-	nvmet_pci_epf_init_dma(nvme_epf);
-
 	return 0;
 }
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Niklas Cassel

From: Shin'ichiro Kawasaki <[email protected]>

For DMA initialization to work across all EPC drivers, the DMA initialization has to be done in the .init() callback.

This is because not all EPC drivers will have a refclock (which is often needed to access registers of a DMA controller embedded in a PCIe controller) at the time the .bind() callback is called.

However, all EPC drivers are guaranteed to have a refclock by the time the .init() callback is called.

Thus, move the DMA initialization to the .init() callback.

Quoted 8 lines

This change was already done for other EPF drivers in commit 60bd3e039aa2 ("PCI: endpoint: pci-epf-{mhi/test}: Move DMA initialization to EPC init callback").

Fixes 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")

Looks good.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#2 lore raw
In reply to Niklas Cassel
Quoted 52 lines · Niklas Cassel

From: Shin'ichiro Kawasaki <[email protected]>

For DMA initialization to work across all EPC drivers, the DMA initialization has to be done in the .init() callback.

This is because not all EPC drivers will have a refclock (which is often needed to access registers of a DMA controller embedded in a PCIe controller) at the time the .bind() callback is called.

However, all EPC drivers are guaranteed to have a refclock by the time the .init() callback is called.

Thus, move the DMA initialization to the .init() callback.

This change was already done for other EPF drivers in commit 60bd3e039aa2 ("PCI: endpoint: pci-epf-{mhi/test}: Move DMA initialization to EPC init callback").

Fixes 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")
---
 drivers/nvme/target/pci-epf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/pci-epf.c +2 -2
index 2e78397a7373a..9c5b0f78ce8df 100644
@@ -2325,6 +2325,8 @@ static int nvmet_pci_epf_epc_init(struct pci_epf *epf)
 		return ret;
 	}
 
+	nvmet_pci_epf_init_dma(nvme_epf);
+
 	/* Set device ID, class, etc. */
 	epf->header->vendorid = ctrl->tctrl->subsys->vendor_id;
 	epf->header->subsys_vendor_id = ctrl->tctrl->subsys->subsys_vendor_id;
@@ -2422,8 +2424,6 @@ static int nvmet_pci_epf_bind(struct pci_epf *epf)
 	if (ret)
 		return ret;
 
-	nvmet_pci_epf_init_dma(nvme_epf);
-
 	return 0;
 }
 
Signature · 1 line
2.51.0

Gentle ping

Kind regards,
Niklas

maintainer Applied
#3 lore raw
In reply to Niklas Cassel
Quoted 9 lines · Niklas Cassel

From: Shin'ichiro Kawasaki <[email protected]>

For DMA initialization to work across all EPC drivers, the DMA initialization has to be done in the .init() callback.

This is because not all EPC drivers will have a refclock (which is often needed to access registers of a DMA controller embedded in a PCIe controller) at the time the .bind() callback is called.

Quoted 8 lines

However, all EPC drivers are guaranteed to have a refclock by the time the .init() callback is called.

Thus, move the DMA initialization to the .init() callback.

This change was already done for other EPF drivers in commit 60bd3e039aa2 ("PCI: endpoint: pci-epf-{mhi/test}: Move DMA initialization to EPC init callback").

Thanks, applied to nvme-6.19.