[RESEND PATCH v4 4/8] bus: mhi: core: Clear configuration from channel context during reset

2021-01-08 Thread Bhaumik Bhatt
When clearing up the channel context after client drivers are
done using channels, the configuration is currently not being
reset entirely. Ensure this is done to appropriately handle
issues where clients unaware of the context state end up calling
functions which expect a context.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/init.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 482b365..30eef19 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -558,6 +558,7 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
struct mhi_ring *buf_ring;
struct mhi_ring *tre_ring;
struct mhi_chan_ctxt *chan_ctxt;
+   u32 tmp;
 
buf_ring = _chan->buf_ring;
tre_ring = _chan->tre_ring;
@@ -568,7 +569,19 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
vfree(buf_ring->base);
 
buf_ring->base = tre_ring->base = NULL;
+   tre_ring->ctxt_wp = NULL;
chan_ctxt->rbase = 0;
+   chan_ctxt->rlen = 0;
+   chan_ctxt->rp = 0;
+   chan_ctxt->wp = 0;
+
+   tmp = chan_ctxt->chcfg;
+   tmp &= ~CHAN_CTX_CHSTATE_MASK;
+   tmp |= (MHI_CH_STATE_DISABLED << CHAN_CTX_CHSTATE_SHIFT);
+   chan_ctxt->chcfg = tmp;
+
+   /* Update to all cores */
+   smp_wmb();
 }
 
 int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH v4 4/8] bus: mhi: core: Clear configuration from channel context during reset

2020-12-03 Thread Hemant Kumar




On 12/3/20 5:23 PM, Bhaumik Bhatt wrote:

When clearing up the channel context after client drivers are
done using channels, the configuration is currently not being
reset entirely. Ensure this is done to appropriately handle
issues where clients unaware of the context state end up calling
functions which expect a context.

Signed-off-by: Bhaumik Bhatt 
---


Reviewed-by: Hemant Kumar 

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH v4 4/8] bus: mhi: core: Clear configuration from channel context during reset

2020-12-03 Thread Bhaumik Bhatt
When clearing up the channel context after client drivers are
done using channels, the configuration is currently not being
reset entirely. Ensure this is done to appropriately handle
issues where clients unaware of the context state end up calling
functions which expect a context.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/init.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 5cdddb2..1b6962d 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -553,6 +553,7 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
struct mhi_ring *buf_ring;
struct mhi_ring *tre_ring;
struct mhi_chan_ctxt *chan_ctxt;
+   u32 tmp;
 
buf_ring = _chan->buf_ring;
tre_ring = _chan->tre_ring;
@@ -563,7 +564,19 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
vfree(buf_ring->base);
 
buf_ring->base = tre_ring->base = NULL;
+   tre_ring->ctxt_wp = NULL;
chan_ctxt->rbase = 0;
+   chan_ctxt->rlen = 0;
+   chan_ctxt->rp = 0;
+   chan_ctxt->wp = 0;
+
+   tmp = chan_ctxt->chcfg;
+   tmp &= ~CHAN_CTX_CHSTATE_MASK;
+   tmp |= (MHI_CH_STATE_DISABLED << CHAN_CTX_CHSTATE_SHIFT);
+   chan_ctxt->chcfg = tmp;
+
+   /* Update to all cores */
+   smp_wmb();
 }
 
 int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project