mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] MHI EP fixes and improvements
@ 2022-12-28 16:16 Manivannan Sadhasivam
  2022-12-28 16:16 ` [PATCH 1/6] bus: mhi: ep: Power up/down MHI stack during MHI RESET Manivannan Sadhasivam
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:16 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam

This series fixes several issues on the MHI EP stack and also improves
the suspend and resume functionality.

Thanks,
Mani

Manivannan Sadhasivam (6):
  bus: mhi: ep: Power up/down MHI stack during MHI RESET
  bus: mhi: ep: Check if the channel is supported by the controller
  bus: mhi: ep: Only send -ENOTCONN status if client driver is available
  bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD
    cmd
  bus: mhi: ep: Move chan->lock to the start of processing queued ch
    ring
  bus: mhi: ep: Save channel state locally during suspend and resume

 drivers/bus/mhi/ep/main.c | 79 +++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 37 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] bus: mhi: ep: Power up/down MHI stack during MHI RESET
  2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
@ 2022-12-28 16:16 ` 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
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:16 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam

During graceful shutdown scenario, host will issue MHI RESET to the
endpoint device before initiating shutdown. In that case, it makes sense
to completely power down the MHI stack as sooner or later the access to
MMIO registers will be prohibited. Also, the stack needs to be powered
up in the case of SYS_ERR to recover the device.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 35 +++++++----------------------------
 1 file changed, 7 insertions(+), 28 deletions(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 1dc8a3557a46..55209d42a995 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -973,11 +973,9 @@ static void mhi_ep_abort_transfer(struct mhi_ep_cntrl *mhi_cntrl)
 static void mhi_ep_reset_worker(struct work_struct *work)
 {
 	struct mhi_ep_cntrl *mhi_cntrl = container_of(work, struct mhi_ep_cntrl, reset_work);
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
 	enum mhi_state cur_state;
-	int ret;
 
-	mhi_ep_abort_transfer(mhi_cntrl);
+	mhi_ep_power_down(mhi_cntrl);
 
 	spin_lock_bh(&mhi_cntrl->state_lock);
 	/* Reset MMIO to signal host that the MHI_RESET is completed in endpoint */
@@ -990,27 +988,8 @@ static void mhi_ep_reset_worker(struct work_struct *work)
 	 * issue reset during shutdown also and we don't need to do re-init in
 	 * that case.
 	 */
-	if (cur_state == MHI_STATE_SYS_ERR) {
-		mhi_ep_mmio_init(mhi_cntrl);
-
-		/* Set AMSS EE before signaling ready state */
-		mhi_ep_mmio_set_env(mhi_cntrl, MHI_EE_AMSS);
-
-		/* All set, notify the host that we are ready */
-		ret = mhi_ep_set_ready_state(mhi_cntrl);
-		if (ret)
-			return;
-
-		dev_dbg(dev, "READY state notification sent to the host\n");
-
-		ret = mhi_ep_enable(mhi_cntrl);
-		if (ret) {
-			dev_err(dev, "Failed to enable MHI endpoint: %d\n", ret);
-			return;
-		}
-
-		enable_irq(mhi_cntrl->irq);
-	}
+	if (cur_state == MHI_STATE_SYS_ERR)
+		mhi_ep_power_up(mhi_cntrl);
 }
 
 /*
@@ -1089,11 +1068,11 @@ EXPORT_SYMBOL_GPL(mhi_ep_power_up);
 
 void mhi_ep_power_down(struct mhi_ep_cntrl *mhi_cntrl)
 {
-	if (mhi_cntrl->enabled)
+	if (mhi_cntrl->enabled) {
 		mhi_ep_abort_transfer(mhi_cntrl);
-
-	kfree(mhi_cntrl->mhi_event);
-	disable_irq(mhi_cntrl->irq);
+		kfree(mhi_cntrl->mhi_event);
+		disable_irq(mhi_cntrl->irq);
+	}
 }
 EXPORT_SYMBOL_GPL(mhi_ep_power_down);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller
  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
@ 2022-12-28 16:17 ` 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
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:17 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam

Before processing the command ring for the channel, check if the channel is
supported by the controller or not.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 55209d42a995..8b065a3cc848 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -123,6 +123,13 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
 	int ret;
 
 	ch_id = MHI_TRE_GET_CMD_CHID(el);
+
+	/* Check if the channel is supported by the controller */
+	if ((ch_id > mhi_cntrl->max_chan) || !mhi_cntrl->mhi_chan[ch_id].name) {
+		dev_err(dev, "Channel (%u) not supported!\n", ch_id);
+		return -ENODEV;
+	}
+
 	mhi_chan = &mhi_cntrl->mhi_chan[ch_id];
 	ch_ring = &mhi_cntrl->mhi_chan[ch_id].ring;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available
  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
  2022-12-28 16:17 ` [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller Manivannan Sadhasivam
@ 2022-12-28 16:17 ` 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
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:17 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam, stable

For the STOP and RESET commands, only send the channel disconnect status
-ENOTCONN if client driver is available. Otherwise, it will result in
null pointer dereference.

Cc: <stable@vger.kernel.org> # 5.19
Fixes: e827569062a8 ("bus: mhi: ep: Add support for processing command rings")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 8b065a3cc848..7d68b00bdbcf 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -203,9 +203,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
 		mhi_ep_mmio_disable_chdb(mhi_cntrl, ch_id);
 
 		/* Send channel disconnect status to client drivers */
-		result.transaction_status = -ENOTCONN;
-		result.bytes_xferd = 0;
-		mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
+		if (mhi_chan->xfer_cb) {
+			result.transaction_status = -ENOTCONN;
+			result.bytes_xferd = 0;
+			mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
+		}
 
 		/* Set channel state to STOP */
 		mhi_chan->state = MHI_CH_STATE_STOP;
@@ -235,9 +237,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
 		mhi_ep_ring_reset(mhi_cntrl, ch_ring);
 
 		/* Send channel disconnect status to client driver */
-		result.transaction_status = -ENOTCONN;
-		result.bytes_xferd = 0;
-		mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
+		if (mhi_chan->xfer_cb) {
+			result.transaction_status = -ENOTCONN;
+			result.bytes_xferd = 0;
+			mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
+		}
 
 		/* Set channel state to DISABLED */
 		mhi_chan->state = MHI_CH_STATE_DISABLED;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD cmd
  2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
                   ` (2 preceding siblings ...)
  2022-12-28 16:17 ` [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available Manivannan Sadhasivam
@ 2022-12-28 16:17 ` 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
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:17 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam

The debug log incorrectly mentions that STOP command is received instead of
RESET command. Fix that.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 7d68b00bdbcf..0bce6610ebf1 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -226,7 +226,7 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
 		mutex_unlock(&mhi_chan->lock);
 		break;
 	case MHI_PKT_TYPE_RESET_CHAN_CMD:
-		dev_dbg(dev, "Received STOP command for channel (%u)\n", ch_id);
+		dev_dbg(dev, "Received RESET command for channel (%u)\n", ch_id);
 		if (!ch_ring->started) {
 			dev_err(dev, "Channel (%u) not opened\n", ch_id);
 			return -ENODEV;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] bus: mhi: ep: Move chan->lock to the start of processing queued ch ring
  2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
                   ` (3 preceding siblings ...)
  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
@ 2022-12-28 16:17 ` Manivannan Sadhasivam
  2023-01-05 15:56   ` Jeffrey Hugo
  2022-12-28 16:17 ` [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Manivannan Sadhasivam
  2023-01-23  7:23 ` [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:17 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam, stable

There is a good chance that while the channel ring gets processed, the STOP
or RESET command for the channel might be received from the MHI host. In
those cases, the entire channel ring processing needs to be protected by
chan->lock to prevent the race where the corresponding channel ring might
be reset.

While at it, let's also add a sanity check to make sure that the ring is
started before processing it. Because, if the STOP/RESET command gets
processed while mhi_ep_ch_ring_worker() waited for chan->lock, the ring
would've been reset.

Cc: <stable@vger.kernel.org> # 5.19
Fixes: 03c0bb8ec983 ("bus: mhi: ep: Add support for processing channel rings")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 0bce6610ebf1..2362fcc8b32c 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -730,24 +730,37 @@ static void mhi_ep_ch_ring_worker(struct work_struct *work)
 		list_del(&itr->node);
 		ring = itr->ring;
 
+		chan = &mhi_cntrl->mhi_chan[ring->ch_id];
+		mutex_lock(&chan->lock);
+
+		/*
+		 * The ring could've stopped while we waited to grab the (chan->lock), so do
+		 * a sanity check before going further.
+		 */
+		if (!ring->started) {
+			mutex_unlock(&chan->lock);
+			kfree(itr);
+			continue;
+		}
+
 		/* Update the write offset for the ring */
 		ret = mhi_ep_update_wr_offset(ring);
 		if (ret) {
 			dev_err(dev, "Error updating write offset for ring\n");
+			mutex_unlock(&chan->lock);
 			kfree(itr);
 			continue;
 		}
 
 		/* Sanity check to make sure there are elements in the ring */
 		if (ring->rd_offset == ring->wr_offset) {
+			mutex_unlock(&chan->lock);
 			kfree(itr);
 			continue;
 		}
 
 		el = &ring->ring_cache[ring->rd_offset];
-		chan = &mhi_cntrl->mhi_chan[ring->ch_id];
 
-		mutex_lock(&chan->lock);
 		dev_dbg(dev, "Processing the ring for channel (%u)\n", ring->ch_id);
 		ret = mhi_ep_process_ch_ring(ring, el);
 		if (ret) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume
  2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
                   ` (4 preceding siblings ...)
  2022-12-28 16:17 ` [PATCH 5/6] bus: mhi: ep: Move chan->lock to the start of processing queued ch ring Manivannan Sadhasivam
@ 2022-12-28 16:17 ` Manivannan Sadhasivam
  2023-01-05 15:57   ` Jeffrey Hugo
  2023-01-23  7:23 ` [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
  6 siblings, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2022-12-28 16:17 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam, stable

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] bus: mhi: ep: Power up/down MHI stack during MHI RESET
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05  4:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel

On 12/28/2022 9:16 AM, Manivannan Sadhasivam wrote:
> During graceful shutdown scenario, host will issue MHI RESET to the
> endpoint device before initiating shutdown. In that case, it makes sense
> to completely power down the MHI stack as sooner or later the access to
> MMIO registers will be prohibited. Also, the stack needs to be powered
> up in the case of SYS_ERR to recover the device.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05  4:11 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel

On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> Before processing the command ring for the channel, check if the channel is
> supported by the controller or not.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05  4:12 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel, stable

On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> For the STOP and RESET commands, only send the channel disconnect status
> -ENOTCONN if client driver is available. Otherwise, it will result in
> null pointer dereference.
> 
> Cc: <stable@vger.kernel.org> # 5.19
> Fixes: e827569062a8 ("bus: mhi: ep: Add support for processing command rings")
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD cmd
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05 15:54 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel

On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> The debug log incorrectly mentions that STOP command is received instead of
> RESET command. Fix that.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Fixes?

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] bus: mhi: ep: Move chan->lock to the start of processing queued ch ring
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05 15:56 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel, stable

On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> There is a good chance that while the channel ring gets processed, the STOP
> or RESET command for the channel might be received from the MHI host. In
> those cases, the entire channel ring processing needs to be protected by
> chan->lock to prevent the race where the corresponding channel ring might
> be reset.
> 
> While at it, let's also add a sanity check to make sure that the ring is
> started before processing it. Because, if the STOP/RESET command gets
> processed while mhi_ep_ch_ring_worker() waited for chan->lock, the ring
> would've been reset.
> 
> Cc: <stable@vger.kernel.org> # 5.19
> Fixes: 03c0bb8ec983 ("bus: mhi: ep: Add support for processing channel rings")
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume
  2022-12-28 16:17 ` [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Manivannan Sadhasivam
@ 2023-01-05 15:57   ` Jeffrey Hugo
  0 siblings, 0 replies; 14+ messages in thread
From: Jeffrey Hugo @ 2023-01-05 15:57 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi; +Cc: linux-arm-msm, linux-kernel, stable

On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> 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>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/6] MHI EP fixes and improvements
  2022-12-28 16:16 [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam
                   ` (5 preceding siblings ...)
  2022-12-28 16:17 ` [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Manivannan Sadhasivam
@ 2023-01-23  7:23 ` Manivannan Sadhasivam
  6 siblings, 0 replies; 14+ messages in thread
From: Manivannan Sadhasivam @ 2023-01-23  7:23 UTC (permalink / raw)
  To: mhi; +Cc: linux-arm-msm, linux-kernel

On Wed, Dec 28, 2022 at 09:46:58PM +0530, Manivannan Sadhasivam wrote:
> This series fixes several issues on the MHI EP stack and also improves
> the suspend and resume functionality.
> 

Applied to mhi-next!

Thanks,
Mani

> Thanks,
> Mani
> 
> Manivannan Sadhasivam (6):
>   bus: mhi: ep: Power up/down MHI stack during MHI RESET
>   bus: mhi: ep: Check if the channel is supported by the controller
>   bus: mhi: ep: Only send -ENOTCONN status if client driver is available
>   bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD
>     cmd
>   bus: mhi: ep: Move chan->lock to the start of processing queued ch
>     ring
>   bus: mhi: ep: Save channel state locally during suspend and resume
> 
>  drivers/bus/mhi/ep/main.c | 79 +++++++++++++++++++++------------------
>  1 file changed, 42 insertions(+), 37 deletions(-)
> 
> -- 
> 2.25.1
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-01-23  7:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Manivannan Sadhasivam
2023-01-05 15:57   ` Jeffrey Hugo
2023-01-23  7:23 ` [PATCH 0/6] MHI EP fixes and improvements Manivannan Sadhasivam

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).