linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior
Date: Wed, 7 Apr 2021 10:35:44 +0530	[thread overview]
Message-ID: <20210407050544.GB8675@work> (raw)
In-Reply-To: <1617700315-12492-1-git-send-email-loic.poulain@linaro.org>

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
> 

  parent reply	other threads:[~2021-04-07  5:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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:01   ` Manivannan Sadhasivam
2021-04-07  6:50   ` Manivannan Sadhasivam
2021-04-07  5:05 ` Manivannan Sadhasivam [this message]
2021-04-07  6:50 ` [PATCH v2 1/2] bus: mhi: core: Fix MHI runtime_pm behavior 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=20210407050544.GB8675@work \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bbhatt@codeaurora.org \
    --cc=hemantk@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=loic.poulain@linaro.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).