diff mbox series

[1/5] scsi: ufs: Allow UFS 3.0 as a valid version

Message ID 5c4281080538b74ca39cedb9112ffe71bf7a80b5.1587727756.git.Jose.Abreu@synopsys.com (mailing list archive)
State Superseded
Headers show
Series scsi: ufs: Misc improvements for DesignWare drivers and UFS | expand

Commit Message

Jose Abreu April 24, 2020, 11:36 a.m. UTC
Add a define for UFS version 3.0 and do not print an error message upon
probe when using this version.

Signed-off-by: Joao Lima <Joao.Lima@synopsys.com>
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Joao Lima <Joao.Lima@synopsys.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 drivers/scsi/ufs/ufshci.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Winkler, Tomas April 24, 2020, 11:57 a.m. UTC | #1
> Add a define for UFS version 3.0 and do not print an error message upon probe
> when using this version.
> 
> Signed-off-by: Joao Lima <Joao.Lima@synopsys.com>
> Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
LGTM
Thanks
Tomas
> 
> ---
> Cc: Joao Lima <Joao.Lima@synopsys.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/scsi/ufs/ufshcd.c | 3 ++-
>  drivers/scsi/ufs/ufshci.h | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> 7d1fa1349d40..2e5c200e915b 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -8441,7 +8441,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem
> *mmio_base, unsigned int irq)
>  	if ((hba->ufs_version != UFSHCI_VERSION_10) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_11) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_20) &&
> -	    (hba->ufs_version != UFSHCI_VERSION_21))
> +	    (hba->ufs_version != UFSHCI_VERSION_21) &&
> +	    (hba->ufs_version != UFSHCI_VERSION_30))
>  		dev_err(hba->dev, "invalid UFS version 0x%x\n",
>  			hba->ufs_version);
> 
> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index
> c2961d37cc1c..f2ee81669b00 100644
> --- a/drivers/scsi/ufs/ufshci.h
> +++ b/drivers/scsi/ufs/ufshci.h
> @@ -104,6 +104,7 @@ enum {
>  	UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */
>  	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
>  	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
> +	UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */
>  };
> 
>  /*
> --
> 2.7.4
Alim Akhtar April 24, 2020, 12:08 p.m. UTC | #2
Hello Jose,

> -----Original Message-----
> From: Jose Abreu <Jose.Abreu@synopsys.com>
> Sent: 24 April 2020 17:07
> To: linux-scsi@vger.kernel.org
> Cc: Joao Pinto <Joao.Pinto@synopsys.com>; Jose Abreu
> <Jose.Abreu@synopsys.com>; Joao Lima <Joao.Lima@synopsys.com>; Alim
> Akhtar <alim.akhtar@samsung.com>; Avri Altman <avri.altman@wdc.com>;
> James E.J. Bottomley <jejb@linux.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>; linux-kernel@vger.kernel.org
> Subject: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
> 
> Add a define for UFS version 3.0 and do not print an error message upon
probe
> when using this version.
> 
> Signed-off-by: Joao Lima <Joao.Lima@synopsys.com>
> Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
> 
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

> ---
> Cc: Joao Lima <Joao.Lima@synopsys.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/scsi/ufs/ufshcd.c | 3 ++-
>  drivers/scsi/ufs/ufshci.h | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> 7d1fa1349d40..2e5c200e915b 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -8441,7 +8441,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem
> *mmio_base, unsigned int irq)
>  	if ((hba->ufs_version != UFSHCI_VERSION_10) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_11) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_20) &&
> -	    (hba->ufs_version != UFSHCI_VERSION_21))
> +	    (hba->ufs_version != UFSHCI_VERSION_21) &&
> +	    (hba->ufs_version != UFSHCI_VERSION_30))
>  		dev_err(hba->dev, "invalid UFS version 0x%x\n",
>  			hba->ufs_version);
> 
> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index
> c2961d37cc1c..f2ee81669b00 100644
> --- a/drivers/scsi/ufs/ufshci.h
> +++ b/drivers/scsi/ufs/ufshci.h
> @@ -104,6 +104,7 @@ enum {
>  	UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */
>  	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
>  	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
> +	UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */
>  };
> 
>  /*
> --
> 2.7.4
Christoph Hellwig April 25, 2020, 11:10 a.m. UTC | #3
On Fri, Apr 24, 2020 at 01:36:56PM +0200, Jose Abreu wrote:
> Add a define for UFS version 3.0 and do not print an error message upon
> probe when using this version.

This doesn't really scale.  Version checks only make sense for a minimum
supported version.  Rejecting newer versions is just a bad idea.

> @@ -8441,7 +8441,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>  	if ((hba->ufs_version != UFSHCI_VERSION_10) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_11) &&
>  	    (hba->ufs_version != UFSHCI_VERSION_20) &&
> -	    (hba->ufs_version != UFSHCI_VERSION_21))
> +	    (hba->ufs_version != UFSHCI_VERSION_21) &&
> +	    (hba->ufs_version != UFSHCI_VERSION_30))

i.e. this should become

	if (hba->ufs_version < UFSHCI_VERSION_10)

as an additional cleanup I think it makes more sense t use a UFSHCI_VER()
macro similar to KERNEL_VERSION() or NVME_VS() instead of adding a new
define for every version.
Jose Abreu April 27, 2020, 7:50 a.m. UTC | #4
From: Christoph Hellwig <hch@infradead.org>
Date: Apr/25/2020, 12:10:56 (UTC+00:00)

> On Fri, Apr 24, 2020 at 01:36:56PM +0200, Jose Abreu wrote:
> > Add a define for UFS version 3.0 and do not print an error message upon
> > probe when using this version.
> 
> This doesn't really scale.  Version checks only make sense for a minimum
> supported version.  Rejecting newer versions is just a bad idea.
> 
> > @@ -8441,7 +8441,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
> >  	if ((hba->ufs_version != UFSHCI_VERSION_10) &&
> >  	    (hba->ufs_version != UFSHCI_VERSION_11) &&
> >  	    (hba->ufs_version != UFSHCI_VERSION_20) &&
> > -	    (hba->ufs_version != UFSHCI_VERSION_21))
> > +	    (hba->ufs_version != UFSHCI_VERSION_21) &&
> > +	    (hba->ufs_version != UFSHCI_VERSION_30))
> 
> i.e. this should become
> 
> 	if (hba->ufs_version < UFSHCI_VERSION_10)
> 
> as an additional cleanup I think it makes more sense t use a UFSHCI_VER()
> macro similar to KERNEL_VERSION() or NVME_VS() instead of adding a new
> define for every version.

Yeah, unfortunately I don't think this can be done because of this:

enum {
	UFSHCI_VERSION_10 = 0x00010000, /* 1.0 */
	UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */
	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
};

So, version 1.0 and 1.1 have higher values of 2.0 and 2.1 in terms of 
absolute value.

---
Thanks,
Jose Miguel Abreu
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 7d1fa1349d40..2e5c200e915b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8441,7 +8441,8 @@  int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	if ((hba->ufs_version != UFSHCI_VERSION_10) &&
 	    (hba->ufs_version != UFSHCI_VERSION_11) &&
 	    (hba->ufs_version != UFSHCI_VERSION_20) &&
-	    (hba->ufs_version != UFSHCI_VERSION_21))
+	    (hba->ufs_version != UFSHCI_VERSION_21) &&
+	    (hba->ufs_version != UFSHCI_VERSION_30))
 		dev_err(hba->dev, "invalid UFS version 0x%x\n",
 			hba->ufs_version);
 
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index c2961d37cc1c..f2ee81669b00 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -104,6 +104,7 @@  enum {
 	UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */
 	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
 	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
+	UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */
 };
 
 /*