public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] bootstd: Skip over bad device during bootflows scanning
@ 2023-11-02 18:51 Tony Dinh
  2023-11-06 17:25 ` Simon Glass
  2023-11-10 16:21 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Tony Dinh @ 2023-11-02 18:51 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List; +Cc: Tom Rini, Stefan Roese, Tony Dinh

During bootstd scanning for bootdevs, if bootdev_hunt_drv() encounters
a device not found error (e.g. ENOENT), let it return a successful status
so that bootstd will continue scanning the next devices, not stopping
prematurely.

Background:

During scanning for bootflows, it's possible for bootstd to encounter a
faulty device controller. Also when the same u-boot is used for another
variant of the same board, some device controller such as SATA might
not exist.

I've found this issue while converting the Marvell Sheevaplug board to
use bootstd. This board has 2 variants, the original Sheevaplug has MMC and
USB only, but the later variant comes with USB, MMC, and eSATA ports. We
have been using the same u-boot (starting with CONFIG_IDE and later with DM
CONFIG_SATA) for both variants. This worked well with the old
envs-scripting booting scheme.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
---

Changes in v2:
- Restore bootdev_next_prio() to the original.
- Add a check in bootdev_hunt_drv(). If its descendant bootdev hunt driver
function returns -ENOENT, set the hunt status to successful (this is the
case where the device does not exist, or a bad device controller).
- Update bootdev_hunter_func() docs to indicate that a return
status -ENOENT is not an error, just a "device not found" status.
- Set status of sata_rescan() to -ENOENT when the SATA device is not found.

 boot/bootdev-uclass.c | 2 +-
 drivers/ata/sata.c    | 2 +-
 include/bootdev.h     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 44ae98a926..4926a50da8 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -784,7 +784,7 @@ static int bootdev_hunt_drv(struct bootdev_hunter *info, uint seq, bool show)
 		if (info->hunt) {
 			ret = info->hunt(info, show);
 			log_debug("  - hunt result %d\n", ret);
-			if (ret)
+			if (ret && ret != -ENOENT)
 				return ret;
 		}
 		std->hunters_used |= BIT(seq);
diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index dcb5fcf476..64fc078bad 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -65,7 +65,7 @@ int sata_rescan(bool verbose)
 	ret = uclass_find_first_device(UCLASS_AHCI, &dev);
 	if (ret || !dev) {
 		printf("Cannot find SATA device (err=%d)\n", ret);
-		return -ENOSYS;
+		return -ENOENT;
 	}
 
 	ret = device_remove(dev, DM_REMOVE_NORMAL);
diff --git a/include/bootdev.h b/include/bootdev.h
index b079a91b5b..35fa25aff1 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -65,7 +65,7 @@ struct bootdev_hunter;
  *
  * @info: Info structure describing this hunter
  * @show: true to show information from the hunter
- * Returns: 0 if OK, -ve on error
+ * Returns: 0 if OK, -ENOENT on device not found, otherwise -ve on error
  */
 typedef int (*bootdev_hunter_func)(struct bootdev_hunter *info, bool show);
 
-- 
2.39.2


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

* Re: [PATCH v2] bootstd: Skip over bad device during bootflows scanning
  2023-11-02 18:51 [PATCH v2] bootstd: Skip over bad device during bootflows scanning Tony Dinh
@ 2023-11-06 17:25 ` Simon Glass
  2023-11-10 16:21 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2023-11-06 17:25 UTC (permalink / raw)
  To: Tony Dinh; +Cc: U-Boot Mailing List, Tom Rini, Stefan Roese

On Thu, 2 Nov 2023 at 12:51, Tony Dinh <mibodhi@gmail.com> wrote:
>
> During bootstd scanning for bootdevs, if bootdev_hunt_drv() encounters
> a device not found error (e.g. ENOENT), let it return a successful status
> so that bootstd will continue scanning the next devices, not stopping
> prematurely.
>
> Background:
>
> During scanning for bootflows, it's possible for bootstd to encounter a
> faulty device controller. Also when the same u-boot is used for another
> variant of the same board, some device controller such as SATA might
> not exist.
>
> I've found this issue while converting the Marvell Sheevaplug board to
> use bootstd. This board has 2 variants, the original Sheevaplug has MMC and
> USB only, but the later variant comes with USB, MMC, and eSATA ports. We
> have been using the same u-boot (starting with CONFIG_IDE and later with DM
> CONFIG_SATA) for both variants. This worked well with the old
> envs-scripting booting scheme.
>
> Signed-off-by: Tony Dinh <mibodhi@gmail.com>
> ---
>
> Changes in v2:
> - Restore bootdev_next_prio() to the original.
> - Add a check in bootdev_hunt_drv(). If its descendant bootdev hunt driver
> function returns -ENOENT, set the hunt status to successful (this is the
> case where the device does not exist, or a bad device controller).
> - Update bootdev_hunter_func() docs to indicate that a return
> status -ENOENT is not an error, just a "device not found" status.
> - Set status of sata_rescan() to -ENOENT when the SATA device is not found.
>
>  boot/bootdev-uclass.c | 2 +-
>  drivers/ata/sata.c    | 2 +-
>  include/bootdev.h     | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

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

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

* Re: [PATCH v2] bootstd: Skip over bad device during bootflows scanning
  2023-11-02 18:51 [PATCH v2] bootstd: Skip over bad device during bootflows scanning Tony Dinh
  2023-11-06 17:25 ` Simon Glass
@ 2023-11-10 16:21 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-11-10 16:21 UTC (permalink / raw)
  To: Tony Dinh; +Cc: Simon Glass, U-Boot Mailing List, Stefan Roese

[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]

On Thu, Nov 02, 2023 at 11:51:15AM -0700, Tony Dinh wrote:

> During bootstd scanning for bootdevs, if bootdev_hunt_drv() encounters
> a device not found error (e.g. ENOENT), let it return a successful status
> so that bootstd will continue scanning the next devices, not stopping
> prematurely.
> 
> Background:
> 
> During scanning for bootflows, it's possible for bootstd to encounter a
> faulty device controller. Also when the same u-boot is used for another
> variant of the same board, some device controller such as SATA might
> not exist.
> 
> I've found this issue while converting the Marvell Sheevaplug board to
> use bootstd. This board has 2 variants, the original Sheevaplug has MMC and
> USB only, but the later variant comes with USB, MMC, and eSATA ports. We
> have been using the same u-boot (starting with CONFIG_IDE and later with DM
> CONFIG_SATA) for both variants. This worked well with the old
> envs-scripting booting scheme.
> 
> Signed-off-by: Tony Dinh <mibodhi@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-11-10 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 18:51 [PATCH v2] bootstd: Skip over bad device during bootflows scanning Tony Dinh
2023-11-06 17:25 ` Simon Glass
2023-11-10 16:21 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox