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 E2F65C27C76 for ; Wed, 25 Jan 2023 17:05:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C035854C2; Wed, 25 Jan 2023 18:05:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com 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=canonical.com header.i=@canonical.com header.b="maofl2pG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1395A85666; Wed, 25 Jan 2023 18:05:03 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E1FCC85641 for ; Wed, 25 Jan 2023 18:04:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E889F3FD96 for ; Wed, 25 Jan 2023 17:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674666297; bh=B4EYhDhlPnQsIIdsk/ZjZ+fN0KUO2wlla3QQv6LE6WQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=maofl2pGS+cxbptusO2KbjfRCztiCEm+3gsMudoUPOP8H4acwVm/qICJNf5TSA73G dMnMbOBkKazs3MyYO3z864ZT171r0K73RfromLwuwaYl6YIrbuvn7ioLqJ8sIXQxx7 XKb7bwmlwkHstJln9X8Jq6Zeg/F0ZMqwm7UqTWPLriuj5CURj4aGf1qHZDupp3hZgE t5fPy1ND1IFaz6R0AWrc/5pnjFgaA2chI4RqctM2sJOdo+UE9OHKV9LkFxIZAZnHHg 3Art0us4ZTM/kLFredHBQeOlc+yozBuQ3biSwvgCHzOZpUCrlMhEAE6UbYGm/fkGop yshMccU7lEFgQ== Received: by mail-wm1-f70.google.com with SMTP id bi18-20020a05600c3d9200b003d991844dbcso1382739wmb.4 for ; Wed, 25 Jan 2023 09:04:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B4EYhDhlPnQsIIdsk/ZjZ+fN0KUO2wlla3QQv6LE6WQ=; b=j+uepFl5wu9j6fb/r0lHSGIzQmnoCaxEzxePNIaa9GqpgDTXJPnWgXBtPR1Ok2Ur29 8BtLe06JPTi5waRkDE3ubqLRm2eZ50m/+LPq0gxg9OOGrjmNmFw4t6fxpwR4py4xmJVc SONvSFmDnFsQNekwXNdJTl5CeJUd6ZpO6Kg9bJD8EAPPpiGTS5k1+Mq2kO7QIow3F3hL 7OYu9uzQIXawkXhVT+fgHIUMjlnAFjpZiEGCCqVMyMq8UNFx0besl3iuO0QjofgLywyU wdhin6p3ct9EX2v4GhdplvDYfgh1YE1+Dka9JRjUWUMQEeR9wF+UIbzzwmhYmwcDx64B uMWg== X-Gm-Message-State: AFqh2kp6JyHKi17cIZYuD32Z79QmcoVV2a0wiHFyYWq07Jxj7bvgpw/Y /wXf9xqEvS0SLlK/K0HsRGBk8D86xlBK4MH8mLEO2PHQ0qDFQsLE8uJNyJ9BDbVxfqbBcDAONAB T1clacvOfDJid0hsZPURbuOaCSR+AUxA= X-Received: by 2002:a05:600c:4f56:b0:3db:1f68:28f with SMTP id m22-20020a05600c4f5600b003db1f68028fmr24248815wmq.24.1674666297602; Wed, 25 Jan 2023 09:04:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxnNlte+AjzaEevewepVAYLGm18+p9Ari2RJ7lyfu1V9YKBmzyY5feK5etyURb9pY7ZJyn3Q== X-Received: by 2002:a05:600c:4f56:b0:3db:1f68:28f with SMTP id m22-20020a05600c4f5600b003db1f68028fmr24248795wmq.24.1674666297319; Wed, 25 Jan 2023 09:04:57 -0800 (PST) Received: from [192.168.123.67] (ip-088-152-145-137.um26.pools.vodafone-ip.de. [88.152.145.137]) by smtp.gmail.com with ESMTPSA id m14-20020a05600c4f4e00b003a3442f1229sm2727921wmq.29.2023.01.25.09.04.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Jan 2023 09:04:56 -0800 (PST) Message-ID: Date: Wed, 25 Jan 2023 18:04:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH] bootstd: Replicate the dtb-filename quirks of distroboot Content-Language: en-US To: Tom Rini Cc: Simon Glass , Mark Kettenis , U-Boot Mailing List References: <20230125031151.69027-1-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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 directories >>> for the .dtb file. The SOC-based filename fallback is supported only for >>> 32-bit ARM. >>> >>> Adjust the code to mirror this behaviour. >>> >>> Signed-off-by: Simon Glass >>> Suggested-by: Mark Kettenis >>> --- >>> >>> boot/bootmeth_efi.c | 63 ++++++++++++++++++++++++++++++++++++++------- >>> 1 file changed, 54 insertions(+), 9 deletions(-) >>> >>> 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 *dev, 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 .dtb file >>> + * >>> + * @fname: Place to put filename >>> + * @size: Max size of filename >>> + * @seq: Sequence number, to cycle through options (0=first) >>> + * Returns: 0 on success, -ENOENT if the "fdtfile" env var does not 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 = "/dtb"; >>> + break; >>> + case 1: >>> + prefix = ""; >>> + break; >>> + case 2: >>> + prefix = "/dtb/current"; >>> + break; >>> + default: >>> + return log_msg_ret("pref", -EINVAL); >>> + } >>> fdt_fname = 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 = env_get("soc"); >>> const char *board = env_get("board"); >>> const char *boardver = 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 = 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(struct udevice *dev, >>> if (ret) >>> return log_msg_ret("read", -EINVAL); >>> - distro_efi_get_fdt_name(fname, sizeof(fname)); >>> + fdt_addr = env_get_hex("fdt_addr_r", 0); >>> + >>> + /* try the various available names */ >>> + ret = -ENOENT; >>> + for (seq = 0; ret; seq++) >> >> There are boards that don't have a dtb file available and that is ok. Don't >> loop past seq = 2. >> >> { >>> + ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq); >>> + if (ret) >>> + return log_msg_ret("nam", ret); >>> + ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr, >>> + &size); >>> + } >>> + >>> bflow->fdt_fname = strdup(fname); >>> if (!bflow->fdt_fname) >>> return log_msg_ret("fil", -ENOMEM); >> >> This should not be an error. The Distroboot fallback is the device-tree at >> $fdtcontroladdr. > > But it should note that it's using that because that's still quite often > an unexpected feature to people. > 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. A message "fil: returning err= -12" signals not caring about users. Best regards Heinrich