Skip to content

Commit 685a0bc

Browse files
Sam Bobroffmpe
authored andcommitted
powerpc/eeh: Initialize EEH address cache earlier
The EEH address cache is currently initialized and populated by a single function: eeh_addr_cache_build(). While the initial population of the cache can only be done once resources are allocated, initialization (just setting up a spinlock) could be done much earlier. So move the initialization step into a separate function and call it from a core_initcall (rather than a subsys initcall). This will allow future work to make use of the cache during boot time PCI scanning. Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/0557206741bffee76cdfff042f65321f6f7a5b41.1565930772.git.sbobroff@linux.ibm.com
1 parent 617082a commit 685a0bc

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎arch/powerpc/include/asm/eeh.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ int __init eeh_ops_register(struct eeh_ops *ops);
274274
int __exit eeh_ops_unregister(const char *name);
275275
int eeh_check_failure(const volatile void __iomem *token);
276276
int eeh_dev_check_failure(struct eeh_dev *edev);
277+
void eeh_addr_cache_init(void);
277278
void eeh_addr_cache_build(void);
278279
void eeh_add_device_early(struct pci_dn *);
279280
void eeh_add_device_tree_early(struct pci_dn *);
@@ -332,6 +333,8 @@ static inline int eeh_check_failure(const volatile void __iomem *token)
332333

333334
#define eeh_dev_check_failure(x) (0)
334335

336+
static inline void eeh_addr_cache_init(void) { }
337+
335338
static inline void eeh_addr_cache_build(void) { }
336339

337340
static inline void eeh_add_device_early(struct pci_dn *pdn) { }

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,8 @@ static int eeh_init(void)
11201120
list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
11211121
eeh_dev_phb_init_dynamic(hose);
11221122

1123+
eeh_addr_cache_init();
1124+
11231125
/* Initialize EEH event */
11241126
return eeh_event_init();
11251127
}

‎arch/powerpc/kernel/eeh_cache.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ void eeh_addr_cache_rmv_dev(struct pci_dev *dev)
257257
spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
258258
}
259259

260+
/**
261+
* eeh_addr_cache_init - Initialize a cache of I/O addresses
262+
*
263+
* Initialize a cache of pci i/o addresses. This cache will be used to
264+
* find the pci device that corresponds to a given address.
265+
*/
266+
void eeh_addr_cache_init(void)
267+
{
268+
spin_lock_init(&pci_io_addr_cache_root.piar_lock);
269+
}
270+
260271
/**
261272
* eeh_addr_cache_build - Build a cache of I/O addresses
262273
*
@@ -272,8 +283,6 @@ void eeh_addr_cache_build(void)
272283
struct eeh_dev *edev;
273284
struct pci_dev *dev = NULL;
274285

275-
spin_lock_init(&pci_io_addr_cache_root.piar_lock);
276-
277286
for_each_pci_dev(dev) {
278287
pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
279288
if (!pdn)

0 commit comments

Comments
 (0)