Merge ../linus
authorDave Jones <davej@redhat.com>
Thu, 29 Jun 2006 20:01:54 +0000 (16:01 -0400)
committerDave Jones <davej@redhat.com>
Thu, 29 Jun 2006 20:01:54 +0000 (16:01 -0400)
Conflicts:

drivers/char/agp/Kconfig

1  2 
drivers/char/agp/Kconfig
drivers/char/agp/amd64-agp.c
drivers/char/agp/ati-agp.c

diff --combined drivers/char/agp/Kconfig
@@@ -1,8 -1,6 +1,7 @@@
  config AGP
-       tristate "/dev/agpgart (AGP Support)" if !GART_IOMMU
+       tristate "/dev/agpgart (AGP Support)"
        depends on ALPHA || IA64 || PPC || X86
-       default y if GART_IOMMU
 +      depends on PCI
        ---help---
          AGP (Accelerated Graphics Port) is a bus system mainly used to
          connect graphics cards to the rest of the system.
@@@ -57,9 -55,9 +56,9 @@@ config AGP_AM
          X on AMD Irongate, 761, and 762 chipsets.
  
  config AGP_AMD64
-       tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU
+       tristate "AMD Opteron/Athlon64 on-CPU GART support" if !IOMMU
        depends on AGP && X86
-       default y if GART_IOMMU
+       default y if IOMMU
        help
          This option gives you AGP support for the GLX component of
          X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
  #include <linux/agp_backend.h>
  #include <linux/mmzone.h>
  #include <asm/page.h>         /* PAGE_SIZE */
+ #include <asm/k8.h>
  #include "agp.h"
  
- /* Will need to be increased if AMD64 ever goes >8-way. */
- #define MAX_HAMMER_GARTS   8
  /* PTE bits. */
  #define GPTE_VALID    1
  #define GPTE_COHERENT 2
  #define ULI_X86_64_HTT_FEA_REG                0x50
  #define ULI_X86_64_ENU_SCR_REG                0x54
  
- static int nr_garts;
- static struct pci_dev * hammers[MAX_HAMMER_GARTS];
  static struct resource *aperture_resource;
  static int __initdata agp_try_unsupported = 1;
  
- #define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
- static void flush_amd64_tlb(struct pci_dev *dev)
- {
-       u32 tmp;
-       pci_read_config_dword (dev, AMD64_GARTCACHECTL, &tmp);
-       tmp |= INVGART;
-       pci_write_config_dword (dev, AMD64_GARTCACHECTL, tmp);
- }
  static void amd64_tlbflush(struct agp_memory *temp)
  {
-       int gart_iterator;
-       for_each_nb()
-               flush_amd64_tlb(hammers[gart_iterator]);
+       k8_flush_garts();
  }
  
  static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
@@@ -153,7 -135,7 +135,7 @@@ static int amd64_fetch_size(void
        u32 temp;
        struct aper_size_info_32 *values;
  
-       dev = hammers[0];
+       dev = k8_northbridges[0];
        if (dev==NULL)
                return 0;
  
@@@ -201,9 -183,6 +183,6 @@@ static u64 amd64_configure (struct pci_
        tmp &= ~(DISGARTCPU | DISGARTIO);
        pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp);
  
-       /* keep CPU's coherent. */
-       flush_amd64_tlb (hammer);
        return aper_base;
  }
  
@@@ -222,13 -201,14 +201,14 @@@ static struct aper_size_info_32 amd_815
  static int amd_8151_configure(void)
  {
        unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
-       int gart_iterator;
+       int i;
  
        /* Configure AGP regs in each x86-64 host bridge. */
-       for_each_nb() {
+         for (i = 0; i < num_k8_northbridges; i++) {
                agp_bridge->gart_bus_addr =
-                               amd64_configure(hammers[gart_iterator],gatt_bus);
+                               amd64_configure(k8_northbridges[i], gatt_bus);
        }
+       k8_flush_garts();
        return 0;
  }
  
  static void amd64_cleanup(void)
  {
        u32 tmp;
-       int gart_iterator;
-       for_each_nb() {
+       int i;
+         for (i = 0; i < num_k8_northbridges; i++) {
+               struct pci_dev *dev = k8_northbridges[i];
                /* disable gart translation */
-               pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp);
+               pci_read_config_dword (dev, AMD64_GARTAPERTURECTL, &tmp);
                tmp &= ~AMD64_GARTEN;
-               pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp);
+               pci_write_config_dword (dev, AMD64_GARTAPERTURECTL, tmp);
        }
  }
  
@@@ -311,7 -292,7 +292,7 @@@ static int __devinit aperture_valid(u6
  /*
   * W*s centric BIOS sometimes only set up the aperture in the AGP
   * bridge, not the northbridge. On AMD64 this is handled early
-  * in aperture.c, but when GART_IOMMU is not enabled or we run
+  * in aperture.c, but when IOMMU is not enabled or we run
   * on a 32bit kernel this needs to be redone.
   * Unfortunately it is impossible to fix the aperture here because it's too late
   * to allocate that much memory. But at least error out cleanly instead of
@@@ -361,17 -342,15 +342,15 @@@ static __devinit int fix_northbridge(st
  
  static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
  {
-       struct pci_dev *loop_dev = NULL;
-       int i = 0;
-       /* cache pci_devs of northbridges. */
-       while ((loop_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev))
-                       != NULL) {
-               if (i == MAX_HAMMER_GARTS) {
-                       printk(KERN_ERR PFX "Too many northbridges for AGP\n");
-                       return -1;
-               }
-               if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) {
+       int i;
+       if (cache_k8_northbridges() < 0)
+               return -ENODEV;
+       i = 0;
+       for (i = 0; i < num_k8_northbridges; i++) {
+               struct pci_dev *dev = k8_northbridges[i];
+               if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
                        printk(KERN_ERR PFX "No usable aperture found.\n");
  #ifdef __x86_64__
                        /* should port this to i386 */
  #endif
                        return -1;
                }
-               hammers[i++] = loop_dev;
        }
