sisfb: limit POST memory test according to PCI resource length

If the POST memory test fails, the driver may access illegal
memory areas. Instead of hard coding the maximum size, set it
according to the PCI resource length (an additional check is needed in
sisfb_post_map_vram() to ensure it's big enough). DRAM sizing will later
adjust video_size to the correct value.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Thomas Winischhofer <thomas@winischhofer.net>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Aaro Koskinen and committed by
Paul Mundt
32ed3036 7ac3d3eb

+6 -2
+6 -2
drivers/video/sis/sis_main.c
··· 4181 4181 sisfb_post_map_vram(struct sis_video_info *ivideo, unsigned int *mapsize, 4182 4182 unsigned int min) 4183 4183 { 4184 + if (*mapsize < (min << 20)) 4185 + return; 4186 + 4184 4187 ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize)); 4185 4188 4186 4189 if(!ivideo->video_vbase) { ··· 4517 4514 } else { 4518 4515 #endif 4519 4516 /* Need to map max FB size for finding out about RAM size */ 4520 - mapsize = 64 << 20; 4517 + mapsize = ivideo->video_size; 4521 4518 sisfb_post_map_vram(ivideo, &mapsize, 4); 4522 4519 4523 4520 if(ivideo->video_vbase) { ··· 4683 4680 orSISIDXREG(SISSR, 0x20, (0x80 | 0x04)); 4684 4681 4685 4682 /* Need to map max FB size for finding out about RAM size */ 4686 - mapsize = 256 << 20; 4683 + mapsize = ivideo->video_size; 4687 4684 sisfb_post_map_vram(ivideo, &mapsize, 32); 4688 4685 4689 4686 if(!ivideo->video_vbase) { ··· 5939 5936 } 5940 5937 5941 5938 ivideo->video_base = pci_resource_start(pdev, 0); 5939 + ivideo->video_size = pci_resource_len(pdev, 0); 5942 5940 ivideo->mmio_base = pci_resource_start(pdev, 1); 5943 5941 ivideo->mmio_size = pci_resource_len(pdev, 1); 5944 5942 ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30;