Skip to contentSkip to conversation

drm/amdgpu: Fix vbios version string search

PATCH In review Lijo Lazar 2 participants 2 messages Sep 14, 2023

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix vbios version string search

Search for vbios version string in STRING_OFFSET-ATOM_ROM_HEADER region first. If those offsets are not populated, use the hardcoded region.

---
 drivers/gpu/drm/amd/amdgpu/atom.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/atom.c +18 -1
index 9f63ddb89b75..2c221000782c 100644
@@ -1444,10 +1444,27 @@ static void atom_get_vbios_pn(struct atom_context *ctx)
 
 static void atom_get_vbios_version(struct atom_context *ctx)
 {
+	unsigned short start = 3, end;
 	unsigned char *vbios_ver;
+	unsigned char *p_rom;
+
+	p_rom = ctx->bios;
+	/* Search from strings offset if it's present */
+	start = *(unsigned short *)(p_rom +
+				    OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+	/* Search till atom rom header start point */
+	end = *(unsigned short *)(p_rom + OFFSET_TO_ATOM_ROM_HEADER_POINTER);
+
+	/* Use hardcoded offsets, if the offsets are not populated */
+	if (end <= start) {
+		start = 3;
+		end = 1024;
+	}
 
 	/* find anchor ATOMBIOSBK-AMD */
-	vbios_ver = atom_find_str_in_rom(ctx, BIOS_VERSION_PREFIX, 3, 1024, 64);
+	vbios_ver =
+		atom_find_str_in_rom(ctx, BIOS_VERSION_PREFIX, start, end, 64);
 	if (vbios_ver != NULL) {
 		/* skip ATOMBIOSBK-AMD VER */
 		vbios_ver += 18;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Regards,
Hawking
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, September 14, 2023 17:24
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix vbios version string search

Search for vbios version string in STRING_OFFSET-ATOM_ROM_HEADER region first. If those offsets are not populated, use the hardcoded region.

---
 drivers/gpu/drm/amd/amdgpu/atom.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/atom.c +18 -2
index 9f63ddb89b75..2c221000782c 100644
@@ -1444,10 +1444,27 @@ static void atom_get_vbios_pn(struct atom_context *ctx)
 
 static void atom_get_vbios_version(struct atom_context *ctx)  {
+       unsigned short start = 3, end;
        unsigned char *vbios_ver;
+       unsigned char *p_rom;
+
+       p_rom = ctx->bios;
+       /* Search from strings offset if it's present */
+       start = *(unsigned short *)(p_rom +
+                                   OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+       /* Search till atom rom header start point */
+       end = *(unsigned short *)(p_rom + OFFSET_TO_ATOM_ROM_HEADER_POINTER);
+
+       /* Use hardcoded offsets, if the offsets are not populated */
+       if (end <= start) {
+               start = 3;
+               end = 1024;
+       }
 
        /* find anchor ATOMBIOSBK-AMD */
-       vbios_ver = atom_find_str_in_rom(ctx, BIOS_VERSION_PREFIX, 3, 1024, 64);
+       vbios_ver =
+               atom_find_str_in_rom(ctx, BIOS_VERSION_PREFIX, start, end, 64);
        if (vbios_ver != NULL) {
                /* skip ATOMBIOSBK-AMD VER */
                vbios_ver += 18;
--

2.25.1