public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Simplify the auto-hibernation configuration code
@ 2023-12-14 19:23 Bart Van Assche
  2023-12-14 19:23 ` [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bart Van Assche @ 2023-12-14 19:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche

Hi Martin,

The two patches in this series simplify the code for configuring
auto-hibernation. Please consider these two patches for the next merge
window.

Thanks,

Bart.

Bart Van Assche (2):
  scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static
  scsi: ufs: Simplify ufshcd_auto_hibern8_update()

 drivers/ufs/core/ufshcd.c | 40 +++++++++++++++------------------------
 include/ufs/ufshcd.h      |  1 -
 2 files changed, 15 insertions(+), 26 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static
  2023-12-14 19:23 [PATCH 0/2] Simplify the auto-hibernation configuration code Bart Van Assche
@ 2023-12-14 19:23 ` Bart Van Assche
  2023-12-15  2:31   ` Peter Wang (王信友)
  2023-12-14 19:23 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Bart Van Assche
  2023-12-19  1:51 ` [PATCH 0/2] Simplify the auto-hibernation configuration code Martin K. Petersen
  2 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2023-12-14 19:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Bao D . Nguyen, Can Guo, Avri Altman,
	James E.J. Bottomley, Stanley Jhu, Manivannan Sadhasivam,
	Asutosh Das, Bean Huo, Peter Wang, Arthur Simchaev, Po-Wen Kao,
	Eric Biggers

Rename ufshcd_auto_hibern8_enable() into ufshcd_configure_auto_hibern8()
since this function can enable or disable auto-hibernation. Since
ufshcd_auto_hibern8_enable() is only used inside the UFSHCI driver core,
declare it static. Additionally, move the definition of this function to
just before its first caller.

Suggested-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Reviewed-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Cc: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 24 +++++++++++-------------
 include/ufs/ufshcd.h      |  1 -
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 219ba7b0501b..608dba595beb 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4413,6 +4413,14 @@ int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
 }
 EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);
 
+static void ufshcd_configure_auto_hibern8(struct ufs_hba *hba)
+{
+	if (!ufshcd_is_auto_hibern8_supported(hba))
+		return;
+
+	ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
+}
+
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 {
 	unsigned long flags;
@@ -4432,21 +4440,13 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 	    !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
 		ufshcd_rpm_get_sync(hba);
 		ufshcd_hold(hba);
-		ufshcd_auto_hibern8_enable(hba);
+		ufshcd_configure_auto_hibern8(hba);
 		ufshcd_release(hba);
 		ufshcd_rpm_put_sync(hba);
 	}
 }
 EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update);
 
-void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
-{
-	if (!ufshcd_is_auto_hibern8_supported(hba))
-		return;
-
-	ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
-}
-
  /**
  * ufshcd_init_pwr_info - setting the POR (power on reset)
  * values in hba power info
@@ -8953,8 +8953,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
 
 	if (hba->ee_usr_mask)
 		ufshcd_write_ee_control(hba);
-	/* Enable Auto-Hibernate if configured */
-	ufshcd_auto_hibern8_enable(hba);
+	ufshcd_configure_auto_hibern8(hba);
 
 out:
 	spin_lock_irqsave(hba->host->host_lock, flags);
@@ -9956,8 +9955,7 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 		cancel_delayed_work(&hba->rpm_dev_flush_recheck_work);
 	}
 
-	/* Enable Auto-Hibernate if configured */
-	ufshcd_auto_hibern8_enable(hba);
+	ufshcd_configure_auto_hibern8(hba);
 
 	goto out;
 
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 38637bea9a52..8e2bce9a4f21 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1371,7 +1371,6 @@ static inline int ufshcd_disable_host_tx_lcc(struct ufs_hba *hba)
 	return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0);
 }
 
