All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-scsi@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Bart Van Assche <bvanassche@acm.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Bean Huo <beanhuo@micron.com>, Avri Altman <avri.altman@wdc.com>,
	Jinyoung Choi <j-young.choi@samsung.com>
Subject: [PATCH v3 2/5] scsi: ufs: Move a clock scaling check
Date: Tue,  8 Nov 2022 15:33:36 -0800	[thread overview]
Message-ID: <20221108233339.412808-3-bvanassche@acm.org> (raw)
In-Reply-To: <20221108233339.412808-1-bvanassche@acm.org>

Move a check related to clock scaling into ufshcd_devfreq_scale(). This
patch prepares for adding a second ufshcd_clock_scaling_prepare()
caller in a function not related to clock scaling.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 81c20e315dba..195261e3521c 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1236,8 +1236,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba)
 	ufshcd_scsi_block_requests(hba);
 	down_write(&hba->clk_scaling_lock);
 
-	if (!hba->clk_scaling.is_allowed ||
-	    ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) {
+	if (ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) {
 		ret = -EBUSY;
 		up_write(&hba->clk_scaling_lock);
 		ufshcd_scsi_unblock_requests(hba);
@@ -1275,10 +1274,18 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
 	int ret = 0;
 	bool is_writelock = true;
 
+	if (!hba->clk_scaling.is_allowed)
+		return -EBUSY;
+
 	ret = ufshcd_clock_scaling_prepare(hba);
 	if (ret)
 		return ret;
 
+	if (!hba->clk_scaling.is_allowed) {
+		ret = -EBUSY;
+		goto out_unprepare;
+	}
+
 	/* scale down the gear before scaling down clocks */
 	if (!scale_up) {
 		ret = ufshcd_scale_gear(hba, false);

  parent reply	other threads:[~2022-11-08 23:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 23:33 [PATCH v3 0/5] Prepare for upstreaming Pixel 6 and 7 UFS support Bart Van Assche
2022-11-08 23:33 ` [PATCH v3 1/5] scsi: ufs: Reduce the clock scaling latency Bart Van Assche
2022-11-08 23:33 ` Bart Van Assche [this message]
2022-11-08 23:33 ` [PATCH v3 3/5] scsi: ufs: Pass the clock scaling timeout as an argument Bart Van Assche
2022-11-08 23:33 ` [PATCH v3 4/5] scsi: ufs: Add suspend/resume SCSI command processing support Bart Van Assche
2022-11-10 11:07   ` Avri Altman
2022-11-22 22:10     ` Bart Van Assche
2022-11-08 23:33 ` [PATCH v3 5/5] scsi: ufs: Allow UFS host drivers to override the sg entry size Bart Van Assche
2022-11-09  8:56   ` Avri Altman
2022-11-09 12:34   ` Christoph Hellwig
2022-11-09 17:29     ` Bart Van Assche
2022-11-15  7:48       ` Christoph Hellwig
2022-11-15  8:56         ` Avri Altman
2022-11-15 19:36           ` Bart Van Assche
2022-11-16  7:06             ` Avri Altman
2022-11-15 19:04         ` Bart Van Assche
2022-11-09 18:24   ` Eric Biggers
2022-11-09 18:35     ` Bart Van Assche

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=20221108233339.412808-3-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=adrian.hunter@intel.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=j-young.choi@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.