Skip to content

Commit b905f8c

Browse files
Sam Bobroffmpe
authored andcommitted
powerpc/eeh: EEH for pSeries hot plug
On PowerNV and pSeries, devices currently acquire EEH support from several different places: Boot-time devices from eeh_probe_devices() and eeh_addr_cache_build(), Virtual Function devices from the pcibios bus add device hooks and hot plugged devices from pci_hp_add_devices() (with other platforms using other methods as well). Unfortunately, pSeries machines currently discover hot plugged devices using pci_rescan_bus(), not pci_hp_add_devices(), and so those devices do not receive EEH support. Rather than adding another case for pci_rescan_bus(), this change widens the scope of the pcibios bus add device hooks so that they can handle all devices. As a side effect this also supports devices discovered after manually rescanning via /sys/bus/pci/rescan. Note that on PowerNV, this change allows the EEH subsystem to become enabled after boot as long as it has not been forced off, which was not previously possible (it was already possible on pSeries). Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/72ae8ae9c54097158894a52de23690448de38ea9.1565930772.git.sbobroff@linux.ibm.com
1 parent 685a0bc commit b905f8c

3 files changed

Lines changed: 56 additions & 41 deletions

File tree

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ void eeh_add_device_late(struct pci_dev *dev)
11921192
struct pci_dn *pdn;
11931193
struct eeh_dev *edev;
11941194

1195-
if (!dev || !eeh_enabled())
1195+
if (!dev)
11961196
return;
11971197

