Skip to content

Commit 1cf0184

Browse files
floatiouskeithbusch
authored andcommitted
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: Damien Le Moal <[email protected]> Fixes: 0faa0fe ("nvmet: New NVMe PCI endpoint function target driver") Signed-off-by: Niklas Cassel <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 7b65815 commit 1cf0184

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/nvme/target/pci-epf.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,8 +2109,15 @@ static int nvmet_pci_epf_configure_bar(struct nvmet_pci_epf *nvme_epf)
21092109
return -ENODEV;
21102110
}
21112111

2112-
if (epc_features->bar[BAR_0].only_64bit)
2113-
epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
2112+
/*
2113+
* While NVMe PCIe Transport Specification 1.1, section 2.1.10, claims
2114+
* that the BAR0 type is Implementation Specific, in NVMe 1.1, the type
2115+
* is required to be 64-bit. Thus, for interoperability, always set the
2116+
* type to 64-bit. In the rare case that the PCI EPC does not support
2117+
* configuring BAR0 as 64-bit, the call to pci_epc_set_bar() will fail,
2118+
* and we will return failure back to the user.
2119+
*/
2120+
epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
21142121

21152122
/*
21162123
* Calculate the size of the register bar: NVMe registers first with

0 commit comments

Comments
 (0)