scsi: ufs: Misc improvements for DesignWare drivers and UFS
cover scsi: ufs: Misc improvements for DesignWare drivers and UFS
Misc set of improvements for Synopsys DesignWare drivers and UFS core.
Patch 1/5, allows UFS 3.0 as a valid version for a given Host.
Patch 2/5, removes all mention of G210 to the DesignWare drivers so that we can use same driver among different Test Chips.
Patch 3/5, re-arranges the initialization sequence of PCI driver to be more modular.
Patch 4/5, allows MSI as a valid interrupt type.
Finally at 5/5, we change the Maintainers for UFS DesignWare drivers.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
Jose Abreu (5):
scsi: ufs: Allow UFS 3.0 as a valid version
scsi: ufs: Rename tc-dwc-g210 -> tc-dwc
scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type
MAINTAINERS: Change Maintainers for SCSI UFS DWC Drivers
MAINTAINERS | 3 +-
drivers/scsi/ufs/Kconfig | 4 +-
drivers/scsi/ufs/Makefile | 4 +-
drivers/scsi/ufs/tc-dwc-g210-pci.c | 176 ------------------
drivers/scsi/ufs/tc-dwc-pci.c | 202 +++++++++++++++++++++
.../ufs/{tc-dwc-g210-pltfrm.c => tc-dwc-pltfrm.c} | 37 ++--
drivers/scsi/ufs/{tc-dwc-g210.c => tc-dwc.c} | 6 +-
drivers/scsi/ufs/{tc-dwc-g210.h => tc-dwc.h} | 6 +-
drivers/scsi/ufs/ufshcd.c | 3 +-
drivers/scsi/ufs/ufshci.h | 1 +
10 files changed, 236 insertions(+), 206 deletions(-)
delete mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c
create mode 100644 drivers/scsi/ufs/tc-dwc-pci.c
rename drivers/scsi/ufs/{tc-dwc-g210-pltfrm.c => tc-dwc-pltfrm.c} (70%)
rename drivers/scsi/ufs/{tc-dwc-g210.c => tc-dwc.c} (98%)
rename drivers/scsi/ufs/{tc-dwc-g210.h => tc-dwc.h} (78%)Signature · 1 line
2.7.4
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.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +2 -1
@@ -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);
drivers/scsi/ufs/ufshci.h +1 -0
@@ -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 */ };/*
Signature · 1 line
2.7.4
RE: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
Quoted 5 lines
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 <[email protected]>Signed-off-by Jose Abreu <[email protected]>
LGTM
Thanks
Tomas
Quoted 44 lines
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/scsi/ufs/ufshcd.c index renamed from drivers/scsi/ufs/ufshcd.c +0
-0
7d1fa1349d40..2e5c200e915b100644drivers/scsi/ufs/ufshcd.c +2
-1@@ -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);drivers/scsi/ufs/ufshci.h index renamed from drivers/scsi/ufs/ufshci.h +0
-0
c2961d37cc1c..f2ee81669b00100644drivers/scsi/ufs/ufshci.h +1
-1@@ -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
RE: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
In reply to Jose AbreuHello Jose,
Quoted 11 lines
-----Original Message-----
From: Jose Abreu <[email protected]>
Sent: 24 April 2020 17:07
To: [email protected]
Cc: Joao Pinto <[email protected]>; Jose Abreu <[email protected]>; Joao Lima <[email protected]>; Alim Akhtar <[email protected]>; Avri Altman <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]
Subject: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
Quoted 1 line
Add a define for UFS version 3.0 and do not print an error message upon
probe
Quoted 5 lines
when using this version.
Signed-off-by Joao Lima <[email protected]>Signed-off-by Jose Abreu <[email protected]>
Quoted 43 lines
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/scsi/ufs/ufshcd.c index renamed from drivers/scsi/ufs/ufshcd.c +0
-0
7d1fa1349d40..2e5c200e915b100644drivers/scsi/ufs/ufshcd.c +2
-1@@ -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);drivers/scsi/ufs/ufshci.h index renamed from drivers/scsi/ufs/ufshci.h +0
-0
c2961d37cc1c..f2ee81669b00100644drivers/scsi/ufs/ufshci.h +1
-1@@ -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
Re: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
In reply to Jose AbreuQuoted 2 lines · Jose Abreu
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.
drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · line 8445
Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +2
-1@@ -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.
RE: [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version
From: Christoph Hellwig <[email protected]>
Date: Apr/25/2020, 12:10:56 (UTC+00:00)
Quoted 17 lines · Jose Abreu
Quoted 2 lines
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.
drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · line 8445
Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +2
-1@@ -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
Quoted 5 lines
if (hba->ufs_version < UFSHCI_VERSION_10)as an additional cleanup I think it makes more sense t use a
UFSHCI_VER()macro similar toKERNEL_VERSION()orNVME_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
PATCH 2/5 scsi: ufs: Rename tc-dwc-g210 -> tc-dwc
In reply to Jose AbreuIn preparation for the addition of new Synopsys Test Chips versions we remove all G210 mentions in files and Kconfig entries so that we can re-use the same driver for different Test Chips.
As the PCI ID for these chips is different and as we will have different DT bindings, there is no reason to add new drivers for them and we can just re-use the existing ones.
No functional change.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/scsi/ufs/Kconfig | 4 +-
drivers/scsi/ufs/Makefile | 4 +-
.../scsi/ufs/{tc-dwc-g210-pci.c => tc-dwc-pci.c} | 70 +++++++++++-----------
.../ufs/{tc-dwc-g210-pltfrm.c => tc-dwc-pltfrm.c} | 37 ++++++------
drivers/scsi/ufs/{tc-dwc-g210.c => tc-dwc.c} | 6 +-
drivers/scsi/ufs/{tc-dwc-g210.h => tc-dwc.h} | 6 +-
6 files changed, 64 insertions(+), 63 deletions(-)
rename drivers/scsi/ufs/{tc-dwc-g210-pci.c => tc-dwc-pci.c} (60%)
rename drivers/scsi/ufs/{tc-dwc-g210-pltfrm.c => tc-dwc-pltfrm.c} (70%)
rename drivers/scsi/ufs/{tc-dwc-g210.c => tc-dwc.c} (98%)
rename drivers/scsi/ufs/{tc-dwc-g210.h => tc-dwc.h} (78%)drivers/scsi/ufs/Kconfig +2 -2
@@ -62,7 +62,7 @@ config SCSI_UFSHCD_PCI If unsure, say N. config SCSI_UFS_DWC_TC_PCI - tristate "DesignWare pci support using a G210 Test Chip" + tristate "DesignWare PCI support using a Synopsys Test Chip" depends on SCSI_UFSHCD_PCI ---help--- Synopsys Test Chip is a PHY for prototyping purposes.
@@ -89,7 +89,7 @@ config SCSI_UFS_CDNS_PLATFORM If unsure, say N. config SCSI_UFS_DWC_TC_PLATFORM - tristate "DesignWare platform support using a G210 Test Chip" + tristate "DesignWare platform support using a Synopsys Test Chip" depends on SCSI_UFSHCD_PLATFORM ---help--- Synopsys Test Chip is a PHY for prototyping purposes.
drivers/scsi/ufs/Makefile +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # UFSHCD makefile -obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o -obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o +obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-pci.o ufshcd-dwc.o tc-dwc.o +obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-pltfrm.o ufshcd-dwc.o tc-dwc.o obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
drivers/scsi/ufs/tc-dwc-pci.c renamed from drivers/scsi/ufs/tc-dwc-g210-pci.c +35 -35
167 lines not on this page · raw message
drivers/scsi/ufs/tc-dwc-pltfrm.c renamed from drivers/scsi/ufs/tc-dwc-g210-pltfrm.c +19 -18
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Synopsys G210 Test Chip driver +* Synopsys Test Chip driver * * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) *
@@ -15,7 +15,7 @@#include "ufshcd-pltfrm.h" #include "ufshcd-dwc.h" -#include "tc-dwc-g210.h" +#include "tc-dwc.h" /* * UFS DWC specific variant operations
@@ -32,7 +32,7 @@ static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = { .phy_initialization = tc_dwc_g210_config_40_bit, }; -static const struct of_device_id tc_dwc_g210_pltfm_match[] = { +static const struct of_device_id tc_dwc_pltfm_match[] = { { .compatible ="snps,g210-tc-6.00-20bit" , .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
@@ -43,21 +43,21 @@ static const struct of_device_id tc_dwc_g210_pltfm_match[] = { }, { }, }; -MODULE_DEVICE_TABLE (of, tc_dwc_g210_pltfm_match); +MODULE_DEVICE_TABLE (of, tc_dwc_pltfm_match);/** -* tc_dwc_g210_pltfm_probe() +* tc_dwc_pltfm_probe() * @pdev: pointer to platform device structure * */ -static int tc_dwc_g210_pltfm_probe (struct platform_device *pdev) +static int tc_dwc_pltfm_probe (struct platform_device *pdev) {int err;const struct of_device_id *of_id;struct ufs_hba_variant_ops *vops;struct device *dev = &pdev->dev; - of_id =of_match_node (tc_dwc_g210_pltfm_match, dev->of_node); + of_id =of_match_node (tc_dwc_pltfm_match, dev->of_node); vops = (struct ufs_hba_variant_ops *)of_id->data;/* Perform generic probe */
@@ -69,11 +69,11 @@ static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev) }/** -* tc_dwc_g210_pltfm_remove() +* tc_dwc_pltfm_remove() * @pdev: pointer to platform device structure * */ -static int tc_dwc_g210_pltfm_remove (struct platform_device *pdev) +static int tc_dwc_pltfm_remove (struct platform_device *pdev) {struct ufs_hba *hba =platform_get_drvdata (pdev);
@@ -83,7 +83,7 @@ static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev)return 0 ; } -static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = { +static const struct dev_pm_ops tc_dwc_pltfm_pm_ops = { .suspend = ufshcd_pltfrm_suspend, .resume = ufshcd_pltfrm_resume, .runtime_suspend = ufshcd_pltfrm_runtime_suspend,
@@ -91,20 +91,21 @@ static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = { .runtime_idle = ufshcd_pltfrm_runtime_idle, }; -static struct platform_driver tc_dwc_g210_pltfm_driver = { - .probe = tc_dwc_g210_pltfm_probe, - .remove = tc_dwc_g210_pltfm_remove, +static struct platform_driver tc_dwc_pltfm_driver = { + .probe = tc_dwc_pltfm_probe, + .remove = tc_dwc_pltfm_remove, .shutdown = ufshcd_pltfrm_shutdown, .driver = { - .name ="tc-dwc-g210-pltfm" , - .pm = &tc_dwc_g210_pltfm_pm_ops, - .of_match_table =of_match_ptr (tc_dwc_g210_pltfm_match), + .name ="tc-dwc-pltfm" , + .pm = &tc_dwc_pltfm_pm_ops, + .of_match_table =of_match_ptr (tc_dwc_pltfm_match), }, }; -module_platform_driver (tc_dwc_g210_pltfm_driver); +module_platform_driver (tc_dwc_pltfm_driver);MODULE_ALIAS ("platform:tc-dwc-g210-pltfm" ); -MODULE_DESCRIPTION ("Synopsys Test Chip G210 platform glue driver" ); +MODULE_ALIAS ("platform:tc-dwc-pltfm" ); +MODULE_DESCRIPTION ("Synopsys Test Chip platform glue driver" );MODULE_AUTHOR ("Joao Pinto <[email protected]>" );MODULE_LICENSE ("Dual BSD/GPL" );
drivers/scsi/ufs/tc-dwc.c renamed from drivers/scsi/ufs/tc-dwc-g210.c +3 -3
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Synopsys G210 Test Chip driver +* Synopsys Test Chip driver * * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) *
@@ -12,7 +12,7 @@#include "ufshcd-dwc.h" #include "ufshci-dwc.h" -#include "tc-dwc-g210.h" +#include "tc-dwc.h" /** * tc_dwc_g210_setup_40bit_rmmi()
@@ -313,5 +313,5 @@ int tc_dwc_g210_config_20_bit(struct ufs_hba *hba)EXPORT_SYMBOL (tc_dwc_g210_config_20_bit);MODULE_AUTHOR ("Joao Pinto <[email protected]>" ); -MODULE_DESCRIPTION ("Synopsys G210 Test Chip driver" ); +MODULE_DESCRIPTION ("Synopsys Test Chip driver" );MODULE_LICENSE ("Dual BSD/GPL" );
drivers/scsi/ufs/tc-dwc.h renamed from drivers/scsi/ufs/tc-dwc-g210.h +3 -3
@@ -1,14 +1,14 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Synopsys G210 Test Chip driver +* Synopsys Test Chip driver * * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) * * Authors: Joao Pinto <[email protected]> */ -#ifndef _TC_DWC_G210_H -#define _TC_DWC_G210_H +#ifndef _TC_DWC_H +#define _TC_DWC_Hint tc_dwc_g210_config_40_bit (struct ufs_hba *hba);int tc_dwc_g210_config_20_bit (struct ufs_hba *hba);
Signature · 1 line
2.7.4
PATCH 3/5 scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
In reply to Jose AbreuIn preparation for the addition of new Test Chips, we re-arrange the initialization sequence so that we rely on PCI ID to match for given Test Chip type.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/ufs/tc-dwc-pci.c | 68 ++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-)
drivers/scsi/ufs/tc-dwc-pci.c +44 -24
@@ -14,6 +14,11 @@#include <linux/pci.h> #include <linux/pm_runtime.h> +struct tc_dwc_data { +struct ufs_hba_variant_ops ops; +int (*setup)(struct pci_dev *pdev,struct tc_dwc_data *data); +}; +/* Test Chip type expected values */ #define TC_G210_20BIT 20#define TC_G210_40BIT 40
@@ -23,6 +28,20 @@ static int tc_type = TC_G210_INV;module_param (tc_type, int,0 );MODULE_PARM_DESC (tc_type,"Test Chip Type (20 = 20-bit, 40 = 40-bit)" ); +static int tc_dwc_g210_set_config (struct pci_dev *pdev,struct tc_dwc_data *data) +{ +if (tc_type ==TC_G210_20BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_20_bit; + }else if (tc_type ==TC_G210_40BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_40_bit; + }else { +dev_err (&pdev->dev,"test chip version not specified\n" ); +return -EPERM ; + } + +return 0 ; +} +static int tc_dwc_pci_suspend (struct device *dev) {return ufshcd_system_suspend (dev_get_drvdata (dev));
@@ -48,14 +67,6 @@ static int tc_dwc_pci_runtime_idle(struct device *dev)return ufshcd_runtime_idle (dev_get_drvdata (dev)); } -/* -* struct ufs_hba_dwc_vops - UFS DWC specific variant operations -*/ -static struct ufs_hba_variant_ops tc_dwc_pci_hba_vops = { - .name ="tc-dwc-pci" , - .link_startup_notify = ufshcd_dwc_link_startup_notify, -}; -/** * tc_dwc_pci_shutdown - main function to put the controller in reset state * @pdev: pointer to PCI device handle
@@ -89,22 +100,11 @@ static void tc_dwc_pci_remove(struct pci_dev *pdev)static int tc_dwc_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { -struct ufs_hba *hba; +struct tc_dwc_data *data = (struct tc_dwc_data *)id->driver_data;void __iomem *mmio_base; +struct ufs_hba *hba;int err; -/* Check Test Chip type and set the specific setup routine */ -if (tc_type ==TC_G210_20BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_20_bit; - }else if (tc_type ==TC_G210_40BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_40_bit; - }else { -dev_err (&pdev->dev,"test chip version not specified\n" ); -return -EPERM ; - } - err =pcim_enable_device (pdev);if (err) {dev_err (&pdev->dev,"pcim_enable_device failed\n" );
@@ -127,7 +127,16 @@ tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return err; } - hba->vops = &tc_dwc_pci_hba_vops; +/* Check Test Chip type and set the specific setup routine */ +if (data && data->setup) { + err = data->setup (pdev, data); +if (err) +return err; + }else { +return -ENOENT ; + } + + hba->vops = &data->ops; err =ufshcd_init (hba, mmio_base, pdev->irq);if (err) {
@@ -150,9 +159,20 @@ static const struct dev_pm_ops tc_dwc_pci_pm_ops = { .runtime_idle = tc_dwc_pci_runtime_idle, }; +static struct tc_dwc_data tc_dwc_g210_data = { + .setup = tc_dwc_g210_set_config, + .ops = { + .name ="tc-dwc-g210-pci" , + .link_startup_notify = ufshcd_dwc_link_startup_notify, + }, +}; + +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_1 0xB101 +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_2 0xB102 +static const struct pci_device_id tc_dwc_pci_tbl[] = { - {PCI_VENDOR_ID_SYNOPSYS ,0xB101 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYNOPSYS ,0xB102 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_DEVICE_DATA (SYNOPSYS ,TC_G210_1 , &tc_dwc_g210_data) }, + {PCI_DEVICE_DATA (SYNOPSYS ,TC_G210_2 , &tc_dwc_g210_data) }, { }/* terminate list */ };
Signature · 1 line
2.7.4
RE: [PATCH 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
Quoted 115 lines
In preparation for the addition of new Test Chips, we re-arrange the initialization sequence so that we rely on PCI ID to match for given Test Chip type.
Signed-off-by Jose Abreu <[email protected]>---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/tc-dwc-pci.c | 68 ++++++++++++++++++++++++++++----------- ---- 1 file changed, 44 insertions(+), 24 deletions(-)drivers/scsi/ufs/tc-dwc-pci.c index renamed from drivers/scsi/ufs/tc-dwc-pci.c +0
-0
aeb11f7f0c91..74a2d80d32bd100644drivers/scsi/ufs/tc-dwc-pci.c +4
-0@@ -14,6 +14,11 @@#include <linux/pci.h> #include <linux/pm_runtime.h> +struct tc_dwc_data { +struct ufs_hba_variant_ops ops; +int (*setup)(struct pci_dev *pdev,struct tc_dwc_data *data); }; +/* Test Chip type expected values */ #define TC_G210_20BIT 20#define TC_G210_40BIT 40@@ -23,6 +28,20 @@ static int tc_type = TC_G210_INV;
module_param(tc_type, int, 0);MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");drivers/scsi/ufs/tc-dwc-pci.c +14
-8+static int tc_dwc_g210_set_config (struct pci_dev *pdev,struct +tc_dwc_data *data) { +if (tc_type ==TC_G210_20BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_20_bit; + }else if (tc_type ==TC_G210_40BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_40_bit; + }else { +dev_err (&pdev->dev,"test chip version not specified\n" ); +return -EPERM ; + } + +return 0 ; +} +static int tc_dwc_pci_suspend (struct device *dev) {return ufshcd_system_suspend (dev_get_drvdata (dev));@@ -48,14 +67,6 @@ static int tc_dwc_pci_runtime_idle(struct device *dev)return ufshcd_runtime_idle (dev_get_drvdata (dev)); } -/* -* struct ufs_hba_dwc_vops - UFS DWC specific variant operations -*/ -static struct ufs_hba_variant_ops tc_dwc_pci_hba_vops = { - .name ="tc-dwc-pci" , - .link_startup_notify = ufshcd_dwc_link_startup_notify, -}; -/** * tc_dwc_pci_shutdown - main function to put the controller in reset state * @pdev: pointer to PCI device handle @@ -89,22 +100,11 @@ static void tc_dwc_pci_remove(struct pci_dev *pdev)static int
tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id){drivers/scsi/ufs/tc-dwc-pci.c +2
-13-struct ufs_hba *hba; +struct tc_dwc_data *data = (struct tc_dwc_data *)id->driver_data;void __iomem *mmio_base; +struct ufs_hba *hba;int err; -/* Check Test Chip type and set the specific setup routine */ -if (tc_type ==TC_G210_20BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_20_bit; - }else if (tc_type ==TC_G210_40BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_40_bit; - }else { -dev_err (&pdev->dev,"test chip version not specified\n" ); -return -EPERM ; - } - err =pcim_enable_device (pdev);if (err) { dev_err(&pdev->dev, "pcim_enable_device failed\n"); @@ -127,7 +127,16 @@
tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)drivers/scsi/ufs/tc-dwc-pci.c +10
-1return err; } - hba->vops = &tc_dwc_pci_hba_vops; +/* Check Test Chip type and set the specific setup routine */ +if (data && data->setup) { + err = data->setup (pdev, data); +if (err) +return err; + }else { +return -ENOENT ; + } + + hba->vops = &data->ops; err =ufshcd_init (hba, mmio_base, pdev->irq);if (err) {
drivers/scsi/ufs/tc-dwc-pci.c static const struct dev_pm_ops tc_dwc_pci_pm_ops · line 163
Quoted 5 lines
drivers/scsi/ufs/tc-dwc-pci.c +1
-0@@ -150,9 +159,20 @@ static const struct dev_pm_ops tc_dwc_pci_pm_ops = { .runtime_idle = tc_dwc_pci_runtime_idle, }; +static struct tc_dwc_data tc_dwc_g210_data = {
Constify the struct, if possible.
Quoted 22 lines
drivers/scsi/ufs/tc-dwc-pci.c +12
-2+ .setup = tc_dwc_g210_set_config, + .ops = { + .name = "tc-dwc-g210-pci", + .link_startup_notify = ufshcd_dwc_link_startup_notify, + }, +}; + +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_1 0xB101 +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_2 0xB102 +static const struct pci_device_id tc_dwc_pci_tbl[] = { - {PCI_VENDOR_ID_SYNOPSYS ,0xB101 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {PCI_VENDOR_ID_SYNOPSYS ,0xB102 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , 0 }, + { PCI_DEVICE_DATA(SYNOPSYS, TC_G210_1, &tc_dwc_g210_data) }, + { PCI_DEVICE_DATA(SYNOPSYS, TC_G210_2, &tc_dwc_g210_data) },{ } /* terminate list */
};--
2.7.4
RE: [PATCH 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
From: Winkler, Tomas <[email protected]>
Date: Apr/24/2020, 13:00:33 (UTC+00:00)
Quoted 119 lines
Quoted 119 lines
In preparation for the addition of new Test Chips, we re-arrange the initialization sequence so that we rely on PCI ID to match for given Test Chip type.
Signed-off-by Jose Abreu <[email protected]>---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/tc-dwc-pci.c | 68 ++++++++++++++++++++++++++++----------- ---- 1 file changed, 44 insertions(+), 24 deletions(-)drivers/scsi/ufs/tc-dwc-pci.c index renamed from drivers/scsi/ufs/tc-dwc-pci.c +0
-0
aeb11f7f0c91..74a2d80d32bd100644drivers/scsi/ufs/tc-dwc-pci.c +4
-0@@ -14,6 +14,11 @@#include <linux/pci.h> #include <linux/pm_runtime.h> +struct tc_dwc_data { +struct ufs_hba_variant_ops ops; +int (*setup)(struct pci_dev *pdev,struct tc_dwc_data *data); }; +/* Test Chip type expected values */ #define TC_G210_20BIT 20#define TC_G210_40BIT 40@@ -23,6 +28,20 @@ static int tc_type = TC_G210_INV;
module_param(tc_type, int, 0);MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");drivers/scsi/ufs/tc-dwc-pci.c +14
-8+static int tc_dwc_g210_set_config (struct pci_dev *pdev,struct +tc_dwc_data *data) { +if (tc_type ==TC_G210_20BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_20_bit; + }else if (tc_type ==TC_G210_40BIT ) { + data->ops.phy_initialization = tc_dwc_g210_config_40_bit; + }else { +dev_err (&pdev->dev,"test chip version not specified\n" ); +return -EPERM ; + } + +return 0 ; +} +static int tc_dwc_pci_suspend (struct device *dev) {return ufshcd_system_suspend (dev_get_drvdata (dev));@@ -48,14 +67,6 @@ static int tc_dwc_pci_runtime_idle(struct device *dev)return ufshcd_runtime_idle (dev_get_drvdata (dev)); } -/* -* struct ufs_hba_dwc_vops - UFS DWC specific variant operations -*/ -static struct ufs_hba_variant_ops tc_dwc_pci_hba_vops = { - .name ="tc-dwc-pci" , - .link_startup_notify = ufshcd_dwc_link_startup_notify, -}; -/** * tc_dwc_pci_shutdown - main function to put the controller in reset state * @pdev: pointer to PCI device handle @@ -89,22 +100,11 @@ static void tc_dwc_pci_remove(struct pci_dev *pdev)static int
tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id){drivers/scsi/ufs/tc-dwc-pci.c +2
-13-struct ufs_hba *hba; +struct tc_dwc_data *data = (struct tc_dwc_data *)id->driver_data;void __iomem *mmio_base; +struct ufs_hba *hba;int err; -/* Check Test Chip type and set the specific setup routine */ -if (tc_type ==TC_G210_20BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_20_bit; - }else if (tc_type ==TC_G210_40BIT ) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_40_bit; - }else { -dev_err (&pdev->dev,"test chip version not specified\n" ); -return -EPERM ; - } - err =pcim_enable_device (pdev);if (err) { dev_err(&pdev->dev, "pcim_enable_device failed\n"); @@ -127,7 +127,16 @@
tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)drivers/scsi/ufs/tc-dwc-pci.c +10
-1return err; } - hba->vops = &tc_dwc_pci_hba_vops; +/* Check Test Chip type and set the specific setup routine */ +if (data && data->setup) { + err = data->setup (pdev, data); +if (err) +return err; + }else { +return -ENOENT ; + } + + hba->vops = &data->ops; err =ufshcd_init (hba, mmio_base, pdev->irq);if (err) {@@ -150,9 +159,20 @@ static const struct dev_pm_ops tc_dwc_pci_pm_ops = { .runtime_idle = tc_dwc_pci_runtime_idle, };
Quoted 3 lines
drivers/scsi/ufs/tc-dwc-pci.c static const struct dev_pm_ops tc_dwc_pci_pm_ops = { · line 162
Quoted 1 line
drivers/scsi/ufs/tc-dwc-pci.c +1
-0+static struct tc_dwc_data tc_dwc_g210_data = {Constify the struct, if possible.
Actually, I can't because I overwrite one of the ops callback in the probe() depending on TC specified.
---
Thanks,
Jose Miguel Abreu
PATCH 4/5 scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type
In reply to Jose AbreuNewer Test Chips boards have MSI support. It does no harm to try to request it as the function will fallback to legacy interrupts if MSI is not supported.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/ufs/tc-dwc-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/ufs/tc-dwc-pci.c +7 -1
@@ -136,9 +136,15 @@ tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENOENT ; } + err =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES ); +if (err <0 ) { +dev_err (&pdev->dev,"Allocation failed\n" ); +return err; + } + hba->vops = &data->ops; - err =ufshcd_init (hba, mmio_base, pdev->irq); + err =ufshcd_init (hba, mmio_base,pci_irq_vector (pdev,0 ));if (err) {dev_err (&pdev->dev,"Initialization failed\n" );return err;
Signature · 1 line
2.7.4
RE: [PATCH 4/5] scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type
Quoted 24 lines
Newer Test Chips boards have MSI support. It does no harm to try to request it as the function will fallback to legacy interrupts if MSI is not supported.
Signed-off-by Jose Abreu <[email protected]>---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/tc-dwc-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/scsi/ufs/tc-dwc-pci.c index renamed from drivers/scsi/ufs/tc-dwc-pci.c +0
-0
74a2d80d32bd..e0a880cbbe68100644
drivers/scsi/ufs/tc-dwc-pci.c tc_dwc_pci_probe(struct pci_dev *pdev, const struct · line 140
Quoted 5 lines
drivers/scsi/ufs/tc-dwc-pci.c +1
-0@@ -136,9 +136,15 @@ tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENOENT ; } + err =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES );
PCI_IRQ_LEGACY | PCI_IRQ_MSI , is enough you don't have MSIX
drivers/scsi/ufs/tc-dwc-pci.c tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 144
Quoted 5 lines
drivers/scsi/ufs/tc-dwc-pci.c +5
-0+if (err <0 ) { +dev_err (&pdev->dev,"Allocation failed\n" ); +return err; + } +
Where do you call pci_free_irq_vectors() ?
Quoted 9 lines
drivers/scsi/ufs/tc-dwc-pci.c +1
-1hba->vops = &data->ops; - err =ufshcd_init (hba, mmio_base, pdev->irq); + err =ufshcd_init (hba, mmio_base,pci_irq_vector (pdev,0 ));if (err) {dev_err (&pdev->dev,"Initialization failed\n" );return err;
--
2.7.4
RE: [PATCH 4/5] scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type
From: Winkler, Tomas <[email protected]>
Date: Apr/24/2020, 12:55:57 (UTC+00:00)
Quoted 28 lines
Quoted 28 lines
Newer Test Chips boards have MSI support. It does no harm to try to request it as the function will fallback to legacy interrupts if MSI is not supported.
Signed-off-by Jose Abreu <[email protected]>---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Avri Altman <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/ufs/tc-dwc-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/scsi/ufs/tc-dwc-pci.c index renamed from drivers/scsi/ufs/tc-dwc-pci.c +0
-0
74a2d80d32bd..e0a880cbbe68100644drivers/scsi/ufs/tc-dwc-pci.c +0
-0@@ -136,9 +136,15 @@ tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENOENT ; }
Quoted 2 lines
drivers/scsi/ufs/tc-dwc-pci.c tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 139
Quoted 1 line
drivers/scsi/ufs/tc-dwc-pci.c +1
-0+ err =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES );
PCI_IRQ_LEGACY|PCI_IRQ_MSI, is enough you don't have MSIX
Makes sense :)
Quoted 6 lines
drivers/scsi/ufs/tc-dwc-pci.c tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 144
Quoted 5 lines
drivers/scsi/ufs/tc-dwc-pci.c +5
-0+if (err <0 ) { +dev_err (&pdev->dev,"Allocation failed\n" ); +return err; + } +Where do you call
pci_free_irq_vectors()?
Right ... Will be fixed in v2. Thanks!
---
Thanks,
Jose Miguel Abreu
PATCH 5/5 MAINTAINERS: Change Maintainers for SCSI UFS DWC Drivers
In reply to Jose AbreuPedro Sousa is no longer with Synopsys. Joao Lima and me have been working internally with our UFS Controller so we are able to help and we are volunteering as Maintainers for UFS DWC Drivers.
---
Cc: Joao Lima <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: [email protected]
--- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
MAINTAINERS +2 -1
@@ -17307,7 +17307,8 @@ F: Documentation/scsi/ufs.rst F: drivers/scsi/ufs/ UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS -M: Pedro Sousa <[email protected]> +M: Joao Lima <[email protected]> +M: Jose Abreu <[email protected]> L: [email protected] S: Supported F: drivers/scsi/ufs/*dwc*
Signature · 1 line
2.7.4