All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
@ 2019-12-04 10:36 Peng Ma
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-04 10:36 UTC (permalink / raw)
  To: u-boot

 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.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
---
 drivers/ata/sata_sil.c | 60 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index d06d7a079d..bbba98f9a6 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -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),
 };
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.
  2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
@ 2019-12-04 10:36 ` Peng Ma
  2019-12-28  2:26   ` Simon Glass
  2020-01-08 20:12   ` Tom Rini
  2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-04 10:36 UTC (permalink / raw)
  To: u-boot

 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.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
---
 drivers/ata/fsl_sata.c | 58 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c
index 3261c10f91..3d25101ff2 100644
--- a/drivers/ata/fsl_sata.c
+++ b/drivers/ata/fsl_sata.c
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
@ 2019-12-04 10:36 ` Peng Ma
  2019-12-28  2:26   ` Simon Glass
                     ` (2 more replies)
  2019-12-28  2:26 ` [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Simon Glass
  2020-01-08 20:12 ` Tom Rini
  3 siblings, 3 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-04 10:36 UTC (permalink / raw)
  To: u-boot

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)

Signed-off-by: Peng Ma <peng.ma@nxp.com>
---
 cmd/sata.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/sata.c b/cmd/sata.c
index a73cc54bd3..6bdb516cb5 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -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);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
  2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
  2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
@ 2019-12-28  2:26 ` Simon Glass
  2019-12-30  7:27   ` [EXT] " Peng Ma
  2020-01-08 20:12 ` Tom Rini
  3 siblings, 1 reply; 16+ messages in thread
From: Simon Glass @ 2019-12-28  2:26 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>
>  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.
>
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> ---
>  drivers/ata/sata_sil.c | 60 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 56 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
> index d06d7a079d..bbba98f9a6 100644
> --- a/drivers/ata/sata_sil.c
> +++ b/drivers/ata/sata_sil.c
> @@ -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 (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.

> +       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),
>  };
>
> --
> 2.17.1
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
@ 2019-12-28  2:26   ` Simon Glass
  2019-12-30  7:32     ` [EXT] " Peng Ma
  2020-01-08 20:12   ` Tom Rini
  1 sibling, 1 reply; 16+ messages in thread
From: Simon Glass @ 2019-12-28  2:26 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>
>  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.
>
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> ---
>  drivers/ata/fsl_sata.c | 58 +++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 51 insertions(+), 7 deletions(-)

Why does this remove/unbind?

Regards,
Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
@ 2019-12-28  2:26   ` Simon Glass
  2019-12-30  7:19     ` [EXT] " Peng Ma
  2020-01-08 20:12   ` Tom Rini
  2020-01-28  0:56   ` Tom Rini
  2 siblings, 1 reply; 16+ messages in thread
From: Simon Glass @ 2019-12-28  2:26 UTC (permalink / raw)
  To: u-boot

On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>
> 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)
>
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> ---
>  cmd/sata.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function
  2019-12-28  2:26   ` Simon Glass
@ 2019-12-30  7:19     ` Peng Ma
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-30  7:19 UTC (permalink / raw)
  To: u-boot

Hi Simon,

>-----Original Message-----
>From: Simon Glass <sjg@chromium.org>
>Sent: 2019年12月28日 10:27
>To: Peng Ma <peng.ma@nxp.com>
>Cc: Priyanka Jain <priyanka.jain@nxp.com>; Marcel Ziswiler
><marcel.ziswiler@toradex.com>; Andy Tang <andy.tang@nxp.com>;
>u-boot at lists.denx.de
>Subject: [EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function
>
>Caution: EXT Email
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>>
>> 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)
>>
>> Signed-off-by: Peng Ma <peng.ma@nxp.com>
>> ---
>>  cmd/sata.c | 2 ++
>>  1 file changed, 2 insertions(+)
>
>Reviewed-by: Simon Glass <sjg@chromium.org>
[Peng Ma] thanks very much.

Best Regards,
Peng

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
  2019-12-28  2:26 ` [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Simon Glass
@ 2019-12-30  7:27   ` Peng Ma
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-30  7:27 UTC (permalink / raw)
  To: u-boot

Hi Simon,

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

