public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: Caleb Connolly <caleb.connolly@linaro.org>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	u-boot@lists.denx.de
Subject: Re: [resend PATCH] bootdev: avoid infinite probe loop
Date: Thu, 04 Jan 2024 17:51:13 +0100	[thread overview]
Message-ID: <e92d3669c76cfcd69375ef3c2f4b814a@manjaro.org> (raw)
In-Reply-To: <20240104160346.285881-1-caleb.connolly@linaro.org>

On 2024-01-04 17:03, Caleb Connolly wrote:
> Sometimes, when only one bootdev is available, and it fails to probe, 
> we
> end up in an infinite loop calling probe() on the same device over and
> over. With only debug level log output.
> 
> Break the loop if we fail to probe the same device twice in a row, and
> promote the probe failure message to log_warning().
> 
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>

Looks good to me.

Reviewed-by: Dragan Simic <dsimic@manjaro.org>

> ---
> Resend, actually change log message to WARN loglevel.
> ---
>  boot/bootdev-uclass.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
> index d01d603700d9..cd1c2bc06774 100644
> --- a/boot/bootdev-uclass.c
> +++ b/boot/bootdev-uclass.c
> @@ -636,7 +636,7 @@ int bootdev_next_label(struct bootflow_iter *iter,
> struct udevice **devp,
> 
>  int bootdev_next_prio(struct bootflow_iter *iter, struct udevice 
> **devp)
>  {
> -	struct udevice *dev = *devp;
> +	struct udevice *dev = *devp, *last_dev = NULL;
>  	bool found;
>  	int ret;
> 
> @@ -686,9 +686,19 @@ int bootdev_next_prio(struct bootflow_iter *iter,
> struct udevice **devp)
>  			}
>  		} else {
>  			ret = device_probe(dev);
> +			if (!ret)
> +				last_dev = dev;
>  			if (ret) {
> -				log_debug("Device '%s' failed to probe\n",
> +				log_warning("Device '%s' failed to probe\n",
>  					  dev->name);
> +				if (last_dev == dev) {
> +					/*
> +					 * We have already tried this device
> +					 * and it failed to probe. Give up.
> +					 */
> +					return log_msg_ret("probe", ret);
> +				}
> +				last_dev = dev;
>  				dev = NULL;
>  			}
>  		}

  parent reply	other threads:[~2024-01-04 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 16:03 [resend PATCH] bootdev: avoid infinite probe loop Caleb Connolly
2024-01-04 16:06 ` Simon Glass
2024-01-04 16:12   ` Caleb Connolly
2024-01-04 16:51 ` Dragan Simic [this message]
2024-01-19 16:08 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e92d3669c76cfcd69375ef3c2f4b814a@manjaro.org \
    --to=dsimic@manjaro.org \
    --cc=caleb.connolly@linaro.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox