Lines Matching full:pe
3 * The file intends to implement PE based on the information from
7 * PE is only meaningful in one PHB domain.
26 * eeh_set_pe_aux_size - Set PE auxillary data size
27 * @size: PE auxillary data size
29 * Set PE auxillary data size
40 * eeh_pe_alloc - Allocate PE
42 * @type: PE type
44 * Allocate PE instance dynamically.
48 struct eeh_pe *pe; in eeh_pe_alloc() local
57 /* Allocate PHB PE */ in eeh_pe_alloc()
58 pe = kzalloc(alloc_size, GFP_KERNEL); in eeh_pe_alloc()
59 if (!pe) return NULL; in eeh_pe_alloc()
61 /* Initialize PHB PE */ in eeh_pe_alloc()
62 pe->type = type; in eeh_pe_alloc()
63 pe->phb = phb; in eeh_pe_alloc()
64 INIT_LIST_HEAD(&pe->child_list); in eeh_pe_alloc()
65 INIT_LIST_HEAD(&pe->edevs); in eeh_pe_alloc()
67 pe->data = (void *)pe + ALIGN(sizeof(struct eeh_pe), in eeh_pe_alloc()
69 return pe; in eeh_pe_alloc()
73 * eeh_phb_pe_create - Create PHB PE
77 * system boot or PCI hotplug in order to create PHB PE.
81 struct eeh_pe *pe; in eeh_phb_pe_create() local
83 /* Allocate PHB PE */ in eeh_phb_pe_create()
84 pe = eeh_pe_alloc(phb, EEH_PE_PHB); in eeh_phb_pe_create()
85 if (!pe) { in eeh_phb_pe_create()
91 list_add_tail(&pe->child, &eeh_phb_pe); in eeh_phb_pe_create()
93 pr_debug("EEH: Add PE for PHB#%x\n", phb->global_number); in eeh_phb_pe_create()
99 * eeh_wait_state - Wait for PE state
100 * @pe: EEH PE
103 * Wait for the state of associated PE. It might take some time
104 * to retrieve the PE's state.
106 int eeh_wait_state(struct eeh_pe *pe, int max_wait) in eeh_wait_state() argument
112 * According to PAPR, the state of PE might be temporarily in eeh_wait_state()
123 ret = eeh_ops->get_state(pe, &mwait); in eeh_wait_state()
129 pr_warn("%s: Timeout when getting PE's state (%d)\n", in eeh_wait_state()
150 * eeh_phb_pe_get - Retrieve PHB PE based on the given PHB
155 * to retrieve the corresponding PHB PE according to the given PHB.
159 struct eeh_pe *pe; in eeh_phb_pe_get() local
161 list_for_each_entry(pe, &eeh_phb_pe, child) { in eeh_phb_pe_get()
164 * the PE for PHB has been determined when that in eeh_phb_pe_get()
167 if ((pe->type & EEH_PE_PHB) && pe->phb == phb) in eeh_phb_pe_get()
168 return pe; in eeh_phb_pe_get()
175 * eeh_pe_next - Retrieve the next PE in the tree
176 * @pe: current PE
177 * @root: root PE
179 * The function is used to retrieve the next PE in the
180 * hierarchy PE tree.
182 struct eeh_pe *eeh_pe_next(struct eeh_pe *pe, struct eeh_pe *root) in eeh_pe_next() argument
184 struct list_head *next = pe->child_list.next; in eeh_pe_next()
186 if (next == &pe->child_list) { in eeh_pe_next()
188 if (pe == root) in eeh_pe_next()
190 next = pe->child.next; in eeh_pe_next()
191 if (next != &pe->parent->child_list) in eeh_pe_next()
193 pe = pe->parent; in eeh_pe_next()
202 * @root: root PE
206 * The function is used to traverse the specified PE and its
214 struct eeh_pe *pe; in eeh_pe_traverse() local
217 eeh_for_each_pe(root, pe) { in eeh_pe_traverse()
218 ret = fn(pe, flag); in eeh_pe_traverse()
226 * eeh_pe_dev_traverse - Traverse the devices from the PE
227 * @root: EEH PE
232 * PE and its child PEs.
237 struct eeh_pe *pe; in eeh_pe_dev_traverse() local
241 pr_warn("%s: Invalid PE %p\n", in eeh_pe_dev_traverse()
246 /* Traverse root PE */ in eeh_pe_dev_traverse()
247 eeh_for_each_pe(root, pe) in eeh_pe_dev_traverse()
248 eeh_pe_for_each_dev(pe, edev, tmp) in eeh_pe_dev_traverse()
253 * __eeh_pe_get - Check the PE address
255 * For one particular PE, it can be identified by PE address
260 static void *__eeh_pe_get(struct eeh_pe *pe, void *flag) in __eeh_pe_get() argument
265 if (pe->type & EEH_PE_PHB) in __eeh_pe_get()
268 if (*target_pe == pe->addr) in __eeh_pe_get()
269 return pe; in __eeh_pe_get()
275 * eeh_pe_get - Search PE based on the given address
277 * @pe_no: PE number
279 * Search the corresponding PE based on the specified address which
281 * the associated PE has been created against the PE address. It's
282 * notable that the PE address has 2 format: traditional PE address
284 * PE address.
294 * eeh_pe_tree_insert - Add EEH device to parent PE
296 * @new_pe_parent: PE to create additional PEs under
298 * Add EEH device to the PE in edev->pe_config_addr. If a PE already
299 * exists with that address then @edev is added to that PE. Otherwise
300 * a new PE is created and inserted into the PE tree as a child of
303 * If @new_pe_parent is NULL then the new PE will be inserted under
309 struct eeh_pe *pe, *parent; in eeh_pe_tree_insert() local
312 * Search the PE has been existing or not according in eeh_pe_tree_insert()
313 * to the PE address. If that has been existing, the in eeh_pe_tree_insert()
314 * PE should be composed of PCI bus and its subordinate in eeh_pe_tree_insert()
317 pe = eeh_pe_get(hose, edev->pe_config_addr); in eeh_pe_tree_insert()
318 if (pe) { in eeh_pe_tree_insert()
319 if (pe->type & EEH_PE_INVALID) { in eeh_pe_tree_insert()
320 list_add_tail(&edev->entry, &pe->edevs); in eeh_pe_tree_insert()
321 edev->pe = pe; in eeh_pe_tree_insert()
326 parent = pe; in eeh_pe_tree_insert()
334 eeh_edev_dbg(edev, "Added to existing PE (parent: PE#%x)\n", in eeh_pe_tree_insert()
335 pe->parent->addr); in eeh_pe_tree_insert()
337 /* Mark the PE as type of PCI bus */ in eeh_pe_tree_insert()
338 pe->type = EEH_PE_BUS; in eeh_pe_tree_insert()
339 edev->pe = pe; in eeh_pe_tree_insert()
341 /* Put the edev to PE */ in eeh_pe_tree_insert()
342 list_add_tail(&edev->entry, &pe->edevs); in eeh_pe_tree_insert()
343 eeh_edev_dbg(edev, "Added to bus PE\n"); in eeh_pe_tree_insert()
348 /* Create a new EEH PE */ in eeh_pe_tree_insert()
350 pe = eeh_pe_alloc(hose, EEH_PE_VF); in eeh_pe_tree_insert()
352 pe = eeh_pe_alloc(hose, EEH_PE_DEVICE); in eeh_pe_tree_insert()
353 if (!pe) { in eeh_pe_tree_insert()
358 pe->addr = edev->pe_config_addr; in eeh_pe_tree_insert()
361 * Put the new EEH PE into hierarchy tree. If the parent in eeh_pe_tree_insert()
362 * can't be found, the newly created PE will be attached in eeh_pe_tree_insert()
364 * PE with its parent. in eeh_pe_tree_insert()
369 pr_err("%s: No PHB PE is found (PHB Domain=%d)\n", in eeh_pe_tree_insert()
371 edev->pe = NULL; in eeh_pe_tree_insert()
372 kfree(pe); in eeh_pe_tree_insert()
377 /* link new PE into the tree */ in eeh_pe_tree_insert()
378 pe->parent = new_pe_parent; in eeh_pe_tree_insert()
379 list_add_tail(&pe->child, &new_pe_parent->child_list); in eeh_pe_tree_insert()
382 * Put the newly created PE into the child list and in eeh_pe_tree_insert()
385 list_add_tail(&edev->entry, &pe->edevs); in eeh_pe_tree_insert()
386 edev->pe = pe; in eeh_pe_tree_insert()
387 eeh_edev_dbg(edev, "Added to new (parent: PE#%x)\n", in eeh_pe_tree_insert()
394 * eeh_pe_tree_remove - Remove one EEH device from the associated PE
397 * The PE hierarchy tree might be changed when doing PCI hotplug.
400 * corresponding PE accordingly if necessary.
404 struct eeh_pe *pe, *parent, *child; in eeh_pe_tree_remove() local
408 pe = eeh_dev_to_pe(edev); in eeh_pe_tree_remove()
409 if (!pe) { in eeh_pe_tree_remove()
410 eeh_edev_dbg(edev, "No PE found for device.\n"); in eeh_pe_tree_remove()
415 edev->pe = NULL; in eeh_pe_tree_remove()
419 * Check if the parent PE includes any EEH devices. in eeh_pe_tree_remove()
421 * delete the parent PE if it doesn't have associated in eeh_pe_tree_remove()
425 parent = pe->parent; in eeh_pe_tree_remove()
428 if (pe->type & EEH_PE_PHB) in eeh_pe_tree_remove()
432 * XXX: KEEP is set while resetting a PE. I don't think it's in eeh_pe_tree_remove()
436 keep = !!(pe->state & EEH_PE_KEEP); in eeh_pe_tree_remove()
437 recover = !!(pe->state & EEH_PE_RECOVERING); in eeh_pe_tree_remove()
441 if (list_empty(&pe->edevs) && in eeh_pe_tree_remove()
442 list_empty(&pe->child_list)) { in eeh_pe_tree_remove()
443 list_del(&pe->child); in eeh_pe_tree_remove()
444 kfree(pe); in eeh_pe_tree_remove()
450 * Mark the PE as invalid. At the end of the recovery in eeh_pe_tree_remove()
454 * remove edev's while traversing the PE tree which in eeh_pe_tree_remove()
455 * might trigger the removal of a PE and we can't in eeh_pe_tree_remove()
458 if (list_empty(&pe->edevs)) { in eeh_pe_tree_remove()
460 list_for_each_entry(child, &pe->child_list, child) { in eeh_pe_tree_remove()
468 pe->type |= EEH_PE_INVALID; in eeh_pe_tree_remove()
474 pe = parent; in eeh_pe_tree_remove()
481 * eeh_pe_update_time_stamp - Update PE's frozen time stamp
482 * @pe: EEH PE
484 * We have time stamp for each PE to trace its time of getting
486 * the time stamp on first error of the specific PE. On the other
489 void eeh_pe_update_time_stamp(struct eeh_pe *pe) in eeh_pe_update_time_stamp() argument
493 if (!pe) return; in eeh_pe_update_time_stamp()
495 if (pe->freeze_count <= 0) { in eeh_pe_update_time_stamp()
496 pe->freeze_count = 0; in eeh_pe_update_time_stamp()
497 pe->tstamp = ktime_get_seconds(); in eeh_pe_update_time_stamp()
500 if (tstamp - pe->tstamp > 3600) { in eeh_pe_update_time_stamp()
501 pe->tstamp = tstamp; in eeh_pe_update_time_stamp()
502 pe->freeze_count = 0; in eeh_pe_update_time_stamp()
508 * eeh_pe_state_mark - Mark specified state for PE and its associated device
509 * @pe: EEH PE
511 * EEH error affects the current PE and its child PEs. The function
517 struct eeh_pe *pe; in eeh_pe_state_mark() local
519 eeh_for_each_pe(root, pe) in eeh_pe_state_mark()
520 if (!(pe->state & EEH_PE_REMOVED)) in eeh_pe_state_mark()
521 pe->state |= state; in eeh_pe_state_mark()
527 * @pe: EEH PE
529 * Record that a PE has been isolated by marking the PE and it's children as
535 struct eeh_pe *pe; in eeh_pe_mark_isolated() local
540 eeh_for_each_pe(root, pe) { in eeh_pe_mark_isolated()
541 list_for_each_entry(edev, &pe->edevs, entry) { in eeh_pe_mark_isolated()
547 if (pe->state & EEH_PE_CFG_RESTRICTED) in eeh_pe_mark_isolated()
548 pe->state |= EEH_PE_CFG_BLOCKED; in eeh_pe_mark_isolated()
561 * eeh_pe_dev_state_mark - Mark state for all device under the PE
562 * @pe: EEH PE
564 * Mark specific state for all child devices of the PE.
566 void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode) in eeh_pe_dev_mode_mark() argument
568 eeh_pe_dev_traverse(pe, __eeh_pe_dev_mode_mark, &mode); in eeh_pe_dev_mode_mark()
572 * eeh_pe_state_clear - Clear state for the PE
573 * @data: EEH PE
578 * given PE. Besides, we also clear the check count of the PE
583 struct eeh_pe *pe; in eeh_pe_state_clear() local
587 eeh_for_each_pe(root, pe) { in eeh_pe_state_clear()
588 /* Keep the state of permanently removed PE intact */ in eeh_pe_state_clear()
589 if (pe->state & EEH_PE_REMOVED) in eeh_pe_state_clear()
592 if (!include_passed && eeh_pe_passed(pe)) in eeh_pe_state_clear()
595 pe->state &= ~state; in eeh_pe_state_clear()
605 pe->check_count = 0; in eeh_pe_state_clear()
606 eeh_pe_for_each_dev(pe, edev, tmp) { in eeh_pe_state_clear()
615 if (pe->state & EEH_PE_CFG_RESTRICTED) in eeh_pe_state_clear()
616 pe->state &= ~EEH_PE_CFG_BLOCKED; in eeh_pe_state_clear()
787 * @pe: EEH PE
792 void eeh_pe_restore_bars(struct eeh_pe *pe) in eeh_pe_restore_bars() argument
798 eeh_pe_dev_traverse(pe, eeh_restore_one_device_bars, NULL); in eeh_pe_restore_bars()
802 * eeh_pe_loc_get - Retrieve location code binding to the given PE
803 * @pe: EEH PE
805 * Retrieve the location code of the given PE. If the primary PE bus
808 * of the primary PE bus will be checked for the location code.
810 const char *eeh_pe_loc_get(struct eeh_pe *pe) in eeh_pe_loc_get() argument
812 struct pci_bus *bus = eeh_pe_bus_get(pe); in eeh_pe_loc_get()
839 * eeh_pe_bus_get - Retrieve PCI bus according to the given PE
840 * @pe: EEH PE
842 * Retrieve the PCI bus according to the given PE. Basically,
843 * there're 3 types of PEs: PHB/Bus/Device. For PHB PE, the
845 * returned for BUS PE. However, we don't have associated PCI
846 * bus for DEVICE PE.
848 struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe) in eeh_pe_bus_get() argument
853 if (pe->type & EEH_PE_PHB) in eeh_pe_bus_get()
854 return pe->phb->bus; in eeh_pe_bus_get()
857 if (pe->state & EEH_PE_PRI_BUS) in eeh_pe_bus_get()
858 return pe->bus; in eeh_pe_bus_get()
861 edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, entry); in eeh_pe_bus_get()