Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Move pci_rebar_size_to_bytes() and export it

pci_rebar_size_to_bytes() is in drivers/pci/pci.h but would be useful for
endpoint drivers as well.

Move the function to rebar.c and export it.

In addition, convert the literal to where the number comes from
(PCI_REBAR_MIN_SIZE).

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patch.msgid.link/20251113180053.27944-4-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
a3378698 876e1594

+13 -4
-4
drivers/pci/pci.h
··· 1024 1024 void pci_restore_rebar_state(struct pci_dev *pdev); 1025 1025 int pci_rebar_get_current_size(struct pci_dev *pdev, int bar); 1026 1026 int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size); 1027 - static inline u64 pci_rebar_size_to_bytes(int size) 1028 - { 1029 - return 1ULL << (size + 20); 1030 - } 1031 1027 1032 1028 struct device_node; 1033 1029
+12
drivers/pci/rebar.c
··· 35 35 } 36 36 EXPORT_SYMBOL_GPL(pci_rebar_bytes_to_size); 37 37 38 + /** 39 + * pci_rebar_size_to_bytes - Convert encoded BAR Size to size in bytes 40 + * @size: encoded BAR Size as defined in the PCIe spec (0=1MB, 31=128TB) 41 + * 42 + * Return: BAR size in bytes 43 + */ 44 + resource_size_t pci_rebar_size_to_bytes(int size) 45 + { 46 + return 1ULL << (size + ilog2(PCI_REBAR_MIN_SIZE)); 47 + } 48 + EXPORT_SYMBOL_GPL(pci_rebar_size_to_bytes); 49 + 38 50 void pci_rebar_init(struct pci_dev *pdev) 39 51 { 40 52 pdev->rebar_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
+1
include/linux/pci.h
··· 1422 1422 1423 1423 /* Resizable BAR related routines */ 1424 1424 int pci_rebar_bytes_to_size(u64 bytes); 1425 + resource_size_t pci_rebar_size_to_bytes(int size); 1425 1426 u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar); 1426 1427 int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size, 1427 1428 int exclude_bars);