-void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
 void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
 			     const struct ufs_dev_quirk *fixups);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] scsi: ufs: Simplify ufshcd_auto_hibern8_update()
  2023-12-14 19:23 [PATCH 0/2] Simplify the auto-hibernation configuration code Bart Van Assche
  2023-12-14 19:23 ` [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static Bart Van Assche
@ 2023-12-14 19:23 ` Bart Van Assche
  2023-12-19  1:51 ` [PATCH 0/2] Simplify the auto-hibernation configuration code Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2023-12-14 19:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Bao D . Nguyen, Can Guo, Avri Altman,
	James E.J. Bottomley, Stanley Jhu, Asutosh Das, Bean Huo,
	Manivannan Sadhasivam, Arthur Simchaev

Calls to ufshcd_auto_hibern8_update() are already serialized: this
function is either called if user space software is not running
(preparing to suspend) or from a single sysfs store callback function.
Kernfs serializes sysfs .store() callbacks. No functionality is changed.

Reviewed-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Cc: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 608dba595beb..d6ae5d17892c 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4423,21 +4423,13 @@ static void ufshcd_configure_auto_hibern8(struct ufs_hba *hba)
 
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 {
-	unsigned long flags;
-	bool update = false;
+	const u32 cur_ahit = READ_ONCE(hba->ahit);
 
-	if (!ufshcd_is_auto_hibern8_supported(hba))
+	if (!ufshcd_is_auto_hibern8_supported(hba) || cur_ahit == ahit)
 		return;
 
-	spin_lock_irqsave(hba->host->host_lock, flags);
-	if (hba->ahit != ahit) {
-		hba->ahit = ahit;
-		update = true;
-	}
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
-
-	if (update &&
-	    !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
+	WRITE_ONCE(hba->ahit, ahit);
+	if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
 		ufshcd_rpm_get_sync(hba);
 		ufshcd_hold(hba);
 		ufshcd_configure_auto_hibern8(hba);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static
  2023-12-14 19:23 ` [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static Bart Van Assche
@ 2023-12-15  2:31   ` Peter Wang (王信友)
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Wang (王信友) @ 2023-12-15  2:31 UTC (permalink / raw)
  To: bvanassche@acm.org, martin.petersen@oracle.com
  Cc: ebiggers@google.com, quic_nguyenb@quicinc.com, jejb@linux.ibm.com,
	beanhuo@micron.com, avri.altman@wdc.com, Arthur.Simchaev@wdc.com,
	quic_asutoshd@quicinc.com, linux-scsi@vger.kernel.org,
	chu.stanley@gmail.com, Powen Kao (高伯文),
	mani@kernel.org, quic_cang@quicinc.com

On Thu, 2023-12-14 at 11:23 -0800, Bart Van Assche wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Rename ufshcd_auto_hibern8_enable() into
> ufshcd_configure_auto_hibern8()
> since this function can enable or disable auto-hibernation. Since
> ufshcd_auto_hibern8_enable() is only used inside the UFSHCI driver
> core,
> declare it static. Additionally, move the definition of this function
> to
> just before its first caller.

Reviewed-by: Peter Wang <peter.wang@mediatek.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Simplify the auto-hibernation configuration code
  2023-12-14 19:23 [PATCH 0/2] Simplify the auto-hibernation configuration code Bart Van Assche
  2023-12-14 19:23 ` [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static Bart Van Assche
  2023-12-14 19:23 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Bart Van Assche
@ 2023-12-19  1:51 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2023-12-19  1:51 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Martin K . Petersen, linux-scsi


Bart,

> The two patches in this series simplify the code for configuring
> auto-hibernation. Please consider these two patches for the next merge
> window.

Applied to 6.8/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-19  1:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 19:23 [PATCH 0/2] Simplify the auto-hibernation configuration code Bart Van Assche
2023-12-14 19:23 ` [PATCH 1/2] scsi: ufs: Rename ufshcd_auto_hibern8_enable() and make it static Bart Van Assche
2023-12-15  2:31   ` Peter Wang (王信友)
2023-12-14 19:23 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Bart Van Assche
2023-12-19  1:51 ` [PATCH 0/2] Simplify the auto-hibernation configuration code Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox