x86/agp: tighten check to update amd nb aperture
[sfrench/cifs-2.6.git] / drivers / char / agp / amd64-agp.c
index 52f4361eb6e41fde34a1e6fa53d981725a3485bd..d765afda9c2abb93c4985466fccd86cc2a382982 100644 (file)
@@ -271,15 +271,15 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
        nb_order = (nb_order >> 1) & 7;
        pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base);
        nb_aper = nb_base << 25;
-       if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) {
-               return 0;
-       }
 
        /* Northbridge seems to contain crap. Try the AGP bridge. */
 
        pci_read_config_word(agp, cap+0x14, &apsize);
-       if (apsize == 0xffff)
+       if (apsize == 0xffff) {
+               if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order))
+                       return 0;
                return -1;
+       }
 
        apsize &= 0xfff;
        /* Some BIOS use weird encodings not in the AGPv3 table. */
@@ -301,6 +301,11 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
                order = nb_order;
        }
 
+       if (nb_order >= order) {
+               if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order))
+                       return 0;
+       }
+
        dev_info(&agp->dev, "aperture from AGP @ %Lx size %u MB\n",
                 aper, 32 << order);
        if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order))