Skip to contentSkip to conversation

drm/amdgpu/nv: add asic func for fetching vbios from rom directly

PATCH In review Alex Deucher 2 participants 3 messages Nov 13, 2019 – Nov 15, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/nv: add asic func for fetching vbios from rom directly

Needed as a fallback if the vbios can't be fetched by other means.

---
 drivers/gpu/drm/amd/amdgpu/nv.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/nv.c +22 -2
index 7283d6198b89..ad04d1d6e9c7 100644
@@ -40,6 +40,7 @@
 #include "gc/gc_10_1_0_sh_mask.h"
 #include "hdp/hdp_5_0_0_offset.h"
 #include "hdp/hdp_5_0_0_sh_mask.h"
+#include "smuio/smuio_11_0_0_offset.h"
 
 #include "soc15.h"
 #include "soc15_common.h"
@@ -156,8 +157,27 @@ static bool nv_read_disabled_bios(struct amdgpu_device *adev)
 static bool nv_read_bios_from_rom(struct amdgpu_device *adev,
 				  u8 *bios, u32 length_bytes)
 {
-	/* TODO: will implement it when SMU header is available */
-	return false;
+	u32 *dw_ptr;
+	u32 i, length_dw;
+
+	if (bios == NULL)
+		return false;
+	if (length_bytes == 0)
+		return false;
+	/* APU vbios image is part of sbios image */
+	if (adev->flags & AMD_IS_APU)
+		return false;
+
+	dw_ptr = (u32 *)bios;
+	length_dw = ALIGN(length_bytes, 4) / 4;
+
+	/* set rom index to 0 */
+	WREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_INDEX), 0);
+	/* read out the rom data */
+	for (i = 0; i < length_dw; i++)
+		dw_ptr[i] = RREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_DATA));
+
+	return true;
 }
 
 static struct soc15_allowed_register_entry nv_allowed_read_registers[] = {
Signature · 6 lines
2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20191113192937.781329-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Ping?

Quoted 51 lines · Alex Deucher

Needed as a fallback if the vbios can't be fetched by other means.

---
 drivers/gpu/drm/amd/amdgpu/nv.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/nv.c +22 -3
index 7283d6198b89..ad04d1d6e9c7 100644
@@ -40,6 +40,7 @@
 #include "gc/gc_10_1_0_sh_mask.h"
 #include "hdp/hdp_5_0_0_offset.h"
 #include "hdp/hdp_5_0_0_sh_mask.h"
+#include "smuio/smuio_11_0_0_offset.h"
 
 #include "soc15.h"
 #include "soc15_common.h"
@@ -156,8 +157,27 @@ static bool nv_read_disabled_bios(struct amdgpu_device *adev)
 static bool nv_read_bios_from_rom(struct amdgpu_device *adev,
                                  u8 *bios, u32 length_bytes)
 {
-       /* TODO: will implement it when SMU header is available */
-       return false;
+       u32 *dw_ptr;
+       u32 i, length_dw;
+
+       if (bios == NULL)
+               return false;
+       if (length_bytes == 0)
+               return false;
+       /* APU vbios image is part of sbios image */
+       if (adev->flags & AMD_IS_APU)
+               return false;
+
+       dw_ptr = (u32 *)bios;
+       length_dw = ALIGN(length_bytes, 4) / 4;
+
+       /* set rom index to 0 */
+       WREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_INDEX), 0);
+       /* read out the rom data */
+       for (i = 0; i < length_dw; i++)
+               dw_ptr[i] = RREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_DATA));
+
+       return true;
 }
 
 static struct soc15_allowed_register_entry nv_allowed_read_registers[] = {
--
Quoted 2 lines

2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_PsEm8mzr_5Ryj24MjdH_0CmuKBwTpHNaskfrLq0p8udw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Reviewed-by Xiaojie Yuan
#4 lore raw

BR,
Xiaojie

Quoted 54 lines · Alex Deucher

Ping?

Quoted 50 lines · Alex Deucher

Needed as a fallback if the vbios can't be fetched by other means.

---
drivers/gpu/drm/amd/amdgpu/nv.c | 24 ++++++++++++++++++++++--

1 file changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/nv.c +22 -2
index 7283d6198b89..ad04d1d6e9c7 100644
@@ -40,6 +40,7 @@
 #include "gc/gc_10_1_0_sh_mask.h"
 #include "hdp/hdp_5_0_0_offset.h"
 #include "hdp/hdp_5_0_0_sh_mask.h"
+#include "smuio/smuio_11_0_0_offset.h"
 
 #include "soc15.h"
 #include "soc15_common.h"
@@ -156,8 +157,27 @@ static bool nv_read_disabled_bios(struct amdgpu_device *adev)
 static bool nv_read_bios_from_rom(struct amdgpu_device *adev,
                                 u8 *bios, u32 length_bytes)
 {
-       /* TODO: will implement it when SMU header is available */
-       return false;
+       u32 *dw_ptr;
+       u32 i, length_dw;
+
+       if (bios == NULL)
+               return false;
+       if (length_bytes == 0)
+               return false;
+       /* APU vbios image is part of sbios image */
+       if (adev->flags & AMD_IS_APU)
+               return false;
+
+       dw_ptr = (u32 *)bios;
+       length_dw = ALIGN(length_bytes, 4) / 4;
+
+       /* set rom index to 0 */
+       WREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_INDEX), 0);
+       /* read out the rom data */
+       for (i = 0; i < length_dw; i++)
+               dw_ptr[i] = RREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_DATA));
+
+       return true;
 }
 
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/nv.c +0 -1
 static struct soc15_allowed_register_entry nv_allowed_read_registers[] = {
--

2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx