]> www.infradead.org Git - nvme.git/commitdiff
drm/amdgpu: Fix vbios version string search
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 14 Sep 2023 09:21:52 +0000 (14:51 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 20 Sep 2023 20:24:06 +0000 (16:24 -0400)
Search for vbios version string in STRING_OFFSET-ATOM_ROM_HEADER region
first. If those offsets are not populated, use the hardcoded region.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/atom.c

index 9f63ddb89b75c1b6ea002a52044a4b93cb5e09d2..2c221000782cdffa5c57aeb2b464db0836895f8c 100644 (file)
@@ -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;