Skip to contentSkip to conversation

drm/amdgpu: fix vbios fetching for SR-IOV

PATCH In review Alex Deucher 4 participants 4 messages Sep 25, 2024 – Sep 26, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: fix vbios fetching for SR-IOV

SR-IOV fetches the vbios from VRAM in some cases. Re-enable the VRAM path for dGPUs and rename the function to make it clear that it is not IGP specific.

Fixes 042658d17a54 ("drm/amdgpu: clean up vbios fetching code")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +9 -2
index 46bf623919d7c..45affc02548c1 100644
@@ -87,8 +87,9 @@ static bool check_atom_bios(uint8_t *bios, size_t size)
  * part of the system bios.  On boot, the system bios puts a
  * copy of the igp rom at the start of vram if a discrete card is
  * present.
+ * For SR-IOV, the vbios image is also put in VRAM in the VF.
  */
-static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
+static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)
 {
 	uint8_t __iomem *bios;
 	resource_size_t vram_base;
@@ -414,7 +415,7 @@ static bool amdgpu_get_bios_apu(struct amdgpu_device *adev)
 		goto success;
 	}
 
-	if (igp_read_bios_from_vram(adev)) {
+	if (amdgpu_read_bios_from_vram(adev)) {
 		dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
 		goto success;
 	}
@@ -448,6 +449,12 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
 		goto success;
 	}
 
+	/* this is required for SR-IOV */
+	if (amdgpu_read_bios_from_vram(adev)) {
+		dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
+		goto success;
+	}
+
 	if (amdgpu_read_platform_bios(adev)) {
 		dev_info(adev->dev, "Fetched VBIOS from platform\n");
 		goto success;
Signature · 1 line
2.46.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: 2024年9月26日 2:20
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: fix vbios fetching for SR-IOV

SR-IOV fetches the vbios from VRAM in some cases.
Re-enable the VRAM path for dGPUs and rename the function to make it clear that it is not IGP specific.

Fixes 042658d17a54 ("drm/amdgpu: clean up vbios fetching code")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +9 -2
index 46bf623919d7c..45affc02548c1 100644
@@ -87,8 +87,9 @@ static bool check_atom_bios(uint8_t *bios, size_t size)
  * part of the system bios.  On boot, the system bios puts a
  * copy of the igp rom at the start of vram if a discrete card is
  * present.
+ * For SR-IOV, the vbios image is also put in VRAM in the VF.
  */
-static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
+static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)
 {
        uint8_t __iomem *bios;
        resource_size_t vram_base;
@@ -414,7 +415,7 @@ static bool amdgpu_get_bios_apu(struct amdgpu_device *adev)
                goto success;
        }
 
-       if (igp_read_bios_from_vram(adev)) {
+       if (amdgpu_read_bios_from_vram(adev)) {
                dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
                goto success;
        }
@@ -448,6 +449,12 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
                goto success;
        }
 
+       /* this is required for SR-IOV */
+       if (amdgpu_read_bios_from_vram(adev)) {
+               dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
+               goto success;
+       }
+
        if (amdgpu_read_platform_bios(adev)) {
                dev_info(adev->dev, "Fetched VBIOS from platform\n");
                goto success;

--
2.46.1

#2 lore raw
In reply to Alex Deucher
Quoted 35 lines · Alex Deucher

SR-IOV fetches the vbios from VRAM in some cases. Re-enable the VRAM path for dGPUs and rename the function to make it clear that it is not IGP specific.

Fixes 042658d17a54 ("drm/amdgpu: clean up vbios fetching code")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +3 -2
index 46bf623919d7c..45affc02548c1 100644
@@ -87,8 +87,9 @@ static bool check_atom_bios(uint8_t *bios, size_t size)
  * part of the system bios.  On boot, the system bios puts a
  * copy of the igp rom at the start of vram if a discrete card is
  * present.
+ * For SR-IOV, the vbios image is also put in VRAM in the VF.
  */
-static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
+static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)
 {
 	uint8_t __iomem *bios;
 	resource_size_t vram_base;
@@ -414,7 +415,7 @@ static bool amdgpu_get_bios_apu(struct amdgpu_device *adev)
 		goto success;
 	}
 
-	if (igp_read_bios_from_vram(adev)) {
+	if (amdgpu_read_bios_from_vram(adev)) {
 		dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
 		goto success;
 	}

drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev) · line 453

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +2 -0
@@ -448,6 +449,12 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
 		goto success;
 	}
 
+	/* this is required for SR-IOV */
+	if (amdgpu_read_bios_from_vram(adev)) {

If this is only expected for VFs, then it's better to add amdgpu_sriov_vf(adev) check for this call.

Thanks,
Lijo

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +4 -0
+		dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
+		goto success;
+	}
+
 	if (amdgpu_read_platform_bios(adev)) {
 		dev_info(adev->dev, "Fetched VBIOS from platform\n");
 		goto success;
#3 lore raw
Quoted 42 lines · Lijo
Quoted 38 lines · Alex Deucher

SR-IOV fetches the vbios from VRAM in some cases. Re-enable the VRAM path for dGPUs and rename the function to make it clear that it is not IGP specific.

Fixes 042658d17a54 ("drm/amdgpu: clean up vbios fetching code")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +3 -2
index 46bf623919d7c..45affc02548c1 100644
@@ -87,8 +87,9 @@ static bool check_atom_bios(uint8_t *bios, size_t size)
  * part of the system bios.  On boot, the system bios puts a
  * copy of the igp rom at the start of vram if a discrete card is
  * present.
+ * For SR-IOV, the vbios image is also put in VRAM in the VF.
  */
-static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
+static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)
 {
      uint8_t __iomem *bios;
      resource_size_t vram_base;
@@ -414,7 +415,7 @@ static bool amdgpu_get_bios_apu(struct amdgpu_device *adev)
              goto success;
      }
 
-     if (igp_read_bios_from_vram(adev)) {
+     if (amdgpu_read_bios_from_vram(adev)) {
              dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
              goto success;
      }
@@ -448,6 +449,12 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev)
              goto success;
      }
 
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev) · line 453

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +2 -0
+     /* this is required for SR-IOV */
+     if (amdgpu_read_bios_from_vram(adev)) {

If this is only expected for VFs, then it's better to add amdgpu_sriov_vf(adev) check for this call.

I think that is the case, but I'm not 100% sure. I can ask the vbios team.

Alex

Quoted 11 lines

Thanks,
Lijo

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +4 -0
+             dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n");
+             goto success;
+     }
+
      if (amdgpu_read_platform_bios(adev)) {
              dev_info(adev->dev, "Fetched VBIOS from platform\n");
              goto success;