include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / ia64 / sn / kernel / io_common.c
index d4dd8f4..4433dd0 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/sn_feature_sets.h>
 
 extern void sn_init_cpei_timer(void);
 extern void register_sn_procfs(void);
-extern void sn_acpi_bus_fixup(struct pci_bus *);
-extern void sn_bus_fixup(struct pci_bus *);
-extern void sn_acpi_slot_fixup(struct pci_dev *, struct pcidev_info *);
-extern void sn_more_slot_fixup(struct pci_dev *, struct pcidev_info *);
-extern void sn_legacy_pci_window_fixup(struct pci_controller *, u64, u64);
 extern void sn_io_acpi_init(void);
 extern void sn_io_init(void);
 
@@ -48,6 +44,9 @@ struct sysdata_el {
 
 int sn_ioif_inited;            /* SN I/O infrastructure initialized? */
 
+int sn_acpi_rev;               /* SN ACPI revision */
+EXPORT_SYMBOL_GPL(sn_acpi_rev);
+
 struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES];      /* indexed by asic type */
 
 /*
@@ -99,25 +98,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
 }
 
 /*
- * Retrieve the pci device information given the bus and device|function number.
- */
-static inline u64
-sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
-                   u64 sn_irq_info)
-{
-       struct ia64_sal_retval ret_stuff;
-       ret_stuff.status = 0;
-       ret_stuff.v0 = 0;
-
-       SAL_CALL_NOLOCK(ret_stuff,
-                       (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
-                       (u64) segment, (u64) bus_number, (u64) devfn,
-                       (u64) pci_dev,
-                       sn_irq_info, 0, 0);
-       return ret_stuff.v0;
-}
-
-/*
  * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
  *                       device.
  */
@@ -140,7 +120,6 @@ sn_pcidev_info_get(struct pci_dev *dev)
  * Additionally note that the struct sn_flush_device_war also has to be
  * removed from arch/ia64/sn/include/xtalk/hubdev.h
  */
-static u8 war_implemented = 0;
 
 static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
                               struct sn_flush_device_common *common)
@@ -149,15 +128,11 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
        struct sn_flush_device_war *dev_entry;
        struct ia64_sal_retval isrv = {0,0,0,0};
 
-       if (!war_implemented) {
-               printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
-                      "PROM flush WAR\n");
-               war_implemented = 1;
-       }
+       printk_once(KERN_WARNING
+               "PROM version < 4.50 -- implementing old PROM flush WAR\n");
 
        war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
-       if (!war_list)
-               BUG();
+       BUG_ON(!war_list);
 
        SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
                        nasid, widget, __pa(war_list), 0, 0, 0 ,0);
@@ -201,23 +176,20 @@ sn_common_hubdev_init(struct hubdev_info *hubdev)
                sizeof(struct sn_flush_device_kernel *);
        hubdev->hdi_flush_nasid_list.widget_p =
                kzalloc(size, GFP_KERNEL);
-       if (!hubdev->hdi_flush_nasid_list.widget_p)
-               BUG();
+       BUG_ON(!hubdev->hdi_flush_nasid_list.widget_p);
 
        for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
                size = DEV_PER_WIDGET *
                        sizeof(struct sn_flush_device_kernel);
                sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
