Skip to contentSkip to conversation

scsi: ufs: pass device information to apply_dev_quirks

PATCH Applied Stanley Chu 3 participants 7 messages Jan 11, 2020 – Feb 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover scsi: ufs: pass device information to apply_dev_quirks

Currently UFS driver has "global" device quirk scheme to allow driver applying special handling for certain UFS devive models.

However some special device handlings are required for specific UFS hosts only so it is better to make it happen in vendor's callbacks only to not "pollute" common driver and common device quirks.

We already have apply_dev_quirks variant callback for vendors but lack of device information for handling specific UFS device models. This series provides such information to apply_dev_quirks callbacks, and applies related modifications.

In patch 1, since QCOM vendor driver will be built by default as a module, UFS core driver and vendor driver can not be split to different patches, otherwise separated patches will not be built singly.

v2 -> v3
- Fix ufshcd_tune_unipro_params()'s users to have correct parameters for invoking.
- Rebase to Martin's latest queue branch.

v1 -> v2
- Squash patch 1 "scsi: ufs: pass device information to apply_dev_quirks" and patch 2 "scsi: ufs-qcom: modify apply_dev_quirks interface" to resolve build issue.

Stanley Chu (2):
scsi: ufs: pass device information to apply_dev_quirks
scsi: ufs-mediatek: add apply_dev_quirks variant operation

 drivers/scsi/ufs/ufs-mediatek.c | 11 +++++++++++
 drivers/scsi/ufs/ufs-qcom.c     |  3 ++-
 drivers/scsi/ufs/ufshcd.c       |  8 ++++----
 drivers/scsi/ufs/ufshcd.h       |  7 ++++---
 4 files changed, 21 insertions(+), 8 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v3 1/2 scsi: ufs: pass device information to apply_dev_quirks

Pass UFS device information to vendor-specific variant callback "apply_dev_quirks" because some platform vendors need to know such information to apply special handlings or quirks in specific devices.

In the same time, modify existed vendor implementations according to the new interface for those vendor drivers which will be built-in or built as a module alone with UFS core driver.

Cc Alim Akhtar <[email protected]>
Cc Asutosh Das <[email protected]>
Cc Avri Altman <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Bean Huo <[email protected]>
Cc Can Guo <[email protected]>
Cc Matthias Brugger <[email protected]>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 ++-
 drivers/scsi/ufs/ufshcd.c   | 8 ++++----
 drivers/scsi/ufs/ufshcd.h   | 7 ++++---
 3 files changed, 10 insertions(+), 8 deletions(-)
drivers/scsi/ufs/ufs-qcom.c +2 -1
index c69c29a1ceb9..ebb5c66e069f 100644
@@ -949,7 +949,8 @@ static int ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba)
 	return err;
 }
 
-static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
+static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba,
+				     struct ufs_dev_desc *card)
 {
 	int err = 0;
 
drivers/scsi/ufs/ufshcd.c +4 -4
index 1b97f2dc0b63..7c85c890594c 100644
@@ -6803,7 +6803,8 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba)
 	return ret;
 }
 
-static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
+static void ufshcd_tune_unipro_params(struct ufs_hba *hba,
+				      struct ufs_dev_desc *card)
 {
 	if (ufshcd_is_unipro_pa_params_tuning_req(hba)) {
 		ufshcd_tune_pa_tactivate(hba);
@@ -6817,7 +6818,7 @@ 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);
 
-	ufshcd_vops_apply_dev_quirks(hba);
+	ufshcd_vops_apply_dev_quirks(hba, card);
 }
 
 static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
@@ -6980,10 +6981,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
 	}
 
 	ufs_fixup_device_setup(hba, &card);
+	ufshcd_tune_unipro_params(hba, &card);
 	ufs_put_device_desc(&card);
 
-	ufshcd_tune_unipro_params(hba);
-
 	/* UFS device is also active now */
 	ufshcd_set_ufs_dev_active(hba);
 	ufshcd_force_reset_auto_bkops(hba);
drivers/scsi/ufs/ufshcd.h +4 -3
index e05cafddc87b..4f3fa71303da 100644
@@ -320,7 +320,7 @@ struct ufs_hba_variant_ops {
 	void	(*setup_task_mgmt)(struct ufs_hba *, int, u8);
 	void    (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme,
 					enum ufs_notify_change_status);
-	int	(*apply_dev_quirks)(struct ufs_hba *);
+	int	(*apply_dev_quirks)(struct ufs_hba *, struct ufs_dev_desc *);
 	int     (*suspend)(struct ufs_hba *, enum ufs_pm_op);
 	int     (*resume)(struct ufs_hba *, enum ufs_pm_op);
 	void	(*dbg_register_dump)(struct ufs_hba *hba);
@@ -1052,10 +1052,11 @@ static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
 		return hba->vops->hibern8_notify(hba, cmd, status);
 }
 
