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