linux-stable/drivers/bus
Jeffrey Hugo 7dbf082988 bus: mhi: host: Add MHI_PM_SYS_ERR_FAIL state
[ Upstream commit bce3f77068 ]

When processing a SYSERR, if the device does not respond to the MHI_RESET
from the host, the host will be stuck in a difficult to recover state.
The host will remain in MHI_PM_SYS_ERR_PROCESS and not clean up the host
channels.  Clients will not be notified of the SYSERR via the destruction
of their channel devices, which means clients may think that the device is
still up.  Subsequent SYSERR events such as a device fatal error will not
be processed as the state machine cannot transition from PROCESS back to
DETECT.  The only way to recover from this is to unload the mhi module
(wipe the state machine state) or for the mhi controller to initiate
SHUTDOWN.

This issue was discovered by stress testing soc_reset events on AIC100
via the sysfs node.

soc_reset is processed entirely in hardware.  When the register write
hits the endpoint hardware, it causes the soc to reset without firmware
involvement.  In stress testing, there is a rare race where soc_reset N
will cause the soc to reset and PBL to signal SYSERR (fatal error).  If
soc_reset N+1 is triggered before PBL can process the MHI_RESET from the
host, then the soc will reset again, and re-run PBL from the beginning.
This will cause PBL to lose all state.  PBL will be waiting for the host
to respond to the new syserr, but host will be stuck expecting the
previous MHI_RESET to be processed.

Additionally, the AMSS EE firmware (QSM) was hacked to synthetically
reproduce the issue by simulating a FW hang after the QSM issued a
SYSERR.  In this case, soc_reset would not recover the device.

For this failure case, to recover the device, we need a state similar to
PROCESS, but can transition to DETECT.  There is not a viable existing
state to use.  POR has the needed transitions, but assumes the device is
in a good state and could allow the host to attempt to use the device.
Allowing PROCESS to transition to DETECT invites the possibility of
parallel SYSERR processing which could get the host and device out of
sync.

Thus, invent a new state - MHI_PM_SYS_ERR_FAIL

This essentially a holding state.  It allows us to clean up the host
elements that are based on the old state of the device (channels), but
does not allow us to directly advance back to an operational state.  It
does allow the detection and processing of another SYSERR which may
recover the device, or allows the controller to do a clean shutdown.

Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20240112180800.536733-1-quic_jhugo@quicinc.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:05:16 +02:00
..
fsl-mc bus: fsl-mc: don't assume child devices are all fsl-mc devices 2023-07-19 16:21:57 +02:00
mhi bus: mhi: host: Add MHI_PM_SYS_ERR_FAIL state 2024-04-13 13:05:16 +02:00
Kconfig bus: tegra-aconnect: Update dependency to ARCH_TEGRA 2024-03-26 18:20:36 -04:00
Makefile bus: add driver for initializing the SSC bus on (some) qcom SoCs 2022-04-19 13:03:57 -05:00
arm-cci.c
arm-integrator-lm.c
brcmstb_gisb.c bus: brcmstb_gisb: Remove the suppress_bind_attrs attribute of the driver 2022-04-26 09:12:45 -07:00
bt1-apb.c bus: bt1-apb: Don't print error on -EPROBE_DEFER 2022-06-14 12:21:44 +02:00
bt1-axi.c bus: bt1-axi: Don't print error on -EPROBE_DEFER 2022-06-14 12:21:44 +02:00
da8xx-mstpri.c
hisi_lpc.c bus: hisi_lpc: Use platform_device_register_full() 2022-09-08 02:27:29 +00:00
imx-weim.c treewide: Fix probing of devices in DT overlays 2023-09-13 09:43:05 +02:00
intel-ixp4xx-eb.c bus: ixp4xx: fix IXP4XX_EXP_T1_MASK 2023-07-23 13:49:43 +02:00
mips_cdmm.c mips: cdmm: Fix refcount leak in mips_cdmm_phys_base 2022-03-14 15:01:51 +01:00
moxtet.c bus: moxtet: Add spi device table 2024-02-23 09:12:48 +01:00
mvebu-mbus.c bus: mvebu-mbus: use DEFINE_SHOW_ATTRIBUTE to simplify mvebu_{sdram/devs}_debug 2022-09-24 14:59:26 +02:00
omap-ocp2scp.c
omap_l3_noc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_320.RULE 2022-06-10 14:51:36 +02:00
omap_l3_noc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_320.RULE 2022-06-10 14:51:36 +02:00
omap_l3_smx.c
omap_l3_smx.h
qcom-ebi2.c
qcom-ssc-block-bus.c bus: add driver for initializing the SSC bus on (some) qcom SoCs 2022-04-19 13:03:57 -05:00
simple-pm-bus.c drivers: bus: simple-pm-bus: Add support for probing simple bus only devices 2021-10-05 17:47:15 +02:00
sun50i-de2.c bus: sun50i-de2: Adjust printing error message 2021-10-13 14:48:48 +02:00
sunxi-rsb.c bus: sunxi-rsb: Fix error handling in sunxi_rsb_init() 2023-02-09 11:27:59 +01:00
tegra-aconnect.c
tegra-gmi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_56.RULE (part 2) 2022-06-10 14:51:35 +02:00
ti-pwmss.c
ti-sysc.c bus: ti-sysc: Flush posted write only after srst_udelay 2024-01-01 12:39:07 +00:00
ts-nbus.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_56.RULE (part 2) 2022-06-10 14:51:35 +02:00
uniphier-system-bus.c
vexpress-config.c