Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=553aa7659bc0e188348f64e978343ed984eb6e56
Commit:     553aa7659bc0e188348f64e978343ed984eb6e56
Parent:     be8cbcd8896670a01ead7a29e33ffe29604ed734
Author:     Benjamin Herrenschmidt <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 20 14:55:05 2007 +1100
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Thu Dec 20 16:18:16 2007 +1100

    [POWERPC] Disable PCI IO/Mem on a device when resources can't be allocated
    
    This patch changes the PowerPC PCI code to disable IO and/or Memory
    decoding on a PCI device when a resource of that type failed to be
    allocated.  This is done to avoid having unallocated dangling BARs
    enabled that might try to decode on top of other devices.
    
    If a proper resource is assigned later on, then pci_enable_device()
    will take care of re-enabling decoding.
    
    Signed-off-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/pci-common.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 1037b3a..88838b0 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1034,7 +1034,7 @@ clear_resource:
        }
 }
 
-static inline void __devinit alloc_resource(struct pci_dev *dev, int idx)
+static inline int __devinit alloc_resource(struct pci_dev *dev, int idx)
 {
        struct resource *pr, *r = &dev->resource[idx];
 
@@ -1058,7 +1058,10 @@ static inline void __devinit alloc_resource(struct 
pci_dev *dev, int idx)
                r->flags |= IORESOURCE_UNSET;
                r->end -= r->start;
                r->start = 0;
+
+               return -EBUSY;
        }
+       return 0;
 }
 
 static void __init pcibios_allocate_resources(int pass)
@@ -1080,8 +1083,12 @@ static void __init pcibios_allocate_resources(int pass)
                                disabled = !(command & PCI_COMMAND_IO);
                        else
                                disabled = !(command & PCI_COMMAND_MEMORY);
-                       if (pass == disabled)
-                               alloc_resource(dev, idx);
+                       if (pass == disabled && alloc_resource(dev, idx)) {
+                               command &= ~(r->flags & (IORESOURCE_IO |
+                                                        IORESOURCE_MEM));
+                               pci_write_config_word(dev,
+                                                     PCI_COMMAND, command);
+                       }
                }
                if (pass)
                        continue;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to