Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge patch series "Remove UFS_DEVICE_QUIRK_DELAY_AFTER_LPM quirk"

Bao D. Nguyen <quic_nguyenb@quicinc.com> says:

Multiple ufs device manufacturers request support for the
UFS_DEVICE_QUIRK_DELAY_AFTER_LPM quirk in the Qualcomm's platform
driver. After checking further with the major UFS manufacturers
engineering teams such as Samsung, Kioxia, SK Hynix and Micron, all
the manufacturers require this quirk. Since the quirk is needed by all
the ufs device manufacturers, remove the quirk in the ufs core driver
and implement a universal delay for all the ufs devices.

In addition to verifying with the public device's datasheets, the ufs
device manufacturer's engineering teams confirmed the required vcc
power-off time for the devices is a minimum of 1ms before vcc can be
powered on again. The existing 5ms delay implemented in the ufs core
driver seems too conservative, so replace the hard coded 5ms delay
with a variable default to 2ms setting to improve the system resume
latency. The platform drivers can override this setting as needed.

Link: https://patch.msgid.link/cover.1760383740.git.quic_nguyenb@quicinc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+17 -21
+11 -4
drivers/ufs/core/ufshcd.c
··· 9777 9777 } 9778 9778 9779 9779 /* 9780 - * Some UFS devices require delay after VCC power rail is turned-off. 9780 + * All UFS devices require delay after VCC power rail is turned-off. 9781 9781 */ 9782 - if (vcc_off && hba->vreg_info.vcc && 9783 - hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM) 9784 - usleep_range(5000, 5100); 9782 + if (vcc_off && hba->vreg_info.vcc && !hba->vreg_info.vcc->always_on) 9783 + usleep_range(hba->vcc_off_delay_us, 9784 + hba->vcc_off_delay_us + 100); 9785 9785 } 9786 9786 9787 9787 #ifdef CONFIG_PM ··· 10707 10707 hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10708 10708 UFS_SLEEP_PWR_MODE, 10709 10709 UIC_LINK_HIBERN8_STATE); 10710 + 10711 + /* 10712 + * Most ufs devices require 1ms delay after vcc is powered off before 10713 + * it can be powered on again. Set the default to 2ms. The platform 10714 + * drivers can override this setting as needed. 10715 + */ 10716 + hba->vcc_off_delay_us = 2000; 10710 10717 10711 10718 init_completion(&hba->dev_cmd.complete); 10712 10719
+4 -7
drivers/ufs/host/ufs-mediatek.c
··· 41 41 static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { 42 42 { .wmanufacturerid = UFS_ANY_VENDOR, 43 43 .model = UFS_ANY_MODEL, 44 - .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM | 45 - UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM }, 44 + .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM }, 46 45 { .wmanufacturerid = UFS_VENDOR_SKHYNIX, 47 46 .model = "H9HQ21AFAMZDAR", 48 47 .quirk = UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES }, ··· 1888 1889 { 1889 1890 ufshcd_fixup_dev_quirks(hba, ufs_mtk_dev_fixups); 1890 1891 1891 - if (ufs_mtk_is_broken_vcc(hba) && hba->vreg_info.vcc && 1892 - (hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM)) { 1892 + if (ufs_mtk_is_broken_vcc(hba) && hba->vreg_info.vcc) { 1893 1893 hba->vreg_info.vcc->always_on = true; 1894 1894 /* 1895 1895 * VCC will be kept always-on thus we don't 1896 - * need any delay during regulator operations 1896 + * need any delay before putting device's VCC in LPM mode. 1897 1897 */ 1898 - hba->dev_quirks &= ~(UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | 1899 - UFS_DEVICE_QUIRK_DELAY_AFTER_LPM); 1898 + hba->dev_quirks &= ~UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM; 1900 1899 } 1901 1900 1902 1901 ufs_mtk_vreg_fix_vcc(hba);
-3
drivers/ufs/host/ufs-qcom.c
··· 1024 1024 { .wmanufacturerid = UFS_VENDOR_SKHYNIX, 1025 1025 .model = UFS_ANY_MODEL, 1026 1026 .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM }, 1027 - { .wmanufacturerid = UFS_VENDOR_TOSHIBA, 1028 - .model = UFS_ANY_MODEL, 1029 - .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, 1030 1027 { .wmanufacturerid = UFS_VENDOR_WDC, 1031 1028 .model = UFS_ANY_MODEL, 1032 1029 .quirk = UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE },
-7
include/ufs/ufs_quirks.h
··· 101 101 #define UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES (1 << 10) 102 102 103 103 /* 104 - * Some UFS devices require delay after VCC power rail is turned-off. 105 - * Enable this quirk to introduce 5ms delays after VCC power-off during 106 - * suspend flow. 107 - */ 108 - #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11) 109 - 110 - /* 111 104 * Some ufs devices may need more time to be in hibern8 before exiting. 112 105 * Enable this quirk to give it an additional 100us. 113 106 */
+2
include/ufs/ufshcd.h
··· 1117 1117 int critical_health_count; 1118 1118 atomic_t dev_lvl_exception_count; 1119 1119 u64 dev_lvl_exception_id; 1120 + 1121 + u32 vcc_off_delay_us; 1120 1122 }; 1121 1123 1122 1124 /**