Commit 1cf0184c authored by Niklas Cassel's avatar Niklas Cassel Committed by Keith Busch
Browse files

nvmet: pci-epf: Always configure BAR0 as 64-bit



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: default avatarDamien Le Moal <dlemoal@kernel.org>
Fixes: 0faa0fe6 ("nvmet: New NVMe PCI endpoint function target driver")
Signed-off-by: default avatarNiklas Cassel <cassel@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 7b658153
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -2109,7 +2109,14 @@ static int nvmet_pci_epf_configure_bar(struct nvmet_pci_epf *nvme_epf)
		return -ENODEV;
	}

	if (epc_features->bar[BAR_0].only_64bit)
	/*
	 * 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;

	/*