* [PATCH V3 1/2] ufs: qcom: Add quirks for Samsung UFS devices
2025-04-11 12:16 [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manish Pandey
@ 2025-04-11 12:16 ` Manish Pandey
2025-04-11 15:33 ` Bean Huo
2025-04-11 12:16 ` [PATCH V3 2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for " Manish Pandey
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Manish Pandey @ 2025-04-11 12:16 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen, Manivannan Sadhasivam
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, linux-scsi,
linux-kernel, linux-arm-msm, quic_nitirawa, quic_bhaskarv,
quic_rampraka, quic_cang, quic_nguyenb
Introduce quirks for Samsung UFS devices to adjust PA TX HSG1 sync length
and TX_HS_EQUALIZER settings on the Qualcomm UFS Host controller. This
ensures proper functionality of Samsung UFS devices with the Qualcomm
UFS Host controller.
Signed-off-by: Manish Pandey <quic_mapa@quicinc.com>
---
drivers/ufs/host/ufs-qcom.c | 43 +++++++++++++++++++++++++++++++++++++
drivers/ufs/host/ufs-qcom.h | 18 ++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 4c05b2dbe231..77f8ddb1f207 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -33,6 +33,10 @@
((((c) >> 16) & MCQ_QCFGPTR_MASK) * MCQ_QCFGPTR_UNIT)
#define MCQ_QCFG_SIZE 0x40
+/* De-emphasis for gear-5 */
+#define DEEMPHASIS_3_5_dB 0x04
+#define NO_DEEMPHASIS 0x0
+
enum {
TSTBUS_UAWM,
TSTBUS_UARM,
@@ -795,6 +799,23 @@ static int ufs_qcom_icc_update_bw(struct ufs_qcom_host *host)
return ufs_qcom_icc_set_bw(host, bw_table.mem_bw, bw_table.cfg_bw);
}
+static void ufs_qcom_set_tx_hs_equalizer(struct ufs_hba *hba, u32 gear, u32 tx_lanes)
+{
+ u32 equalizer_val;
+ int ret, i;
+
+ /* Determine the equalizer value based on the gear */
+ equalizer_val = (gear == 5) ? DEEMPHASIS_3_5_dB : NO_DEEMPHASIS;
+
+ for (i = 0; i < tx_lanes; i++) {
+ ret = ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(TX_HS_EQUALIZER, i),
+ equalizer_val);
+ if (ret)
+ dev_err(hba->dev, "%s: failed equalizer lane %d\n",
+ __func__, i);
+ }
+}
+
static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
enum ufs_notify_change_status status,
const struct ufs_pa_layer_attr *dev_max_params,
@@ -846,6 +867,11 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
dev_req_params->gear_tx,
PA_INITIAL_ADAPT);
}
+
+ if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING)
+ ufs_qcom_set_tx_hs_equalizer(hba,
+ dev_req_params->gear_tx, dev_req_params->lane_tx);
+
break;
case POST_CHANGE:
if (ufs_qcom_cfg_timers(hba, false)) {
@@ -893,6 +919,16 @@ static int ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba)
(pa_vs_config_reg1 | (1 << 12)));
}
+static void ufs_qcom_override_pa_tx_hsg1_sync_len(struct ufs_hba *hba)
+{
+ int err;
+
+ err = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(PA_TX_HSG1_SYNC_LENGTH),
+ PA_TX_HSG1_SYNC_LENGTH_VAL);
+ if (err)
+ dev_err(hba->dev, "Failed (%d) set PA_TX_HSG1_SYNC_LENGTH\n", err);
+}
+
static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
{
int err = 0;
@@ -900,6 +936,9 @@ static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME)
err = ufs_qcom_quirk_host_pa_saveconfigtime(hba);
+ if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH)
+ ufs_qcom_override_pa_tx_hsg1_sync_len(hba);
+
return err;
}
@@ -914,6 +953,10 @@ static struct ufs_dev_quirk ufs_qcom_dev_fixups[] = {
{ .wmanufacturerid = UFS_VENDOR_WDC,
.model = UFS_ANY_MODEL,
.quirk = UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE },
+ { .wmanufacturerid = UFS_VENDOR_SAMSUNG,
+ .model = UFS_ANY_MODEL,
+ .quirk = UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH |
+ UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING },
{}
};
diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
index d0e6ec9128e7..05d4cb569c50 100644
--- a/drivers/ufs/host/ufs-qcom.h
+++ b/drivers/ufs/host/ufs-qcom.h
@@ -122,8 +122,11 @@ enum {
TMRLUT_HW_CGC_EN | OCSC_HW_CGC_EN)
/* QUniPro Vendor specific attributes */
+#define PA_TX_HSG1_SYNC_LENGTH 0x1552
#define PA_VS_CONFIG_REG1 0x9000
#define DME_VS_CORE_CLK_CTRL 0xD002
+#define TX_HS_EQUALIZER 0x0037
+
/* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */
#define CLK_1US_CYCLES_MASK_V4 GENMASK(27, 16)
#define CLK_1US_CYCLES_MASK GENMASK(7, 0)
@@ -141,6 +144,21 @@ enum {
#define UNIPRO_CORE_CLK_FREQ_201_5_MHZ 202
#define UNIPRO_CORE_CLK_FREQ_403_MHZ 403
+/* TX_HSG1_SYNC_LENGTH attr value */
+#define PA_TX_HSG1_SYNC_LENGTH_VAL 0x4A
+
+/*
+ * Some ufs device vendors need a different TSync length.
+ * Enable this quirk to give an additional TX_HS_SYNC_LENGTH.
+ */
+#define UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH BIT(16)
+
+/*
+ * Some ufs device vendors need a different Deemphasis setting.
+ * Enable this quirk to tune TX Deemphasis parameters.
+ */
+#define UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING BIT(17)
+
/* ICE allocator type to share AES engines among TX stream and RX stream */
#define ICE_ALLOCATOR_TYPE 2
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH V3 1/2] ufs: qcom: Add quirks for Samsung UFS devices
2025-04-11 12:16 ` [PATCH V3 1/2] ufs: qcom: Add quirks for Samsung UFS devices Manish Pandey
@ 2025-04-11 15:33 ` Bean Huo
0 siblings, 0 replies; 8+ messages in thread
From: Bean Huo @ 2025-04-11 15:33 UTC (permalink / raw)
To: Manish Pandey, James E.J. Bottomley, Martin K. Petersen,
Manivannan Sadhasivam
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, linux-scsi,
linux-kernel, linux-arm-msm, quic_nitirawa, quic_bhaskarv,
quic_rampraka, quic_cang, quic_nguyenb
On Fri, 2025-04-11 at 17:46 +0530, Manish Pandey wrote:
> Introduce quirks for Samsung UFS devices to adjust PA TX HSG1 sync
> length
> and TX_HS_EQUALIZER settings on the Qualcomm UFS Host controller.
> This
> ensures proper functionality of Samsung UFS devices with the Qualcomm
> UFS Host controller.
>
> Signed-off-by: Manish Pandey <quic_mapa@quicinc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH V3 2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for UFS devices
2025-04-11 12:16 [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manish Pandey
2025-04-11 12:16 ` [PATCH V3 1/2] ufs: qcom: Add quirks for Samsung UFS devices Manish Pandey
@ 2025-04-11 12:16 ` Manish Pandey
2025-04-11 15:42 ` Bean Huo
2025-04-11 17:21 ` [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manivannan Sadhasivam
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Manish Pandey @ 2025-04-11 12:16 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen, Manivannan Sadhasivam
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, linux-scsi,
linux-kernel, linux-arm-msm, quic_nitirawa, quic_bhaskarv,
quic_rampraka, quic_cang, quic_nguyenb
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 properhibernation process.
Signed-off-by: Manish Pandey <quic_mapa@quicinc.com>
---
drivers/ufs/core/ufshcd.c | 29 +++++++++++++++++++++++++++++
include/ufs/ufs_quirks.h | 6 ++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8cae93fd221c..dce7625f9875 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -278,6 +278,7 @@ static const struct ufs_dev_quirk ufs_fixups[] = {
.model = UFS_ANY_MODEL,
.quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
+ UFS_DEVICE_QUIRK_PA_HIBER8TIME |
UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS },
{ .wmanufacturerid = UFS_VENDOR_SKHYNIX,
.model = UFS_ANY_MODEL,
@@ -8470,6 +8471,31 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba)
return ret;
}
+/**
+ * ufshcd_quirk_override_pa_h8time - Ensures proper adjustment of PA_HIBERN8TIME.
+ * @hba: per-adapter instance
+ *
+ * Some UFS devices require specific adjustments to the PA_HIBERN8TIME parameter
+ * to ensure proper hibernation timing. This function retrieves the current
+ * PA_HIBERN8TIME value and increments it by 100us.
+ */
+static void ufshcd_quirk_override_pa_h8time(struct ufs_hba *hba)
+{
+ u32 pa_h8time;
+ int ret;
+
+ ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_HIBERN8TIME), &pa_h8time);
+ if (ret) {
+ dev_err(hba->dev, "Failed to get PA_HIBERN8TIME: %d\n", ret);
+ return;
+ }
+
+ /* Increment by 1 to increase hibernation time by 100 µs */
+ ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), pa_h8time + 1);
+ if (ret)
+ dev_err(hba->dev, "Failed updating PA_HIBERN8TIME: %d\n", ret);
+}
+
static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
{
ufshcd_vops_apply_dev_quirks(hba);
@@ -8480,6 +8506,9 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE)
ufshcd_quirk_tune_host_pa_tactivate(hba);
+
+ if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_HIBER8TIME)
+ ufshcd_quirk_override_pa_h8time(hba);
}
static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
diff --git a/include/ufs/ufs_quirks.h b/include/ufs/ufs_quirks.h
index 41ff44dfa1db..f52de5ed1b3b 100644
--- a/include/ufs/ufs_quirks.h
+++ b/include/ufs/ufs_quirks.h
@@ -107,4 +107,10 @@ struct ufs_dev_quirk {
*/
#define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11)
+/*
+ * Some ufs devices may need more time to be in hibern8 before exiting.
+ * Enable this quirk to give it an additional 100us.
+ */
+#define UFS_DEVICE_QUIRK_PA_HIBER8TIME (1 << 12)
+
#endif /* UFS_QUIRKS_H_ */
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH V3 2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for UFS devices
2025-04-11 12:16 ` [PATCH V3 2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for " Manish Pandey
@ 2025-04-11 15:42 ` Bean Huo
0 siblings, 0 replies; 8+ messages in thread
From: Bean Huo @ 2025-04-11 15:42 UTC (permalink / raw)
To: Manish Pandey, James E.J. Bottomley, Martin K. Petersen,
Manivannan Sadhasivam
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, linux-scsi,
linux-kernel, linux-arm-msm, quic_nitirawa, quic_bhaskarv,
quic_rampraka, quic_cang, quic_nguyenb
On Fri, 2025-04-11 at 17:46 +0530, Manish Pandey wrote:
> 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 properhibernation
> process.
>
> Signed-off-by: Manish Pandey <quic_mapa@quicinc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices
2025-04-11 12:16 [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manish Pandey
2025-04-11 12:16 ` [PATCH V3 1/2] ufs: qcom: Add quirks for Samsung UFS devices Manish Pandey
2025-04-11 12:16 ` [PATCH V3 2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for " Manish Pandey
@ 2025-04-11 17:21 ` Manivannan Sadhasivam
2025-04-12 10:28 ` Martin K. Petersen
2025-04-22 1:58 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Manivannan Sadhasivam @ 2025-04-11 17:21 UTC (permalink / raw)
To: Manish Pandey
Cc: James E.J. Bottomley, Martin K. Petersen, Alim Akhtar,
Avri Altman, Bart Van Assche, linux-scsi, linux-kernel,
linux-arm-msm, quic_nitirawa, quic_bhaskarv, quic_rampraka,
quic_cang, quic_nguyenb
On Fri, Apr 11, 2025 at 05:46:28PM +0530, Manish Pandey wrote:
> Introduce quirks for Samsung UFS devices to modify the PA TX HSG1 sync
> length and TX_HS_EQUALIZER settings on the Qualcomm UFS Host controller.
>
> Additionally, Samsung UFS devices require extra time in hibern8 mode
> before exiting, beyond the standard handshaking phase between the host
> and device. Introduce a quirk to increase the PA_HIBERN8TIME parameter
> by 100 µs to ensure a proper hibernation process.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> Changes in V3
> - Addressed Mani's comment and updated commit message.
> - used BIT macro in ufs-qcom.h to define quirks.
> Changes in V2
> - Split patches to add PA_HIBERN8TIME quirk in ufshcd.c
>
> ---
> Manish Pandey (2):
> ufs: qcom: Add quirks for Samsung UFS devices
> scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for UFS devices
>
> drivers/ufs/core/ufshcd.c | 29 +++++++++++++++++++++++++
> drivers/ufs/host/ufs-qcom.c | 43 +++++++++++++++++++++++++++++++++++++
> drivers/ufs/host/ufs-qcom.h | 18 ++++++++++++++++
> include/ufs/ufs_quirks.h | 6 ++++++
> 4 files changed, 96 insertions(+)
>
> --
> 2.17.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices
2025-04-11 12:16 [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manish Pandey
` (2 preceding siblings ...)
2025-04-11 17:21 ` [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manivannan Sadhasivam
@ 2025-04-12 10:28 ` Martin K. Petersen
2025-04-22 1:58 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2025-04-12 10:28 UTC (permalink / raw)
To: James E.J. Bottomley, Manivannan Sadhasivam, Manish Pandey
Cc: Martin K . Petersen, Alim Akhtar, Avri Altman, Bart Van Assche,
linux-scsi, linux-kernel, linux-arm-msm, quic_nitirawa,
quic_bhaskarv, quic_rampraka, quic_cang, quic_nguyenb
On Fri, 11 Apr 2025 17:46:28 +0530, Manish Pandey wrote:
> Introduce quirks for Samsung UFS devices to modify the PA TX HSG1 sync
> length and TX_HS_EQUALIZER settings on the Qualcomm UFS Host controller.
>
> Additionally, Samsung UFS devices require extra time in hibern8 mode
> before exiting, beyond the standard handshaking phase between the host
> and device. Introduce a quirk to increase the PA_HIBERN8TIME parameter
> by 100 µs to ensure a proper hibernation process.
>
> [...]
Applied to 6.15/scsi-fixes, thanks!
[1/2] ufs: qcom: Add quirks for Samsung UFS devices
https://git.kernel.org/mkp/scsi/c/f8cba9a700cf
[2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for UFS devices
https://git.kernel.org/mkp/scsi/c/569330a34a31
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices
2025-04-11 12:16 [PATCH V3 0/2] scsi: ufs: Implement Quirks for Samsung UFS Devices Manish Pandey
` (3 preceding siblings ...)
2025-04-12 10:28 ` Martin K. Petersen
@ 2025-04-22 1:58 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2025-04-22 1:58 UTC (permalink / raw)
To: James E.J. Bottomley, Manivannan Sadhasivam, Manish Pandey
Cc: Martin K . Petersen, Alim Akhtar, Avri Altman, Bart Van Assche,
linux-scsi, linux-kernel, linux-arm-msm, quic_nitirawa,
quic_bhaskarv, quic_rampraka, quic_cang, quic_nguyenb
On Fri, 11 Apr 2025 17:46:28 +0530, Manish Pandey wrote:
> Introduce quirks for Samsung UFS devices to modify the PA TX HSG1 sync
> length and TX_HS_EQUALIZER settings on the Qualcomm UFS Host controller.
>
> Additionally, Samsung UFS devices require extra time in hibern8 mode
> before exiting, beyond the standard handshaking phase between the host
> and device. Introduce a quirk to increase the PA_HIBERN8TIME parameter
> by 100 µs to ensure a proper hibernation process.
>
> [...]
Applied to 6.15/scsi-fixes, thanks!
[1/2] ufs: qcom: Add quirks for Samsung UFS devices
https://git.kernel.org/mkp/scsi/c/f8cba9a700cf
[2/2] scsi: ufs: introduce quirk to extend PA_HIBERN8TIME for UFS devices
https://git.kernel.org/mkp/scsi/c/569330a34a31
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread