Skip to contentSkip to conversation

dm: ahci: Add a generic PCI-based AHCI driver

PATCH Superseded Bin Meng 3 participants 13 messages Jun 17, 2017 – Jul 29, 2017 libata

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c
drivers/ata/Kconfig +7 -0
index 6427f1b..cc1c52c 100644
@@ -40,6 +40,13 @@ config DM_SCSI
 
 menu "SATA/SCSI device support"
 
+config AHCI_PCI
+	bool "Support for PCI-based AHCI controller"
+	default y if X86
+	select DM_SCSI
+	help
+	  Enables support for the PCI-based AHCI controller.
+
 config SATA_CEVA
 	bool "Ceva Sata controller"
 	depends on AHCI
drivers/ata/Makefile +1 -0
index c48184c..4e2de93 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_DWC_AHCI) += dwc_ahci.o
 obj-$(CONFIG_AHCI) += ahci-uclass.o
+obj-$(CONFIG_AHCI_PCI) += ahci-pci.o
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
 obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
 obj-$(CONFIG_FSL_SATA) += fsl_sata.o
drivers/ata/ahci-pci.c new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.9.2
author
#1 lore raw

PATCH 2/3 dm: ahci: Avoid scsi_scan_dev() in ahci_probe_scsi()

Running 'scsi scan' command causes scsi_scan_dev() to be called, from which device_probe() is called and consequently AHCI driver probe routine will be called as SCSI driver's parent, and finally ahci_probe_scsi() calls scsi_scan_dev() again.

Remove the call to scsi_scan_dev() in ahci_probe_scsi().

---

 drivers/ata/ahci.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/ata/ahci.c +0 -5
index 6da412d..606347f 100644
@@ -1183,11 +1183,6 @@ int ahci_probe_scsi(struct udevice *ahci_dev)
 	ret = ahci_start_ports(uc_priv);
 	if (ret)
 		return ret;
-
-	debug("Scanning %s\n", dev->name);
-	ret = scsi_scan_dev(dev, true);
-	if (ret)
-		return ret;
 #endif
 
 	return 0;
Signature · 1 line
2.9.2
author
#4 lore raw

PATCH 3/3 cmd: scsi: Fix null pointer dereference in 'scsi reset'

In reply to Bin Meng

During 'scsi reset', scsi_bus_reset() is called with udevice pointed to NULL, which causes exception. As a temporary fix, disable the call for DM SCSI for now.

---

 cmd/scsi.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/scsi.c +2 -0
index 5709718..8e36de1 100644
@@ -36,7 +36,9 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	case 2:
 		if (strncmp(argv[1], "res", 3) == 0) {
 			printf("\nReset SCSI\n");
+#ifndef CONFIG_DM_SCSI
 			scsi_bus_reset(NULL);
+#endif
 			ret = scsi_scan(true);
 			if (ret)
 				return CMD_RET_FAILURE;
Signature · 1 line
2.9.2
#2 lore raw

PATCH 2/3 dm: ahci: Avoid scsi_scan_dev() in ahci_probe_scsi()

In reply to Bin Meng
Quoted 5 lines · Bin Meng

Running 'scsi scan' command causes scsi_scan_dev() to be called, from which device_probe() is called and consequently AHCI driver probe routine will be called as SCSI driver's parent, and finally ahci_probe_scsi() calls scsi_scan_dev() again.

Quoted 7 lines

Remove the call to scsi_scan_dev() in ahci_probe_scsi().

---

drivers/ata/ahci.c | 5 -----

1 file changed, 5 deletions(-)

I just sent a similar patch but anyway I agree this is a good idea.

#7 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

In reply to Bin Meng

Hi Bin,

Quoted 11 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

- Simon

Quoted 82 lines
drivers/ata/Kconfig +7 -0
index 6427f1b..cc1c52c 100644
@@ -40,6 +40,13 @@ config DM_SCSI
 
 menu "SATA/SCSI device support"
 
+config AHCI_PCI
+       bool "Support for PCI-based AHCI controller"
+       default y if X86
+       select DM_SCSI
+       help
+         Enables support for the PCI-based AHCI controller.
+
 config SATA_CEVA
        bool "Ceva Sata controller"
        depends on AHCI
drivers/ata/Makefile +1 -0
index c48184c..4e2de93 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_DWC_AHCI) += dwc_ahci.o
 obj-$(CONFIG_AHCI) += ahci-uclass.o
+obj-$(CONFIG_AHCI_PCI) += ahci-pci.o
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
 obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
 obj-$(CONFIG_FSL_SATA) += fsl_sata.o
