]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: core: Replace hard coded vcc-off delay with a variable
authorBao D. Nguyen <quic_nguyenb@quicinc.com>
Mon, 13 Oct 2025 19:38:16 +0000 (12:38 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 22 Oct 2025 01:22:17 +0000 (21:22 -0400)
After the UFS device VCC is powered off, all the UFS device
manufacturers require a minimum of 1ms of power-off time before VCC can
be powered on again. This requirement has been verified with all the UFS
device manufacturer's datasheets.

Replace the hard coded 5ms delay with a variable with a default setting
of 2ms to improve the system resume latency. The platform drivers can
override this setting as needed.

Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/72fa649406a0bf02271575b7d58f22c968aa5d7e.1760383740.git.quic_nguyenb@quicinc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c
include/ufs/ufshcd.h

index 4ca652c02ac2e916c95e8bf1111217ce061aa25f..516e9e06d3c3f73de51bfde1c85bce51affbd7fd 100644 (file)
@@ -9777,7 +9777,8 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)
         * All UFS devices require delay after VCC power rail is turned-off.
         */
        if (vcc_off && hba->vreg_info.vcc && !hba->vreg_info.vcc->always_on)
-               usleep_range(5000, 5100);
+               usleep_range(hba->vcc_off_delay_us,
+                            hba->vcc_off_delay_us + 100);
 }
 
 #ifdef CONFIG_PM
@@ -10704,6 +10705,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
                                                UFS_SLEEP_PWR_MODE,
                                                UIC_LINK_HIBERN8_STATE);
 
+       /*
+        * Most ufs devices require 1ms delay after vcc is powered off before
+        * it can be powered on again. Set the default to 2ms. The platform
+        * drivers can override this setting as needed.
+        */
+       hba->vcc_off_delay_us = 2000;
+
        init_completion(&hba->dev_cmd.complete);
 
        err = ufshcd_hba_init(hba);
index 9425cfd9d00eb0671566cfad2e4b8ad67e4802b2..752640a3e25fa96d96b43a2f483f21899e1cc93d 100644 (file)
@@ -1117,6 +1117,8 @@ struct ufs_hba {
        int critical_health_count;
        atomic_t dev_lvl_exception_count;
        u64 dev_lvl_exception_id;
+
+       u32 vcc_off_delay_us;
 };
 
 /**