@@ -269,20 +269,27 @@ int eeh_wait_state(struct eeh_pe *pe, int max_wait)
* The overall PEs form hierarchy tree. The first layer of the
* hierarchy tree is composed of PHB PEs. The function is used
* to retrieve the corresponding PHB PE according to the given PHB.
+ * Returns a referenced PE.
*/
struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb)
{
struct eeh_pe *pe;
+ unsigned long flags;
+ eeh_lock_pes(&flags);
list_for_each_entry(pe, &eeh_phb_pe, child) {
/*
* Actually, we needn't check the type since
* the PE for PHB has been determined when that
* was created.
*/
- if ((pe->type & EEH_PE_PHB) && pe->phb == phb)
- return pe;
+ if ((pe->type & EEH_PE_PHB) && pe->phb == phb) {
+ eeh_get_pe(pe); /* Acquire ref */
+ eeh_unlock_pes(flags);
+ return pe; /* Give ref */
+ }
}
+ eeh_unlock_pes(flags);
return NULL;
}
Synchronize access to eeh_pe. Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com> --- arch/powerpc/kernel/eeh_pe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)