Commit 8645aaa8 authored by Oliver O'Halloran's avatar Oliver O'Halloran Committed by Michael Ellerman

powerpc/eeh: Add sysfs files in late probe

Move creating the EEH specific sysfs files into eeh_add_device_late()
rather than being open-coded all over the place. Calling the function is
generally done immediately after calling eeh_add_device_late() anyway. This
is also a correctness fix since currently the sysfs files will be added
even if the EEH probe happens to fail.

Similarly, on pseries we currently add the sysfs files before calling
eeh_add_device_late(). This is flat-out broken since the sysfs files
require the pci_dev->dev.archdata.edev pointer to be set, and that is done
in eeh_add_device_late().
Reviewed-by: default avatarSam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200306073904.4737-1-oohall@gmail.com
parent 7053f80d
...@@ -305,7 +305,6 @@ void eeh_add_device_early(struct pci_dn *); ...@@ -305,7 +305,6 @@ void eeh_add_device_early(struct pci_dn *);
void eeh_add_device_tree_early(struct pci_dn *); void eeh_add_device_tree_early(struct pci_dn *);
void eeh_add_device_late(struct pci_dev *); void eeh_add_device_late(struct pci_dev *);
void eeh_add_device_tree_late(struct pci_bus *); void eeh_add_device_tree_late(struct pci_bus *);
void eeh_add_sysfs_files(struct pci_bus *);
void eeh_remove_device(struct pci_dev *); void eeh_remove_device(struct pci_dev *);
int eeh_unfreeze_pe(struct eeh_pe *pe); int eeh_unfreeze_pe(struct eeh_pe *pe);
int eeh_pe_reset_and_recover(struct eeh_pe *pe); int eeh_pe_reset_and_recover(struct eeh_pe *pe);
...@@ -368,8 +367,6 @@ static inline void eeh_add_device_late(struct pci_dev *dev) { } ...@@ -368,8 +367,6 @@ static inline void eeh_add_device_late(struct pci_dev *dev) { }
static inline void eeh_add_device_tree_late(struct pci_bus *bus) { } static inline void eeh_add_device_tree_late(struct pci_bus *bus) { }
static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
static inline void eeh_remove_device(struct pci_dev *dev) { } static inline void eeh_remove_device(struct pci_dev *dev) { }
#define EEH_POSSIBLE_ERROR(val, type) (0) #define EEH_POSSIBLE_ERROR(val, type) (0)
......
...@@ -1210,6 +1210,7 @@ void eeh_add_device_late(struct pci_dev *dev) ...@@ -1210,6 +1210,7 @@ void eeh_add_device_late(struct pci_dev *dev)
dev->dev.archdata.edev = edev; dev->dev.archdata.edev = edev;
eeh_addr_cache_insert_dev(dev); eeh_addr_cache_insert_dev(dev);
eeh_sysfs_add_device(dev);
} }
/** /**
...@@ -1237,29 +1238,6 @@ void eeh_add_device_tree_late(struct pci_bus *bus) ...@@ -1237,29 +1238,6 @@ void eeh_add_device_tree_late(struct pci_bus *bus)
} }
EXPORT_SYMBOL_GPL(eeh_add_device_tree_late); EXPORT_SYMBOL_GPL(eeh_add_device_tree_late);
/**
* eeh_add_sysfs_files - Add EEH sysfs files for the indicated PCI bus
* @bus: PCI bus
*
* This routine must be used to add EEH sysfs files for PCI
* devices which are attached to the indicated PCI bus. The PCI bus
* is added after system boot through hotplug or dlpar.
*/
void eeh_add_sysfs_files(struct pci_bus *bus)
{
struct pci_dev *dev;
list_for_each_entry(dev, &bus->devices, bus_list) {
eeh_sysfs_add_device(dev);
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
struct pci_bus *subbus = dev->subordinate;
if (subbus)
eeh_add_sysfs_files(subbus);
}
}
}
EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
/** /**
* eeh_remove_device - Undo EEH setup for the indicated pci device * eeh_remove_device - Undo EEH setup for the indicated pci device
* @dev: pci device to be removed * @dev: pci device to be removed
......
...@@ -86,9 +86,6 @@ static int of_pci_phb_probe(struct platform_device *dev) ...@@ -86,9 +86,6 @@ static int of_pci_phb_probe(struct platform_device *dev)
/* Add probed PCI devices to the device model */ /* Add probed PCI devices to the device model */
pci_bus_add_devices(phb->bus); pci_bus_add_devices(phb->bus);
/* sysfs files should only be added after devices are added */
eeh_add_sysfs_files(phb->bus);
return 0; return 0;
} }
......
...@@ -1404,9 +1404,6 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus) ...@@ -1404,9 +1404,6 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus)
/* Add new devices to global lists. Register in proc, sysfs. */ /* Add new devices to global lists. Register in proc, sysfs. */
pci_bus_add_devices(bus); pci_bus_add_devices(bus);
/* sysfs files should only be added after devices are added */
eeh_add_sysfs_files(bus);
} }
EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus); EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);
......
...@@ -48,7 +48,6 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev) ...@@ -48,7 +48,6 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev)
dev_dbg(&pdev->dev, "EEH: Setting up device\n"); dev_dbg(&pdev->dev, "EEH: Setting up device\n");
eeh_add_device_early(pdn); eeh_add_device_early(pdn);
eeh_add_device_late(pdev); eeh_add_device_late(pdev);
eeh_sysfs_add_device(pdev);
} }
static int pnv_eeh_init(void) static int pnv_eeh_init(void)
......
...@@ -68,7 +68,6 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev) ...@@ -68,7 +68,6 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
} }
#endif #endif
eeh_add_device_early(pdn); eeh_add_device_early(pdn);
eeh_add_device_late(pdev);
#ifdef CONFIG_PCI_IOV #ifdef CONFIG_PCI_IOV
if (pdev->is_virtfn) { if (pdev->is_virtfn) {
struct eeh_dev *edev = pdn_to_eeh_dev(pdn); struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
...@@ -78,7 +77,7 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev) ...@@ -78,7 +77,7 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
eeh_add_to_parent_pe(edev); /* Add as VF PE type */ eeh_add_to_parent_pe(edev); /* Add as VF PE type */
} }
#endif #endif
eeh_sysfs_add_device(pdev); eeh_add_device_late(pdev);
} }
/* /*
......
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