-static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
+static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba,
+					       struct ufs_dev_desc *card)
 {
 	if (hba->vops && hba->vops->apply_dev_quirks)
-		return hba->vops->apply_dev_quirks(hba);
+		return hba->vops->apply_dev_quirks(hba, card);
 	return 0;
 }
 
Signature · 1 line
2.18.0
#2 lore raw
Quoted 55 lines · Stanley Chu

Pass UFS device information to vendor-specific variant callback "apply_dev_quirks" because some platform vendors need to know such information to apply special handlings or quirks in specific devices.

In the same time, modify existed vendor implementations according to the new interface for those vendor drivers which will be built-in or built as a module alone with UFS core driver.

Cc Alim Akhtar <[email protected]>
Cc Asutosh Das <[email protected]>
Cc Avri Altman <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Bean Huo <[email protected]>
Cc Can Guo <[email protected]>
Cc Matthias Brugger <[email protected]>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 ++-
 drivers/scsi/ufs/ufshcd.c   | 8 ++++----
 drivers/scsi/ufs/ufshcd.h   | 7 ++++---
 3 files changed, 10 insertions(+), 8 deletions(-)
drivers/scsi/ufs/ufs-qcom.c +2 -1
index c69c29a1ceb9..ebb5c66e069f 100644
@@ -949,7 +949,8 @@ static int
 ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba)
 	return err;
 }
 
-static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
+static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba,
+				     struct ufs_dev_desc *card)
 {
 	int err = 0;
drivers/scsi/ufs/ufshcd.c +2 -1
index 1b97f2dc0b63..7c85c890594c 100644
@@ -6803,7 +6803,8 @@ static int
 ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba)
 	return ret;
 }
 
-static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
+static void ufshcd_tune_unipro_params(struct ufs_hba *hba,
+				      struct ufs_dev_desc *card)
 {
 	if (ufshcd_is_unipro_pa_params_tuning_req(hba)) {
drivers/scsi/ufs/ufshcd.c +0 -0
 		ufshcd_tune_pa_tactivate(hba);

drivers/scsi/ufs/ufshcd.c static void ufshcd_tune_unipro_params(struct · line 6822

Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +1 -1
@@ -6817,7 +6818,7 @@ 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);
 
-	ufshcd_vops_apply_dev_quirks(hba);
+	ufshcd_vops_apply_dev_quirks(hba, card);

Hi Stanley,

Is this series merged? If no, would you mind moving ufshcd_vops_apply_dev_quirks(hba, card); a little bit? Like below.

@@ -6852,14 +6852,14 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba)

                ufshcd_tune_pa_hibern8time(hba);
        }

+ ufshcd_vops_apply_dev_quirks(hba, card);
+

        if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TACTIVATE)
                /* set 1ms timeout for PA_TACTIVATE */
                ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 10);

In this way, vendor codes have a chance to modify the dev_quirks before ufshcd_tune_unipro_params() does the rest of its job.

Thanks,
Can Guo.

Quoted 42 lines
drivers/scsi/ufs/ufshcd.c +0 -0
 }
 

static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)

drivers/scsi/ufs/ufshcd.c +1 -2
@@ -6980,10 +6981,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
 	}
 
 	ufs_fixup_device_setup(hba, &card);
+	ufshcd_tune_unipro_params(hba, &card);
 	ufs_put_device_desc(&card);
 
-	ufshcd_tune_unipro_params(hba);
-
 	/* UFS device is also active now */
 	ufshcd_set_ufs_dev_active(hba);
 	ufshcd_force_reset_auto_bkops(hba);
drivers/scsi/ufs/ufshcd.h +4 -3
index e05cafddc87b..4f3fa71303da 100644
@@ -320,7 +320,7 @@ struct ufs_hba_variant_ops {
 	void	(*setup_task_mgmt)(struct ufs_hba *, int, u8);
 	void    (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme,
 					enum ufs_notify_change_status);
-	int	(*apply_dev_quirks)(struct ufs_hba *);
+	int	(*apply_dev_quirks)(struct ufs_hba *, struct ufs_dev_desc *);
 	int     (*suspend)(struct ufs_hba *, enum ufs_pm_op);
 	int     (*resume)(struct ufs_hba *, enum ufs_pm_op);
 	void	(*dbg_register_dump)(struct ufs_hba *hba);
@@ -1052,10 +1052,11 @@ static inline void
 ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
 		return hba->vops->hibern8_notify(hba, cmd, status);
 }
 
-static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
+static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba,
+					       struct ufs_dev_desc *card)
 {
 	if (hba->vops && hba->vops->apply_dev_quirks)
-		return hba->vops->apply_dev_quirks(hba);
+		return hba->vops->apply_dev_quirks(hba, card);
 	return 0;
 }
#3 lore raw

Hi Can,

Quoted 16 lines

Hi Stanley,

Is this series merged? If no, would you mind moving ufshcd_vops_apply_dev_quirks(hba, card); a little bit? Like below.

