diff options
author | Linas Vepstas <linas@linas.org> | 2005-11-03 19:48:45 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-09 19:33:07 -0500 |
commit | 56b0fca3a008ddec8c00cfdddbef17bd9ce188e3 (patch) | |
tree | cc4138445bd5f65a59c7d2f68ab5169dceb1766f | |
parent | 693765021460f19c5d7c638eb76e2efe1cd84752 (diff) |
[PATCH] ppc64: PCI address cache minor fixes
03-eeh-addr-cache-cleanup.patch
This is a minor patch to clean up a buglet related to the PCI address cache.
(The buglet doesn't manifes itself unless there are also bugs elsewhere,
which is why its minor.). Also:
-- Improved debug printing.
-- Declare some private routines as static
-- Adds reference counting to struct pci_dn->pcidev structure
Signed-off-by: Linas Vepstas <linas@linas.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/ppc64/kernel/eeh.c | 33 | ||||
-rw-r--r-- | include/asm-powerpc/ppc-pci.h | 4 |
2 files changed, 26 insertions, 11 deletions
diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c index bb11569d2b4b..99f11b66b5a0 100644 --- a/arch/ppc64/kernel/eeh.c +++ b/arch/ppc64/kernel/eeh.c | |||
@@ -219,9 +219,9 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, | |||
219 | while (*p) { | 219 | while (*p) { |
220 | parent = *p; | 220 | parent = *p; |
221 | piar = rb_entry(parent, struct pci_io_addr_range, rb_node); | 221 | piar = rb_entry(parent, struct pci_io_addr_range, rb_node); |
222 | if (alo < piar->addr_lo) { | 222 | if (ahi < piar->addr_lo) { |
223 | p = &parent->rb_left; | 223 | p = &parent->rb_left; |
224 | } else if (ahi > piar->addr_hi) { | 224 | } else if (alo > piar->addr_hi) { |
225 | p = &parent->rb_right; | 225 | p = &parent->rb_right; |
226 | } else { | 226 | } else { |
227 | if (dev != piar->pcidev || | 227 | if (dev != piar->pcidev || |
@@ -240,6 +240,11 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, | |||
240 | piar->pcidev = dev; | 240 | piar->pcidev = dev; |
241 | piar->flags = flags; | 241 | piar->flags = flags; |
242 | 242 | ||
243 | #ifdef DEBUG | ||
244 | printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", | ||
245 | alo, ahi, pci_name (dev)); | ||
246 | #endif | ||
247 | |||
243 | rb_link_node(&piar->rb_node, parent, p); | 248 | rb_link_node(&piar->rb_node, parent, p); |
244 | rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root); | 249 | rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root); |
245 | 250 | ||
@@ -301,7 +306,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) | |||
301 | * we maintain a cache of devices that can be quickly searched. | 306 | * we maintain a cache of devices that can be quickly searched. |
302 | * This routine adds a device to that cache. | 307 | * This routine adds a device to that cache. |
303 | */ | 308 | */ |
304 | void pci_addr_cache_insert_device(struct pci_dev *dev) | 309 | static void pci_addr_cache_insert_device(struct pci_dev *dev) |
305 | { | 310 | { |
306 | unsigned long flags; | 311 | unsigned long flags; |
307 | 312 | ||
@@ -344,7 +349,7 @@ restart: | |||
344 | * the tree multiple times (once per resource). | 349 | * the tree multiple times (once per resource). |
345 | * But so what; device removal doesn't need to be that fast. | 350 | * But so what; device removal doesn't need to be that fast. |
346 | */ | 351 | */ |
347 | void pci_addr_cache_remove_device(struct pci_dev *dev) | 352 | static void pci_addr_cache_remove_device(struct pci_dev *dev) |
348 | { | 353 | { |
349 | unsigned long flags; | 354 | unsigned long flags; |
350 | 355 | ||
@@ -366,6 +371,9 @@ void __init pci_addr_cache_build(void) | |||
366 | { | 371 | { |
367 | struct pci_dev *dev = NULL; | 372 | struct pci_dev *dev = NULL; |
368 | 373 | ||
374 | if (!eeh_subsystem_enabled) | ||
375 | return; | ||
376 | |||
369 | spin_lock_init(&pci_io_addr_cache_root.piar_lock); | 377 | spin_lock_init(&pci_io_addr_cache_root.piar_lock); |
370 | 378 | ||
371 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 379 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
@@ -837,7 +845,7 @@ void eeh_add_device_early(struct device_node *dn) | |||
837 | info.buid_lo = BUID_LO(phb->buid); | 845 | info.buid_lo = BUID_LO(phb->buid); |
838 | early_enable_eeh(dn, &info); | 846 | early_enable_eeh(dn, &info); |
839 | } | 847 | } |
840 | EXPORT_SYMBOL(eeh_add_device_early); | 848 | EXPORT_SYMBOL_GPL(eeh_add_device_early); |
841 | 849 | ||
842 | /** | 850 | /** |
843 | * eeh_add_device_late - perform EEH initialization for the indicated pci device | 851 | * eeh_add_device_late - perform EEH initialization for the indicated pci device |
@@ -848,6 +856,8 @@ EXPORT_SYMBOL(eeh_add_device_early); | |||
848 | */ | 856 | */ |
849 | void eeh_add_device_late(struct pci_dev *dev) | 857 | void eeh_add_device_late(struct pci_dev *dev) |
850 | { | 858 | { |
859 | struct device_node *dn; | ||
860 | |||
851 | if (!dev || !eeh_subsystem_enabled) | 861 | if (!dev || !eeh_subsystem_enabled) |
852 | return; | 862 | return; |
853 | 863 | ||
@@ -855,9 +865,13 @@ void eeh_add_device_late(struct pci_dev *dev) | |||
855 | printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev)); | 865 | printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev)); |
856 | #endif | 866 | #endif |
857 | 867 | ||
868 | pci_dev_get (dev); | ||
869 | dn = pci_device_to_OF_node(dev); | ||
870 | PCI_DN(dn)->pcidev = dev; | ||
871 | |||
858 | pci_addr_cache_insert_device (dev); | 872 | pci_addr_cache_insert_device (dev); |
859 | } | 873 | } |
860 | EXPORT_SYMBOL(eeh_add_device_late); | 874 | EXPORT_SYMBOL_GPL(eeh_add_device_late); |
861 | 875 | ||
862 | /** | 876 | /** |
863 | * eeh_remove_device - undo EEH setup for the indicated pci device | 877 | * eeh_remove_device - undo EEH setup for the indicated pci device |
@@ -868,6 +882,7 @@ EXPORT_SYMBOL(eeh_add_device_late); | |||
868 | */ | 882 | */ |
869 | void eeh_remove_device(struct pci_dev *dev) | 883 | void eeh_remove_device(struct pci_dev *dev) |
870 | { | 884 | { |
885 | struct device_node *dn; | ||
871 | if (!dev || !eeh_subsystem_enabled) | 886 | if (!dev || !eeh_subsystem_enabled) |
872 | return; | 887 | return; |
873 | 888 | ||
@@ -876,8 +891,12 @@ void eeh_remove_device(struct pci_dev *dev) | |||
876 | printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev)); | 891 | printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev)); |
877 | #endif | 892 | #endif |
878 | pci_addr_cache_remove_device(dev); | 893 | pci_addr_cache_remove_device(dev); |
894 | |||
895 | dn = pci_device_to_OF_node(dev); | ||
896 | PCI_DN(dn)->pcidev = NULL; | ||
897 | pci_dev_put (dev); | ||
879 | } | 898 | } |
880 | EXPORT_SYMBOL(eeh_remove_device); | 899 | EXPORT_SYMBOL_GPL(eeh_remove_device); |
881 | 900 | ||
882 | static int proc_eeh_show(struct seq_file *m, void *v) | 901 | static int proc_eeh_show(struct seq_file *m, void *v) |
883 | { | 902 | { |
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h index 302f0a9878c7..c47146f74a7b 100644 --- a/include/asm-powerpc/ppc-pci.h +++ b/include/asm-powerpc/ppc-pci.h | |||
@@ -40,10 +40,6 @@ void pci_devs_phb_init(void); | |||
40 | void pci_devs_phb_init_dynamic(struct pci_controller *phb); | 40 | void pci_devs_phb_init_dynamic(struct pci_controller *phb); |
41 | void __devinit scan_phb(struct pci_controller *hose); | 41 | void __devinit scan_phb(struct pci_controller *hose); |
42 | 42 | ||
43 | /* PCI address cache management routines */ | ||
44 | void pci_addr_cache_insert_device(struct pci_dev *dev); | ||
45 | void pci_addr_cache_remove_device(struct pci_dev *dev); | ||
46 | |||
47 | /* From rtas_pci.h */ | 43 | /* From rtas_pci.h */ |
48 | void init_pci_config_tokens (void); | 44 | void init_pci_config_tokens (void); |
49 | unsigned long get_phb_buid (struct device_node *); | 45 | unsigned long get_phb_buid (struct device_node *); |