drm/nouveau/bios/vpstate: There are some fermi vbios with no boost or tdp entry
authorKarol Herbst <karolherbst@gmail.com>
Sat, 14 Jul 2018 10:52:08 +0000 (12:52 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 16 Jul 2018 08:06:29 +0000 (18:06 +1000)
If the entry size is too small, default to invalid values for both
boost_id and tdp_id, so as to default to the base clock in both cases.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/bios/vpstate.c

index 20b6fc8243e0aa1a9d3e8b9228c952617e908745..71524548de32cc5b87e881b78893732230d77f6f 100644 (file)
@@ -58,8 +58,14 @@ nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h)
                h->ecount   = nvbios_rd08(b, h->offset + 0x5);
 
                h->base_id  = nvbios_rd08(b, h->offset + 0x0f);
-               h->boost_id = nvbios_rd08(b, h->offset + 0x10);
-               h->tdp_id   = nvbios_rd08(b, h->offset + 0x11);
+               if (h->hlen > 0x10)
+                       h->boost_id = nvbios_rd08(b, h->offset + 0x10);
+               else
+                       h->boost_id = 0xff;
+               if (h->hlen > 0x11)
+                       h->tdp_id = nvbios_rd08(b, h->offset + 0x11);
+               else
+                       h->tdp_id = 0xff;
                return 0;
        default:
                return -EINVAL;