Skip to content

Commit 569330a

Browse files
quic-mapamartinkpetersen
authored andcommitted
scsi: ufs: Introduce quirk to extend PA_HIBERN8TIME for UFS devices
Samsung UFS devices require additional time in hibern8 mode before exiting, beyond the negotiated handshaking phase between the host and device. Introduce a quirk to increase the PA_HIBERN8TIME parameter by 100 µs, a value derived from experiments, to ensure a proper hibernation process. Signed-off-by: Manish Pandey <quic_mapa@quicinc.com> Link: https://lore.kernel.org/r/20250411121630.21330-3-quic_mapa@quicinc.com Reviewed-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f8cba9a commit 569330a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ static const struct ufs_dev_quirk ufs_fixups[] = {
278278
.model = UFS_ANY_MODEL,
279279
.quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
280280
UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
281+
UFS_DEVICE_QUIRK_PA_HIBER8TIME |
281282
UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS },
282283
{ .wmanufacturerid = UFS_VENDOR_SKHYNIX,
283284
.model = UFS_ANY_MODEL,
@@ -8470,6 +8471,31 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba)
84708471
return ret;
84718472
}
84728473

8474+
/**
8475+
* ufshcd_quirk_override_pa_h8time - Ensures proper adjustment of PA_HIBERN8TIME.
8476+
* @hba: per-adapter instance
8477+
*
8478+
* Some UFS devices require specific adjustments to the PA_HIBERN8TIME parameter
8479+
* to ensure proper hibernation timing. This function retrieves the current
8480+
* PA_HIBERN8TIME value and increments it by 100us.
8481+
*/
8482+
static void ufshcd_quirk_override_pa_h8time(struct ufs_hba *hba)
8483+
{
8484+
u32 pa_h8time;
8485+
int ret;
8486+
8487+
ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_HIBERN8TIME), &pa_h8time);
8488+
if (ret) {
8489+
dev_err(hba->dev, "Failed to get PA_HIBERN8TIME: %d\n", ret);
8490+
return;
8491+
}
8492+
8493+
/* Increment by 1 to increase hibernation time by 100 µs */
8494+
ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), pa_h8time + 1);
8495+
if (ret)
8496+
dev_err(hba->dev, "Failed updating PA_HIBERN8TIME: %d\n", ret);
8497+
}
8498+
84738499
static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
84748500
{
84758501
ufshcd_vops_apply_dev_quirks(hba);
@@ -8480,6 +8506,9 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
84808506

84818507
if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE)
84828508
ufshcd_quirk_tune_host_pa_tactivate(hba);
8509+
8510+
if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_HIBER8TIME)
8511+
ufshcd_quirk_override_pa_h8time(hba);
84838512
}
84848513

84858514
static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)

include/ufs/ufs_quirks.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,10 @@ struct ufs_dev_quirk {
107107
*/
108108
#define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11)
109109

110+
/*
111+
* Some ufs devices may need more time to be in hibern8 before exiting.
112+
* Enable this quirk to give it an additional 100us.
113+
*/
114+
#define UFS_DEVICE_QUIRK_PA_HIBER8TIME (1 << 12)
115+
110116
#endif /* UFS_QUIRKS_H_ */

0 commit comments

Comments
 (0)