PCI: Convert BAR sizes bitmasks to u64

PCIe r7.0, sec 7.8.6, defines resizable BAR sizes beyond the currently
supported maximum of 128TB, which will require more than u32 to store the
entire bitmask.

Convert Resizable BAR related functions to use u64 bitmask for BAR sizes to
make the typing more future-proof.

The support for the larger BAR sizes themselves is not added at this point.

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-12-ilpo.jarvinen@linux.intel.com
This commit is contained in:
Ilpo Järvinen 2025-11-13 20:00:53 +02:00 committed by Bjorn Helgaas
parent c7df7059e3
commit bf0a90fc90
5 changed files with 6 additions and 6 deletions

View File

@ -69,7 +69,7 @@ static void resize_vram_bar(struct xe_device *xe)
if (!pci_rebar_size_supported(pdev, LMEM_BAR, rebar_size)) { if (!pci_rebar_size_supported(pdev, LMEM_BAR, rebar_size)) {
drm_info(&xe->drm, drm_info(&xe->drm,
"Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leaving default: %lluMiB\n", "Requested size: %lluMiB is not supported by rebar sizes: 0x%llx. Leaving default: %lluMiB\n",
(u64)pci_rebar_size_to_bytes(rebar_size) >> 20, (u64)pci_rebar_size_to_bytes(rebar_size) >> 20,
pci_rebar_get_possible_sizes(pdev, LMEM_BAR), pci_rebar_get_possible_sizes(pdev, LMEM_BAR),
(u64)current_size >> 20); (u64)current_size >> 20);

View File

@ -1367,7 +1367,7 @@ EXPORT_SYMBOL_GPL(pci_iov_vf_bar_set_size);
u32 pci_iov_vf_bar_get_sizes(struct pci_dev *dev, int resno, int num_vfs) u32 pci_iov_vf_bar_get_sizes(struct pci_dev *dev, int resno, int num_vfs)
{ {
u64 vf_len = pci_resource_len(dev, resno); u64 vf_len = pci_resource_len(dev, resno);
u32 sizes; u64 sizes;
if (!num_vfs) if (!num_vfs)
return 0; return 0;

View File

@ -1587,7 +1587,7 @@ static ssize_t __resource_resize_show(struct device *dev, int n, char *buf)
pci_config_pm_runtime_get(pdev); pci_config_pm_runtime_get(pdev);
ret = sysfs_emit(buf, "%016llx\n", ret = sysfs_emit(buf, "%016llx\n",
(u64)pci_rebar_get_possible_sizes(pdev, n)); pci_rebar_get_possible_sizes(pdev, n));
pci_config_pm_runtime_put(pdev); pci_config_pm_runtime_put(pdev);

View File

@ -105,7 +105,7 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
* Return: A bitmask of possible sizes (bit 0=1MB, bit 31=128TB), or %0 if * Return: A bitmask of possible sizes (bit 0=1MB, bit 31=128TB), or %0 if
* BAR isn't resizable. * BAR isn't resizable.
*/ */
u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) u64 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
{ {
int pos; int pos;
u32 cap; u32 cap;
@ -155,7 +155,7 @@ EXPORT_SYMBOL_GPL(pci_rebar_size_supported);
*/ */
int pci_rebar_get_max_size(struct pci_dev *pdev, int bar) int pci_rebar_get_max_size(struct pci_dev *pdev, int bar)
{ {
u32 sizes; u64 sizes;
sizes = pci_rebar_get_possible_sizes(pdev, bar); sizes = pci_rebar_get_possible_sizes(pdev, bar);
if (!sizes) if (!sizes)

View File

@ -1423,7 +1423,7 @@ int pci_release_resource(struct pci_dev *dev, int resno);
/* Resizable BAR related routines */ /* Resizable BAR related routines */
int pci_rebar_bytes_to_size(u64 bytes); int pci_rebar_bytes_to_size(u64 bytes);
resource_size_t pci_rebar_size_to_bytes(int size); resource_size_t pci_rebar_size_to_bytes(int size);
u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar); u64 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar);
bool pci_rebar_size_supported(struct pci_dev *pdev, int bar, int size); bool pci_rebar_size_supported(struct pci_dev *pdev, int bar, int size);
int pci_rebar_get_max_size(struct pci_dev *pdev, int bar); int pci_rebar_get_max_size(struct pci_dev *pdev, int bar);
int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size, int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size,