]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/ia64/sn/kernel/io_init.c
[IA64-SGI] Small cleanup for misuse of list_for_each to list_for_each_safe.
[karo-tx-linux.git] / arch / ia64 / sn / kernel / io_init.c
index 258d9d7aff98f759d0af721756310d76b4063199..3437c2390429daff50c60e1700dde33e66645198 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/nodemask.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
+#include <asm/sn/sn_feature_sets.h>
 #include <asm/sn/geo.h>
 #include <asm/sn/io.h>
 #include <asm/sn/pcibr_provider.h>
@@ -132,8 +133,8 @@ static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
  * 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)
+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;
@@ -141,7 +142,7 @@ sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
 
        SAL_CALL_NOLOCK(ret_stuff,
                        (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
-                       (u64) segment, (u64) bus_number, (u64) devfn, 
+                       (u64) segment, (u64) bus_number, (u64) devfn,
                        (u64) pci_dev,
                        sn_irq_info, 0, 0);
        return ret_stuff.v0;
@@ -165,11 +166,49 @@ sn_pcidev_info_get(struct pci_dev *dev)
        return NULL;
 }
 
+/* Older PROM flush WAR
+ *
+ * 01/16/06 -- This war will be in place until a new official PROM is released.
+ * 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)
+{
+       struct sn_flush_device_war *war_list;
+       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;
+       }
+
+       war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
+       if (!war_list)
+               BUG();
+
+       SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
+                       nasid, widget, __pa(war_list), 0, 0, 0 ,0);
+       if (isrv.status)
+               panic("sn_device_fixup_war failed: %s\n",
+                     ia64_sal_strerror(isrv.status));
+
+       dev_entry = war_list + device;
+       memcpy(common,dev_entry, sizeof(*common));
+       kfree(war_list);
+
+       return isrv.status;
+}
+
 /*
- * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for 
+ * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for
  *     each node in the system.
  */
-static void sn_fixup_ionodes(void)
+static void __init sn_fixup_ionodes(void)
 {
        struct sn_flush_device_kernel *sn_flush_device_kernel;
        struct sn_flush_device_kernel *dev_entry;
@@ -242,12 +281,21 @@ static void sn_fixup_ionodes(void)
                                memset(dev_entry->common, 0x0, sizeof(struct
                                                       sn_flush_device_common));
 
-                               status = sal_get_device_dmaflush_list(nasid,
-                                                                       widget,
-                                                                       device,
+                               if (sn_prom_feature_available(
+                                                      PRF_DEVICE_FLUSH_LIST))
+                                       status = sal_get_device_dmaflush_list(
+                                                                         nasid,
+                                                                        widget,
+                                                                        device,
                                                      (u64)(dev_entry->common));
-                               if (status)
-                                       BUG();
+                               else
+                                       status = sn_device_fixup_war(nasid,
+                                                                    widget,
+                                                                    device,
+                                                            dev_entry->common);
+                               if (status != SALRET_OK)
+                                       panic("SAL call failed: %s\n",
+                                             ia64_sal_strerror(status));
 
                                spin_lock_init(&dev_entry->sfdl_flush_lock);
                        }
@@ -268,7 +316,7 @@ static void sn_fixup_ionodes(void)
  */
 static void
 sn_pci_window_fixup(struct pci_dev *dev, unsigned int count,
-                   int64_t * pci_addrs)
+                   s64 * pci_addrs)
 {
        struct pci_controller *controller = PCI_CONTROLLER(dev->bus);
        unsigned int i;
@@ -328,7 +376,7 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
        struct pci_bus *host_pci_bus;
        struct pci_dev *host_pci_dev;
        struct pcidev_info *pcidev_info;
-       int64_t pci_addrs[PCI_ROM_RESOURCE + 1];
+       s64 pci_addrs[PCI_ROM_RESOURCE + 1];
        struct sn_irq_info *sn_irq_info;
        unsigned long size;
        unsigned int bus_no, devfn;
@@ -419,6 +467,13 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
                pcidev_info->pdi_sn_irq_info = NULL;
                kfree(sn_irq_info);
        }
+
+       /*
+        * MSI currently not supported on altix.  Remove this when
+        * the MSI abstraction patches are integrated into the kernel
+        * (sometime after 2.6.16 releases)
+        */
+       dev->no_msi = 1;
 }
 
 /*
@@ -562,15 +617,15 @@ void sn_bus_store_sysdata(struct pci_dev *dev)
 void sn_bus_free_sysdata(void)
 {
        struct sysdata_el *element;
-       struct list_head *list;
+       struct list_head *list, *safe;
 
-sn_sysdata_free_start:
-       list_for_each(list, &sn_sysdata_list) {
+       list_for_each_safe(list, safe, &sn_sysdata_list) {
                element = list_entry(list, struct sysdata_el, entry);
                list_del(&element->entry);
+               list_del(&(((struct pcidev_info *)
+                            (element->sysdata))->pdi_list));
                kfree(element->sysdata);
                kfree(element);
-               goto sn_sysdata_free_start;
        }
        return;
 }