From patchwork Thu Jan 4 16:01:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 759855 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp7046314wrw; Thu, 4 Jan 2024 08:01:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+B2QoEyLJC8k9CnZOk8NzmhivdClO7aUCOfGpmwmir06QlXoqI98A8Vg/PbS5RaisNPsZ X-Received: by 2002:adf:cb89:0:b0:336:5d2d:8f6a with SMTP id q9-20020adfcb89000000b003365d2d8f6amr363300wrh.87.1704384103701; Thu, 04 Jan 2024 08:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704384103; cv=none; d=google.com; s=arc-20160816; b=q1ng2ifrh4GPlXUnuStApfB+6tveWkyFZX3x4H0J7nZPku3q3FYrDWt13eshFfYgoA yZWp2VXULzWAXQ6EAFkhASzbzFny5l+8gk5u2HPK34ZjHvN99HEvQrBpYFvhiQBSQAWb HV/GmA5/IClvODcZ1zYspH3Vhx765tVx+96u+VkIvqWJrI4F9sYEOSgkt+JwdWkp87GK ZFGyc10V31KUcoEeyg98T91N72tLmkUyCe3i2MVzH+s43ONWEAJm/3tNfH8nc1Gklu+L luz0C+mMz1GdLK7pJXyx8N+yk+z2GyW+GAdbaBn/vz0eyfxD93xCe/riqzqK2GcLdGVT Y6Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=oVnIuD2Mh6WGEVfGg+7k2hwkJY6Yq7S2GdbmIRPY4sM=; fh=G8EDw7LjwfpHMXvMa4bMcdbgEZVG4DwAjafNEahJIzU=; b=cTYjCIzjh3W7lGoRIH4kdDlPbDxdjQDYnARx5FvBQdNKi1dM1q95zHPV/6ImoReOIQ AsCRRJRM2uvQwQW5seaR5jmNXTP4WgexNoXF4mZ24+JYIQrfaUSpLMbG1KoDkbir+UGh jJzNF3KF3kM5xbVTNEWNilwcYF9Ubfv4i8JoDP9YFiB8wZvItIuG64Ze0J62YLgc3C13 uZ1QVIa9I1Vx1ZL8xynrnZ+IZK3aMKPdaoeUoD1oc+8KmVDBE5p0hYhdWBNURbAkYye+ NoGvPFNesZrj2R1NoNehEU4KmjdqbGrK5EbmtWfPGAEhYAUWOC3LxqDfL1ZjsemgBgSl snww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpDw2PQu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id d8-20020adff2c8000000b0033662a8c03dsi14556964wrp.220.2024.01.04.08.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpDw2PQu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 96BB98747A; Thu, 4 Jan 2024 17:01:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FpDw2PQu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3040587575; Thu, 4 Jan 2024 17:01:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8F94B862DA for ; Thu, 4 Jan 2024 17:01:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40d41555f9dso5848235e9.2 for ; Thu, 04 Jan 2024 08:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704384095; x=1704988895; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oVnIuD2Mh6WGEVfGg+7k2hwkJY6Yq7S2GdbmIRPY4sM=; b=FpDw2PQupDeVPwkTpzLD2ACGUa/L+U7ObJdJToDhNZP52go0kz+zK/GyzOOMvvLvvZ htoSYx0CbzyfNIeTreLFd0y29h0BurU/63kgqVtDydnWHxqoVlaGQ+Pd+rMXuGoDnm8O oJKtZkf1BM+uBK1Ueh5YA13ag/ymp4H++cfBT/Ch8EGumCLLLH5C83pxEAScsv4StzQY eCfRId60Cco9bHafyp/dw0cOPOKjyHllmnKsyTn5UlXkDzOwfkrhpMGujVi8tOvCl1dt NGCEwvdEHv65QeTGYoaV44nUWDKcyzqc0TsjbSBbPulCOPO9Nb6MDoC7ORrXb9OWdAsH LBrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704384095; x=1704988895; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oVnIuD2Mh6WGEVfGg+7k2hwkJY6Yq7S2GdbmIRPY4sM=; b=iRXGwx9wZSUwmp7NhuHjm8ZKvVQbsQdjmcsyZe9dXfQl0DY9RLM5++ro0k3ezdYKf1 onuwAn+GdjmmFwnUTMuaXq0pkyBalrSt6U1/wvTnnQIrpIT05YLM7e7EKhQJ30Tl1ice ndnAF3vgyfXGaf4yZzXV4RVQS/d3IYJ+mxQxxOaMO25joGgHJ2ahf+V5baqIAPR09Fuv R/1vLaN1zVmf+DIBGI232ab4m1QW7Vb8YhGYBtmTvK8EyzNl9xasNCvPhgRSDk5Ubn/H p4WpGJqcOZ73imRX+BnMqErMq1Xv7tXbr2MXbfkgHhPiaG9xp0bzvb0uJTLbfpC6X2eI rP/Q== X-Gm-Message-State: AOJu0Ywnkont4dVuRZZrtxKezI9v7mgaosD6KyJtsgV/1iVUHoUt3UHS 8DZ0pbv7RtETzOjI7IFERfwXDFWVNCdBoA== X-Received: by 2002:a05:600c:4c16:b0:40c:32bf:20f with SMTP id d22-20020a05600c4c1600b0040c32bf020fmr464061wmp.147.1704384094963; Thu, 04 Jan 2024 08:01:34 -0800 (PST) Received: from lion.caleb.rex.connolly.tech (host-92-17-96-230.as13285.net. [92.17.96.230]) by smtp.gmail.com with ESMTPSA id je2-20020a05600c1f8200b0040d934f48d3sm3986459wmb.32.2024.01.04.08.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:01:34 -0800 (PST) From: Caleb Connolly To: Tom Rini , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH] bootdev: avoid infinite probe loop Date: Thu, 4 Jan 2024 16:01:33 +0000 Message-ID: <20240104160133.284685-1-caleb.connolly@linaro.org> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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_warn(). Signed-off-by: Caleb Connolly --- boot/bootdev-uclass.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index d01d603700d9..8dde1e18cd6e 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", 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; } }