@@ -218,9 +218,16 @@ static struct device_node *find_pe_dn(struct pci_dev *dev, int *total)
if (!dn)
return NULL;
- /* Get the top level device in the PE */
+ /*
+ * Get the top level device in the PE, but some PCI devices
+ * without EEH capability (e.g. VirtIO based PCI devices)
+ * don't have the associated PE. So we should not get the
+ * top level device from PE for those PCI devices.
+ */
edev = of_node_to_eeh_dev(dn);
- edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list);
+ if (edev->pe)
+ edev = list_first_entry(&edev->pe->edevs,
+ struct eeh_dev, list);
dn = eeh_dev_to_of_node(edev);
if (!dn)
return NULL;