Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Johan Hovold <johan+linaro@kernel.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Can Guo <quic_cang@quicinc.com>
Subject: Re: [PATCH] scsi: ufs: core: fix devfreq deadlocks
Date: Thu, 5 Jan 2023 10:38:58 -0800	[thread overview]
Message-ID: <349e3564-10d4-9429-93d2-7bb639253fc2@acm.org> (raw)
In-Reply-To: <20221222102121.18682-1-johan+linaro@kernel.org>

On 12/22/22 02:21, Johan Hovold wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index bda61be5f035..5c3821b2fcf8 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -1234,12 +1234,14 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba)
>   	 * clock scaling is in progress
>   	 */
>   	ufshcd_scsi_block_requests(hba);
> +	mutex_lock(&hba->wb_mutex);
>   	down_write(&hba->clk_scaling_lock);
>   
>   	if (!hba->clk_scaling.is_allowed ||
>   	    ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) {
>   		ret = -EBUSY;
>   		up_write(&hba->clk_scaling_lock);
> +		mutex_unlock(&hba->wb_mutex);
>   		ufshcd_scsi_unblock_requests(hba);
>   		goto out;
>   	}
> @@ -1251,12 +1253,16 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba)
>   	return ret;
>   }

Please add an __acquires(&hba->wb_mutex) annotation for sparse.

> -static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, bool writelock)
> +static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, bool scale_up)
>   {
> -	if (writelock)
> -		up_write(&hba->clk_scaling_lock);
> -	else
> -		up_read(&hba->clk_scaling_lock);
> +	up_write(&hba->clk_scaling_lock);
> +
> +	/* Enable Write Booster if we have scaled up else disable it */
> +	if (ufshcd_enable_wb_if_scaling_up(hba))
> +		ufshcd_wb_toggle(hba, scale_up);
> +
> +	mutex_unlock(&hba->wb_mutex);
> +
>   	ufshcd_scsi_unblock_requests(hba);
>   	ufshcd_release(hba);
>   }

Please add a __releases(&hba->wb_mutex) annotation for sparse.

> @@ -1273,7 +1279,6 @@ static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, bool writelock)
>   static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
>   {
>   	int ret = 0;
> -	bool is_writelock = true;
>   
>   	ret = ufshcd_clock_scaling_prepare(hba);
>   	if (ret)
> @@ -1302,15 +1307,8 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
>   		}
>   	}
>   
> -	/* Enable Write Booster if we have scaled up else disable it */
> -	if (ufshcd_enable_wb_if_scaling_up(hba)) {
> -		downgrade_write(&hba->clk_scaling_lock);
> -		is_writelock = false;
> -		ufshcd_wb_toggle(hba, scale_up);
> -	}
> -
>   out_unprepare:
> -	ufshcd_clock_scaling_unprepare(hba, is_writelock);
> +	ufshcd_clock_scaling_unprepare(hba, scale_up);
>   	return ret;
>   }

This patch moves the ufshcd_wb_toggle() from before the out_unprepare 
label to after the out_unprepare label (into 
ufshcd_clock_scaling_unprepare()). Does this change perhaps introduce a 
new call to ufshcd_wb_toggle() in error paths?

Thanks,

Bart.


  parent reply	other threads:[~2023-01-05 18:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 10:21 [PATCH] scsi: ufs: core: fix devfreq deadlocks Johan Hovold
2023-01-03 21:28 ` Andrew Halaney
2023-01-03 21:45 ` Bart Van Assche
2023-01-04  8:24   ` Avri Altman
2023-01-04 22:34     ` Bart Van Assche
2023-01-04 14:10   ` Asutosh Das
2023-01-04 22:31     ` Bart Van Assche
2023-01-05  7:21       ` Avri Altman
2023-01-06  2:24         ` Jinyoung CHOI
2023-01-06 14:51           ` (2) " Asutosh Das
2023-01-05 18:38 ` Bart Van Assche [this message]
2023-01-16 16:03   ` Johan Hovold

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=349e3564-10d4-9429-93d2-7bb639253fc2@acm.org \
    --to=bvanassche@acm.org \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=jejb@linux.ibm.com \
    --cc=johan+linaro@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_cang@quicinc.com \
    --cc=stable@vger.kernel.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