aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sis/sis_main.c
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2010-11-10 06:04:19 -0500
committerPaul Mundt <lethal@linux-sh.org>2010-11-10 06:26:37 -0500
commit32ed3036c56284a720c0c00d92ee14bf609f497d (patch)
treedfde210bb1990a776894e1d2bd214f5a473a5177 /drivers/video/sis/sis_main.c
parent7ac3d3ebf1f6e2051472150092a6d023043dd0f1 (diff)
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>
Diffstat (limited to 'drivers/video/sis/sis_main.c')
-rw-r--r--drivers/video/sis/sis_main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index b52f8e4ef1fd..3dde12b0ab06 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -4181,6 +4181,9 @@ static void __devinit
4181sisfb_post_map_vram(struct sis_video_info *ivideo, unsigned int *mapsize, 4181sisfb_post_map_vram(struct sis_video_info *ivideo, unsigned int *mapsize,
4182 unsigned int min) 4182 unsigned int min)
4183{ 4183{
4184 if (*mapsize < (min << 20))
4185 return;
4186
4184 ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize)); 4187 ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize));
4185 4188
4186 if(!ivideo->video_vbase) { 4189 if(!ivideo->video_vbase) {
@@ -4514,7 +4517,7 @@ sisfb_post_sis300(struct pci_dev *pdev)
4514 } else { 4517 } else {
4515#endif 4518#endif
4516 /* Need to map max FB size for finding out about RAM size */ 4519 /* Need to map max FB size for finding out about RAM size */
4517 mapsize = 64 << 20; 4520 mapsize = ivideo->video_size;
4518 sisfb_post_map_vram(ivideo, &mapsize, 4); 4521 sisfb_post_map_vram(ivideo, &mapsize, 4);
4519 4522
4520 if(ivideo->video_vbase) { 4523 if(ivideo->video_vbase) {
@@ -4680,7 +4683,7 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4680 orSISIDXREG(SISSR, 0x20, (0x80 | 0x04)); 4683 orSISIDXREG(SISSR, 0x20, (0x80 | 0x04));
4681 4684
4682 /* Need to map max FB size for finding out about RAM size */ 4685 /* Need to map max FB size for finding out about RAM size */
4683 mapsize = 256 << 20; 4686 mapsize = ivideo->video_size;
4684 sisfb_post_map_vram(ivideo, &mapsize, 32); 4687 sisfb_post_map_vram(ivideo, &mapsize, 32);
4685 4688
4686 if(!ivideo->video_vbase) { 4689 if(!ivideo->video_vbase) {
@@ -5936,6 +5939,7 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5936 } 5939 }
5937 5940
5938 ivideo->video_base = pci_resource_start(pdev, 0); 5941 ivideo->video_base = pci_resource_start(pdev, 0);
5942 ivideo->video_size = pci_resource_len(pdev, 0);
5939 ivideo->mmio_base = pci_resource_start(pdev, 1); 5943 ivideo->mmio_base = pci_resource_start(pdev, 1);
5940 ivideo->mmio_size = pci_resource_len(pdev, 1); 5944 ivideo->mmio_size = pci_resource_len(pdev, 1);
5941 ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30; 5945 ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30;