linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] scsi: ufs: pass device information to apply_dev_quirks
@ 2020-01-06  0:27 Stanley Chu
  2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
  2020-01-06  0:27 ` [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation Stanley Chu
  0 siblings, 2 replies; 9+ messages in thread
From: Stanley Chu @ 2020-01-06  0:27 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, Stanley Chu

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.

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       |  5 +++--
 drivers/scsi/ufs/ufshcd.h       |  7 ++++---
 4 files changed, 20 insertions(+), 6 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-06  0:27 [PATCH v2 0/2] scsi: ufs: pass device information to apply_dev_quirks Stanley Chu
@ 2020-01-06  0:27 ` Stanley Chu
  2020-01-06 17:45   ` asutoshd
                     ` (2 more replies)
  2020-01-06  0:27 ` [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation Stanley Chu
  1 sibling, 3 replies; 9+ messages in thread
From: Stanley Chu @ 2020-01-06  0:27 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, 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 implementation according to
the new interface.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 ++-
 drivers/scsi/ufs/ufshcd.c   | 5 +++--
 drivers/scsi/ufs/ufshcd.h   | 7 ++++---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index c69c29a1ceb9..ebb5c66e069f 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -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;
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1b97f2dc0b63..9abf0ea8c308 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -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)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index e05cafddc87b..4f3fa71303da 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -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;
 }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation
  2020-01-06  0:27 [PATCH v2 0/2] scsi: ufs: pass device information to apply_dev_quirks Stanley Chu
  2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
@ 2020-01-06  0:27 ` Stanley Chu
  2020-01-07  9:16   ` [EXT] " Bean Huo (beanhuo)
  1 sibling, 1 reply; 9+ messages in thread
From: Stanley Chu @ 2020-01-06  0:27 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, Stanley Chu

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

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-mediatek.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 41f80eeada46..8d999c0e60fe 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -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,
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
@ 2020-01-06 17:45   ` asutoshd
  2020-01-06 20:21     ` Avri Altman
  2020-01-07  8:21   ` [EXT] " Bean Huo (beanhuo)
  2020-01-10  6:25   ` Martin K. Petersen
  2 siblings, 1 reply; 9+ messages in thread
From: asutoshd @ 2020-01-06 17:45 UTC (permalink / raw)
  To: Stanley Chu
  Cc: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb,
	beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, linux-scsi-owner

On 2020-01-05 16:27, Stanley Chu wrote:
> 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 implementation according to
> the new interface.
> 
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bart Van Assche <bvanassche@acm.org>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Reviewed-by: Avri Altman <avri.altman@wdc.com>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
> ---
>  drivers/scsi/ufs/ufs-qcom.c | 3 ++-
>  drivers/scsi/ufs/ufshcd.c   | 5 +++--
>  drivers/scsi/ufs/ufshcd.h   | 7 ++++---
>  3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index c69c29a1ceb9..ebb5c66e069f 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -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;
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 1b97f2dc0b63..9abf0ea8c308 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -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)
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index e05cafddc87b..4f3fa71303da 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -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;
>  }

Please separate the vendor code (ufs-qcom, in this case) to a separate 
patch.

-asd

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-06 17:45   ` asutoshd
@ 2020-01-06 20:21     ` Avri Altman
  0 siblings, 0 replies; 9+ messages in thread
From: Avri Altman @ 2020-01-06 20:21 UTC (permalink / raw)
  To: asutoshd, Stanley Chu
  Cc: linux-scsi, martin.petersen, alim.akhtar, jejb, beanhuo, cang,
	matthias.bgg, bvanassche, linux-mediatek, linux-arm-kernel,
	linux-kernel, kuohong.wang, peter.wang, chun-hung.wu, andy.teng,
	linux-scsi-owner

> 
> Please separate the vendor code (ufs-qcom, in this case) to a separate patch.
He can't - this patch won't compile if he does.

Thanks,
Avri

> 
> -asd

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [EXT] [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
  2020-01-06 17:45   ` asutoshd
@ 2020-01-07  8:21   ` Bean Huo (beanhuo)
  2020-01-10  6:25   ` Martin K. Petersen
  2 siblings, 0 replies; 9+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-07  8:21 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: asutoshd, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng

> Reviewed-by: Avri Altman <avri.altman@wdc.com>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [EXT] [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation
  2020-01-06  0:27 ` [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation Stanley Chu
@ 2020-01-07  9:16   ` Bean Huo (beanhuo)
  0 siblings, 0 replies; 9+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-07  9:16 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: asutoshd, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng

> Reviewed-by: Avri Altman <avri.altman@wdc.com>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
  2020-01-06 17:45   ` asutoshd
  2020-01-07  8:21   ` [EXT] " Bean Huo (beanhuo)
@ 2020-01-10  6:25   ` Martin K. Petersen
  2020-01-10  7:08     ` Stanley Chu
  2 siblings, 1 reply; 9+ messages in thread
From: Martin K. Petersen @ 2020-01-10  6:25 UTC (permalink / raw)
  To: Stanley Chu
  Cc: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb,
	beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng


Stanley,

> 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.

This doesn't compile. You missed adding the additional argument to one
caller of ufshcd_tune_unipro_params().

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] scsi: ufs: pass device information to apply_dev_quirks
  2020-01-10  6:25   ` Martin K. Petersen
@ 2020-01-10  7:08     ` Stanley Chu
  0 siblings, 0 replies; 9+ messages in thread
From: Stanley Chu @ 2020-01-10  7:08 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: linux-scsi, andy.teng, jejb, chun-hung.wu, kuohong.wang,
	linux-kernel, avri.altman, cang, linux-mediatek, peter.wang,
	alim.akhtar, matthias.bgg, asutoshd, bvanassche,
	linux-arm-kernel, beanhuo

Hi Martin,

On Fri, 2020-01-10 at 01:25 -0500, Martin K. Petersen wrote:
> Stanley,
> 
> > 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.
> 
> This doesn't compile. You missed adding the additional argument to one
> caller of ufshcd_tune_unipro_params().
> 

Sorry for this. I'll fix it in next version and try to separate vendor's
implementation and common driver to different commits if this is the
root cause of compile issue.

Thanks.
Stanley


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-01-10  7:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06  0:27 [PATCH v2 0/2] scsi: ufs: pass device information to apply_dev_quirks Stanley Chu
2020-01-06  0:27 ` [PATCH v2 1/2] " Stanley Chu
2020-01-06 17:45   ` asutoshd
2020-01-06 20:21     ` Avri Altman
2020-01-07  8:21   ` [EXT] " Bean Huo (beanhuo)
2020-01-10  6:25   ` Martin K. Petersen
2020-01-10  7:08     ` Stanley Chu
2020-01-06  0:27 ` [PATCH v2 2/2] scsi: ufs-mediatek: add apply_dev_quirks variant operation Stanley Chu
2020-01-07  9:16   ` [EXT] " Bean Huo (beanhuo)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).