summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2023-12-14 11:23:58 -0800
committerMartin K. Petersen <martin.petersen@oracle.com>2023-12-18 20:51:14 -0500
commit45a2c87f28ad0ee8c286bb6dd5686bc54f5b7160 (patch)
tree7596bb7ec887123560f46c67bfe5b8284ef0fa58 /drivers
parentbdf5c0bb4dd9e7a8a4423643e6c73a7114bd58d8 (diff)
scsi: ufs: core: Simplify ufshcd_auto_hibern8_update()
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> Link: https://lore.kernel.org/r/20231214192416.3638077-3-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ufs/core/ufshcd.c16
1 files 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);