]> Gentwo Git Trees - linux/.git/commitdiff
drm/amdgpu: Use pci_rebar_get_max_size()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 13 Nov 2025 18:00:52 +0000 (20:00 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 14 Nov 2025 18:34:21 +0000 (12:34 -0600)
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
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index d777454a170a26d689dc00f22b12f963fd0e3aba..9c9b482e7ec2170ce47aa635032a827d1fb3afd6 100644 (file)
@@ -1673,9 +1673,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
        int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size);
        struct pci_bus *root;
        struct resource *res;
+       int max_size, r;
        unsigned int i;
        u16 cmd;
-       int r;
 
        if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT))
                return 0;
@@ -1721,8 +1721,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
                return 0;
 
        /* Limit the BAR size to what is available */
-       rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1,
-                       rbar_size);
+       max_size = pci_rebar_get_max_size(adev->pdev, 0);
+       if (max_size < 0)
+               return 0;
+       rbar_size = min(max_size, rbar_size);
 
        /* Disable memory decoding while we change the BAR addresses and size */
        pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);