Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/eeh: Cleanup on EEH PCI address cache

The patch does cleanup on EEH PCI address cache based on the fact
EEH core is the only user of the component.

* Cleanup on function names so that they all have prefix
"eeh" and looks more short.
* Function printk() has been replaced with pr_debug() or
pr_warning() accordingly.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Gavin Shan and committed by
Benjamin Herrenschmidt
3ab96a02 f8f7d63f

+32 -33
+2 -2
arch/powerpc/include/asm/eeh.h
··· 197 197 unsigned long eeh_check_failure(const volatile void __iomem *token, 198 198 unsigned long val); 199 199 int eeh_dev_check_failure(struct eeh_dev *edev); 200 - void __init pci_addr_cache_build(void); 200 + void __init eeh_addr_cache_build(void); 201 201 void eeh_add_device_tree_early(struct device_node *); 202 202 void eeh_add_device_tree_late(struct pci_bus *); 203 203 void eeh_remove_bus_device(struct pci_dev *); ··· 233 233 234 234 #define eeh_dev_check_failure(x) (0) 235 235 236 - static inline void pci_addr_cache_build(void) { } 236 + static inline void eeh_addr_cache_build(void) { } 237 237 238 238 static inline void eeh_add_device_tree_early(struct device_node *dn) { } 239 239
+3 -4
arch/powerpc/include/asm/ppc-pci.h
··· 47 47 48 48 #ifdef CONFIG_EEH 49 49 50 - void pci_addr_cache_build(void); 51 - void pci_addr_cache_insert_device(struct pci_dev *dev); 52 - void pci_addr_cache_remove_device(struct pci_dev *dev); 53 - struct eeh_dev *pci_addr_cache_get_device(unsigned long addr); 50 + void eeh_addr_cache_insert_dev(struct pci_dev *dev); 51 + void eeh_addr_cache_rmv_dev(struct pci_dev *dev); 52 + struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr); 54 53 void eeh_slot_error_detail(struct eeh_pe *pe, int severity); 55 54 int eeh_pci_enable(struct eeh_pe *pe, int function); 56 55 int eeh_reset_pe(struct eeh_pe *);
+3 -3
arch/powerpc/platforms/pseries/eeh.c
··· 411 411 412 412 /* Finding the phys addr + pci device; this is pretty quick. */ 413 413 addr = eeh_token_to_phys((unsigned long __force) token); 414 - edev = pci_addr_cache_get_device(addr); 414 + edev = eeh_addr_cache_get_dev(addr); 415 415 if (!edev) { 416 416 eeh_stats.no_device++; 417 417 return val; ··· 787 787 edev->pdev = dev; 788 788 dev->dev.archdata.edev = edev; 789 789 790 - pci_addr_cache_insert_device(dev); 790 + eeh_addr_cache_insert_dev(dev); 791 791 eeh_sysfs_add_device(dev); 792 792 } 793 793 ··· 844 844 pci_dev_put(dev); 845 845 846 846 eeh_rmv_from_parent_pe(edev); 847 - pci_addr_cache_remove_device(dev); 847 + eeh_addr_cache_rmv_dev(dev); 848 848 eeh_sysfs_remove_device(dev); 849 849 } 850 850
+23 -23
arch/powerpc/platforms/pseries/eeh_cache.c
··· 60 60 spinlock_t piar_lock; 61 61 } pci_io_addr_cache_root; 62 62 63 - static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr) 63 + static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr) 64 64 { 65 65 struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node; 66 66 ··· 84 84 } 85 85 86 86 /** 87 - * pci_addr_cache_get_device - Get device, given only address 87 + * eeh_addr_cache_get_dev - Get device, given only address 88 88 * @addr: mmio (PIO) phys address or i/o port number 89 89 * 90 90 * Given an mmio phys address, or a port number, find a pci device ··· 93 93 * from zero (that is, they do *not* have pci_io_addr added in). 94 94 * It is safe to call this function within an interrupt. 95 95 */ 96 - struct eeh_dev *pci_addr_cache_get_device(unsigned long addr) 96 + struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr) 97 97 { 98 98 struct eeh_dev *edev; 99 99 unsigned long flags; 100 100 101 101 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); 102 - edev = __pci_addr_cache_get_device(addr); 102 + edev = __eeh_addr_cache_get_device(addr); 103 103 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); 104 104 return edev; 105 105 } ··· 109 109 * Handy-dandy debug print routine, does nothing more 110 110 * than print out the contents of our addr cache. 111 111 */ 112 - static void pci_addr_cache_print(struct pci_io_addr_cache *cache) 112 + static void eeh_addr_cache_print(struct pci_io_addr_cache *cache) 113 113 { 114 114 struct rb_node *n; 115 115 int cnt = 0; ··· 118 118 while (n) { 119 119 struct pci_io_addr_range *piar; 120 120 piar = rb_entry(n, struct pci_io_addr_range, rb_node); 121 - printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", 121 + pr_debug("PCI: %s addr range %d [%lx-%lx]: %s\n", 122 122 (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, 123 123 piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); 124 124 cnt++; ··· 129 129 130 130 /* Insert address range into the rb tree. */ 131 131 static struct pci_io_addr_range * 132 - pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, 132 + eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo, 133 133 unsigned long ahi, unsigned int flags) 134 134 { 135 135 struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node; ··· 147 147 } else { 148 148 if (dev != piar->pcidev || 149 149 alo != piar->addr_lo || ahi != piar->addr_hi) { 150 - printk(KERN_WARNING "PIAR: overlapping address range\n"); 150 + pr_warning("PIAR: overlapping address range\n"); 151 151 } 152 152 return piar; 153 153 } ··· 164 164 piar->flags = flags; 165 165 166 166 #ifdef DEBUG 167 - printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", 167 + pr_debug("PIAR: insert range=[%lx:%lx] dev=%s\n", 168 168 alo, ahi, pci_name(dev)); 169 169 #endif 170 170 ··· 174 174 return piar; 175 175 } 176 176 177 - static void __pci_addr_cache_insert_device(struct pci_dev *dev) 177 + static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) 178 178 { 179 179 struct device_node *dn; 180 180 struct eeh_dev *edev; ··· 182 182 183 183 dn = pci_device_to_OF_node(dev); 184 184 if (!dn) { 185 - printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev)); 185 + pr_warning("PCI: no pci dn found for dev=%s\n", pci_name(dev)); 186 186 return; 187 187 } 188 188 ··· 213 213 continue; 214 214 if (start == 0 || ~start == 0 || end == 0 || ~end == 0) 215 215 continue; 216 - pci_addr_cache_insert(dev, start, end, flags); 216 + eeh_addr_cache_insert(dev, start, end, flags); 217 217 } 218 218 } 219 219 220 220 /** 221 - * pci_addr_cache_insert_device - Add a device to the address cache 221 + * eeh_addr_cache_insert_dev - Add a device to the address cache 222 222 * @dev: PCI device whose I/O addresses we are interested in. 223 223 * 224 224 * In order to support the fast lookup of devices based on addresses, 225 225 * we maintain a cache of devices that can be quickly searched. 226 226 * This routine adds a device to that cache. 227 227 */ 228 - void pci_addr_cache_insert_device(struct pci_dev *dev) 228 + void eeh_addr_cache_insert_dev(struct pci_dev *dev) 229 229 { 230 230 unsigned long flags; 231 231 ··· 234 234 return; 235 235 236 236 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); 237 - __pci_addr_cache_insert_device(dev); 237 + __eeh_addr_cache_insert_dev(dev); 238 238 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); 239 239 } 240 240 241 - static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) 241 + static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev) 242 242 { 243 243 struct rb_node *n; 244 244 ··· 259 259 } 260 260 261 261 /** 262 - * pci_addr_cache_remove_device - remove pci device from addr cache 262 + * eeh_addr_cache_rmv_dev - remove pci device from addr cache 263 263 * @dev: device to remove 264 264 * 265 265 * Remove a device from the addr-cache tree. ··· 267 267 * the tree multiple times (once per resource). 268 268 * But so what; device removal doesn't need to be that fast. 269 269 */ 270 - void pci_addr_cache_remove_device(struct pci_dev *dev) 270 + void eeh_addr_cache_rmv_dev(struct pci_dev *dev) 271 271 { 272 272 unsigned long flags; 273 273 274 274 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); 275 - __pci_addr_cache_remove_device(dev); 275 + __eeh_addr_cache_rmv_dev(dev); 276 276 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); 277 277 } 278 278 279 279 /** 280 - * pci_addr_cache_build - Build a cache of I/O addresses 280 + * eeh_addr_cache_build - Build a cache of I/O addresses 281 281 * 282 282 * Build a cache of pci i/o addresses. This cache will be used to 283 283 * find the pci device that corresponds to a given address. ··· 285 285 * Must be run late in boot process, after the pci controllers 286 286 * have been scanned for devices (after all device resources are known). 287 287 */ 288 - void __init pci_addr_cache_build(void) 288 + void __init eeh_addr_cache_build(void) 289 289 { 290 290 struct device_node *dn; 291 291 struct eeh_dev *edev; ··· 294 294 spin_lock_init(&pci_io_addr_cache_root.piar_lock); 295 295 296 296 for_each_pci_dev(dev) { 297 - pci_addr_cache_insert_device(dev); 297 + eeh_addr_cache_insert_dev(dev); 298 298 299 299 dn = pci_device_to_OF_node(dev); 300 300 if (!dn) ··· 313 313 314 314 #ifdef DEBUG 315 315 /* Verify tree built up above, echo back the list of addrs. */ 316 - pci_addr_cache_print(&pci_io_addr_cache_root); 316 + eeh_addr_cache_print(&pci_io_addr_cache_root); 317 317 #endif 318 318 } 319 319
+1 -1
arch/powerpc/platforms/pseries/pci.c
··· 73 73 { 74 74 pSeries_request_regions(); 75 75 76 - pci_addr_cache_build(); 76 + eeh_addr_cache_build(); 77 77 } 78 78 79 79 /*