Skip to contentSkip to conversation

scsi: ufs: Add PCI driver for Intel Host controllers

PATCH Applied Adrian Hunter 4 participants 12 messages Jun 5, 2017 – Jun 6, 2017 SCSI

lore
Share & tools
lore
#0 lore raw

cover scsi: ufs: Add PCI driver for Intel Host controllers

Hi

Here is a PCI driver for Intel UFS host controllers, with a small tidy-up precursor patch.

Szymon Mielczarek (2):
scsi: ufs: Tidy clocks list head usage
scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

 drivers/scsi/ufs/Kconfig            |  11 +++
 drivers/scsi/ufs/Makefile           |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c  |   2 -
 drivers/scsi/ufs/ufshcd-intel-pci.c | 183 ++++++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd-pci.c       |   2 -
 drivers/scsi/ufs/ufshcd-pltfrm.c    |   2 -
 drivers/scsi/ufs/ufshcd.c           |  12 ++-
 7 files changed, 202 insertions(+), 11 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c

Regards
Adrian

#4 lore raw

PATCH 2/2 scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

From: Szymon Mielczarek <[email protected]>

This patch adds a glue pci driver for Intel UFS Host controllers.

---
 drivers/scsi/ufs/Kconfig            |  11 +++
 drivers/scsi/ufs/Makefile           |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 183 ++++++++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c
drivers/scsi/ufs/Kconfig +11 -0
index e27b4d4e6ae2..702420bc0fac 100644
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
 	  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+	tristate "Intel PCI bus based UFS Controller support"
+	depends on SCSI_UFSHCD && PCI
+	---help---
+	This selects the Intel PCI UFS Host Controller Interface. Select this if
+	you have Intel UFS Host Controller with PCI Interface.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
 	tristate "Platform bus based UFS Controller support"
 	depends on SCSI_UFSHCD
drivers/scsi/ufs/Makefile +1 -0
index 6e77cb0bfee9..be817e1a6666 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-d
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufshcd-intel-pci.c new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 scsi: ufs: Tidy clocks list head usage

In reply to Adrian Hunter

From: Szymon Mielczarek <[email protected]>

Move the initialization of clocks list head to ufshcd_alloc_host() so that every driver doesn't have to do it. Remove checks for the list head being NULL because that is not possible.

---
 drivers/scsi/ufs/tc-dwc-g210-pci.c |  2 --
 drivers/scsi/ufs/ufshcd-pci.c      |  2 --
 drivers/scsi/ufs/ufshcd-pltfrm.c   |  2 --
 drivers/scsi/ufs/ufshcd.c          | 12 +++++++-----
 4 files changed, 7 insertions(+), 11 deletions(-)
