mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: mhi@lists.linux.dev
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	stable@vger.kernel.org
Subject: [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume
Date: Wed, 28 Dec 2022 21:47:04 +0530	[thread overview]
Message-ID: <20221228161704.255268-7-manivannan.sadhasivam@linaro.org> (raw)
In-Reply-To: <20221228161704.255268-1-manivannan.sadhasivam@linaro.org>

During suspend and resume, the channel state needs to be saved locally.
Otherwise, the endpoint may access the channels while they were being
suspended and causing access violations.

Fix it by saving the channel state locally during suspend and resume.

Cc: <stable@vger.kernel.org> # 5.19
Fixes: e4b7b5f0f30a ("bus: mhi: ep: Add support for suspending and resuming channels")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 2362fcc8b32c..bcaaba97ef63 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -1122,6 +1122,7 @@ void mhi_ep_suspend_channels(struct mhi_ep_cntrl *mhi_cntrl)
 
 		dev_dbg(&mhi_chan->mhi_dev->dev, "Suspending channel\n");
 		/* Set channel state to SUSPENDED */
+		mhi_chan->state = MHI_CH_STATE_SUSPENDED;
 		tmp &= ~CHAN_CTX_CHSTATE_MASK;
 		tmp |= FIELD_PREP(CHAN_CTX_CHSTATE_MASK, MHI_CH_STATE_SUSPENDED);
 		mhi_cntrl->ch_ctx_cache[i].chcfg = cpu_to_le32(tmp);
@@ -1151,6 +1152,7 @@ void mhi_ep_resume_channels(struct mhi_ep_cntrl *mhi_cntrl)
 
 		dev_dbg(&mhi_chan->mhi_dev->dev, "Resuming channel\n");
 		/* Set channel state to RUNNING */
+		mhi_chan->state = MHI_CH_STATE_RUNNING;
 		tmp &= ~CHAN_CTX_CHSTATE_MASK;
 		tmp |= FIELD_PREP(CHAN_CTX_CHSTATE_MASK, MHI_CH_STATE_RUNNING);
 		mhi_cntrl->ch_ctx_cache[i].chcfg = cpu_to_le32(tmp);
-- 
2.25.1


  parent reply	other threads:[~2022-12-28 16:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
2022-12-28 16:16 ` [PATCH 1/6] bus: mhi: ep: Power up/down MHI stack during MHI RESET Manivannan Sadhasivam
2023-01-05  4:09   ` Jeffrey Hugo
2022-12-28 16:17 ` [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller Manivannan Sadhasivam
2023-01-05  4:11   ` Jeffrey Hugo
2022-12-28 16:17 ` [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available Manivannan Sadhasivam
2023-01-05  4:12   ` Jeffrey Hugo
2022-12-28 16:17 ` [PATCH 4/6] bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD cmd Manivannan Sadhasivam
2023-01-05 15:54   ` Jeffrey Hugo
2022-12-28 16:17 ` [PATCH 5/6] bus: mhi: ep: Move chan->lock to the start of processing queued ch ring Manivannan Sadhasivam
2023-01-05 15:56   ` Jeffrey Hugo
2022-12-28 16:17 ` Manivannan Sadhasivam [this message]
2023-01-05 15:57   ` [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Jeffrey Hugo
2023-01-23  7:23 ` [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221228161704.255268-7-manivannan.sadhasivam@linaro.org \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhi@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).