* [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity
2021-04-06 9:11 [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Loic Poulain
@ 2021-04-06 9:11 ` Loic Poulain
2021-04-07 5:01 ` Manivannan Sadhasivam
2021-04-07 6:50 ` Manivannan Sadhasivam
2021-04-07 5:05 ` [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Manivannan Sadhasivam
2021-04-07 6:50 ` Manivannan Sadhasivam
2 siblings, 2 replies; 6+ messages in thread
From: Loic Poulain @ 2021-04-06 9:11 UTC (permalink / raw)
To: manivannan.sadhasivam, hemantk; +Cc: bbhatt, linux-arm-msm, Loic Poulain
Since M3 can be entered/exited quite a lot when used for runtime PM,
keep the mhi suspend/resume transitions quiet.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
v2: Coding style, adjust alignment of dev_dbg params
drivers/bus/mhi/core/pm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index edd7794..6cbac21 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -858,7 +858,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
return -EBUSY;
}
- dev_info(dev, "Allowing M3 transition\n");
+ dev_dbg(dev, "Allowing M3 transition\n");
new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER);
if (new_state != MHI_PM_M3_ENTER) {
write_unlock_irq(&mhi_cntrl->pm_lock);
@@ -872,7 +872,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
/* Set MHI to M3 and wait for completion */
mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3);
write_unlock_irq(&mhi_cntrl->pm_lock);
- dev_info(dev, "Wait for M3 completion\n");
+ dev_dbg(dev, "Wait for M3 completion\n");
ret = wait_event_timeout(mhi_cntrl->state_event,
mhi_cntrl->dev_state == MHI_STATE_M3 ||
@@ -906,9 +906,9 @@ int mhi_pm_resume(struct mhi_controller *mhi_cntrl)
enum mhi_pm_state cur_state;
int ret;
- dev_info(dev, "Entered with PM state: %s, MHI state: %s\n",
- to_mhi_pm_state_str(mhi_cntrl->pm_state),
- TO_MHI_STATE_STR(mhi_cntrl->dev_state));
+ dev_dbg(dev, "Entered with PM state: %s, MHI state: %s\n",
+ to_mhi_pm_state_str(mhi_cntrl->pm_state),
+ TO_MHI_STATE_STR(mhi_cntrl->dev_state));
if (mhi_cntrl->pm_state == MHI_PM_DISABLE)
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity
2021-04-06 9:11 ` [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity Loic Poulain
@ 2021-04-07 5:01 ` Manivannan Sadhasivam
2021-04-07 6:50 ` Manivannan Sadhasivam
1 sibling, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2021-04-07 5:01 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, bbhatt, linux-arm-msm
On Tue, Apr 06, 2021 at 11:11:55AM +0200, Loic Poulain wrote:
> Since M3 can be entered/exited quite a lot when used for runtime PM,
> keep the mhi suspend/resume transitions quiet.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thanks,
Mani
> ---
> v2: Coding style, adjust alignment of dev_dbg params
>
> drivers/bus/mhi/core/pm.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index edd7794..6cbac21 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -858,7 +858,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
> return -EBUSY;
> }
>
> - dev_info(dev, "Allowing M3 transition\n");
> + dev_dbg(dev, "Allowing M3 transition\n");
> new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER);
> if (new_state != MHI_PM_M3_ENTER) {
> write_unlock_irq(&mhi_cntrl->pm_lock);
> @@ -872,7 +872,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
> /* Set MHI to M3 and wait for completion */
> mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3);
> write_unlock_irq(&mhi_cntrl->pm_lock);
> - dev_info(dev, "Wait for M3 completion\n");
> + dev_dbg(dev, "Wait for M3 completion\n");
This could be "Waiting for M3 completion". But I'll change it while
applying.
Thanks,
Mani
>
> ret = wait_event_timeout(mhi_cntrl->state_event,
> mhi_cntrl->dev_state == MHI_STATE_M3 ||
> @@ -906,9 +906,9 @@ int mhi_pm_resume(struct mhi_controller *mhi_cntrl)
> enum mhi_pm_state cur_state;
> int ret;
>
> - dev_info(dev, "Entered with PM state: %s, MHI state: %s\n",
> - to_mhi_pm_state_str(mhi_cntrl->pm_state),
> - TO_MHI_STATE_STR(mhi_cntrl->dev_state));
> + dev_dbg(dev, "Entered with PM state: %s, MHI state: %s\n",
> + to_mhi_pm_state_str(mhi_cntrl->pm_state),
> + TO_MHI_STATE_STR(mhi_cntrl->dev_state));
>
> if (mhi_cntrl->pm_state == MHI_PM_DISABLE)
> return 0;
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity
2021-04-06 9:11 ` [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity Loic Poulain
2021-04-07 5:01 ` Manivannan Sadhasivam
@ 2021-04-07 6:50 ` Manivannan Sadhasivam
1 sibling, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2021-04-07 6:50 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, bbhatt, linux-arm-msm
On Tue, Apr 06, 2021 at 11:11:55AM +0200, Loic Poulain wrote:
> Since M3 can be entered/exited quite a lot when used for runtime PM,
> keep the mhi suspend/resume transitions quiet.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Applied to mhi-next!
Thanks,
Mani
> ---
> v2: Coding style, adjust alignment of dev_dbg params
>
> drivers/bus/mhi/core/pm.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index edd7794..6cbac21 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -858,7 +858,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
> return -EBUSY;
> }
>
> - dev_info(dev, "Allowing M3 transition\n");
> + dev_dbg(dev, "Allowing M3 transition\n");
> new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER);
> if (new_state != MHI_PM_M3_ENTER) {
> write_unlock_irq(&mhi_cntrl->pm_lock);
> @@ -872,7 +872,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
> /* Set MHI to M3 and wait for completion */
> mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3);
> write_unlock_irq(&mhi_cntrl->pm_lock);
> - dev_info(dev, "Wait for M3 completion\n");
> + dev_dbg(dev, "Wait for M3 completion\n");
>
> ret = wait_event_timeout(mhi_cntrl->state_event,
> mhi_cntrl->dev_state == MHI_STATE_M3 ||
> @@ -906,9 +906,9 @@ int mhi_pm_resume(struct mhi_controller *mhi_cntrl)
> enum mhi_pm_state cur_state;
> int ret;
>
> - dev_info(dev, "Entered with PM state: %s, MHI state: %s\n",
> - to_mhi_pm_state_str(mhi_cntrl->pm_state),
> - TO_MHI_STATE_STR(mhi_cntrl->dev_state));
> + dev_dbg(dev, "Entered with PM state: %s, MHI state: %s\n",
> + to_mhi_pm_state_str(mhi_cntrl->pm_state),
> + TO_MHI_STATE_STR(mhi_cntrl->dev_state));
>
> if (mhi_cntrl->pm_state == MHI_PM_DISABLE)
> return 0;
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior
2021-04-06 9:11 [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Loic Poulain
2021-04-06 9:11 ` [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity Loic Poulain
@ 2021-04-07 5:05 ` Manivannan Sadhasivam
2021-04-07 6:50 ` Manivannan Sadhasivam
2 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2021-04-07 5:05 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, bbhatt, linux-arm-msm
On Tue, Apr 06, 2021 at 11:11:54AM +0200, Loic Poulain wrote:
> This change ensures that PM reference is always get during packet
> queueing and released either after queuing completion (RX) or once
> the buffer has been consumed (TX). This guarantees proper update for
> underlying MHI controller runtime status (e.g. last_busy timestamp)
> and prevents suspend to be triggered while TX packets are flying,
> or before we completed update of the RX ring.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thanks,
Mani
> ---
> v2: mhi_reset_data_chan: move put under existing DMA_TO_DEVICE if block
>
> drivers/bus/mhi/core/main.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index c780234..6e72239 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -584,8 +584,11 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
> /* notify client */
> mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
>
> - if (mhi_chan->dir == DMA_TO_DEVICE)
> + if (mhi_chan->dir == DMA_TO_DEVICE) {
> atomic_dec(&mhi_cntrl->pending_pkts);
> + /* Release the reference got from mhi_queue() */
> + mhi_cntrl->runtime_put(mhi_cntrl);
> + }
>
> /*
> * Recycle the buffer if buffer is pre-allocated,
> @@ -1021,9 +1024,11 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
> if (unlikely(ret))
> goto exit_unlock;
>
> - /* trigger M3 exit if necessary */
> - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
> - mhi_trigger_resume(mhi_cntrl);
> + /* Packet is queued, take a usage ref to exit M3 if necessary
> + * for host->device buffer, balanced put is done on buffer completion
> + * for device->host buffer, balanced put is after ringing the DB
> + */
> + mhi_cntrl->runtime_get(mhi_cntrl);
>
> /* Assert dev_wake (to exit/prevent M1/M2)*/
> mhi_cntrl->wake_toggle(mhi_cntrl);
> @@ -1034,6 +1039,9 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
> if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)))
> mhi_ring_chan_db(mhi_cntrl, mhi_chan);
>
> + if (dir == DMA_FROM_DEVICE)
> + mhi_cntrl->runtime_put(mhi_cntrl);
> +
> exit_unlock:
> read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags);
>
> @@ -1416,8 +1424,11 @@ static void mhi_reset_data_chan(struct mhi_controller *mhi_cntrl,
> while (tre_ring->rp != tre_ring->wp) {
> struct mhi_buf_info *buf_info = buf_ring->rp;
>
> - if (mhi_chan->dir == DMA_TO_DEVICE)
> + if (mhi_chan->dir == DMA_TO_DEVICE) {
> atomic_dec(&mhi_cntrl->pending_pkts);
> + /* Release the reference got from mhi_queue() */
> + mhi_cntrl->runtime_put(mhi_cntrl);
> + }
>
> if (!buf_info->pre_mapped)
> mhi_cntrl->unmap_single(mhi_cntrl, buf_info);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior
2021-04-06 9:11 [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Loic Poulain
2021-04-06 9:11 ` [PATCH v2 2/2] bus: mhi: pm: reduce PM state change verbosity Loic Poulain
2021-04-07 5:05 ` [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Manivannan Sadhasivam
@ 2021-04-07 6:50 ` Manivannan Sadhasivam
2 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2021-04-07 6:50 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, bbhatt, linux-arm-msm
On Tue, Apr 06, 2021 at 11:11:54AM +0200, Loic Poulain wrote:
> This change ensures that PM reference is always get during packet
> queueing and released either after queuing completion (RX) or once
> the buffer has been consumed (TX). This guarantees proper update for
> underlying MHI controller runtime status (e.g. last_busy timestamp)
> and prevents suspend to be triggered while TX packets are flying,
> or before we completed update of the RX ring.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Applied to mhi-next!
Thanks,
Mani
> ---
> v2: mhi_reset_data_chan: move put under existing DMA_TO_DEVICE if block
>
> drivers/bus/mhi/core/main.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index c780234..6e72239 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -584,8 +584,11 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
> /* notify client */
> mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
>
> - if (mhi_chan->dir == DMA_TO_DEVICE)
> + if (mhi_chan->dir == DMA_TO_DEVICE) {
> atomic_dec(&mhi_cntrl->pending_pkts);
> + /* Release the reference got from mhi_queue() */
> + mhi_cntrl->runtime_put(mhi_cntrl);
> + }
>
> /*
> * Recycle the buffer if buffer is pre-allocated,
> @@ -1021,9 +1024,11 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
> if (unlikely(ret))
> goto exit_unlock;
>
> - /* trigger M3 exit if necessary */
> - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
> - mhi_trigger_resume(mhi_cntrl);
> + /* Packet is queued, take a usage ref to exit M3 if necessary
> + * for host->device buffer, balanced put is done on buffer completion
> + * for device->host buffer, balanced put is after ringing the DB
> + */
> + mhi_cntrl->runtime_get(mhi_cntrl);
>
> /* Assert dev_wake (to exit/prevent M1/M2)*/
> mhi_cntrl->wake_toggle(mhi_cntrl);
> @@ -1034,6 +1039,9 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
> if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)))
> mhi_ring_chan_db(mhi_cntrl, mhi_chan);
>
> + if (dir == DMA_FROM_DEVICE)
> + mhi_cntrl->runtime_put(mhi_cntrl);
> +
> exit_unlock:
> read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags);
>
> @@ -1416,8 +1424,11 @@ static void mhi_reset_data_chan(struct mhi_controller *mhi_cntrl,
> while (tre_ring->rp != tre_ring->wp) {
> struct mhi_buf_info *buf_info = buf_ring->rp;
>
> - if (mhi_chan->dir == DMA_TO_DEVICE)
> + if (mhi_chan->dir == DMA_TO_DEVICE) {
> atomic_dec(&mhi_cntrl->pending_pkts);
> + /* Release the reference got from mhi_queue() */
> + mhi_cntrl->runtime_put(mhi_cntrl);
> + }
>
> if (!buf_info->pre_mapped)
> mhi_cntrl->unmap_single(mhi_cntrl, buf_info);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread