All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms
@ 2021-05-31  5:17 ` Stanley Chu
  2021-05-31  5:31   ` Alim Akhtar
  0 siblings, 1 reply; 3+ messages in thread
From: Stanley Chu @ 2021-05-31  5:17 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, powen.kao,
	cc.chou, chaotian.jing, jiajie.hao, Stanley Chu

Some MediaTek platforms have incorrect UFSHCI versions showed
in register map. Fix the version by referring to UniPro version
which is always correct.

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 9912e208c2a1..3d3605fd05b2 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -606,6 +606,16 @@ static void ufs_mtk_get_controller_version(struct ufs_hba *hba)
 		if (ver >= UFS_UNIPRO_VER_1_8)
 			host->hw_ver.major = 3;
 	}
+
+	/* Fix HCI version for some platforms with incorrect version */
+	if (hba->ufs_version < ufshci_version(3, 0) &&
+	    host->hw_ver.major == 3)
+		hba->ufs_version = ufshci_version(3, 0);
+}
+
+static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba)
+{
+	return hba->ufs_version;
 }
 
 /**
@@ -1042,6 +1052,7 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba,
 static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
 	.name                = "mediatek.ufshci",
 	.init                = ufs_mtk_init,
+	.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
 	.setup_clocks        = ufs_mtk_setup_clocks,
 	.hce_enable_notify   = ufs_mtk_hce_enable_notify,
 	.link_startup_notify = ufs_mtk_link_startup_notify,
-- 
2.18.0


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

* RE: [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms
  2021-05-31  5:17 ` [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms Stanley Chu
@ 2021-05-31  5:31   ` Alim Akhtar
  2021-05-31  6:27     ` Stanley Chu
  0 siblings, 1 reply; 3+ messages in thread
From: Alim Akhtar @ 2021-05-31  5:31 UTC (permalink / raw)
  To: 'Stanley Chu', linux-scsi, martin.petersen, avri.altman, jejb
  Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, powen.kao,
	cc.chou, chaotian.jing, jiajie.hao

Hi Stanley,

> -----Original Message-----
> From: Stanley Chu <stanley.chu@mediatek.com>
> Sent: 31 May 2021 10:48
> To: linux-scsi@vger.kernel.org; martin.petersen@oracle.com;
> avri.altman@wdc.com; alim.akhtar@samsung.com; jejb@linux.ibm.com
> Cc: peter.wang@mediatek.com; chun-hung.wu@mediatek.com;
> alice.chao@mediatek.com; jonathan.hsu@mediatek.com;
> powen.kao@mediatek.com; cc.chou@mediatek.com;
> chaotian.jing@mediatek.com; jiajie.hao@mediatek.com; Stanley Chu
> <stanley.chu@mediatek.com>
> Subject: [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms
> 
> Some MediaTek platforms have incorrect UFSHCI versions showed in register
> map. Fix the version by referring to UniPro version which is always
correct.
> 
A bit of extra details will help here, like say HCI version below 3.0 is
broken on some MediaTek SoC etc.
That will also help to understand if this was a deviation from HCI spec. 

> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
> ---

With the updated commit message, feel free to add
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.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 9912e208c2a1..3d3605fd05b2 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -606,6 +606,16 @@ static void ufs_mtk_get_controller_version(struct
> ufs_hba *hba)
>  		if (ver >= UFS_UNIPRO_VER_1_8)
>  			host->hw_ver.major = 3;
>  	}
> +
> +	/* Fix HCI version for some platforms with incorrect version */
> +	if (hba->ufs_version < ufshci_version(3, 0) &&
> +	    host->hw_ver.major == 3)
> +		hba->ufs_version = ufshci_version(3, 0); }
> +
> +static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba) {
> +	return hba->ufs_version;
>  }
> 
>  /**
> @@ -1042,6 +1052,7 @@ static void ufs_mtk_event_notify(struct ufs_hba
> *hba,  static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
>  	.name                = "mediatek.ufshci",
>  	.init                = ufs_mtk_init,
> +	.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
>  	.setup_clocks        = ufs_mtk_setup_clocks,
>  	.hce_enable_notify   = ufs_mtk_hce_enable_notify,
>  	.link_startup_notify = ufs_mtk_link_startup_notify,
> --
> 2.18.0



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

* RE: [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms
  2021-05-31  5:31   ` Alim Akhtar
@ 2021-05-31  6:27     ` Stanley Chu
  0 siblings, 0 replies; 3+ messages in thread
From: Stanley Chu @ 2021-05-31  6:27 UTC (permalink / raw)
  To: Alim Akhtar
  Cc: linux-scsi, martin.petersen, avri.altman, jejb, peter.wang,
	chun-hung.wu, alice.chao, jonathan.hsu, powen.kao, cc.chou,
	chaotian.jing, jiajie.hao

Hi Alim,

On Mon, 2021-05-31 at 11:01 +0530, Alim Akhtar wrote:
> Hi Stanley,
> 
> > -----Original Message-----
> > From: Stanley Chu <stanley.chu@mediatek.com>
> > Sent: 31 May 2021 10:48
> > To: linux-scsi@vger.kernel.org; martin.petersen@oracle.com;
> > avri.altman@wdc.com; alim.akhtar@samsung.com; jejb@linux.ibm.com
> > Cc: peter.wang@mediatek.com; chun-hung.wu@mediatek.com;
> > alice.chao@mediatek.com; jonathan.hsu@mediatek.com;
> > powen.kao@mediatek.com; cc.chou@mediatek.com;
> > chaotian.jing@mediatek.com; jiajie.hao@mediatek.com; Stanley Chu
> > <stanley.chu@mediatek.com>
> > Subject: [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms
> > 
> > Some MediaTek platforms have incorrect UFSHCI versions showed in register
> > map. Fix the version by referring to UniPro version which is always
> correct.
> > 
> A bit of extra details will help here, like say HCI version below 3.0 is
> broken on some MediaTek SoC etc.
> That will also help to understand if this was a deviation from HCI spec. 

Thanks for the review.
I would fix it in next version.

> 
> > Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
> > ---
> 
> With the updated commit message, feel free to add
> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.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 9912e208c2a1..3d3605fd05b2 100644
> > --- a/drivers/scsi/ufs/ufs-mediatek.c
> > +++ b/drivers/scsi/ufs/ufs-mediatek.c
> > @@ -606,6 +606,16 @@ static void ufs_mtk_get_controller_version(struct
> > ufs_hba *hba)
> >  		if (ver >= UFS_UNIPRO_VER_1_8)
> >  			host->hw_ver.major = 3;
> >  	}
> > +
> > +	/* Fix HCI version for some platforms with incorrect version */
> > +	if (hba->ufs_version < ufshci_version(3, 0) &&
> > +	    host->hw_ver.major == 3)
> > +		hba->ufs_version = ufshci_version(3, 0); }
> > +
> > +static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba) {
> > +	return hba->ufs_version;
> >  }
> > 
> >  /**
> > @@ -1042,6 +1052,7 @@ static void ufs_mtk_event_notify(struct ufs_hba
> > *hba,  static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
> >  	.name                = "mediatek.ufshci",
> >  	.init                = ufs_mtk_init,
> > +	.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
> >  	.setup_clocks        = ufs_mtk_setup_clocks,
> >  	.hce_enable_notify   = ufs_mtk_hce_enable_notify,
> >  	.link_startup_notify = ufs_mtk_link_startup_notify,
> > --
> > 2.18.0
> 
> 


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

end of thread, other threads:[~2021-05-31  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210531051803epcas5p4c0a997f3346da0a0a1190630ac64ba94@epcas5p4.samsung.com>
2021-05-31  5:17 ` [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms Stanley Chu
2021-05-31  5:31   ` Alim Akhtar
2021-05-31  6:27     ` Stanley Chu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.