public inbox for linux-arm-msm@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	"Vinod Koul" <vkoul@kernel.org>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Sanyog Kale" <sanyog.r.kale@intel.com>,
	"Andy Gross" <agross@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konrad.dybcio@linaro.org>,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
	"Charles Keepax" <ckeepax@opensource.cirrus.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 1/2] soundwire: qcom: fix unbalanced pm_runtime_put()
Date: Wed, 17 May 2023 11:47:20 -0500	[thread overview]
Message-ID: <7bcb1ee2-3950-5a43-14ee-5f16942b1eee@linux.intel.com> (raw)
In-Reply-To: <20230517163750.997629-1-krzysztof.kozlowski@linaro.org>



On 5/17/23 11:37, Krzysztof Kozlowski wrote:
> This reverts commit 57ed510b0547 ("soundwire: qcom: use
> pm_runtime_resume_and_get()") which introduced unbalanced
> pm_runtime_put(), when device did not have runtime PM enabled.
> 
> If pm_runtime_resume_and_get() failed with -EACCES, the driver continued
> execution and finally called pm_runtime_put_autosuspend().  Since
> pm_runtime_resume_and_get() drops the usage counter on every error, this
> lead to double decrement of that counter visible in certain debugfs
> actions on unattached devices (still in reset state):
> 
>   $ cat /sys/kernel/debug/soundwire/master-0-0/sdw:0:0217:f001:00:0/registers
>   qcom-soundwire 3210000.soundwire-controller: swrm_wait_for_wr_fifo_avail err write overflow
>   soundwire sdw-master-0: trf on Slave 1 failed:-5 read addr e36 count 1
>   soundwire sdw:0:0217:f001:00:0: Runtime PM usage count underflow!
> 
> Fixes: 57ed510b0547 ("soundwire: qcom: use pm_runtime_resume_and_get()")
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Yes, this resume_and_get() added more problems indeed. One of those
well-intended changes that went sideways.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>


> ---
>  drivers/soundwire/qcom.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index aad5942e5980..f442280af9d3 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -614,11 +614,12 @@ static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id)
>  	struct qcom_swrm_ctrl *ctrl = dev_id;
>  	int ret;
>  
> -	ret = pm_runtime_resume_and_get(ctrl->dev);
> +	ret = pm_runtime_get_sync(ctrl->dev);
>  	if (ret < 0 && ret != -EACCES) {
>  		dev_err_ratelimited(ctrl->dev,
> -				    "pm_runtime_resume_and_get failed in %s, ret %d\n",
> +				    "pm_runtime_get_sync failed in %s, ret %d\n",
>  				    __func__, ret);
> +		pm_runtime_put_noidle(ctrl->dev);
>  		return ret;
>  	}
>  
> @@ -1197,11 +1198,12 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
>  	struct snd_soc_dai *codec_dai;
>  	int ret, i;
>  
> -	ret = pm_runtime_resume_and_get(ctrl->dev);
> +	ret = pm_runtime_get_sync(ctrl->dev);
>  	if (ret < 0 && ret != -EACCES) {
>  		dev_err_ratelimited(ctrl->dev,
> -				    "pm_runtime_resume_and_get failed in %s, ret %d\n",
> +				    "pm_runtime_get_sync failed in %s, ret %d\n",
>  				    __func__, ret);
> +		pm_runtime_put_noidle(ctrl->dev);
>  		return ret;
>  	}
>  
> @@ -1402,11 +1404,12 @@ static int swrm_reg_show(struct seq_file *s_file, void *data)
>  	struct qcom_swrm_ctrl *ctrl = s_file->private;
>  	int reg, reg_val, ret;
>  
> -	ret = pm_runtime_resume_and_get(ctrl->dev);
> +	ret = pm_runtime_get_sync(ctrl->dev);
>  	if (ret < 0 && ret != -EACCES) {
>  		dev_err_ratelimited(ctrl->dev,
> -				    "pm_runtime_resume_and_get failed in %s, ret %d\n",
> +				    "pm_runtime_get_sync failed in %s, ret %d\n",
>  				    __func__, ret);
> +		pm_runtime_put_noidle(ctrl->dev);
>  		return ret;
>  	}
>  

  parent reply	other threads:[~2023-05-17 16:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 16:37 [PATCH 1/2] soundwire: qcom: fix unbalanced pm_runtime_put() Krzysztof Kozlowski
2023-05-17 16:37 ` [PATCH 2/2] soundwire: debugfs: " Krzysztof Kozlowski
2023-05-17 16:47   ` Pierre-Louis Bossart
2023-05-17 16:47 ` Pierre-Louis Bossart [this message]
2023-05-29  5:20 ` [PATCH 1/2] soundwire: qcom: " Vinod Koul

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=7bcb1ee2-3950-5a43-14ee-5f16942b1eee@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=sanyog.r.kale@intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /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