-               nr_garts = i;
-       return i == 0 ? -1 : 0;
+       return 0;
  }
  
  /* Handle AMD 8151 quirks */
@@@ -450,7 -427,7 +427,7 @@@ static int __devinit uli_agp_init(struc
        }
  
        /* shadow x86-64 registers into ULi registers */
-       pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &httfea);
+       pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea);
  
        /* if x86-64 aperture base is beyond 4G, exit here */
        if ((httfea & 0x7fff) >> (32 - 25))
@@@ -513,7 -490,7 +490,7 @@@ static int __devinit nforce3_agp_init(s
        pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp);
  
        /* shadow x86-64 registers into NVIDIA registers */
-       pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &apbase);
+       pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase);
  
        /* if x86-64 aperture base is beyond 4G, exit here */
        if ( (apbase & 0x7fff) >> (32 - 25) ) {
@@@ -754,14 -731,10 +731,10 @@@ static struct pci_driver agp_amd64_pci_
  int __init agp_amd64_init(void)
  {
        int err = 0;
-       static struct pci_device_id amd64nb[] = {
-               { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) },
-               { },
-       };
  
        if (agp_off)
                return -EINVAL;
 -      if (pci_register_driver(&agp_amd64_pci_driver) > 0) {
 +      if (pci_register_driver(&agp_amd64_pci_driver) < 0) {
                struct pci_dev *dev;
                if (!agp_try_unsupported && !agp_try_unsupported_boot) {
                        printk(KERN_INFO PFX "No supported AGP bridge found.\n");
                }
  
                /* First check that we have at least one AMD64 NB */
-               if (!pci_dev_present(amd64nb))
+               if (!pci_dev_present(k8_nb_ids))
                        return -ENODEV;
  
                /* Look for any AGP bridge */
@@@ -802,7 -775,7 +775,7 @@@ static void __exit agp_amd64_cleanup(vo
  
  /* On AMD64 the PCI driver needs to initialize this driver early
     for the IOMMU, so it has to be called via a backdoor. */
- #ifndef CONFIG_GART_IOMMU
+ #ifndef CONFIG_IOMMU
  module_init(agp_amd64_init);
  module_exit(agp_amd64_cleanup);
  #endif
@@@ -41,6 -41,7 +41,6 @@@ static struct gatt_mask ati_generic_mas
  };
  
  
 -
  typedef struct _ati_page_map {
        unsigned long *real;
        unsigned long __iomem *remapped;
@@@ -140,8 -141,7 +140,8 @@@ static int ati_create_gatt_pages(int nr
        ati_generic_private.num_tables = nr_tables;
        ati_generic_private.gatt_pages = tables;
  
 -      if (retval != 0) ati_free_gatt_pages();
 +      if (retval != 0)
 +              ati_free_gatt_pages();
  
        return retval;
  }
@@@ -219,16 -219,16 +219,16 @@@ static int ati_configure(void
        ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
  
        if (is_r200())
 -              pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000);
 +              pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000);
        else
                pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000);
  
        /* address to map too */
 -        /*
 +      /*
        pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
        agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
        printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
 -        */
 +      */
        writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID);
        readl(ati_generic_private.registers+ATI_GART_FEATURE_ID);       /* PCI Posting.*/
  
  
  
  #ifdef CONFIG_PM
 -static int agp_ati_resume(struct pci_dev *dev)
 +static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
  {
 -      pci_restore_state(dev);
 +      pci_save_state(dev);
 +      pci_set_power_state(dev, 3);
  
 -      return ati_configure();
 +      return 0;
  }
  
 -static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
 +static int agp_ati_resume(struct pci_dev *dev)
  {
 -      pci_save_state(dev);
 +      pci_set_power_state(dev, 0);
 +      pci_restore_state(dev);
  
 -      return 0;
 +      return ati_configure();
  }
  #endif
  
  /*
-  *Since we don't need contigious memory we just try
+  *Since we don't need contiguous memory we just try
   * to get the gatt table once
   */
  
@@@ -323,9 -321,9 +323,9 @@@ static int ati_remove_memory(struct agp
        unsigned long __iomem *cur_gatt;
        unsigned long addr;
  
 -      if (type != 0 || mem->type != 0) {
 +      if (type != 0 || mem->type != 0)
                return -EINVAL;
 -      }
 +
        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);
@@@ -504,8 -502,9 +504,8 @@@ found
  
        bridge->dev = pdev;
        bridge->capndx = cap_ptr;
 -      
 -      bridge->driver = &ati_generic_bridge;
  
 +      bridge->driver = &ati_generic_bridge;
  
        printk(KERN_INFO PFX "Detected Ati %s chipset\n",
                        devs[j].chipset_name);
@@@ -547,8 -546,8 +547,8 @@@ static struct pci_driver agp_ati_pci_dr
        .probe          = agp_ati_probe,
        .remove         = agp_ati_remove,
  #ifdef CONFIG_PM
 -      .resume         = agp_ati_resume,
        .suspend        = agp_ati_suspend,
 +      .resume         = agp_ati_resume,
  #endif
  };