11981198
pr_debug("EEH: Adding device %s\n", pci_name(dev));
@@ -1248,6 +1248,8 @@ void eeh_add_device_tree_late(struct pci_bus *bus)
12481248
{
12491249
struct pci_dev *dev;
12501250

1251+
if (eeh_has_flag(EEH_FORCE_DISABLED))
1252+
return;
12511253
list_for_each_entry(dev, &bus->devices, bus_list) {
12521254
eeh_add_device_late(dev);
12531255
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {

‎arch/powerpc/platforms/powernv/eeh-powernv.c‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev)
4141
{
4242
struct pci_dn *pdn = pci_get_pdn(pdev);
4343

44-
if (!pdev->is_virtfn)
44+
if (eeh_has_flag(EEH_FORCE_DISABLED))
4545
return;
4646

4747
pr_debug("%s: EEH: Setting up device %s.\n", __func__, pci_name(pdev));
@@ -196,6 +196,25 @@ PNV_EEH_DBGFS_ENTRY(inbB, 0xE10);
196196

197197
#endif /* CONFIG_DEBUG_FS */
198198

199+
void pnv_eeh_enable_phbs(void)
200+
{
201+
struct pci_controller *hose;
202+
struct pnv_phb *phb;
203+
204+
list_for_each_entry(hose, &hose_list, list_node) {
205+
phb = hose->private_data;
206+
/*
207+
* If EEH is enabled, we're going to rely on that.
208+
* Otherwise, we restore to conventional mechanism
209+
* to clear frozen PE during PCI config access.
210+
*/
211+
if (eeh_enabled())
212+
phb->flags |= PNV_PHB_FLAG_EEH;
213+
else
214+
phb->flags &= ~PNV_PHB_FLAG_EEH;
215+
}
216+
}
217+
199218
/**
200219
* pnv_eeh_post_init - EEH platform dependent post initialization
201220
*
@@ -234,19 +253,11 @@ int pnv_eeh_post_init(void)
234253
if (!eeh_enabled())
235254
disable_irq(eeh_event_irq);
236255

256+
pnv_eeh_enable_phbs();
257+
237258
list_for_each_entry(hose, &hose_list, list_node) {
238259
phb = hose->private_data;
239260

240-
/*
241-
* If EEH is enabled, we're going to rely on that.
242-
* Otherwise, we restore to conventional mechanism
243-
* to clear frozen PE during PCI config access.
244-
*/
245-
if (eeh_enabled())
246-
phb->flags |= PNV_PHB_FLAG_EEH;
247-
else
248-
phb->flags &= ~PNV_PHB_FLAG_EEH;
249-
250261
/* Create debugfs entries */
251262
#ifdef CONFIG_DEBUG_FS
252263
if (phb->has_dbgfs || !phb->dbgfs)
@@ -454,7 +465,11 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
454465
* Enable EEH explicitly so that we will do EEH check
455466
* while accessing I/O stuff
456467
*/
457-
eeh_add_flag(EEH_ENABLED);
468+
if (!eeh_has_flag(EEH_ENABLED)) {
469+
enable_irq(eeh_event_irq);
470+
pnv_eeh_enable_phbs();
471+
eeh_add_flag(EEH_ENABLED);
472+
}
458473

459474
/* Save memory bars */
460475
eeh_save_bars(edev);

‎arch/powerpc/platforms/pseries/eeh_pseries.c‎

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,44 +42,44 @@ static int ibm_get_config_addr_info;
4242
static int ibm_get_config_addr_info2;
4343
static int ibm_configure_pe;
4444

45-
#ifdef CONFIG_PCI_IOV
4645
void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
4746
{
4847
struct pci_dn *pdn = pci_get_pdn(pdev);
49-
struct pci_dn *physfn_pdn;
50-
struct eeh_dev *edev;
5148

52-
if (!pdev->is_virtfn)
49+
if (eeh_has_flag(EEH_FORCE_DISABLED))
5350
return;
5451

5552
pr_debug("%s: EEH: Setting up device %s.\n", __func__, pci_name(pdev));
53+
#ifdef CONFIG_PCI_IOV
54+
if (pdev->is_virtfn) {
55+
struct pci_dn *physfn_pdn;
5656

57-
pdn->device_id = pdev->device;
58-
pdn->vendor_id = pdev->vendor;
59-
pdn->class_code = pdev->class;
60-
/*
61-
* Last allow unfreeze return code used for retrieval
62-
* by user space in eeh-sysfs to show the last command
63-
* completion from platform.
64-
*/
65-
pdn->last_allow_rc = 0;
66-
physfn_pdn = pci_get_pdn(pdev->physfn);
67-
pdn->pe_number = physfn_pdn->pe_num_map[pdn->vf_index];
68-
edev = pdn_to_eeh_dev(pdn);
69-
70-
/*
71-
* The following operations will fail if VF's sysfs files
72-
* aren't created or its resources aren't finalized.
73-
*/
57+
pdn->device_id = pdev->device;
58+
pdn->vendor_id = pdev->vendor;
59+
pdn->class_code = pdev->class;
60+
/*
61+
* Last allow unfreeze return code used for retrieval
62+
* by user space in eeh-sysfs to show the last command
63+
* completion from platform.
64+
*/
65+
pdn->last_allow_rc = 0;
66+
physfn_pdn = pci_get_pdn(pdev->physfn);
67+
pdn->pe_number = physfn_pdn->pe_num_map[pdn->vf_index];
68+
}
69+
#endif
7470
eeh_add_device_early(pdn);
7571
eeh_add_device_late(pdev);
76-
edev->pe_config_addr = (pdn->busno << 16) | (pdn->devfn << 8);
77-
eeh_rmv_from_parent_pe(edev); /* Remove as it is adding to bus pe */
78-
eeh_add_to_parent_pe(edev); /* Add as VF PE type */
79-
eeh_sysfs_add_device(pdev);
72+
#ifdef CONFIG_PCI_IOV
73+
if (pdev->is_virtfn) {
74+
struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
8075

81-
}
76+
edev->pe_config_addr = (pdn->busno << 16) | (pdn->devfn << 8);
77+
eeh_rmv_from_parent_pe(edev); /* Remove as it is adding to bus pe */
78+
eeh_add_to_parent_pe(edev); /* Add as VF PE type */
79+
}
8280
#endif
81+
eeh_sysfs_add_device(pdev);
82+
}
8383

8484
/*
8585
* Buffer for reporting slot-error-detail rtas calls. Its here
@@ -146,10 +146,8 @@ static int pseries_eeh_init(void)
146146
/* Set EEH probe mode */
147147
eeh_add_flag(EEH_PROBE_MODE_DEVTREE | EEH_ENABLE_IO_FOR_LOG);
148148

149-
#ifdef CONFIG_PCI_IOV
150149
/* Set EEH machine dependent code */
151150
ppc_md.pcibios_bus_add_device = pseries_pcibios_bus_add_device;
152-
#endif
153151

154152
return 0;
155153
}

0 commit comments

Comments
 (0)