]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix lockup accessing config space on G5
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 10 Mar 2004 10:07:03 +0000 (02:07 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 10 Mar 2004 10:07:03 +0000 (02:07 -0800)
This patch fixes the code that workaround lockups when accessing
the config space of devices on K2 when they are shut down. The
code was there but in the wrong place ;) And a typo prevented the
ohci1394 version of it from working.

arch/ppc64/kernel/pmac_feature.c
arch/ppc64/kernel/pmac_pci.c

index a47d2bfe3fdac3880af5655b027ac960da5233d6..dbc94842da3e4572f126d8a745efeacf6a9c9d90 100644 (file)
@@ -221,7 +221,7 @@ static long __pmac g5_fw_enable(struct device_node* node, long param, long value
                mb();
                k2_skiplist[1] = NULL;
        } else {
-               k2_skiplist[0] = pdev;
+               k2_skiplist[1] = pdev;
                mb();
                MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
        }
index 6220ad0ddc80dbb2326ce3cf1e7bf15c468ca704..3a7b57a81baf43bfdff39288cb32b5c89ec8b3a5 100644 (file)
@@ -152,7 +152,6 @@ static int __pmac macrisc_read_config(struct pci_bus *bus, unsigned int devfn,
        struct pci_controller *hose;
        struct device_node *busdn;
        unsigned long addr;
-       int i;
 
        if (bus->self)
                busdn = pci_device_to_OF_node(bus->self);
@@ -164,24 +163,6 @@ static int __pmac macrisc_read_config(struct pci_bus *bus, unsigned int devfn,
        if (hose == NULL)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
-       /*
-        * When a device in K2 is powered down, we die on config
-        * cycle accesses. Fix that here.
-        */
-       for (i=0; i<2; i++)
-               if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
-                   k2_skiplist[i]->devfn == devfn) {
-                       switch (len) {
-                       case 1:
-                               *val = 0xff; break;
-                       case 2:
-                               *val = 0xffff; break;
-                       default:
-                               *val = 0xfffffffful; break;
-                       }
-                       return PCIBIOS_SUCCESSFUL;
-               }
-           
        addr = macrisc_cfg_access(hose, bus->number, devfn, offset);
        if (!addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
@@ -209,7 +190,6 @@ static int __pmac macrisc_write_config(struct pci_bus *bus, unsigned int devfn,
        struct pci_controller *hose;
        struct device_node *busdn;
        unsigned long addr;
-       int i;
 
        if (bus->self)
                busdn = pci_device_to_OF_node(bus->self);
@@ -221,15 +201,6 @@ static int __pmac macrisc_write_config(struct pci_bus *bus, unsigned int devfn,
        if (hose == NULL)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
-       /*
-        * When a device in K2 is powered down, we die on config
-        * cycle accesses. Fix that here.
-        */
-       for (i=0; i<2; i++)
-               if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
-                   k2_skiplist[i]->devfn == devfn)
-                       return PCIBIOS_SUCCESSFUL;
-
        addr = macrisc_cfg_access(hose, bus->number, devfn, offset);
        if (!addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
@@ -265,6 +236,17 @@ static struct pci_ops macrisc_pci_ops =
  * implement self-view of the HT host yet
  */
 
+static int skip_k2_device(struct pci_bus *bus, unsigned int devfn)
+{
+       int i;
+
+       for (i=0; i<2; i++)
+               if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
+                   k2_skiplist[i]->devfn == devfn)
+                       return 1;
+       return 0;
+}
+
 #define U3_HT_CFA0(devfn, off)         \
                ((((unsigned long)devfn) << 8) | offset)
 #define U3_HT_CFA1(bus, devfn, off)    \
@@ -305,6 +287,24 @@ static int __pmac u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
        addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
        if (!addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
+       /*
+        * When a device in K2 is powered down, we die on config
+        * cycle accesses. Fix that here. We may ultimately want
+        * to cache the config space for those instead of returning
+        * 0xffffffff's to make life easier to HW detection tools
+        */
+       if (skip_k2_device(bus, devfn)) {
+               switch (len) {
+               case 1:
+                       *val = 0xff; break;
+               case 2:
+                       *val = 0xffff; break;
+               default:
+                       *val = 0xfffffffful; break;
+               }
+               return PCIBIOS_SUCCESSFUL;
+       }
+
        /*
         * Note: the caller has already checked that offset is
         * suitably aligned and that len is 1, 2 or 4.
@@ -343,6 +343,13 @@ static int __pmac u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
        addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
        if (!addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
+       /*
+        * When a device in K2 is powered down, we die on config
+        * cycle accesses. Fix that here.
+        */
+       if (skip_k2_device(bus, devfn))
+               return PCIBIOS_SUCCESSFUL;
+
        /*
         * Note: the caller has already checked that offset is
         * suitably aligned and that len is 1, 2 or 4.