drivers/ata/ahci-pci.c new file +42 -1
new file mode 100644
index 0000000..f46fad8
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <ahci.h>
+#include <dm.h>
+#include <pci.h>
+
+static int ahci_pci_bind(struct udevice *dev)
+{
+       struct udevice *scsi_dev;
+
+       return ahci_bind_scsi(dev, &scsi_dev);
+}
+
+static int ahci_pci_probe(struct udevice *dev)
+{
+       return ahci_probe_scsi(dev);
+}
+
+static const struct udevice_id ahci_pci_ids[] = {
+       { .compatible = "ahci-pci" },
+       { }
+};
+
+U_BOOT_DRIVER(ahci_pci) = {
+       .name   = "ahci_pci",
+       .id     = UCLASS_AHCI,
+       .of_match = ahci_pci_ids,
+       .bind   = ahci_pci_bind,
+       .probe = ahci_pci_probe,
+};
+
+static struct pci_device_id ahci_pci_supported[] = {
+       { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI, ~0) },
+       {},
+};
+
+U_BOOT_PCI_DEVICE(ahci_pci, ahci_pci_supported);
--

2.9.2

author
#8 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Bin,

Quoted 6 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

Quoted 9 lines
Quoted 5 lines
 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

That's my understanding as well but I have no target to test. Can you test that on Chromebook Link?

Regards,
Bin

author
#9 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

Hi Simon,

Quoted 18 lines · Bin Meng

Hi Simon,

Quoted 15 lines · Simon Glass

Hi Bin,

Quoted 11 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c
Quoted 6 lines
Quoted 3 lines

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

That's my understanding as well but I have no target to test. Can you test that on Chromebook Link?

Will this series be applied to u-boot-dm?

Regards,
Bin

#10 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 18 lines · Bin Meng

Hi Simon,

Quoted 15 lines · Simon Glass

Hi Bin,

Quoted 11 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

That's my understanding as well but I have no target to test. Can you test that on Chromebook Link?

Will this series be applied to u-boot-dm?

Yes, just got to testing this. Had some problems booting the device.

Tested-on: chromebook_link

Quoted 3 lines

Regards,
Bin

#3 lore raw

PATCH 2/3 dm: ahci: Avoid scsi_scan_dev() in ahci_probe_scsi()

In reply to Simon Glass
Quoted 5 lines · Bin Meng

Running 'scsi scan' command causes scsi_scan_dev() to be called, from which device_probe() is called and consequently AHCI driver probe routine will be called as SCSI driver's parent, and finally ahci_probe_scsi() calls scsi_scan_dev() again.

Quoted 7 lines

Remove the call to scsi_scan_dev() in ahci_probe_scsi().

---

drivers/ata/ahci.c | 5 -----

1 file changed, 5 deletions(-)

I just sent a similar patch but anyway I agree this is a good idea.

Applied to u-boot-dm, thanks!

#11 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

In reply to Simon Glass

Hi Bin,

Quoted 31 lines · Simon Glass

Hi Bin,

Quoted 28 lines · Bin Meng

Hi Simon,

Quoted 24 lines · Bin Meng

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Bin,

Quoted 6 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

Quoted 9 lines
Quoted 5 lines
 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

That's my understanding as well but I have no target to test. Can you test that on Chromebook Link?

Quoted 7 lines
Quoted 1 line

Will this series be applied to u-boot-dm?

Yes, just got to testing this. Had some problems booting the device.

Tested-on: chromebook_link

Unfortunately this produces a build warning when applied to u-boot-dm/master:

+warning: (AHCI_PCI) selects DM_SCSI which has unmet direct dependencies (BLK || BLK)

Can you please take a look? I'm sorry I did not get to it earlier.

Regards,
Simon

author
#12 lore raw

PATCH 1/3 dm: ahci: Add a generic PCI-based AHCI driver

Hi Simon,

Quoted 42 lines · Simon Glass

Hi Bin,

Quoted 31 lines · Simon Glass

Hi Bin,

Quoted 28 lines · Bin Meng

Hi Simon,

Quoted 24 lines · Bin Meng

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Bin,

Quoted 6 lines · Bin Meng

This adds support for PCI-based AHCI controller and enables it on x86 by default.

---

Quoted 9 lines
Quoted 5 lines
 drivers/ata/Kconfig    |  7 +++++++
 drivers/ata/Makefile   |  1 +
 drivers/ata/ahci-pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/ata/ahci-pci.c

I believe that if the device tree specifies this driver then it will override the generic PCI probing done here. Is that right?

That's my understanding as well but I have no target to test. Can you test that on Chromebook Link?

Quoted 7 lines
Quoted 1 line

Will this series be applied to u-boot-dm?

Yes, just got to testing this. Had some problems booting the device.

Tested-on: chromebook_link

Quoted 6 lines

Unfortunately this produces a build warning when applied to u-boot-dm/master:

+warning: (AHCI_PCI) selects DM_SCSI which has unmet direct dependencies (BLK || BLK)

Can you please take a look? I'm sorry I did not get to it earlier.

Sure I will take a look.

Regards,
Bin