drivers/scsi/ufs/tc-dwc-g210-pci.c +0 -2
index c09a0fef0fe6..325d5e14fc0d 100644
@@ -130,8 +130,6 @@ static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	hba->vops = &tc_dwc_g210_pci_hba_vops;
 
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
drivers/scsi/ufs/ufshcd-pci.c +0 -2
index 52b546fb509b..5dd4122cbd85 100644
@@ -143,8 +143,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
 	if (err) {
 		dev_err(&pdev->dev, "Initialization failed\n");
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -2
index 8e5e6c04c035..e82bde077296 100644
@@ -58,8 +58,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 	if (!np)
 		goto out;
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	cnt = of_property_count_strings(np, "clock-names");
 	if (!cnt || (cnt == -EINVAL)) {
 		dev_info(dev, "%s: Unable to find clocks, assuming enabled\n",
drivers/scsi/ufs/ufshcd.c +7 -5
index ffe8d8608818..88ccd63f83c1 100644
@@ -314,7 +314,7 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba)
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return;
 
 	list_for_each_entry(clki, head, list) {
@@ -869,7 +869,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up)
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE);
@@ -943,7 +943,7 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return false;
 
 	list_for_each_entry(clki, head, list) {
@@ -6752,7 +6752,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
@@ -6818,7 +6818,7 @@ static int ufshcd_init_clocks(struct ufs_hba *hba)
 	struct device *dev = hba->dev;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	list_for_each_entry(clki, head, list) {
@@ -7811,6 +7811,8 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
 	hba->dev = dev;
 	*hba_handle = hba;
 
+	INIT_LIST_HEAD(&hba->clk_list_head);
+
 out_error:
 	return err;
 }
Signature · 1 line
1.9.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] scsi: ufs: Tidy clocks list head usage

Quoted 120 lines · Adrian Hunter

From: Szymon Mielczarek <[email protected]>

Move the initialization of clocks list head to ufshcd_alloc_host() so that every driver doesn't have to do it. Remove checks for the list head being NULL because that is not possible.

---
 drivers/scsi/ufs/tc-dwc-g210-pci.c |  2 --
 drivers/scsi/ufs/ufshcd-pci.c      |  2 --
 drivers/scsi/ufs/ufshcd-pltfrm.c   |  2 --
 drivers/scsi/ufs/ufshcd.c          | 12 +++++++-----
 4 files changed, 7 insertions(+), 11 deletions(-)
drivers/scsi/ufs/tc-dwc-g210-pci.c +0 -2
index c09a0fef0fe6..325d5e14fc0d 100644
@@ -130,8 +130,6 @@ static void tc_dwc_g210_pci_remove(struct pci_dev 
 *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	hba->vops = &tc_dwc_g210_pci_hba_vops;
 
drivers/scsi/ufs/tc-dwc-g210-pci.c +0 -0
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
drivers/scsi/ufs/ufshcd-pci.c +0 -2
index 52b546fb509b..5dd4122cbd85 100644
@@ -143,8 +143,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
 	if (err) {
 		dev_err(&pdev->dev, "Initialization failed\n");
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -2
index 8e5e6c04c035..e82bde077296 100644
@@ -58,8 +58,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba 
 *hba)
 	if (!np)
 		goto out;
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	cnt = of_property_count_strings(np, "clock-names");
 	if (!cnt || (cnt == -EINVAL)) {
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -0
 		dev_info(dev, "%s: Unable to find clocks, assuming enabled\n",
drivers/scsi/ufs/ufshcd.c +1 -1
index ffe8d8608818..88ccd63f83c1 100644
@@ -314,7 +314,7 @@ static void ufshcd_print_clk_freqs(struct ufs_hba 
 *hba)
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return;
 
drivers/scsi/ufs/ufshcd.c +1 -1
 	list_for_each_entry(clki, head, list) {
@@ -869,7 +869,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba,
 bool scale_up)
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
drivers/scsi/ufs/ufshcd.c +1 -1
 	ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE);
@@ -943,7 +943,7 @@ static bool
 ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return false;
 
drivers/scsi/ufs/ufshcd.c +1 -1
 	list_for_each_entry(clki, head, list) {
@@ -6752,7 +6752,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba
 *hba, bool on,
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
drivers/scsi/ufs/ufshcd.c +1 -1
 	ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
@@ -6818,7 +6818,7 @@ static int ufshcd_init_clocks(struct ufs_hba 
 *hba)
 	struct device *dev = hba->dev;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
drivers/scsi/ufs/ufshcd.c +2 -0
 	list_for_each_entry(clki, head, list) {
@@ -7811,6 +7811,8 @@ int ufshcd_alloc_host(struct device *dev, struct
 ufs_hba **hba_handle)
 	hba->dev = dev;
 	*hba_handle = hba;
 
+	INIT_LIST_HEAD(&hba->clk_list_head);
+
 out_error:
 	return err;
Quoted 1 line

}

Looks good to me.

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw

Re: [PATCH 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

In reply to Adrian Hunter
Quoted 100 lines · Adrian Hunter

From: Szymon Mielczarek <[email protected]>

This patch adds a glue pci driver for Intel UFS Host controllers.

---
 drivers/scsi/ufs/Kconfig            |  11 +++
 drivers/scsi/ufs/Makefile           |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 183 
++++++++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c
drivers/scsi/ufs/Kconfig +5 -0
index e27b4d4e6ae2..702420bc0fac 100644
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
 	  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+	tristate "Intel PCI bus based UFS Controller support"
+	depends on SCSI_UFSHCD && PCI
+	---help---
+	This selects the Intel PCI UFS Host Controller Interface. Select this 

if

drivers/scsi/ufs/Kconfig +6 -0
+	you have Intel UFS Host Controller with PCI Interface.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
 	tristate "Platform bus based UFS Controller support"
 	depends on SCSI_UFSHCD
drivers/scsi/ufs/Makefile +0 -0
index 6e77cb0bfee9..be817e1a6666 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) +=

tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-d
obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o

drivers/scsi/ufs/Makefile +1 -0
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufshcd-intel-pci.c new file +6 -0
new file mode 100644
index 000000000000..c2d379f612aa
@@ -0,0 +1,183 @@
+/*
+ * Universal Flash Storage Intel Host controller PCI driver
+ *
+ * Copyright (c) 2017, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or 

modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */

drivers/scsi/ufs/ufshcd-intel-pci.c new file +27 -0
+
+#include "ufshcd.h"
+#include <linux/pci.h>
+#include <linux/pm_runtime.h>
+
+static int ufs_intel_disable_lcc(struct ufs_hba *hba)
+{
+	u32 attr = UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE);
+	u32 lcc_enable = 0;
+
+	ufshcd_dme_get(hba, attr, &lcc_enable);
+	if (lcc_enable)
+		ufshcd_dme_set(hba, attr, 0);
+
+	return 0;
+}
+
+static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
+					 enum ufs_notify_change_status status)
+{
+	int err = 0;
+
+	switch (status) {
+	case PRE_CHANGE:
+		err = ufs_intel_disable_lcc(hba);
+		break;
+	case POST_CHANGE:

drivers/scsi/ufs/ufshcd-intel-pci.c line 51

Quoted 10 lines
drivers/scsi/ufs/ufshcd-intel-pci.c new file +10 -0
+		break;
+	default:
+		break;
+	}
+
+	return err;
+}
+
+static struct ufs_hba_variant_ops ufs_intel_hba_vops = {
+	.name                   = "intel",

How about s/intel/intel-pci ? Rest looks good to me.

Quoted 133 lines
drivers/scsi/ufs/ufshcd-intel-pci.c new file +48 -0
+	.link_startup_notify	= ufs_intel_link_startup_notify,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int ufs_intel_suspend(struct device *dev)
+{
+	return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_resume(struct device *dev)
+{
+	return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+static int ufs_intel_runtime_suspend(struct device *dev)
+{
+	return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_resume(struct device *dev)
+{
+	return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_idle(struct device *dev)
+{
+	return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM */
+
+static void ufs_intel_shutdown(struct pci_dev *pdev)
+{
+	ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+static void ufs_intel_remove(struct pci_dev *pdev)
+{
+	struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+	pm_runtime_forbid(&pdev->dev);
+	pm_runtime_get_noresume(&pdev->dev);
+	ufshcd_remove(hba);
+	ufshcd_dealloc_host(hba);
+}
+
+static int ufs_intel_probe(struct pci_dev *pdev, const struct

pci_device_id *id)

drivers/scsi/ufs/ufshcd-intel-pci.c new file +84 -0
+{
+	struct ufs_hba *hba;
+	void __iomem *mmio_base;
+	int err;
+
+	dev_info(&pdev->dev, "UFS controller found [%04x:%04x]\n",
+		 (int)pdev->vendor, (int)pdev->device);
+
+	err = pcim_enable_device(pdev);
+	if (err)
+		return err;
+
+	pci_set_master(pdev);
+
+	err = pcim_iomap_regions(pdev, 1 << 0, UFSHCD);
+	if (err < 0)
+		return err;
+
+	mmio_base = pcim_iomap_table(pdev)[0];
+
+	err = ufshcd_alloc_host(&pdev->dev, &hba);
+	if (err)
+		return err;
+
+	hba->vops = &ufs_intel_hba_vops;
+
+	err = ufshcd_init(hba, mmio_base, pdev->irq);
+	if (err) {
+		dev_err(&pdev->dev, "Initialization failed\n");
+		goto out_dealloc;
+	}
+
+	pci_set_drvdata(pdev, hba);
+	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_allow(&pdev->dev);
+
+	return 0;
+
+out_dealloc:
+	ufshcd_dealloc_host(hba);
+	return err;
+}
+
+static const struct dev_pm_ops ufs_intel_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(ufs_intel_suspend,
+				ufs_intel_resume)
+	SET_RUNTIME_PM_OPS(ufs_intel_runtime_suspend,
+			   ufs_intel_runtime_resume,
+			   ufs_intel_runtime_idle)
+};
+
+#define PCI_CLASS_STORAGE_UFSHCI 0x010901
+
+#define UFSHCD_INTEL_PCI_UFSHCI_DEVICE() { \
+	.vendor      = PCI_VENDOR_ID_INTEL, \
+	.device      = PCI_ANY_ID, \
+	.subvendor   = PCI_ANY_ID, \
+	.subdevice   = PCI_ANY_ID, \
+	.class       = PCI_CLASS_STORAGE_UFSHCI, \
+	.class_mask  = ~0, \
+}
+
+static const struct pci_device_id ufs_intel_tbl[] = {
+	UFSHCD_INTEL_PCI_UFSHCI_DEVICE(),
+	{ }	/* terminate list */
+};
+MODULE_DEVICE_TABLE(pci, ufs_intel_tbl);
+
+static struct pci_driver ufs_intel_driver = {
+	.name       = "ufshcd-intel-pci",
+	.id_table   = ufs_intel_tbl,
+	.probe      = ufs_intel_probe,
+	.remove     = ufs_intel_remove,
+	.shutdown   = ufs_intel_shutdown,
+	.driver     = {
+		.pm = &ufs_intel_pm_ops
+	},
+};
+
+module_pci_driver(ufs_intel_driver);
+
+MODULE_AUTHOR("Szymon Mielczarek <[email protected]>");
+MODULE_DESCRIPTION("Intel UFS host controller PCI glue driver");
+MODULE_LICENSE("GPL v2");
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH 1/2] scsi: ufs: Tidy clocks list head usage

In reply to Adrian Hunter

Adrian,

Quoted 3 lines

Move the initialization of clocks list head to ufshcd_alloc_host() so that every driver doesn't have to do it. Remove checks for the list head being NULL because that is not possible.

Applied to 4.13/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#6 lore raw

PATCH v2 1/2 scsi: ufs: Tidy clocks list head usage

In reply to Subhash Jadavani

From: Szymon Mielczarek <[email protected]>

Move the initialization of clocks list head to ufshcd_alloc_host so that every driver doesn't have to do it. Remove checks for the list head being NULL because that is not possible.

---
 drivers/scsi/ufs/tc-dwc-g210-pci.c |  2 --
 drivers/scsi/ufs/ufshcd-pci.c      |  2 --
 drivers/scsi/ufs/ufshcd-pltfrm.c   |  2 --
 drivers/scsi/ufs/ufshcd.c          | 12 +++++++-----
 4 files changed, 7 insertions(+), 11 deletions(-)
drivers/scsi/ufs/tc-dwc-g210-pci.c +0 -2
index c09a0fef0fe6..325d5e14fc0d 100644
@@ -130,8 +130,6 @@ static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	hba->vops = &tc_dwc_g210_pci_hba_vops;
 
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
drivers/scsi/ufs/ufshcd-pci.c +0 -2
index 52b546fb509b..5dd4122cbd85 100644
@@ -143,8 +143,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 		return err;
 	}
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
 	if (err) {
 		dev_err(&pdev->dev, "Initialization failed\n");
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -2
index 8e5e6c04c035..e82bde077296 100644
@@ -58,8 +58,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 	if (!np)
 		goto out;
 
-	INIT_LIST_HEAD(&hba->clk_list_head);
-
 	cnt = of_property_count_strings(np, "clock-names");
 	if (!cnt || (cnt == -EINVAL)) {
 		dev_info(dev, "%s: Unable to find clocks, assuming enabled\n",
drivers/scsi/ufs/ufshcd.c +7 -5
index ffe8d8608818..88ccd63f83c1 100644
@@ -314,7 +314,7 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba)
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return;
 
 	list_for_each_entry(clki, head, list) {
@@ -869,7 +869,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up)
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE);
@@ -943,7 +943,7 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		return false;
 
 	list_for_each_entry(clki, head, list) {
@@ -6752,7 +6752,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
 	ktime_t start = ktime_get();
 	bool clk_state_changed = false;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
@@ -6818,7 +6818,7 @@ static int ufshcd_init_clocks(struct ufs_hba *hba)
 	struct device *dev = hba->dev;
 	struct list_head *head = &hba->clk_list_head;
 
-	if (!head || list_empty(head))
+	if (list_empty(head))
 		goto out;
 
 	list_for_each_entry(clki, head, list) {
@@ -7811,6 +7811,8 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
 	hba->dev = dev;
 	*hba_handle = hba;
 
+	INIT_LIST_HEAD(&hba->clk_list_head);
+
 out_error:
 	return err;
 }
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH V2 1/2] scsi: ufs: Tidy clocks list head usage

Oops, sorry, didn't mean to send this one again, since it has been applied.

#8 lore raw

PATCH v2 2/2 scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

In reply to Adrian Hunter

From: Szymon Mielczarek <[email protected]>

This patch adds a glue pci driver for Intel UFS Host controllers.

---

Changes in V2:

Change variant name from intel to intel-pci

 drivers/scsi/ufs/Kconfig            |  11 +++
 drivers/scsi/ufs/Makefile           |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 183 ++++++++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c
drivers/scsi/ufs/Kconfig +11 -0
index e27b4d4e6ae2..702420bc0fac 100644
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
 	  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+	tristate "Intel PCI bus based UFS Controller support"
+	depends on SCSI_UFSHCD && PCI
+	---help---
+	This selects the Intel PCI UFS Host Controller Interface. Select this if
+	you have Intel UFS Host Controller with PCI Interface.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
 	tristate "Platform bus based UFS Controller support"
 	depends on SCSI_UFSHCD
drivers/scsi/ufs/Makefile +1 -0
index 6e77cb0bfee9..be817e1a6666 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-d
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufshcd-intel-pci.c new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

Re: [PATCH 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

In reply to Adrian Hunter
Quoted 1 line

+#define PCI_CLASS_STORAGE_UFSHCI 0x010901

should me move to pci_ids.h

drivers/scsi/ufs/ufshcd-intel-pci.c line 160

Quoted 9 lines
drivers/scsi/ufs/ufshcd-intel-pci.c new file +9 -0
+
+#define UFSHCD_INTEL_PCI_UFSHCI_DEVICE() { \
+	.vendor      = PCI_VENDOR_ID_INTEL, \
+	.device      = PCI_ANY_ID, \
+	.subvendor   = PCI_ANY_ID, \
+	.subdevice   = PCI_ANY_ID, \
+	.class       = PCI_CLASS_STORAGE_UFSHCI, \
+	.class_mask  = ~0, \
+}

Please don't use a macro for this. And matching for any possible future intel device with the classcode looks a little sketchy to me to be honest.

#10 lore raw

PATCH v3 2/2 scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

From: Szymon Mielczarek <[email protected]>

This patch adds a glue pci driver for Intel UFS Host controllers.

---

Changes in V3:

Remove UFSHCI class code and match on PCI device ID

Changes in V2:

Change variant name from intel to intel-pci

 drivers/scsi/ufs/Kconfig            |  11 +++
 drivers/scsi/ufs/Makefile           |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 174 ++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c
drivers/scsi/ufs/Kconfig +11 -0
index e27b4d4e6ae2..702420bc0fac 100644
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
 	  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+	tristate "Intel PCI bus based UFS Controller support"
+	depends on SCSI_UFSHCD && PCI
+	---help---
+	This selects the Intel PCI UFS Host Controller Interface. Select this if
+	you have Intel UFS Host Controller with PCI Interface.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
 	tristate "Platform bus based UFS Controller support"
 	depends on SCSI_UFSHCD
drivers/scsi/ufs/Makefile +1 -0
index 6e77cb0bfee9..be817e1a6666 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-d
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufshcd-intel-pci.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.9.1
#11 lore raw

Re: [PATCH V3 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

This looks much better. But the new file still looks almost like a copy and paste of tc-dwc-g210-pci.c. Wouldnt it make more sense to start with a common ufshcd-pci driver that sets up the ufs_hba_variant_opsA based on the PCI ID table?

Also given that this almost entitrely a copy & paste job of tc-dwc-g210-pci.c. you should add the copyrights and following their license.