mirror_ubuntu-kernels/drivers/bus/mhi/host
Jeffrey Hugo 1d1493bdc2 bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state
If firmware loading fails, the controller's pm_state is updated to
MHI_PM_FW_DL_ERR unconditionally.  This can corrupt the pm_state as the
update is not done under the proper lock, and also does not validate
the state transition.  The firmware loading can fail due to a detected
syserr, but if MHI_PM_FW_DL_ERR is unconditionally set as the pm_state,
the handling of the syserr can break when it attempts to transition from
syserr detect, to syserr process.

By grabbing the lock, we ensure we don't race with some other pm_state
update.  By using mhi_try_set_pm_state(), we check that the transition
to MHI_PM_FW_DL_ERR is valid via the state machine logic.  If it is not
valid, then some other transition is occurring like syserr processing, and
we assume that will resolve the firmware loading error.

Fixes: 12e050c77b ("bus: mhi: core: Move to an error state on any firmware load failure")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/1681142292-27571-3-git-send-email-quic_jhugo@quicinc.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2023-04-10 21:32:55 +05:30
..
boot.c bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state 2023-04-10 21:32:55 +05:30
debugfs.c bus: mhi: Make mhi_state_str[] array static inline and move to common.h 2022-03-18 14:02:55 +01:00
init.c bus: mhi: host: Use ERANGE for BHIOFF/BHIEOFF range check 2023-04-03 10:48:17 +05:30
internal.h treewide: use get_random_u32_inclusive() when possible 2022-11-18 02:18:02 +01:00
Kconfig
main.c bus: mhi: host: Remove duplicate ee check for syserr 2023-04-10 21:32:55 +05:30
Makefile
pci_generic.c bus: mhi: pci_generic: Add Foxconn T99W510 2023-04-03 10:50:43 +05:30
pm.c bus: mhi: host: Fix race between channel preparation and M0 event 2022-10-28 22:59:10 +05:30