include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / char / agp / amd-k7-agp.c
index 603a986..a7637d7 100644 (file)
@@ -6,9 +6,9 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/agp_backend.h>
-#include <linux/gfp.h>
 #include <linux/page-flags.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include "agp.h"
 
 #define AMD_MMBASE     0x14
@@ -44,7 +44,7 @@ static int amd_create_page_map(struct amd_page_map *page_map)
 #ifndef CONFIG_X86
        SetPageReserved(virt_to_page(page_map->real));
        global_cache_flush();
-       page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
+       page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
                                            PAGE_SIZE);
        if (page_map->remapped == NULL) {
                ClearPageReserved(virt_to_page(page_map->real));
@@ -160,7 +160,7 @@ static int amd_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);
 
        /* Get the address for the gart region.
         * This is a bus address even on the alpha, b/c its
@@ -173,7 +173,7 @@ static int amd_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(amd_irongate_private.gatt_pages[i]->real) | 1,
+               writel(virt_to_phys(amd_irongate_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. */
        }
@@ -223,12 +223,14 @@ static int amd_irongate_configure(void)
 
        current_size = A_SIZE_LVL2(agp_bridge->current_size);
 
-       /* Get the memory mapped registers */
-       pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
-       temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
-       amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
-       if (!amd_irongate_private.registers)
-               return -ENOMEM;
+       if (!amd_irongate_private.registers) {
+               /* Get the memory mapped registers */
+               pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
+               temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
+               amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
+               if (!amd_irongate_private.registers)
+                       return -ENOMEM;
+       }
 
        /* Write out the address of the gatt table */
        writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE);
@@ -323,7 +325,9 @@ static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
                addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
                cur_gatt = GET_GATT(addr);
                writel(agp_generic_mask_memory(agp_bridge,
-                       mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr));
+                                              page_to_phys(mem->pages[i]),
+                                              mem->type),
+                      cur_gatt+GET_GATT_OFF(addr));
                readl(cur_gatt+GET_GATT_OFF(addr));     /* PCI Posting. */
        }
        amd_irongate_tlbflush(mem);
@@ -492,6 +496,26 @@ static void __devexit agp_amdk7_remove(struct pci_dev *pdev)
        agp_put_bridge(bridge);
 }
 
+#ifdef CONFIG_PM
+
+static int agp_amdk7_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       pci_save_state(pdev);
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
+       return 0;
+}
+
+static int agp_amdk7_resume(struct pci_dev *pdev)
+{
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+
+       return amd_irongate_driver.configure();
+}
+
+#endif /* CONFIG_PM */
+
 /* must be the same order as name table above */
 static struct pci_device_id agp_amdk7_pci_table[] = {
        {
@@ -528,6 +552,10 @@ static struct pci_driver agp_amdk7_pci_driver = {
        .id_table       = agp_amdk7_pci_table,
        .probe          = agp_amdk7_probe,
        .remove         = agp_amdk7_remove,
+#ifdef CONFIG_PM
+       .suspend        = agp_amdk7_suspend,
+       .resume         = agp_amdk7_resume,
+#endif
 };
 
 static int __init agp_amdk7_init(void)