Commit 3ab96a02 authored by Gavin Shan's avatar Gavin Shan Committed by Benjamin Herrenschmidt

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: default avatarGavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent f8f7d63f
...@@ -197,7 +197,7 @@ int __exit eeh_ops_unregister(const char *name); ...@@ -197,7 +197,7 @@ int __exit eeh_ops_unregister(const char *name);
unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long eeh_check_failure(const volatile void __iomem *token,
unsigned long val); unsigned long val);
int eeh_dev_check_failure(struct eeh_dev *edev); int eeh_dev_check_failure(struct eeh_dev *edev);
void __init pci_addr_cache_build(void); void __init eeh_addr_cache_build(void);
void eeh_add_device_tree_early(struct device_node *); void eeh_add_device_tree_early(struct device_node *);
void eeh_add_device_tree_late(struct pci_bus *); void eeh_add_device_tree_late(struct pci_bus *);
void eeh_remove_bus_device(struct pci_dev *); void eeh_remove_bus_device(struct pci_dev *);
...@@ -233,7 +233,7 @@ static inline unsigned long eeh_check_failure(const volatile void __iomem *token ...@@ -233,7 +233,7 @@ static inline unsigned long eeh_check_failure(const volatile void __iomem *token
#define eeh_dev_check_failure(x) (0) #define eeh_dev_check_failure(x) (0)
static inline void pci_addr_cache_build(void) { } static inline void eeh_addr_cache_build(void) { }
static inline void eeh_add_device_tree_early(struct device_node *dn) { } static inline void eeh_add_device_tree_early(struct device_node *dn) { }
......
...@@ -47,10 +47,9 @@ extern int rtas_setup_phb(struct pci_controller *phb); ...@@ -47,10 +47,9 @@ extern int rtas_setup_phb(struct pci_controller *phb);
#ifdef CONFIG_EEH #ifdef CONFIG_EEH
void pci_addr_cache_build(void); void eeh_addr_cache_insert_dev(struct pci_dev *dev);
void pci_addr_cache_insert_device(struct pci_dev *dev); void eeh_addr_cache_rmv_dev(struct pci_dev *dev);
void pci_addr_cache_remove_device(struct pci_dev *dev); struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr);
struct eeh_dev *pci_addr_cache_get_device(unsigned long addr);
void eeh_slot_error_detail(struct eeh_pe *pe, int severity); void eeh_slot_error_detail(struct eeh_pe *pe, int severity);
int eeh_pci_enable(struct eeh_pe *pe, int function); int eeh_pci_enable(struct eeh_pe *pe, int function);
int eeh_reset_pe(struct eeh_pe *); int eeh_reset_pe(struct eeh_pe *);
......
...@@ -411,7 +411,7 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon ...@@ -411,7 +411,7 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
/* Finding the phys addr + pci device; this is pretty quick. */ /* Finding the phys addr + pci device; this is pretty quick. */
addr = eeh_token_to_phys((unsigned long __force) token); addr = eeh_token_to_phys((unsigned long __force) token);
edev = pci_addr_cache_get_device(addr); edev = eeh_addr_cache_get_dev(addr);
if (!edev) { if (!edev) {
eeh_stats.no_device++; eeh_stats.no_device++;
return val; return val;
...@@ -787,7 +787,7 @@ static void eeh_add_device_late(struct pci_dev *dev) ...@@ -787,7 +787,7 @@ static void eeh_add_device_late(struct pci_dev *dev)
edev->pdev = dev; edev->pdev = dev;
dev->dev.archdata.edev = edev; dev->dev.archdata.edev = edev;
pci_addr_cache_insert_device(dev); eeh_addr_cache_insert_dev(dev);
eeh_sysfs_add_device(dev); eeh_sysfs_add_device(dev);
} }
...@@ -844,7 +844,7 @@ static void eeh_remove_device(struct pci_dev *dev) ...@@ -844,7 +844,7 @@ static void eeh_remove_device(struct pci_dev *dev)
pci_dev_put(dev); pci_dev_put(dev);
eeh_rmv_from_parent_pe(edev); eeh_rmv_from_parent_pe(edev);
pci_addr_cache_remove_device(dev); eeh_addr_cache_rmv_dev(dev);
eeh_sysfs_remove_device(dev); eeh_sysfs_remove_device(dev);
} }
......
...@@ -60,7 +60,7 @@ static struct pci_io_addr_cache { ...@@ -60,7 +60,7 @@ static struct pci_io_addr_cache {
spinlock_t piar_lock; spinlock_t piar_lock;
} pci_io_addr_cache_root; } pci_io_addr_cache_root;
static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr) static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr)
{ {
struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node; struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node;
...@@ -84,7 +84,7 @@ static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr) ...@@ -84,7 +84,7 @@ static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr)
} }
/** /**
* pci_addr_cache_get_device - Get device, given only address * eeh_addr_cache_get_dev - Get device, given only address
* @addr: mmio (PIO) phys address or i/o port number * @addr: mmio (PIO) phys address or i/o port number
* *
* Given an mmio phys address, or a port number, find a pci device * Given an mmio phys address, or a port number, find a pci device
...@@ -93,13 +93,13 @@ static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr) ...@@ -93,13 +93,13 @@ static inline struct eeh_dev *__pci_addr_cache_get_device(unsigned long addr)
* from zero (that is, they do *not* have pci_io_addr added in). * from zero (that is, they do *not* have pci_io_addr added in).
* It is safe to call this function within an interrupt. * It is safe to call this function within an interrupt.
*/ */
struct eeh_dev *pci_addr_cache_get_device(unsigned long addr) struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr)
{ {
struct eeh_dev *edev; struct eeh_dev *edev;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
edev = __pci_addr_cache_get_device(addr); edev = __eeh_addr_cache_get_device(addr);
spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
return edev; return edev;
} }
...@@ -109,7 +109,7 @@ struct eeh_dev *pci_addr_cache_get_device(unsigned long addr) ...@@ -109,7 +109,7 @@ struct eeh_dev *pci_addr_cache_get_device(unsigned long addr)
* Handy-dandy debug print routine, does nothing more * Handy-dandy debug print routine, does nothing more
* than print out the contents of our addr cache. * than print out the contents of our addr cache.
*/ */
static void pci_addr_cache_print(struct pci_io_addr_cache *cache) static void eeh_addr_cache_print(struct pci_io_addr_cache *cache)
{ {
struct rb_node *n; struct rb_node *n;
int cnt = 0; int cnt = 0;
...@@ -118,7 +118,7 @@ static void pci_addr_cache_print(struct pci_io_addr_cache *cache) ...@@ -118,7 +118,7 @@ static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
while (n) { while (n) {
struct pci_io_addr_range *piar; struct pci_io_addr_range *piar;
piar = rb_entry(n, struct pci_io_addr_range, rb_node); piar = rb_entry(n, struct pci_io_addr_range, rb_node);
printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", pr_debug("PCI: %s addr range %d [%lx-%lx]: %s\n",
(piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev));
cnt++; cnt++;
...@@ -129,7 +129,7 @@ static void pci_addr_cache_print(struct pci_io_addr_cache *cache) ...@@ -129,7 +129,7 @@ static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
/* Insert address range into the rb tree. */ /* Insert address range into the rb tree. */
static struct pci_io_addr_range * static struct pci_io_addr_range *
pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
unsigned long ahi, unsigned int flags) unsigned long ahi, unsigned int flags)
{ {
struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node; struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node;
...@@ -147,7 +147,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, ...@@ -147,7 +147,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
} else { } else {
if (dev != piar->pcidev || if (dev != piar->pcidev ||
alo != piar->addr_lo || ahi != piar->addr_hi) { alo != piar->addr_lo || ahi != piar->addr_hi) {
printk(KERN_WARNING "PIAR: overlapping address range\n"); pr_warning("PIAR: overlapping address range\n");
} }
return piar; return piar;
} }
...@@ -164,7 +164,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, ...@@ -164,7 +164,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
piar->flags = flags; piar->flags = flags;
#ifdef DEBUG #ifdef DEBUG
printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", pr_debug("PIAR: insert range=[%lx:%lx] dev=%s\n",
alo, ahi, pci_name(dev)); alo, ahi, pci_name(dev));
#endif #endif
...@@ -174,7 +174,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, ...@@ -174,7 +174,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
return piar; return piar;
} }
static void __pci_addr_cache_insert_device(struct pci_dev *dev) static void __eeh_addr_cache_insert_dev(struct pci_dev *dev)
{ {
struct device_node *dn; struct device_node *dn;
struct eeh_dev *edev; struct eeh_dev *edev;
...@@ -182,7 +182,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) ...@@ -182,7 +182,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
dn = pci_device_to_OF_node(dev); dn = pci_device_to_OF_node(dev);
if (!dn) { if (!dn) {
printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev)); pr_warning("PCI: no pci dn found for dev=%s\n", pci_name(dev));
return; return;
} }
...@@ -213,19 +213,19 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) ...@@ -213,19 +213,19 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
continue; continue;
if (start == 0 || ~start == 0 || end == 0 || ~end == 0) if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
continue; continue;
pci_addr_cache_insert(dev, start, end, flags); eeh_addr_cache_insert(dev, start, end, flags);
} }
} }
/** /**
* pci_addr_cache_insert_device - Add a device to the address cache * eeh_addr_cache_insert_dev - Add a device to the address cache
* @dev: PCI device whose I/O addresses we are interested in. * @dev: PCI device whose I/O addresses we are interested in.
* *
* In order to support the fast lookup of devices based on addresses, * In order to support the fast lookup of devices based on addresses,
* we maintain a cache of devices that can be quickly searched. * we maintain a cache of devices that can be quickly searched.
* This routine adds a device to that cache. * This routine adds a device to that cache.
*/ */
void pci_addr_cache_insert_device(struct pci_dev *dev) void eeh_addr_cache_insert_dev(struct pci_dev *dev)
{ {
unsigned long flags; unsigned long flags;
...@@ -234,11 +234,11 @@ void pci_addr_cache_insert_device(struct pci_dev *dev) ...@@ -234,11 +234,11 @@ void pci_addr_cache_insert_device(struct pci_dev *dev)
return; return;
spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
__pci_addr_cache_insert_device(dev); __eeh_addr_cache_insert_dev(dev);
spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
} }
static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev)
{ {
struct rb_node *n; struct rb_node *n;
...@@ -259,7 +259,7 @@ static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) ...@@ -259,7 +259,7 @@ static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
} }
/** /**
* pci_addr_cache_remove_device - remove pci device from addr cache * eeh_addr_cache_rmv_dev - remove pci device from addr cache
* @dev: device to remove * @dev: device to remove
* *
* Remove a device from the addr-cache tree. * Remove a device from the addr-cache tree.
...@@ -267,17 +267,17 @@ static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) ...@@ -267,17 +267,17 @@ static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
* the tree multiple times (once per resource). * the tree multiple times (once per resource).
* But so what; device removal doesn't need to be that fast. * But so what; device removal doesn't need to be that fast.
*/ */
void pci_addr_cache_remove_device(struct pci_dev *dev) void eeh_addr_cache_rmv_dev(struct pci_dev *dev)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
__pci_addr_cache_remove_device(dev); __eeh_addr_cache_rmv_dev(dev);
spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
} }
/** /**
* pci_addr_cache_build - Build a cache of I/O addresses * eeh_addr_cache_build - Build a cache of I/O addresses
* *
* Build a cache of pci i/o addresses. This cache will be used to * Build a cache of pci i/o addresses. This cache will be used to
* find the pci device that corresponds to a given address. * find the pci device that corresponds to a given address.
...@@ -285,7 +285,7 @@ void pci_addr_cache_remove_device(struct pci_dev *dev) ...@@ -285,7 +285,7 @@ void pci_addr_cache_remove_device(struct pci_dev *dev)
* Must be run late in boot process, after the pci controllers * Must be run late in boot process, after the pci controllers
* have been scanned for devices (after all device resources are known). * have been scanned for devices (after all device resources are known).
*/ */
void __init pci_addr_cache_build(void) void __init eeh_addr_cache_build(void)
{ {
struct device_node *dn; struct device_node *dn;
struct eeh_dev *edev; struct eeh_dev *edev;
...@@ -294,7 +294,7 @@ void __init pci_addr_cache_build(void) ...@@ -294,7 +294,7 @@ void __init pci_addr_cache_build(void)
spin_lock_init(&pci_io_addr_cache_root.piar_lock); spin_lock_init(&pci_io_addr_cache_root.piar_lock);
for_each_pci_dev(dev) { for_each_pci_dev(dev) {
pci_addr_cache_insert_device(dev); eeh_addr_cache_insert_dev(dev);
dn = pci_device_to_OF_node(dev); dn = pci_device_to_OF_node(dev);
if (!dn) if (!dn)
...@@ -313,7 +313,7 @@ void __init pci_addr_cache_build(void) ...@@ -313,7 +313,7 @@ void __init pci_addr_cache_build(void)
#ifdef DEBUG #ifdef DEBUG
/* Verify tree built up above, echo back the list of addrs. */ /* Verify tree built up above, echo back the list of addrs. */
pci_addr_cache_print(&pci_io_addr_cache_root); eeh_addr_cache_print(&pci_io_addr_cache_root);
#endif #endif
} }
...@@ -73,7 +73,7 @@ void __init pSeries_final_fixup(void) ...@@ -73,7 +73,7 @@ void __init pSeries_final_fixup(void)
{ {
pSeries_request_regions(); pSeries_request_regions();
pci_addr_cache_build(); eeh_addr_cache_build();
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment