drm/amdgpu: Prefer shadow rom when available
authorLijo Lazar <lijo.lazar@amd.com>
Tue, 25 Mar 2025 06:12:08 +0000 (11:42 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:47:58 +0000 (10:47 +0200)
commit 27145f78f56a3178c4f9ffe51c4406d8dd0ca90c upstream.

Fetch VBIOS from shadow ROM when available before trying other methods
like EFI method.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Fixes: 9c081c11c621 ("drm/amdgpu: Reorder to read EFI exported ROM first")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4066
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c

index 45affc02548c16bc3a361a654d6f2e73bcc82862..a3a7d20ab4fea9ce7b4a063bddd7647e48760847 100644 (file)
@@ -437,6 +437,13 @@ success:
        return true;
 }
 
+static bool amdgpu_prefer_rom_resource(struct amdgpu_device *adev)
+{
+       struct resource *res = &adev->pdev->resource[PCI_ROM_RESOURCE];
+
+       return (res->flags & IORESOURCE_ROM_SHADOW);
+}
+
 static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
 {
        if (amdgpu_atrm_get_bios(adev)) {
@@ -455,14 +462,27 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
                goto success;
        }
 
-       if (amdgpu_read_platform_bios(adev)) {
-               dev_info(adev->dev, "Fetched VBIOS from platform\n");
-               goto success;
-       }
+       if (amdgpu_prefer_rom_resource(adev)) {
+               if (amdgpu_read_bios(adev)) {
+                       dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n");
+                       goto success;
+               }
 
-       if (amdgpu_read_bios(adev)) {
-               dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n");
-               goto success;
+               if (amdgpu_read_platform_bios(adev)) {
+                       dev_info(adev->dev, "Fetched VBIOS from platform\n");
+                       goto success;
+               }
+
+       } else {
+               if (amdgpu_read_platform_bios(adev)) {
+                       dev_info(adev->dev, "Fetched VBIOS from platform\n");
+                       goto success;
+               }
+
+               if (amdgpu_read_bios(adev)) {
+                       dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n");
+                       goto success;
+               }
        }
 
        if (amdgpu_read_bios_from_rom(adev)) {