Skip to content

Commit 77583f7

Browse files
maheshsalmpe
authored andcommitted
PCI: rpaphp: Error out on busy status from get-sensor-state
When certain PHB HW failure causes pHyp to recover PHB, it marks the PE state as temporarily unavailable until recovery is complete. This also triggers an EEH handler in Linux which needs to notify drivers, and perform recovery. But before notifying the driver about the PCI error it uses get_adapter_status()->rpaphp_get_sensor_state()->rtas_call(get-sensor-state) operation of the hotplug_slot to determine if the slot contains a device or not. If the slot is empty, the recovery is skipped entirely. eeh_event_handler() ->eeh_handle_normal_event() ->eeh_slot_presence_check() ->get_adapter_status() ->rpaphp_get_sensor_state() ->rtas_get_sensor() ->rtas_call(get-sensor-state) However on certain PHB failures, the RTAS call rtas_call(get-sensor-state) returns extended busy error (9902) until PHB is recovered by pHyp. Once PHB is recovered, the rtas_call(get-sensor-state) returns success with correct presence status. The RTAS call interface rtas_get_sensor() loops over the RTAS call on extended delay return code (9902) until the return value is either success (0) or error (-1). This causes the EEH handler to get stuck for ~6 seconds before it could notify that the PCI error has been detected and stop any active operations. Hence with running I/O traffic, during this 6 seconds, the network driver continues its operation and hits a timeout (netdev watchdog). ------------ [52732.244731] DEBUG: ibm_read_slot_reset_state2() [52732.244762] DEBUG: ret = 0, rets[0]=5, rets[1]=1, rets[2]=4000, rets[3]=> [52732.244798] DEBUG: in eeh_slot_presence_check [52732.244804] DEBUG: error state check [52732.244807] DEBUG: Is slot hotpluggable [52732.244810] DEBUG: hotpluggable ops ? [52732.244953] DEBUG: Calling ops->get_adapter_status [52732.244958] DEBUG: calling rpaphp_get_sensor_state [52736.564262] ------------[ cut here ]------------ [52736.564299] NETDEV WATCHDOG: enP64p1s0f3 (tg3): transmit queue 0 timed o> [52736.564324] WARNING: CPU: 1442 PID: 0 at net/sched/sch_generic.c:478 dev> [...] [52736.564505] NIP [c000000000c32368] dev_watchdog+0x438/0x440 [52736.564513] LR [c000000000c32364] dev_watchdog+0x434/0x440 ------------ On timeouts, network driver starts dumping debug information to console (e.g bnx2 driver calls bnx2x_panic_dump()), and go into recovery path while pHyp is still recovering the PHB. As part of recovery, the driver tries to reset the device and it keeps failing since every PCI read/write returns ff's. And when EEH recovery kicks-in, the driver is unable to recover the device. This impacts the ssh connection and leads to the system being inaccessible. To get the NIC working again it needs a reboot or re-assign the I/O adapter from HMC. [ 9531.168587] EEH: Beginning: 'slot_reset' [ 9531.168601] PCI 0013:01:00.0#10000: EEH: Invoking bnx2x->slot_reset() [...] [ 9614.110094] bnx2x: [bnx2x_func_stop:9129(enP19p1s0f0)]FUNC_STOP ramrod failed. Running a dry transaction [ 9614.110300] bnx2x: [bnx2x_igu_int_disable:902(enP19p1s0f0)]BUG! Proper val not read from IGU! [ 9629.178067] bnx2x: [bnx2x_fw_command:3055(enP19p1s0f0)]FW failed to respond! [ 9629.178085] bnx2x 0013:01:00.0 enP19p1s0f0: bc 7.10.4 [ 9629.178091] bnx2x: [bnx2x_fw_dump_lvl:789(enP19p1s0f0)]Cannot dump MCP info while in PCI error [ 9644.241813] bnx2x: [bnx2x_io_slot_reset:14245(enP19p1s0f0)]IO slot reset --> driver unload [...] [ 9644.241819] PCI 0013:01:00.0#10000: EEH: bnx2x driver reports: 'disconnect' [ 9644.241823] PCI 0013:01:00.1#10000: EEH: Invoking bnx2x->slot_reset() [ 9644.241827] bnx2x: [bnx2x_io_slot_reset:14229(enP19p1s0f1)]IO slot reset initializing... [ 9644.241916] bnx2x 0013:01:00.1: enabling device (0140 -> 0142) [ 9644.258604] bnx2x: [bnx2x_io_slot_reset:14245(enP19p1s0f1)]IO slot reset --> driver unload [ 9644.258612] PCI 0013:01:00.1#10000: EEH: bnx2x driver reports: 'disconnect' [ 9644.258615] EEH: Finished:'slot_reset' with aggregate recovery state:'disconnect' [ 9644.258620] EEH: Unable to recover from failure from PHB#13-PE#10000. [ 9644.261811] EEH: Beginning: 'error_detected(permanent failure)' [...] [ 9644.261823] EEH: Finished:'error_detected(permanent failure)' Hence, it becomes important to inform driver about the PCI error detection as early as possible, so that driver is aware of PCI error and waits for EEH handler's next action for successful recovery. Current implementation uses rtas_get_sensor() API which blocks the slot check state until RTAS call returns success. To avoid this, fix the PCI hotplug driver (rpaphp) to return an error (-EBUSY) if the slot presence state can not be detected immediately while PE is in EEH recovery state. Change rpaphp_get_sensor_state() to invoke rtas_call(get-sensor-state) directly only if the respective PE is in EEH recovery state, and take actions based on RTAS return status. This way EEH handler will not be blocked on rpaphp_get_sensor_state() and can immediately notify driver about the PCI error and stop any active operations. In normal cases (non-EEH case) rpaphp_get_sensor_state() will continue to invoke rtas_get_sensor() as it was earlier with no change in existing behavior. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.ibm.com> Reviewed-by: Nathan Lynch <nathanl@linux.ibm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/169235815601.193557.13989873835811325343.stgit@jupiter
1 parent e160bf6 commit 77583f7

