Skip to contentSkip to conversation

ata: sata_sil: Continue probing other sata port when failed current port.

PATCH New Peng Ma 4 participants 16 messages Dec 4, 2019 – Jan 28, 2020 libata

lore
Share & tools
lore

Peng Ma

author
#0 lore raw

PATCH 1/3 ata: sata_sil: Continue probing other sata port when failed current port.

In the initialization of sata driver, we want to initialize all port probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

---
 drivers/ata/sata_sil.c | 60 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)
drivers/ata/sata_sil.c +56 -4
index d06d7a079d..bbba98f9a6 100644
@@ -19,6 +19,7 @@
 #if CONFIG_IS_ENABLED(BLK)
 #include <dm.h>
 #include <blk.h>
+#include <dm/device-internal.h>
 #endif
 
 #include "sata_sil.h"
@@ -762,15 +763,33 @@ U_BOOT_DRIVER(sata_sil_driver) = {
 	.platdata_auto_alloc_size = sizeof(struct sil_sata_priv),
 };
 
+static int sil_unbind_device(struct udevice *dev)
+{
+	int ret;
+
+	ret = device_remove(dev, DM_REMOVE_NORMAL);
+	if (ret)
+		return ret;
+
+	ret = device_unbind(dev);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int sil_pci_probe(struct udevice *dev)
 {
 	struct udevice *blk;
+	int failed_number;
 	char sata_name[10];
 	pci_dev_t devno;
 	u16 word;
 	int ret;
 	int i;
 
+	failed_number = 0;
+
 	/* Get PCI device number */
 	devno = dm_pci_get_bdf(dev);
 	if (devno == -1)
@@ -823,12 +842,44 @@ static int sil_pci_probe(struct udevice *dev)
 		}
 
 		ret = sil_init_sata(blk, i);
-		if (ret)
-			return -ENODEV;
+		if (ret) {
+			ret = sil_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
+		}
 
 		ret = scan_sata(blk, i);
-		if (ret)
-			return -ENODEV;
+		if (ret) {
+			ret = sil_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
+		}
+	}
+
+	if (failed_number == sata_info.maxport)
+		return -ENODEV;
+	else
+		return 0;
+}
+
+static int sil_pci_remove(struct udevice *dev)
+{
+	int i;
+	struct sil_sata *sata;
+	struct sil_sata_priv *priv;
+
+	priv = dev_get_priv(dev);
+
+	for (i = sata_info.portbase; i < sata_info.maxport; i++) {
+		sata = priv->sil_sata_desc[i];
+		if (sata)
+			free(sata);
 	}
 
 	return 0;
@@ -856,6 +907,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = {
 	.of_match = sil_pci_ids,
 	.ops = &sata_sil_ops,
 	.probe = sil_pci_probe,
+	.remove = sil_pci_remove,
 	.priv_auto_alloc_size = sizeof(struct sil_sata_priv),
 };
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 ata: fsl_sata: Continue probing other sata port when failed current port.

In the initialization of sata driver, we want to initialize all port probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

---
 drivers/ata/fsl_sata.c | 58 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 7 deletions(-)
drivers/ata/fsl_sata.c +51 -7
index 3261c10f91..3d25101ff2 100644
@@ -21,6 +21,7 @@
 #include <dm.h>
 #include <ahci.h>
 #include <blk.h>
+#include <dm/device-internal.h>
 #else
 #ifndef CONFIG_SYS_SATA1_FLAGS
 	#define CONFIG_SYS_SATA1_FLAGS	FLAGS_DMA
@@ -121,7 +122,7 @@ static int init_sata(struct fsl_ata_priv *priv, int dev)
 	/* Zero all of the device driver struct */
 	memset((void *)sata, 0, sizeof(fsl_sata_t));
 
-	snprintf(sata->name, 12, "SATA%d:\n", dev);
+	snprintf(sata->name, 12, "SATA%d:", dev);
 
 	/* Set the controller register base address to device struct */
 #if !CONFIG_IS_ENABLED(BLK)
@@ -232,10 +233,7 @@ static int init_sata(struct fsl_ata_priv *priv, int dev)
 	mdelay(100);
 
 	/* print sata device name */
-	if (!dev)
-		printf("%s ", sata->name);
-	else
-		printf("       %s ", sata->name);
+	printf("%s ", sata->name);
 
 	/* Wait PHY RDY signal changed for 500ms */
 	ata_wait_register(&reg->hstatus, HSTATUS_PHY_RDY,
@@ -916,15 +914,32 @@ static int fsl_ata_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int fsl_unbind_device(struct udevice *dev)
+{
+	int ret;
+
+	ret = device_remove(dev, DM_REMOVE_NORMAL);
+	if (ret)
+		return ret;
+
+	ret = device_unbind(dev);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int fsl_ata_probe(struct udevice *dev)
 {
 	struct fsl_ata_priv *blk_priv, *priv;
 	struct udevice *blk;
+	int failed_number;
 	char sata_name[10];
 	int nr_ports;
 	int ret;
 	int i;
 
+	failed_number = 0;
 	priv = dev_get_priv(dev);
 	nr_ports = priv->number;
 	nr_ports = min(nr_ports, CONFIG_SYS_SATA_MAX_DEVICE);
@@ -942,7 +957,12 @@ static int fsl_ata_probe(struct udevice *dev)
 		ret = init_sata(priv, i);
 		if (ret) {
 			debug("%s: Failed to init sata\n", __func__);
-			return ret;
+			ret = fsl_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
 		}
 
 		blk_priv = dev_get_platdata(blk);
@@ -951,10 +971,33 @@ static int fsl_ata_probe(struct udevice *dev)
 		ret = scan_sata(blk);
 		if (ret) {
 			debug("%s: Failed to scan bus\n", __func__);
-			return ret;
+			ret = fsl_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
 		}
 	}
 
+	if (failed_number == nr_ports)
+		return -ENODEV;
+	else
+		return 0;
+}
+
+static int fsl_ata_remove(struct udevice *dev)
+{
+	fsl_sata_t *sata;
+	struct fsl_ata_priv *priv;
+
+	priv = dev_get_priv(dev);
+	sata = priv->fsl_sata;
+
+	free(sata->cmd_hdr_tbl_offset);
+	free(sata->cmd_desc_offset);
+	free(sata);
+
 	return 0;
 }
 
@@ -981,6 +1024,7 @@ U_BOOT_DRIVER(fsl_ahci) = {
 	.ops = &sata_fsl_ahci_ops,
 	.ofdata_to_platdata = fsl_ata_ofdata_to_platdata,
 	.probe	= fsl_ata_probe,
+	.remove = fsl_ata_remove,
 	.priv_auto_alloc_size = sizeof(struct fsl_ata_priv),
 };
 #endif
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 ata: fsl_sata: Continue probing other sata port when failed current port.

Hi Peng,

Quoted 9 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

---
 drivers/ata/fsl_sata.c | 58 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 7 deletions(-)

Why does this remove/unbind?

Regards,
Simon

author
#3 lore raw

[EXT] Re: [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.

Hi Simon,

Quoted 20 lines

-----Original Message-----
From: Simon Glass <[email protected]>
Sent: 2019年12月28日 10:27
To: Peng Ma <[email protected]>
Cc: Priyanka Jain <[email protected]>; Marcel Ziswiler <[email protected]>; Andy Tang <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.

Caution: EXT Email

Hi Peng,

Quoted 5 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port
probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

Quoted 8 lines
Quoted 5 lines
---
 drivers/ata/fsl_sata.c | 58
+++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 7 deletions(-)

Why does this remove/unbind?

[Peng Ma] Can I understand that it is the same as patch1? If not please give me more informations.
Thanks.

Best Regards,
Peng

Quoted 2 lines

Regards,
Simon

#4 lore raw

PATCH 2/3 ata: fsl_sata: Continue probing other sata port when failed current port.

In reply to Peng Ma
Quoted 5 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port
probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/bef4cf3a/attachment.sig>
author
#5 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

In reply to Peng Ma

If we didn't unbind the sata from block device, the same devices would be added after sata remove,
This patch is to resolve this issue as below:

=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
=> sata stop
=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)

---
 cmd/sata.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/sata.c +2 -0
index a73cc54bd3..6bdb516cb5 100644
@@ -26,6 +26,8 @@ int sata_remove(int devnum)
 	struct udevice *dev;
 	int rc;
 
+	blk_unbind_all(IF_TYPE_SATA);
+
 	rc = uclass_find_device(UCLASS_AHCI, devnum, &dev);
 	if (!rc && !dev)
 		rc = uclass_find_first_device(UCLASS_AHCI, &dev);
Signature · 1 line
2.17.1
#6 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

Quoted 41 lines · Peng Ma

If we didn't unbind the sata from block device, the same devices would be added after sata remove,
This patch is to resolve this issue as below:

=> sata info
SATA#0:

        (3.0 Gbps)
SATA#1:
        (3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
=> sata stop
=> sata info
SATA#0:

        (3.0 Gbps)
SATA#1:
        (3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)

Quoted 4 lines
---
 cmd/sata.c | 2 ++
 1 file changed, 2 insertions(+)
author
#7 lore raw

[EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function

Hi Simon,

Quoted 58 lines

-----Original Message-----
From: Simon Glass <[email protected]>
Sent: 2019年12月28日 10:27
To: Peng Ma <[email protected]>
Cc: Priyanka Jain <[email protected]>; Marcel Ziswiler <[email protected]>; Andy Tang <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function

Caution: EXT Email

Quoted 11 lines · Peng Ma

If we didn't unbind the sata from block device, the same devices would be added after sata remove, This patch is to resolve this issue as below:

=> sata info
SATA#0:

        (3.0 Gbps)
SATA#1:
        (3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:

BTPR247005PY30

Quoted 7 lines

Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) =>

sata

Quoted 6 lines

stop => sata info
SATA#0:

        (3.0 Gbps)
SATA#1:
        (3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:

BTPR247005PY300

Quoted 4 lines

Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:

BTPR247005VX300

Quoted 4 lines

Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:

BTPR247005PY300

Quoted 4 lines

Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:

BTPR247005VX300

Quoted 4 lines

Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)

Quoted 6 lines
Quoted 4 lines
---
 cmd/sata.c | 2 ++
 1 file changed, 2 insertions(+)

[Peng Ma] thanks very much.

Best Regards,
Peng

#8 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

In reply to Peng Ma
Quoted 40 lines · Peng Ma

If we didn't unbind the sata from block device, the same devices would be added after sata remove,
This patch is to resolve this issue as below:

=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
=> sata stop
=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)

Quoted 2 lines

This is a correct bug fix, yes. It also causes size growth on tbs2910 that is in turn fatal on CI. For the moment I'm setting this patch aside so that I can take the rest of the series and figure out what to do with tbs2910 again afterwards.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/dbb12eb8/attachment.sig>
#9 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

On Wed, 8 Jan 2020 15:12:44 -0500
Tom Rini trini at konsulko.com wrote:
...

Quoted 4 lines

This is a correct bug fix, yes. It also causes size growth on tbs2910 that is in turn fatal on CI. For the moment I'm setting this patch aside so that I can take the rest of the series and figure out what to do with tbs2910 again afterwards.

Maybe we can apply patch [1] for tbs2910? But it hasn't been tested on real hardware yet, it seems.

[1] http://patchwork.ozlabs.org/patch/1205244

--
Anatolij

#10 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

Quoted 8 lines · Anatolij Gustschin

On Wed, 8 Jan 2020 15:12:44 -0500
Tom Rini trini at konsulko.com wrote:
...

Quoted 4 lines

This is a correct bug fix, yes. It also causes size growth on tbs2910 that is in turn fatal on CI. For the moment I'm setting this patch aside so that I can take the rest of the series and figure out what to do with tbs2910 again afterwards.

Quoted 4 lines

Maybe we can apply patch [1] for tbs2910? But it hasn't been tested on real hardware yet, it seems.

[1] http://patchwork.ozlabs.org/patch/1205244

Yes, that seems like the best path forward. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/41502990/attachment.sig>
#11 lore raw

PATCH 3/3 cmd: sata: Add block unbind device function

In reply to Peng Ma
Quoted 40 lines · Peng Ma

If we didn't unbind the sata from block device, the same devices would be added after sata remove,
This patch is to resolve this issue as below:

=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
=> sata stop
=> sata info
SATA#0:

	(3.0 Gbps)
SATA#1:
	(3.0 Gbps)

Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005PY300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
Device 3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX300
Type: Hard Disk
Supports 48-bit addressing
Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)

Quoted 2 lines

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/ccdc77a2/attachment.sig>
#12 lore raw

PATCH 1/3 ata: sata_sil: Continue probing other sata port when failed current port.

In reply to Peng Ma

Hi Peng,

Quoted 25 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

---
 drivers/ata/sata_sil.c | 60 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)
drivers/ata/sata_sil.c +1 -0
index d06d7a079d..bbba98f9a6 100644
@@ -19,6 +19,7 @@
 #if CONFIG_IS_ENABLED(BLK)
 #include <dm.h>
 #include <blk.h>
+#include <dm/device-internal.h>
 #endif
 
 #include "sata_sil.h"
@@ -762,15 +763,33 @@ U_BOOT_DRIVER(sata_sil_driver) = {
        .platdata_auto_alloc_size = sizeof(struct sil_sata_priv),
 };

drivers/ata/sata_sil.c U_BOOT_DRIVER(sata_sil_driver) = { · line 774

Quoted 10 lines
drivers/ata/sata_sil.c +9 -0
 
+static int (struct udevice *dev)
+{
+       int ret;
+
+       ret = device_remove(dev, DM_REMOVE_NORMAL);
+       if (ret)
+               return ret;
+
+       ret = device_unbind(dev);

Why are you unbinding the devices? I don't think this is needed.

Quoted 79 lines
drivers/ata/sata_sil.c +46 -5
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static int sil_pci_probe(struct udevice *dev)
 {
        struct udevice *blk;
+       int failed_number;
        char sata_name[10];
        pci_dev_t devno;
        u16 word;
        int ret;
        int i;
 
+       failed_number = 0;
+
        /* Get PCI device number */
        devno = dm_pci_get_bdf(dev);
        if (devno == -1)
@@ -823,12 +842,44 @@ static int sil_pci_probe(struct udevice *dev)
                }
 
                ret = sil_init_sata(blk, i);
-               if (ret)
-                       return -ENODEV;
+               if (ret) {
+                       ret = sil_unbind_device(blk);
+                       if (ret)
+                               return ret;
+
+                       failed_number++;
+                       continue;
+               }
 
                ret = scan_sata(blk, i);
-               if (ret)
-                       return -ENODEV;
+               if (ret) {
+                       ret = sil_unbind_device(blk);
+                       if (ret)
+                               return ret;
+
+                       failed_number++;
+                       continue;
+               }
+       }
+
+       if (failed_number == sata_info.maxport)
+               return -ENODEV;
+       else
+               return 0;
+}
+
+static int sil_pci_remove(struct udevice *dev)
+{
+       int i;
+       struct sil_sata *sata;
+       struct sil_sata_priv *priv;
+
+       priv = dev_get_priv(dev);
+
+       for (i = sata_info.portbase; i < sata_info.maxport; i++) {
+               sata = priv->sil_sata_desc[i];
+               if (sata)
+                       free(sata);
        }
 
        return 0;
@@ -856,6 +907,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = {
        .of_match = sil_pci_ids,
        .ops = &sata_sil_ops,
        .probe = sil_pci_probe,
+       .remove = sil_pci_remove,
        .priv_auto_alloc_size = sizeof(struct sil_sata_priv),
 };
 
--
Quoted 2 lines

2.17.1

Regards,
Simon

author
#13 lore raw

Hi Simon,

I am very sorry to reply late, Please see comments inline.

Best Regards,
Peng

Quoted 41 lines

-----Original Message-----
From: Simon Glass <[email protected]>
Sent: 2019年12月28日 10:27
To: Peng Ma <[email protected]>
Cc: Priyanka Jain <[email protected]>; Marcel Ziswiler <[email protected]>; Andy Tang <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.

Caution: EXT Email

Hi Peng,

Quoted 26 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port
probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

---
 drivers/ata/sata_sil.c | 60
+++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)
drivers/ata/sata_sil.c index renamed from drivers/ata/sata_sil.c +0 -0

d06d7a079d..bbba98f9a6 100644

drivers/ata/sata_sil.c +1 -0
@@ -19,6 +19,7 @@
 #if CONFIG_IS_ENABLED(BLK)
 #include <dm.h>
 #include <blk.h>
+#include <dm/device-internal.h>
 #endif
 
 #include "sata_sil.h"
@@ -762,15 +763,33 @@ U_BOOT_DRIVER(sata_sil_driver) = {
        .platdata_auto_alloc_size = sizeof(struct sil_sata_priv),  };
 
Quoted 11 lines

drivers/ata/sata_sil.c U_BOOT_DRIVER(sata_sil_driver) = { · line 774

Quoted 9 lines
drivers/ata/sata_sil.c +9 -0
+static int (struct udevice *dev)
+{
+       int ret;
+
+       ret = device_remove(dev, DM_REMOVE_NORMAL);
+       if (ret)
+               return ret;
+
+       ret = device_unbind(dev);

Why are you unbinding the devices? I don't think this is needed.

[Peng Ma] Before sil_init_sata function failed the function blk_create_devicef have already be called, In the blk_create_devicef function it would be bound the silicon sata to block device, So we should unbind this device here once the function sil_init_sata return failed.

Quoted 82 lines
Quoted 77 lines
drivers/ata/sata_sil.c +45 -5
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static int sil_pci_probe(struct udevice *dev)  {
        struct udevice *blk;
+       int failed_number;
        char sata_name[10];
        pci_dev_t devno;
        u16 word;
        int ret;
        int i;
 
+       failed_number = 0;
+
        /* Get PCI device number */
        devno = dm_pci_get_bdf(dev);
        if (devno == -1)
@@ -823,12 +842,44 @@ static int sil_pci_probe(struct udevice *dev)
                }
 
                ret = sil_init_sata(blk, i);
-               if (ret)
-                       return -ENODEV;
+               if (ret) {
+                       ret = sil_unbind_device(blk);
+                       if (ret)
+                               return ret;
+
+                       failed_number++;
+                       continue;
+               }
 
                ret = scan_sata(blk, i);
-               if (ret)
-                       return -ENODEV;
+               if (ret) {
+                       ret = sil_unbind_device(blk);
+                       if (ret)
+                               return ret;
+
+                       failed_number++;
+                       continue;
+               }
+       }
+
+       if (failed_number == sata_info.maxport)
+               return -ENODEV;
+       else
+               return 0;
+}
+
+static int sil_pci_remove(struct udevice *dev) {
+       int i;
+       struct sil_sata *sata;
+       struct sil_sata_priv *priv;
+
+       priv = dev_get_priv(dev);
+
+       for (i = sata_info.portbase; i < sata_info.maxport; i++) {
+               sata = priv->sil_sata_desc[i];
+               if (sata)
+                       free(sata);
        }
 
        return 0;
@@ -856,6 +907,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = {
        .of_match = sil_pci_ids,
        .ops = &sata_sil_ops,
        .probe = sil_pci_probe,
+       .remove = sil_pci_remove,
        .priv_auto_alloc_size = sizeof(struct sil_sata_priv),  };
 
--
Quoted 2 lines

2.17.1

Regards,
Simon

#14 lore raw

PATCH 1/3 ata: sata_sil: Continue probing other sata port when failed current port.

In reply to Peng Ma
Quoted 5 lines · Peng Ma

In the initialization of sata driver, we want to initialize all port
probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/1edc0111/attachment.sig>
author
#15 lore raw
Quoted 14 lines

-----Original Message-----
From: Tom Rini <[email protected]>
Sent: 2020年1月9日 4:12
To: Peng Ma <[email protected]>
Cc: sjg at chromium.org; Priyanka Jain <[email protected]>; Marcel Ziswiler <[email protected]>; Andy Tang <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.

On Wed, Dec 04, 2019 at 10:36:42AM +0000, Peng Ma wrote:

Quoted 8 lines
Quoted 5 lines

In the initialization of sata driver, we want to initialize all port probes, Therefore, any detection failure between of them should continue initialization by skipping the current port instead of exit.

Applied to u-boot/master, thanks!

[Peng Ma] Thanks a lot.

Best Regards,
Peng

Quoted 2 lines

--
Tom