Best Regards,
Peng
>-----Original Message-----
>From: Simon Glass <sjg@chromium.org>
>Sent: 2019年12月28日 10:27
>To: Peng Ma <peng.ma@nxp.com>
>Cc: Priyanka Jain <priyanka.jain@nxp.com>; Marcel Ziswiler
><marcel.ziswiler@toradex.com>; Andy Tang <andy.tang@nxp.com>;
>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,
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>>
>>  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.
>>
>> Signed-off-by: Peng Ma <peng.ma@nxp.com>
>> ---
>>  drivers/ata/sata_sil.c | 60
>> +++++++++++++++++++++++++++++++++++++++---
>>  1 file changed, 56 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index
>> d06d7a079d..bbba98f9a6 100644
>> --- a/drivers/ata/sata_sil.c
>> +++ b/drivers/ata/sata_sil.c
>> @@ -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 (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.
>
>> +       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),  };
>>
>> --
>> 2.17.1
>>
>
>Regards,
>Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [EXT] Re: [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.
  2019-12-28  2:26   ` Simon Glass
@ 2019-12-30  7:32     ` Peng Ma
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-30  7:32 UTC (permalink / raw)
  To: u-boot

Hi Simon,

>-----Original Message-----
>From: Simon Glass <sjg@chromium.org>
>Sent: 2019年12月28日 10:27
>To: Peng Ma <peng.ma@nxp.com>
>Cc: Priyanka Jain <priyanka.jain@nxp.com>; Marcel Ziswiler
><marcel.ziswiler@toradex.com>; Andy Tang <andy.tang@nxp.com>;
>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,
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma <peng.ma@nxp.com> wrote:
>>
>>  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.
>>
>> Signed-off-by: Peng Ma <peng.ma@nxp.com>
>> ---
>>  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
>Regards,
>Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
  2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
                   ` (2 preceding siblings ...)
  2019-12-28  2:26 ` [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Simon Glass
@ 2020-01-08 20:12 ` Tom Rini
  2020-01-09  2:22   ` [EXT] " Peng Ma
  3 siblings, 1 reply; 16+ messages in thread
From: Tom Rini @ 2020-01-08 20:12 UTC (permalink / raw)
  To: u-boot

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

> 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.
> 
> Signed-off-by: Peng Ma <peng.ma@nxp.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
  2019-12-28  2:26   ` Simon Glass
@ 2020-01-08 20:12   ` Tom Rini
  1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-01-08 20:12 UTC (permalink / raw)
  To: u-boot

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

> 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.
> 
> Signed-off-by: Peng Ma <peng.ma@nxp.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
  2019-12-28  2:26   ` Simon Glass
@ 2020-01-08 20:12   ` Tom Rini
  2020-01-08 21:49     ` Anatolij Gustschin
  2020-01-28  0:56   ` Tom Rini
  2 siblings, 1 reply; 16+ messages in thread
From: Tom Rini @ 2020-01-08 20:12 UTC (permalink / raw)
  To: u-boot

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

> 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)
> 
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

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.

-- 
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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2020-01-08 20:12   ` Tom Rini
@ 2020-01-08 21:49     ` Anatolij Gustschin
  2020-01-08 21:57       ` Tom Rini
  0 siblings, 1 reply; 16+ messages in thread
From: Anatolij Gustschin @ 2020-01-08 21:49 UTC (permalink / raw)
  To: u-boot

On Wed, 8 Jan 2020 15:12:44 -0500
Tom Rini trini at konsulko.com wrote:
...
> 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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2020-01-08 21:49     ` Anatolij Gustschin
@ 2020-01-08 21:57       ` Tom Rini
  0 siblings, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-01-08 21:57 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 08, 2020 at 10:49:44PM +0100, Anatolij Gustschin wrote:
> On Wed, 8 Jan 2020 15:12:44 -0500
> Tom Rini trini at konsulko.com wrote:
> ...
> > 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

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

-- 
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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
  2020-01-08 20:12 ` Tom Rini
@ 2020-01-09  2:22   ` Peng Ma
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Ma @ 2020-01-09  2:22 UTC (permalink / raw)
  To: u-boot



>-----Original Message-----
>From: Tom Rini <trini@konsulko.com>
>Sent: 2020年1月9日 4:12
>To: Peng Ma <peng.ma@nxp.com>
>Cc: sjg at chromium.org; Priyanka Jain <priyanka.jain@nxp.com>; Marcel
>Ziswiler <marcel.ziswiler@toradex.com>; Andy Tang <andy.tang@nxp.com>;
>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:
>
>> 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.
>>
>> Signed-off-by: Peng Ma <peng.ma@nxp.com>
>
>Applied to u-boot/master, thanks!
>
[Peng Ma] Thanks a lot.

Best Regards,
Peng
>--
>Tom

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] cmd: sata: Add block unbind device function
  2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
  2019-12-28  2:26   ` Simon Glass
  2020-01-08 20:12   ` Tom Rini
@ 2020-01-28  0:56   ` Tom Rini
  2 siblings, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-01-28  0:56 UTC (permalink / raw)
  To: u-boot

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

> 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)
> 
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-01-28  0:56 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
2019-12-28  2:26   ` Simon Glass
2019-12-30  7:32     ` [EXT] " Peng Ma
2020-01-08 20:12   ` Tom Rini
2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
2019-12-28  2:26   ` Simon Glass
2019-12-30  7:19     ` [EXT] " Peng Ma
2020-01-08 20:12   ` Tom Rini
2020-01-08 21:49     ` Anatolij Gustschin
2020-01-08 21:57       ` Tom Rini
2020-01-28  0:56   ` Tom Rini
2019-12-28  2:26 ` [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Simon Glass
2019-12-30  7:27   ` [EXT] " Peng Ma
2020-01-08 20:12 ` Tom Rini
2020-01-09  2:22   ` [EXT] " Peng Ma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.