1 file changed

Lines changed: 82 additions & 3 deletions

File tree

drivers/pci/hotplug/rpaphp_pci.c

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,92 @@
1919
#include "../pci.h" /* for pci_add_new_bus */
2020
#include "rpaphp.h"
2121

22+
/*
23+
* RTAS call get-sensor-state(DR_ENTITY_SENSE) return values as per PAPR:
24+
* -- generic return codes ---
25+
* -1: Hardware Error
26+
* -2: RTAS_BUSY
27+
* -3: Invalid sensor. RTAS Parameter Error.
28+
* -- rtas_get_sensor function specific return codes ---
29+
* -9000: Need DR entity to be powered up and unisolated before RTAS call
30+
* -9001: Need DR entity to be powered up, but not unisolated, before RTAS call
31+
* -9002: DR entity unusable
32+
* 990x: Extended delay - where x is a number in the range of 0-5
33+
*/
34+
#define RTAS_SLOT_UNISOLATED -9000
35+
#define RTAS_SLOT_NOT_UNISOLATED -9001
36+
#define RTAS_SLOT_NOT_USABLE -9002
37+
38+
static int rtas_get_sensor_errno(int rtas_rc)
39+
{
40+
switch (rtas_rc) {
41+
case 0:
42+
/* Success case */
43+
return 0;
44+
case RTAS_SLOT_UNISOLATED:
45+
case RTAS_SLOT_NOT_UNISOLATED:
46+
return -EFAULT;
47+
case RTAS_SLOT_NOT_USABLE:
48+
return -ENODEV;
49+
case RTAS_BUSY:
50+
case RTAS_EXTENDED_DELAY_MIN...RTAS_EXTENDED_DELAY_MAX:
51+
return -EBUSY;
52+
default:
53+
return rtas_error_rc(rtas_rc);
54+
}
55+
}
56+
57+
/*
58+
* get_adapter_status() can be called by the EEH handler during EEH recovery.
59+
* On certain PHB failures, the RTAS call rtas_call(get-sensor-state) returns
60+
* extended busy error (9902) until PHB is recovered by pHyp. The RTAS call
61+
* interface rtas_get_sensor() loops over the RTAS call on extended delay
62+
* return code (9902) until the return value is either success (0) or error
63+
* (-1). This causes the EEH handler to get stuck for ~6 seconds before it
64+
* could notify that the PCI error has been detected and stop any active
65+
* operations. This sometimes causes EEH recovery to fail. To avoid this issue,
66+
* invoke rtas_call(get-sensor-state) directly if the respective PE is in EEH
67+
* recovery state and return -EBUSY error based on RTAS return status. This
68+
* will help the EEH handler to notify the driver about the PCI error
69+
* immediately and successfully proceed with EEH recovery steps.
70+
*/
71+
72+
static int __rpaphp_get_sensor_state(struct slot *slot, int *state)
73+
{
74+
int rc;
75+
int token = rtas_token("get-sensor-state");
76+
struct pci_dn *pdn;
77+
struct eeh_pe *pe;
78+
struct pci_controller *phb = PCI_DN(slot->dn)->phb;
79+
80+
if (token == RTAS_UNKNOWN_SERVICE)
81+
return -ENOENT;
82+
83+
/*
84+
* Fallback to existing method for empty slot or PE isn't in EEH
85+
* recovery.
86+
*/
87+
pdn = list_first_entry_or_null(&PCI_DN(phb->dn)->child_list,
88+
struct pci_dn, list);
89+
if (!pdn)
90+
goto fallback;
91+
92+
pe = eeh_dev_to_pe(pdn->edev);
93+
if (pe && (pe->state & EEH_PE_RECOVERING)) {
94+
rc = rtas_call(token, 2, 2, state, DR_ENTITY_SENSE,
95+
slot->index);
96+
return rtas_get_sensor_errno(rc);
97+
}
98+
fallback:
99+
return rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
100+
}
101+
22102
int rpaphp_get_sensor_state(struct slot *slot, int *state)
23103
{
24104
int rc;
25105
int setlevel;
26106

27-
rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
107+
rc = __rpaphp_get_sensor_state(slot, state);
28108

29109
if (rc < 0) {
30110
if (rc == -EFAULT || rc == -EEXIST) {
@@ -40,8 +120,7 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
40120
dbg("%s: power on slot[%s] failed rc=%d.\n",
41121
__func__, slot->name, rc);
42122
} else {
43-
rc = rtas_get_sensor(DR_ENTITY_SENSE,
44-
slot->index, state);
123+
rc = __rpaphp_get_sensor_state(slot, state);
45124
}
46125
} else if (rc == -ENODEV)
47126
info("%s: slot is unusable\n", __func__);

0 commit comments

Comments
 (0)