Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C91DCC27C76 for ; Wed, 25 Jan 2023 17:37:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C32CD85666; Wed, 25 Jan 2023 18:37:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="TQpxz29f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 491E08551E; Wed, 25 Jan 2023 18:37:49 +0100 (CET) Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (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 68B0785480 for ; Wed, 25 Jan 2023 18:37:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x832.google.com with SMTP id v19so4032799qtq.13 for ; Wed, 25 Jan 2023 09:37:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=j7kgFTdB70yVsxMsavJP3iq6fpZXzSELvpuEoxPnip0=; b=TQpxz29fZwrtc7C6Sf/An2xf5UskVybx3QruPsY2CiJJzw2D6wDhg6VtCZeQUimwei 4wckgks6HkV8+QvexAPRMq6C+Zu8ygfxi3XmV+QVDKgApAc7QHPwPUHbWwhMenfYZqUJ KvVGWB4RSBFVUa2ssLV+/a7hKtZpLVx8EB8eg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j7kgFTdB70yVsxMsavJP3iq6fpZXzSELvpuEoxPnip0=; b=JnF2CBYgxyZBbbBBAJhmOLxBkeaKqCqk4tBDkJPtODUIyns/xuPeI3oVKhYCt9hcI7 EmwFnMMumndPNExzA7fTPNEdvtsiWfGUrPPUH3mtalB4y+NcpBbJm+1yP0rE7wsfuJRb 6e+GGhCyY/fQG9jTSQXJSmyNahxZwf8TVdPzLgSm4NnXkMk1uz7yy3liO1IhGUAG8tdB wEcnPx/ovwSAFFlC/VEfxqEomD+y8ECW4T+o0gBJXSLf+wc75ereyzCQluawmO6uf0pu cDE651SEQnwGqAAnMTfdE7Jsnkjos6T3280cr2q16vKQEmtU2dZEJA+29Ivink3uT5Il H+Vw== X-Gm-Message-State: AFqh2krFn0dhsTogb13VfiXF/cpNIfy4nXbu1J2zlC6KTtSzEWLiUAnc qUid02CTfxzdv7mzIf0c/aDJhA== X-Google-Smtp-Source: AMrXdXuHGbEkluKuWTJo6+pDeWsbfLLPxDOge1IB82NMWD16LXUUEyB/bwWtYnsMxnH4ailxC5T+Iw== X-Received: by 2002:ac8:60d8:0:b0:3b6:321d:508d with SMTP id i24-20020ac860d8000000b003b6321d508dmr49529793qtm.41.1674668265058; Wed, 25 Jan 2023 09:37:45 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-bae1-07f2-e77c-42e1.res6.spectrum.com. [2603:6081:7b00:6400:bae1:7f2:e77c:42e1]) by smtp.gmail.com with ESMTPSA id 18-20020ac856f2000000b0039cd4d87aacsm3600568qtu.15.2023.01.25.09.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 09:37:44 -0800 (PST) Date: Wed, 25 Jan 2023 12:37:42 -0500 From: Tom Rini To: Heinrich Schuchardt Cc: Simon Glass , Mark Kettenis , U-Boot Mailing List Subject: Re: [PATCH] bootstd: Replicate the dtb-filename quirks of distroboot Message-ID: References: <20230125031151.69027-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="uQIdKoSdbb2tkq8y" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett 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.6 at phobos.denx.de X-Virus-Status: Clean --uQIdKoSdbb2tkq8y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 25, 2023 at 06:04:56PM +0100, Heinrich Schuchardt wrote: > On 1/25/23 17:15, Tom Rini wrote: > > On Wed, Jan 25, 2023 at 04:38:53PM +0100, Heinrich Schuchardt wrote: > > > On 1/25/23 04:11, Simon Glass wrote: > > > > For EFI, the distro boot scripts search in three different director= ies > > > > for the .dtb file. The SOC-based filename fallback is supported onl= y for > > > > 32-bit ARM. > > > >=20 > > > > Adjust the code to mirror this behaviour. > > > >=20 > > > > Signed-off-by: Simon Glass > > > > Suggested-by: Mark Kettenis > > > > --- > > > >=20 > > > > boot/bootmeth_efi.c | 63 ++++++++++++++++++++++++++++++++++++++-= ------ > > > > 1 file changed, 54 insertions(+), 9 deletions(-) > > > >=20 > > > > diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c > > > > index 67c972e3fe4..f9544846e68 100644 > > > > --- a/boot/bootmeth_efi.c > > > > +++ b/boot/bootmeth_efi.c > > > > @@ -147,25 +147,57 @@ static int distro_efi_check(struct udevice *d= ev, struct bootflow_iter *iter) > > > > return 0; > > > > } > > > > -static void distro_efi_get_fdt_name(char *fname, int size) > > > > +/** > > > > + * distro_efi_get_fdt_name() - Get the filename for reading the .d= tb file > > > > + * > > > > + * @fname: Place to put filename > > > > + * @size: Max size of filename > > > > + * @seq: Sequence number, to cycle through options (0=3Dfirst) > > > > + * Returns: 0 on success, -ENOENT if the "fdtfile" env var does no= t exist, > > > > + * -EINVAL if there are no more options > > > > + */ > > > > +static int distro_efi_get_fdt_name(char *fname, int size, int seq) > > > > { > > > > const char *fdt_fname; > > > > + const char *prefix; > > > > + > > > > + /* select the prefix */ > > > > + switch (seq) { > > > > + case 0: > > > > + /* this is the default */ > > > > + prefix =3D "/dtb"; > > > > + break; > > > > + case 1: > > > > + prefix =3D ""; > > > > + break; > > > > + case 2: > > > > + prefix =3D "/dtb/current"; > > > > + break; > > > > + default: > > > > + return log_msg_ret("pref", -EINVAL); > > > > + } > > > > fdt_fname =3D env_get("fdtfile"); > > > > if (fdt_fname) { > > > > - snprintf(fname, size, "dtb/%s", fdt_fname); > > > > + snprintf(fname, size, "%s/%s", prefix, fdt_fname); > > > > log_debug("Using device tree: %s\n", fname); > > > > - } else { > > > > + > > > > + /* Use this fallback only for 32-bit ARM */ > > > > + } else if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_ARM64)) { > > > > const char *soc =3D env_get("soc"); > > > > const char *board =3D env_get("board"); > > > > const char *boardver =3D env_get("boardver"); > > > > /* cf the code in label_boot() which seems very complex */ > > > > - snprintf(fname, size, "dtb/%s%s%s%s.dtb", > > > > + snprintf(fname, size, "%s/%s%s%s%s.dtb", prefix, > > > > soc ? soc : "", soc ? "-" : "", board ? board : "", > > > > boardver ? boardver : ""); > > > > log_debug("Using default device tree: %s\n", fname); > > > > + } else { > > > > + return log_msg_ret("env", -ENOENT); > > > > } > > > > + > > > > + return 0; > > > > } > > > > static int distro_efi_read_bootflow_file(struct udevice *dev, > > > > @@ -174,7 +206,7 @@ static int distro_efi_read_bootflow_file(struct= udevice *dev, > > > > struct blk_desc *desc =3D NULL; > > > > ulong fdt_addr, size; > > > > char fname[256]; > > > > - int ret; > > > > + int ret, seq; > > > > /* We require a partition table */ > > > > if (!bflow->part) > > > > @@ -196,13 +228,22 @@ static int distro_efi_read_bootflow_file(stru= ct udevice *dev, > > > > if (ret) > > > > return log_msg_ret("read", -EINVAL); > > > > - distro_efi_get_fdt_name(fname, sizeof(fname)); > > > > + fdt_addr =3D env_get_hex("fdt_addr_r", 0); > > > > + > > > > + /* try the various available names */ > > > > + ret =3D -ENOENT; > > > > + for (seq =3D 0; ret; seq++) > > >=20 > > > There are boards that don't have a dtb file available and that is ok.= Don't > > > loop past seq =3D 2. > > >=20 > > > { > > > > + ret =3D distro_efi_get_fdt_name(fname, sizeof(fname), seq); > > > > + if (ret) > > > > + return log_msg_ret("nam", ret); > > > > + ret =3D bootmeth_common_read_file(dev, bflow, fname, fdt_addr, > > > > + &size); > > > > + } > > > > + > > > > bflow->fdt_fname =3D strdup(fname); > > > > if (!bflow->fdt_fname) > > > > return log_msg_ret("fil", -ENOMEM); > > >=20 > > > This should not be an error. The Distroboot fallback is the device-tr= ee at > > > $fdtcontroladdr. > >=20 > > But it should note that it's using that because that's still quite often > > an unexpected feature to people. > >=20 >=20 > On QEMU it is just what is needed. Other boards supply the device-tree via > TF-A or OpenSBI. We should not start breaking boards. >=20 > A message "fil: returning err=3D -12" signals not caring about users. Yes, I'm saying we need a positive message when using the in memory device tree. --=20 Tom --uQIdKoSdbb2tkq8y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmPRaOAACgkQFHw5/5Y0 tyyfCwwAi9YRDlxghKSWoZGYVgWr9G0JNA9w3HwPU4YYmwrI+4DLLYVCEkFA5P3T rQ+Cf6ksCAlemOgoTcFCm8OYdY83dhUjaQYwU7bDzD2J3/C31DHstPlelTVQGIAZ m96d254YA+G/v22NW5el//WqJsXFDrSgfAtJjzSLGuoMkARccCQ4E/PwFOMVx3pR 9JLAaL6GG3P7TPqeG/B4YuDPyG/xKywQqG3WUDm1ZzGQBW2NJT7vdKVF5mIauaJU rClcuDwJth9jovOqMq5kFOZ8KA4P/FM/w+6zgggA6COGOZtvmRoV9WFkB39qJgtj 98+3ian4bp/XkAftPS/oE+O/nrN/KA/LxPCdKOT95qUAA+CnYxv3eq9qdYAcB7ML MB5thGt9JXE1PxBuVZZv2XCaFGCw4HfQpu7Oo4erq1lJ+wnSy5K1IRgBHYayn/fd OKoUyz++4denZyIleDg+5pm/eq8k8ulUz9Zs1ZmfyYyiXYYKs66spBRewQ1okOe8 x7K34xFT =wwA7 -----END PGP SIGNATURE----- --uQIdKoSdbb2tkq8y--