(quoted diff) +2 -0
@@ -6852,14 +6852,14 @@ static void ufshcd_tune_unipro_params(struct 
 ufs_hba *hba)
                 ufshcd_tune_pa_hibern8time(hba);
         }
 
+       ufshcd_vops_apply_dev_quirks(hba, card);
+
         if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TACTIVATE)
                 /* set 1ms timeout for PA_TACTIVATE */
                 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 10);
 
Quoted 3 lines

In this way, vendor codes have a chance to modify the dev_quirks before ufshcd_tune_unipro_params() does the rest of its job.

This patch has been merged to 5.6-rc1.

Basically I am fine with your proposal. But if you need to move it to new mentioned position, our apply_dev_quirks callback also need corresponding change so it might need our co-works : )

For example, you could just post your proposed changes and then we would provide corresponding change as soon as possible?

Besides, I would like to remind that allowing vendor to "fix" device quirks in advance imply that current common device quirks have some problems? If so, would you consider to fix common device quirks instead?

Quoted 2 lines

Thanks,
Can Guo.

Thanks,
Stanley Chu

#4 lore raw

Hi Stanley,

Quoted 37 lines · Stanley Chu

Hi Can,

Quoted 16 lines

Hi Stanley,

Is this series merged? If no, would you mind moving ufshcd_vops_apply_dev_quirks(hba, card); a little bit? Like below.

(quoted diff) +2 -0
@@ -6852,14 +6852,14 @@ static void ufshcd_tune_unipro_params(struct
 ufs_hba *hba)
                 ufshcd_tune_pa_hibern8time(hba);
         }
 
+       ufshcd_vops_apply_dev_quirks(hba, card);
+
         if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TACTIVATE)
                 /* set 1ms timeout for PA_TACTIVATE */
                 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 10);
 
Quoted 3 lines

In this way, vendor codes have a chance to modify the dev_quirks before ufshcd_tune_unipro_params() does the rest of its job.

This patch has been merged to 5.6-rc1.

Basically I am fine with your proposal. But if you need to move it to new mentioned position, our apply_dev_quirks callback also need corresponding change so it might need our co-works : )

For example, you could just post your proposed changes and then we would provide corresponding change as soon as possible?

Besides, I would like to remind that allowing vendor to "fix" device quirks in advance imply that current common device quirks have some problems? If so, would you consider to fix common device quirks instead?

Quoted 5 lines
Quoted 2 lines

Thanks,
Can Guo.

Thanks,
Stanley Chu

Thanks for your cooperations on this :)

There are some failure seen with specific UFS devices on our platforms, we can fix it with the quirk QUIRK_HOST_PA_TACTIVATE, but we are not sure if other vendors need it or not. So we want to handle it more carefully by limiting it to our platforms only. I had sent out that patch weeks ago, so I will just upload the new patch as we both agreed in that patch series.

Thanks,
Can Guo

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

PATCH v3 2/2 scsi: ufs-mediatek: add apply_dev_quirks variant operation

In reply to Stanley Chu

Add vendor-specific variant callback "apply_dev_quirks" in MediaTek UFS driver.

Cc Alim Akhtar <[email protected]>
Cc Asutosh Das <[email protected]>
Cc Avri Altman <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Bean Huo <[email protected]>
Cc Can Guo <[email protected]>
Cc Matthias Brugger <[email protected]>
---
 drivers/scsi/ufs/ufs-mediatek.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +11 -0
index 41f80eeada46..8d999c0e60fe 100644
@@ -16,6 +16,7 @@
 
 #include "ufshcd.h"
 #include "ufshcd-pltfrm.h"
+#include "ufs_quirks.h"
 #include "unipro.h"
 #include "ufs-mediatek.h"
 
@@ -405,6 +406,15 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	return 0;
 }
 
+static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba,
+				    struct ufs_dev_desc *card)
+{
+	if (card->wmanufacturerid == UFS_VENDOR_SAMSUNG)
+		ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6);
+
+	return 0;
+}
+
 /**
  * struct ufs_hba_mtk_vops - UFS MTK specific variant operations
  *
@@ -417,6 +427,7 @@ static struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
 	.setup_clocks        = ufs_mtk_setup_clocks,
 	.link_startup_notify = ufs_mtk_link_startup_notify,
 	.pwr_change_notify   = ufs_mtk_pwr_change_notify,
+	.apply_dev_quirks    = ufs_mtk_apply_dev_quirks,
 	.suspend             = ufs_mtk_suspend,
 	.resume              = ufs_mtk_resume,
 	.device_reset        = ufs_mtk_device_reset,
Signature · 1 line
2.18.0
#6 lore raw
In reply to Stanley Chu

Stanley,

Quoted 2 lines

Currently UFS driver has "global" device quirk scheme to allow driver applying special handling for certain UFS devive models.

Applied to 5.6/scsi-queue, thanks!

Signature · 6 lines
Martin K. Petersen	Oracle Linux Engineering

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel