Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau/pm: translate ramcfg strap through ram restrict table

Hopefully this is how we're supposed to correctly handle when the RAMCFG
strap is above the number of entries in timing-related tables.

It's rather difficult to confirm without finding a configuration where
the ram restrict table doesn't map 8-15 back onto 0-7 anyway. There's
not a single vbios in the repo which is configured differently..

In any case, this is probably still better than potentially reading
outside of the bounds of various tables..

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

+4 -2
+4 -2
drivers/gpu/drm/nouveau/nouveau_perf.c
··· 116 116 entries = tmap[4]; 117 117 } 118 118 119 - ramcfg = nv_rd32(dev, NV_PEXTDEV_BOOT_0) & 0x0000003c; 120 - ramcfg >>= 2; 119 + ramcfg = (nv_rd32(dev, NV_PEXTDEV_BOOT_0) & 0x0000003c) >> 2; 120 + if (bios->ram_restrict_tbl_ptr) 121 + ramcfg = bios->data[bios->ram_restrict_tbl_ptr + ramcfg]; 122 + 121 123 if (ramcfg >= entries) { 122 124 NV_WARN(dev, "ramcfg strap out of bounds!\n"); 123 125 return NULL;