public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit
@ 2025-03-17  9:57 Niklas Cassel
  2025-03-17 17:57 ` Chaitanya Kulkarni
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Niklas Cassel @ 2025-03-17  9:57 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
	Manivannan Sadhasivam, Damien Le Moal, Krzysztof Wilczyński,
	Keith Busch
  Cc: Niklas Cassel, linux-nvme

NVMe PCIe Transport Specification 1.1, section 2.1.10, claims that the
BAR0 type is Implementation Specific.

However, in NVMe 1.1, the type is required to be 64-bit.

Thus, to make our PCI EPF work on as many host systems as possible,
always configure the BAR0 type to be 64-bit.

In the rare case that the underlying PCI EPC does not support configuring
BAR0 as 64-bit, the call to pci_epc_set_bar() will fail, and we will
return a failure back to the user.

This should not be a problem, as most PCI EPCs support configuring a BAR
as 64-bit (and those EPCs with .only_64bit set to true in epc_features
only support configuring the BAR as 64-bit).

Tested-by: Damien Le Moal <dlemoal@kernel.org>
Fixes: 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
Changes since v1:
-Added Fixes-tag.
-Picked up tags.

 drivers/nvme/target/pci-epf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index 0136df45ca275..a24f6549c0d15 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -2096,8 +2096,15 @@ static int nvmet_pci_epf_configure_bar(struct nvmet_pci_epf *nvme_epf)
 		return -ENODEV;
 	}
 
-	if (epc_features->bar[BAR_0].only_64bit)
-		epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
+	/*
+	 * While NVMe PCIe Transport Specification 1.1, section 2.1.10, claims
+	 * that the BAR0 type is Implementation Specific, in NVMe 1.1, the type
+	 * is required to be 64-bit. Thus, for interoperability, always set the
+	 * type to 64-bit. In the rare case that the PCI EPC does not support
+	 * configuring BAR0 as 64-bit, the call to pci_epc_set_bar() will fail,
+	 * and we will return failure back to the user.
+	 */
+	epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
 
 	/*
 	 * Calculate the size of the register bar: NVMe registers first with
-- 
2.48.1



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

* Re: [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit
  2025-03-17  9:57 [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit Niklas Cassel
@ 2025-03-17 17:57 ` Chaitanya Kulkarni
  2025-03-18  5:49 ` Christoph Hellwig
  2025-03-18 15:46 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-03-17 17:57 UTC (permalink / raw)
  To: Niklas Cassel, Damien Le Moal
  Cc: linux-nvme@lists.infradead.org, Christoph Hellwig, Keith Busch,
	Manivannan Sadhasivam, Sagi Grimberg, Chaitanya Kulkarni,
	Krzysztof Wilczyński

On 3/17/25 02:57, Niklas Cassel wrote:
> NVMe PCIe Transport Specification 1.1, section 2.1.10, claims that the
> BAR0 type is Implementation Specific.
>
> However, in NVMe 1.1, the type is required to be 64-bit.
>
> Thus, to make our PCI EPF work on as many host systems as possible,
> always configure the BAR0 type to be 64-bit.
>
> In the rare case that the underlying PCI EPC does not support configuring
> BAR0 as 64-bit, the call to pci_epc_set_bar() will fail, and we will
> return a failure back to the user.
>
> This should not be a problem, as most PCI EPCs support configuring a BAR
> as 64-bit (and those EPCs with .only_64bit set to true in epc_features
> only support configuring the BAR as 64-bit).
>
> Tested-by: Damien Le Moal<dlemoal@kernel.org>
> Fixes: 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")
> Signed-off-by: Niklas Cassel<cassel@kernel.org>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



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

* Re: [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit
  2025-03-17  9:57 [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit Niklas Cassel
  2025-03-17 17:57 ` Chaitanya Kulkarni
@ 2025-03-18  5:49 ` Christoph Hellwig
  2025-03-18 15:46 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-03-18  5:49 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Sagi Grimberg, Chaitanya Kulkarni, Manivannan Sadhasivam,
	Damien Le Moal, Krzysztof Wilczyński, Keith Busch,
	linux-nvme

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit
  2025-03-17  9:57 [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit Niklas Cassel
  2025-03-17 17:57 ` Chaitanya Kulkarni
  2025-03-18  5:49 ` Christoph Hellwig
@ 2025-03-18 15:46 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2025-03-18 15:46 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
	Manivannan Sadhasivam, Damien Le Moal, Krzysztof Wilczy´nski,
	linux-nvme

On Mon, Mar 17, 2025 at 10:57:04AM +0100, Niklas Cassel wrote:
> NVMe PCIe Transport Specification 1.1, section 2.1.10, claims that the
> BAR0 type is Implementation Specific.
> 
> However, in NVMe 1.1, the type is required to be 64-bit.
> 
> Thus, to make our PCI EPF work on as many host systems as possible,
> always configure the BAR0 type to be 64-bit.
> 
> In the rare case that the underlying PCI EPC does not support configuring
> BAR0 as 64-bit, the call to pci_epc_set_bar() will fail, and we will
> return a failure back to the user.
> 
> This should not be a problem, as most PCI EPCs support configuring a BAR
> as 64-bit (and those EPCs with .only_64bit set to true in epc_features
> only support configuring the BAR as 64-bit).

Thanks, applied to nvme-6.15.


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

end of thread, other threads:[~2025-03-18 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  9:57 [PATCH v2] nvmet: pci-epf: Always configure BAR0 as 64-bit Niklas Cassel
2025-03-17 17:57 ` Chaitanya Kulkarni
2025-03-18  5:49 ` Christoph Hellwig
2025-03-18 15:46 ` Keith Busch

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