Skip to content

Commit 29a025b

Browse files
floatiouskwilczynski
authored andcommitted
PCI: endpoint: Allocate a 64-bit BAR if that is the only option
pci_epf_alloc_space() already sets the 64-bit flag if the BAR size is larger than 2GB, 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. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 4176605 commit 29a025b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/pci/endpoint/pci-epf-core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ EXPORT_SYMBOL_GPL(pci_epf_free_space);
255255
* @type: Identifies if the allocation is for primary EPC or secondary EPC
256256
*
257257
* Invoke to allocate memory for the PCI EPF register space.
258+
* Flag PCI_BASE_ADDRESS_MEM_TYPE_64 will automatically get set if the BAR
259+
* can only be a 64-bit BAR, or if the requested size is larger than 2 GB.
258260
*/
259261
void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
260262
const struct pci_epc_features *epc_features,
@@ -304,9 +306,10 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
304306
epf_bar[bar].addr = space;
305307
epf_bar[bar].size = size;
306308
epf_bar[bar].barno = bar;
307-
epf_bar[bar].flags |= upper_32_bits(size) ?
308-
PCI_BASE_ADDRESS_MEM_TYPE_64 :
309-
PCI_BASE_ADDRESS_MEM_TYPE_32;
309+
if (upper_32_bits(size) || epc_features->bar[bar].only_64bit)
310+
epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
311+
else
312+
epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_32;
310313

311314
return space;
312315
}

0 commit comments

Comments
 (0)