x86, k8 nb: Fix boot crash: enable k8_northbridges unconditionally on AMD systems
[safe/jmp/linux-2.6] / drivers / char / agp / ati-agp.c
index 07b4d8f..3b2ecbe 100644 (file)
@@ -269,12 +269,17 @@ static int ati_insert_memory(struct agp_memory * mem,
        int i, j, num_entries;
        unsigned long __iomem *cur_gatt;
        unsigned long addr;
+       int mask_type;
 
        num_entries = A_SIZE_LVL2(agp_bridge->current_size)->num_entries;
 
-       if (type != 0 || mem->type != 0)
+       mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
+       if (mask_type != 0 || type != mem->type)
                return -EINVAL;
 
+       if (mem->page_count == 0)
+               return 0;
+
        if ((pg_start + mem->page_count) > num_entries)
                return -EINVAL;
 
@@ -287,19 +292,21 @@ static int ati_insert_memory(struct agp_memory * mem,
                j++;
        }
 
-       if (mem->is_flushed == FALSE) {
+       if (!mem->is_flushed) {
                /*CACHE_FLUSH(); */
                global_cache_flush();
-               mem->is_flushed = TRUE;
+               mem->is_flushed = true;
        }
 
        for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
                addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
                cur_gatt = GET_GATT(addr);
-               writel(agp_bridge->driver->mask_memory(agp_bridge,
-                       mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr));
-               readl(cur_gatt+GET_GATT_OFF(addr));     /* PCI Posting. */
+               writel(agp_bridge->driver->mask_memory(agp_bridge,      
+                                                      page_to_phys(mem->pages[i]),
+                                                      mem->type),
+                      cur_gatt+GET_GATT_OFF(addr));
        }
+       readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */
        agp_bridge->driver->tlb_flush(mem);
        return 0;
 }
@@ -310,17 +317,22 @@ static int ati_remove_memory(struct agp_memory * mem, off_t pg_start,
        int i;
        unsigned long __iomem *cur_gatt;
        unsigned long addr;
+       int mask_type;
 
-       if (type != 0 || mem->type != 0)
+       mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
+       if (mask_type != 0 || type != mem->type)
                return -EINVAL;
 
+       if (mem->page_count == 0)
+               return 0;
+
        for (i = pg_start; i < (mem->page_count + pg_start); i++) {
                addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr;
                cur_gatt = GET_GATT(addr);
                writel(agp_bridge->scratch_page, cur_gatt+GET_GATT_OFF(addr));
-               readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
        }
 
+       readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */
        agp_bridge->driver->tlb_flush(mem);
        return 0;
 }
@@ -348,7 +360,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
 
        agp_bridge->gatt_table_real = (u32 *)page_dir.real;
        agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped;
-       agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
+       agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
 
        /* Write out the size register */
        current_size = A_SIZE_LVL2(agp_bridge->current_size);
@@ -378,7 +390,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
 
        /* Calculate the agp offset */
        for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
-               writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1,
+               writel(virt_to_phys(ati_generic_private.gatt_pages[i]->real) | 1,
                        page_dir.remapped+GET_PAGE_DIR_OFF(addr));
                readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr));        /* PCI Posting. */
        }
@@ -418,7 +430,9 @@ static const struct agp_bridge_driver ati_generic_bridge = {
        .alloc_by_type          = agp_generic_alloc_by_type,
        .free_by_type           = agp_generic_free_by_type,
        .agp_alloc_page         = agp_generic_alloc_page,
+       .agp_alloc_pages        = agp_generic_alloc_pages,
        .agp_destroy_page       = agp_generic_destroy_page,
+       .agp_destroy_pages      = agp_generic_destroy_pages,
        .agp_type_to_mask_type  = agp_generic_type_to_mask_type,
 };
 
@@ -486,8 +500,8 @@ static int __devinit agp_ati_probe(struct pci_dev *pdev,
                        goto found;
        }
 
-       printk(KERN_ERR PFX
-            "Unsupported Ati chipset (device id: %04x)\n", pdev->device);
+       dev_err(&pdev->dev, "unsupported Ati chipset [%04x/%04x])\n",
+               pdev->vendor, pdev->device);
        return -ENODEV;
 
 found:
@@ -500,8 +514,7 @@ found:
 
        bridge->driver = &ati_generic_bridge;
 
-       printk(KERN_INFO PFX "Detected Ati %s chipset\n",
-                       devs[j].chipset_name);
+       dev_info(&pdev->dev, "Ati %s chipset\n", devs[j].chipset_name);
 
        /* Fill in the mode register */
        pci_read_config_dword(pdev,
@@ -560,6 +573,6 @@ static void __exit agp_ati_cleanup(void)
 module_init(agp_ati_init);
 module_exit(agp_ati_cleanup);
 
-MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
+MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
 MODULE_LICENSE("GPL and additional rights");