pci_epf_alloc_space() already sets the 64-bit flag if the BAR size is larger than 4GB, even if the caller did not explicitly request a 64-bit BAR. Thus, let pci_epf_alloc_space() also set the 64-bit flag if the hardware description says that the specific BAR can only be 64-bit. Signed-off-by: Niklas Cassel <cassel@xxxxxxxxxx> --- drivers/pci/endpoint/functions/pci-epf-test.c | 3 ++- drivers/pci/endpoint/pci-epf-core.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 01ba088849cc..8c9802b9b835 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -868,7 +868,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) /* * pci_epf_alloc_space() might have given us a 64-bit BAR, - * if we requested a size larger than 4 GB. + * either because the BAR can only be a 64-bit BAR, or if + * we requested a size larger than 4 GB. */ add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1; } diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 0a28a0b0911b..e7dbbeb1f0de 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -304,9 +304,10 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, epf_bar[bar].addr = space; epf_bar[bar].size = size; epf_bar[bar].barno = bar; - epf_bar[bar].flags |= upper_32_bits(size) ? - PCI_BASE_ADDRESS_MEM_TYPE_64 : - PCI_BASE_ADDRESS_MEM_TYPE_32; + if (upper_32_bits(size) || epc_features->bar[bar].only_64bit) + epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; + else + epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_32; return space; } -- 2.44.0