FAILED: patch "[PATCH] bus: mhi: host: Use mhi_tryset_pm_state() for setting fw" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 1d1493bdc25f498468a606a4ece947d155cfa3a9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023050652-balancing-evasive-6713@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
1d1493bdc25f ("bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 1d1493bdc25f498468a606a4ece947d155cfa3a9 Mon Sep 17 00:00:00 2001
From: Jeffrey Hugo <[email protected]>
Date: Mon, 10 Apr 2023 09:58:12 -0600
Subject: [PATCH] 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.
drivers/bus/mhi/host/boot.c +12 -4
@@ -391,6 +391,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) {const struct firmware *firmware =NULL ;struct device *dev = &mhi_cntrl->mhi_dev->dev; +enum mhi_pm_state new_state;const char *fw_name;void *buf;dma_addr_t dma_addr;
@@ -508,14 +509,18 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) } error_fw_load: - mhi_cntrl->pm_state =MHI_PM_FW_DL_ERR ; -wake_up_all (&mhi_cntrl->state_event); +write_lock_irq (&mhi_cntrl->pm_lock); + new_state =mhi_tryset_pm_state (mhi_cntrl,MHI_PM_FW_DL_ERR ); +write_unlock_irq (&mhi_cntrl->pm_lock); +if (new_state ==MHI_PM_FW_DL_ERR ) +wake_up_all (&mhi_cntrl->state_event); }int mhi_download_amss_image (struct mhi_controller *mhi_cntrl) {struct image_info *image_info = mhi_cntrl->fbc_image;struct device *dev = &mhi_cntrl->mhi_dev->dev; +enum mhi_pm_state new_state;int ret;if (!image_info)
@@ -526,8 +531,11 @@ int mhi_download_amss_image(struct mhi_controller *mhi_cntrl) &image_info->mhi_buf[image_info->entries - 1]);if (ret) {dev_err (dev,"MHI did not load AMSS, ret:%d\n" , ret); - mhi_cntrl->pm_state =MHI_PM_FW_DL_ERR ; -wake_up_all (&mhi_cntrl->state_event); +write_lock_irq (&mhi_cntrl->pm_lock); + new_state =mhi_tryset_pm_state (mhi_cntrl,MHI_PM_FW_DL_ERR ); +write_unlock_irq (&mhi_cntrl->pm_lock); +if (new_state ==MHI_PM_FW_DL_ERR ) +wake_up_all (&mhi_cntrl->state_event); }return ret;
PATCH 1/1 bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state
Commit 1d1493bdc25f498468a606a4ece947d155cfa3a9 upstream.
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.
--- drivers/bus/mhi/core/boot.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/bus/mhi/core/boot.c +12 -4
@@ -390,6 +390,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) {const struct firmware *firmware =NULL ;struct device *dev = &mhi_cntrl->mhi_dev->dev; +enum mhi_pm_state new_state;const char *fw_name;void *buf;dma_addr_t dma_addr;
@@ -507,14 +508,18 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) } error_fw_load: - mhi_cntrl->pm_state =MHI_PM_FW_DL_ERR ; -wake_up_all (&mhi_cntrl->state_event); +write_lock_irq (&mhi_cntrl->pm_lock); + new_state =mhi_tryset_pm_state (mhi_cntrl,MHI_PM_FW_DL_ERR ); +write_unlock_irq (&mhi_cntrl->pm_lock); +if (new_state ==MHI_PM_FW_DL_ERR ) +wake_up_all (&mhi_cntrl->state_event); }int mhi_download_amss_image (struct mhi_controller *mhi_cntrl) {struct image_info *image_info = mhi_cntrl->fbc_image;struct device *dev = &mhi_cntrl->mhi_dev->dev; +enum mhi_pm_state new_state;int ret;if (!image_info)
@@ -525,8 +530,11 @@ int mhi_download_amss_image(struct mhi_controller *mhi_cntrl) &image_info->mhi_buf[image_info->entries - 1]);if (ret) {dev_err (dev,"MHI did not load AMSS, ret:%d\n" , ret); - mhi_cntrl->pm_state =MHI_PM_FW_DL_ERR ; -wake_up_all (&mhi_cntrl->state_event); +write_lock_irq (&mhi_cntrl->pm_lock); + new_state =mhi_tryset_pm_state (mhi_cntrl,MHI_PM_FW_DL_ERR ); +write_unlock_irq (&mhi_cntrl->pm_lock); +if (new_state ==MHI_PM_FW_DL_ERR ) +wake_up_all (&mhi_cntrl->state_event); }return ret;
Signature · 1 line
2.7.4