aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/agp')
-rw-r--r--drivers/char/agp/amd64-agp.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index e3c7ea07f57c..f5af65ac8c78 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -228,24 +228,10 @@ static const struct agp_bridge_driver amd_8151_driver = {
228}; 228};
229 229
230/* Some basic sanity checks for the aperture. */ 230/* Some basic sanity checks for the aperture. */
231static int __devinit aperture_valid(u64 aper, u32 size) 231static int __devinit agp_aperture_valid(u64 aper, u32 size)
232{ 232{
233 if (aper == 0) { 233 if (!aperture_valid(aper, size, 32*1024*1024))
234 printk(KERN_ERR PFX "No aperture\n");
235 return 0; 234 return 0;
236 }
237 if ((u64)aper + size > 0x100000000ULL) {
238 printk(KERN_ERR PFX "Aperture out of bounds\n");
239 return 0;
240 }
241 if (e820_any_mapped(aper, aper + size, E820_RAM)) {
242 printk(KERN_ERR PFX "Aperture pointing to RAM\n");
243 return 0;
244 }
245 if (size < 32*1024*1024) {
246 printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20);
247 return 0;
248 }
249 235
250 /* Request the Aperture. This catches cases when someone else 236 /* Request the Aperture. This catches cases when someone else
251 already put a mapping in there - happens with some very broken BIOS 237 already put a mapping in there - happens with some very broken BIOS
@@ -282,7 +268,7 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
282 nb_order = (nb_order >> 1) & 7; 268 nb_order = (nb_order >> 1) & 7;
283 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); 269 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base);
284 nb_aper = nb_base << 25; 270 nb_aper = nb_base << 25;
285 if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { 271 if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) {
286 return 0; 272 return 0;
287 } 273 }
288 274
@@ -313,7 +299,7 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
313 } 299 }
314 300
315 printk(KERN_INFO PFX "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order); 301 printk(KERN_INFO PFX "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order);
316 if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order)) 302 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order))
317 return -1; 303 return -1;
318 304
319 pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); 305 pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1);