Skip to content

Commit c7df705

Browse files
ij-intelbjorn-helgaas
authored andcommitted
drm/amdgpu: Use pci_rebar_get_max_size()
Use pci_rebar_get_max_size() to simplify amdgpu_device_resize_fb_bar(). 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-11-ilpo.jarvinen@linux.intel.com
1 parent 46ba95b commit c7df705

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,9 +1673,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
16731673
int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size);
16741674
struct pci_bus *root;
16751675
struct resource *res;
1676+
int max_size, r;
16761677
unsigned int i;
16771678
u16 cmd;
1678-
int r;
16791679

16801680
if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT))
16811681
return 0;
@@ -1721,8 +1721,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
17211721
return 0;
17221722

17231723
/* Limit the BAR size to what is available */
1724-
rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1,
1725-
rbar_size);
1724+
max_size = pci_rebar_get_max_size(adev->pdev, 0);
1725+
if (max_size < 0)
1726+
return 0;
1727+
rbar_size = min(max_size, rbar_size);
17261728

17271729
/* Disable memory decoding while we change the BAR addresses and size */
17281730
pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);

0 commit comments

Comments
 (0)