-               if (!sn_flush_device_kernel)
-                       BUG();
+               BUG_ON(!sn_flush_device_kernel);
 
                dev_entry = sn_flush_device_kernel;
                for (device = 0; device < DEV_PER_WIDGET;
                     device++, dev_entry++) {
                        size = sizeof(struct sn_flush_device_common);
                        dev_entry->common = kzalloc(size, GFP_KERNEL);
-                       if (!dev_entry->common)
-                               BUG();
+                       BUG_ON(!dev_entry->common);
                        if (sn_prom_feature_available(PRF_DEVICE_FLUSH_LIST))
                                status = sal_get_device_dmaflush_list(
                                             hubdev->hdi_nasid, widget, device,
@@ -249,50 +221,25 @@ void sn_pci_unfixup_slot(struct pci_dev *dev)
 }
 
 /*
- * sn_pci_fixup_slot() - This routine sets up a slot's resources consistent
- *                      with the Linux PCI abstraction layer. Resources
- *                      acquired from our PCI provider include PIO maps
- *                      to BAR space and interrupt objects.
+ * sn_pci_fixup_slot()
  */
-void sn_pci_fixup_slot(struct pci_dev *dev)
+void sn_pci_fixup_slot(struct pci_dev *dev, struct pcidev_info *pcidev_info,
+                      struct sn_irq_info *sn_irq_info)
 {
        int segment = pci_domain_nr(dev->bus);
-       int status = 0;
        struct pcibus_bussoft *bs;
-       struct pci_bus *host_pci_bus;
-       struct pci_dev *host_pci_dev;
-       struct pcidev_info *pcidev_info;
-       struct sn_irq_info *sn_irq_info;
-       unsigned int bus_no, devfn;
+       struct pci_bus *host_pci_bus;
+       struct pci_dev *host_pci_dev;
+       unsigned int bus_no, devfn;
 
        pci_dev_get(dev); /* for the sysdata pointer */
-       pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
-       if (!pcidev_info)
-               BUG();          /* Cannot afford to run out of memory */
-
-       sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
-       if (!sn_irq_info)
-               BUG();          /* Cannot afford to run out of memory */
-
-       /* Call to retrieve pci device information needed by kernel. */
-       status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
-                                    dev->devfn,
-                                    (u64) __pa(pcidev_info),
-                                    (u64) __pa(sn_irq_info));
-       if (status)
-               BUG(); /* Cannot get platform pci device information */
 
        /* Add pcidev_info to list in pci_controller.platform_data */
        list_add_tail(&pcidev_info->pdi_list,
                      &(SN_PLATFORM_DATA(dev->bus)->pcidev_info));
-
-       if (SN_ACPI_BASE_SUPPORT())
-               sn_acpi_slot_fixup(dev, pcidev_info);
-       else
-               sn_more_slot_fixup(dev, pcidev_info);
        /*
         * Using the PROMs values for the PCI host bus, get the Linux
-        * PCI host_pci_dev struct and set up host bus linkages
+        * PCI host_pci_dev struct and set up host bus linkages
         */
 
        bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
@@ -372,8 +319,7 @@ sn_common_bus_fixup(struct pci_bus *bus,
         */
        controller->platform_data = kzalloc(sizeof(struct sn_platform_data),
                                            GFP_KERNEL);
-       if (controller->platform_data == NULL)
-               BUG();
+       BUG_ON(controller->platform_data == NULL);
        sn_platform_data =
                        (struct sn_platform_data *) controller->platform_data;
        sn_platform_data->provider_soft = provider_soft;
@@ -392,8 +338,8 @@ sn_common_bus_fixup(struct pci_bus *bus,
        if (controller->node >= num_online_nodes()) {
                struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
 
-               printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
-                      "L_IO=%lx L_MEM=%lx BASE=%lx\n",
+               printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u "
+                      "L_IO=%llx L_MEM=%llx BASE=%llx\n",
                       b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
                       b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
                printk(KERN_WARNING "on node %d but only %d nodes online."
@@ -409,7 +355,7 @@ void sn_bus_store_sysdata(struct pci_dev *dev)
 
        element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
        if (!element) {
-               dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__);
+               dev_dbg(&dev->dev, "%s: out of memory!\n", __func__);
                return;
        }
        element->sysdata = SN_PCIDEV_INFO(dev);
@@ -436,7 +382,7 @@ void sn_bus_free_sysdata(void)
  * hubdev_init_node() - Creates the HUB data structure and link them to it's
  *                     own NODE specific data area.
  */
-void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
+void __init hubdev_init_node(nodepda_t * npda, cnodeid_t node)
 {
        struct hubdev_info *hubdev_info;
        int size;
@@ -486,14 +432,10 @@ void sn_generate_path(struct pci_bus *pci_bus, char *address)
        bricktype = MODULE_GET_BTYPE(moduleid);
        if ((bricktype == L1_BRICKTYPE_191010) ||
            (bricktype == L1_BRICKTYPE_1932))
-                       sprintf(address, "%s^%d", address, geo_slot(geoid));
+                       sprintf(address + strlen(address), "^%d",
+                                               geo_slot(geoid));
 }
 
-/*
- * sn_pci_fixup_bus() - Perform SN specific setup of software structs
- *                     (pcibus_bussoft, pcidev_info) and hardware
- *                     registers, for the specified bus and devices under it.
- */
 void __devinit
 sn_pci_fixup_bus(struct pci_bus *bus)
 {
@@ -519,8 +461,17 @@ sn_io_early_init(void)
        if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
                return 0;
 
+       /* we set the acpi revision to that of the DSDT table OEM rev. */
+       {
+               struct acpi_table_header *header = NULL;
+
+               acpi_get_table(ACPI_SIG_DSDT, 1, &header);
+               BUG_ON(header == NULL);
+               sn_acpi_rev = header->oem_revision;
+       }
+
        /*
-        * prime sn_pci_provider[].  Individial provider init routines will
+        * prime sn_pci_provider[].  Individual provider init routines will
         * override their respective default entries.
         */
 
@@ -544,8 +495,12 @@ sn_io_early_init(void)
        register_sn_procfs();
 #endif
 
-       printk(KERN_INFO "ACPI  DSDT OEM Rev 0x%x\n",
-              acpi_gbl_DSDT->oem_revision);
+       {
+               struct acpi_table_header *header;
+               (void)acpi_get_table(ACPI_SIG_DSDT, 1, &header);
+               printk(KERN_INFO "ACPI  DSDT OEM Rev 0x%x\n",
+                       header->oem_revision);
+       }
        if (SN_ACPI_BASE_SUPPORT())
                sn_io_acpi_init();
        else
@@ -582,19 +537,18 @@ sn_io_late_init(void)
                nasid = NASID_GET(bussoft->bs_base);
                cnode = nasid_to_cnodeid(nasid);
                if ((bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) ||
-                   (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCE)) {
-                       /* TIO PCI Bridge: find nearest node with CPUs */
+                   (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCE) ||
+                   (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_PIC)) {
+                       /* PCI Bridge: find nearest node with CPUs */
                        int e = sn_hwperf_get_nearest_node(cnode, NULL,
                                                           &near_cnode);
                        if (e < 0) {
                                near_cnode = (cnodeid_t)-1; /* use any node */
-                               printk(KERN_WARNING "pcibr_bus_fixup: failed "
-                                      "to find near node with CPUs to TIO "
+                               printk(KERN_WARNING "sn_io_late_init: failed "
+                                      "to find near node with CPUs for "
                                       "node %d, err=%d\n", cnode, e);
                        }
                        PCI_CONTROLLER(bus)->node = near_cnode;
-               } else if (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_PIC) {
-                       PCI_CONTROLLER(bus)->node = cnode;
                }
        }
 
@@ -605,7 +559,6 @@ sn_io_late_init(void)
 
 fs_initcall(sn_io_late_init);
 
-EXPORT_SYMBOL(sn_pci_fixup_slot);
 EXPORT_SYMBOL(sn_pci_unfixup_slot);
 EXPORT_SYMBOL(sn_bus_store_sysdata);
 EXPORT_SYMBOL(sn_bus_free_sysdata);