From patchwork Tue Jan 17 17:47:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727611 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Rl+/Xs9V; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGbQ44q2z23fT for ; Wed, 18 Jan 2023 04:48:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99E0F855E4; Tue, 17 Jan 2023 18:48:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Rl+/Xs9V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 200FA855D3; Tue, 17 Jan 2023 18:48:40 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 C696780F98 for ; Tue, 17 Jan 2023 18:48:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id v6so6223636ilq.3 for ; Tue, 17 Jan 2023 09:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+QgzLCJwzcjlzA/Y+NxaJmCxMMV6JSVSddEjyoNWl/k=; b=Rl+/Xs9VHRh1tviVKAo11+okMQZvd0J7ZydjsTdwEJDBXJzFwIeoliIK5vhzm2bSUD kBKby8f5SOrwrOYE2m0Y+s8TvKC34d5XuzJ/zBYuzkfRTCzlXShVcUJU9ihvxkvSQk4O uW0nWiAFEAwTVGI5Irs0t19InODOGyXHJqkEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QgzLCJwzcjlzA/Y+NxaJmCxMMV6JSVSddEjyoNWl/k=; b=q7fcgRUZnlvdsTLPgGVqGHjEdbnE28m2ObYQWZ6FhKsq8fJ8gkaFlx/WXmJ9/IlqEH nxaAg8qJW1q5LkVxeCEX9lvUCGsfpb61SPfunrUCMdVFrlUKhqFf2ORjN6a/hmPtkrgZ CkL3AQirbp6l9nwIjDKmQBsc0QV8fHjB/TZPuzZ3nt+TMkIUfykhlr/rttQ9EP/bEM0E NdQH4cCLbF0jFJUncDEiFGdYYeJwvGmcdnCszhokFXUJpKTDV00UUuQHTQDCNSejLAAm xzuxZaWvPOj4wL3bp3ElrrQ2oCD8TisOkaGMFzmPASbXgkaHhIEOeIyJ1d3Er51mXAwI rSyw== X-Gm-Message-State: AFqh2koIKVE79pK9S2ZHSBkjK8riQE1ufMkuHQGKzBxsxW83ykvqD9Vs Mfu+dhbUJ5LtwwHAjbXaXX8RBrJKEB7x1WO3 X-Google-Smtp-Source: AMrXdXtOQXfs9KDVih05zMDAXE4ZAo1kWgD6RVTU5iQk5JxRqIJRr5sPImxYgBEE8ABAl501Nw2WIA== X-Received: by 2002:a92:3204:0:b0:30c:22e:9af2 with SMTP id z4-20020a923204000000b0030c022e9af2mr3299088ile.13.1673977716178; Tue, 17 Jan 2023 09:48:36 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:35 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 01/70] dm: core: Correct ordering of uclasses IDs Date: Tue, 17 Jan 2023 10:47:11 -0700 Message-Id: <20230117174820.1281477-2-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean A few of these are out of order. Fix them. Signed-off-by: Simon Glass --- (no changes since v1) include/dm/uclass-id.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 376f741cc2b..33e43c20db6 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -47,9 +47,9 @@ enum uclass_id { UCLASS_CPU, /* CPU, typically part of an SoC */ UCLASS_CROS_EC, /* Chrome OS EC */ UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */ - UCLASS_DSI_HOST, /* Display Serial Interface host */ UCLASS_DMA, /* Direct Memory Access */ UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ + UCLASS_DSI_HOST, /* Display Serial Interface host */ UCLASS_ECDSA, /* Elliptic curve cryptographic device */ UCLASS_EFI_LOADER, /* Devices created by UEFI applications */ UCLASS_EFI_MEDIA, /* Devices provided by UEFI firmware */ @@ -101,6 +101,7 @@ enum uclass_id { UCLASS_PINCTRL, /* Pinctrl (pin muxing/configuration) device */ UCLASS_PMIC, /* PMIC I/O device */ UCLASS_POWER_DOMAIN, /* (SoC) Power domains */ + UCLASS_PVBLOCK, /* Xen virtual block device */ UCLASS_PWM, /* Pulse-width modulator */ UCLASS_PWRSEQ, /* Power sequence device */ UCLASS_QFW, /* QEMU firmware config device */ @@ -142,7 +143,6 @@ enum uclass_id { UCLASS_W1, /* Dallas 1-Wire bus */ UCLASS_W1_EEPROM, /* one-wire EEPROMs */ UCLASS_WDT, /* Watchdog Timer driver */ - UCLASS_PVBLOCK, /* Xen virtual block device */ UCLASS_COUNT, UCLASS_INVALID = -1, From patchwork Tue Jan 17 17:47:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727612 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=G+HX6Rwi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGbd6H8Nz23fT for ; Wed, 18 Jan 2023 04:49:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA356855FD; Tue, 17 Jan 2023 18:48:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="G+HX6Rwi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DB2D855EB; Tue, 17 Jan 2023 18:48:42 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 46966855C7 for ; Tue, 17 Jan 2023 18:48:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id a3so9810789ilp.6 for ; Tue, 17 Jan 2023 09:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k6cXt+IOPtqEjjxb2+fO82ONpgRnE80Ua2spiQs3DHI=; b=G+HX6RwiiNBXIloZjVWb04Bcgrqx9KkzwMOfEdQxZUJMdfa1hcQJupxBNe1qojlqPF KCrUV/JIXN59MBHP7MeTooH1WgnCHN5Au91EN+oX747sIPQCk6HJxrjfuaCEoo3P4mXS JBLCRCYoDb8kXRGJIEUaQuenQTwAsj6YsXb8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k6cXt+IOPtqEjjxb2+fO82ONpgRnE80Ua2spiQs3DHI=; b=7rwShwRNAXasbqf5yS1GeaNuJBctkDM3BMfwIi+4ktU7Xt0RSYEGKp2s6sNK0nQh3p eeQI6TN2FfheKt4Y/P5gc6GjfECaNVH+sirnkv+nWUG38vK7oRCGNhtkwYvLjy5QkJQH 0sTlbEa0ztHQxwAdMsSCDUxzVsLXXCs3bbsSurGSXsym4hE4FNMBVKQalBWSYKms4ldx NYtlB/ietWyFPv7JJEA7pMIF5n7kAeyc5ikGbP7rdNuFun5RdM3/sb/Ja9IqUw5SBJIB xw96nKF3y3LWvZimqRJIBZ7v3azQW8kDcWfDhQ4Ah/QxTtk1x2VutYSYBHZw8gtUnU/o npEg== X-Gm-Message-State: AFqh2kpQhYom9HgcdUOIp4IK7vlNaL+IpKrdkO31WGd7QHgCqWCan1OX SqmC9HfiOVoLD6/wiBmgurcdoU6QewqHdJVx X-Google-Smtp-Source: AMrXdXvWVbsJ7QuHvzbb/FTFO+9i1kK1pFxA0RhBwxPVJfpY8jWOwygRW/ts8zYtdZV4g5kzCDnfMQ== X-Received: by 2002:a92:d911:0:b0:30d:859b:156b with SMTP id s17-20020a92d911000000b0030d859b156bmr3451428iln.25.1673977717344; Tue, 17 Jan 2023 09:48:37 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:36 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 02/70] dm: core: Support sorting devices with dm tree Date: Tue, 17 Jan 2023 10:47:12 -0700 Message-Id: <20230117174820.1281477-3-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a -s flag to sort the top-level devices in order of uclass ID. Signed-off-by: Simon Glass --- (no changes since v1) cmd/dm.c | 10 +++++-- doc/usage/cmd/dm.rst | 5 +++- drivers/core/dump.c | 65 ++++++++++++++++++++++++++++++++++++---- include/dm/util.h | 8 +++-- test/py/tests/test_dm.py | 38 +++++++++++++++++++++++ 5 files changed, 114 insertions(+), 12 deletions(-) diff --git a/cmd/dm.c b/cmd/dm.c index 218be85795d..979cd36061e 100644 --- a/cmd/dm.c +++ b/cmd/dm.c @@ -59,7 +59,11 @@ static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - dm_dump_tree(); + bool sort; + + sort = argc > 1 && !strcmp(argv[1], "-s"); + + dm_dump_tree(sort); return 0; } @@ -87,7 +91,7 @@ static char dm_help_text[] = "dm drivers Dump list of drivers with uclass and instances\n" DM_MEM_HELP "dm static Dump list of drivers with static platform data\n" - "dm tree Dump tree of driver model devices ('*' = activated)\n" + "dm tree [-s] Dump tree of driver model devices (-s=sort)\n" "dm uclass Dump list of instances for each uclass" ; #endif @@ -98,5 +102,5 @@ U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text, U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers), DM_MEM U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info), - U_BOOT_SUBCMD_MKENT(tree, 1, 1, do_dm_dump_tree), + U_BOOT_SUBCMD_MKENT(tree, 2, 1, do_dm_dump_tree), U_BOOT_SUBCMD_MKENT(uclass, 1, 1, do_dm_dump_uclass)); diff --git a/doc/usage/cmd/dm.rst b/doc/usage/cmd/dm.rst index 7bc1962a754..236cd02bd62 100644 --- a/doc/usage/cmd/dm.rst +++ b/doc/usage/cmd/dm.rst @@ -12,7 +12,7 @@ Synopis dm devres dm drivers dm static - dm tree + dm tree [-s] dm uclass Description @@ -123,6 +123,9 @@ Name Shows the device name as well as the tree structure, since child devices are shown attached to their parent. +If -s is given, the top-level devices (those which are children of the root +device) are shown sorted in order of uclass ID, so it is easier to find a +particular device type. dm uclass ~~~~~~~~~ diff --git a/drivers/core/dump.c b/drivers/core/dump.c index 1c1f7e4d308..0c7d2ec4d0c 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -5,12 +5,34 @@ #include #include +#include #include +#include #include #include #include -static void show_devices(struct udevice *dev, int depth, int last_flag) +/** + * struct sort_info - information used for sorting + * + * @dev: List of devices + * @alloced: Maximum number of devices in @dev + */ +struct sort_info { + struct udevice **dev; + int size; +}; + +static int h_cmp_uclass_id(const void *d1, const void *d2) +{ + const struct udevice *const *dev1 = d1; + const struct udevice *const *dev2 = d2; + + return device_get_uclass_id(*dev1) - device_get_uclass_id(*dev2); +} + +static void show_devices(struct udevice *dev, int depth, int last_flag, + struct udevice **devs) { int i, is_last; struct udevice *child; @@ -39,21 +61,52 @@ static void show_devices(struct udevice *dev, int depth, int last_flag) printf("%s\n", dev->name); - device_foreach_child(child, dev) { - is_last = list_is_last(&child->sibling_node, &dev->child_head); - show_devices(child, depth + 1, (last_flag << 1) | is_last); + if (devs) { + int count; + int i; + + count = 0; + device_foreach_child(child, dev) + devs[count++] = child; + qsort(devs, count, sizeof(struct udevice *), h_cmp_uclass_id); + + for (i = 0; i < count; i++) { + show_devices(devs[i], depth + 1, + (last_flag << 1) | (i == count - 1), + devs + count); + } + } else { + device_foreach_child(child, dev) { + is_last = list_is_last(&child->sibling_node, + &dev->child_head); + show_devices(child, depth + 1, + (last_flag << 1) | is_last, NULL); + } } } -void dm_dump_tree(void) +void dm_dump_tree(bool sort) { struct udevice *root; root = dm_root(); if (root) { + int dev_count, uclasses; + struct udevice **devs = NULL; + + dm_get_stats(&dev_count, &uclasses); + printf(" Class Index Probed Driver Name\n"); printf("-----------------------------------------------------------\n"); - show_devices(root, -1, 0); + if (sort) { + devs = calloc(dev_count, sizeof(struct udevice *)); + if (!devs) { + printf("(out of memory)\n"); + return; + } + } + show_devices(root, -1, 0, devs); + free(devs); } } diff --git a/include/dm/util.h b/include/dm/util.h index e10c6060ce0..4bb49e9e8c0 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -26,8 +26,12 @@ struct list_head; */ int list_count_items(struct list_head *head); -/* Dump out a tree of all devices */ -void dm_dump_tree(void); +/** + * Dump out a tree of all devices + * + * @sort: Sort by uclass name + */ +void dm_dump_tree(bool sort); /* Dump out a list of uclasses and their devices */ void dm_dump_uclass(void); diff --git a/test/py/tests/test_dm.py b/test/py/tests/test_dm.py index ea93061fdfa..68d4ea12235 100644 --- a/test/py/tests/test_dm.py +++ b/test/py/tests/test_dm.py @@ -16,6 +16,44 @@ def test_dm_compat(u_boot_console): for driver in drivers: assert driver in response + # check sorting - output looks something like this: + # testacpi 0 [ ] testacpi_drv |-- acpi-test + # testacpi 1 [ ] testacpi_drv | `-- child + # pci_emul_p 1 [ ] pci_emul_parent_drv |-- pci-emul2 + # pci_emul 5 [ ] sandbox_swap_case_em | `-- emul2@1f,0 + + # The number of '| ' and '--' matches indicate the indent level. We start + # checking sorting only after UCLASS_AXI_EMUL after which the names should + # be sorted. + + response = u_boot_console.run_command('dm tree -s') + lines = response.split('\n')[2:] + stack = [] # holds where we were up to at the previous indent level + prev = '' # uclass name of previous line + start = False + for line in lines: + indent = line.count('| ') + ('--' in line) + cur = line.split()[0] + if not start: + if cur != 'axi_emul': + continue + start = True + + # Handle going up or down an indent level + if indent > len(stack): + stack.append(prev) + prev = '' + elif indent < len(stack): + prev = stack.pop() + + # Check that the current uclass name is not alphabetically before the + # previous one + if 'emul' not in cur and cur < prev: + print('indent', cur >= prev, indent, prev, cur, stack) + assert cur >= prev + prev = cur + + @pytest.mark.buildconfigspec('cmd_dm') def test_dm_drivers(u_boot_console): """Test that each driver in `dm compat` is also listed in `dm drivers`.""" From patchwork Tue Jan 17 17:47:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727613 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=oZs2tZRo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGdV2p23z23fp for ; Wed, 18 Jan 2023 04:50:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34BBA85611; Tue, 17 Jan 2023 18:48:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="oZs2tZRo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C7E62855C7; Tue, 17 Jan 2023 18:48:45 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 63B7C855BA for ; Tue, 17 Jan 2023 18:48:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id y69so722293iof.3 for ; Tue, 17 Jan 2023 09:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NfW6NGfMs5XjPsj9BSrcC9kzvZYLbDNqCI79Kvt2npw=; b=oZs2tZRovzTQXlFEJ/qPML37lpsRtDUHwXnBdd8ToNXbkjvQI/zkEssr8ASgPlR/Wl ZBH42MQDZAkrRAXdwY+eM4GU/LcCMoI1xKLn+jCuULT/bp6ensmTz9i777yyNQjw4pNm fH1CZHufLj72ZpTT5UOI2nN+Vk4Gd4ODu8EDk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NfW6NGfMs5XjPsj9BSrcC9kzvZYLbDNqCI79Kvt2npw=; b=MDmZ+sOiI3qzgR8UwAxyuyUj3C+edNImsSpEjBofpWVG6zvr6NLZ16IFnKgvTgpAXx AVMUN8QurBXK5kITUC5IGhhj0o9iTdgXRQ7KkKKkWITinJs6PDYNPMCJpAVESEgbplzT VdM7Nzzi4qBkwd1cpI9lQEjj/B1ybJAUknKCml2all8VKDy11lGbUvuqmwAikNwtXSno HBT2xagXnBgCbQ7IBYmI2u9ijeZaoad458fQbn1vLvur5W+2gKojyQP0dZNj3z9mVqXr HuteTTRQyw2S10bxOIUoziB1vgf9XSbnC0BD2QPhcicPBVMDmNbIr1abcobDHKRd0jar EU6A== X-Gm-Message-State: AFqh2komHbpaHBiIvPlBsQE6SYtOBIk3bULhHrXmUsAujmN/3t1/yvnP LsJgCYnosWKEE4Be34ExgY3nGRVE4/fH9Oo8 X-Google-Smtp-Source: AMrXdXvuBA0Y0C/EkVxniCftvz0e9pKg4O4eqaACuYs3MtTSC+L6H/QSLRQsZtjB0e+AQr9GVuPTMQ== X-Received: by 2002:a05:6602:5dd:b0:704:ce4a:5bd6 with SMTP id w29-20020a05660205dd00b00704ce4a5bd6mr2465099iox.14.1673977718725; Tue, 17 Jan 2023 09:48:38 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:38 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 03/70] dm: test: Correct assertion in dm_test_part() Date: Tue, 17 Jan 2023 10:47:13 -0700 Message-Id: <20230117174820.1281477-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This obscures the line number. Update the test to avoid make sure that the line which failed is displayed, so it is possible to diagnose the failure. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/part.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/dm/part.c b/test/dm/part.c index 78dd8472c2e..5e4efa587c3 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -11,8 +11,8 @@ #include #include -static inline int do_test(struct unit_test_state *uts, int expected, - const char *part_str, bool whole) +static int do_test(struct unit_test_state *uts, int expected, + const char *part_str, bool whole) { struct blk_desc *mmc_dev_desc; struct disk_partition part_info; @@ -54,11 +54,8 @@ static int dm_test_part(struct unit_test_state *uts) oldbootdevice = env_get("bootdevice"); -#define test(expected, part_str, whole) do { \ - ret = do_test(uts, expected, part_str, whole); \ - if (ret) \ - goto out; \ -} while (0) +#define test(expected, part_str, whole) \ + ut_assertok(do_test(uts, expected, part_str, whole)) env_set("bootdevice", NULL); test(-ENODEV, NULL, true); @@ -92,7 +89,6 @@ static int dm_test_part(struct unit_test_state *uts) test(2, "1#test2", false); ret = 0; -out: env_set("bootdevice", oldbootdevice); return ret; } From patchwork Tue Jan 17 17:47:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727614 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=loJfNGg5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGdk2gFZz23fp for ; Wed, 18 Jan 2023 04:50:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6DDA3855BA; Tue, 17 Jan 2023 18:48:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="loJfNGg5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 93B5E85600; Tue, 17 Jan 2023 18:48:47 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 9ABC0855E6 for ; Tue, 17 Jan 2023 18:48:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id m15so15769167ilq.2 for ; Tue, 17 Jan 2023 09:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0y5yIzeGQPSksYNzS7KDWiGRsD8Pk+qE8GHr5poNfEE=; b=loJfNGg5EXAcwRDeyk8COrwzEPjBGmtrXPe35xA1Cc4ZZ8AL+EFgDdgC6eiS0RFwI1 Q6iJd/D0QwimuqA4JEtP4e/VV3AoI8Fc/2Aa03xQqRVSDAyWvqbSm1VjTiTzEcgWwPiZ d+fu0450vAT9b3WpZFeMgiDYB1Vqdv2aOGkiY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0y5yIzeGQPSksYNzS7KDWiGRsD8Pk+qE8GHr5poNfEE=; b=U43VVOY7R+GkITCwnbgyX3xeug6hIs079kKSlUrtfxOecoUfF1OrvGYZE3FhdPZbo/ fCzgYjPBjLK9UTFLAN4sL6kfvTfvk6H1WTXI/GR1kyc6DgvZCDoKo12+f8Z9sg4bvfZu xm5g5IqWh587mj6ItY4WRzdofaMBhp0WmQe8/BVhTcE3vq5sw9Ovc8DY6x/1+TUVtDVj KnqG/vX8yrzEUJ1mSQCOrl5veDixU20kCIH+TP1oj3JR5ynfL5W3XSLqHcCPpLei6FwB iXEPOxsUSuw2GNZLfFxLfLz9HAFvnqHoziS+uL4EtGzMOSlzsZqFNX+yCLM/GzqPrhfA Bdhw== X-Gm-Message-State: AFqh2ko/Lket6JVegapMaNwSc4naz2pPQCGxh8NWQPjKRzjTSof9B9/D D3hkqm21jbOAQk2JBhx/q7eEriw7En9T6ptE X-Google-Smtp-Source: AMrXdXsP8q6juTAW/8SLFjMLw23ng3DbWRI3+2L41krnTWq2WIo+cX95D+yMgFzSb8hzCQTslyoAsA== X-Received: by 2002:a92:db11:0:b0:30d:a7d5:d8fe with SMTP id b17-20020a92db11000000b0030da7d5d8femr3555469iln.2.1673977719803; Tue, 17 Jan 2023 09:48:39 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:39 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 04/70] lib: Add a function to split a string into substrings Date: Tue, 17 Jan 2023 10:47:14 -0700 Message-Id: <20230117174820.1281477-5-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Some environment variables provide a space-separated list of strings. It is easier to process these when they are broken out into an array of strings. Add a utility function to handle this. Signed-off-by: Simon Glass --- (no changes since v1) include/vsprintf.h | 24 ++++++++++++++ lib/strto.c | 41 +++++++++++++++++++++++ test/str_ut.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) diff --git a/include/vsprintf.h b/include/vsprintf.h index e006af200fd..ed8a060ee17 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -328,6 +328,30 @@ char *strmhz(char *buf, unsigned long hz); */ void str_to_upper(const char *in, char *out, size_t len); +/** + * str_to_list() - Convert a string to a list of string pointers + * + * Splits a string containing space-delimited substrings into a number of + * separate strings, e.g. "this is" becomes {"this", "is", NULL}. If @instr is + * empty then this returns just {NULL}. The string should have only a single + * space between items, with no leading or trailing spaces. + * + * @instr: String to process (this is alloced by this function) + * Returns: List of string pointers, terminated by NULL. Each entry points to + * a string. If @instr is empty, the list consists just of a single NULL entry. + * Note that the first entry points to the alloced string. + * Returns NULL if out of memory + */ +const char **str_to_list(const char *instr); + +/** + * str_free_list() - Free a string list + * + * @ptr: String list to free, as created by str_to_list(). This can also be + * NULL, in which case the function does nothing + */ +void str_free_list(const char **ptr); + /** * vsscanf - Unformat a buffer into a list of arguments * @inp: input buffer diff --git a/lib/strto.c b/lib/strto.c index 6462d4fddf1..154921165cb 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -11,6 +11,7 @@ #include #include +#include #include /* from lib/kstrtox.c */ @@ -222,3 +223,43 @@ void str_to_upper(const char *in, char *out, size_t len) if (len) *out = '\0'; } + +const char **str_to_list(const char *instr) +{ + const char **ptr; + char *str, *p; + int count, i; + + /* don't allocate if the string is empty */ + str = *instr ? strdup(instr) : (char *)instr; + if (!str) + return NULL; + + /* count the number of space-separated strings */ + for (count = *str != '\0', p = str; *p; p++) { + if (*p == ' ') { + count++; + *p = '\0'; + } + } + + /* allocate the pointer array, allowing for a NULL terminator */ + ptr = calloc(count + 1, sizeof(char *)); + if (!ptr) { + if (*str) + free(str); + return NULL; + } + + for (i = 0, p = str; i < count; p += strlen(p) + 1, i++) + ptr[i] = p; + + return ptr; +} + +void str_free_list(const char **ptr) +{ + if (ptr) + free((char *)ptr[0]); + free(ptr); +} diff --git a/test/str_ut.c b/test/str_ut.c index 5a844347c2b..fa9328ede50 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -274,6 +274,88 @@ static int str_trailing(struct unit_test_state *uts) } STR_TEST(str_trailing, 0); +static int test_str_to_list(struct unit_test_state *uts) +{ + const char **ptr; + ulong start; + + /* check out of memory */ + start = ut_check_delta(0); + malloc_enable_testing(0); + ut_assertnull(str_to_list("")); + ut_assertok(ut_check_delta(start)); + + ut_assertnull(str_to_list("this is a test")); + ut_assertok(ut_check_delta(start)); + + malloc_enable_testing(1); + ut_assertnull(str_to_list("this is a test")); + ut_assertok(ut_check_delta(start)); + + /* for an empty string, only one nalloc is needed */ + malloc_enable_testing(1); + ptr = str_to_list(""); + ut_assertnonnull(ptr); + ut_assertnull(ptr[0]); + str_free_list(ptr); + ut_assertok(ut_check_delta(start)); + + malloc_disable_testing(); + + /* test the same again, without any nalloc restrictions */ + ptr = str_to_list(""); + ut_assertnonnull(ptr); + ut_assertnull(ptr[0]); + str_free_list(ptr); + ut_assertok(ut_check_delta(start)); + + /* test a single string */ + start = ut_check_delta(0); + ptr = str_to_list("hi"); + ut_assertnonnull(ptr); + ut_assertnonnull(ptr[0]); + ut_asserteq_str("hi", ptr[0]); + ut_assertnull(ptr[1]); + str_free_list(ptr); + ut_assertok(ut_check_delta(start)); + + /* test two strings */ + ptr = str_to_list("hi there"); + ut_assertnonnull(ptr); + ut_assertnonnull(ptr[0]); + ut_asserteq_str("hi", ptr[0]); + ut_assertnonnull(ptr[1]); + ut_asserteq_str("there", ptr[1]); + ut_assertnull(ptr[2]); + str_free_list(ptr); + ut_assertok(ut_check_delta(start)); + + /* test leading, trailing and multiple spaces */ + ptr = str_to_list(" more space "); + ut_assertnonnull(ptr); + ut_assertnonnull(ptr[0]); + ut_asserteq_str("", ptr[0]); + ut_assertnonnull(ptr[1]); + ut_asserteq_str("more", ptr[1]); + ut_assertnonnull(ptr[2]); + ut_asserteq_str("", ptr[2]); + ut_assertnonnull(ptr[3]); + ut_asserteq_str("space", ptr[3]); + ut_assertnonnull(ptr[4]); + ut_asserteq_str("", ptr[4]); + ut_assertnonnull(ptr[5]); + ut_asserteq_str("", ptr[5]); + ut_assertnull(ptr[6]); + str_free_list(ptr); + ut_assertok(ut_check_delta(start)); + + /* test freeing a NULL pointer */ + str_free_list(NULL); + + return 0; +} +STR_TEST(test_str_to_list, 0); + int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(str_test); From patchwork Tue Jan 17 17:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727617 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=c5BL7iRz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGfR2kWJz23fp for ; Wed, 18 Jan 2023 04:51:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4449B85603; Tue, 17 Jan 2023 18:49:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="c5BL7iRz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0401985600; Tue, 17 Jan 2023 18:48:49 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 99F43855E5 for ; Tue, 17 Jan 2023 18:48:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id h26so15737585ila.11 for ; Tue, 17 Jan 2023 09:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xV9515DdDJZ/GJ+prKkja81xHQT/MYP7/RksVbS5xHc=; b=c5BL7iRzVcAH2T7fevl+995ZFAYiBpx31TMnPQB77yV7+vo631t+f8X/0ihgQ30EAJ BJ6Jq8Y8ggD/xfbrpQtP9Z690yl7TTC+f5/iBvoxbJWdz3tZ5xX/cFaw6xN7eXECbmNi U13H+mqclYoDqc2qPnBbowLJiwKA8DHKjDPNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xV9515DdDJZ/GJ+prKkja81xHQT/MYP7/RksVbS5xHc=; b=naXJStMT+AjVZ+KNxHehp8gN04VfilqqmP+3MOtjsf5Trp85PdH0jnuCRCZ/vflW1f Gyk1DbR/evUHdXRbYZaAbv3EDaHvkU/aLvBgCyMdLBwJZeJDaWIQcatdhz16aRnU/WzW y7+myWM72/QNGLHFsYWGMA/A21pgbc6FjPjvdBZrvxntvTAddkyrvhLOgjey1Zy+sBwZ QL7DOOgO8lXrWTs3zNTfiUtjkU/6G8dWNHYSooGZZumi1vIHc6vBvZGSHdqZEIZcIHow LOJbsOFdg2qysTd+RQEAzJRiHY9qKqLD+L5a9gntAdSe185EKI85rRr2/LSzDlhFNBuV MerQ== X-Gm-Message-State: AFqh2kpajoNmQ3uVPIxzEjEQa0lLRQhlNVyMeFZGKcqL9fIyXRRePeVO wIOJ2skCMYNOCdC3lU9yUm9YYk9ohvrSjrdM X-Google-Smtp-Source: AMrXdXshOpTN8OzGJ5ghCz5JcMMUR/yFYcbkX0eMgO4318aIXUvLtVVb1cnkaN12rXvutZM5b+Pr0g== X-Received: by 2002:a05:6e02:de6:b0:30e:f36a:f24e with SMTP id m6-20020a056e020de600b0030ef36af24emr2577429ilj.11.1673977720910; Tue, 17 Jan 2023 09:48:40 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:40 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 05/70] bootstd: Remove special-case code for boot_targets Date: Tue, 17 Jan 2023 10:47:15 -0700 Message-Id: <20230117174820.1281477-6-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Rather than implement this as its own case in build_order(), process the boot_targets environment variable in the bootstd_get_bootdev_order() function. This allows build_order() to be simplified. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 32 +++++--------------------------- boot/bootstd-uclass.c | 17 ++++++++++++++++- include/bootstd.h | 14 +++++++++++--- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index affe0d3e04e..696efb4b19e 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -504,34 +503,13 @@ static int build_order(struct udevice *bootstd, struct udevice **order, const char *overflow_target = NULL; const char *const *labels; struct udevice *dev; - const char *targets; int i, ret, count; + bool ok; - targets = env_get("boot_targets"); - labels = IS_ENABLED(CONFIG_BOOTSTD_FULL) ? - bootstd_get_bootdev_order(bootstd) : NULL; - if (targets) { - char str[BOOT_TARGETS_MAX_LEN]; - char *target; - - if (strlen(targets) >= BOOT_TARGETS_MAX_LEN) - return log_msg_ret("len", -E2BIG); - - /* make a copy of the string, since strok() will change it */ - strcpy(str, targets); - for (i = 0, target = strtok(str, " "); target; - target = strtok(NULL, " ")) { - ret = bootdev_find_by_label(target, &dev); - if (!ret) { - if (i == max_count) { - overflow_target = target; - break; - } - order[i++] = dev; - } - } - count = i; - } else if (labels) { + labels = bootstd_get_bootdev_order(bootstd, &ok); + if (!ok) + return log_msg_ret("ord", -ENOMEM); + if (labels) { int upto; upto = 0; diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 7887acdc11b..81555d341e3 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -72,9 +73,23 @@ static int bootstd_remove(struct udevice *dev) return 0; } -const char *const *const bootstd_get_bootdev_order(struct udevice *dev) +const char *const *const bootstd_get_bootdev_order(struct udevice *dev, + bool *okp) { struct bootstd_priv *std = dev_get_priv(dev); + const char *targets = env_get("boot_targets"); + + *okp = true; + log_debug("- targets %s %p\n", targets, std->bootdev_order); + if (targets && *targets) { + str_free_list(std->env_order); + std->env_order = str_to_list(targets); + if (!std->env_order) { + *okp = false; + return NULL; + } + return std->env_order; + } return std->bootdev_order; } diff --git a/include/bootstd.h b/include/bootstd.h index 4fa0d531001..bd305094fdc 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -22,7 +22,10 @@ struct udevice; * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames, * e.g. "/", "/boot/"; NULL if none * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item - * being a bootdev label, e.g. "mmc2", "mmc1"; + * being a bootdev label, e.g. "mmc2", "mmc1" (NULL terminated) + * @env_order: Order as specified by the boot_targets env var (or NULL if none), + * with each item being a bootdev label, e.g. "mmc2", "mmc1" (NULL + * terminated) * @cur_bootdev: Currently selected bootdev (for commands) * @cur_bootflow: Currently selected bootflow (for commands) * @glob_head: Head for the global list of all bootflows across all bootdevs @@ -34,6 +37,7 @@ struct udevice; struct bootstd_priv { const char **prefixes; const char **bootdev_order; + const char **env_order; struct udevice *cur_bootdev; struct bootflow *cur_bootflow; struct list_head glob_head; @@ -51,9 +55,13 @@ struct bootstd_priv { * The list is alloced by the bootstd driver so should not be freed. That is the * reason for all the const stuff in the function signature * - * Return: list of string points, terminated by NULL; or NULL if no boot order + * @dev: bootstd device + * @okp: returns true if OK, false if out of memory + * Return: list of string pointers, terminated by NULL; or NULL if no boot + * order. Note that this returns NULL in the case of an empty list */ -const char *const *const bootstd_get_bootdev_order(struct udevice *dev); +const char *const *const bootstd_get_bootdev_order(struct udevice *dev, + bool *okp); /** * bootstd_get_prefixes() - Get the filename-prefixes list From patchwork Tue Jan 17 17:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727616 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fQWnIbcn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGfB362kz23fp for ; Wed, 18 Jan 2023 04:51:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D165855F9; Tue, 17 Jan 2023 18:49:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="fQWnIbcn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 653DF855EE; Tue, 17 Jan 2023 18:48:48 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 9EFA0855CE for ; Tue, 17 Jan 2023 18:48:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id h26so15737603ila.11 for ; Tue, 17 Jan 2023 09:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9DLS/e1he79/vL+7Ya5T36uAwbzPlA95q1kDQMF2Eo8=; b=fQWnIbcnb/RVp08V2K4LpbuHQsVIe15/UMKrnt8QrKNbcCeux/4xQMBqt8uouvEppF MJTVOUpr+uB/psi8jOpAJQSrjJ+p+UnHKQ46Q31nBr9XHUx3aHjRjIiy5EuRc3pKoTxj ryKJQ6bo9Lt22Sj6T3d4ES5K7aOm6J9wkaOKU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9DLS/e1he79/vL+7Ya5T36uAwbzPlA95q1kDQMF2Eo8=; b=GHFVymZTFcJY5PF/TGPp88YmRNvSUG/lpK6ZL18cAujUAozxtdpgMsd1bdipfTJekC NAVtMTGtMnye2lazqsjwZYab2tTeuZwwniGi24Ycm5rxNepBr22jQI9F03xQw7QgVmeL FM9cCzlw9SAG1BnnsDcRZmQVGAd9x0VWiGCnY71Y1652zOOpcuUPNeWj9bO+42kmyrvE kWjttI9axd2e6cc8b2KcAW98DVK8R8vKcrfqJdsEhpQ8OHhs8rKcTZYDoPhXckM/jDvq bqbVUdVh/azJkb97wTNmE13ZaDK5yzeGeJiGet6WBwdzO5W4i0VtxhVppTxc6QpRpDAH ETTg== X-Gm-Message-State: AFqh2krGQhKUVeZ/3fdbbbtfHJDFbnGbWN3DghtsfkAbGr3LDf4K+lYH 9HoC9o4foON6igHUdzvxT/N8zN55faWE1fDB X-Google-Smtp-Source: AMrXdXvi9BfigUXZ4MXeDmduziYDRlKAw1x67jEW2qXwRhM+aX2zOAdXI9HI1ZglACelaMzo4ymE0w== X-Received: by 2002:a92:d0ce:0:b0:30b:b982:7632 with SMTP id y14-20020a92d0ce000000b0030bb9827632mr3207267ila.23.1673977721922; Tue, 17 Jan 2023 09:48:41 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:41 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 06/70] bootstd: Simplify locating existing bootdevs Date: Tue, 17 Jan 2023 10:47:16 -0700 Message-Id: <20230117174820.1281477-7-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean There is no point in trying to match the alias order for bootdevs, since build_order() either sorts them by priority, uses the boot_targets environment variable or the bootdev-order property. Just use the iterator instead, to simplify the code. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 696efb4b19e..cffa01824c0 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -544,8 +544,8 @@ static int build_order(struct udevice *bootstd, struct udevice **order, int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) { struct udevice *bootstd, *dev = *devp, **order; - int upto, i; - int count; + struct uclass *uc; + int count, upto; int ret; ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd); @@ -568,15 +568,9 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) if (!order) return log_msg_ret("order", -ENOMEM); - /* - * Get a list of bootdevs, in seq order (i.e. using aliases). There may - * be gaps so try to count up high enough to find them all. - */ - for (i = 0, upto = 0; upto < count && i < 20 + count * 2; i++) { - ret = uclass_find_device_by_seq(UCLASS_BOOTDEV, i, &dev); - if (!ret) - order[upto++] = dev; - } + /* Get the list of bootdevs */ + uclass_id_foreach_dev(UCLASS_BOOTDEV, dev, uc) + order[upto++] = dev; log_debug("Found %d bootdevs\n", count); if (upto != count) log_debug("Expected %d bootdevs, found %d using aliases\n", From patchwork Tue Jan 17 17:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727615 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NHmrt0Eq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGdy0Rznz23fp for ; Wed, 18 Jan 2023 04:51:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4401185615; Tue, 17 Jan 2023 18:48:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="NHmrt0Eq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15B8D85600; Tue, 17 Jan 2023 18:48:48 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 AB0CA855DA for ; Tue, 17 Jan 2023 18:48:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id a3so9810916ilp.6 for ; Tue, 17 Jan 2023 09:48:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jDqiTu3iRC1Yz4phmDUK/WswWRd7own6PMu7ecM8tcY=; b=NHmrt0EqJLUt8lwUiGt7iISBk3QiI8C1T5Q+JqLB224BpczqahArssOSBT/2QEk7/U XNzeqhtA/JMyqmcWRwCrAQpD+mZ03RmilYjQ4baro812cjZsJOqfKfL+f5qCdPTzcif/ BZK1IlUoHYSb7GwGQ5ucTgOvmIXM/9HzQmWus= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jDqiTu3iRC1Yz4phmDUK/WswWRd7own6PMu7ecM8tcY=; b=Z9sEF4b5aMmuNa4at+sYYuaieSJ5QI91/k4w3ote/b21FXWrSOAGa+qjdtkQlGzxa6 E3Fyg9o3A/gzmJJZVikxdzNuhSZbU8tWz/wAYC1F0dgkNFJ0FEEt/trwTjdpahXfPV4l aLl8mmBsmVfOlwbcUT/a4/bwa/3L7k0e+DNhKNLBq0wt7j63nFBO7CH0FrzOOyu2O6oi iaqJ5nyDCKUII78+VH8fk/8nFYkBlykmGuGIb4W/klwvPdWM3kPPkPG97YQmMV2ORzWn baE/wjoZd0wD9YyuJRSRD+v2j0U1u1HkHWPvmSYYpH8mQxoAyBvwcvlGfVeke84QNN25 5Rkw== X-Gm-Message-State: AFqh2kqX33z3UcH/AhAEU7Kr7ekT4hFml0eho/GMuzhnvGLex7tnMuLR 9FWnbfo6LcDl5me/nJtlvK6V3sPIXTSOy5Lo X-Google-Smtp-Source: AMrXdXv8+Dm5oR1UXaKTyr2hqR/EgHU54tGNLimpTWCTPllUehdEAAvetgWCYQhT4fTGNf7hJkKnwg== X-Received: by 2002:a92:4b08:0:b0:303:e77:188b with SMTP id m8-20020a924b08000000b003030e77188bmr3310134ilg.32.1673977722948; Tue, 17 Jan 2023 09:48:42 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:42 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 07/70] test: Fix the help for the ut command Date: Tue, 17 Jan 2023 10:47:17 -0700 Message-Id: <20230117174820.1281477-8-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean The font help has an incorrect newline. Fix it. Signed-off-by: Simon Glass Fixes: cdd964e3801 ("test: Tidy up help for ut command") --- (no changes since v1) test/cmd_ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 067bd0828a1..1713d0d1c85 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -189,7 +189,7 @@ static char ut_help_text[] = "\nfdt - fdt command" #endif #ifdef CONFIG_CONSOLE_TRUETYPE - "\nut font - font command\n" + "\nut font - font command" #endif #ifdef CONFIG_CMD_LOADM "\nloadm - loadm command parameters and loading memory blob" From patchwork Tue Jan 17 17:47:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727618 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=K7ZI4KXF; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGfg2pZvz23fp for ; Wed, 18 Jan 2023 04:51:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89DDF85601; Tue, 17 Jan 2023 18:49:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="K7ZI4KXF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1229855D3; Tue, 17 Jan 2023 18:48:50 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 83A4F855D3 for ; Tue, 17 Jan 2023 18:48:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id d10so15737239ilc.12 for ; Tue, 17 Jan 2023 09:48:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OaNbZg6cZFtT7/Y5BK2RphdONaqf7A/P5Q56/0qC4fg=; b=K7ZI4KXFrOzQ9V9CLH2D6czNylLfsUi3QNyLhueyuscdkOjqCv1fXeXt17CF/MKQGX IR/wMqn4dJL4hYw1AM1OIQJd2AfwWTVMg69or4ofsDELb+FW6P5f93ds+3jo2gJgmEdP ICY07foUYT0M738LeRTl+kekv5FvrV/puhLe0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OaNbZg6cZFtT7/Y5BK2RphdONaqf7A/P5Q56/0qC4fg=; b=uKarYvHvyf5IP08s4uwcPgwJQQTx7Wrd7oUBZy/EyiZ0O8NNP3FsnqS6XCQx09MnHI M0kTG3J20kqt7EkSdECARwg3sg4h9nPcUDsabQ6p214nXFZ8OjwS2dkQx11+uyMG/hud mspljpAe4M8dbLdmCNwfsJb9Ul6wQV/PmQe6SxClWsuf/36mAI2lf2i4AFGHkpwDryvi LwbBaY1Zl6uRJi+m9vot4xcWTLUZoE6V33dgidQleEi3rcToJfEchgfItwBjVaqF90/V koDPT4mw+DSWVAC7Pi9HE4o81H28y0BWuDBPQtxnrfCCBDtG+92DQylf7KP13kxRPn3M Xanw== X-Gm-Message-State: AFqh2krXximdxqjzg5TIa2KrfHeSPvKwmmsSIWx8jgkl5w8QT71tLSNc tZqFTPZa1P1ipJIqwdPrP4uADSCf4k2otRrr X-Google-Smtp-Source: AMrXdXsD8NvkHoEGyr3at+l/xk/U9de08R+4cNZbcqGfFtRpEB/NMnxSpARnCTkkCPib2LsPCR82IA== X-Received: by 2002:a92:d9d1:0:b0:302:364f:68f4 with SMTP id n17-20020a92d9d1000000b00302364f68f4mr3156546ilq.17.1673977723966; Tue, 17 Jan 2023 09:48:43 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:43 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 08/70] test: Drop duplicate restore of DM state Date: Tue, 17 Jan 2023 10:47:18 -0700 Message-Id: <20230117174820.1281477-9-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This code is present twice. Fix it so that it is only executed once. Signed-off-by: Simon Glass --- (no changes since v1) test/test-main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/test-main.c b/test/test-main.c index 5931e94a915..9ab090b7b33 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -635,9 +635,5 @@ int ut_run_list(const char *category, const char *prefix, else printf("Failures: %d\n", uts.fail_count); - /* Best efforts only...ignore errors */ - if (has_dm_tests) - dm_test_restore(uts.of_root); - return ret; } From patchwork Tue Jan 17 17:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727619 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Bl96s8NB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGfw4YJVz23fp for ; Wed, 18 Jan 2023 04:51:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 726B8855E4; Tue, 17 Jan 2023 18:50:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Bl96s8NB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74B3080F98; Tue, 17 Jan 2023 18:48:52 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 BCEC9855F9 for ; Tue, 17 Jan 2023 18:48:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id y69so722428iof.3 for ; Tue, 17 Jan 2023 09:48:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4NQl1ThJFYsymS0Gbf2P6z2aRKVo6yeFAQjUJjmfJ5w=; b=Bl96s8NBy2VQU2fujUZhWVIHQk5vfFLvBteIoBlwJJGCmufKN5XjF/bMtqU2ikkgDa 3ceZ8CD0TbSyZYlbYfrwDPYGU0geDnsO/OsOrr3St9Nx4js3ijYHhJKjnhov2CoOmIjU Yjc+/q1q3HPsO9fNxDYfqop53zbO/NcpYcPK4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4NQl1ThJFYsymS0Gbf2P6z2aRKVo6yeFAQjUJjmfJ5w=; b=TlOoLYWmYCDOB7Pz4sjb2cJxRAMjN7pybPDWYjXbSgYjDF+F/tqQt0PCvxYc5JOpl+ TgUovc4/uUzcP5lnRuScEgPKB2ijzFvvqnq8IR0ajGFeNfbg4gWIiKY34+o4YMMGwcKS vbkGDCCgY0hCS7hwziafUWFxRZ6ydxzxPkQjhM3ghjDAvxTNR8DcVu+7UMrEhrXFSGnz Sa0JmfYXHS/OUQ7qzZjxLpXasbkO/N7Silf4c//PEv7OzupwAA4Rt2HoPOk2CR1M32zY MF/kp90YXFdKDmI9UoAUSWgguPzt8w5s8JSQ4v29XRhmQdqhC+oyHT+Veg9dMRGCMAhJ tMsQ== X-Gm-Message-State: AFqh2kpyNZmaHVTqI+Q8R+N5ESlWKh9i08KhioScn4XufIglC+gO1k44 bqJlm0h+tQ5skU7wPnlJAm+OFVR0c+ogCKYn X-Google-Smtp-Source: AMrXdXt2B9gKbdtnb1n1KBGhKndyMZmzDkPSlTgk+L6Zjpu+pBSE1vUFFU1IuDPMnusJLYj3IrQ+Uw== X-Received: by 2002:a05:6602:10:b0:704:9b43:35 with SMTP id b16-20020a056602001000b007049b430035mr2928389ioa.5.1673977724980; Tue, 17 Jan 2023 09:48:44 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:44 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass , Jaehoon Chung , Peng Fan Subject: [PATCH v3 09/70] sandbox: mmc: Start off with a zeroed file Date: Tue, 17 Jan 2023 10:47:19 -0700 Message-Id: <20230117174820.1281477-10-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean When running multiple tests the mmc emulator calls malloc() to obtain the memory for its disk image. Since the memory is not cleared, it is possible that it happens to contain a partition table. The dm_test_part() test (for one) relies on mmc0 being empty on startup. Zero the memory to ensure that it is. Signed-off-by: Simon Glass --- (no changes since v1) drivers/mmc/sandbox_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c index ba79a5565c3..0ba7940a4db 100644 --- a/drivers/mmc/sandbox_mmc.c +++ b/drivers/mmc/sandbox_mmc.c @@ -183,7 +183,7 @@ static int sandbox_mmc_probe(struct udevice *dev) priv->csize = 0; priv->size = (priv->csize + 1) * SIZE_MULTIPLE; /* 1 MiB */ - priv->buf = malloc(priv->size); + priv->buf = calloc(1, priv->size); if (!priv->buf) { log_err("%s: Not enough memory (%x bytes)\n", dev->name, priv->size); From patchwork Tue Jan 17 17:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727620 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JeBjcLdJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGg85YbWz23fp for ; Wed, 18 Jan 2023 04:52:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D56185666; Tue, 17 Jan 2023 18:50:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="JeBjcLdJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B112D855FC; Tue, 17 Jan 2023 18:48:52 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 9AF2F855E6 for ; Tue, 17 Jan 2023 18:48:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id u8so15782797ilg.0 for ; Tue, 17 Jan 2023 09:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nlyf9FpwFduB9tdRZ8dcOWIeI5LNXBSTRS2T36ZCXXk=; b=JeBjcLdJvA+OtQQsamsY4Ro/S3guA1y8BwsnXC/+SrPtMTqC/7VhDQZTuayd4EYduC lXdKThbbClwSxDeZLOi9l2DatgfjOmy8ajgBvi7zsLUBc0/9NcRVB34cRsIaqid1429+ RuIT7W4frrs+vFI6fe6R45fdvHYmH9h8xxTYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nlyf9FpwFduB9tdRZ8dcOWIeI5LNXBSTRS2T36ZCXXk=; b=i6jXKmrODNpbesfedrSQznlbYmNz5GnRR/P7DI3L7nYFVN8gMeoDdCFxlW68Y2VMPn 8zCXk4PyKznKFpjeSyEdcAcUjqq9kLkhsit/VbEXDlxYzf/zc/zO1f8sYn78RmPYBl6M G0bTKwqoXD1Vc7Ai0sqAKtE/w9LdOAtMc17+YfVXAgeg+KD+9fYZaaymhyhjAcGIgxG1 2U+dgMyZnVJjA18JSpL9C5d+aSfs+nIP6aCFO/9He4GiDQ5fw1NTgyR+QbEKffZcMHod FlbBpXKoHhhXx8wslI5SLjP1UHK/V7/UBNS+0l0GI7114Lk+31iqX0VI6bOWOqsUsdgu Rmvw== X-Gm-Message-State: AFqh2kpkNVRGH2plebv2jtG9yxXpLHW1FdO0+PIPFtdnymnGs+d+nLQ9 I+XtBVbRmMMRv568mNeE2mlqBG/6bXqjcZS1 X-Google-Smtp-Source: AMrXdXtL/F+Zoe+iKXC672pPNiXogKINNuC7Il6DLmk/XttxQTIV/C+taWdYx/O6CjivnzDHEISKjw== X-Received: by 2002:a92:c54f:0:b0:30d:976d:bbe7 with SMTP id a15-20020a92c54f000000b0030d976dbbe7mr3408495ilj.4.1673977726058; Tue, 17 Jan 2023 09:48:46 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:45 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 10/70] vbe: Avoid a build failure when bloblist is not enabled Date: Tue, 17 Jan 2023 10:47:20 -0700 Message-Id: <20230117174820.1281477-11-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This needs to be able to work (at least partially) without the bloblist active. Add a condition for this. Signed-off-by: Simon Glass --- (no changes since v1) cmd/vbe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/vbe.c b/cmd/vbe.c index befaf07c64d..600690394eb 100644 --- a/cmd/vbe.c +++ b/cmd/vbe.c @@ -79,10 +79,13 @@ static int do_vbe_info(struct cmd_tbl *cmdtp, int flag, int argc, static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct vbe_handoff *handoff; + struct vbe_handoff *handoff = NULL; int i; - handoff = bloblist_find(BLOBLISTT_VBE, sizeof(struct vbe_handoff)); + if (IS_ENABLED(CONFIG_BLOBLIST)) { + handoff = bloblist_find(BLOBLISTT_VBE, + sizeof(struct vbe_handoff)); + } if (!handoff) { printf("No VBE state\n"); return CMD_RET_FAILURE; From patchwork Tue Jan 17 17:47:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727621 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DSDHtO/t; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGgP1kqtz23gc for ; Wed, 18 Jan 2023 04:52:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 87D1E85676; Tue, 17 Jan 2023 18:50:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="DSDHtO/t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 653C4855FC; Tue, 17 Jan 2023 18:48:53 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 BBD0C855D5 for ; Tue, 17 Jan 2023 18:48:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id p189so3275219iod.0 for ; Tue, 17 Jan 2023 09:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/j51gAyjOpuz1/MoSzYMopxuOHmDv1WNeN/3/rRJBRE=; b=DSDHtO/tMakp8bAqdpETjfjmWMOXKYO2Ca362Kj1ZPMAyXOfIWWTSojDA9lGWTC0+i 1nNhmPuc3KW7n3vnOzzzXQzQt29yG9rDoZVPlIA30F5wITQXDwHdKrPCEoNrIUa9aYgW nv3hI6a7zwtArYS87Xx96oT+NYdFv1DXfh0GM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/j51gAyjOpuz1/MoSzYMopxuOHmDv1WNeN/3/rRJBRE=; b=edGYgHbjo/ZyyPMsXI45RPv4biww9rWLiN1kIhjfD7jMaxPOcPtHrafbhglPnCq7gU wv1p+arGNzBF2xZVQzCM7yfGI5JGDtSH6CXw0gcwws6GlzrHeT1MocfpgkY1zMHWBy74 MoARi4VkWVGWpzS4yHU1vd6txUeBjw2USwIoQpkV6wkgUclKyowDRzd2MShRyo1baoLP XJ5tA1Ms7o0mX2gZKLAE1eDfojrcRzt7VsOyG3nqlnT4jwzLf0uSd7ovpA3P7j96/3W/ 3ewY4sd/qWmVXsen43wvqs9m0iX5wYgpb7bYdB830ur340Zqe+H6w6hObGoaBOhk3t3/ pnhA== X-Gm-Message-State: AFqh2kpBwSDJ92k973M5bt02D8Rr9a94uDwAvDHe3szbZDvASdk0HZNR GVFJx8wsXYneQYPNbWEIPfxyfmoOd2E2CYl1 X-Google-Smtp-Source: AMrXdXvgBePjXEmTb2shD8Tan69eNKQ0xi8lzrZuWwHerbqORX0uCNxSArugktxoimjdWUImFCv2yA== X-Received: by 2002:a5d:8252:0:b0:704:884e:fda2 with SMTP id n18-20020a5d8252000000b00704884efda2mr2812735ioo.12.1673977727137; Tue, 17 Jan 2023 09:48:47 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:46 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 11/70] vbe: sandbox: Drop VBE node in chosen Date: Tue, 17 Jan 2023 10:47:21 -0700 Message-Id: <20230117174820.1281477-12-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This is not needed anymore since VBE creates the node when it sets up the OS requests. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/sandbox.dtsi | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index afe598a4f56..18bf1cb5b69 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -12,19 +12,6 @@ chosen { stdout-path = "/serial"; - - fwupd { - compatible = "simple-bus"; - firmware { - compatible = "fwupd,vbe-simple"; - cur-version = "1.2.3"; - bootloader-version = "2022.01"; - storage = "mmc1"; - area-start = <0x0>; - area-size = <0x1000000>; - skip-offset = <0x8000>; - }; - }; }; alarm_wdt: alarm-wdt { From patchwork Tue Jan 17 17:47:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727622 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TRoYtf+f; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGgf52cKz23fp for ; Wed, 18 Jan 2023 04:52:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6EB3E8567D; Tue, 17 Jan 2023 18:50:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="TRoYtf+f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F22D85603; Tue, 17 Jan 2023 18:48:54 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 E5314855D7 for ; Tue, 17 Jan 2023 18:48:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id n85so7592838iod.7 for ; Tue, 17 Jan 2023 09:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Sh4Qu2udh51AfPPcjiea68a4IlhHcMjK3pKRk4MBRk=; b=TRoYtf+fOWzQi5aq0j9XW3fT0xDibZ3iS0WtK/moAujyBie7JG+aLPW9qLBiOuRDsa ZzAwuGN8/5xa/f8HMDqiiM8rPMxHlJjoNzdWtXcL+G2dfnfmakzgcpZaBRta3hlEtRlL LcKE99/XzkZ2U9CSyZcTAYZ639aJ2Y8NpW/Nk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Sh4Qu2udh51AfPPcjiea68a4IlhHcMjK3pKRk4MBRk=; b=WXe5k8g6dVPzeEmWRVMIleWFmas5hKShwQgbqL/+bIQ0B6wFwKlPcjFsibPlqcWOPM BD/82m0yqPBF+VUv4QJCHlmLsanJfuDPhJ46E8l34gtqMzMO1aBEEP2CcJXmRCkqYKTk IDareAqvGd9YL7o5MP86Go5cqsrWK/a9NznGoBg4BlZmGJ6e3Q6JebRr3Mg0phMBffNx OzmZYvVAfMwnJ5sCvqLa2j43X/3CUMUqORl22I5gBAchFQIoUOXzE2eXrDNnOemfbhPw T8chgcl8hwpxreQ8ToKcAxRkkCpBVgLkv967cAXffFYWOtLzXQG1oaLUPWXVTRvrebiq Vf6Q== X-Gm-Message-State: AFqh2kqJGv57zgr5B2y3CrWLFtWA5y/Zc6FLoBZvjHoS4ue1wIYx7vE1 hZrPtdgTgeO24/8zDEnpSw9myMHEdnFrpFT0 X-Google-Smtp-Source: AMrXdXuDm1SoFYicOgDG7eUYomabvrwskQRH1/v2iC9cM9nDnU4yRbOEdVNxiU9G/jazUiVDhtUIjA== X-Received: by 2002:a05:6602:72b:b0:6e3:db2:6a7b with SMTP id g11-20020a056602072b00b006e30db26a7bmr2921022iox.6.1673977728230; Tue, 17 Jan 2023 09:48:48 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:47 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 12/70] dm: part: Update test to use mmc2 Date: Tue, 17 Jan 2023 10:47:22 -0700 Message-Id: <20230117174820.1281477-13-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this test sets up a partition table on mmc1. But this is used by the bootstd tests, so it is not possible to run those after this test has run, without restarting the Python test harness. This is inconvenient when running tests repeatedly with 'ut dm'. Move the test to use mmc2, which is not used by anything. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/part.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/dm/part.c b/test/dm/part.c index 5e4efa587c3..b60687114f1 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -43,7 +43,7 @@ static int dm_test_part(struct unit_test_state *uts) }, }; - ut_asserteq(1, blk_get_device_by_str("mmc", "1", &mmc_dev_desc)); + ut_asserteq(2, blk_get_device_by_str("mmc", "2", &mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) { gen_rand_uuid_str(parts[0].uuid, UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -63,7 +63,7 @@ static int dm_test_part(struct unit_test_state *uts) env_set("bootdevice", "0"); test(0, NULL, true); test(0, "", true); - env_set("bootdevice", "1"); + env_set("bootdevice", "2"); test(1, NULL, false); test(1, "", false); test(1, "-", false); @@ -74,8 +74,8 @@ static int dm_test_part(struct unit_test_state *uts) test(0, ".0", true); test(0, ".0:0", true); test(-EINVAL, "#test1", true); - test(1, "1", false); - test(1, "1", true); + test(1, "2", false); + test(1, "2", true); test(-ENOENT, "1:0", false); test(0, "1:0", true); test(1, "1:1", false); @@ -85,8 +85,8 @@ static int dm_test_part(struct unit_test_state *uts) test(1, "1.0:1", false); test(2, "1.0:2", false); test(-EINVAL, "1#bogus", false); - test(1, "1#test1", false); - test(2, "1#test2", false); + test(1, "2#test1", false); + test(2, "2#test2", false); ret = 0; env_set("bootdevice", oldbootdevice); From patchwork Tue Jan 17 17:47:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727623 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LdKVPaM7; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGgv15yCz23fp for ; Wed, 18 Jan 2023 04:52:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8866D8566F; Tue, 17 Jan 2023 18:50:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="LdKVPaM7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48956855BA; Tue, 17 Jan 2023 18:48:55 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 44D4485642 for ; Tue, 17 Jan 2023 18:48:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15756476ila.4 for ; Tue, 17 Jan 2023 09:48:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vV76eROcNAB0Voigu2NBMsDmSK28JLdV7LB72Y3GBs0=; b=LdKVPaM7RkPnHY2K2T7oZMr4CijED4qfsgjGm5a4k6uILXRMOrbWEe1F4OLB5tXlzo q7Iukzh4lPqcr2JhUX9jfr8BSKOXW32fH9rH/JZ2u5yVdDRnVnOyeMrVXCIslejUeZ+f oivJDXFF/VK3o/cNXtCKcar9RpwVf55rRTVP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vV76eROcNAB0Voigu2NBMsDmSK28JLdV7LB72Y3GBs0=; b=zIRovM/Q8YMC43SUPhwRWyZrrPIDQezARQQ+RQfOfPO+Fv13fKCenY4IEx9MCS1xN/ FaD4EXaC3PMo6vNm6CcRWNbf5xzrr4ZOOkTCQmQwJ0nOiMYUkL3naW5iLydUYfh8qt0j /iQucTBOvZBEyO4TvYVBKALHKId0HZ3L/cJFc+A5cAGHG5pbdLnjv8pPl6q7bh67Wffb cXwHpDAi7gmUgD/w1Jxv+N2YxZ6z0Nq//WL7TShPUYmqwSzB3gdooGc+wW82CGYphK3+ MbGkpuiwM79qWZs6z76ie1WebDt/dFXr/R7Mu5J6hltFyxYhy+hasoKpvY+A+g0/xWi4 p63w== X-Gm-Message-State: AFqh2kogabnNr2StorqHyRUbHi45pKAlNZCTtQN76h0Dtb+FBxnQUZH9 eC1GfUpin/mkh9cKcmnQo+C4ULS0yZe8F7mp X-Google-Smtp-Source: AMrXdXvtcwf223fKrj6lkk1kfssZolNqeleEyOqXuHWMUzkILM76X9wuIc6q31ph/FzzjXbFh9Iymg== X-Received: by 2002:a92:c6ca:0:b0:302:d225:71a8 with SMTP id v10-20020a92c6ca000000b00302d22571a8mr3417640ilm.19.1673977729372; Tue, 17 Jan 2023 09:48:49 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:48 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 13/70] dm: test: Correct ordering of DM setup Date: Tue, 17 Jan 2023 10:47:23 -0700 Message-Id: <20230117174820.1281477-14-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean We must call dm_scan_other() after devices from the device tree have been created, since that function behaves differently if there is no bootstd device. Adjust the logic to achieve this. Also fix the bootflow_system() test which was relying on this broken behaviour. Signed-off-by: Simon Glass --- (no changes since v1) test/boot/bootflow.c | 10 ++++++---- test/test-main.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 5b76cd3ab14..12976005e41 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -338,12 +338,14 @@ BOOTSTD_TEST(bootflow_iter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); /* Check using the system bootdev */ static int bootflow_system(struct unit_test_state *uts) { - struct udevice *dev; + struct udevice *bootstd, *dev; if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) return -EAGAIN; - ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr", - &dev)); + ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); + ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr), + "efi_mgr", 0, ofnode_null(), &dev)); + ut_assertok(device_probe(dev)); sandbox_set_fake_efi_mgr_dev(dev, true); /* We should get a single 'bootmgr' method right at the end */ @@ -353,7 +355,7 @@ static int bootflow_system(struct unit_test_state *uts) ut_assert_skip_to_line( " 0 efi_mgr ready (none) 0 "); ut_assert_skip_to_line("No more bootdevs"); - ut_assert_skip_to_line("(5 bootflows, 5 valid)"); + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); ut_assert_console_end(); return 0; diff --git a/test/test-main.c b/test/test-main.c index 9ab090b7b33..72aa3a0aa8f 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -296,10 +296,8 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) uts->start = mallinfo(); - if (test->flags & UT_TESTF_SCAN_PDATA) { + if (test->flags & UT_TESTF_SCAN_PDATA) ut_assertok(dm_scan_plat(false)); - ut_assertok(dm_scan_other(false)); - } if (test->flags & UT_TESTF_PROBE_TEST) ut_assertok(do_autoprobe(uts)); @@ -308,6 +306,13 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) (test->flags & UT_TESTF_SCAN_FDT)) ut_assertok(dm_extended_scan(false)); + /* + * Do this after FDT scan since dm_scan_other() in bootstd-uclass.c + * checks for the existence of bootstd + */ + if (test->flags & UT_TESTF_SCAN_PDATA) + ut_assertok(dm_scan_other(false)); + if (IS_ENABLED(CONFIG_SANDBOX) && (test->flags & UT_TESTF_OTHER_FDT)) { /* make sure the other FDT is available */ ut_assertok(test_load_other_fdt(uts)); From patchwork Tue Jan 17 17:47:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727624 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mQPbvnz2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGh65RFlz23fp for ; Wed, 18 Jan 2023 04:52:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 183CD855F3; Tue, 17 Jan 2023 18:50:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="mQPbvnz2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 114BD85601; Tue, 17 Jan 2023 18:48:57 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 3F46A8560A for ; Tue, 17 Jan 2023 18:48:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id j1so6975576iob.6 for ; Tue, 17 Jan 2023 09:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4LReShInxAc05QaBD9JMK+xisgx4iGESs+TCbPApYAU=; b=mQPbvnz2e4Pwg93/uSTnmpbi+/OCXqkx6AS6twjSIL1BJ1UQBn9uvfnx/jVWqC2Cl6 2+5OCoVytLCKUSFrFlKFxTSG+qplgO0sg6dTv9bzU2wu4I7mEqYCfc0G3TUjCfUaVJnj 8eRE3fcHerirmu/aK1jP29456PJ3EE5VbNDEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4LReShInxAc05QaBD9JMK+xisgx4iGESs+TCbPApYAU=; b=f2f3ZvwznIL/gINNl9tqI2P/R/56XvvlgVoC7qk1dyKgeHFlQUq0KTGS4xDX63weUX 9ZhYSRfmI7AEkM3gy4/iv+mY+TRUkHYGhrzyB4Ziryq08C1H9Gi8/irVpJFvOUgcJ9Sc xG97vIDYWoQEJwNIaGLslaXw5EFAw7mRobUA63XJOOETmOsj0LxZf/7HPjC8MnsBO5W7 GsJVRMBkGU3QaNHQtOdTcnDMBkiq+lBSxrZeECMF+r5kZdyHjpS8fDv8UoSlPMQNdVdv vkqj54orp6g/xW7AQltn+gZ7HCw5rpS7FxuDaZKX80QkYTXeyTCR61EB8enRO+ckjMsW 0TIw== X-Gm-Message-State: AFqh2kqQVI8eyfhFabtO9Hu/e0jxttR84f6V7uvhNgaCZ2fx5bbQVUDo DaWf0ZLT9fKTUjR53xcAaT8CME7sGaYQAIMo X-Google-Smtp-Source: AMrXdXsTOl3WEtdMn5k5kuGqHhx76S0t3Ah9Bxa8PY1VLvq4COYffRzYuInlzUqLKMBzxbzohH/IUw== X-Received: by 2002:a05:6602:5dd:b0:704:ce4a:5bd6 with SMTP id w29-20020a05660205dd00b00704ce4a5bd6mr2465616iox.14.1673977730524; Tue, 17 Jan 2023 09:48:50 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:50 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 14/70] ide: Drop non-DM code for BLK Date: Tue, 17 Jan 2023 10:47:24 -0700 Message-Id: <20230117174820.1281477-15-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean We require CONFIG_BLK to be enabled now, so this code is unused. Drop it. Signed-off-by: Simon Glass --- (no changes since v1) drivers/block/ide.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index eaa58d859c6..13a1cb4b9e4 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -443,9 +443,6 @@ static void atapi_inquiry(struct blk_desc *dev_desc) device = dev_desc->devnum; dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */ -#ifndef CONFIG_BLK - dev_desc->block_read = atapi_read; -#endif memset(ccb, 0, sizeof(ccb)); memset(iobuf, 0, sizeof(iobuf)); @@ -692,6 +689,7 @@ __weak unsigned char ide_inb(int dev, int port) void ide_init(void) { + struct udevice *dev; unsigned char c; int i, bus; @@ -759,29 +757,14 @@ void ide_init(void) ide_dev_desc[i].log2blksz = LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); ide_dev_desc[i].lba = 0; -#ifndef CONFIG_BLK - ide_dev_desc[i].block_read = ide_read; - ide_dev_desc[i].block_write = ide_write; -#endif if (!ide_bus_ok[IDE_BUS(i)]) continue; ide_ident(&ide_dev_desc[i]); dev_print(&ide_dev_desc[i]); - -#ifndef CONFIG_BLK - if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) { - /* initialize partition type */ - part_init(&ide_dev_desc[i]); - } -#endif } schedule(); -#ifdef CONFIG_BLK - struct udevice *dev; - uclass_first_device(UCLASS_IDE, &dev); -#endif } __weak void ide_input_swap_data(int dev, ulong *sect_buf, int words) @@ -830,17 +813,10 @@ __weak void ide_input_data(int dev, ulong *sect_buf, int words) } } -#ifdef CONFIG_BLK ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) -#else -ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer) -#endif { -#ifdef CONFIG_BLK struct blk_desc *block_dev = dev_get_uclass_plat(dev); -#endif int device = block_dev->devnum; ulong n = 0; unsigned char c; @@ -957,17 +933,10 @@ IDE_READ_E: return n; } -#ifdef CONFIG_BLK ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) -#else -ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer) -#endif { -#ifdef CONFIG_BLK struct blk_desc *block_dev = dev_get_uclass_plat(dev); -#endif int device = block_dev->devnum; ulong n = 0; unsigned char c; @@ -1056,7 +1025,6 @@ int ide_device_present(int dev) } #endif -#ifdef CONFIG_BLK static int ide_blk_probe(struct udevice *udev) { struct blk_desc *desc = dev_get_uclass_plat(udev); @@ -1141,11 +1109,3 @@ UCLASS_DRIVER(ide) = { .name = "ide", .id = UCLASS_IDE, }; -#else -U_BOOT_LEGACY_BLK(ide) = { - .uclass_idname = "ide", - .uclass_id = UCLASS_IDE, - .max_devs = CONFIG_SYS_IDE_MAXDEVICE, - .desc = ide_dev_desc, -}; -#endif From patchwork Tue Jan 17 17:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727627 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Z5CY5p5J; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGjq1W91z23fp for ; Wed, 18 Jan 2023 04:54:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B0A18564A; Tue, 17 Jan 2023 18:50:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Z5CY5p5J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBAD6855D3; Tue, 17 Jan 2023 18:48:58 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 557DB85602 for ; Tue, 17 Jan 2023 18:48:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id u8so15737986ilq.13 for ; Tue, 17 Jan 2023 09:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=60/dmLhOZZcX+AEAQ98Oeb2c4Qbw7OnaHPy+uiahuXU=; b=Z5CY5p5Jc0jDc+3Np7ySUs6iymEaUq8JmXoU2DrbfOrpgLUWzZvnJ35dkv67dEe+QD Vx9GUq31KYtm7CQ76zgP2JiuQZmKjWcp89zFYUZyHkEhNUW8N+ASYOvwgb2Mp5C6mXxm 11oOxMHaORRt3ZfXNdZ3badDOBCQNKsui31sI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=60/dmLhOZZcX+AEAQ98Oeb2c4Qbw7OnaHPy+uiahuXU=; b=F/qZtE7zSucTfo/eTAB2gidenH1NPXczom+GbwD8QCEZ4zB5zAeS/V/FIM3ZodUAh+ 9mpf/ATUywpKMcgbOHxqe9P6EG2MtKrnE86ZtOityDXdvY387o2PAmQp0YTuktIX25KW O2XE8EqWaLSKPenOCYY8k9pbE9vw8JLFdT2Vo9dvphUqVQ/a4czhwCBa3dlOaffalbN5 CYoHBu0obY0BKvZpp42Moq4SkjNLuqv3qFgM0Af4n5Sdn/OTx84xTGv3l8DasjzcXbj6 /0vIwv5D0pfkJTfsLndyidzLP8Zcv12IyQmNGuY1ZgL6dJgGVpUPsXA4PrxM7nbaj/jb Gc9w== X-Gm-Message-State: AFqh2kqi5yQkosxaLry71A6QOEoiuzeUhQBDzTGXkgGlxt4AYKM/Z1wL OivRgd6DBQq60Vuj0uU+3A6w0wwt7iDK8RSD X-Google-Smtp-Source: AMrXdXszSVkJaN8f1dXxXKP7gjqYmlmQ3LdPPEavqQu1OBHEYiAKnsj+b3q2jyOrYvG88I55CGBUkg== X-Received: by 2002:a92:da43:0:b0:30e:f171:660f with SMTP id p3-20020a92da43000000b0030ef171660fmr3357816ilq.31.1673977731686; Tue, 17 Jan 2023 09:48:51 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:51 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass , Jaehoon Chung , Peng Fan Subject: [PATCH v3 15/70] dm: mmc: Use bootdev_setup_sibling_blk() Date: Tue, 17 Jan 2023 10:47:25 -0700 Message-Id: <20230117174820.1281477-16-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present MMC uses the bootdev_setup_for_dev() function to set up the bootdev. This is because MMC only has one block-device child, so does not need to worry about naming of the bootdev. However this inconsistency with other bootdevs that use block devices is a bit annoying. The only real reason for it is to have a name like 'mmc0.bootdev' instead of 'mmc0.blk.bootdev'. Update bootdev_setup_sibling_blk() to drop '.blk' from the name where it appears, thus removing the only reason to use the bootdev_setup_for_dev(). Switch MMC over to the subling function. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 42 ++++++++++++++++++++++++++++------------ drivers/mmc/mmc-uclass.c | 2 +- include/bootdev.h | 5 ++++- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index cffa01824c0..97f75cba49d 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -234,13 +234,27 @@ int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name) return 0; } +static int bootdev_get_suffix_start(struct udevice *dev, const char *suffix) +{ + int len, slen; + + len = strlen(dev->name); + slen = strlen(suffix); + if (len > slen && !strcmp(suffix, dev->name + len - slen)) + return len - slen; + + return len; +} + int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name) { struct udevice *parent, *dev; char dev_name[50]; - int ret; + int ret, len; - snprintf(dev_name, sizeof(dev_name), "%s.%s", blk->name, "bootdev"); + len = bootdev_get_suffix_start(blk, ".blk"); + snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name, + "bootdev"); parent = dev_get_parent(blk); ret = device_find_child_by_name(parent, dev_name, &dev); @@ -271,20 +285,22 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp) struct udevice *parent = dev_get_parent(dev); struct udevice *blk; int ret, len; - char *p; if (device_get_uclass_id(dev) != UCLASS_BOOTDEV) return -EINVAL; /* This should always work if bootdev_setup_sibling_blk() was used */ - p = strstr(dev->name, ".bootdev"); - if (!p) - return log_msg_ret("str", -EINVAL); - - len = p - dev->name; + len = bootdev_get_suffix_start(dev, ".bootdev"); ret = device_find_child_by_namelen(parent, dev->name, len, &blk); - if (ret) - return log_msg_ret("find", ret); + if (ret) { + char dev_name[50]; + + snprintf(dev_name, sizeof(dev_name), "%.*s.blk", len, + dev->name); + ret = device_find_child_by_name(parent, dev_name, &blk); + if (ret) + return log_msg_ret("find", ret); + } *blkp = blk; return 0; @@ -295,13 +311,15 @@ static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp) struct udevice *parent = dev_get_parent(blk); struct udevice *bootdev; char dev_name[50]; - int ret; + int ret, len; if (device_get_uclass_id(blk) != UCLASS_BLK) return -EINVAL; /* This should always work if bootdev_setup_sibling_blk() was used */ - snprintf(dev_name, sizeof(dev_name), "%s.%s", blk->name, "bootdev"); + len = bootdev_get_suffix_start(blk, ".blk"); + snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name, + "bootdev"); ret = device_find_child_by_name(parent, dev_name, &bootdev); if (ret) return log_msg_ret("find", ret); diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 759a6b728c8..01d9b0201f2 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -421,7 +421,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) mmc->cfg = cfg; mmc->priv = dev; - ret = bootdev_setup_for_dev(dev, "mmc_bootdev"); + ret = bootdev_setup_sibling_blk(bdev, "mmc_bootdev"); if (ret) return log_msg_ret("bootdev", ret); diff --git a/include/bootdev.h b/include/bootdev.h index 9fc219839fe..d0ca51c6d5e 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -204,7 +204,10 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp); #if CONFIG_IS_ENABLED(BOOTSTD) /** - * bootdev_setup_for_dev() - Bind a new bootdev device + * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) + * + * Please use bootdev_setup_sibling_blk() instead since it supports multiple + * (child) block devices for each media device. * * Creates a bootdev device as a child of @parent. This should be called from * the driver's bind() method or its uclass' post_bind() method. From patchwork Tue Jan 17 17:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727625 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ihVbjSYj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGhL33ZJz23fp for ; Wed, 18 Jan 2023 04:53:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D24F8562A; Tue, 17 Jan 2023 18:50:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="ihVbjSYj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74FDE85616; Tue, 17 Jan 2023 18:48:58 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 A3199855E5 for ; Tue, 17 Jan 2023 18:48:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15756567ila.4 for ; Tue, 17 Jan 2023 09:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NfRv3hap3i4Gdgali0RUoJx6Ngz/bTo1lrTmagyeoxo=; b=ihVbjSYjOqUH1mFtU2P1xIZgoa8Rpjg2t7x4XeYn6rFi5A8vCL7qEddpsuIsUJWLKg VEPuXzG/R5GX1APvgyZduDHklvyAe9WZ9G+pLk9p2u7Y7VCVNp9S8aMRKCoPg0LPgt39 mja5oJKtyz2YwYftgc1WOgLh/3aLyiZ1ruLzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NfRv3hap3i4Gdgali0RUoJx6Ngz/bTo1lrTmagyeoxo=; b=oWi21x13kSRIL1mEplsSmn6USW7FN/RS1U8+OCWHHvTzki2AUlmRlegN9BYb7YYQKt FzwBmYCsRdATApfAV4VBcZrCD8+qMnzIblP0zprK+cjC51iLOFpHXY2dtiz/tnVzVX5n oRnUl0xdoq/ZkHNYCfqNkk+VGEuq+gfxnuhYeIIZ1L6kw4EmoDZC9XnKEPM0US5bLdtd YDAEMlbjjA5U7lfUCVwY1uOJPPukanOuXFkEgP1oz18qhnEhpsYlIfEvZSX9dTtsjlNS zwarrc1+haMpmwoAht9o7VRcK2CYBrVkK3ttbIuy0UFZ2fvmN9UuRDKOIX5WOs1npHTp w4rA== X-Gm-Message-State: AFqh2krb5rdzaJc5fMlujs6qaZ5qcSi4n0P5ekpkC5+aAkCiZJeiY2IL /hOzR7S9uuKXB1iLwhTFd9DYXOwsZ2YvPlWC X-Google-Smtp-Source: AMrXdXv0h6IA4idR5hbA3g8q1kmpIygObgk58SYZ7OWwCgtEnqAo3utPZrD6rWhoVC4Ex0jvA23iQw== X-Received: by 2002:a05:6e02:1aa9:b0:30b:e72e:adb5 with SMTP id l9-20020a056e021aa900b0030be72eadb5mr3594144ilv.30.1673977732834; Tue, 17 Jan 2023 09:48:52 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:52 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 16/70] bootstd: Add a default method to get bootflows Date: Tue, 17 Jan 2023 10:47:26 -0700 Message-Id: <20230117174820.1281477-17-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean The code in these functions turns out to often be the same. Add a default get_bootflow() function and allow the drivers to select it by setting the method to NULL. This saves a little code space. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 27 +++++++++++++++++++++++++-- drivers/mmc/mmc_bootdev.c | 25 ------------------------- drivers/usb/host/usb_bootdev.c | 24 ------------------------ include/bootdev.h | 5 ++++- 4 files changed, 29 insertions(+), 52 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 97f75cba49d..0ef3daf24cb 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -450,14 +450,37 @@ int bootdev_find_by_any(const char *name, struct udevice **devp) return 0; } +static int default_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow) +{ + struct udevice *blk; + int ret; + + ret = bootdev_get_sibling_blk(dev, &blk); + /* + * If there is no media, indicate that no more partitions should be + * checked + */ + if (ret == -EOPNOTSUPP) + ret = -ESHUTDOWN; + if (ret) + return log_msg_ret("blk", ret); + assert(blk); + ret = bootdev_find_in_blk(dev, blk, iter, bflow); + if (ret) + return log_msg_ret("find", ret); + + return 0; +} + int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, struct bootflow *bflow) { const struct bootdev_ops *ops = bootdev_get_ops(dev); - if (!ops->get_bootflow) - return -ENOSYS; bootflow_init(bflow, dev, iter->method); + if (!ops->get_bootflow) + return default_get_bootflow(dev, iter, bflow); return ops->get_bootflow(dev, iter, bflow); } diff --git a/drivers/mmc/mmc_bootdev.c b/drivers/mmc/mmc_bootdev.c index b4f41fb3a67..037b67bc0ff 100644 --- a/drivers/mmc/mmc_bootdev.c +++ b/drivers/mmc/mmc_bootdev.c @@ -11,30 +11,6 @@ #include #include -static int mmc_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, - struct bootflow *bflow) -{ - struct udevice *mmc_dev = dev_get_parent(dev); - struct udevice *blk; - int ret; - - ret = mmc_get_blk(mmc_dev, &blk); - /* - * If there is no media, indicate that no more partitions should be - * checked - */ - if (ret == -EOPNOTSUPP) - ret = -ESHUTDOWN; - if (ret) - return log_msg_ret("blk", ret); - assert(blk); - ret = bootdev_find_in_blk(dev, blk, iter, bflow); - if (ret) - return log_msg_ret("find", ret); - - return 0; -} - static int mmc_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); @@ -45,7 +21,6 @@ static int mmc_bootdev_bind(struct udevice *dev) } struct bootdev_ops mmc_bootdev_ops = { - .get_bootflow = mmc_get_bootflow, }; static const struct udevice_id mmc_bootdev_ids[] = { diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c index b85f699933d..b2d157faf33 100644 --- a/drivers/usb/host/usb_bootdev.c +++ b/drivers/usb/host/usb_bootdev.c @@ -11,29 +11,6 @@ #include #include -static int usb_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, - struct bootflow *bflow) -{ - struct udevice *blk; - int ret; - - ret = bootdev_get_sibling_blk(dev, &blk); - /* - * If there is no media, indicate that no more partitions should be - * checked - */ - if (ret == -EOPNOTSUPP) - ret = -ESHUTDOWN; - if (ret) - return log_msg_ret("blk", ret); - assert(blk); - ret = bootdev_find_in_blk(dev, blk, iter, bflow); - if (ret) - return log_msg_ret("find", ret); - - return 0; -} - static int usb_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); @@ -44,7 +21,6 @@ static int usb_bootdev_bind(struct udevice *dev) } struct bootdev_ops usb_bootdev_ops = { - .get_bootflow = usb_get_bootflow, }; static const struct udevice_id usb_bootdev_ids[] = { diff --git a/include/bootdev.h b/include/bootdev.h index d0ca51c6d5e..1e91d4130e7 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -50,7 +50,10 @@ struct bootdev_uc_plat { /** struct bootdev_ops - Operations for the bootdev uclass */ struct bootdev_ops { /** - * get_bootflow() - get a bootflow + * get_bootflow() - get a bootflow (optional) + * + * If this is NULL then the default implementaton is used, which is + * default_get_bootflow() * * @dev: Bootflow device to check * @iter: Provides current dev, part, method to get. Should update From patchwork Tue Jan 17 17:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727626 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Jpz/So7D; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGjc2SlPz23fp for ; Wed, 18 Jan 2023 04:54:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E2B7285673; Tue, 17 Jan 2023 18:50:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Jpz/So7D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C43D685605; Tue, 17 Jan 2023 18:48:58 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 CEECD85603 for ; Tue, 17 Jan 2023 18:48:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15756598ila.4 for ; Tue, 17 Jan 2023 09:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sTX/UPWjsQEUAItGBW0rAVSKRj4mmqlfFm6Vb8hi7h8=; b=Jpz/So7Dn7bKyH41B2gmGB3KUPmAi13IxMs5OAiZmjUhtSsoYMU/5PfZyc+3FhmieF rC+5tABeykJgCgQU/NlAcveSGDulTRIlz3G91AF4zNHm3+8cpGVctEvtCoffxNA2OXHw +h0xVEE6XkyOi82lGF6WlvD38T7ErSv7NCLPU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sTX/UPWjsQEUAItGBW0rAVSKRj4mmqlfFm6Vb8hi7h8=; b=cKWk8AWYozWfN+IZG4MosEqRl1ajF+xzIyQRHtkqY4JIeoOxGscyV2L8a2pfkWnkoV zzSU2znmN2jke4PTEor1MLo5oLnkiRHyeRTJ2lcUDywLYtHUJ4xSuT51ST+rm0HUnzCX ykV69DWuoBpSB1QRZD9LY1vZmZzaAN5TRUdN5Gsc74GdEqfVe8vhL7m19kraCDIYe7ek 5fC9VMffxlbGr+1EF2n2Ru0X/SngMm1gfqy7dX7JomrNS0Y5XW6+VcJWEaHOw5MGeLeb QDNSHAVkZ1vjmUKZ48g1Ls4J3HIWjAdq0hyYskkMLbWs8EFxDcCZKQ79qWUSUQTcaSSz VU8Q== X-Gm-Message-State: AFqh2kr7McmejFMfeCtrsyj8u44zz981py0zHGWmRgeiEp3NSGwV74l6 eiBkePtdlmqqoDxhM6osUfa5f0Zxac/vlwtd X-Google-Smtp-Source: AMrXdXuToqZZ0wEw7DKugyHw/rNzMamWaJaxC4wdgl74JeYBTTkqpKjyt8GIxfVg7k+4cADfyg9jgA== X-Received: by 2002:a92:d48c:0:b0:30e:e8d3:a5ff with SMTP id p12-20020a92d48c000000b0030ee8d3a5ffmr10013536ilg.27.1673977734018; Tue, 17 Jan 2023 09:48:54 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:53 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 17/70] sandbox: Allow ethernet to be disabled at runtime Date: Tue, 17 Jan 2023 10:47:27 -0700 Message-Id: <20230117174820.1281477-18-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/state.c | 16 ++++++++++++++++ arch/sandbox/include/asm/state.h | 1 + arch/sandbox/include/asm/test.h | 16 ++++++++++++++++ include/test/test.h | 25 +++++++++++++++++++++++++ net/net.c | 4 ++++ 5 files changed, 62 insertions(+) diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index dd7978cfced..267f280df14 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -12,6 +12,7 @@ #include #include #include +#include /* Main state record for the sandbox */ static struct sandbox_state main_state; @@ -366,6 +367,7 @@ void state_reset_for_test(struct sandbox_state *state) state->sysreset_allowed[SYSRESET_POWER_OFF] = true; state->sysreset_allowed[SYSRESET_COLD] = true; state->allow_memio = false; + sandbox_set_eth_enable(true); memset(&state->wdt, '\0', sizeof(state->wdt)); memset(state->spi, '\0', sizeof(state->spi)); @@ -444,6 +446,20 @@ int state_load_other_fdt(const char **bufp, int *sizep) return 0; } +void sandbox_set_eth_enable(bool enable) +{ + struct sandbox_state *state = state_get_current(); + + state->disable_eth = !enable; +} + +bool sandbox_eth_enabled(void) +{ + struct sandbox_state *state = state_get_current(); + + return !state->disable_eth; +} + int state_init(void) { state = &main_state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 49ea483d332..f125fb87af7 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -96,6 +96,7 @@ struct sandbox_state { const char *select_unittests; /* Unit test to run */ bool handle_signals; /* Handle signals within sandbox */ bool autoboot_keyed; /* Use keyed-autoboot feature */ + bool disable_eth; /* Disable Ethernet devices */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 568738c16d5..1c522e38f3d 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -344,4 +344,20 @@ void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev); */ int sandbox_load_other_fdt(void **fdtp, int *sizep); +/** + * sandbox_set_eth_enable() - Enable / disable Ethernet + * + * Allows control of whether Ethernet packets are actually send/received + * + * @enable: true to enable Ethernet, false to disable + */ +void sandbox_set_eth_enable(bool enable); + +/** + * sandbox_eth_enabled() - Check if Ethernet is enabled + * + * Returns: true if Ethernet is enabled on sandbox, False if not + */ +bool sandbox_eth_enabled(void); + #endif diff --git a/include/test/test.h b/include/test/test.h index 4ad74614afc..76ec4d739a3 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -169,4 +169,29 @@ static inline int test_load_other_fdt(struct unit_test_state *uts) return ret; } +/** + * test_set_eth_enable() - Enable / disable Ethernet + * + * Allows control of whether Ethernet packets are actually send/received + * + * @enable: true to enable Ethernet, false to disable + */ +static inline void test_set_eth_enable(bool enable) +{ +#ifdef CONFIG_SANDBOX + sandbox_set_eth_enable(enable); +#endif +} + +/* Allow ethernet to be disabled for testing purposes */ +static inline bool test_eth_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_eth_enabled(); +#endif + return enabled; +} + #endif /* __TEST_TEST_H */ diff --git a/net/net.c b/net/net.c index 57da9bda85a..c9a749f6cc8 100644 --- a/net/net.c +++ b/net/net.c @@ -106,6 +106,7 @@ #endif #include #include +#include #include "arp.h" #include "bootp.h" #include "cdp.h" @@ -465,6 +466,9 @@ restart: debug_cond(DEBUG_INT_STATE, "--- net_loop Init\n"); net_init_loop(); + if (!test_eth_enabled()) + return 0; + switch (net_check_prereq(protocol)) { case 1: /* network not configured */ From patchwork Tue Jan 17 17:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727628 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dlt80Ciy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGk25vzZz23fp for ; Wed, 18 Jan 2023 04:54:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AE1D98566E; Tue, 17 Jan 2023 18:50:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="dlt80Ciy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B73D855D3; Tue, 17 Jan 2023 18:48:59 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 09D36855E6 for ; Tue, 17 Jan 2023 18:48:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id u8so15738092ilq.13 for ; Tue, 17 Jan 2023 09:48:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QxLuKoJjkDUyH83uGnft1SaEmer0p3Z+Hf1BgZcHZe4=; b=dlt80CiyZ85exUlCgUDwvR10u/zCP4YKsOOjRLW+iV5YGsUnjuNCRRorPPI7/aqCN8 whec7WCvdzQy/GSnwYhQd3zFU3AY4NaEApGEq/FACuxfa73/yyVFxVkCvribRPvbSQgr LU1b7Vv5JqneCEbBlL98p+221L5J5zTCEbqVQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QxLuKoJjkDUyH83uGnft1SaEmer0p3Z+Hf1BgZcHZe4=; b=c9BofNGW4WjBEeuZZQerCR2x8cbMHR1aD1lDwvqu9aiF3wOHW1g5e4ZT6zQ0fT6frj Z02EXbpPHJIdSJuLhSSUSuVI0P79GawxY1D80S5DrDXenAWdUeoGF4yhgSVcHuYSzdbb +qZiXBIYAknOHGAVxsO8iiJ2k2msGoJRbkp0T2wdxnYC9JmTsgaU7jwoTEF4dW7oJwzK tuDXi9Uu/OHtTgXOwwWG7mweND/8cS+99wh6RrKuVr/8wuwYzNwBagAhOYMoJtj5CCBH L9bjVR40mgShcvsWd0eynAiQH/aMFYdbOK3QAX2dfXq4crVV/I9pYy16RjEY5AQ7/z4k tV5g== X-Gm-Message-State: AFqh2kqGEP/WI6CuTWIJXXmF9PaIuefZDHT5PL+RoBI2/Vxx2vjL7gtx hLhgNGIRGWmg0EvZr45LiXXbVZLMT973QjNn X-Google-Smtp-Source: AMrXdXs2oXe5jBm33UnTPTveZuiGQKvJpHXe6kjbEi6Wyr+ZpYCz6ggQhAJstgxieK3/SJDc90E2mg== X-Received: by 2002:a92:60c:0:b0:305:e1f9:89b with SMTP id x12-20020a92060c000000b00305e1f9089bmr3276855ilg.24.1673977735199; Tue, 17 Jan 2023 09:48:55 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:54 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 18/70] sandbox: Allow ethernet bootdevs to be disabled for tests Date: Tue, 17 Jan 2023 10:47:28 -0700 Message-Id: <20230117174820.1281477-19-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Most tests don't want these and can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass --- (no changes since v1) include/net.h | 16 ++++++++++++++++ include/test/test.h | 12 ++++++++++++ net/eth-uclass.c | 14 +++++++++++++- test/test-main.c | 8 +++++++- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/net.h b/include/net.h index ee08f3307ec..759d4669df1 100644 --- a/include/net.h +++ b/include/net.h @@ -886,4 +886,20 @@ static inline struct in_addr env_get_ip(char *var) */ void reset_phy(void); +#if CONFIG_IS_ENABLED(NET) +/** + * eth_set_enable_bootdevs() - Enable or disable binding of Ethernet bootdevs + * + * These get in the way of bootstd testing, so are normally disabled by tests. + * This provide control of this setting. It only affects binding of Ethernet + * devices, so if that has already happened, this flag does nothing. + * + * @enable: true to enable binding of bootdevs when binding new Ethernet + * devices, false to disable it + */ +void eth_set_enable_bootdevs(bool enable); +#else +static inline void eth_set_enable_bootdevs(bool enable) {} +#endif + #endif /* __NET_H__ */ diff --git a/include/test/test.h b/include/test/test.h index 76ec4d739a3..beabe9333dc 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -71,6 +71,7 @@ enum { * since it cannot access the flags. */ UT_TESTF_MANUAL = BIT(8), + UT_TESTF_ETH_BOOTDEV = BIT(9), /* enable Ethernet bootdevs */ }; /** @@ -194,4 +195,15 @@ static inline bool test_eth_enabled(void) return enabled; } +/* Allow ethernet bootdev to be ignored for testing purposes */ +static inline bool test_eth_bootdev_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_eth_enabled(); +#endif + return enabled; +} + #endif /* __TEST_TEST_H */ diff --git a/net/eth-uclass.c b/net/eth-uclass.c index f41da4b37b3..b01a910938e 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -38,9 +38,12 @@ struct eth_device_priv { * struct eth_uclass_priv - The structure attached to the uclass itself * * @current: The Ethernet device that the network functions are using + * @no_bootdevs: true to skip binding Ethernet bootdevs (this is a negative flag + * so that the default value enables it) */ struct eth_uclass_priv { struct udevice *current; + bool no_bootdevs; }; /* eth_errno - This stores the most recent failure code from DM functions */ @@ -59,6 +62,14 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void) return uclass_get_priv(uc); } +void eth_set_enable_bootdevs(bool enable) +{ + struct eth_uclass_priv *priv = eth_get_uclass_priv(); + + if (priv) + priv->no_bootdevs = !enable; +} + void eth_set_current_to_next(void) { struct eth_uclass_priv *uc_priv; @@ -477,6 +488,7 @@ int eth_initialize(void) static int eth_post_bind(struct udevice *dev) { + struct eth_uclass_priv *priv = uclass_get_priv(dev->uclass); int ret; if (strchr(dev->name, ' ')) { @@ -488,7 +500,7 @@ static int eth_post_bind(struct udevice *dev) #ifdef CONFIG_DM_ETH_PHY eth_phy_binds_nodes(dev); #endif - if (CONFIG_IS_ENABLED(BOOTDEV_ETH)) { + if (CONFIG_IS_ENABLED(BOOTDEV_ETH) && !priv->no_bootdevs) { ret = bootdev_setup_for_dev(dev, "eth_bootdev"); if (ret) return log_msg_ret("bootdev", ret); diff --git a/test/test-main.c b/test/test-main.c index 72aa3a0aa8f..9d0f6643d5e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -303,8 +304,13 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) ut_assertok(do_autoprobe(uts)); if (!CONFIG_IS_ENABLED(OF_PLATDATA) && - (test->flags & UT_TESTF_SCAN_FDT)) + (test->flags & UT_TESTF_SCAN_FDT)) { + /* + * only set this if we know the ethernet uclass will be created + */ + eth_set_enable_bootdevs(test->flags & UT_TESTF_ETH_BOOTDEV); ut_assertok(dm_extended_scan(false)); + } /* * Do this after FDT scan since dm_scan_other() in bootstd-uclass.c From patchwork Tue Jan 17 17:47:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727629 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CHw2dhak; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGkG4jFJz23fp for ; Wed, 18 Jan 2023 04:54:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1BF6E85660; Tue, 17 Jan 2023 18:50:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="CHw2dhak"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D603885600; Tue, 17 Jan 2023 18:48:59 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 3C78C855F9 for ; Tue, 17 Jan 2023 18:48:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id p189so3275412iod.0 for ; Tue, 17 Jan 2023 09:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0iigWcJhFjWt6QBBatwSEJkSX8OtQcw1dukrhV5y1l0=; b=CHw2dhakl/0bIDQoOXOcCHFy6rjtY+LbbB/DAYgOJzhFONifxxqI+hNELp6PVSE0bn FgF6acyrMTmFzRv6KVuM2IOnMgHJiBG2sEN1VbLfSjqjbPaxn/we8wAJDn6uao3LA0YD gASuj2QasDLjYcx4TciLbyFrgxdTNOwsjZQh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0iigWcJhFjWt6QBBatwSEJkSX8OtQcw1dukrhV5y1l0=; b=gUdh2lxvezpVl4OGNGMauWG1/L2SWuqrBb/VFo4+4dVrlm6vsj2Rtg8E4xrmXnHjoX yxQJmDMsQ/oDd67Ta7C0zkkPbtui7TiBnwgcxs/1hU1lDYPy5h/EHS88yuSX7+mJO9mn n1ys661XkVjboKzgPbtzCjdBY2+6Gppfx+Wnn6qZxMju/dd3kxPh/cmHULZWJGo94iby /HZUD2dm6f50sIL3YbMsIHYc39P1FYw0BaKEH38HACsDQbRePFwMw43UjTDVMCd4rys8 YD9Es6KToeYB++oVb99yX2F01pqqXoAgqN59cpB41pN31SAuEkfRxN2+9GcTsOkfoQmm 8oQw== X-Gm-Message-State: AFqh2ko99FcOnqeuvV+bsn1OVmn4oHxEFaYzGYfZXJJ1e0rAH0m4pPb1 mpcXIHfF471VFZc1+5B0KM4hY+Ahdm2HoyyA X-Google-Smtp-Source: AMrXdXsMLo/M3iXdoKR9IK68ZXrtocQ2i6B6iP/E1GBosD3QZVSEl9gerGQ832iXFwC9en+5iWVo7g== X-Received: by 2002:a05:6602:5d9:b0:6e2:fd23:821b with SMTP id w25-20020a05660205d900b006e2fd23821bmr2823804iox.3.1673977736395; Tue, 17 Jan 2023 09:48:56 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:55 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 19/70] sandbox: Enable the Ethernet bootdev Date: Tue, 17 Jan 2023 10:47:29 -0700 Message-Id: <20230117174820.1281477-20-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This bootdev is disabled at present since it messes with the tests. Now that there is a way to disable networking at runtime, enable the driver. This allows running tests with it if necessary. Signed-off-by: Simon Glass --- (no changes since v1) configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 1 - 2 files changed, 2 deletions(-) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 6c5bacea323..4a2f94f65bc 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -132,7 +132,6 @@ CONFIG_ENV_IS_IN_EXT4=y CONFIG_ENV_EXT4_INTERFACE="host" CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_ENV_IMPORT_FDT=y -# CONFIG_BOOTDEV_ETH is not set CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 41453e0e2fa..eaaec42b1fe 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -75,7 +75,6 @@ CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_EXT4=y CONFIG_ENV_EXT4_INTERFACE="host" CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" -# CONFIG_BOOTDEV_ETH is not set CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y From patchwork Tue Jan 17 17:47:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727630 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=UVUVXATb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGkW0Lf9z23fp for ; Wed, 18 Jan 2023 04:54:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BB24585665; Tue, 17 Jan 2023 18:50:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="UVUVXATb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32A4C855D3; Tue, 17 Jan 2023 18:49:08 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 4036B85602 for ; Tue, 17 Jan 2023 18:48:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id h184so5813402iof.9 for ; Tue, 17 Jan 2023 09:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FZ+WgV8ncXsAd6KCWY2Vd06F2h/NRn1zhX3mwNn7g9g=; b=UVUVXATbxzhdNZYeu3X2mSQF5IlQVsk+FV452mR2eMUSw30Bvo0fqIAwmNkhu6fGrk xRC4fX9CWiyVg7hvZB2hGvLNAC2Q8b2EP0a4i34DXllPqF82+gDiCHTBUUoeyAcUp1VI GSUt0hF3Ni0iPAiPL+S+oGdycWUPCRZy2I1+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FZ+WgV8ncXsAd6KCWY2Vd06F2h/NRn1zhX3mwNn7g9g=; b=6hXNqvci/kHwtB/YJFZv9VN1klr0c/R8a02UvZl3Dj/uEiCisGdRU6IBWP1gan7q4g 2w5uSjPEZQv4Slv+HsOAf5COSMBBMh2E7LRD7tgnp19LY430k8mtqNh19006QTlAfJZj lIfu802pfYLt9fS1uBt5T/bkSeSANoaXKAfMwPQrq/TEMGS49NqpouTOCp214LEqFtiN XNVbLDFpU/SHLvjtiI+4UGMzUV/502F5h/JI6l8KZus5l2l4mebuee+jgzQfDmXlshg8 AIUR1tmdoohWhfcRGGdDJCQF6+nSHbBf/CQUqtVHScHkQ5qlYZF6aq5s2VpUDOewa3Xp w++w== X-Gm-Message-State: AFqh2krXGl2dzZdo9t35StPVd4UJBvPjJncj/TXKn0Y78Wca2doW8/P5 08CERYZ+yCUErhuvWH3c6+qPoIT0JxEmZWkh X-Google-Smtp-Source: AMrXdXuW0+hwg8OkJftX589daOcfeKZaneWYKKUNaSHkKmdLPT2vALTTk/6BxAVrOycNOl2W90tXYw== X-Received: by 2002:a6b:8f10:0:b0:704:bc04:adfb with SMTP id r16-20020a6b8f10000000b00704bc04adfbmr5608826iod.3.1673977737597; Tue, 17 Jan 2023 09:48:57 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:57 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 20/70] lib: Support printing an error string Date: Tue, 17 Jan 2023 10:47:30 -0700 Message-Id: <20230117174820.1281477-21-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean It is often useful to show an error code to give the user a clue as to what went wrong. When error strings are compiled into U-Boot it is possible to show a message as well. But at present it is not very convenient, since code must check if the error strings are present, then obtain the error string and use it in a printf() string. Add a %dE option which shows an error code along with an error string, if available. This makes it easy to show one or both. Signed-off-by: Simon Glass --- (no changes since v1) lib/vsprintf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 530d8088c7f..8de3882fb6c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -145,6 +145,7 @@ static noinline char *put_dec(char *buf, uint64_t num) #define LEFT 16 /* left justified */ #define SMALL 32 /* Must be 32 == 0x20 */ #define SPECIAL 64 /* 0x */ +#define ERRSTR 128 /* %dE showing error string if enabled */ /* * Macro to add a new character to our output string, but only if it will @@ -678,6 +679,8 @@ repeat: break; case 'd': + if (fmt[1] == 'E') + flags |= ERRSTR; case 'i': flags |= SIGN; case 'u': @@ -712,6 +715,15 @@ repeat: } str = number(str, end, num, base, field_width, precision, flags); + if (IS_ENABLED(CONFIG_ERRNO_STR) && (flags & ERRSTR)) { + const char *p; + + ADDCH(str, ':'); + ADDCH(str, ' '); + for (p = errno_str(num); *p; p++) + ADDCH(str, *p); + fmt++; + } } if (size > 0) { From patchwork Tue Jan 17 17:47:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727631 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gwhbfFgg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGkl2t59z23gH for ; Wed, 18 Jan 2023 04:55:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 12E8A85674; Tue, 17 Jan 2023 18:50:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="gwhbfFgg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A943885602; Tue, 17 Jan 2023 18:49:09 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 8540885605 for ; Tue, 17 Jan 2023 18:48:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id p189so3275466iod.0 for ; Tue, 17 Jan 2023 09:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ACPOEr6WCKil3vHGvHEHqMXMzsk0cpo4qLuRWxDdNL4=; b=gwhbfFgggowyvgb/Z2RJNd3XdiFh4J7rWezQACCCaFyjDwWJBEcrWh+S38w1rlUvbn PWie8AYQvJlyEh+vLZT+/ttCKoxk9GK+IU9pRcWsodfETEBkUHHixueD3eeU9ppm6qXC VeJBu5B+yZrAmdjdE0Evy/LEBEQ8p5uPNAgIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ACPOEr6WCKil3vHGvHEHqMXMzsk0cpo4qLuRWxDdNL4=; b=Zm6/n5wLJ4vrfcV/MTaRYkBwmReBdq67LCGLMUP6ppQesG+WtSGw5lCLM6dvi76Olo iyUfXsvAio78x13e9+Lf0masenQjvfZr3dOKEKoxP/qoic29e3HJk5nPd7i7290kaToa btXPjjX1z9zLY82wMkI84axeb/JMNG7dPoJA1SiB0h8V0RBDtyUv0YcRsAkwWojWX94J 6Jom1bqa1OhyZLOI3zuG2+K4DplDdNasVK6BUSDg5Ww9FMUQy8Qcav3+ElThklfsybT5 E8PEXSlrur0S/nQKDEtX3k/7kIZOgZabjS/FxgQS3Z8bos0FK3Ol7xr0AEtjYyc/Rr8Q D7dA== X-Gm-Message-State: AFqh2kqP4gwPKx44p9PIZ1x4c9gcY0Qhh4OcDdFfCFS9FsqGKy8tvYz5 KL1lrG/sanoO9qN/FTnPX37OSKKUlXyiaxS5 X-Google-Smtp-Source: AMrXdXv4Ur+yj53VlJzP/oA7N0FRF9XJiXH288OPIIyI47VEux8/SCt5apDBUn5AZQcbf2qqoCw0ow== X-Received: by 2002:a6b:6113:0:b0:704:9bc7:d0ba with SMTP id v19-20020a6b6113000000b007049bc7d0bamr3211116iob.3.1673977738737; Tue, 17 Jan 2023 09:48:58 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:58 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 21/70] event: Correct duplicate log message in event_notify() Date: Tue, 17 Jan 2023 10:47:31 -0700 Message-Id: <20230117174820.1281477-22-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Use a different one for each call. Signed-off-by: Simon Glass --- (no changes since v1) common/event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/event.c b/common/event.c index 231b9e6ffdd..c312556490e 100644 --- a/common/event.c +++ b/common/event.c @@ -123,7 +123,7 @@ int event_notify(enum event_t type, void *data, int size) ret = notify_static(&event); if (ret) - return log_msg_ret("dyn", ret); + return log_msg_ret("sta", ret); if (CONFIG_IS_ENABLED(EVENT_DYNAMIC)) { ret = notify_dynamic(&event); From patchwork Tue Jan 17 17:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727632 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NQiC45e7; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGkz5d3Kz23gH for ; Wed, 18 Jan 2023 04:55:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C667185689; Tue, 17 Jan 2023 18:50:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="NQiC45e7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 91376855CF; Tue, 17 Jan 2023 18:49:10 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 A61F185600 for ; Tue, 17 Jan 2023 18:49:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id u8so15783120ilg.0 for ; Tue, 17 Jan 2023 09:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q1Usf6ZRWTrZ9mvj1E1PhYOeJl8BkD2Ki8U2jhgkPKE=; b=NQiC45e7cCmWcw1LW6RspKZbn1ntEYIB2EXZMJPrStZwz6k1rG9G5RxeO+Zn5QTzu7 0PnWkuF1qPvnMNjc3C6v/TRfRYV0Gdoupzewyr1fpvUl1oEVNWZV2qyE+gN5L4Ogzh1R d3btDrm4h0JBSSGOXXqMRAD+YYFJhOaN2yVSU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q1Usf6ZRWTrZ9mvj1E1PhYOeJl8BkD2Ki8U2jhgkPKE=; b=PBt5/BiOd6/f2sSLmsO3X3DySeVcOg/ZQlGzATKbuwcxt4OxteHyulAAvsVI7kTo/O GDe8d4addKmLSQNa8Bms+b5Z3S5S0rn2t77IJC5FOYSbgGqKPmyepGZzeW1Mp351Gr6X 6yKt1tLY5QC6LEX9JwCzRi0M32eSb7FZnmLKxwzR4Dtc0qioRvZqnIVndEsPsi1BE7vi rDxQfCNA7QaE47NFPSb4g2ESBB6+jTGGB1NRLormip5OFWw0YWEUXckKnN4k6fEfOhbn BuYd3mI9IJapGRCclC0ZHL7vNCEjYRWPOkDHh+mIk9eySGi0tw6RdXcgnTwZOLVNVstQ p1Vw== X-Gm-Message-State: AFqh2kqnKq92z4IwTHtOA+PJA8WO4gIndbNBBAwCiIXx6GexZn0b1N7V 0JImCdrRlnBmFBPqqw5kZP8B1A5lC1on82cW X-Google-Smtp-Source: AMrXdXspzZWcT8QGeL4zwUH8qk/XnIBWqVG9VgTzUoImf5Hi+HjPJSBGtk4j4L8Yx/OrwuSJ4jxk3g== X-Received: by 2002:a05:6e02:2190:b0:30c:3500:20cf with SMTP id j16-20020a056e02219000b0030c350020cfmr3667876ila.1.1673977739906; Tue, 17 Jan 2023 09:48:59 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:48:59 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 22/70] efi: Improve logging in efi_disk Date: Tue, 17 Jan 2023 10:47:32 -0700 Message-Id: <20230117174820.1281477-23-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean When this fails it can be time-consuming to debug. Add some debugging to help with this. Also try to return error codes instead of just using -1. Signed-off-by: Simon Glass --- (no changes since v1) lib/efi_loader/efi_disk.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index d170a864605..d2256713a8e 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -424,13 +424,16 @@ static efi_status_t efi_disk_add_dev( if (!node) { ret = EFI_OUT_OF_RESOURCES; + log_debug("no node\n"); goto error; } /* Parent must expose EFI_BLOCK_IO_PROTOCOL */ ret = efi_search_protocol(parent, &efi_block_io_guid, &handler); - if (ret != EFI_SUCCESS) + if (ret != EFI_SUCCESS) { + log_debug("search failed\n"); goto error; + } /* * Link the partition (child controller) to the block device @@ -439,8 +442,10 @@ static efi_status_t efi_disk_add_dev( ret = efi_protocol_open(handler, &protocol_interface, NULL, &diskobj->header, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); - if (ret != EFI_SUCCESS) - goto error; + if (ret != EFI_SUCCESS) { + log_debug("prot open failed\n"); + goto error; + } diskobj->dp = efi_dp_append_node(dp_parent, node); efi_free_pool(node); @@ -471,8 +476,10 @@ static efi_status_t efi_disk_add_dev( */ esp_guid, NULL, NULL); - if (ret != EFI_SUCCESS) + if (ret != EFI_SUCCESS) { + log_debug("install failed %lx\n", ret); goto error; + } /* * On partitions or whole disks without partitions install the @@ -485,8 +492,10 @@ static efi_status_t efi_disk_add_dev( ret = efi_add_protocol(&diskobj->header, &efi_simple_file_system_protocol_guid, diskobj->volume); - if (ret != EFI_SUCCESS) + if (ret != EFI_SUCCESS) { + log_debug("simple FS failed\n"); return ret; + } } diskobj->ops = block_io_disk_template; diskobj->dev_index = dev_index; @@ -556,18 +565,21 @@ static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle) ret = efi_disk_add_dev(NULL, NULL, desc, diskid, NULL, 0, &disk, agent_handle); if (ret != EFI_SUCCESS) { - if (ret == EFI_NOT_READY) + if (ret == EFI_NOT_READY) { log_notice("Disk %s not ready\n", dev->name); - else + ret = -EBUSY; + } else { log_err("Adding disk for %s failed (err=%ld/%#lx)\n", dev->name, ret, ret); + ret = -ENOENT; + } - return -1; + return ret; } if (efi_link_dev(&disk->header, dev)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); - return -1; + return -EINVAL; } return 0; From patchwork Tue Jan 17 17:47:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727636 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TJkjl7wC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGlv5mhQz23gH for ; Wed, 18 Jan 2023 04:56:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AF22F85611; Tue, 17 Jan 2023 18:51:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="TJkjl7wC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 413308564E; Tue, 17 Jan 2023 18:50:29 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 E90DF85616 for ; Tue, 17 Jan 2023 18:49:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id u8so15783148ilg.0 for ; Tue, 17 Jan 2023 09:49:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=32rzHJPMDzQq8Ar/ikOyvvqO5szayJMsluW30JM1syc=; b=TJkjl7wCqtQVdOBfOJl/lP8EdTPoye/7876YOitBDHqPKGM28wGPHaV1C0S2H5EVZe 463gHFv7YrYoZidO0tCarincKJxX7UA3supdf6G7DdNKBiAiiYG3WD7dej5K9VyVyghJ aCZ2wxEnBAwt0F6j7dTV3FT/vm80/AsdVqWsM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=32rzHJPMDzQq8Ar/ikOyvvqO5szayJMsluW30JM1syc=; b=t4Vmsd07Cf2Z5zceczCXKOzUXmatnwCuqX9NJYykwUmquGmcnbnGF8zuye2LD2MnQU Kd4/VFhPZi1oGOezEMqQajLAKPbSxGsjghPaBkXY4C7LQtjZnEndZSTCvgJQwhyxDXby Bq4GSyJGwRu1tJ0mcx11Kw7t/wbW6qD/VnrbNYc2OBVOVTT/sigBSeG5Inm0hmIjxlpQ 3uxz4jwPiAmsTxfNqTIpWkV5Z+UFpE5m8O5xp+M0omhvPtvAK1PRKqLK2B7soSjgQP6L NjElEDKpKUm1wQZ7hyFwGxQ63NhC1TiQseIVGNuHFeOfL47TSYeF9d7OuHGqzzDs1mSF cTkQ== X-Gm-Message-State: AFqh2kq5MIoSCaDAGM/daQ5lwd7oM6e2PvUx09KaanlekeWc+OQ99X1j gX4tB4SaHGEMD9ccuB1Jz+0As//x+cA0ZEwm X-Google-Smtp-Source: AMrXdXtq7oLyMriUHFM83NGrQZGIG34T+g+H8WUGr+yFvTip6wIqcKWNdUHMkUypfmPbQetBCudnvQ== X-Received: by 2002:a92:d11:0:b0:30c:4c54:87f4 with SMTP id 17-20020a920d11000000b0030c4c5487f4mr3863963iln.3.1673977741099; Tue, 17 Jan 2023 09:49:01 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:00 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 23/70] bootstd: Add the concept of a bootdev hunter Date: Tue, 17 Jan 2023 10:47:33 -0700 Message-Id: <20230117174820.1281477-24-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Some bootdevs must be enumerated before they appear. For example, USB bootdevs are not visible until USB is enumerated. With standard boot this needs to happen automatically, since we only want to enumerate a bus if it is needed. Add a way to define bootdev 'hunters' which can be used to hunt for bootdevs of a given type. Track which ones have been used and add a command to list them. Include a clang work-around which seems to be needed. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 31 +++++++++++++++++++++++ cmd/bootdev.c | 35 +++++++++++++++++++++++--- include/bootdev.h | 58 +++++++++++++++++++++++++++++++++++++++++++ include/bootstd.h | 3 +++ test/boot/bootdev.c | 52 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+), 3 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 0ef3daf24cb..62eb0b617cd 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -636,6 +636,37 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) return 0; } +void bootdev_list_hunters(struct bootstd_priv *std) +{ + struct bootdev_hunter *orig, *start; + int n_ent, i; + + orig = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + + /* + * workaround for strange bug in clang-12 which sees all the below data + * as zeroes. Any access of start seems to fix it, such as + * + * printf("%p", start); + * + * Use memcpy() to force the correct behaviour. + */ + memcpy(&start, &orig, sizeof(orig)); + printf("%4s %4s %-15s %s\n", "Prio", "Used", "Uclass", "Hunter"); + printf("%4s %4s %-15s %s\n", "----", "----", "---------------", "---------------"); + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + + printf("%4d %4s %-15s %s\n", info->prio, + std->hunters_used & BIT(i) ? "*" : "", + uclass_get_name(info->uclass), + info->drv ? info->drv->name : "(none)"); + } + + printf("(total hunters: %d)\n", n_ent); +} + static int bootdev_post_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); diff --git a/cmd/bootdev.c b/cmd/bootdev.c index ecd797c0503..80bfe2812e4 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -107,14 +107,43 @@ static int do_bootdev_info(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } +static int do_bootdev_hunt(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct bootstd_priv *priv; + const char *spec = NULL; + bool list = false; + int ret = 0; + + if (argc >= 2) { + if (!strcmp(argv[1], "-l")) + list = true; + else + spec = argv[1]; + } + + ret = bootstd_get_priv(&priv); + if (ret) + return ret; + if (list) { + bootdev_list_hunters(priv); + } else { + /* TODO: implement hunting */ + } + + return 0; +} + #ifdef CONFIG_SYS_LONGHELP static char bootdev_help_text[] = - "list [-p] - list all available bootdevs (-p to probe)\n" - "bootdev select - select a bootdev by name | label | seq\n" - "bootdev info [-p] - show information about a bootdev (-p to probe)"; + "list [-p] - list all available bootdevs (-p to probe)\n" + "bootdev hunt [-l|] - use hunt drivers to find bootdevs\n" + "bootdev select - select a bootdev by name | label | seq\n" + "bootdev info [-p] - show information about a bootdev (-p to probe)"; #endif U_BOOT_CMD_WITH_SUBCMDS(bootdev, "Boot devices", bootdev_help_text, U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootdev_list), + U_BOOT_SUBCMD_MKENT(hunt, 2, 1, do_bootdev_hunt), U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootdev_select), U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootdev_info)); diff --git a/include/bootdev.h b/include/bootdev.h index 1e91d4130e7..cafb5285a28 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -11,6 +11,7 @@ struct bootflow; struct bootflow_iter; +struct bootstd_priv; struct udevice; /** @@ -33,6 +34,53 @@ enum bootdev_prio_t { BOOTDEVP_COUNT, }; +struct bootdev_hunter; + +/** + * bootdev_hunter_func - function to probe for bootdevs of a given type + * + * This should hunt around for bootdevs of the given type, binding them as it + * finds them. This may involve bus enumeration, etc. + * + * @info: Info structure describing this hunter + * @show: true to show information from the hunter + * Returns: 0 if OK, -ve on error + */ +typedef int (*bootdev_hunter_func)(struct bootdev_hunter *info, bool show); + +/** + * struct bootdev_hunter - information about how to hunt for bootdevs + * + * @prio: Scanning priority of this hunter + * @uclass: Uclass ID for the media associated with this bootdev + * @drv: bootdev driver for the things found by this hunter + * @hunt: Function to call to hunt for bootdevs of this type (NULL if none) + * + * Some bootdevs are not visible until other devices are enumerated. For + * example, USB bootdevs only appear when the USB bus is enumerated. + * + * On the other hand, we don't always want to enumerate all the buses just to + * find the first valid bootdev. Ideally we want to work through them in + * priority order, so that the fastest bootdevs are discovered first. + * + * This struct holds information about the bootdev so we can determine the probe + * order and how to hunt for bootdevs of this type + */ +struct bootdev_hunter { + enum bootdev_prio_t prio; + enum uclass_id uclass; + struct driver *drv; + bootdev_hunter_func hunt; +}; + +/* declare a new bootdev hunter */ +#define BOOTDEV_HUNTER(__name) \ + ll_entry_declare(struct bootdev_hunter, __name, bootdev_hunter) + +/* access a bootdev hunter by name */ +#define BOOTDEV_HUNTER_GET(__name) \ + ll_entry_get(struct bootdev_hunter, __name, bootdev_hunter) + /** * struct bootdev_uc_plat - uclass information about a bootdev * @@ -205,6 +253,16 @@ int bootdev_find_by_any(const char *name, struct udevice **devp); */ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp); +/** + * bootdev_list_hunters() - List the available bootdev hunters + * + * These provide a way to find new bootdevs by enumerating buses, etc. This + * function lists the available hunters + * + * @std: Pointer to bootstd private info + */ +void bootdev_list_hunters(struct bootstd_priv *std); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/include/bootstd.h b/include/bootstd.h index bd305094fdc..dddb3e15384 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -33,6 +33,8 @@ struct udevice; * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none * @theme: Node containing the theme information + * @hunters_used: Bitmask of used hunters, indexed by their position in the + * linker list. The bit is set if the hunter has been used already */ struct bootstd_priv { const char **prefixes; @@ -45,6 +47,7 @@ struct bootstd_priv { struct udevice **bootmeth_order; struct udevice *vbe_bootmeth; ofnode theme; + uint hunters_used; }; /** diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 1c2a79fb108..a8ca12a3c8f 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -221,3 +221,55 @@ static int bootdev_test_prio(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check listing hunters */ +static int bootdev_test_hunter(struct unit_test_state *uts) +{ + struct bootstd_priv *std; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + console_record_reset_enable(); + bootdev_list_hunters(std); + ut_assert_nextline("Prio Used Uclass Hunter"); + ut_assert_nextlinen("----"); + ut_assert_nextline("(total hunters: 0)"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check 'bootdev hunt' command */ +static int bootdev_test_cmd_hunt(struct unit_test_state *uts) +{ + struct bootstd_priv *std; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + console_record_reset_enable(); + ut_assertok(run_command("bootdev hunt -l", 0)); + ut_assert_nextline("Prio Used Uclass Hunter"); + ut_assert_nextlinen("----"); + ut_assert_nextline("(total hunters: 0)"); + ut_assert_console_end(); + + /* Scan all hunters */ + ut_assertok(run_command("bootdev hunt", 0)); + ut_assert_console_end(); + + /* List available hunters */ + ut_assertok(run_command("bootdev hunt -l", 0)); + ut_assert_nextlinen("Prio"); + ut_assert_nextlinen("----"); + ut_assert_nextline("(total hunters: 0)"); + ut_assert_console_end(); + + ut_asserteq(0, std->hunters_used); + + return 0; +} +BOOTSTD_TEST(bootdev_test_cmd_hunt, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_ETH_BOOTDEV); From patchwork Tue Jan 17 17:47:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727635 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fQQqLBme; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGlg53bSz23gH for ; Wed, 18 Jan 2023 04:55:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC07C856A1; Tue, 17 Jan 2023 18:51:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="fQQqLBme"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 081C88564E; Tue, 17 Jan 2023 18:49:15 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 0E6E68561D for ; Tue, 17 Jan 2023 18:49:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id p12so2790373ilq.10 for ; Tue, 17 Jan 2023 09:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2NT4ePm/QKBLhQjqT5ySkMrTcLaqbWq1JgCtzGJe+xk=; b=fQQqLBmepJwIIqhdi4AtupicSrp+roIy4pp5qI4tdnUpRWxJC0xJRoefzuPbcpNdPQ 43h/3xzJVOdQF57PYgCTb+p67osFXEzq1Dv3xtE04BHCujmSvLy+eq9XFZFGz1nhxb3T jzgFAkAY8RtNHA/CZdzw1Jp5xWw7xiinq5/00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2NT4ePm/QKBLhQjqT5ySkMrTcLaqbWq1JgCtzGJe+xk=; b=Y6qMk8kEwVSlfbLSY0q1zH5I2E+aHmja+YYV7qvwnp4Z/vRYuyDZWVaBSc1fIDzrBU rfk9Kum2bwnlRLaypkQ2JXLvcbsiqHJNsYRNxLPVtjCV59PM8ihBfRZclaajlf5F2FVy 1THQSVM0u1BoqxlqvUhA1SPfc7O2pihQIBWiDuGkRUkclMgnaaqJy20gB9g+YWOEQ2kk gEIhmo5MMy+MhwTC5Tf1jN2xI3lnk0huAGdLQej/U1x+5lTCv3EDEYJxci9w04IvOIJo we2trCwAHaHqkXvdkIu8P2iKeh6h3tEKyu04oyr7ShxPikW2rr7TxTyF9b5rAart26TG 1GJQ== X-Gm-Message-State: AFqh2kpY4IcRxJQNgpwUsoMHKyNbxo5rjiSrZI0uEyB1YHshCgoniGO4 SqLiBpxAeKlQKmwz6LGqTMg3/YGXUV1IcEVB X-Google-Smtp-Source: AMrXdXviY/nH+3Iy9bVpD9BObII61MM7SWQysuYQRzXfK4SwXIwEtfdOEzZRYivA9u8KM4djw3MG9w== X-Received: by 2002:a05:6e02:1aab:b0:30e:f07b:84ac with SMTP id l11-20020a056e021aab00b0030ef07b84acmr12552274ilv.19.1673977742226; Tue, 17 Jan 2023 09:49:02 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:01 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 24/70] bootstd: Support running bootdev hunters Date: Tue, 17 Jan 2023 10:47:34 -0700 Message-Id: <20230117174820.1281477-25-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a way to run a bootdev hunter to find bootdevs of a certain type. Add this to the 'bootdev hunt' command. Test for this are added in a later patch, since a useful test needs some hunters to work with. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 61 +++++++++++++++++++++++++++++++++++++++++++ cmd/bootdev.c | 7 ++++- include/bootdev.h | 14 ++++++++++ test/boot/bootdev.c | 3 +++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 62eb0b617cd..081b94ce332 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -636,6 +636,67 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) return 0; } +static int bootdev_hunt_drv(struct bootdev_hunter *info, uint seq, bool show) +{ + const char *name = uclass_get_name(info->uclass); + struct bootstd_priv *std; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return log_msg_ret("std", ret); + + if (!(std->hunters_used & BIT(seq))) { + if (show) + printf("Hunting with: %s\n", + uclass_get_name(info->uclass)); + log_debug("Hunting with: %s\n", name); + if (info->hunt) { + ret = info->hunt(info, show); + if (ret) + return ret; + } + std->hunters_used |= BIT(seq); + } + + return 0; +} + +int bootdev_hunt(const char *spec, bool show) +{ + struct bootdev_hunter *start; + const char *end; + int n_ent, i; + int result; + size_t len; + + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + result = 0; + + len = SIZE_MAX; + if (spec) { + trailing_strtoln_end(spec, NULL, &end); + len = end - spec; + } + + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + const char *name = uclass_get_name(info->uclass); + int ret; + + log_debug("looking at %.*s for %s\n", + (int)max(strlen(name), len), spec, name); + if (spec && strncmp(spec, name, max(strlen(name), len))) + continue; + ret = bootdev_hunt_drv(info, i, show); + if (ret) + result = ret; + } + + return result; +} + void bootdev_list_hunters(struct bootstd_priv *std) { struct bootdev_hunter *orig, *start; diff --git a/cmd/bootdev.c b/cmd/bootdev.c index 80bfe2812e4..28866faac76 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -128,7 +128,12 @@ static int do_bootdev_hunt(struct cmd_tbl *cmdtp, int flag, int argc, if (list) { bootdev_list_hunters(priv); } else { - /* TODO: implement hunting */ + ret = bootdev_hunt(spec, true); + if (ret) { + printf("Failed (err=%dE)\n", ret); + + return CMD_RET_FAILURE; + } } return 0; diff --git a/include/bootdev.h b/include/bootdev.h index cafb5285a28..deef7890489 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -263,6 +263,20 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp); */ void bootdev_list_hunters(struct bootstd_priv *std); +/** + * bootdev_hunt() - Hunt for bootdevs matching a particular spec + * + * This runs the selected hunter (or all if @spec is NULL) to try to find new + * bootdevs. + * + * @spec: Spec to match, e.g. "mmc0", or NULL for any. If provided, this must + * match a uclass name so that the hunter can be determined. Any trailing number + * is ignored + * @show: true to show each hunter before using it + * Returns: 0 if OK, -ve on error + */ +int bootdev_hunt(const char *spec, bool show); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index a8ca12a3c8f..45a00c34c0c 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -237,6 +237,9 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline("(total hunters: 0)"); ut_assert_console_end(); + ut_assertok(bootdev_hunt("mmc1", false)); + ut_assert_console_end(); + return 0; } BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); From patchwork Tue Jan 17 17:47:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727633 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HyD3q2iI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGlC74nSz23gH for ; Wed, 18 Jan 2023 04:55:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B60185690; Tue, 17 Jan 2023 18:51:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="HyD3q2iI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B639485605; Tue, 17 Jan 2023 18:49:13 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 446AF855E8 for ; Tue, 17 Jan 2023 18:49:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id a3so9811390ilp.6 for ; Tue, 17 Jan 2023 09:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n4Fmxr+OMBJg2QgGXaPinvsvD5h2Mna1okUVTg2hfus=; b=HyD3q2iIcpdoQ3sskILzIdjooTtlMhgZTUc1iYUwUGQpSLT4PziL171c9h28GbofJf ELI+bUiOcV5DC7VXRZqoHkSPitps8CvQn898YEsb/f+6EpDLOYwI/0LjwYjWSglvuJRc 239fS2Tqt9eP7HXsrnwDl/2KU3EeN5epPm3so= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n4Fmxr+OMBJg2QgGXaPinvsvD5h2Mna1okUVTg2hfus=; b=2LeMCsfk6ddoFko1YN5qpmae05leEXMXVkXBoVp1Yy/g74WSxBscFpAeiL+XR1DGaT 19M3Vb7UN36ANFBnjIyJ4CU9i2JkWzlX1DRoCTl0v6YHRMLSSRXesDZlSYLUKH4sZRjN /tGu6SEs/vpBUsLMpjd34TaNpoQKYj6P6ASJYkgodwbU0jK+c3M3XuefjfO7vgM4VK9s qxG2b+MDiE1HGKMPf7ZIOmB+5YV3uqXNx7VhhpyqxXftZchzH0ZBwBHf79AhIr4P5r6L 9kHuK+aQrj+gLguSfJ+kWLYrZQM9IYT+T8IPMxDO6aiR3ufhOtoiJ+pE2WeNmCSLzxwb AwIg== X-Gm-Message-State: AFqh2kqIeZG4UYIa2NS0D5TD/X8cByNHRyY4aF3vy2BupBJMTnuhYV/q k+PEO4xbnapZI8jnOLalV4x1Sp5GQ5Jac8rL X-Google-Smtp-Source: AMrXdXtbAm2pJ61HcjvZv1JltbOx9ejAduerHayZP7DJRd8BU68gagnJJXU8F1ndiQbWTYyBfRLhKw== X-Received: by 2002:a05:6e02:d46:b0:304:344:c61a with SMTP id h6-20020a056e020d4600b003040344c61amr3445726ilj.16.1673977743332; Tue, 17 Jan 2023 09:49:03 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:02 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass , Marek Vasut Subject: [PATCH v3 25/70] dm: usb: Mark the device name as alloced when binding Date: Tue, 17 Jan 2023 10:47:35 -0700 Message-Id: <20230117174820.1281477-26-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Since usb_find_and_bind_driver() allocates the device name it should tell driver about that, to avoid memory leaks. Fix this. Signed-off-by: Simon Glass --- (no changes since v1) drivers/usb/host/usb-uclass.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 93c318c3d1d..28f7ca9654d 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -563,6 +563,8 @@ static int usb_find_and_bind_driver(struct udevice *parent, if (!str) return -ENOMEM; ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp); + if (!ret) + device_set_name_alloced(*devp); error: debug("%s: No match found: %d\n", __func__, ret); From patchwork Tue Jan 17 17:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727676 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Lx3uelim; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGxG6b1wz23fT for ; Wed, 18 Jan 2023 05:04:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A027485616; Tue, 17 Jan 2023 18:59:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Lx3uelim"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 845FD855C7; Tue, 17 Jan 2023 18:50:29 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 11A89855D6 for ; Tue, 17 Jan 2023 18:49:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id m15so15769709ilq.2 for ; Tue, 17 Jan 2023 09:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K1kM7XygsFfkp8S/m/bBxnWmgr6md7to6ydzyAhfgKU=; b=Lx3uelimcBmTjgYjCGd02Xl/DUpsfTx2+0bFVYvtKbpDyMXUyK5rSYokv6XSvJnkDZ ORquRXW94wJG0GwGVE2CZyrx3Eso6z/yEzr3E3i6KbkGK+hBCUJp3XONAcuuHnEzlN/A 6Ey2M43M//sR3gdylpU20U1JVF7/YtUgEVshQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K1kM7XygsFfkp8S/m/bBxnWmgr6md7to6ydzyAhfgKU=; b=y2yccDBjV6WKFY1jhl08dsWne9m8y6YVUf/mD2aHBH8Id+tth4S08BGj8oEEfnBENx 5e7KnHetIeT7hxgCdEhPisIW/6Tp0F5fhsSBN+JK8OkuNVPFESW/AlUGGGI8iqC/nRhc uyl3ZfJGvTS1kJMeZM3eo1AsVPMrG5dgnOm6Ua5zpPNJxO/Oj9uPvyEvHJj5iM3XWqdq MmcuYOdiIsqo0ZHsdWpIkwkU32Yg8BVsd8beX34pfx2vbuDQXJr+VRFtN3U0AdpRm0Uw vDgur+yPXK2C29wRQX7IlZBs9yuYj4y7myOe+3CKSql+NpsHB+TgMx073rrd+uHbNL/k s8Ag== X-Gm-Message-State: AFqh2krGPzfxUg+7+FnNCJetaUCulG3zEs4Gud/kncwhWsAndi9m8VEK YJkriGgcf9PxfTg4B7NH2mnGcVJfSEFb63MT X-Google-Smtp-Source: AMrXdXtfM9oTFZJT/aWR4OB205TJbJ63DCKSb1APF+smFGqTuA0rS6YC846FYxPamF7p2K4iTWkNOQ== X-Received: by 2002:a92:60c:0:b0:305:e1f9:89b with SMTP id x12-20020a92060c000000b00305e1f9089bmr3277214ilg.24.1673977744330; Tue, 17 Jan 2023 09:49:04 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:03 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 26/70] test: Add a generic function to skip delays Date: Tue, 17 Jan 2023 10:47:36 -0700 Message-Id: <20230117174820.1281477-27-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this feature is sandbox-specific. For running tests on boards, we need a nop version. Add one. Signed-off-by: Simon Glass --- (no changes since v1) include/test/test.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/test/test.h b/include/test/test.h index beabe9333dc..752897cf06f 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -170,6 +170,22 @@ static inline int test_load_other_fdt(struct unit_test_state *uts) return ret; } +/** + * Control skipping of time delays + * + * Some tests have unnecessay time delays (e.g. USB). Allow these to be + * skipped to speed up testing + * + * @param skip_delays true to skip delays from now on, false to honour delay + * requests + */ +static inline void test_set_skip_delays(bool skip_delays) +{ +#ifdef CONFIG_SANDBOX + state_set_skip_delays(skip_delays); +#endif +} + /** * test_set_eth_enable() - Enable / disable Ethernet * From patchwork Tue Jan 17 17:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727675 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MJa/FYFG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGx070XTz23fT for ; Wed, 18 Jan 2023 05:04:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 197478566E; Tue, 17 Jan 2023 18:59:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="MJa/FYFG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9187D85626; Tue, 17 Jan 2023 18:50:29 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 E41B9855EE for ; Tue, 17 Jan 2023 18:49:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id v6so6224323ilq.3 for ; Tue, 17 Jan 2023 09:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AdBnzxRJ9ylPDcqUVoSrCV6c7Z/JCan9DYsCCl2/1h4=; b=MJa/FYFGT3kelYfXmttzPnv73rFiKDmk6paPUtM+smTGFyxV4mIQjUrSDeB8eiyJKi G6ooaUzvnTBiUlJ950/y1PMEToiGkVVuFVSGI+I3oGUvjx87t4VR/IhS8HQN2Yz1ntys n73ZDnRl1aPVEVeKTTGm3lhHr7SwNdpbbe6Bg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AdBnzxRJ9ylPDcqUVoSrCV6c7Z/JCan9DYsCCl2/1h4=; b=sbp9rO2tXfOY1sDJJYW3QjqpotnlPH5pRunzjrkvyhhUVnxdNK3SyPpt4PMWdLQeyr fY0uPaRjBHpWS9MEZaQq+t4yRyJcmn/oM8OWQXNw5NqLYzrEFQDEQYxv+rmAdmSEnrnK HcmXKvkNc4Oki4KmaBuynjyJTfbD6Bl7ZneM6ZKsJnibZPE0wcEn0m5iQlSPabxgm3/g cI8hhZYZXhvegaecDU76dk2ugWMeoYiKeC6Ln0uTSkSfw3NWUshIi4xhHGE1RAxFbUxW prl/UuSpZxYlxFyiXBhWDDV+B+gu/QOMrW/5qE1HBID+eOGJVbh7plWYIgDpU1AesQ4R TVGg== X-Gm-Message-State: AFqh2krlICUoZpzBsB7P+PL5CnljU9UngDT4f9lo4GXLNvw7YqTUmQki j1eJ2InOOWTxXh9slVto/P8UYhxOSUbAFpjT X-Google-Smtp-Source: AMrXdXsyD5dY2Z3j75B6PJW6IiBtiPqt94YPJOVSCUBorcLbtivPAIiwBSn6mMRpFk6WK8LQAcrnBA== X-Received: by 2002:a92:2809:0:b0:30e:e3b7:83d9 with SMTP id l9-20020a922809000000b0030ee3b783d9mr3764704ilf.20.1673977745331; Tue, 17 Jan 2023 09:49:05 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:04 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 27/70] bootstd: Add a USB hunter Date: Tue, 17 Jan 2023 10:47:37 -0700 Message-Id: <20230117174820.1281477-28-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a hunter for USB which enumerates the bus to find new bootdevs. Update the tests and speed up bootdev_test_prio() while we are here, by dropping the USB delays. Signed-off-by: Simon Glass --- (no changes since v1) drivers/usb/host/usb_bootdev.c | 12 ++++++++++++ test/boot/bootdev.c | 26 +++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c index b2d157faf33..66d0b6ae8f5 100644 --- a/drivers/usb/host/usb_bootdev.c +++ b/drivers/usb/host/usb_bootdev.c @@ -20,6 +20,11 @@ static int usb_bootdev_bind(struct udevice *dev) return 0; } +static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + return usb_init(); +} + struct bootdev_ops usb_bootdev_ops = { }; @@ -35,3 +40,10 @@ U_BOOT_DRIVER(usb_bootdev) = { .bind = usb_bootdev_bind, .of_match = usb_bootdev_ids, }; + +BOOTDEV_HUNTER(usb_bootdev_hunter) = { + .prio = BOOTDEVP_3_SCAN_SLOW, + .uclass = UCLASS_USB, + .hunt = usb_bootdev_hunt, + .drv = DM_DRIVER_REF(usb_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 45a00c34c0c..7a0c5793890 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -190,6 +190,8 @@ static int bootdev_test_prio(struct unit_test_state *uts) struct bootflow bflow; struct udevice *blk; + test_set_skip_delays(true); + /* Start up USB which gives us three additional bootdevs */ usb_started = false; ut_assertok(run_command("usb start", 0)); @@ -227,6 +229,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) { struct bootstd_priv *std; + test_set_skip_delays(true); + /* get access to the used hunters */ ut_assertok(bootstd_get_priv(&std)); @@ -234,12 +238,17 @@ static int bootdev_test_hunter(struct unit_test_state *uts) bootdev_list_hunters(std); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); - ut_assertok(bootdev_hunt("mmc1", false)); + ut_assertok(bootdev_hunt("usb1", false)); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); + ut_asserteq(GENMASK(0, 0), std->hunters_used); + return 0; } BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); @@ -249,6 +258,8 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) { struct bootstd_priv *std; + test_set_skip_delays(true); + /* get access to the used hunters */ ut_assertok(bootstd_get_priv(&std)); @@ -256,21 +267,26 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); /* Scan all hunters */ ut_assertok(run_command("bootdev hunt", 0)); + ut_assert_nextline("Hunting with: usb"); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); /* List available hunters */ ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 * usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); - ut_asserteq(0, std->hunters_used); + ut_asserteq(GENMASK(0, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727634 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZhP5dGA3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGlR3b1qz23gH for ; Wed, 18 Jan 2023 04:55:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8E546856C0; Tue, 17 Jan 2023 18:51:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="ZhP5dGA3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6C9A85605; Tue, 17 Jan 2023 18:49:14 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 48C88855F3 for ; Tue, 17 Jan 2023 18:49:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id h26so15738197ila.11 for ; Tue, 17 Jan 2023 09:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WVSeB6MC3RtGYKemeN/9YJ9pLiFK776X6Z+dvl7M8wo=; b=ZhP5dGA3qrOAXlcxPCMBIcslv98N7+u/iQMxLkJtbwJn2NjMejGJOPRdQDzL8FjEio VRA4+VjgbLpxhuj8XVpTnrRvSG1uQycUoTfVK1hYjOoTTeSvFW6N+c+Be8yR/zf4Y1yy K9DN0lqYf0fpNASo8KWyxTCfef5Mw3yrqTzd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WVSeB6MC3RtGYKemeN/9YJ9pLiFK776X6Z+dvl7M8wo=; b=UNzBL2VKCEZ+gR40g0wy1Q0K5OUlTLqVD9XiBUWiqV17q3B5j5pyjCEcEWQeMS+Vb4 YxoU1Q9YTpyWSbml2hQ6z4r1U4+ao6WobmyvT3N1Q/RgufTlGEZquHWBrrX8qpQILOmG LFwdPMjTh1fLPviWYYrerVx+krIgpi6+Q7jpbEfoaxIOuvUGl5j8ssbpRQsMXVx0kcVs G035uJK6lBdkJVJFbtume8SdCTpDnDhjbsE00ApAJZPdGxoXh0tLi43pk+4NXNtrRZtA dHnlXJJqvXxHZw4tTHbU/kDdKlrF4LiL1iYkmnP379Wjx11fooVE+XoDJYJU7yK69sJ7 o+rQ== X-Gm-Message-State: AFqh2koF9xSJDGwdQ1wFdCF3A/f1a5Q9TLHKLU7Zl4+ONjxCH2ht6b6P 8TCxXvJV/Txl7BdOyzXT6/DkLWuHo/loLwMy X-Google-Smtp-Source: AMrXdXvpF1vlke7jZwV7HkYW9CkF9PHTSEepMj5xDANolgMThd1UR9Lc0aC8XcNnB4C/u1pYURnkLQ== X-Received: by 2002:a05:6e02:12e8:b0:30e:f006:365 with SMTP id l8-20020a056e0212e800b0030ef0060365mr3849730iln.24.1673977746351; Tue, 17 Jan 2023 09:49:06 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:05 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 28/70] bootstd: Add an MMC hunter Date: Tue, 17 Jan 2023 10:47:38 -0700 Message-Id: <20230117174820.1281477-29-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a hunter for MMC. This doesn't do anything at present, since MMC is currently set up when U-Boot starts. If MMC moves to lazy init then we can add a hunter function. Signed-off-by: Simon Glass --- (no changes since v1) drivers/mmc/mmc_bootdev.c | 6 ++++++ test/boot/bootdev.c | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/mmc_bootdev.c b/drivers/mmc/mmc_bootdev.c index 037b67bc0ff..300208f0c71 100644 --- a/drivers/mmc/mmc_bootdev.c +++ b/drivers/mmc/mmc_bootdev.c @@ -35,3 +35,9 @@ U_BOOT_DRIVER(mmc_bootdev) = { .bind = mmc_bootdev_bind, .of_match = mmc_bootdev_ids, }; + +BOOTDEV_HUNTER(mmc_bootdev_hunter) = { + .prio = BOOTDEVP_0_INTERNAL_FAST, + .uclass = UCLASS_MMC, + .drv = DM_DRIVER_REF(mmc_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 7a0c5793890..78cb0ac628a 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -238,8 +238,9 @@ static int bootdev_test_hunter(struct unit_test_state *uts) bootdev_list_hunters(std); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); + ut_assert_nextline(" 10 mmc mmc_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 1)"); + ut_assert_nextline("(total hunters: 2)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -247,7 +248,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - ut_asserteq(GENMASK(0, 0), std->hunters_used); + /* USB is second in the list, so bit 1 */ + ut_asserteq(BIT(1), std->hunters_used); return 0; } @@ -267,12 +269,12 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 1)"); + ut_assert_skip_to_line("(total hunters: 2)"); ut_assert_console_end(); /* Scan all hunters */ ut_assertok(run_command("bootdev hunt", 0)); + ut_assert_nextline("Hunting with: mmc"); ut_assert_nextline("Hunting with: usb"); ut_assert_nextline( "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); @@ -282,11 +284,13 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); + ut_assert_nextline(" 10 * mmc mmc_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 1)"); + + ut_assert_nextline("(total hunters: 2)"); ut_assert_console_end(); - ut_asserteq(GENMASK(0, 0), std->hunters_used); + ut_asserteq(GENMASK(1, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727678 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=j+kQt41G; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGxj2KRVz23fT for ; Wed, 18 Jan 2023 05:04:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAEF7855EF; Tue, 17 Jan 2023 18:59:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="j+kQt41G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8B2B85103; Tue, 17 Jan 2023 18:59:10 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 C479485629 for ; Tue, 17 Jan 2023 18:49:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x136.google.com with SMTP id v6so6224370ilq.3 for ; Tue, 17 Jan 2023 09:49:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sXTNNBsONX1eD3Hc6ilO6Yqzy9Y14hMnKk1yOFakZnw=; b=j+kQt41GxrUtR50sl+U53mb67uxiSsviXOC58XMUPu2lUqJ05tgC7/xNTz+aFonwwP gGzK3/JgFTWyiU4Y3M1UuYFZg/SjdSFcHq8I7Wb4aQ1c5uQk+wVphBCskqzv9qHuyYci SGPHmulmlzoTQJh41VqgfOpC0FTKrFze7kmkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sXTNNBsONX1eD3Hc6ilO6Yqzy9Y14hMnKk1yOFakZnw=; b=yTS9J/EqOUXiVRhmiGknUld2Md1COMKgcDmgYtDtnfQulipdkyNQ9BCWNzS0aikB7W bs0szHD/2A5FdoOs6u6XGwyBlg1V1HeWOXeYCUAuAsW9tF4MXUswjgmdy/MrktB+F/tD idfPk485wbLjg+1V4LraMIcouKc8MMKxYqWvRlIN6YuTobD/ktx6AzETbVOX2huEZVzl JaqGbli02pDOyAfFx3FeEQNIPQOKghCRSjW2EvatXTeYNqoG8su3zDRrfbD+xLYMiWDG sQup0Jkrc3wdJSoeKHYnRETKF0jlEErp0aO2UkB2UM9jGOL5bjCcX74zLCTJnMHukybI wg9A== X-Gm-Message-State: AFqh2krvuzo2/DkSHUpjNnhoSBu70DfX2DbWNDcjg4UnhIKaylxYv5ny fYO45QTFK94ua7kzvp8lK807eEXjYV0axHIb X-Google-Smtp-Source: AMrXdXtr+Fp6T2NOOrW0Sb0zPWrvFQG+EuX/XkH31TlUvHOyd2LAcT/Iq0KjH9OzX/OLHzJIG/h+Eg== X-Received: by 2002:a92:d388:0:b0:30c:4edd:bd5 with SMTP id o8-20020a92d388000000b0030c4edd0bd5mr3370057ilo.17.1673977747440; Tue, 17 Jan 2023 09:49:07 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:07 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass , Ramon Fried , Joe Hershberger Subject: [PATCH v3 29/70] net: Add a function to run dhcp Date: Tue, 17 Jan 2023 10:47:39 -0700 Message-Id: <20230117174820.1281477-30-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this must be done by executing the command. Also it involves fiddling with the environment to determine the correct autoload behaviour. Ideally it should be possible to run network operations without even having the command line present (CONFIG_CMDLINE). For now, add a function to handle DHCP, so it can be called from a bootdev more easily. Signed-off-by: Simon Glass Reviewed-by: Ramon Fried --- (no changes since v1) cmd/net.c | 35 +++++++++++++++++++++++++++++++++++ include/net.h | 15 +++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/cmd/net.c b/cmd/net.c index dd50930a362..4227321871c 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -4,6 +4,8 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ +#define LOG_CATEGORY UCLASS_ETH + /* * Boot support */ @@ -13,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +123,38 @@ U_BOOT_CMD( "boot image via network using DHCP/TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]" ); + +int dhcp_run(ulong addr, const char *fname, bool autoload) +{ + char *dhcp_argv[] = {"dhcp", NULL, (char *)fname, NULL}; + struct cmd_tbl cmdtp = {}; /* dummy */ + char file_addr[17]; + int old_autoload; + int ret, result; + + log_debug("addr=%lx, fname=%s, autoload=%d\n", addr, fname, autoload); + old_autoload = env_get_yesno("autoload"); + ret = env_set("autoload", autoload ? "y" : "n"); + if (ret) + return log_msg_ret("en1", -EINVAL); + + if (autoload) { + sprintf(file_addr, "%lx", addr); + dhcp_argv[1] = file_addr; + } + + result = do_dhcp(&cmdtp, 0, !autoload ? 1 : fname ? 3 : 2, dhcp_argv); + + ret = env_set("autoload", old_autoload == -1 ? NULL : + old_autoload ? "y" : "n"); + if (ret) + return log_msg_ret("en2", -EINVAL); + + if (result) + return log_msg_ret("res", -ENOENT); + + return 0; +} #endif #if defined(CONFIG_CMD_NFS) diff --git a/include/net.h b/include/net.h index 759d4669df1..399af5e0645 100644 --- a/include/net.h +++ b/include/net.h @@ -65,6 +65,21 @@ struct in_addr { */ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +/** + * dhcp_run() - Run DHCP on the current ethernet device + * + * This sets the autoload variable, then puts it back to similar to its original + * state (y, n or unset). + * + * @addr: Address to load the file into (0 if @autoload is false) + * @fname: Filename of file to load (NULL if @autoload is false or to use the + * default filename) + * @autoload: true to load the file, false to just get the network IP + * @return 0 if OK, -EINVAL if the environment failed, -ENOENT if ant file was + * not found + */ +int dhcp_run(ulong addr, const char *fname, bool autoload); + /** * An incoming packet handler. * @param pkt pointer to the application packet From patchwork Tue Jan 17 17:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727638 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nEm1bjJM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGmN2MGJz23gH for ; Wed, 18 Jan 2023 04:56:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56222856A8; Tue, 17 Jan 2023 18:51:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="nEm1bjJM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D8858566D; Tue, 17 Jan 2023 18:50:34 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 0792285643 for ; Tue, 17 Jan 2023 18:49:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id 203so4582182iou.13 for ; Tue, 17 Jan 2023 09:49:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UoFLeV0Mjl15TUs2PaTBRmGb1+Cz/rmNtEMPjqERy5Q=; b=nEm1bjJMy+JMHXOqhSre3S7T8YcSKkOEHpa5jONUQi3t7Tr1i/2ZiBD+DHP43/wtnO 0stM1F4ZyqY0hD6xkWYDRHGGvsVW5DmPoHuSPnrG6Lkt/Tpyfg0sGGbbGIO16Y1BQZhO 1up5V9Vymm3b2BfPnq76Sj4l43aR5FAkQ/OoM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UoFLeV0Mjl15TUs2PaTBRmGb1+Cz/rmNtEMPjqERy5Q=; b=48/gqbAd7LQFHLvwXczpuutXVG+qSY76ISGhhPopxiNKe0Lomy+Ul1Hi3DKX8l4EOt FLgyTGzfRW14u5DTUk4ybxdGLP/xzQXXubMFj/Lzthfj+1opR28do5VXy3VUTm7diuZ0 OqbW4CgknQEgmqmmWu0HE4eq+dIk604Mv2goyCbH2VrvZ7VY/WI7T11qFS4fXszdYvCO SO8tQxEZ8SQxad1MXbfVmQAaplOjF9od/M51SlFwYn9Nr7EydJl4WdMUq+epN7yNWHe4 J6sGwQeiaGB+rGrniDnGqCWGV3/aJFUWiur3lgjONkBy8p3dMZhLnCWF35JbJgetyIXg JcrA== X-Gm-Message-State: AFqh2kqD3d+KFtHYMIjnltZwzrmThOCeiloKo5/F+m3AIy6uMWeGiZev mhIg/rshJpky0LZU0QGR4QLe/Bn4Sgypqvim X-Google-Smtp-Source: AMrXdXuOnxiovK9zeuhRej71tfcZLkineGftoouv3ywaU3Sd9Nt9aY6E46SldOYEusDte2LOUSncxA== X-Received: by 2002:a5e:db05:0:b0:704:b0a3:66a5 with SMTP id q5-20020a5edb05000000b00704b0a366a5mr2729592iop.15.1673977748497; Tue, 17 Jan 2023 09:49:08 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:08 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 30/70] bootstd: Add a hunter for ethernet Date: Tue, 17 Jan 2023 10:47:40 -0700 Message-Id: <20230117174820.1281477-31-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Sometimes ethernet devices are attached to PCI. Since it is quick to scan, add this into the ethernet hunter. Run dhcp to establish the network connection. Drop this from the bootdev since that is not needed now. Update a log message for clarity. Signed-off-by: Simon Glass --- (no changes since v1) net/eth_bootdev.c | 64 +++++++++++++++++++++++++++++---------------- test/boot/bootdev.c | 17 +++++++----- 2 files changed, 52 insertions(+), 29 deletions(-) diff --git a/net/eth_bootdev.c b/net/eth_bootdev.c index b735966d2bc..fdf48f00131 100644 --- a/net/eth_bootdev.c +++ b/net/eth_bootdev.c @@ -6,6 +6,8 @@ * Written by Simon Glass */ +#define LOG_CATEGORY UCLASS_BOOTSTD + #include #include #include @@ -13,8 +15,10 @@ #include #include #include +#include #include #include +#include static int eth_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, struct bootflow *bflow) @@ -41,30 +45,8 @@ static int eth_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, if (!bflow->name) return log_msg_ret("name", -ENOMEM); - /* - * There is not a direct interface to the network stack so run - * everything through the command-line interpreter for now. - * - * Don't bother checking the result of dhcp. It can fail with: - * - * DHCP client bound to address 192.168.4.50 (4 ms) - * *** Warning: no boot file name; using 'C0A80432.img' - * Using smsc95xx_eth device - * TFTP from server 192.168.4.1; our IP address is 192.168.4.50 - * Filename 'C0A80432.img'. - * Load address: 0x200000 - * Loading: * - * TFTP error: 'File not found' (1) - * - * This is not a real failure, since we don't actually care if the - * boot file exists. - */ - log_debug("running dhcp\n"); - run_command("dhcp", 0); - bflow->state = BOOTFLOWST_MEDIA; - /* See distro_pxe_read_bootflow() for the standard impl of this */ - log_debug("dhcp complete - reading bootflow with method %s\n", + log_debug("dhcp complete - reading bootflow with method '%s'\n", bflow->method->name); ret = bootmeth_read_bootflow(bflow->method, bflow); log_debug("reading bootflow returned %d\n", ret); @@ -83,6 +65,35 @@ static int eth_bootdev_bind(struct udevice *dev) return 0; } +static int eth_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + if (!test_eth_enabled()) + return 0; + + /* init PCI first since this is often used to provide Ehternet */ + if (IS_ENABLED(CONFIG_PCI)) { + ret = pci_init(); + if (ret) + log_warning("Failed to init PCI (%dE)\n", ret); + } + + /* + * Ethernet devices can also come from USB, but that is a higher + * priority (BOOTDEVP_5_SCAN_SLOW) than ethernet, so it should have been + * enumerated already. If something like 'bootflow scan dhcp' is used + * then the user will need to run 'usb start' first. + */ + if (IS_ENABLED(CONFIG_CMD_DHCP)) { + ret = dhcp_run(0, NULL, false); + if (ret) + return -EINVAL; + } + + return 0; +} + struct bootdev_ops eth_bootdev_ops = { .get_bootflow = eth_get_bootflow, }; @@ -99,3 +110,10 @@ U_BOOT_DRIVER(eth_bootdev) = { .bind = eth_bootdev_bind, .of_match = eth_bootdev_ids, }; + +BOOTDEV_HUNTER(eth_bootdev_hunt) = { + .prio = BOOTDEVP_4_NET_BASE, + .uclass = UCLASS_ETH, + .hunt = eth_bootdev_hunt, + .drv = DM_DRIVER_REF(eth_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 78cb0ac628a..32a31c44609 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -238,9 +238,10 @@ static int bootdev_test_hunter(struct unit_test_state *uts) bootdev_list_hunters(std); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); + ut_assert_nextline(" 50 ethernet eth_bootdev"); ut_assert_nextline(" 10 mmc mmc_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 2)"); + ut_assert_nextline("(total hunters: 3)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -248,8 +249,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is second in the list, so bit 1 */ - ut_asserteq(BIT(1), std->hunters_used); + /* USB is third in the list, so bit 2 */ + ut_asserteq(BIT(2), std->hunters_used); return 0; } @@ -269,11 +270,14 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 2)"); + ut_assert_skip_to_line("(total hunters: 3)"); ut_assert_console_end(); /* Scan all hunters */ + sandbox_set_eth_enable(false); + ut_assertok(run_command("bootdev hunt", 0)); + ut_assert_nextline("Hunting with: ethernet"); ut_assert_nextline("Hunting with: mmc"); ut_assert_nextline("Hunting with: usb"); ut_assert_nextline( @@ -284,13 +288,14 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); + ut_assert_nextline(" 50 * ethernet eth_bootdev"); ut_assert_nextline(" 10 * mmc mmc_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 2)"); + ut_assert_nextline("(total hunters: 3)"); ut_assert_console_end(); - ut_asserteq(GENMASK(1, 0), std->hunters_used); + ut_asserteq(GENMASK(2, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727637 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SxUnPZgP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGm76pmmz23gH for ; Wed, 18 Jan 2023 04:56:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 449EB85663; Tue, 17 Jan 2023 18:51:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="SxUnPZgP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 08492855D9; Tue, 17 Jan 2023 18:50:34 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 7641D855D3 for ; Tue, 17 Jan 2023 18:49:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id m15so15769829ilq.2 for ; Tue, 17 Jan 2023 09:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fWdvsKTTaLX7XFjmgJEA7bwdMT7A7EY+PrQFQ6rngn4=; b=SxUnPZgPXCWKW6bEV2bD4u05RDxm3ISQ05VGRwJzB0mhCajUyP8Jy/uTbojTfEMnXL RsHcWZ7AUqjvOLKW2xZ9lZTpbXc1fYMW6WIgKWLiXcDsERYpHXUP5tEEV1NGbsemmbKw oz8Ed7fVr+8wbDddPsdu8RqTmsGuLk94Agoog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fWdvsKTTaLX7XFjmgJEA7bwdMT7A7EY+PrQFQ6rngn4=; b=TkR/gVsY31QHGTQTV2jiNRv0vA514mPkXAMbML2d2uEE0OQaE6bb98VGgMCHhI6fbq eZX59kko7w2IHuny/czIVgXrqoh5/h/9eVVv3/U8DanatR9Dvd5hXElSvaudaM+sOVRQ ueTwfCAAXHJEkVo0VGV0in9CNQ4NW57qVPv3zSvTBozt2O4kHeFerU4O53mKCBX1eXZc SmJDwCR4k3Cf7yC7BJkOeR6YB/lN6Ie/PnM0vH3jl895YAaeWPjiMZSOff54FoJLxg88 vnDJkZ9QFgwxipaAMJgy4CSbwl6cp1UAwgTfmYlc2IsTaHA2kNveFxaSis/5nbhU/+zR wKFw== X-Gm-Message-State: AFqh2kqATgXJoCzC1CDeKTMJxNIuduxsXN2N5PmT+H3nFSshki8vloTz SfIJU83fTIz0Mmwe6Aua9XmnA0H3ZQCsMUNg X-Google-Smtp-Source: AMrXdXsYsODf5bLZBT4Kj8kSr1wqr+3C1Pzh+8lX2HrvHozLxpkOeOTWJrpYXgBtlgalWda1lRO9Mg== X-Received: by 2002:a92:dc4a:0:b0:30c:3ca2:3122 with SMTP id x10-20020a92dc4a000000b0030c3ca23122mr2589405ilq.21.1673977749635; Tue, 17 Jan 2023 09:49:09 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:09 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 31/70] part: Add a function to find the first bootable partition Date: Tue, 17 Jan 2023 10:47:41 -0700 Message-Id: <20230117174820.1281477-32-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean If a disk has a bootable partition we are expected to use it to locate the boot files. Add a function to find it. To test this, update mmc1 to have two paritions, fixing up other tests accordingly. Signed-off-by: Simon Glass --- (no changes since v1) disk/part.c | 16 ++++++++++++++++ include/part.h | 8 ++++++++ test/boot/bootflow.c | 6 +++--- test/dm/part.c | 13 +++++++++++++ test/py/tests/bootstd/mmc1.img.xz | Bin 4448 -> 4480 bytes test/py/tests/test_ut.py | 13 +++++++++---- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/disk/part.c b/disk/part.c index 5ee60a7fb59..d449635254e 100644 --- a/disk/part.c +++ b/disk/part.c @@ -770,3 +770,19 @@ void part_set_generic_name(const struct blk_desc *dev_desc, sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num); } + +int part_get_bootable(struct blk_desc *desc) +{ + struct disk_partition info; + int p; + + for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) { + int ret; + + ret = part_get_info(desc, p, &info); + if (!ret && info.bootable) + return p; + } + + return 0; +} diff --git a/include/part.h b/include/part.h index 807370d9429..be75c735495 100644 --- a/include/part.h +++ b/include/part.h @@ -303,6 +303,14 @@ part_get_info_by_dev_and_name_or_num(const char *dev_iface, } #endif +/** + * part_get_bootable() - Find the first bootable partition + * + * @desc: Block-device descriptor + * @return first bootable partition, or 0 if there is none + */ +int part_get_bootable(struct blk_desc *desc); + struct udevice; /** * part_create_block_devices - Create block devices for disk partitions diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 12976005e41..38ffe8fa9be 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -315,15 +315,15 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(BOOTFLOWST_FS, bflow.state); bootflow_free(&bflow); - /* Then more to partition 2 which doesn't exist */ - ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow)); + /* Then more to partition 2 which exists but is not bootable */ + ut_asserteq(-EPERM, bootflow_scan_next(&iter, &bflow)); ut_asserteq(2, iter.num_methods); ut_asserteq(0, iter.cur_method); ut_asserteq(2, iter.part); ut_asserteq(0x1e, iter.max_part); ut_asserteq_str("syslinux", iter.method->name); ut_asserteq(0, bflow.err); - ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BOOTFLOWST_PART, bflow.state); bootflow_free(&bflow); bootflow_iter_uninit(&iter); diff --git a/test/dm/part.c b/test/dm/part.c index b60687114f1..35e99eeb01a 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -93,3 +93,16 @@ static int dm_test_part(struct unit_test_state *uts) return ret; } DM_TEST(dm_test_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_part_bootable(struct unit_test_state *uts) +{ + struct blk_desc *desc; + struct udevice *dev; + + ut_assertok(uclass_get_device_by_name(UCLASS_BLK, "mmc1.blk", &dev)); + desc = dev_get_uclass_plat(dev); + ut_asserteq(1, part_get_bootable(desc)); + + return 0; +} +DM_TEST(dm_test_part_bootable, UT_TESTF_SCAN_FDT); diff --git a/test/py/tests/bootstd/mmc1.img.xz b/test/py/tests/bootstd/mmc1.img.xz index 4e7f39b830eb4bddcb9ff6df39e89f130b5706b9..cebf7b9c53b3ed2370dbc65f0d26dd9bf096fab8 100644 GIT binary patch delta 1655 zcmV--28j9KB7h@*{Wp48S^xk9=GL@E0stWa8~^|S5YJf5|NmMBd|dzlZ~gpA<{Uz| zzgb+hQv3zT1yKgH@;2zWF3PJ~6cavY@U&ANJ0gCP@g^CK!(rj@H-&MG2+zt#VrMq1 z-bKm%b2F*>ab%+I**3@5=eRQUvo=zPEG1lh0FMJM7*2m;f5_u>M)rb8W}+Uqf+ks) z_#_Lj9#uBA9K(VBR-_^mmJcn)WfTd{;~te;2sbZTUWEL8Ce`b-Jt10-wlVDTu17Rv z4VaVs=u)K>0j21p2`cQW|5_%jats!dr@lFlB;k`$3txXy+a#DV!4|8tN&)+Lh{XiP zVol6p;1;M=YgT!hV3^xhq6kT^pvtCdcsw##ssXd#S4+B)%GmE^iJuWCu6oZ}pJD9s z`5K;^&Q>pwgZ@W#?43SjFfDh&0r#>&hl5~mNbUgZ8U1#x{hSCvZikVj1k;>{8^d^7 zLg>&U@uq9E$6xZvh&l$FOl?xq{b&{NB=g?qmeFk5cgCCIZ?CrYEJ-LLMpd6h)hC=q zzRSVQ!8553c{1arJOgZG`#wznKO7b7FMmwg$LxREB*TT&O>G`dqd^Ih93Z#d-K*=) zB)cm55`*cT+@1Ydj{@IW@FEnmg>)#(gV4|lVc9LZ64Ot3r`x`b9TwuPQS117K6VKm zl4s4)`kLs1X`71Z@E(8n)q_&iJAu zxrcxBv2_h4N#VeAIVRirRLy0xDeR^;;Vt?=n$Td*Al4sMA_xLBPMEI_h7m8eKclnG!mg*6f3@RV!!Dy zYU+!M?VT~mD+f6->%5e(H(O~9j2-0lS3Zz)dxe0S#EnU;TS z1+1Ngg5l(_;}GfW7P-o32Rt7w0p$R@00nGCgd@1H>W z>mvvhif|1nW{sZiRe4N<^SQN<<#+#?0AH6Dij6NKGjqrw3#H*wc1Om*DX%Y_j=q%{ zXCpEp3>^z@l5blk3EN&soj}hZr(J*5Kyt+`2QqO39ZhCv?^TkQZF(NvEooQvZb5YQ2_Ok;$%a*I2t@M5()&$Q zuV=`l72@)HIyule&bL9;-q&H&xA3Xxc|8DS`hJ-e^zB)(=ryl3L>8eKYJh+Ke!cK( zwmHfOzQ8A%A?^JQAX0xp!To?PeLc@XvxgAG7QpKBDB5$%SMwfIwI>kGz&<(}KCq79 z_uig^In$u^bS?|I(*e!CouC=N%slEv86cwifl_Dsu3QefK_gtT&7j@j63>@_2q)R4 zrZV2K-w`h{0zYK~I_WYrIP0NLdKl+jI3O9iA8VaviOYeV( zTKFljND&c=eUd343kD+Rb078iL#ms`bg7moAG7Pd;l?P40x+rM2QzGdz?dmEn*GYUkzwP^7jB&Wh zfS-SG_@D&{8E!xrxM!T zJ!haq_%|(J-Rp9)}RPcy(EHK-`P*jm3mj(l0$#6Rqz%nYslFG5fXZr#G00004Sz0zM B8fpLl delta 1580 zcmV+{2GjX~Bj6%`{Wp48S^xk9=GL@E0stWa761SMbT8$j|Nr9#SzQ1CZ~gp9mywT@ zX9SH~J$HQgn~xH8r*R%x@0<=h+lgT<_xrs-znV_419+K~}pr5i6t;;X5H=eceQvOcz_m&Of`5M?JgubSFnsOe+W}JM1vca*@H`m~N2QSki3RrWs?u`efk)`Q z1I4j(WS_wYySbVdeqbLrhyrft+P^Wzf571<6mAn+(ayStI^6-?9Fj{Gs}2-@F;yAl zAQOk)7XLbruq4a2$s4F#dasOsO^R3gu)9P6O%UzUxh^V$sh<-dfsA}`+boMeRiGPY zHb_fTFwNahDhgBW3n>8?}IRO(WSH}POQ<0wl zF!z5*OIwmO-cwSxzreS*!N~4_jW?h<+JIB;zC;lmb+LP&V;{_Lr_1Kndj zqC4_Y7L)_}b=v{EpiRcl{@ z(6s$?Vc$rX3-Bu2_dtb&zY9Uk?{0C)>TF*|z{)b5M>QOyU2(e%>yohpf1>1(R#|F^Hc-17;yAyM~LkW#W2`CT75_U7J zxojLkA%oKe7gYnM614d2W`i%suCVf(9QPuGO$GLNTPdH0EpA*&OIR~b2Pe~|1|4#c*3#T*fO7SGKF^YW7GpTbWD$R-k(a zP`C~@itq8#G#Cb%4OWwphP_No3N9VoqQpA$)fAzcK!YH%-PC0q) zHc`?8x(xn~H?y)XqTn)90O>*@{&pI95tQm6NY}2?gPsKGDD<4lc)Q;-uK& zVRB7!Xz7-)wq(Y*`$x=Rkg26+lHFQf>(vzXE8oiK$7v@B;nPh! zb5^(04D6|me}<(ne=-;Z8cFKLTNA**CxYb+d4!i%?T|pB7!QfT59)C$75dFOasor+ zrB5HUPWpVffF-(L69owH?ird#UnAH>E%?|nRP5f!k?8w3fe<1V|2OGJ9m;yqxw)m> zHooGc=ROmb$F15b2C5~M%n1-@A$}(cds-s8=12K?Z3JJadoXCDN)@Dot{Yl< zdq^?V9nxMDrw#2SM@Xeo;Gh1K0t`TUEtkL!x_NFC(EMPASHtlBC;wb<9CV}n5={?B zq3451GV+&de{TMM-hczKl26E4EHe`3n&yWhCX?@KX`(lZlX0TZV?Zj5_|v|NqU@l7 zm;}ZS?8YON!pN()9pDTEVzXKJbDDG1gk8N?HvAmPpT|AQ-syX5hWnN{b>b=Ktj(Lo zE@t+o7-y~t`5t!!)3~}CU2nmN3!7;VkF^Hmj1c#Ao{g000001X)@WZu`Cf diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 6958fabfa34..e8c8a6d6bd5 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -19,13 +19,14 @@ def mkdir_cond(dirname): if not os.path.exists(dirname): os.mkdir(dirname) -def setup_image(cons, mmc_dev, part_type): +def setup_image(cons, mmc_dev, part_type, second_part=False): """Create a 20MB disk image with a single partition Args: cons (ConsoleBase): Console to use mmc_dev (int): MMC device number to use, e.g. 1 part_type (int): Partition type, e.g. 0xc for FAT32 + second_part (bool): True to contain a small second partition Returns: tuple: @@ -36,9 +37,13 @@ def setup_image(cons, mmc_dev, part_type): mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') mkdir_cond(mnt) + spec = f'type={part_type:x}, size=18M, bootable' + if second_part: + spec += '\ntype=c' + u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname) u_boot_utils.run_and_log(cons, 'sudo sfdisk %s' % fname, - stdin=f'type={part_type:x}'.encode('utf-8')) + stdin=spec.encode('utf-8')) return fname, mnt def mount_image(cons, fname, mnt, fstype): @@ -59,7 +64,7 @@ def mount_image(cons, fname, mnt, fstype): u_boot_utils.run_and_log(cons, f'sudo mkfs.{fstype} {part}') opts = '' if fstype == 'vfat': - opts += ' -o uid={os.getuid()},gid={os.getgid()}' + opts += f' -o uid={os.getuid()},gid={os.getgid()}' u_boot_utils.run_and_log(cons, f'sudo mount -o loop {part} {mnt}{opts}') u_boot_utils.run_and_log(cons, f'sudo chown {getpass.getuser()} {mnt}') return loop @@ -218,7 +223,7 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} def setup_bootflow_image(cons): """Create a 20MB disk image with a single FAT partition""" mmc_dev = 1 - fname, mnt = setup_image(cons, mmc_dev, 0xc) + fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True) loop = None mounted = False From patchwork Tue Jan 17 17:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727639 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=A94GGr5d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGmc1Z3xz23gH for ; Wed, 18 Jan 2023 04:56:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4252E85695; Tue, 17 Jan 2023 18:51:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="A94GGr5d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 043D285676; Tue, 17 Jan 2023 18:50:36 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 C17768563D for ; Tue, 17 Jan 2023 18:49:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2c.google.com with SMTP id z194so3423046iof.10 for ; Tue, 17 Jan 2023 09:49:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RLKxfZKtnJazsruiexCxFeH4PrM8J9y4jlbjv4kfNqQ=; b=A94GGr5d/pbuXoI4VTHZYcxcqpw5jb9wW5sJ/BzfJeRM35rhA4TtsQIQgJsmbzBPPg 1wmonyuGarNdNd3aSulHHrEh0Tj22dQ7oqTWA+GpDKTHRVSFKSVv0BhAAqS32OYFcsek v+2pd+dmxr80QmlUsIYzX5D/IIGzODVk9iQvY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RLKxfZKtnJazsruiexCxFeH4PrM8J9y4jlbjv4kfNqQ=; b=W2B5sBhD5Nz8AMU92ORDRy+AE7qVnjaql2mMy1ObGAVqJ3j+ep6IHCGROKGD+zBSHX e/T4IxdMtsk+BONrxi2iUe9BEA5Omq2Xl9jRy6oh3SQ5G845+niBItL8CuP7vyfTDP8a A7rXarIVzmCHDp8qWqIi7y6C47ZqqR2pEjFjYVGQwniwMoUatD6p3ALWwHeVnJhV7Hm+ YfylDx0akn/sgrXXnVrBiuOxmA7PcDMYB04Pf4mnn/sTqTep256UH89T1BmyZiL7df/j PVqomD/pUP/yz7BaPtmiTNYu3NdeAaU+P0ZSkNRePbypzwoS+U/ua0mprgwzMLdZlNVp s+/Q== X-Gm-Message-State: AFqh2kpn3P9HFewzuWzw6hWnHROgXuh0gOI3xfzVDtb7uXbww2EWuGNF I3+dXoTSJRjWjV/l/33jAiKKBnbl9pvEDgaE X-Google-Smtp-Source: AMrXdXupmZ0DbbWkROr3Pr06L9ymxJwAy/xyOAijN5McX516wPpY6KO4GMYbWX5l97cKl6SnSUY38w== X-Received: by 2002:a05:6602:2d86:b0:6df:5b14:61ee with SMTP id k6-20020a0566022d8600b006df5b1461eemr4450757iow.5.1673977750925; Tue, 17 Jan 2023 09:49:10 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:10 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 32/70] bootstd: Only scan bootable partitions Date: Tue, 17 Jan 2023 10:47:42 -0700 Message-Id: <20230117174820.1281477-33-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present all partitions are scanned, whether marked bootable or not. Use only bootable partitions, defaulting to partition 1 if none is found. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 10 +++++++++- include/bootflow.h | 2 ++ test/boot/bootdev.c | 37 +++++++++++++++++++++++++++++++++++++ test/boot/bootflow.c | 4 ++-- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 081b94ce332..3dcf317c150 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -163,7 +163,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, */ iter->max_part = MAX_PART_PER_BOOTDEV; - if (iter->part) { + /* If this is the whole disk, check if we have bootable partitions */ + if (!iter->part) { + iter->first_bootable = part_get_bootable(desc); + log_debug("checking bootable=%d\n", iter->first_bootable); + + /* if there are bootable partitions, scan only those */ + } else if (iter->first_bootable ? !info.bootable : iter->part != 1) { + return log_msg_ret("boot", -EINVAL); + } else { ret = fs_set_blk_dev_with_part(desc, bflow->part); bflow->state = BOOTFLOWST_PART; diff --git a/include/bootflow.h b/include/bootflow.h index c201246c6de..3a93e4b5cab 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -123,6 +123,7 @@ enum bootflow_flags_t { * @method: Current bootmeth * @max_part: Maximum hardware partition number in @dev, 0 if there is no * partition table + * @first_bootable: First bootable partition, or 0 if none * @err: Error obtained from checking the last iteration. This is used to skip * forward (e.g. to skip the current partition because it is not valid) * -ESHUTDOWN: try next bootdev @@ -144,6 +145,7 @@ struct bootflow_iter { int part; struct udevice *method; int max_part; + int first_bootable; int err; int num_devs; int cur_dev; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 32a31c44609..db0e0ca20fa 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -301,3 +301,40 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) } BOOTSTD_TEST(bootdev_test_cmd_hunt, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); + +/* Check that only bootable partitions are processed */ +static int bootdev_test_bootable(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootflow bflow; + struct udevice *blk; + + memset(&iter, '\0', sizeof(iter)); + memset(&bflow, '\0', sizeof(bflow)); + iter.part = 0; + ut_assertok(uclass_get_device_by_name(UCLASS_BLK, "mmc1.blk", &blk)); + iter.dev = blk; + ut_assertok(device_find_next_child(&iter.dev)); + uclass_first_device(UCLASS_BOOTMETH, &bflow.method); + + /* + * initially we don't have any knowledge of which partitions are + * bootable, but mmc1 has two partitions, with the first one being + * bootable + */ + iter.part = 2; + ut_asserteq(-EINVAL, bootdev_find_in_blk(iter.dev, blk, &iter, &bflow)); + ut_asserteq(0, iter.first_bootable); + + /* scan with part == 0 to get the partition info */ + iter.part = 0; + ut_asserteq(-ENOENT, bootdev_find_in_blk(iter.dev, blk, &iter, &bflow)); + ut_asserteq(1, iter.first_bootable); + + /* now it will refuse to use non-bootable partitions */ + iter.part = 2; + ut_asserteq(-EINVAL, bootdev_find_in_blk(iter.dev, blk, &iter, &bflow)); + + return 0; +} +BOOTSTD_TEST(bootdev_test_bootable, UT_TESTF_DM | UT_TESTF_SCAN_FDT); diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 38ffe8fa9be..f852b6e9b6f 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -316,14 +316,14 @@ static int bootflow_iter(struct unit_test_state *uts) bootflow_free(&bflow); /* Then more to partition 2 which exists but is not bootable */ - ut_asserteq(-EPERM, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(-EINVAL, bootflow_scan_next(&iter, &bflow)); ut_asserteq(2, iter.num_methods); ut_asserteq(0, iter.cur_method); ut_asserteq(2, iter.part); ut_asserteq(0x1e, iter.max_part); ut_asserteq_str("syslinux", iter.method->name); ut_asserteq(0, bflow.err); - ut_asserteq(BOOTFLOWST_PART, bflow.state); + ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); bootflow_free(&bflow); bootflow_iter_uninit(&iter); From patchwork Tue Jan 17 17:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727659 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=kMJtWfL5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGsC6Mn8z23fT for ; Wed, 18 Jan 2023 05:00:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6064A85709; Tue, 17 Jan 2023 18:51:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="kMJtWfL5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BABA0855EE; Tue, 17 Jan 2023 18:50:49 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 A10B685642 for ; Tue, 17 Jan 2023 18:49:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd29.google.com with SMTP id p66so15253000iof.1 for ; Tue, 17 Jan 2023 09:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2JNqwIu5G8Xprwyee+Ne/5ympwEBrJ/V1WuKITf3Ca0=; b=kMJtWfL5hwvwioV1T5/eh2x3DwOe6wJi0UE0xPav3ZpNeNsTx5iVpvKL0jObAgn9Zl J5xhuslfTw0rR+zpu+fPX93Rx0oO7+L+IBX7zqJWjVYaYkaIiSZguhpZl+bt59dIAuSh 09Royrdo4X4LRhZwQefiPWmdGUviC7SGxoniY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2JNqwIu5G8Xprwyee+Ne/5ympwEBrJ/V1WuKITf3Ca0=; b=fN8ORW5ytlb2vpD8GvRs1ymeYXmiCcJ42jyjCLkgc6VTiPVNPfhRJFZFW6cdnDtdH9 M8ky+RknYNAWdDEl4BI8rQz9Qqs39D5kJPcyMBh1aRX5fCtDfvQ3pr3w/HYcmrtWjz0a lhX0/SJtyX9pyy4jeO9WVD4iYy2rZAHU3SYwmw9ooy+lNu7sSrOF9+vp6IevRtMQMy/c pa4b6IEhMBKJp6qrIlkbFUWJ7t/wYITi7DaeEvRjlQnTyINpWTETnZDLyd/rMsG+LF30 VWaGGhMLAckTWk2FNBYzjBLLK73rc5ZTesOpfgRvKIvjLH+tpfm/u4Onqe6AmahCRPDh RqMw== X-Gm-Message-State: AFqh2koNPPXbfIgVjhIufVOZv+BiFWt9Ryinx8gpoaT49n2KE9ECd8Lw pexRuJLrL6+onOiqaZuhGKcUzWOAkJHY8yqu X-Google-Smtp-Source: AMrXdXt3lrhPIrpSfhkAq2+dCh4v0Q/lEgZwGziPRLC5ep0c1cSjumDOJLbtW7dg4CEXNNF2npH7Sg== X-Received: by 2002:a6b:e406:0:b0:704:c568:d8cc with SMTP id u6-20020a6be406000000b00704c568d8ccmr2949167iog.8.1673977752030; Tue, 17 Jan 2023 09:49:12 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:11 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 33/70] scsi: Correct allocation of block-device name Date: Tue, 17 Jan 2023 10:47:43 -0700 Message-Id: <20230117174820.1281477-34-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This should be allocated so that it does not go out of scope. Fix this and set the log category while we are here. Signed-off-by: Simon Glass --- (no changes since v1) drivers/scsi/scsi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index a020a7da23a..f7add08db86 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -4,6 +4,8 @@ * Denis Peter, MPL AG Switzerland */ +#define LOG_CATEGORY UCLASS_SCSI + #include #include #include @@ -558,7 +560,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) struct udevice *bdev; struct blk_desc bd; struct blk_desc *bdesc; - char str[10]; + char str[10], *name; /* * detect the scsi driver to get information about its geometry (block @@ -574,12 +576,16 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) * block devices created */ snprintf(str, sizeof(str), "id%dlun%d", id, lun); - ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1, + name = strdup(str); + if (!name) + return log_msg_ret("nam", -ENOMEM); + ret = blk_create_devicef(dev, "scsi_blk", name, UCLASS_SCSI, -1, bd.blksz, bd.lba, &bdev); if (ret) { debug("Can't create device\n"); return ret; } + device_set_name_alloced(bdev); bdesc = dev_get_uclass_plat(bdev); bdesc->target = id; From patchwork Tue Jan 17 17:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727663 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PYOPEItB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGtC6xlZz23fT for ; Wed, 18 Jan 2023 05:01:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 387D185712; Tue, 17 Jan 2023 18:52:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="PYOPEItB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF7EC8568E; Tue, 17 Jan 2023 18:50:59 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 BFF5984231 for ; Tue, 17 Jan 2023 18:49:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15757075ila.4 for ; Tue, 17 Jan 2023 09:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lAd6F9zH3Cs08O22Zn2ZK4F2u4LAES2eDejaYh2j/OA=; b=PYOPEItBEqDQXtrw99RnZ9XDnMNfrM3V3ZM4qSct/ifQicubxzXCqPTncDwYpIG7sC qAU0jBdzT7Iobf027yISW1NMotdR3Tvj9DEgkuq5bDUg62bOpk7N9GgwiGgsT8AYnx79 o+wtBNuf56W7n1dwN5XqWOzwEaVALZ2AnOckE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lAd6F9zH3Cs08O22Zn2ZK4F2u4LAES2eDejaYh2j/OA=; b=YNm10/mPIBP7b2emg33ELIGYSiK7RdJ0tPYg93NKJzvUrEAO3sAx9rdCZCJwC58+O5 fHnz4O++zJN8RiqQ+fpYuE8aJzPDRo6ArZ8Z3i1RSRIylROQ1wUOnbtxtDXitUOIWcao V4D0LfXgKPPx5xsy4T2hjtJ4jyvgU9KkRX+mmr2+MzwZGARooVyfSIFSFaPz6Xkm5TpV mENLKUivqTKABK38OSCzv7Q6Jmi696uCR1X7vRyeU++TGzaRfn9GsqB1OfjmHS9QjgFz 8597WIhhrZsf9YJsG70i3ACW0YxhMqtJoveaDIppriIaA8PDw9NboxCzVjQ/vNAqXq+Q VyGQ== X-Gm-Message-State: AFqh2krU2AE61CmUChwy20suioRfxinQHSulrwC0cu1PDwfWf+gqgAJi /8ULkdY065iJK37QWco5bLcSWqOyIVEz+QOb X-Google-Smtp-Source: AMrXdXse+1M1ULEw7sMB5SyabVefEfaOsQcRHVVFflOi2BHKJDIeXFoZhyom8vpW7skvHCIlj2XDIA== X-Received: by 2002:a05:6e02:1beb:b0:302:a938:81ce with SMTP id y11-20020a056e021beb00b00302a93881cemr4153353ilv.13.1673977753056; Tue, 17 Jan 2023 09:49:13 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:12 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 34/70] scsi: Remove all children of SCSI devices before rescanning Date: Tue, 17 Jan 2023 10:47:44 -0700 Message-Id: <20230117174820.1281477-35-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this only unbinds block devices of a certain type. But SCSI device can have different types of children, including bootdevs. Unbind all children so tht everything is clean and ready for a new scan. Signed-off-by: Simon Glass --- (no changes since v1) drivers/scsi/scsi.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index f7add08db86..4a2d8d009a6 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -644,12 +644,23 @@ int scsi_scan(bool verbose) if (verbose) printf("scanning bus for devices...\n"); - blk_unbind_all(UCLASS_SCSI); - ret = uclass_get(UCLASS_SCSI, &uc); if (ret) return ret; + /* remove all children of the SCSI devices */ + uclass_foreach_dev(dev, uc) { + log_debug("unbind %s\n", dev->name); + ret = device_chld_remove(dev, NULL, DM_REMOVE_NORMAL); + if (!ret) + ret = device_chld_unbind(dev, NULL); + if (ret) { + if (verbose) + printf("unable to unbind devices (%dE)\n", ret); + return log_msg_ret("unb", ret); + } + } + uclass_foreach_dev(dev, uc) { ret = scsi_scan_dev(dev, verbose); if (ret) From patchwork Tue Jan 17 17:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727677 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Tpjuh4uA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGxT27N7z23fT for ; Wed, 18 Jan 2023 05:04:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F19185103; Tue, 17 Jan 2023 18:59:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Tpjuh4uA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A9BF6855F2; Tue, 17 Jan 2023 18:59:07 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 F27E885624 for ; Tue, 17 Jan 2023 18:49:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15757101ila.4 for ; Tue, 17 Jan 2023 09:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uFODEcbWcSX9Dw1qNnYub+qfU8IbsdhNeYeayX4AhU4=; b=Tpjuh4uAvwUa1xTQ/9r1nzBWd1vQvE7/BbL5Rr4dlP2dm3/FbAjWhLYDWCYBTS1Dlg a3/Hr2TA7kJ7cSl19BSpZ4fiSR3NNxHJCQe/XZ/j87FGW9ekPysmgYl/DG/JalBLApR8 bTkB2m4ZKC+PXW25yTRccycH3BThmKfSkqnBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uFODEcbWcSX9Dw1qNnYub+qfU8IbsdhNeYeayX4AhU4=; b=TdhlAxG5ZkvtFUFSBdkG6NOvFDF7hm2zK3FpjuN+42230GYJz7AgOsM6dPhfkDBCyR tGDADJ0gWjBlf9VpU5wXODDNoZASrn3Tg4VqHoGTtRxQ1pwXCgrWvgmgodL+Ku11MEMr MoV8YBZJoQq0b/8NUSQqOqSl79T9pthrHqP8sAKhxhUDrsaMzX5gnUGmk1+NwpcP2NBf wi4TogMrUJV3kKwkoSKg8c88QyUuA4KkA5uVNaA+YWem8TUaeuq6VN86UdVF3e3Kgj74 GjOxvjsVuM83RSVjP3jSq009jLuvFMFQBqBAfLWGPQg+aGKnIgugNU1VpM7NeyvwVrKZ wx9Q== X-Gm-Message-State: AFqh2krLha5sYJ+OfXSzeWVlSiuMu7XqIgR4Qke5WS4RInc1TH+oaeXY WIWL94g1yk4c1s6BtRI6gvfSsGulqcjsQFAW X-Google-Smtp-Source: AMrXdXvukmdA5jDj3PHLHdI/OKgAH4rsN4zOClmaYbyxuoScSNkCpmXKION/YdXRdqZi7eGtNIImOw== X-Received: by 2002:a92:50d:0:b0:30c:233f:1d73 with SMTP id q13-20020a92050d000000b0030c233f1d73mr17608330ile.28.1673977754053; Tue, 17 Jan 2023 09:49:14 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:13 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 35/70] bootstd: Add a SCSI bootdev Date: Tue, 17 Jan 2023 10:47:45 -0700 Message-Id: <20230117174820.1281477-36-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev for SCSI so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- (no changes since v1) drivers/scsi/Makefile | 7 +++++ drivers/scsi/scsi.c | 7 ++++- drivers/scsi/scsi_bootdev.c | 62 +++++++++++++++++++++++++++++++++++++ test/boot/bootdev.c | 18 ++++++----- 4 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 drivers/scsi/scsi_bootdev.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index d1b40c61401..d8d6de59090 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -6,6 +6,13 @@ ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DM_SCSI) += scsi-uclass.o obj-$(CONFIG_SCSI) += scsi.o + +ifdef CONFIG_SCSI +ifdef CONFIG_DM_SCSI +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += scsi_bootdev.o +endif +endif + endif ifdef CONFIG_SPL_BUILD diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 4a2d8d009a6..6caeb3fcdd0 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -604,7 +605,11 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) ret = blk_probe_or_unbind(bdev); if (ret < 0) /* TODO: undo create */ - return ret; + return log_msg_ret("pro", ret); + + ret = bootdev_setup_sibling_blk(bdev, "scsi_bootdev"); + if (ret) + return log_msg_ret("bd", ret); if (verbose) { printf(" Device %d: ", bdesc->devnum); diff --git a/drivers/scsi/scsi_bootdev.c b/drivers/scsi/scsi_bootdev.c new file mode 100644 index 00000000000..2367b33da9c --- /dev/null +++ b/drivers/scsi/scsi_bootdev.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Bootdevice for USB + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +static int scsi_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_2_SCAN_FAST; + + return 0; +} + +static int scsi_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + if (IS_ENABLED(CONFIG_PCI)) { + ret = pci_init(); + if (ret) + return log_msg_ret("pci", ret); + } + + ret = scsi_scan(true); + if (ret) + return log_msg_ret("scs", ret); + + return 0; +} + +struct bootdev_ops scsi_bootdev_ops = { +}; + +static const struct udevice_id scsi_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-scsi" }, + { } +}; + +U_BOOT_DRIVER(scsi_bootdev) = { + .name = "scsi_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &scsi_bootdev_ops, + .bind = scsi_bootdev_bind, + .of_match = scsi_bootdev_ids, +}; + +BOOTDEV_HUNTER(scsi_bootdev_hunter) = { + .prio = BOOTDEVP_2_SCAN_FAST, + .uclass = UCLASS_SCSI, + .hunt = scsi_bootdev_hunt, + .drv = DM_DRIVER_REF(scsi_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index db0e0ca20fa..5661a3c0009 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -240,8 +240,9 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextlinen("----"); ut_assert_nextline(" 50 ethernet eth_bootdev"); ut_assert_nextline(" 10 mmc mmc_bootdev"); + ut_assert_nextline(" 30 scsi scsi_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 3)"); + ut_assert_nextline("(total hunters: 4)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -249,8 +250,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is third in the list, so bit 2 */ - ut_asserteq(BIT(2), std->hunters_used); + /* USB is fourth in the list, so bit 3 */ + ut_asserteq(BIT(3), std->hunters_used); return 0; } @@ -270,7 +271,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 3)"); + ut_assert_skip_to_line("(total hunters: 4)"); ut_assert_console_end(); /* Scan all hunters */ @@ -279,7 +280,9 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); ut_assert_nextline("Hunting with: mmc"); - ut_assert_nextline("Hunting with: usb"); + ut_assert_nextline("Hunting with: scsi"); + ut_assert_nextline("scanning bus for devices..."); + ut_assert_skip_to_line("Hunting with: usb"); ut_assert_nextline( "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); @@ -290,12 +293,13 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextlinen("----"); ut_assert_nextline(" 50 * ethernet eth_bootdev"); ut_assert_nextline(" 10 * mmc mmc_bootdev"); + ut_assert_nextline(" 30 * scsi scsi_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 3)"); + ut_assert_nextline("(total hunters: 4)"); ut_assert_console_end(); - ut_asserteq(GENMASK(2, 0), std->hunters_used); + ut_asserteq(GENMASK(3, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727640 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dNCkciQh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGmq2R7Nz23gH for ; Wed, 18 Jan 2023 04:56:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0CBFC85692; Tue, 17 Jan 2023 18:51:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="dNCkciQh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96803855D9; Tue, 17 Jan 2023 18:50:37 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 D199C8563B for ; Tue, 17 Jan 2023 18:49:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id u8so15783479ilg.0 for ; Tue, 17 Jan 2023 09:49:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qw6WBOR/SzsZtQVbvNEsr8p9x0qSsx//n40Tx6nbe2o=; b=dNCkciQhDlaf2O505LqYhLSkJvK8V6UN421PIaTRG49avy6w+8harCC1vOzCgC68Zk OCBkvTlUiF9xrln1OMUID8gDLOso0wPlhWvML4gWzKjfGoWgXzU73J5MkrphT+HSxwIy TIcqkSVdcqACLvpBKurqpQKOsTr4mnWZJDxdE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qw6WBOR/SzsZtQVbvNEsr8p9x0qSsx//n40Tx6nbe2o=; b=z8/Z410ndgIJT/ot3CvykskBeKNTooOBfctcO+0P2kLlWExeWxmNYb3qndE8hQNGyO aW/8CVb876EkXUfRw8ZHQRC48V2uRGsKjwS7I2xoYRejouCdgw0y4LeMfWoLETELCmPh Uc1sWZmT7LsBX2e2JyaB7YdD0Z5qQDc6IjShgWIEmV9DfsWYmVwKERpzcyPWX34j7LCD utinaR8B3WHRZU7tXyFO8vBAErxXgzCXlPISveLlGnEXAPtk1oKRlvainQDyG39pwXGC hOyX5sKholyvkw9efWKELAES1TqfkMcuQx6JkZyoqTrumqyK8AVDW8VG9dL8OHlwFFdM r9yw== X-Gm-Message-State: AFqh2konXiIWScI6t39MhroNXS+Mpoq9/kNx/fwYTiED2N2gIh7Nq6FT NSCJfUQQLkZTyMJau4OvLAARZAOmJMrtLEn4 X-Google-Smtp-Source: AMrXdXvF/cILqp+BEf7m2BYrpPv/RLPFfj0P1CTss/PquDbrPtn1zELEviwFRjIbo9gC0RzGP8H6ig== X-Received: by 2002:a92:60c:0:b0:305:e1f9:89b with SMTP id x12-20020a92060c000000b00305e1f9089bmr3277731ilg.24.1673977755142; Tue, 17 Jan 2023 09:49:15 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:14 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 36/70] bootstd: Add an IDE bootdev Date: Tue, 17 Jan 2023 10:47:46 -0700 Message-Id: <20230117174820.1281477-37-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev for IDE so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- (no changes since v1) configs/sandbox_flattree_defconfig | 8 ++++++ drivers/block/ide.c | 44 ++++++++++++++++++++++++++++++ test/boot/bootdev.c | 16 +++++++---- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index eaaec42b1fe..6e8faf56797 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -40,6 +40,7 @@ CONFIG_CMD_MEMTEST=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y +CONFIG_CMD_IDE=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_OSD=y @@ -90,6 +91,13 @@ CONFIG_ADC=y CONFIG_ADC_SANDBOX=y CONFIG_AXI=y CONFIG_AXI_SANDBOX=y +CONFIG_SYS_IDE_MAXBUS=1 +CONFIG_SYS_ATA_BASE_ADDR=0x100 +CONFIG_SYS_ATA_STRIDE=4 +CONFIG_SYS_ATA_DATA_OFFSET=0 +CONFIG_SYS_ATA_REG_OFFSET=1 +CONFIG_SYS_ATA_ALT_OFFSET=2 +CONFIG_SYS_ATA_IDE0_OFFSET=0 CONFIG_CLK=y CONFIG_CLK_COMPOSITE_CCF=y CONFIG_CLK_K210=y diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 13a1cb4b9e4..80c8b64de2f 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1055,6 +1056,45 @@ U_BOOT_DRIVER(ide_blk) = { .probe = ide_blk_probe, }; +static int ide_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_3_SCAN_SLOW; + + return 0; +} + +static int ide_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + ide_init(); + + return 0; +} + +struct bootdev_ops ide_bootdev_ops = { +}; + +static const struct udevice_id ide_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-ide" }, + { } +}; + +U_BOOT_DRIVER(ide_bootdev) = { + .name = "ide_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &ide_bootdev_ops, + .bind = ide_bootdev_bind, + .of_match = ide_bootdev_ids, +}; + +BOOTDEV_HUNTER(ide_bootdev_hunter) = { + .prio = BOOTDEVP_3_SCAN_SLOW, + .uclass = UCLASS_IDE, + .hunt = ide_bootdev_hunt, + .drv = DM_DRIVER_REF(ide_bootdev), +}; + static int ide_probe(struct udevice *udev) { struct udevice *blk_dev; @@ -1086,6 +1126,10 @@ static int ide_probe(struct udevice *udev) ret = blk_probe_or_unbind(blk_dev); if (ret) return ret; + + ret = bootdev_setup_for_dev(udev, "ide_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); } } diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 5661a3c0009..a3acdcbdba3 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -239,10 +239,11 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); ut_assert_nextline(" 50 ethernet eth_bootdev"); + ut_assert_nextline(" 40 ide ide_bootdev"); ut_assert_nextline(" 10 mmc mmc_bootdev"); ut_assert_nextline(" 30 scsi scsi_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 4)"); + ut_assert_nextline("(total hunters: 5)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -250,8 +251,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is fourth in the list, so bit 3 */ - ut_asserteq(BIT(3), std->hunters_used); + /* USB is fifth in the list, so bit 4 */ + ut_asserteq(BIT(4), std->hunters_used); return 0; } @@ -271,7 +272,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 4)"); + ut_assert_skip_to_line("(total hunters: 5)"); ut_assert_console_end(); /* Scan all hunters */ @@ -279,6 +280,8 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); + ut_assert_nextline("Hunting with: ide"); + ut_assert_nextline("Bus 0: not available "); ut_assert_nextline("Hunting with: mmc"); ut_assert_nextline("Hunting with: scsi"); ut_assert_nextline("scanning bus for devices..."); @@ -292,14 +295,15 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); ut_assert_nextline(" 50 * ethernet eth_bootdev"); + ut_assert_nextline(" 40 * ide ide_bootdev"); ut_assert_nextline(" 10 * mmc mmc_bootdev"); ut_assert_nextline(" 30 * scsi scsi_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 4)"); + ut_assert_nextline("(total hunters: 5)"); ut_assert_console_end(); - ut_asserteq(GENMASK(3, 0), std->hunters_used); + ut_asserteq(GENMASK(4, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727647 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=B+K7nKs7; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGpK1nwvz23gH for ; Wed, 18 Jan 2023 04:58:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C059E856D0; Tue, 17 Jan 2023 18:51:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="B+K7nKs7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 381B185646; Tue, 17 Jan 2023 18:50:42 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 3103E85622 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id m7so3210413ilh.7 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y7uGAXf0bJc4euWxqYsCH7cQ3CUcMbC8YozLFxrnoVY=; b=B+K7nKs7n7STXmnGteq8srFbmRbspVMqRH/wSsQay4jQa/3kTMpu5r9zVL45CNHa/Y OlHubFiBxivSlqGevhRp1jGkxSG8oa57Yq0eM3R4qQx5v9P+jLSGCTFv6xrFXtgi14+/ pMCeoxkr5TrcBE4pTOFYZNOyVBDE5zwxbCoEo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y7uGAXf0bJc4euWxqYsCH7cQ3CUcMbC8YozLFxrnoVY=; b=3VE6QMedf2RLKxogq70GPwFNr3+mdTO/zNWyvZYayN0iBANV02QZxc3rnO2TS4L4b3 MBCwj7QALfUIokzuQq2yvWBMr7eOk32PlLUs2M8aopSTGZj4pa2ux7gfp9Mmi0rh7Pft hPZQx/HYeHGUPUFQiRkWpsXlAKhx6BQ26E9QcNGabThe8VaqEwK+J+ZH/OeOdcEeKZEP /Y3yCQakVPJ833LzwO1ptQy4OSHXFrdoUZUkxUQCcOE5wDO7il9QRkxooAtS2AdCmUbq aXCkjoCI21SQ8NHFH1FeUn/AzdrCahI+H6zIDknlFAllnk/xtngm9T0kMWw6cVNHLJCc 9q4g== X-Gm-Message-State: AFqh2koOU1bqfI4YsQxldQpVEx4BBxVePX5q+4fPZFG36ppWwIJ4fsrP VC1s9gvB9ZWgnBVL92ADeYP5dn5JeHMq8Myg X-Google-Smtp-Source: AMrXdXutixYL/vi6wSmaKdq8O5YzJcevUmAGyCjVjPwstGoBtjX2EFogoLFjSqhiNjuYspuAgWwDvw== X-Received: by 2002:a92:6c0d:0:b0:30d:7387:3d54 with SMTP id h13-20020a926c0d000000b0030d73873d54mr3269542ilc.7.1673977756156; Tue, 17 Jan 2023 09:49:16 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:15 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 37/70] bootstd: Add an NVMe bootdev Date: Tue, 17 Jan 2023 10:47:47 -0700 Message-Id: <20230117174820.1281477-38-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev for NVMe so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- (no changes since v1) drivers/nvme/nvme-uclass.c | 54 ++++++++++++++++++++++++++++++++++++++ drivers/nvme/nvme.c | 5 ++++ test/boot/bootdev.c | 15 ++++++----- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/nvme-uclass.c b/drivers/nvme/nvme-uclass.c index 239a92abba6..7a8ff06e78c 100644 --- a/drivers/nvme/nvme-uclass.c +++ b/drivers/nvme/nvme-uclass.c @@ -7,9 +7,63 @@ #define LOG_CATEGORY UCLASS_NVME #include +#include #include +#include +#include +#include + +static int nvme_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_2_SCAN_FAST; + + return 0; +} + +static int nvme_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + /* init PCI first since this is often used to provide NVMe */ + if (IS_ENABLED(CONFIG_PCI)) { + ret = pci_init(); + if (ret) + log_warning("Failed to init PCI (%dE)\n", ret); + } + + ret = nvme_scan_namespace(); + if (ret) + return log_msg_ret("scan", ret); + + return 0; +} UCLASS_DRIVER(nvme) = { .name = "nvme", .id = UCLASS_NVME, }; + +struct bootdev_ops nvme_bootdev_ops = { +}; + +static const struct udevice_id nvme_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-nvme" }, + { } +}; + +U_BOOT_DRIVER(nvme_bootdev) = { + .name = "nvme_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &nvme_bootdev_ops, + .bind = nvme_bootdev_bind, + .of_match = nvme_bootdev_ids, +}; + +BOOTDEV_HUNTER(nvme_bootdev_hunter) = { + .prio = BOOTDEVP_2_SCAN_FAST, + .uclass = UCLASS_NVME, + .hunt = nvme_bootdev_hunt, + .drv = DM_DRIVER_REF(nvme_bootdev), +}; diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 6d0d3f3ca2b..74e7a5b0110 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -893,6 +894,10 @@ int nvme_init(struct udevice *udev) if (ret) goto free_id; + ret = bootdev_setup_sibling_blk(ns_udev, "nvme_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); + ret = blk_probe_or_unbind(ns_udev); if (ret) goto free_id; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index a3acdcbdba3..6f150175f69 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -241,9 +241,10 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline(" 50 ethernet eth_bootdev"); ut_assert_nextline(" 40 ide ide_bootdev"); ut_assert_nextline(" 10 mmc mmc_bootdev"); + ut_assert_nextline(" 30 nvme nvme_bootdev"); ut_assert_nextline(" 30 scsi scsi_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 5)"); + ut_assert_nextline("(total hunters: 6)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -251,8 +252,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is fifth in the list, so bit 4 */ - ut_asserteq(BIT(4), std->hunters_used); + /* USB is fifth in the list, so bit 5 */ + ut_asserteq(BIT(5), std->hunters_used); return 0; } @@ -272,7 +273,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 5)"); + ut_assert_skip_to_line("(total hunters: 6)"); ut_assert_console_end(); /* Scan all hunters */ @@ -283,6 +284,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline("Hunting with: ide"); ut_assert_nextline("Bus 0: not available "); ut_assert_nextline("Hunting with: mmc"); + ut_assert_nextline("Hunting with: nvme"); ut_assert_nextline("Hunting with: scsi"); ut_assert_nextline("scanning bus for devices..."); ut_assert_skip_to_line("Hunting with: usb"); @@ -297,13 +299,14 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline(" 50 * ethernet eth_bootdev"); ut_assert_nextline(" 40 * ide ide_bootdev"); ut_assert_nextline(" 10 * mmc mmc_bootdev"); + ut_assert_nextline(" 30 * nvme nvme_bootdev"); ut_assert_nextline(" 30 * scsi scsi_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline("(total hunters: 5)"); + ut_assert_nextline("(total hunters: 6)"); ut_assert_console_end(); - ut_asserteq(GENMASK(4, 0), std->hunters_used); + ut_asserteq(GENMASK(5, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727651 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mtJgsK8d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGq95JVlz23gH for ; Wed, 18 Jan 2023 04:59:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88F8E856E5; Tue, 17 Jan 2023 18:51:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="mtJgsK8d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C423E85662; Tue, 17 Jan 2023 18:50:44 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 A582685660 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd30.google.com with SMTP id d22so6434482iof.5 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2zZvTOrbdR550XLIJQmmRCKl+oIuqh5cYwhJrSs8WXE=; b=mtJgsK8d4JFuQHDp77n3x8AJ/tKMkuJzr7tHz8zQqyeEwIyLjcqzeg3HeMcwV9SqYp RxUtEjNLkv7LT3m/+La96z2ahbcyrs3DWigykpxPvaj7qJn5VF657cdiY8J934o4+67K 8qAUgF/pb73PBrTHpcLv87t92TZXaRn1G+Y5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2zZvTOrbdR550XLIJQmmRCKl+oIuqh5cYwhJrSs8WXE=; b=5zrSbiVNmqFBe/bpy5z2fayY6YnyThYy1dDdIN+BTq8Xz3fUGcmf0Y4noIaoqfH1mh kl7DTGo0TNqgJ20v1rEHbvECtWmmiibDQV7u/2GESR08Q6eMs7mRNvCdiRUvlAZqzpfE OKuBO/Z/cYXd0utrL80tBwVFy4Eh9x0OyGloU/5tSm+ksLmUyf7lxWSApN6lS3cVS9c4 s7fl2DATDJpb/3MY4VpWpBIrhwPg3k/N43/KEDoAeameLdSt0EyxYWugCScwY4aU3hd8 /HxPp3DtvaCExz0tRu/b5FGYKX7F4Ei92M36m1cF+cW545asR5nhvKdeE8f7W5qnb6re xHjw== X-Gm-Message-State: AFqh2krL5UYq3plln0JbBTBMp5c2VIlduFIJJvUlpzuoBX9vvhQurBpq UH1iNN2Ri0hb6lbuVXYD2HEcXf/vRCbtlQ6z X-Google-Smtp-Source: AMrXdXtKQiE85tkjQTMvQOt4uRNw3VLz/+2YLpdJfVkHA+DWMdOpuWK0QvzQ6h4QOrbT3hjlYDuLMA== X-Received: by 2002:a6b:e006:0:b0:6e0:2404:39b3 with SMTP id z6-20020a6be006000000b006e0240439b3mr2689024iog.0.1673977757190; Tue, 17 Jan 2023 09:49:17 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:16 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 38/70] virtio: Avoid repeating a long expression Date: Tue, 17 Jan 2023 10:47:48 -0700 Message-Id: <20230117174820.1281477-39-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Use a local variable to hold this name, to reduce the amount of code that needs to be read. Signed-off-by: Simon Glass --- (no changes since v1) drivers/virtio/virtio-uclass.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index da4f2f26a63..6d9b029390e 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -214,6 +214,7 @@ static int virtio_uclass_post_probe(struct udevice *udev) struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(udev); char dev_name[30], *str; struct udevice *vdev; + const char *name; int ret; if (uc_priv->device >= VIRTIO_ID_MAX_NUM) { @@ -222,20 +223,19 @@ static int virtio_uclass_post_probe(struct udevice *udev) return 0; } - if (!virtio_drv_name[uc_priv->device]) { + name = virtio_drv_name[uc_priv->device]; + if (!name) { debug("(%s): underlying virtio device driver unavailable\n", udev->name); return 0; } - snprintf(dev_name, sizeof(dev_name), "%s#%d", - virtio_drv_name[uc_priv->device], dev_seq(udev)); + snprintf(dev_name, sizeof(dev_name), "%s#%d", name, dev_seq(udev)); str = strdup(dev_name); if (!str) return -ENOMEM; - ret = device_bind_driver(udev, virtio_drv_name[uc_priv->device], - str, &vdev); + ret = device_bind_driver(udev, name, str, &vdev); if (ret == -ENOENT) { debug("(%s): no driver configured\n", udev->name); return 0; From patchwork Tue Jan 17 17:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727681 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Q3FryGQS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGyP5B6Rz23fp for ; Wed, 18 Jan 2023 05:05:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D86F8567D; Tue, 17 Jan 2023 18:59:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Q3FryGQS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB79285103; Tue, 17 Jan 2023 18:59:12 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 D2B3285650 for ; Tue, 17 Jan 2023 18:49:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id 203so4582515iou.13 for ; Tue, 17 Jan 2023 09:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BFFB/dIKE2/VMgc6h0elyhg1mmom0xpwVvvliEnAiQw=; b=Q3FryGQS9hAHNIHzdVIG2kfKGJFlCEaGMxjkwCGT5PArNQJUQj5MntVB3h1VIsPZc1 Cntb8tD5VAqA1kFKrgnf4JmurLoZqMwKMDLbPnIBHEbBxsUZNqGhu9VgPjzaPsVRX/q7 DXmAQjtMnf4Cm8HmgtZAJamvZ4JNlss3Ep8q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BFFB/dIKE2/VMgc6h0elyhg1mmom0xpwVvvliEnAiQw=; b=G5dKMlt3hycOZdPa92BhhIg50tB31H024+SITVZCkUaqc27ayXBIA9oJVE/QC+eTjY gdTgA4Lt4WvL4WdbzBVTgngLfDOi3mH9lNiTzOm78acG6TPQPVtckWq+QCWnD4zwqkCO YnGI/TAsM4sX3wPdW/g1CgH7jmYEmZlZFj3ckLk+dlgKyR0VvYXT0Wr6966a3nldfcr6 v+/yTXCc41VHQSx3Ny32SexNVbYquDO/J4JN+EBK1HM/Cqa96F499Ji7NlMJ834PvVni eRV6Xw+LwWrA19fKBdfNIFUeO3AOKxYdWpEQage9Xlu4afqcLPIUBpeA+gkUfFnlKQB1 nwFg== X-Gm-Message-State: AFqh2koG66tLtiNeOcYodpZe56Yw4asHYwO6GvzUtPxNBC+J/lyXTlu0 eTjDW+r94ePRxUKsg/la/IkZ6Dqm1yij7YZV X-Google-Smtp-Source: AMrXdXt0qCFNPG1B40uKfWi/erb2Fc9zCekGkRxbbRM4Ok7v6jRJShPphYjJ2FAuTsu/UEui8PpRyg== X-Received: by 2002:a6b:c341:0:b0:704:d136:f382 with SMTP id t62-20020a6bc341000000b00704d136f382mr1901335iof.16.1673977758187; Tue, 17 Jan 2023 09:49:18 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:17 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 39/70] virtio: Fix returning -ENODEV Date: Tue, 17 Jan 2023 10:47:49 -0700 Message-Id: <20230117174820.1281477-40-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This has a special meaning in driver model. There is clearly a device, so it does not make sense to return this error code. Fix it. Signed-off-by: Simon Glass --- (no changes since v1) drivers/virtio/virtio-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 6d9b029390e..a6bff630ca8 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -163,7 +163,7 @@ int virtio_finalize_features(struct udevice *vdev) return ret; if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { debug("(%s): device refuses features %x\n", vdev->name, status); - return -ENODEV; + return -EINVAL; } return 0; From patchwork Tue Jan 17 17:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727646 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=b4QnDGSV; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGp55CX6z23gH for ; Wed, 18 Jan 2023 04:58:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9591F856AE; Tue, 17 Jan 2023 18:51:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="b4QnDGSV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90CAE8565F; Tue, 17 Jan 2023 18:50:41 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 3105C8562A for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id w2so2062651ilg.1 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rIZGmXqnCj0OmWz+Zv7jAnkGgpRRX1AME8VCFeS0YFM=; b=b4QnDGSVX/PGyBnsCLkF9G3bi3y6Ly2jhkqL4IPTHwb6I1eteFgDXlldCbqOnbfmbR 64AolDiGyMX5EWCeOB5+2ffVS775HaUwuLQPw/uqhL+P8kW5Oh6JC3upoPEAuCEh7dEx pWPuPeBCf4oaU1q6ZNu/27jTxEznt7leJDeq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rIZGmXqnCj0OmWz+Zv7jAnkGgpRRX1AME8VCFeS0YFM=; b=y18IulsQ5RkBCVBsLoo07+NyvWK6F068qd3lsOwKwmcCN0UDV0jHUMsvMJOeUgAt+n LqalSNnaXuIQQ1QNEEeoT+lFe88PNl+TMlwEp/RfgpFBd91t3OVtPLK/t3C+/c66oN9F TltYjZgkhitDXtZ+Jj2Lu6jrUyBmXwepQ2zN1YMj8Upp7+ZjeRtuRvXv7HyIXlV8AMZ4 mcIOLb0SMjnt4jCD6CDWYlf05w3wXzXiJFvl+xV2KmLD/jysPD7iezEwA9j48qzWiXpZ 2OWl9HRWj5XSwLw57DXANB3BbtJdjaAsdeXIE91V0yi2vAMJK4FKUoDwO1FT//YKmTSu tMKQ== X-Gm-Message-State: AFqh2kqXVV/v+xr1aS6uQLOEHOxIidVArL2cBWNQt1g2DzCSKnmrxhGX /xfzchaXEbRZpQtJDN/03xf3YGys9+ytexY9 X-Google-Smtp-Source: AMrXdXsYNn5ZrboftQj5s1pPwpzvpdb/ra0MNtU0laB6fGfkrYnCFUAiX4Q66eYpddRkEMCf4TeYgw== X-Received: by 2002:a92:3601:0:b0:30f:1c5:fb89 with SMTP id d1-20020a923601000000b0030f01c5fb89mr3454092ila.5.1673977759249; Tue, 17 Jan 2023 09:49:19 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:18 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 40/70] virtio: Avoid strange behaviour on removal Date: Tue, 17 Jan 2023 10:47:50 -0700 Message-Id: <20230117174820.1281477-41-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This device does a check on removal which is better handled in the actual test. Move it. Signed-off-by: Simon Glass --- (no changes since v1) drivers/virtio/virtio_sandbox.c | 13 ------------- test/dm/virtio_device.c | 3 +++ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c index 5484ae3a1a0..cf7761c75ee 100644 --- a/drivers/virtio/virtio_sandbox.c +++ b/drivers/virtio/virtio_sandbox.c @@ -167,18 +167,6 @@ static int virtio_sandbox_probe(struct udevice *udev) return 0; } -/* check virtio device driver's remove routine was called to reset the device */ -static int virtio_sandbox_child_post_remove(struct udevice *vdev) -{ - u8 status; - - virtio_get_status(vdev, &status); - if (status) - panic("virtio device was not reset\n"); - - return 0; -} - static const struct dm_virtio_ops virtio_sandbox1_ops = { .get_config = virtio_sandbox_get_config, .set_config = virtio_sandbox_set_config, @@ -203,7 +191,6 @@ U_BOOT_DRIVER(virtio_sandbox1) = { .of_match = virtio_sandbox1_ids, .ops = &virtio_sandbox1_ops, .probe = virtio_sandbox_probe, - .child_post_remove = virtio_sandbox_child_post_remove, .priv_auto = sizeof(struct virtio_sandbox_priv), }; diff --git a/test/dm/virtio_device.c b/test/dm/virtio_device.c index b5c4523a028..fdda4da4178 100644 --- a/test/dm/virtio_device.c +++ b/test/dm/virtio_device.c @@ -100,6 +100,7 @@ DM_TEST(dm_test_virtio_all_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); static int dm_test_virtio_remove(struct unit_test_state *uts) { struct udevice *bus, *dev; + u8 status; /* check probe success */ ut_assertok(uclass_first_device_err(UCLASS_VIRTIO, &bus)); @@ -117,6 +118,8 @@ static int dm_test_virtio_remove(struct unit_test_state *uts) ut_asserteq(-EKEYREJECTED, device_remove(bus, DM_REMOVE_ACTIVE_ALL)); ut_asserteq(false, device_active(dev)); + virtio_get_status(dev, &status); + ut_assertok(status); return 0; } From patchwork Tue Jan 17 17:47:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727641 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mtim/9D0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGn20mXFz23gH for ; Wed, 18 Jan 2023 04:57:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F207B856C8; Tue, 17 Jan 2023 18:51:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="mtim/9D0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDAFE8563B; Tue, 17 Jan 2023 18:50:37 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 D6DCC85651 for ; Tue, 17 Jan 2023 18:49:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id p12so2790905ilq.10 for ; Tue, 17 Jan 2023 09:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dYhivigSrqv1drGlZiJNRwIyOneASg+Neo44R53Y0aM=; b=mtim/9D0TTSdaXSsjWylsX4aisyouJVHWlONpgtWzgTZZyaVZe59juDXDf3URrK4as QG7fLTk9ggNtpknblAoRUNoXLBLyZ4Zt7DX5DMHDA7WWqWkTEY6KhJyZvZAmb5WXVJkj BFsmWx5FrJzxawtgBvslOeHUjONm35hcsLDbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dYhivigSrqv1drGlZiJNRwIyOneASg+Neo44R53Y0aM=; b=eUt78Hr3w3K3t60aMEmBcHwruh4aSJFP1tP0JEOn+q8bj+mVDBDu8bmuP/3Mo1k9tX jyjOTOE3orPWO+kTNg56r1Yvduldv1fbE13uj2y49OWctTIAolFdyZk3BFVQAu1M48+G UFxjiZsdlE5pZgdtUcQnoFW844SV9HzMEfJqogD4XmOApdfIeExWsY/MhupzUSkacfbI q2LGiYrEGSB7GcOL72lOAU300As16Z1A4DVB1Ngpff3FyHGPgM9PAP5e3w4w/lMHJojo gKT9StFOc+Ym8jxtep7wMFL/jpcFzp/wfkDCtrrHo3DDXLGqpSWIJA7kOzGl3elAgZ0w ikUg== X-Gm-Message-State: AFqh2kqSUYrBYOULe6RrUWzqPuI1cfBgbfJITM9kjFav8fLAk40FoIPy wKuJXKJUFsgmZbUXNlQWvx6+Yo4sZfla05Hp X-Google-Smtp-Source: AMrXdXsXwrnlFnuQ7bKVuBkQh1cO0FdGCyECO/x99mV+uxBqKjjKEphhD5g1uH9cM3UR3bL7b94d+A== X-Received: by 2002:a92:c710:0:b0:30f:61d:f5c6 with SMTP id a16-20020a92c710000000b0030f061df5c6mr3286554ilp.12.1673977760215; Tue, 17 Jan 2023 09:49:20 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:19 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 41/70] virtio: Add a block device Date: Tue, 17 Jan 2023 10:47:51 -0700 Message-Id: <20230117174820.1281477-42-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean The test code for virtio is fairly simplistic and does not actually create a block device. Add a way to specify the device type in the device tree. Add a block device so that we can do more testing. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/test.dts | 6 ++++++ drivers/virtio/virtio_sandbox.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 2e580f980fc..9d96e479ca8 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1527,12 +1527,18 @@ sandbox_virtio1 { compatible = "sandbox,virtio1"; + virtio-type = <4>; /* rng */ }; sandbox_virtio2 { compatible = "sandbox,virtio2"; }; + sandbox-virtio-blk { + compatible = "sandbox,virtio1"; + virtio-type = <2>; /* block */ + }; + sandbox_scmi { compatible = "sandbox,scmi-devices"; clocks = <&clk_scmi 2>, <&clk_scmi 0>; diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c index cf7761c75ee..b34f1d60455 100644 --- a/drivers/virtio/virtio_sandbox.c +++ b/drivers/virtio/virtio_sandbox.c @@ -161,7 +161,8 @@ static int virtio_sandbox_probe(struct udevice *udev) /* fake some information for testing */ priv->device_features = BIT_ULL(VIRTIO_F_VERSION_1); - uc_priv->device = VIRTIO_ID_RNG; + uc_priv->device = dev_read_u32_default(udev, "virtio-type", + VIRTIO_ID_RNG); uc_priv->vendor = ('u' << 24) | ('b' << 16) | ('o' << 8) | 't'; return 0; From patchwork Tue Jan 17 17:47:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727645 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BNNc+6nZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGnt6Tcfz23gH for ; Wed, 18 Jan 2023 04:57:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 277C9856AB; Tue, 17 Jan 2023 18:51:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="BNNc+6nZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DBD98567A; Tue, 17 Jan 2023 18:50:41 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 3603E8565F for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id d10so15738151ilc.12 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q8/kSW6Rn6gt907U4fkw2OkHWA0oo6j1fDHjHgMX7WE=; b=BNNc+6nZeNy1XSz0Lo29wwGvvRZ+JchSTXSofepNuEm9MqQe1lWGeBgEibfhOGhCgR ObUjJdS9PTENnbxDENHwkRUo+/p0Bheat5HjIjSuYuzz9J1puRachuJE7UGqmOnASF08 68vZ2oA4ct4ppCJ5Mi4/9cKDaqFAYsk9bhb8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q8/kSW6Rn6gt907U4fkw2OkHWA0oo6j1fDHjHgMX7WE=; b=2fHKh8euWC9tEHWrmER17RcjiJtBEeSOg1n8U4BYiDUPNhdLneZEfTuVKtdx+LoyoI tco71sP+pWyj0TOqxYLDcgkZDocy6AZ1hc4w7/CtXQfRUGTTuo7WFIZ5H169yAWW2PeC VutKuHnLbvcNOksKEAuqwitriRj1DtNJjWBLo7BKXO6ZPDELwRCAJPKCcoUgUoR4bDIh z9aR36e+Dv4NylGACAWXRYLkwTDa9o+gC+NkVr6CTBOZVJTJe/ydYdad194YO2zN/rpd 4x/eVJ07YrtcDU33Azd3zC653DK/GE9ZlgUZ49H2EEcDiLXwwQlhIF/fTruey0gPZ+PI +vrg== X-Gm-Message-State: AFqh2koOe8hYt/ryoQqiWjM/27EBm4DQdMWLzBRXncgTsJxWqngYX2t8 Mg56oI9OWhWZCBHeywkHmFt0ZOY/8ntFxRrG X-Google-Smtp-Source: AMrXdXtgdg1H4W9IzDQm3oX4b6vJmXMr4gJKysVavnrGkxZ+cVlnE6kKMAu+E+iPVYFnHM4rmJgMaA== X-Received: by 2002:a05:6e02:512:b0:300:a953:a263 with SMTP id d18-20020a056e02051200b00300a953a263mr16763818ils.21.1673977761191; Tue, 17 Jan 2023 09:49:21 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:20 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 42/70] bootstd: Add a virtio bootdev Date: Tue, 17 Jan 2023 10:47:52 -0700 Message-Id: <20230117174820.1281477-43-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev for virtio so that these devices can be used with standard boot. Signed-off-by: Simon Glass --- (no changes since v1) drivers/virtio/virtio-uclass.c | 50 ++++++++++++++++++++++++++++++++++ test/boot/bootdev.c | 12 ++++---- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index a6bff630ca8..27efac0d48e 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -18,6 +18,7 @@ #define LOG_CATEGORY UCLASS_VIRTIO #include +#include #include #include #include @@ -246,6 +247,12 @@ static int virtio_uclass_post_probe(struct udevice *udev) } device_set_name_alloced(vdev); + if (uc_priv->device == VIRTIO_ID_BLOCK) { + ret = bootdev_setup_for_dev(udev, name); + if (ret) + return log_msg_ret("bootdev", ret); + } + INIT_LIST_HEAD(&uc_priv->vqs); return 0; @@ -349,6 +356,26 @@ static int virtio_uclass_child_post_probe(struct udevice *vdev) return 0; } +static int virtio_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_2_SCAN_FAST; + + return 0; +} + +static int virtio_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + ret = uclass_probe_all(UCLASS_VIRTIO); + if (ret && ret != -ENOENT) + return log_msg_ret("vir", ret); + + return 0; +} + UCLASS_DRIVER(virtio) = { .name = "virtio", .id = UCLASS_VIRTIO, @@ -360,3 +387,26 @@ UCLASS_DRIVER(virtio) = { .child_post_probe = virtio_uclass_child_post_probe, .per_device_auto = sizeof(struct virtio_dev_priv), }; + +struct bootdev_ops virtio_bootdev_ops = { +}; + +static const struct udevice_id virtio_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-virtio" }, + { } +}; + +U_BOOT_DRIVER(virtio_bootdev) = { + .name = "virtio_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &virtio_bootdev_ops, + .bind = virtio_bootdev_bind, + .of_match = virtio_bootdev_ids, +}; + +BOOTDEV_HUNTER(virtio_bootdev_hunter) = { + .prio = BOOTDEVP_2_SCAN_FAST, + .uclass = UCLASS_VIRTIO, + .hunt = virtio_bootdev_hunt, + .drv = DM_DRIVER_REF(virtio_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 6f150175f69..2ad31a0ef66 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -244,7 +244,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline(" 30 nvme nvme_bootdev"); ut_assert_nextline(" 30 scsi scsi_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline("(total hunters: 6)"); + ut_assert_nextline(" 30 virtio virtio_bootdev"); + ut_assert_nextline("(total hunters: 7)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -273,7 +274,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 6)"); + ut_assert_skip_to_line("(total hunters: 7)"); ut_assert_console_end(); /* Scan all hunters */ @@ -290,6 +291,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_skip_to_line("Hunting with: usb"); ut_assert_nextline( "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + ut_assert_skip_to_line("Hunting with: virtio"); ut_assert_console_end(); /* List available hunters */ @@ -302,11 +304,11 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline(" 30 * nvme nvme_bootdev"); ut_assert_nextline(" 30 * scsi scsi_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); - - ut_assert_nextline("(total hunters: 6)"); + ut_assert_nextline(" 30 * virtio virtio_bootdev"); + ut_assert_nextline("(total hunters: 7)"); ut_assert_console_end(); - ut_asserteq(GENMASK(5, 0), std->hunters_used); + ut_asserteq(GENMASK(6, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:47:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727652 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ahA1d4l6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGqR4lTwz23gH for ; Wed, 18 Jan 2023 04:59:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBEB1856E9; Tue, 17 Jan 2023 18:51:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="ahA1d4l6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2223885646; Tue, 17 Jan 2023 18:50:45 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 8D8DA85663 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id g2so15757397ila.4 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ykdlwrt9Soz3ixlu2La3SZMnwSBir5aEavXtUrEmkEU=; b=ahA1d4l6aAGXYUL9PlixqfDKNP3P+07+ygRkmCMvZye79a98ttQWtA2emq9l5rExfQ UfXA4ZgQgPK49mnGpb2zi/zENAT1gS3WsGTCqgdaA0EIAfeUtC/9HNW16a/QgB1njY9v p/2qd32y8JR6sZJWRJlqGysDrYok7ZiNUYRSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ykdlwrt9Soz3ixlu2La3SZMnwSBir5aEavXtUrEmkEU=; b=ygMj5DCLbWHiSsk0AWENCHkCS2NhcujbDU9b0gwW+Fj9tHe8fyB+ylAYjfztowUjm4 4VN518YGajFThDsa9jBBcInMZ1QVKuLUpcsfQ6yxpcZwi9HcRz1PSjvUsbK46aS48KI0 eQU9K+TrQTBeJR4SEY4IF7b2VBBdLWXezkxmQkkdrAfFrTdYkS3I9HiWWI6EAlGfbTXs CFkliRA8jX8+YcXUh9a63bpQ9PnVJ4HldJiGe29rqPB/AgRbjr7DMSQLFgmf5a9erGTi BUIQNHITkeAx4DlRDL6VBw16QfkmwNqSy0S/B5PCio1c+2vFFoQvbje76SDNZ1m/cCiH 67CQ== X-Gm-Message-State: AFqh2ko6W/ALXUH6JWLrhw+7cYPbwWK4dgefic/KMJjjsrD74qaemraU td10aDzGTtr7fYUe0NxSAacT6FzTJR6cGrLc X-Google-Smtp-Source: AMrXdXvUGAxrMYdv7v4Jd1+dV1WWAUl/NwAULGdKB+63jvKbOooRFIDnVdGcQm2o4r172b3XRBFRZg== X-Received: by 2002:a05:6e02:1185:b0:30d:c130:6cbd with SMTP id y5-20020a056e02118500b0030dc1306cbdmr3194335ili.26.1673977762219; Tue, 17 Jan 2023 09:49:22 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:21 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 43/70] ata: Don't try to use non-existent ports Date: Tue, 17 Jan 2023 10:47:53 -0700 Message-Id: <20230117174820.1281477-44-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean The controller indicates the number of ports but also has a port map which specifies which ports are actually valid. Make use of this to avoid trying to send commands to an invalid port. This avoids a crash on some controllers. Signed-off-by: Simon Glass --- (no changes since v1) drivers/ata/ahci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index de6131f1d9b..272c48b8e57 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -675,6 +675,12 @@ static int ata_scsiop_inquiry(struct ahci_uc_priv *uc_priv, /* Read id from sata */ port = pccb->target; + /* If this port number is not valid, give up */ + if (!(uc_priv->port_map & (1 << port))) { + debug("Port %x not valid in map %x\n", port, uc_priv->port_map); + return -ENODEV; + } + if (ahci_device_data_io(uc_priv, port, (u8 *)&fis, sizeof(fis), (u8 *)tmpid, ATA_ID_WORDS * 2, 0)) { debug("scsi_ahci: SCSI inquiry command failure.\n"); From patchwork Tue Jan 17 17:47:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727679 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZgiEZWfB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGxw4Sw5z23fT for ; Wed, 18 Jan 2023 05:04:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FC8185617; Tue, 17 Jan 2023 18:59:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="ZgiEZWfB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1109855D3; Tue, 17 Jan 2023 18:59:11 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 0212D85605 for ; Tue, 17 Jan 2023 18:49:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id h26so15738671ila.11 for ; Tue, 17 Jan 2023 09:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cObe2evJhMb2FvreL/ezj/bUUnzEiSJg7AzxGby8fxk=; b=ZgiEZWfBFbN3RLy4q3poR8fu+eTthqtVOifsvUe2PV+qS/ChWbbmGEuHH0nCqaXcAh AQB4q2VTUUbnpRhTrClcABqy5eVDc+Sv83/nlugMB9xG25QnkAwzsAcwu1C2XcGaL7HQ gSkUgrgqpoEhGs9Qi/NSdsY7aefjhuM+DW9XA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cObe2evJhMb2FvreL/ezj/bUUnzEiSJg7AzxGby8fxk=; b=h2pFJuux+jQpx9tVZEzm/3teU/+RVdRaMOWF9fY1Wjv6aNvLe8PYikMt8htVBoc2uK QqTtE9yqgySACzzF0pDW3hRgRXOoAda1peUoh72nPEGxZZ+v7V0UVwcMR2BJGmcvGBmX AgC1XIxfNFVcCWLd/aMLQyorT/Vs7ys0XPxOXUi4IB0ompeFMZR2EYUmcn0lIM176Ri5 x0H4rGXG2WYOd6F1C2fERa0uud0NPwkghZ4/SNstJUOsfbz8VoeGacb5Zp1EsKRuZXUa H9yqTWmeQFUl8uCvV7nWIk+w9dKJcc9b9H9br+4/pDLbaucUz5CsnEn8nYy0vjK8fKkq dQRg== X-Gm-Message-State: AFqh2kpCJNUVfivfmxxue4HcJGWxZxv1w7mfY2ibWEOiGKiW+FtweNHC LbL7UhQ391OWfXNZViri9pxHFlp9E2r0RaWE X-Google-Smtp-Source: AMrXdXuN6UKoOHT8EXxpTag/O8dRVTTqWZx9H+W1j8vCa+IlpJYjMCeIK9IXe/SkGrsdRNoJY/5BLQ== X-Received: by 2002:a92:b05:0:b0:30e:e070:cae9 with SMTP id b5-20020a920b05000000b0030ee070cae9mr3307925ilf.28.1673977763228; Tue, 17 Jan 2023 09:49:23 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:22 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 44/70] bootstd: Rename bootdev checkers Date: Tue, 17 Jan 2023 10:47:54 -0700 Message-Id: <20230117174820.1281477-45-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean These functions return 0 if the check passes, so the names are somewhat confusing. Rename them. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 6 +++--- boot/bootmeth_distro.c | 2 +- boot/bootmeth_efi.c | 2 +- boot/bootmeth_efi_mgr.c | 2 +- boot/bootmeth_pxe.c | 2 +- boot/bootmeth_script.c | 2 +- include/bootflow.h | 12 ++++++------ net/eth_bootdev.c | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 163cd4953dd..0345755f58f 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -427,7 +427,7 @@ int bootflow_run_boot(struct bootflow_iter *iter, struct bootflow *bflow) return ret; } -int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter) +int bootflow_iter_check_blk(const struct bootflow_iter *iter) { const struct udevice *media = dev_get_parent(iter->dev); enum uclass_id id = device_get_uclass_id(media); @@ -439,7 +439,7 @@ int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter) return -ENOTSUPP; } -int bootflow_iter_uses_network(const struct bootflow_iter *iter) +int bootflow_iter_check_net(const struct bootflow_iter *iter) { const struct udevice *media = dev_get_parent(iter->dev); enum uclass_id id = device_get_uclass_id(media); @@ -451,7 +451,7 @@ int bootflow_iter_uses_network(const struct bootflow_iter *iter) return -ENOTSUPP; } -int bootflow_iter_uses_system(const struct bootflow_iter *iter) +int bootflow_iter_check_system(const struct bootflow_iter *iter) { const struct udevice *media = dev_get_parent(iter->dev); enum uclass_id id = device_get_uclass_id(media); diff --git a/boot/bootmeth_distro.c b/boot/bootmeth_distro.c index 6ef0fa1f2c9..356929828b9 100644 --- a/boot/bootmeth_distro.c +++ b/boot/bootmeth_distro.c @@ -59,7 +59,7 @@ static int distro_check(struct udevice *dev, struct bootflow_iter *iter) int ret; /* This only works on block devices */ - ret = bootflow_iter_uses_blk_dev(iter); + ret = bootflow_iter_check_blk(iter); if (ret) return log_msg_ret("blk", ret); diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index d5438eb67b9..f7bb153d9de 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -104,7 +104,7 @@ static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter) int ret; /* This only works on block devices */ - ret = bootflow_iter_uses_blk_dev(iter); + ret = bootflow_iter_check_blk(iter); if (ret) return log_msg_ret("blk", ret); diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index 2f327c1f8ce..e9d973429f7 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -36,7 +36,7 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) int ret; /* Must be an bootstd device */ - ret = bootflow_iter_uses_system(iter); + ret = bootflow_iter_check_system(iter); if (ret) return log_msg_ret("net", ret); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index e6992168c06..13e2ff486dc 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -44,7 +44,7 @@ static int distro_pxe_check(struct udevice *dev, struct bootflow_iter *iter) int ret; /* This only works on network devices */ - ret = bootflow_iter_uses_network(iter); + ret = bootflow_iter_check_net(iter); if (ret) return log_msg_ret("net", ret); diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index c7061eb998f..3a3907d75b7 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -28,7 +28,7 @@ static int script_check(struct udevice *dev, struct bootflow_iter *iter) int ret; /* This only works on block devices */ - ret = bootflow_iter_uses_blk_dev(iter); + ret = bootflow_iter_check_blk(iter); if (ret) return log_msg_ret("blk", ret); diff --git a/include/bootflow.h b/include/bootflow.h index 3a93e4b5cab..8ff9e332b1f 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -314,33 +314,33 @@ const char *bootflow_state_get_name(enum bootflow_state_t state); void bootflow_remove(struct bootflow *bflow); /** - * bootflow_iter_uses_blk_dev() - Check that a bootflow uses a block device + * bootflow_iter_check_blk() - Check that a bootflow uses a block device * * This checks the bootdev in the bootflow to make sure it uses a block device * * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet) */ -int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter); +int bootflow_iter_check_blk(const struct bootflow_iter *iter); /** - * bootflow_iter_uses_network() - Check that a bootflow uses a network device + * bootflow_iter_check_net() - Check that a bootflow uses a network device * * This checks the bootdev in the bootflow to make sure it uses a network * device * * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC) */ -int bootflow_iter_uses_network(const struct bootflow_iter *iter); +int bootflow_iter_check_net(const struct bootflow_iter *iter); /** - * bootflow_iter_uses_system() - Check that a bootflow uses the bootstd device + * bootflow_iter_check_system() - Check that a bootflow uses the bootstd device * * This checks the bootdev in the bootflow to make sure it uses the bootstd * device * * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC) */ -int bootflow_iter_uses_system(const struct bootflow_iter *iter); +int bootflow_iter_check_system(const struct bootflow_iter *iter); /** * bootflow_menu_new() - Create a new bootflow menu diff --git a/net/eth_bootdev.c b/net/eth_bootdev.c index fdf48f00131..bcbb35a74cd 100644 --- a/net/eth_bootdev.c +++ b/net/eth_bootdev.c @@ -27,7 +27,7 @@ static int eth_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, int ret; /* Must be an Ethernet device */ - ret = bootflow_iter_uses_network(iter); + ret = bootflow_iter_check_net(iter); if (ret) return log_msg_ret("net", ret); From patchwork Tue Jan 17 17:47:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727680 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bffKAdxz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGyB0FQPz23fT for ; Wed, 18 Jan 2023 05:05:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B01CD85629; Tue, 17 Jan 2023 18:59:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="bffKAdxz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1113F85103; Tue, 17 Jan 2023 18:59:12 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 360918561D for ; Tue, 17 Jan 2023 18:49:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id v6so6224833ilq.3 for ; Tue, 17 Jan 2023 09:49:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+QIPYnFjgRk7ZnFiJUoS7h1O9IX9PBA9wc937iol2wk=; b=bffKAdxzpqhRad/7nRi8uf3Z3SSR9L2jcldRLj9i6loe/pkzxeDDQyK7wwf6lKXLuA fms9WxUnnohbB0BlUmnAzqyf16IplMDHikadNEYlZD5WPxHmYK6QJEm6mfvu5/Hf1p4y sQjandNM9O70n1FJBhU1IJLpTlhtLYWtKnzf0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QIPYnFjgRk7ZnFiJUoS7h1O9IX9PBA9wc937iol2wk=; b=Q1YQHJjzC7ZlBe+Iyx5odtCtfRIOcVQoYJzKFFfElA5oso2dRYbzvv7tnuLEuVzaIE VotvXRaHBldXutW1DLfgVPH59Vivl4WnPrpywC2B0AEGCgykHfh/aL2nQbA+Kj8T/of6 4I/4n8SJjBDgC65rAhl0h32l2OeVg3sfo8qzMg+Lw4I6LkLY4nIaZqLhVaDenzP+kFgI Wkxf0WCeCqusCH30oNaeGp6Co1Qj3/3D1yde9/pt1SMVEJvroS7XU6obPHB+uq0+UBkv 9rL+frGN6zkwI9krMhdsm1FSg1zfPFHshRcuZTzirvMJKxYB3qDKS4igLnZr9Ia/fv2N f8GQ== X-Gm-Message-State: AFqh2kr3aUExdYPz/vJv/lZcYXRyZR24k/8j0aRa7s3Cf64giFU80XRN QCHbO/Mo9w312+j7bmqFOYWUH10yE05FWUcc X-Google-Smtp-Source: AMrXdXvy3ZSXIH8WXVOn5k7RkGWGFJYuDP5dRkcV7osa0wvBxLf9NnwGwiXq6yEBpctsKzNWSXCmZw== X-Received: by 2002:a05:6e02:10c5:b0:302:f7e8:638b with SMTP id s5-20020a056e0210c500b00302f7e8638bmr3144093ilj.11.1673977764264; Tue, 17 Jan 2023 09:49:24 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:23 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 45/70] bootstd: Allow reading an EFI file from the network Date: Tue, 17 Jan 2023 10:47:55 -0700 Message-Id: <20230117174820.1281477-46-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this bootmeth only supports reading from a filesystem. Add support for reading from a network also, using DHCP with autoload. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_efi.c | 117 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 8 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index f7bb153d9de..77b4ba22470 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #define EFI_DIRNAME "efi/boot/" @@ -59,6 +60,40 @@ static int get_efi_leafname(char *str, int max_len) return 0; } +static int get_efi_pxe_arch(void) +{ + /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ + if (IS_ENABLED(CONFIG_ARM64)) + return 0xb; + else if (IS_ENABLED(CONFIG_ARM)) + return 0xa; + else if (IS_ENABLED(CONFIG_X86_64)) + return 0x6; + else if (IS_ENABLED(CONFIG_X86)) + return 0x7; + else if (IS_ENABLED(CONFIG_ARCH_RV32I)) + return 0x19; + else if (IS_ENABLED(CONFIG_ARCH_RV64I)) + return 0x1b; + else if (IS_ENABLED(CONFIG_SANDBOX)) + return 0; /* not used */ + + return -EINVAL; +} + +static int get_efi_pxe_vci(char *str, int max_len) +{ + int ret; + + ret = get_efi_pxe_arch(); + if (ret < 0) + return ret; + + snprintf(str, max_len, "PXEClient:Arch:%05x:UNDI:003000", ret); + + return 0; +} + static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow) { const struct udevice *media_dev; @@ -101,20 +136,18 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow) static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter) { - int ret; - - /* This only works on block devices */ - ret = bootflow_iter_check_blk(iter); - if (ret) - return log_msg_ret("blk", ret); + /* This only works on block and network devices */ + if (bootflow_iter_check_blk(iter) && bootflow_iter_check_net(iter)) + return log_msg_ret("blk", -ENOTSUPP); return 0; } -static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) +static int distro_efi_read_bootflow_file(struct udevice *dev, + struct bootflow *bflow) { struct blk_desc *desc = NULL; - char fname[sizeof(EFI_DIRNAME) + 16]; + char fname[256]; int ret; /* We require a partition table */ @@ -140,6 +173,74 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) return 0; } +static int distro_efi_read_bootflow_net(struct bootflow *bflow) +{ + const char *addr_str; + int ret, arch, size; + char str[36]; + ulong addr; + + ret = get_efi_pxe_vci(str, sizeof(str)); + if (ret) + return log_msg_ret("vci", ret); + ret = get_efi_pxe_arch(); + if (ret < 0) + return log_msg_ret("arc", ret); + arch = ret; + + ret = env_set("bootp_vci", str); + if (ret) + return log_msg_ret("vcs", ret); + ret = env_set_ulong("bootp_arch", arch); + if (ret) + return log_msg_ret("ars", ret); + + /* figure out the load address */ + addr_str = env_get("kernel_addr_r"); + addr = addr_str ? hextoul(addr_str, NULL) : image_load_addr; + + /* clear any previous bootfile */ + env_set("bootfile", NULL); + + /* read the kernel */ + ret = dhcp_run(addr, NULL, true); + if (ret) + return log_msg_ret("dhc", ret); + + size = env_get_hex("filesize", -1); + if (size <= 0) + return log_msg_ret("sz", -EINVAL); + bflow->size = size; + + /* do the hideous EFI hack */ + efi_set_bootdev("Net", "", bflow->fname, map_sysmem(addr, 0), + bflow->size); + + bflow->state = BOOTFLOWST_READY; + + return 0; +} + +static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + const struct udevice *media = dev_get_parent(bflow->dev); + int ret; + + if (IS_ENABLED(CONFIG_CMD_DHCP) && + device_get_uclass_id(media) == UCLASS_ETH) { + /* we only support reading from one device, so ignore 'dev' */ + ret = distro_efi_read_bootflow_net(bflow); + if (ret) + return log_msg_ret("net", ret); + } else { + ret = distro_efi_read_bootflow_file(dev, bflow); + if (ret) + return log_msg_ret("blk", ret); + } + + return 0; +} + int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) { char cmd[50]; From patchwork Tue Jan 17 17:47:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727649 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SxpTu2cI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGpm1CKnz23gH for ; Wed, 18 Jan 2023 04:58:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDD6A856C3; Tue, 17 Jan 2023 18:51:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="SxpTu2cI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A048385646; Tue, 17 Jan 2023 18:50:43 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 7E25385661 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id b127so7211694iof.8 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cbtsxzkApV5Rpqi1npKPvwLnaXyAVA8d2MAfhSWpNwg=; b=SxpTu2cIAYwebXBuaz4zsaBPdqJj6IR0vCe9yIqcILzvmnwD1rCyJWIE99DkEb6TPx R1CMrBxgriBqCebTdaQiaFux2+d7iWf+2e0TQmiEBeRdxHxy+uCvvnJfydPuE2eRVMXe 6dqYRZ5jpdEO1cWO69+FBWQmbrz+TvDt46Vw4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cbtsxzkApV5Rpqi1npKPvwLnaXyAVA8d2MAfhSWpNwg=; b=LmTeZjsEqgltMaaymxp13Z0jiEF/rvGSWymRINhFsE2JDa7C+wafOhRcXIuqNFMQXY kg3lhyENwDCe5gOGG4561SCOlRd/7DNcNQoTuA88wPvtCsb30V6DI91a/sQoTU5krcuU Tm6mKHUUAueuGFozuxml0JM9OWEw1KpRzFZ150lxqEnykFbo81JfrtXMT7Rmfpbnhssc a8u55N1tkmzMU3szI4QQ9fBQu5gBdeITcwhpRv9yC4zsmwHdejkRZsJUtHLPKuotKWDs 6knD3BxuDKTa9oUJNVbP4FMZfsxjDZySjacgvJaUBkX4aM8L7vb1agvC/d2AWv6QM2t0 69ZQ== X-Gm-Message-State: AFqh2kob6cwhQZzW0h2d/8bD87nJCVBg+Mmjq/ZlnAHacrlxv3FnVOSB 9vX6tBFnq30F3iAve/Dek7zjP4Y6T9lEmcyj X-Google-Smtp-Source: AMrXdXuNX9YYACGKCySMDNF5zMgDq7niDU5+j0OnD4bsGBeP8EBYeHVB5GlF56vWjflbYithGmCQWQ== X-Received: by 2002:a05:6602:2d86:b0:6df:5b14:61ee with SMTP id k6-20020a0566022d8600b006df5b1461eemr4451505iow.5.1673977765255; Tue, 17 Jan 2023 09:49:25 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:24 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 46/70] bootstd: Include the device tree in the bootflow Date: Tue, 17 Jan 2023 10:47:56 -0700 Message-Id: <20230117174820.1281477-47-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Some bootmeths provide a way to load a device tree as well as the base OS image. Add a way to store this in the bootflow. Update the 'bootflow info' command to show this information. Note that the device tree is not allocated, but instead is stored at an address provided by an environment variable. This may need to be adjusted at some point, but for now it works well and fits in with the existing distro-boot scripts. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 1 + cmd/bootflow.c | 6 ++++++ include/bootflow.h | 6 ++++++ test/boot/bootflow.c | 1 + 4 files changed, 14 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index 0345755f58f..52cc2f9d548 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -355,6 +355,7 @@ void bootflow_free(struct bootflow *bflow) free(bflow->fname); free(bflow->buf); free(bflow->os_name); + free(bflow->fdt_fname); } void bootflow_remove(struct bootflow *bflow) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 2b6ed26fdcb..56dd35b69cf 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -344,6 +344,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("Logo size: %x (%d bytes)\n", bflow->logo_size, bflow->logo_size); } + printf("FDT: %s\n", bflow->fdt_fname); + if (bflow->fdt_fname) { + printf("FDT size: %x (%d bytes)\n", bflow->fdt_size, + bflow->fdt_size); + printf("FDT addr: %lx\n", bflow->fdt_addr); + } printf("Error: %d\n", bflow->err); if (dump && bflow->buf) { /* Set some sort of maximum on the size */ diff --git a/include/bootflow.h b/include/bootflow.h index 8ff9e332b1f..bf71b09edad 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -60,6 +60,9 @@ enum bootflow_state_t { * @err: Error number received (0 if OK) * @os_name: Name of the OS / distro being booted, or NULL if not known * (allocated) + * @fdt_fname: Filename of FDT file + * @fdt_size: Size of FDT file + * @fdt_addr: Address of loaded fdt */ struct bootflow { struct list_head bm_node; @@ -79,6 +82,9 @@ struct bootflow { int size; int err; char *os_name; + char *fdt_fname; + int fdt_size; + ulong fdt_addr; }; /** diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index f852b6e9b6f..b71ec52eb7a 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -199,6 +199,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts) ut_assert_nextline("Size: 253 (595 bytes)"); ut_assert_nextline("OS: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)"); ut_assert_nextline("Logo: (none)"); + ut_assert_nextline("FDT: "); ut_assert_nextline("Error: 0"); ut_assert_console_end(); From patchwork Tue Jan 17 17:47:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727648 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Wcxf9lEN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGpX3g6dz23gH for ; Wed, 18 Jan 2023 04:58:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE6A185615; Tue, 17 Jan 2023 18:51:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Wcxf9lEN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2142D8565F; Tue, 17 Jan 2023 18:50:43 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 2FB1F85616 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id i1so12258732ilu.8 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oLaKlKPP9yKnTY4F8aE3URlciJmHMlwvzmgPCxJDNBY=; b=Wcxf9lENP3mA7P+H6DRph5TOz4Q5dQs30UNfofhskht5/M/cZYstoN4O9z71NOFkke a/F1JPvcA50AwCMEtpdk+XxkGJdTr6f7Uyvzy2/gfvkvE5EJn4ugt5mJdm5fLwLJgIno qCNUQyYvWdAjrsBokwVWyS38KR/U7a9kqNg6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oLaKlKPP9yKnTY4F8aE3URlciJmHMlwvzmgPCxJDNBY=; b=iV+s6uoTnJPlH72UYcHogTQXkwlSoo+qsXnTqxBQcNB+YH+WJJjACh8VeJUfDjL4+I 70zTazNIx3L7f5F2vihmBySVLao7kNFjLUM8Vrt10iKewOWkuax/DxrVNflvZAE04jo4 yRqeqroOUKaq2Be+yEn2iyIwQ6qoWZuhE0zN/OQzzvlAibUHc28JH/6jf5IutNERQLbT jC/BgxBOs87DQdEbH6ZZ9phjdEzp0mVQEbeBRPnQjVBuaNjBn03SbxT0z+9SnhUNZtTi mVGRIfgOATe5l4uk19j1LofDAxtav74Cw0F4hKVh4Hpr5u+BNZ0hfh0bw4qjJDWyW8L8 5Mfg== X-Gm-Message-State: AFqh2kr7cE7ACSUdCOJLlkEH+Zw14Tgf7j/zp8B94ut0MzBBwlQ4J2jz tLlmKjyB57Ogql5mB+H8ijivIsM3vKWp8bRi X-Google-Smtp-Source: AMrXdXtSvN+FOIpMgUJq1gz4Hd7Jvy1Uqw7yNyezG7IAi+D/yzco7R0yZGMIxaUxQt3CuygqBJ11lw== X-Received: by 2002:a92:c00b:0:b0:30f:2343:2a0a with SMTP id q11-20020a92c00b000000b0030f23432a0amr1957507ild.11.1673977766284; Tue, 17 Jan 2023 09:49:26 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:25 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 47/70] bootstd: Support reading the device tree with EFI Date: Tue, 17 Jan 2023 10:47:57 -0700 Message-Id: <20230117174820.1281477-48-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean With EFI booting the device tree is required but is not actually specified in any way. The normal method is to use a fdtfile environment variable to get the filename, then look for that file on the media. Implement this in the bootmeth. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_efi.c | 105 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 6 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 77b4ba22470..53a0489b93c 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -143,10 +143,32 @@ 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) +{ + const char *fdt_fname; + + fdt_fname = env_get("fdtfile"); + if (fdt_fname) { + snprintf(fname, size, "dtb/%s", fdt_fname); + log_debug("Using device tree: %s\n", fname); + } else { + 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", + soc ? soc : "", soc ? "-" : "", board ? board : "", + boardver ? boardver : ""); + log_debug("Using default device tree: %s\n", fname); + } +} + static int distro_efi_read_bootflow_file(struct udevice *dev, struct bootflow *bflow) { struct blk_desc *desc = NULL; + ulong fdt_addr, size; char fname[256]; int ret; @@ -170,15 +192,43 @@ 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)); + bflow->fdt_fname = strdup(fname); + if (!bflow->fdt_fname) + return log_msg_ret("fil", -ENOMEM); + + fdt_addr = env_get_hex("fdt_addr_r", 0); + ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr, &size); + if (!ret) { + bflow->fdt_size = size; + bflow->fdt_addr = fdt_addr; + + /* + * TODO: Apply extension overlay + * + * Here we need to load and apply the extension overlay. This is + * not implemented. See do_extension_apply(). The extension + * stuff needs an implementation in boot/extension.c so it is + * separate from the command code. Really the extension stuff + * should use the device tree and a uclass / driver interface + * rather than implementing its own list + */ + } else { + log_debug("No device tree available\n"); + } + return 0; } static int distro_efi_read_bootflow_net(struct bootflow *bflow) { - const char *addr_str; + char file_addr[17], fname[256]; + char *tftp_argv[] = {"tftp", file_addr, fname, NULL}; + struct cmd_tbl cmdtp = {}; /* dummy */ + const char *addr_str, *fdt_addr_str; int ret, arch, size; + ulong addr, fdt_addr; char str[36]; - ulong addr; ret = get_efi_pxe_vci(str, sizeof(str)); if (ret) @@ -216,6 +266,25 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) efi_set_bootdev("Net", "", bflow->fname, map_sysmem(addr, 0), bflow->size); + /* read the DT file also */ + fdt_addr_str = env_get("fdt_addr_r"); + if (!fdt_addr_str) + return log_msg_ret("fdt", -EINVAL); + fdt_addr = hextoul(fdt_addr_str, NULL); + sprintf(file_addr, "%lx", fdt_addr); + + distro_efi_get_fdt_name(fname, sizeof(fname)); + bflow->fdt_fname = strdup(fname); + if (!bflow->fdt_fname) + return log_msg_ret("fil", -ENOMEM); + + if (!do_tftpb(&cmdtp, 0, 3, tftp_argv)) { + bflow->fdt_size = env_get_hex("filesize", 0); + bflow->fdt_addr = fdt_addr; + } else { + log_debug("No device tree available\n"); + } + bflow->state = BOOTFLOWST_READY; return 0; @@ -243,15 +312,39 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) { + ulong kernel, fdt; char cmd[50]; + /* A non-zero buffer indicates the kernel is there */ + if (bflow->buf) { + kernel = (ulong)map_to_sysmem(bflow->buf); + + /* + * use the provided device tree if available, else fall back to + * the control FDT + */ + if (bflow->fdt_fname) + fdt = bflow->fdt_addr; + else + fdt = (ulong)map_to_sysmem(gd->fdt_blob); + } else { + /* + * This doesn't actually work for network devices: + * + * do_bootefi_image() No UEFI binary known at 0x02080000 + * + * But this is the same behaviour for distro boot, so it can be + * fixed here. + */ + kernel = env_get_hex("kernel_addr_r", 0); + fdt = env_get_hex("fdt_addr_r", 0); + } + /* * At some point we can add a real interface to bootefi so we can call - * this directly. For now, go through the CLI like distro boot. + * this directly. For now, go through the CLI, like distro boot. */ - snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", - (ulong)map_to_sysmem(bflow->buf), - (ulong)map_to_sysmem(gd->fdt_blob)); + snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt); if (run_command(cmd, 0)) return log_msg_ret("run", -EINVAL); From patchwork Tue Jan 17 17:47:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727642 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Ppm4sstP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGnK1Bnrz23gH for ; Wed, 18 Jan 2023 04:57:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D9F8856CB; Tue, 17 Jan 2023 18:51:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Ppm4sstP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 517548563B; Tue, 17 Jan 2023 18:50:39 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 3287085657 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id p12so2791077ilq.10 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lVU3FPqG+S8OYyexsR/ZDKexopjez3NPRESowjokcgo=; b=Ppm4sstPpxYVVTARpdCmwz0n3uQSps8XOBjtsDtz0y3hXKpRbkoF9GL0n3aWjIei+S xn1XOBM10OGDn//uSA4kxI8beromIiCfLXlFCq1WEWa+XRqDuMQiECR+oLl7LIvC8DgM zrKVsAB+s7JWAHJFPJ7RXLJoIs2I944XSgfL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lVU3FPqG+S8OYyexsR/ZDKexopjez3NPRESowjokcgo=; b=POChdIHhg2usxjKtmvGkrwxu+7Sm3nr4CcG0NTMUazml6bSfo8OWJjQ+STg1BiYK97 3WyCmmv+c0z9NgIzxMitRz7c/uXUYD/I6vyM/hWGNjdM9QcPqAqsvtO9XGQaME9Icn6M M3ubsFf4WZeCIYPCh9qiF1W2TfMzg0fN3/LJMOdKE4Vw7Pf+Eqtka10sJ9gAyJoaQVTT H21OwqvlSxl72oWd/b0kQdtM4WCIiOZjKIN8TVX8pHTmMQXhIaHOJsBvBUtc8IpBoK1T csmgjavOsUvvT6BaU69b+jDFxKRaCv1qgLcU7og3OSkbx87I0XiV2rhiJemelrhhdZTJ vLEA== X-Gm-Message-State: AFqh2koyP+EXAbSQWhob+rZ1PpDfEj/7rQlkkR8enFrcvoDC93IybTIZ jwXCdWP6DsZ0ApQ1dfaXea6D2VboYRUr9MG0 X-Google-Smtp-Source: AMrXdXsgJycGVLQN1O499jiw5YbDs7XZN71Jhu3q7NvMnXUhtn9uwjA//v03i/WDdpW/7BXZRApI4g== X-Received: by 2002:a05:6e02:6c6:b0:30f:618:d931 with SMTP id p6-20020a056e0206c600b0030f0618d931mr3198443ils.10.1673977767318; Tue, 17 Jan 2023 09:49:27 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:26 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 48/70] bootstd: Set the distro_bootpart env var with scripts Date: Tue, 17 Jan 2023 10:47:58 -0700 Message-Id: <20230117174820.1281477-49-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This environment variable is supposed to be set so that the script knows which partition holds the script. Set it before invoking the script. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_script.c | 3 +++ include/bootflow.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index 3a3907d75b7..7050e45addb 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -125,6 +125,8 @@ static int script_boot(struct udevice *dev, struct bootflow *bflow) ret = env_set("devtype", blk_get_devtype(bflow->blk)); if (!ret) ret = env_set_hex("devnum", desc->devnum); + if (!ret) + ret = env_set_hex("distro_bootpart", bflow->part); if (!ret) ret = env_set("prefix", bflow->subdir); if (!ret && IS_ENABLED(CONFIG_ARCH_SUNXI) && @@ -135,6 +137,7 @@ static int script_boot(struct udevice *dev, struct bootflow *bflow) log_debug("devtype: %s\n", env_get("devtype")); log_debug("devnum: %s\n", env_get("devnum")); + log_debug("distro_bootpart: %s\n", env_get("distro_bootpart")); log_debug("prefix: %s\n", env_get("prefix")); log_debug("mmc_bootdev: %s\n", env_get("mmc_bootdev")); diff --git a/include/bootflow.h b/include/bootflow.h index bf71b09edad..ed9b61f5118 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -144,6 +144,8 @@ enum bootflow_flags_t { * appear first, then the global ones, if any * @doing_global: true if we are iterating through the global bootmeths (which * happens before the normal ones) + * @method_flags: flags controlling which methods should be used for this @dev + * (enum bootflow_meth_flags_t) */ struct bootflow_iter { int flags; @@ -161,6 +163,7 @@ struct bootflow_iter { int first_glob_method; struct udevice **method_order; bool doing_global; + int method_flags; }; /** From patchwork Tue Jan 17 17:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727644 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MC3YZBhe; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGnh00Bwz23gc for ; Wed, 18 Jan 2023 04:57:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59A5F856DD; Tue, 17 Jan 2023 18:51:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="MC3YZBhe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D56E58564A; Tue, 17 Jan 2023 18:50:40 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 322FE8564A for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x131.google.com with SMTP id u8so15738910ilq.13 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h/qYv/Ega48r3s/6H+fDn5lXShOHlqz0EAYeJMTAIpw=; b=MC3YZBheAvakuOgmcKZGcAhsw7KWb52l/R9shHE2hhCsa41utWJ61YDf6+f0QA/bM+ C6Dmy0o4z8gTU/eLl5vd0aRyOduP50bxwdHUXe1TsHJu6M2UrnoZo0r4LH9lldvcBbNY EBCjIAk2yF7T8SAbN1VZ/KEcI2VpTcBhVJFEg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h/qYv/Ega48r3s/6H+fDn5lXShOHlqz0EAYeJMTAIpw=; b=TLWeCUZxrf5H+qWcm5rpLGwnAM0D1DEJ3o+fnP2yu9EJMPWOKofTpOM4I2hiBydoAO WaPVTqgBVvQ9q7o96m6lABml6jzhlu8hi+i9lmSpp3+7hvIGpqwfyDQHd0oC9b3Z6Elz TgI3DmT3Z8Z1ramiFr6QTcjRaspjiqJES8VSmoe/HnLZnvu86udfiVueqv02oLKyYIej fpdmp2OweyfqS8qx369XOk5ubWbGTyPPLWXiReJMOUkQA8Gx4YB5gnsNhz4ByEBcXMun JIsOUKL1OtxBv62pZQt3qaKJ1WY0EsBoPVH+SvVQaLd+0ew5T7JuUzIjLYMvSeNWHU/c KHyw== X-Gm-Message-State: AFqh2krnxC0wwrqqDbxLsq0g0wklXyvYMjNRjZ3b8JW+HB8sr/5vt2cH Y9NGbzcm7FqZLOVSpzwttzkHNpbJpKAbaFW4 X-Google-Smtp-Source: AMrXdXsMuFraW0gl2N6k65HPNSvhYCQm5RlzWBu+Z9/HGzZIayAPdcE4v+5b1/Jhx93cKsse4Z3L+A== X-Received: by 2002:a05:6e02:221d:b0:30e:ef30:49fc with SMTP id j29-20020a056e02221d00b0030eef3049fcmr3511729ilf.32.1673977768323; Tue, 17 Jan 2023 09:49:28 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:27 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 49/70] bootstd: Update docs on bootmeth_try_file() for sandbox Date: Tue, 17 Jan 2023 10:47:59 -0700 Message-Id: <20230117174820.1281477-50-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Mention that this function is also used with a NULL block devices to access files on the host, when using sandbox. Update the comment on struct bootflow also. Signed-off-by: Simon Glass --- (no changes since v1) include/bootflow.h | 2 +- include/bootmeth.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bootflow.h b/include/bootflow.h index ed9b61f5118..735ed87a001 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -43,7 +43,7 @@ enum bootflow_state_t { * @glob_node: Points to siblings in the global list (all bootdev) * @dev: Bootdevice device which produced this bootflow * @blk: Block device which contains this bootflow, NULL if this is a network - * device + * device or sandbox 'host' device * @part: Partition number (0 for whole device) * @fs_type: Filesystem type (FS_TYPE...) if this is fixed by the media, else 0. * For example, the sandbox host-filesystem bootdev sets this to diff --git a/include/bootmeth.h b/include/bootmeth.h index 669b14ce81e..bdce301e925 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -240,7 +240,7 @@ int bootmeth_set_order(const char *order_str); * caller before reading the file. * * @bflow: Information about file to try - * @desc: Block descriptor to read from + * @desc: Block descriptor to read from (NULL for sandbox host) * @prefix: Filename prefix to prepend to @fname (NULL for none) * @fname: Filename to read * Return: 0 if OK, -ENOMEM if not enough memory to allocate bflow->fname, From patchwork Tue Jan 17 17:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727650 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YJflpUw2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGpz0lWHz23gH for ; Wed, 18 Jan 2023 04:58:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FC4F856DF; Tue, 17 Jan 2023 18:51:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="YJflpUw2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D91185646; Tue, 17 Jan 2023 18:50:44 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 8AB4685662 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12e.google.com with SMTP id i17so10915695ila.9 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wiBBzNfu+db1/PB4GF6RILZmBBNYcfvmfJ3PdTwYgss=; b=YJflpUw237kem/PqDrld6VuW//DdyuH37cM7659xvwcyodd5H4QPgMp2Gr9hEulhOF vlkvVtN7edWOqOr+AYr4szhP6lT1tmMCA7B7j+13Qs0fJSdD8vQCaUmlQtDeimwPyLKg HptjXygwFGQl4cTWLAxVIh1bfQ4+oP0Op7h4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wiBBzNfu+db1/PB4GF6RILZmBBNYcfvmfJ3PdTwYgss=; b=aQY56+5b66L0IShbkz465uK8qyj3taRuItHqnWPxIXwUU7Ow2IGVfY5F6Ma/7RTtID bh3sSH/0gThYlanZ2EDcgeYawYjkKa0T3pf0xue6F4CUtllSbnJAhj5dXqVOOdUG+qFj 9Wkd/qfBugCIvFo0kqEwKorlK3pbK8wRss1JsX2NU1w0hdgKKOIa09BujN9sy5XZ17cm 8oe/Q7aM7lrjztWuV7pjf8k2oZ+DLwDACzbHrOx2AeOMnfps41kj6GmHArGImcrNWESl zztbAHhpNxG0LfjNSWQQ+OSNJZ+EJOW4tXPRBKWFb6unUdPGuEnx76nS/ISnJBQNs5Gu YLhQ== X-Gm-Message-State: AFqh2kp2kgyIBuiIWULEGv/HdEbe6qy+G+kv9EYl7IcUgVOB/v+IvoB9 Oil8xZiBER/MH+ByYeYpmVEirv64cQStrtZ5 X-Google-Smtp-Source: AMrXdXtfZUAMJvLfL4U6dnJQo7WDFBJo9+UGndeAquI7fm20sN16xEMYPqp58NfFfEhVX5fDYJ1hDQ== X-Received: by 2002:a05:6e02:1cc9:b0:30c:4558:1376 with SMTP id s9-20020a056e021cc900b0030c45581376mr3004217ill.3.1673977769385; Tue, 17 Jan 2023 09:49:29 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:28 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 50/70] bootstd: Move label parsing into its own function Date: Tue, 17 Jan 2023 10:48:00 -0700 Message-Id: <20230117174820.1281477-51-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This is complicated enough to merit its own function, particularly as we are about to add to it. Create a new label_to_uclass() function to decode a label. Also update the code to ignore an empty label or one consisting of just a number. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 48 ++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 3dcf317c150..f43307d006d 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -354,6 +354,37 @@ int bootdev_unbind_dev(struct udevice *parent) return 0; } +/** + * label_to_uclass() - Convert a label to a uclass and sequence number + * + * @label: Label to look up (e.g. "mmc1" or "mmc0") + * @seqp: Returns the sequence number, or -1 if none + * Returns: sequence number on success, else -ve error code + */ +static int label_to_uclass(const char *label, int *seqp) +{ + enum uclass_id id; + const char *end; + int seq, len; + + seq = trailing_strtoln_end(label, NULL, &end); + len = end - label; + if (!len) + return -EINVAL; + id = uclass_get_by_namelen(label, len); + log_debug("find %s: seq=%d, id=%d/%s\n", label, seq, id, + uclass_get_name(id)); + if (id == UCLASS_INVALID) { + log_warning("Unknown uclass '%s' in label\n", label); + return -EINVAL; + } + if (id == UCLASS_USB) + id = UCLASS_MASS_STORAGE; + *seqp = seq; + + return id; +} + /** * bootdev_find_by_label() - Convert a label string to a bootdev device * @@ -372,19 +403,12 @@ int bootdev_find_by_label(const char *label, struct udevice **devp) struct udevice *media; struct uclass *uc; enum uclass_id id; - const char *end; - int seq; + int seq, ret; - seq = trailing_strtoln_end(label, NULL, &end); - id = uclass_get_by_namelen(label, end - label); - log_debug("find %s: seq=%d, id=%d/%s\n", label, seq, id, - uclass_get_name(id)); - if (id == UCLASS_INVALID) { - log_warning("Unknown uclass '%s' in label\n", label); - return -EINVAL; - } - if (id == UCLASS_USB) - id = UCLASS_MASS_STORAGE; + ret = label_to_uclass(label, &seq); + if (ret < 0) + return log_msg_ret("uc", ret); + id = ret; /* Iterate through devices in the media uclass (e.g. UCLASS_MMC) */ uclass_id_foreach_dev(id, media, uc) { From patchwork Tue Jan 17 17:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727643 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DfNUEJlY; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGnS6GvKz23gH for ; Wed, 18 Jan 2023 04:57:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59E16856D7; Tue, 17 Jan 2023 18:51:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="DfNUEJlY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 748E385657; Tue, 17 Jan 2023 18:50:40 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 2F5BF855EE for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id i1so12259151ilu.8 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QjX+rNWLcF9ZTsKpYaTxMUjwDOHUDjuUQABTPldvWyk=; b=DfNUEJlYnzQOZ+gKHNTObohMgcL8RTpihM/ZIzzYHGZGS8KvjvvIUOqwp4qw8oqtci H7Xi0vu62VL4YDJZil+7stzUjIHdaoWpfVoA0iDOdXhUvq/mzT8V5uMjVSVS5e7d2eyy imCNbp7buj+gZGcyukVzJ+5rVXpYN1CLBGvJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QjX+rNWLcF9ZTsKpYaTxMUjwDOHUDjuUQABTPldvWyk=; b=ly8y1eRodhrBZwtCP836LM/sioVCOTGUNMTc9J1MHPzZviHtD+oW0hLzWJUO6NsXDn jND+CUS7eh6VwvsH31tERrgx74JZxWANdflM30FeTmmckfhSgmZA9osFgg7TQQ6AnnpB 9SDqtvOyHwIYVQ7XOa3vv95xZjZXS3cP0IWUUtaWGaHHIsJA71eLDPBr+PMTXNenDSSQ +IRXnJ2LcIEerNyodw17YIB0Ptb8lXdfSBocsfzM+hS2070+ZfxvYdeIXYyv7k/8bugN 6UcA/Dwg+5QqxJ+7ehVU8GGZw2HpGGgN/j/lyljWmiJF28GKGFj924rtB6ZtVBVVMUxz u2ZQ== X-Gm-Message-State: AFqh2kreZdRL+blviMW1sjmiR6peX/pBsRVdcdaq+KjLe0w6rm5EeFN9 djhiCl7oBdH8lV7OzrmlGZp/7rRL44rxw1s/ X-Google-Smtp-Source: AMrXdXulWfxTc5lBd4iX3G7m8cM0G/xUjvvJBm+hVRIBeR775vmGTbm0QQ8yms5s58bSesdexE7HRg== X-Received: by 2002:a05:6e02:4a1:b0:304:c91b:4a5d with SMTP id e1-20020a056e0204a100b00304c91b4a5dmr3071766ils.9.1673977785452; Tue, 17 Jan 2023 09:49:45 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:45 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 51/70] bootstd: Add a new bootmeth method to set the bootflow Date: Tue, 17 Jan 2023 10:48:01 -0700 Message-Id: <20230117174820.1281477-52-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Normally the bootmeth driver reads the bootflow from the bootdev, since it knows the correct way to do it. However it is easier for some bootdevs to handle this themselves. For example, reading from SPI flash is quite different from other devices. Add a way for the bootdev to pass a bootflow to the bootmeth, so that this can be supported. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth-uclass.c | 11 +++++++++++ include/bootmeth.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 4c3529d1555..2aee1e0f0c5 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -50,6 +50,17 @@ int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow) return ops->read_bootflow(dev, bflow); } +int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow, + char *buf, int size) +{ + const struct bootmeth_ops *ops = bootmeth_get_ops(dev); + + if (!ops->set_bootflow) + return -ENOSYS; + + return ops->set_bootflow(dev, bflow, buf, size); +} + int bootmeth_boot(struct udevice *dev, struct bootflow *bflow) { const struct bootmeth_ops *ops = bootmeth_get_ops(dev); diff --git a/include/bootmeth.h b/include/bootmeth.h index bdce301e925..b12dfd42c90 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -87,6 +87,22 @@ struct bootmeth_ops { */ int (*read_bootflow)(struct udevice *dev, struct bootflow *bflow); + /** + * set_bootflow() - set the bootflow for a device + * + * This provides a bootflow file to the bootmeth, to see if it is valid. + * If it is, the bootflow is set up accordingly. + * + * @dev: Bootmethod device to use + * @bflow: On entry, provides bootdev. + * Returns updated bootflow if found + * @buf: Buffer containing the possible bootflow file + * @size: Size of file + * Return: 0 if OK, -ve on error + */ + int (*set_bootflow)(struct udevice *dev, struct bootflow *bflow, + char *buf, int size); + /** * read_file() - read a file needed for a bootflow * @@ -173,6 +189,23 @@ int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter); */ int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow); +/** + * bootmeth_set_bootflow() - set the bootflow for a device + * + * This provides a bootflow file to the bootmeth, to see if it is valid. + * If it is, the bootflow is set up accordingly. + * + * @dev: Bootmethod device to use + * @bflow: On entry, provides bootdev. + * Returns updated bootflow if found + * @buf: Buffer containing the possible bootflow file (must be allocated + * by caller to @size + 1 bytes) + * @size: Size of file + * Return: 0 if OK, -ve on error + */ +int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow, + char *buf, int size); + /** * bootmeth_read_file() - read a file needed for a bootflow * From patchwork Tue Jan 17 17:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727657 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IpjATQ40; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGrl66VQz23fT for ; Wed, 18 Jan 2023 05:00:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B85C3856E8; Tue, 17 Jan 2023 18:51:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="IpjATQ40"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D05B58566B; Tue, 17 Jan 2023 18:50:48 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 B5AE585668 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x131.google.com with SMTP id w2so2063303ilg.1 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q7zU99W4WTPkOk9InpOL3N5ipQP7akFCVLM9MlJc0+o=; b=IpjATQ40sDGcwPURPFuFhzZGy+MxLMQYAw/qhfj6anVwEh+df+bI2fLbmq0Ut8mUCP ctYuxqp+FdqganOxYsZYwKWEKFzj+Sr+qSYr9bMJ13XdN/biLaLgpayBuDGYlTRFVgDz eoMnLDhqDmufj5dA6/DG/RDO4DVHtwF7vPrG8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q7zU99W4WTPkOk9InpOL3N5ipQP7akFCVLM9MlJc0+o=; b=5mHrMLV+oZ/05vTaXoH4MFbAWwEtdQ7TgOVsEHd1qT9y2zdaubzOUM6oFKhJ41ObwX 6meKiSSh4bGbjxdbzysnI1uK8vMH8/SRo7a1OGc/oJuC25czrvt0zhwXgisGnsBWmoNS rRlwBRamUuUD102elmSHcNWkKl0CivdLtjYjFlnLub0/Ar5Dw0ikQGM5Cgj5CEmBfs5n ge6zpVlrokBlqVEDdxkPDFSsnfut0KYPkzkg93zFp051s1YuBHPGaxo0uQfkErVx3kw7 33V9rzIpfFVGRdRNFMVIzaCzfeuScRgOREE9/Dj6fuoIztMwezT7/fvr3mRzy/04DmX6 cCmg== X-Gm-Message-State: AFqh2kpFKW+F9q4jW3imF0eum0fxUOq5wiwgeHiogTGY+RhB6XYPZwyy 8Cq+lNrb4hG5N0pCRRTGOhF9qlnbL/ByNm9b X-Google-Smtp-Source: AMrXdXubp9vXjFBV9ksWqQVGp+OR5ebXXHZqMRa7SMP910krdpYCKoEEkrzO6LactIONZq4JvvT/TQ== X-Received: by 2002:a05:6e02:214b:b0:30d:bfa3:ebce with SMTP id d11-20020a056e02214b00b0030dbfa3ebcemr3397837ilv.27.1673977786584; Tue, 17 Jan 2023 09:49:46 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:46 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 52/70] sandbox: Allow SPI flash bootdevs to be disabled for tests Date: Tue, 17 Jan 2023 10:48:02 -0700 Message-Id: <20230117174820.1281477-53-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Most tests don't want these and they can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/state.c | 14 ++++++++++++++ arch/sandbox/include/asm/state.h | 1 + arch/sandbox/include/asm/test.h | 14 ++++++++++++++ include/test/test.h | 19 +++++++++++++++++++ test/test-main.c | 1 + 5 files changed, 49 insertions(+) diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 267f280df14..69da378ab59 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -460,6 +460,20 @@ bool sandbox_eth_enabled(void) return !state->disable_eth; } +void sandbox_sf_set_enable_bootdevs(bool enable) +{ + struct sandbox_state *state = state_get_current(); + + state->disable_sf_bootdevs = !enable; +} + +bool sandbox_sf_bootdev_enabled(void) +{ + struct sandbox_state *state = state_get_current(); + + return !state->disable_sf_bootdevs; +} + int state_init(void) { state = &main_state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index f125fb87af7..59a20595f51 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -97,6 +97,7 @@ struct sandbox_state { bool handle_signals; /* Handle signals within sandbox */ bool autoboot_keyed; /* Use keyed-autoboot feature */ bool disable_eth; /* Disable Ethernet devices */ + bool disable_sf_bootdevs; /* Don't bind SPI flash bootdevs */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 1c522e38f3d..4853dc948f3 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -360,4 +360,18 @@ void sandbox_set_eth_enable(bool enable); */ bool sandbox_eth_enabled(void); +/** + * sandbox_sf_bootdev_enabled() - Check if SPI flash bootdevs should be bound + * + * Returns: true if sandbox should bind bootdevs for SPI flash, false if not + */ +bool sandbox_sf_bootdev_enabled(void); + +/** + * sandbox_sf_set_enable_bootdevs() - Enable / disable the SPI flash bootdevs + * + * @enable: true to bind the SPI flash bootdevs, false to skip + */ +void sandbox_sf_set_enable_bootdevs(bool enable); + #endif diff --git a/include/test/test.h b/include/test/test.h index 752897cf06f..838e3ce8a8f 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -72,6 +72,7 @@ enum { */ UT_TESTF_MANUAL = BIT(8), UT_TESTF_ETH_BOOTDEV = BIT(9), /* enable Ethernet bootdevs */ + UT_TESTF_SF_BOOTDEV = BIT(10), /* enable SPI flash bootdevs */ }; /** @@ -222,4 +223,22 @@ static inline bool test_eth_bootdev_enabled(void) return enabled; } +/* Allow SPI flash bootdev to be ignored for testing purposes */ +static inline bool test_sf_bootdev_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_sf_bootdev_enabled(); +#endif + return enabled; +} + +static inline void test_sf_set_enable_bootdevs(bool enable) +{ +#ifdef CONFIG_SANDBOX + sandbox_sf_set_enable_bootdevs(enable); +#endif +} + #endif /* __TEST_TEST_H */ diff --git a/test/test-main.c b/test/test-main.c index 9d0f6643d5e..ea959f4e859 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -309,6 +309,7 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) * only set this if we know the ethernet uclass will be created */ eth_set_enable_bootdevs(test->flags & UT_TESTF_ETH_BOOTDEV); + test_sf_set_enable_bootdevs(test->flags & UT_TESTF_SF_BOOTDEV); ut_assertok(dm_extended_scan(false)); } From patchwork Tue Jan 17 17:48:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727658 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=A1UuLdT/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGs00TXRz23fT for ; Wed, 18 Jan 2023 05:00:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63E98856FA; Tue, 17 Jan 2023 18:51:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="A1UuLdT/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB44A8566E; Tue, 17 Jan 2023 18:50:49 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 001298566E for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id v6so6225372ilq.3 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LJ9VdIyVNzHXAOPwHYB+WHg7Rruvh0Y9VY5fDoSXZX4=; b=A1UuLdT/55QTMmNlvc8JwQUiokh2lB6Amx+Dpo6cw7aumOcQDdLiDLv6lG/Z9Z/nTe h8+xdXLKOlDkoZucW4UWKo+r+Xd1bUvrxBJ+FH8Mt9yYHz/uSkZqoEP+cvVahD04HhVi AkfMYAO/3oEpdCovIbuN0yHryaK2RPXQ3CSv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LJ9VdIyVNzHXAOPwHYB+WHg7Rruvh0Y9VY5fDoSXZX4=; b=2rIaSt7O5ci0IKEMnnVDMGjV7NgRjHrydGi5ueo7tQ89LOEwUTyklrNCEgFAUSNkRN TR8tM3fnUjFmQQjSvHU9buaJ0MEcY7YRGFpWE+7rMn5OMYGuZRxc810UFHvMxnhTCgty AqETVFbtDMWZSvuf0vREHIRPEhGwgZ8pma9HZ9PDjqNXuZRi6290bN4Yqqhe7IXtrwBn /NCYOrOwl9Gq5hjsuChx2VoRooNouw7ifHBQhD5IJSBIMVvuOi9tt8W8oNsqdFnUpC23 5WAytUxmeXTMoXzl7l6k36ezA2yxtCKlhpnB/+tyWvUefcVmCobVcTJXV4g9dq1gdtrT 4AKw== X-Gm-Message-State: AFqh2kr4Nd8gfdG3383VNfy70gCxtpfPxR2T8rh2gPKTehGd1ak3ByXx 4LujlV5NMQ+VnljSzylivdjER8v65WfsnKu1 X-Google-Smtp-Source: AMrXdXtnwi3nOREb+gIRl9uEesfx5WvbfNemKOgImo+Fd90Vt5Fn6IQcNgyMCUkZmNfnf18fz4IY7Q== X-Received: by 2002:a92:7f05:0:b0:30c:436d:a6ab with SMTP id a5-20020a927f05000000b0030c436da6abmr2724723ild.12.1673977787679; Tue, 17 Jan 2023 09:49:47 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:47 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 53/70] bootstd: Add a SPI flash bootdev Date: Tue, 17 Jan 2023 10:48:03 -0700 Message-Id: <20230117174820.1281477-54-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a bootdev for SPI flash so that these devices can be used with standard boot. It only supports loading a script. Add a special case for the label, since we want to use "spi", not "spi_flash". Enable the new bootdev on sandbox. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 10 +++- boot/bootflow.c | 12 +++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + drivers/mtd/spi/Kconfig | 8 +++ drivers/mtd/spi/Makefile | 1 + drivers/mtd/spi/sf-uclass.c | 11 ++++ drivers/mtd/spi/sf_bootdev.c | 82 ++++++++++++++++++++++++++++++ include/bootflow.h | 9 ++++ test/boot/bootdev.c | 19 ++++--- 10 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 drivers/mtd/spi/sf_bootdev.c diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index f43307d006d..dd9ec668e16 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -375,8 +375,14 @@ static int label_to_uclass(const char *label, int *seqp) log_debug("find %s: seq=%d, id=%d/%s\n", label, seq, id, uclass_get_name(id)); if (id == UCLASS_INVALID) { - log_warning("Unknown uclass '%s' in label\n", label); - return -EINVAL; + /* try some special cases */ + if (IS_ENABLED(CONFIG_BOOTDEV_SPI_FLASH) && + !strncmp("spi", label, len)) { + id = UCLASS_SPI_FLASH; + } else { + log_warning("Unknown uclass '%s' in label\n", label); + return -EINVAL; + } } if (id == UCLASS_USB) id = UCLASS_MASS_STORAGE; diff --git a/boot/bootflow.c b/boot/bootflow.c index 52cc2f9d548..d2dbc9d4450 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -440,6 +440,18 @@ int bootflow_iter_check_blk(const struct bootflow_iter *iter) return -ENOTSUPP; } +int bootflow_iter_check_sf(const struct bootflow_iter *iter) +{ + const struct udevice *media = dev_get_parent(iter->dev); + enum uclass_id id = device_get_uclass_id(media); + + log_debug("uclass %d: %s\n", id, uclass_get_name(id)); + if (id == UCLASS_SPI_FLASH) + return 0; + + return -ENOTSUPP; +} + int bootflow_iter_check_net(const struct bootflow_iter *iter) { const struct udevice *media = dev_get_parent(iter->dev); diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 4a2f94f65bc..34c342b6f58 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -211,6 +211,7 @@ CONFIG_MMC_SANDBOX=y CONFIG_MMC_SDHCI=y CONFIG_MTD=y CONFIG_SPI_FLASH_SANDBOX=y +CONFIG_BOOTDEV_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_EON=y CONFIG_SPI_FLASH_GIGADEVICE=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 6e8faf56797..f465b99a6bf 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -138,6 +138,7 @@ CONFIG_PWRSEQ=y CONFIG_I2C_EEPROM=y CONFIG_MMC_SANDBOX=y CONFIG_SPI_FLASH_SANDBOX=y +CONFIG_BOOTDEV_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_EON=y CONFIG_SPI_FLASH_GIGADEVICE=y diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig index 7b858a3a919..a9617c6c58c 100644 --- a/drivers/mtd/spi/Kconfig +++ b/drivers/mtd/spi/Kconfig @@ -80,6 +80,14 @@ config SF_DEFAULT_SPEED if SPI_FLASH +config BOOTDEV_SPI_FLASH + bool "SPI Flash bootdev support" + help + Enable a boot device for SPI flash. This allows reading a script + from SPI flash so that it can be used to boot an Operating System. + + If unsure, say N + config SPI_FLASH_SFDP_SUPPORT bool "SFDP table parsing support for SPI NOR flashes" depends on !SPI_FLASH_BAR diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index 99cc4185522..409395382f5 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -21,3 +21,4 @@ obj-$(CONFIG_SPI_FLASH) += spi-nor.o obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_MTD) += sf_mtd.o obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o +obj-$(CONFIG_$(SPL_TPL_)BOOTDEV_SPI_FLASH) += sf_bootdev.o diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index e6e650ef8c0..df1f75390c4 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -6,6 +6,7 @@ #define LOG_CATEGORY UCLASS_SPI_FLASH #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include "sf_internal.h" DECLARE_GLOBAL_DATA_PTR; @@ -86,6 +88,14 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, static int spi_flash_post_bind(struct udevice *dev) { + int ret; + + if (CONFIG_IS_ENABLED(BOOTDEV_SPI_FLASH) && test_sf_bootdev_enabled()) { + ret = bootdev_setup_for_dev(dev, "sf_bootdev"); + if (ret) + return log_msg_ret("bd", ret); + } + #if defined(CONFIG_NEEDS_MANUAL_RELOC) struct dm_spi_flash_ops *ops = sf_get_ops(dev); static int reloc_done; @@ -101,6 +111,7 @@ static int spi_flash_post_bind(struct udevice *dev) reloc_done++; } #endif + return 0; } diff --git a/drivers/mtd/spi/sf_bootdev.c b/drivers/mtd/spi/sf_bootdev.c new file mode 100644 index 00000000000..2272e8567ce --- /dev/null +++ b/drivers/mtd/spi/sf_bootdev.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Read a bootflow from SPI flash + * + * Copyright 2022 Google LLC + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int sf_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow) +{ + struct udevice *sf = dev_get_parent(dev); + uint size; + char *buf; + int ret; + + /* We only support the whole device, not partitions */ + if (iter->part) + return log_msg_ret("max", -ESHUTDOWN); + + size = env_get_hex("script_size_f", 0); + if (!size) + return log_msg_ret("sz", -EINVAL); + + buf = malloc(size + 1); + if (!buf) + return log_msg_ret("buf", -ENOMEM); + + ret = spi_flash_read_dm(sf, env_get_hex("script_offset_f", 0), + size, buf); + if (ret) + return log_msg_ret("cmd", -EINVAL); + bflow->state = BOOTFLOWST_MEDIA; + + ret = bootmeth_set_bootflow(bflow->method, bflow, buf, size); + if (ret) { + free(buf); + return log_msg_ret("method", ret); + } + + return 0; +} + +static int sf_bootdev_bind(struct udevice *dev) +{ + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_2_SCAN_FAST; + + return 0; +} + +struct bootdev_ops sf_bootdev_ops = { + .get_bootflow = sf_get_bootflow, +}; + +static const struct udevice_id sf_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-sf" }, + { } +}; + +U_BOOT_DRIVER(sf_bootdev) = { + .name = "sf_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &sf_bootdev_ops, + .bind = sf_bootdev_bind, + .of_match = sf_bootdev_ids, +}; + +BOOTDEV_HUNTER(sf_bootdev_hunter) = { + .prio = BOOTDEVP_2_SCAN_FAST, + .uclass = UCLASS_SPI_FLASH, + .drv = DM_DRIVER_REF(sf_bootdev), +}; diff --git a/include/bootflow.h b/include/bootflow.h index 735ed87a001..319dda8e0be 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -331,6 +331,15 @@ void bootflow_remove(struct bootflow *bflow); */ int bootflow_iter_check_blk(const struct bootflow_iter *iter); +/** + * bootflow_iter_check_sf() - Check that a bootflow uses SPI FLASH + * + * This checks the bootdev in the bootflow to make sure it uses SPI flash + * + * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet) + */ +int bootflow_iter_check_sf(const struct bootflow_iter *iter); + /** * bootflow_iter_check_net() - Check that a bootflow uses a network device * diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 2ad31a0ef66..ea0703fa5c8 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -243,9 +243,10 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline(" 10 mmc mmc_bootdev"); ut_assert_nextline(" 30 nvme nvme_bootdev"); ut_assert_nextline(" 30 scsi scsi_bootdev"); + ut_assert_nextline(" 30 spi_flash sf_bootdev"); ut_assert_nextline(" 40 usb usb_bootdev"); ut_assert_nextline(" 30 virtio virtio_bootdev"); - ut_assert_nextline("(total hunters: 7)"); + ut_assert_nextline("(total hunters: 8)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -253,8 +254,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is fifth in the list, so bit 5 */ - ut_asserteq(BIT(5), std->hunters_used); + /* USB is fifth in the list, so bit 6 */ + ut_asserteq(BIT(6), std->hunters_used); return 0; } @@ -274,7 +275,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_skip_to_line("(total hunters: 7)"); + ut_assert_skip_to_line("(total hunters: 8)"); ut_assert_console_end(); /* Scan all hunters */ @@ -288,10 +289,11 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline("Hunting with: nvme"); ut_assert_nextline("Hunting with: scsi"); ut_assert_nextline("scanning bus for devices..."); - ut_assert_skip_to_line("Hunting with: usb"); + ut_assert_skip_to_line("Hunting with: spi_flash"); + ut_assert_nextline("Hunting with: usb"); ut_assert_nextline( "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); - ut_assert_skip_to_line("Hunting with: virtio"); + ut_assert_nextline("Hunting with: virtio"); ut_assert_console_end(); /* List available hunters */ @@ -303,12 +305,13 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline(" 10 * mmc mmc_bootdev"); ut_assert_nextline(" 30 * nvme nvme_bootdev"); ut_assert_nextline(" 30 * scsi scsi_bootdev"); + ut_assert_nextline(" 30 * spi_flash sf_bootdev"); ut_assert_nextline(" 40 * usb usb_bootdev"); ut_assert_nextline(" 30 * virtio virtio_bootdev"); - ut_assert_nextline("(total hunters: 7)"); + ut_assert_nextline("(total hunters: 8)"); ut_assert_console_end(); - ut_asserteq(GENMASK(6, 0), std->hunters_used); + ut_asserteq(GENMASK(7, 0), std->hunters_used); return 0; } From patchwork Tue Jan 17 17:48:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727655 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Y62xyyge; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGr91Pszz23gH for ; Wed, 18 Jan 2023 04:59:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CB89856F9; Tue, 17 Jan 2023 18:51:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Y62xyyge"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC34D8564A; Tue, 17 Jan 2023 18:50:47 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 DCC5B8566B for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id g2so15757991ila.4 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Il5iJYwmdvipVy1Z6r/g6W3trB3ql4kVw+9vgkGCkAs=; b=Y62xyygeyFnmBMrxNpEKF2YyJlAVfOU3pdNy1BwZTkejS9BMAfX0t7wnMdFUM6TvCn OWThKBhQDgXd8YA3Ul3IddKvLRfckS2jI79rWRY2jbXooRxrjxvbHTxrCwzYXWBAb59c 0V5iJAigh+8ZjcQnBHN62mXvmxytdAVEAS3DE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Il5iJYwmdvipVy1Z6r/g6W3trB3ql4kVw+9vgkGCkAs=; b=LpkqZU6w3Z4mKIMK7yo7GN/tp4Bvmwbn0hO4I0LDWXqbmSomf27yayWiwS0TqKgUfo FPgtC+37WSFr4caIVVs3g13EwyrRVCbMRmAa3AZKEkWHvY6smM8hiXhyeSKY9cczMnuy vBIV3z5otFSOPU7MNiijtiTo7Fc8Kf2SjRZDDn+Y1nKZaHUgAso/wgdp57i6IWq7Txwd hhMuaqJ+IWn2nnGvPYcF04BWYZ2bgpV3rwIZYkff3cBxyf+InKH1A4oZ4v+m8r2bFKV6 dikKqAMG7Q8dy0ghkohAo7uGjYlMyO4tFcPeXZsmk00DHokXqEPc1ru1KHlpkNs/+909 JkNg== X-Gm-Message-State: AFqh2koCyTIhdpTASCPI7uWBI3D54XSuFurDl5/TXx/wnOlickbbFzac 8D2mzM3J/OXUDvxUV++bKoYHWrujIClcE0pG X-Google-Smtp-Source: AMrXdXv7CxIxrL8/KC9DmGmTTaVBvbV44GKbUJuEN7DiTMKPe87WWsaP/6crViUUNdkYa90VriubgA== X-Received: by 2002:a05:6e02:4a5:b0:303:8ffb:9345 with SMTP id e5-20020a056e0204a500b003038ffb9345mr18832789ils.17.1673977788813; Tue, 17 Jan 2023 09:49:48 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:48 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 54/70] bootstd: Support reading a script from network or SPI flash Date: Tue, 17 Jan 2023 10:48:04 -0700 Message-Id: <20230117174820.1281477-55-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present this bootmeth only supports a block device and the sandbox host filesystem. Add support for obtaining the script from a network device. Also implement the set_bootflow() method so that it is easy for other bootdevs (such as enabling SPI flash to support scripts). Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_script.c | 93 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 13 deletions(-) diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index 7050e45addb..a14c750ff61 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -19,18 +19,14 @@ #include #include #include +#include #define SCRIPT_FNAME1 "boot.scr.uimg" #define SCRIPT_FNAME2 "boot.scr" static int script_check(struct udevice *dev, struct bootflow_iter *iter) { - int ret; - - /* This only works on block devices */ - ret = bootflow_iter_check_blk(iter); - if (ret) - return log_msg_ret("blk", ret); + /* This works on block devices, network devices and SPI Flash */ return 0; } @@ -65,11 +61,11 @@ static int script_fill_info(struct bootflow *bflow) return 0; } -static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow) +static int script_read_bootflow_file(struct udevice *bootstd, + struct bootflow *bflow) { struct blk_desc *desc = NULL; const char *const *prefixes; - struct udevice *bootstd; const char *prefix; int ret, i; @@ -77,12 +73,12 @@ static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow) if (ret) return log_msg_ret("std", ret); - /* We require a partition table */ - if (!bflow->part) - return -ENOENT; - - if (bflow->blk) + if (bflow->blk) { + /* We require a partition table */ + if (!bflow->part) + return -ENOENT; desc = dev_get_uclass_plat(bflow->blk); + } prefixes = bootstd_get_prefixes(bootstd); i = 0; @@ -116,6 +112,76 @@ static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow) return 0; } +static int script_read_bootflow_net(struct bootflow *bflow) +{ + const char *addr_str; + int size, ret; + char *fname; + ulong addr; + + /* figure out the load address */ + addr_str = env_get("scriptaddr"); + addr = addr_str ? hextoul(addr_str, NULL) : image_load_addr; + + fname = env_get("boot_script_dhcp"); + if (!fname) + return log_msg_ret("dhc", -EINVAL); + + ret = dhcp_run(addr, fname, true); + if (ret) + return log_msg_ret("dhc", ret); + + size = env_get_hex("filesize", 0); + if (!size) + return log_msg_ret("sz", -EINVAL); + + bflow->buf = malloc(size + 1); + if (!bflow->buf) + return log_msg_ret("buf", -ENOMEM); + memcpy(bflow->buf, map_sysmem(addr, size), size); + bflow->buf[size] = '\0'; + bflow->size = size; + bflow->state = BOOTFLOWST_READY; + + return 0; +} + +static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + const struct udevice *media = dev_get_parent(bflow->dev); + struct udevice *bootstd; + int ret; + + ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd); + if (ret) + return log_msg_ret("std", ret); + + if (IS_ENABLED(CONFIG_CMD_DHCP) && + device_get_uclass_id(media) == UCLASS_ETH) { + /* we only support reading from one device, so ignore 'dev' */ + ret = script_read_bootflow_net(bflow); + if (ret) + return log_msg_ret("net", ret); + } else { + ret = script_read_bootflow_file(bootstd, bflow); + if (ret) + return log_msg_ret("blk", ret); + } + + return 0; +} + +static int script_set_bootflow(struct udevice *dev, struct bootflow *bflow, + char *buf, int size) +{ + buf[size] = '\0'; + bflow->buf = buf; + bflow->size = size; + bflow->state = BOOTFLOWST_READY; + + return 0; +} + static int script_boot(struct udevice *dev, struct bootflow *bflow) { struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); @@ -162,6 +228,7 @@ static int script_bootmeth_bind(struct udevice *dev) static struct bootmeth_ops script_bootmeth_ops = { .check = script_check, .read_bootflow = script_read_bootflow, + .set_bootflow = script_set_bootflow, .read_file = bootmeth_common_read_file, .boot = script_boot, }; From patchwork Tue Jan 17 17:48:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727656 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Zs4iTayu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGrP12Nnz23gH for ; Wed, 18 Jan 2023 05:00:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4862385701; Tue, 17 Jan 2023 18:51:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Zs4iTayu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2670085663; Tue, 17 Jan 2023 18:50:48 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 B3E0D85667 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id f8so9670991ilj.5 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Bw6I0TDbe5/xci2M9raG88YEFhcHZkFhw80wAsHxCw=; b=Zs4iTayuAv52bFASBFTwqUH6WyLxXskNrjzLzZ4nss4PFeJ5sMuy0Vxl5TT4Z78Ypv b4hGuMZGJHvoyj6AxNI7co4H6WsfbAZs78LBvA00x7dYZOTpLLYOnMVs5xf/2yyb5Cy9 kufr/+dPxD+QwpAjR18P/z9PgJWCzmaTe8hg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Bw6I0TDbe5/xci2M9raG88YEFhcHZkFhw80wAsHxCw=; b=FCxsipqPdF4xykJ+jSjAuFqI8D7TV3wrI4nEiLhd/LdZPeHECy8aBt/8DR+H5QOm6X L0CIXd88Z3HzUbdZGjhl6Aen1ytw+Idy9IWBdUvU/PQvtB5f1wpwiP0vD2j2g7waKAlq Hj/Wc4qUIFVfMRHB0rAwT5IYI+tqeGmIV9Vm/XIntKaz9dcl8j7fL9JTJSoZjVWaLkMJ PYzDl0OkCqUOVn+1vYZINdZSQwN686YXI1nAhwv0ZZG86xrjA3sRKcni67UtxG+r4RTF BnU/BtR7KUUAiC2Kjanqf5nXlVkNILEdEEPNiNyhz0yX/O3blCsOWCbvjJxG75t0bmkh +hnQ== X-Gm-Message-State: AFqh2koYcuWp7dxMnr8GJEOiQVYe+520allqdDVEE+FVgz2wS7INdaQs PcN8le89mrk6Zk8e4P970tfJBgXV8JC7AUjZ X-Google-Smtp-Source: AMrXdXtxgEFDo4Cr8DQQW+2DbEesRh/BaeX2h3wbfGY8KIIOjae2olkSUZwQFo8H4FggJUTgb7UlpQ== X-Received: by 2002:a05:6e02:d07:b0:30b:e56f:f2f7 with SMTP id g7-20020a056e020d0700b0030be56ff2f7mr3016665ilj.24.1673977789863; Tue, 17 Jan 2023 09:49:49 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:49 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 55/70] bootstd: Treat DHCP and PXE as bootdev labels Date: Tue, 17 Jan 2023 10:48:05 -0700 Message-Id: <20230117174820.1281477-56-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean These are associated with the ethernet boot device but do not match its uclass name, so handle them as special cases. Provide a way to pass flags through with the bootdev so that we know how to process it. The flags are checked by the bootmeths, to ensure that only the selected bootmeth is used. While these both use the network device, they work quite differently. It is common to run only one of these, or to run PXE before DHCP. Provide bootflow flags to control which methods are used. Check these in the two bootmeths so that only the chosen one is used. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 53 ++++++++++++++++++++++++------------------ boot/bootmeth_efi.c | 4 ++++ boot/bootmeth_pxe.c | 3 +++ boot/bootmeth_script.c | 2 ++ boot/vbe_simple_fw.c | 2 +- cmd/bootdev.c | 2 +- cmd/bootflow.c | 2 +- include/bootdev.h | 15 ++++++++---- include/bootflow.h | 15 ++++++++++++ test/boot/bootdev.c | 17 ++++++++++---- 10 files changed, 81 insertions(+), 34 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index dd9ec668e16..7ac42afd7b3 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -359,14 +359,17 @@ int bootdev_unbind_dev(struct udevice *parent) * * @label: Label to look up (e.g. "mmc1" or "mmc0") * @seqp: Returns the sequence number, or -1 if none + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none * Returns: sequence number on success, else -ve error code */ -static int label_to_uclass(const char *label, int *seqp) +static int label_to_uclass(const char *label, int *seqp, int *method_flagsp) { + int seq, len, method_flags; enum uclass_id id; const char *end; - int seq, len; + method_flags = 0; seq = trailing_strtoln_end(label, NULL, &end); len = end - label; if (!len) @@ -379,6 +382,14 @@ static int label_to_uclass(const char *label, int *seqp) if (IS_ENABLED(CONFIG_BOOTDEV_SPI_FLASH) && !strncmp("spi", label, len)) { id = UCLASS_SPI_FLASH; + } else if (IS_ENABLED(CONFIG_BOOTDEV_ETH) && + !strncmp("pxe", label, len)) { + id = UCLASS_ETH; + method_flags |= BOOTFLOW_METHF_PXE_ONLY; + } else if (IS_ENABLED(CONFIG_BOOTDEV_ETH) && + !strncmp("dhcp", label, len)) { + id = UCLASS_ETH; + method_flags |= BOOTFLOW_METHF_DHCP_ONLY; } else { log_warning("Unknown uclass '%s' in label\n", label); return -EINVAL; @@ -387,31 +398,21 @@ static int label_to_uclass(const char *label, int *seqp) if (id == UCLASS_USB) id = UCLASS_MASS_STORAGE; *seqp = seq; + if (method_flagsp) + *method_flagsp = method_flags; return id; } -/** - * bootdev_find_by_label() - Convert a label string to a bootdev device - * - * Looks up a label name to find the associated bootdev. For example, if the - * label name is "mmc2", this will find a bootdev for an mmc device whose - * sequence number is 2. - * - * @label: Label string to convert, e.g. "mmc2" - * @devp: Returns bootdev device corresponding to that boot label - * Return: 0 if OK, -EINVAL if the label name (e.g. "mmc") does not refer to a - * uclass, -ENOENT if no bootdev for that media has the sequence number - * (e.g. 2) - */ -int bootdev_find_by_label(const char *label, struct udevice **devp) +int bootdev_find_by_label(const char *label, struct udevice **devp, + int *method_flagsp) { + int seq, ret, method_flags = 0; struct udevice *media; struct uclass *uc; enum uclass_id id; - int seq, ret; - ret = label_to_uclass(label, &seq); + ret = label_to_uclass(label, &seq, &method_flags); if (ret < 0) return log_msg_ret("uc", ret); id = ret; @@ -441,6 +442,8 @@ int bootdev_find_by_label(const char *label, struct udevice **devp) if (!ret) { log_debug("- found %s\n", bdev->name); *devp = bdev; + if (method_flagsp) + *method_flagsp = method_flags; return 0; } log_debug("- no device in %s\n", media->name); @@ -450,9 +453,11 @@ int bootdev_find_by_label(const char *label, struct udevice **devp) return -ENOENT; } -int bootdev_find_by_any(const char *name, struct udevice **devp) +int bootdev_find_by_any(const char *name, struct udevice **devp, + int *method_flagsp) { struct udevice *dev; + int method_flags = 0; int ret, seq; char *endp; @@ -462,18 +467,18 @@ int bootdev_find_by_any(const char *name, struct udevice **devp) if (*endp) { ret = uclass_get_device_by_name(UCLASS_BOOTDEV, name, &dev); if (ret == -ENODEV) { - ret = bootdev_find_by_label(name, &dev); + ret = bootdev_find_by_label(name, &dev, &method_flags); if (ret) { printf("Cannot find bootdev '%s' (err=%d)\n", name, ret); - return ret; + return log_msg_ret("lab", ret); } ret = device_probe(dev); } if (ret) { printf("Cannot probe bootdev '%s' (err=%d)\n", name, ret); - return ret; + return log_msg_ret("pro", ret); } } else { ret = uclass_get_device_by_seq(UCLASS_BOOTDEV, seq, &dev); @@ -484,6 +489,8 @@ int bootdev_find_by_any(const char *name, struct udevice **devp) } *devp = dev; + if (method_flagsp) + *method_flagsp = method_flags; return 0; } @@ -593,7 +600,7 @@ static int build_order(struct udevice *bootstd, struct udevice **order, upto = 0; for (i = 0; labels[i]; i++) { - ret = bootdev_find_by_label(labels[i], &dev); + ret = bootdev_find_by_label(labels[i], &dev, NULL); if (!ret) { if (upto == max_count) { overflow_target = labels[i]; diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 53a0489b93c..67c972e3fe4 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -140,6 +140,10 @@ static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter) if (bootflow_iter_check_blk(iter) && bootflow_iter_check_net(iter)) return log_msg_ret("blk", -ENOTSUPP); + /* This works on block devices and network devices */ + if (iter->method_flags & BOOTFLOW_METHF_PXE_ONLY) + return log_msg_ret("pxe", -ENOTSUPP); + return 0; } diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 13e2ff486dc..ecf8557af83 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -48,6 +48,9 @@ static int distro_pxe_check(struct udevice *dev, struct bootflow_iter *iter) if (ret) return log_msg_ret("net", ret); + if (iter->method_flags & BOOTFLOW_METHF_DHCP_ONLY) + return log_msg_ret("dhcp", -ENOTSUPP); + return 0; } diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c index a14c750ff61..225eb18ee6c 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -27,6 +27,8 @@ static int script_check(struct udevice *dev, struct bootflow_iter *iter) { /* This works on block devices, network devices and SPI Flash */ + if (iter->method_flags & BOOTFLOW_METHF_PXE_ONLY) + return log_msg_ret("pxe", -ENOTSUPP); return 0; } diff --git a/boot/vbe_simple_fw.c b/boot/vbe_simple_fw.c index 0a49d286703..d59a704ddba 100644 --- a/boot/vbe_simple_fw.c +++ b/boot/vbe_simple_fw.c @@ -176,7 +176,7 @@ static int simple_load_from_image(struct spl_image_info *spl_image, priv = dev_get_priv(meth); log_debug("simple %s\n", priv->storage); - ret = bootdev_find_by_label(priv->storage, &bdev); + ret = bootdev_find_by_label(priv->storage, &bdev, NULL); if (ret) return log_msg_ret("bd", ret); log_debug("bootdev %s\n", bdev->name); diff --git a/cmd/bootdev.c b/cmd/bootdev.c index 28866faac76..5b1efaaee87 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -57,7 +57,7 @@ static int do_bootdev_select(struct cmd_tbl *cmdtp, int flag, int argc, std->cur_bootdev = NULL; return 0; } - if (bootdev_find_by_any(argv[1], &dev)) + if (bootdev_find_by_any(argv[1], &dev, NULL)) return CMD_RET_FAILURE; std->cur_bootdev = dev; diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 56dd35b69cf..c8b2f5efdeb 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -121,7 +121,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, if (argc > 1) { const char *label = argv[1]; - if (bootdev_find_by_any(label, &dev)) + if (bootdev_find_by_any(label, &dev, NULL)) return CMD_RET_FAILURE; } } else { diff --git a/include/bootdev.h b/include/bootdev.h index deef7890489..db03c5c032e 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -222,19 +222,26 @@ int bootdev_next_bootflow(struct bootflow **bflowp); * @label: Label to look up (e.g. "mmc1" or "mmc0") * @devp: Returns the bootdev device found, or NULL if none (note it does not * return the media device, but its bootdev child) + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails * Return: 0 if OK, -EINVAL if the uclass is not supported by this board, - * -ENOENT if there is no device with that number + * -ENOENT if there is no device with that number */ -int bootdev_find_by_label(const char *label, struct udevice **devp); +int bootdev_find_by_label(const char *label, struct udevice **devp, + int *method_flagsp); /** * bootdev_find_by_any() - Find a bootdev by name, label or sequence * * @name: name (e.g. "mmc2.bootdev"), label ("mmc2"), or sequence ("2") to find * @devp: returns the device found, on success - * Return: 0 if OK, -ve on error + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails + * Return: 0 if OK, -EINVAL if the uclass is not supported by this board, + * -ENOENT if there is no device with that number */ -int bootdev_find_by_any(const char *name, struct udevice **devp); +int bootdev_find_by_any(const char *name, struct udevice **devp, + int *method_flagsp); /** * bootdev_setup_iter_order() - Set up the ordering of bootdevs to scan diff --git a/include/bootflow.h b/include/bootflow.h index 319dda8e0be..9c6610bb922 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -104,6 +104,21 @@ enum bootflow_flags_t { BOOTFLOWF_SKIP_GLOBAL = 1 << 4, }; +/** + * enum bootflow_meth_flags_t - flags controlling which bootmeths are used + * + * Used during iteration, e.g. by bootdev_find_by_label(), to determine which + * bootmeths are used for the current bootdev. The flags reset when the bootdev + * changes + * + * @BOOTFLOW_METHF_DHCP_ONLY: Only use dhcp (scripts and EFI) + * @BOOTFLOW_METHF_PXE_ONLY: Only use pxe (PXE boot) + */ +enum bootflow_meth_flags_t { + BOOTFLOW_METHF_DHCP_ONLY = 1 << 0, + BOOTFLOW_METHF_PXE_ONLY = 1 << 1, +}; + /** * struct bootflow_iter - state for iterating through bootflows * diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index ea0703fa5c8..e6045b05d81 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -102,22 +102,31 @@ BOOTSTD_TEST(bootdev_test_cmd_select, UT_TESTF_DM | UT_TESTF_SCAN_FDT); static int bootdev_test_labels(struct unit_test_state *uts) { struct udevice *dev, *media; + int mflags = 0; - ut_assertok(bootdev_find_by_label("mmc2", &dev)); + ut_assertok(bootdev_find_by_label("mmc2", &dev, &mflags)); ut_asserteq(UCLASS_BOOTDEV, device_get_uclass_id(dev)); + ut_asserteq(0, mflags); media = dev_get_parent(dev); ut_asserteq(UCLASS_MMC, device_get_uclass_id(media)); ut_asserteq_str("mmc2", media->name); + /* Check method flags */ + ut_assertok(bootdev_find_by_label("pxe", &dev, &mflags)); + ut_asserteq(BOOTFLOW_METHF_PXE_ONLY, mflags); + ut_assertok(bootdev_find_by_label("dhcp", &dev, &mflags)); + ut_asserteq(BOOTFLOW_METHF_DHCP_ONLY, mflags); + /* Check invalid uclass */ - ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev)); + ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags)); /* Check unknown sequence number */ - ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev)); + ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev, &mflags)); return 0; } -BOOTSTD_TEST(bootdev_test_labels, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +BOOTSTD_TEST(bootdev_test_labels, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_ETH_BOOTDEV); /* Check bootdev ordering with the bootdev-order property */ static int bootdev_test_order(struct unit_test_state *uts) From patchwork Tue Jan 17 17:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727654 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PqYx9eo0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGqy0h6vz23gH for ; Wed, 18 Jan 2023 04:59:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C9B1A856F1; Tue, 17 Jan 2023 18:51:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="PqYx9eo0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72D4C85665; Tue, 17 Jan 2023 18:50:46 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 E7E7785673 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd31.google.com with SMTP id p189so3276715iod.0 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AThJnheAyYPtFSuVa1AY0FGwS/EhXi9dEH4w1tFOvI4=; b=PqYx9eo0YK04cezajNJmweEhGJ9uSYNY4LCviUnlt8PZR5SCcqzGN0z9ytt2uQuCVY xc03iOTrH5eUrdK5Yhnu42gl38UvHeoxwGjnyBff8G2e6gH2y9QsxFtuqvi48lz8pbiG +bHiSUvgGVr2Q1RvtbIcKLpFS57XK9YX6J6nM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AThJnheAyYPtFSuVa1AY0FGwS/EhXi9dEH4w1tFOvI4=; b=33DfEpvAm4mLxUWuPMvokxp5+jzM9+ou+OFiHJrTtdooGc+TQt2whBMPeN5inyeRWf N4HW2AOcGJfNY2Gmq82fYZJBPg+5jpUcfv/2GE93nvq+G+ho4xJ1fOmBzi5YqcLRbh/3 G5jHG5D2d34jAowpiAG0GeOG6pAh26ub5aLy1kCwwlCKnHjJbVLsFpPXHULxIrbe8YG2 4pXa0jHbDTTZqHfJKLIZGaAvxE1Z+eJbbeTIGbA48l4p7U8vNxgT2nVelqvOSYNc+Xfe BzT0FA1g78/wauheR79QIXQE3ju0IgW5ylIAgpOAONlUHM17pYnt6toEK/JuKgS+CnqZ L2Pw== X-Gm-Message-State: AFqh2koYtyaJzgGzyFUsCwV3TTBRqLNu1S9ZCb4+YYph0a1g8cNXgnQr VAtFkH3ljg0rsE5LT2OkeMKB+CrR91OHM5KB X-Google-Smtp-Source: AMrXdXvyZD+CaQR0XkVJ3F/3aWXvRND3w7l2N5nfRh65p+JL1JGxiiqFsvh8SuGMTSA6KSAwIcBgMQ== X-Received: by 2002:a5e:8b4b:0:b0:704:a441:de4a with SMTP id z11-20020a5e8b4b000000b00704a441de4amr3018991iom.7.1673977791095; Tue, 17 Jan 2023 09:49:51 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:50 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 56/70] bootstd: Use hunters when scanning for bootflows Date: Tue, 17 Jan 2023 10:48:06 -0700 Message-Id: <20230117174820.1281477-57-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a flag to control whether hunters are used when scanning for bootflows. Enable it by default and tidy up the flag comments a little. Fow now this has no effect, until a future patch enables this feature. Signed-off-by: Simon Glass --- (no changes since v1) cmd/bootflow.c | 5 ++++- include/bootflow.h | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index c8b2f5efdeb..fe58de5fa59 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -96,7 +96,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *dev; struct bootflow bflow; bool all = false, boot = false, errors = false, no_global = false; - bool list = false; + bool list = false, no_hunter = false; int num_valid = 0; bool has_args; int ret, i; @@ -115,6 +115,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, errors = strchr(argv[1], 'e'); no_global = strchr(argv[1], 'G'); list = strchr(argv[1], 'l'); + no_hunter = strchr(argv[1], 'H'); argc--; argv++; } @@ -141,6 +142,8 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, flags |= BOOTFLOWF_ALL; if (no_global) flags |= BOOTFLOWF_SKIP_GLOBAL; + if (!no_hunter) + flags |= BOOTFLOWF_HUNT; /* * If we have a device, just scan for bootflows attached to that device diff --git a/include/bootflow.h b/include/bootflow.h index 9c6610bb922..4012f4b8a82 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -91,17 +91,28 @@ struct bootflow { * enum bootflow_flags_t - flags for the bootflow iterator * * @BOOTFLOWF_FIXED: Only used fixed/internal media - * @BOOTFLOWF_SHOW: Show each bootdev before scanning it + * @BOOTFLOWF_SHOW: Show each bootdev before scanning it; show each hunter + * before using it * @BOOTFLOWF_ALL: Return bootflows with errors as well - * @BOOTFLOWF_SINGLE_DEV: Just scan one bootmeth - * @BOOTFLOWF_SKIP_GLOBAL: Don't scan global bootmeths + * @BOOTFLOWF_HUNT: Hunt for new bootdevs using the bootdrv hunters + * + * Internal flags: + * @BOOTFLOWF_SINGLE_DEV: (internal) Just scan one bootdev + * @BOOTFLOWF_SKIP_GLOBAL: (internal) Don't scan global bootmeths + * this uclass */ enum bootflow_flags_t { BOOTFLOWF_FIXED = 1 << 0, BOOTFLOWF_SHOW = 1 << 1, BOOTFLOWF_ALL = 1 << 2, - BOOTFLOWF_SINGLE_DEV = 1 << 3, - BOOTFLOWF_SKIP_GLOBAL = 1 << 4, + BOOTFLOWF_HUNT = 1 << 3, + + /* + * flags used internally by standard boot - do not set these when + * calling bootflow_scan_bootdev() etc. + */ + BOOTFLOWF_SINGLE_DEV = 1 << 16, + BOOTFLOWF_SKIP_GLOBAL = 1 << 17, }; /** From patchwork Tue Jan 17 17:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727653 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Tk7Cn40l; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGqj6pk6z23gH for ; Wed, 18 Jan 2023 04:59:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5949A856ED; Tue, 17 Jan 2023 18:51:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Tk7Cn40l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB19C8564A; Tue, 17 Jan 2023 18:50:45 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 AD1EF85665 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2f.google.com with SMTP id n85so7594325iod.7 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n9A6668ClzwweEoCFhMZa61GcYkizqVwksidIVKPB2o=; b=Tk7Cn40lwGgBrBtqvwaM6TA5HExpLUQD30SNrO3BY4eM0mb+b6dBe2SUMVxQoMa12Y oSbHRfM4KRp0UEJ1qpVrztJU5M5W26YYAr7y3INw74NwK3nbZQ1cAN9QMTTAUgzhvCzL ilQ3Y0WBN6WudGip45tTcyDz3VG+JAaktHCVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n9A6668ClzwweEoCFhMZa61GcYkizqVwksidIVKPB2o=; b=qKdxYM5lqRj1I043mPFHbhVYWBDyoa5Id67z6tZNoKoLH3E75vULV04BdaBuJqLjaQ 8uUfmOrZl3DyCRS5/as9XNENV6ybn6UdIoM54QtnpjSBuL4ZirMPho4ge6sehXs5PTQZ U5xp7p2SPhJ0Zk4WimlBl9o5gGBQRSkOLZtwp30t7rSa1azcRU1wM7ZIadMUvEIMl002 fC21ci28IgmP4tVLHVHqi/7rmPxIRDXsnrUdYHiXD///DAvKqIJvb2Q3L7pGfk11ru59 nFielgXibJYkKE5A6fdl+iUhuDzLKUbs9dJmjQo4aq5sTkfc3vTPuYSCFIEEPf2IylEE PfCg== X-Gm-Message-State: AFqh2krvUgsYxMT3r5TdVvEz/wp1kqiOP5ifdm1BgNRgjR5Y432WAKr5 5Qds2+y3Z6r2l50UH3szGV8ZxGlGaGXo3K1s X-Google-Smtp-Source: AMrXdXs8GmDfyjvCRTTosoqVrNMLGeKWhpIq6FvR075VzWf3L98Cm7lGaw95VZq8Wsr8Ze23ynKIiA== X-Received: by 2002:a6b:4410:0:b0:6d4:264f:2427 with SMTP id r16-20020a6b4410000000b006d4264f2427mr2652751ioa.21.1673977792144; Tue, 17 Jan 2023 09:49:52 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:51 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 57/70] bootstd: Allow hunting for bootdevs of a given priority Date: Tue, 17 Jan 2023 10:48:07 -0700 Message-Id: <20230117174820.1281477-58-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a way to run the hunter function for a particular priority, so that new bootdevs can be found. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 25 +++++++++++++++++++++++++ include/bootdev.h | 11 +++++++++++ test/boot/bootdev.c | 25 +++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 7ac42afd7b3..e8686159f2b 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -742,6 +742,31 @@ int bootdev_hunt(const char *spec, bool show) return result; } +int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show) +{ + struct bootdev_hunter *start; + int n_ent, i; + int result; + + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + result = 0; + + log_debug("Hunting for priority %d\n", prio); + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + int ret; + + if (prio != info->prio) + continue; + ret = bootdev_hunt_drv(info, i, show); + if (ret && ret != -ENOENT) + result = ret; + } + + return result; +} + void bootdev_list_hunters(struct bootstd_priv *std) { struct bootdev_hunter *orig, *start; diff --git a/include/bootdev.h b/include/bootdev.h index db03c5c032e..b7973fa5760 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -284,6 +284,17 @@ void bootdev_list_hunters(struct bootstd_priv *std); */ int bootdev_hunt(const char *spec, bool show); +/** + * bootdev_hunt_prio() - Hunt for bootdevs of a particular priority + * + * This runs all hunters which can find bootdevs of the given priority. + * + * @prio: Priority to use + * @show: true to show each hunter as it is used + * Returns: 0 if OK, -ve on error + */ +int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index e6045b05d81..f9653633a68 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -363,3 +363,28 @@ static int bootdev_test_bootable(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_bootable, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check hunting for bootdev of a particular priority */ +static int bootdev_test_hunt_prio(struct unit_test_state *uts) +{ + test_set_skip_delays(true); + + console_record_reset_enable(); + ut_assertok(bootdev_hunt_prio(BOOTDEVP_2_SCAN_FAST, false)); + ut_assert_nextline("scanning bus for devices..."); + ut_assert_skip_to_line(" Type: Hard Disk"); + ut_assert_nextlinen(" Capacity:"); + ut_assert_console_end(); + + /* now try a different priority, verbosely */ + ut_assertok(bootdev_hunt_prio(BOOTDEVP_3_SCAN_SLOW, true)); + ut_assert_nextline("Hunting with: ide"); + ut_assert_nextline("Bus 0: not available "); + ut_assert_nextline("Hunting with: usb"); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_hunt_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); From patchwork Tue Jan 17 17:48:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727660 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=oHhFawDM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGsS4r3Tz23fT for ; Wed, 18 Jan 2023 05:01:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E70A485704; Tue, 17 Jan 2023 18:51:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="oHhFawDM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 559A785687; Tue, 17 Jan 2023 18:50:50 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 DCA8785669 for ; Tue, 17 Jan 2023 18:50:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id m7so3211320ilh.7 for ; Tue, 17 Jan 2023 09:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aPp93eAyE78D4O911DNJGYqwpvlfhQuwggFvygqHKBM=; b=oHhFawDMWaWn8h+AO/5tnrany0Fhq5po1npc5j1G2wC/5UcsJlzAwCf62SZB2DSUze 3jj5ef4P79rGtC3YK1jaoWn+C6/sdq61o6SlYie1win16S2ZbnbhPZ334AE7QRLsM2fB KI9KuHD86MeORDGVD8Vm2+aiDTH6UM5x6iibE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aPp93eAyE78D4O911DNJGYqwpvlfhQuwggFvygqHKBM=; b=C/SOeAMF/puA8YVVJ8cTusfKR+ZnsnY5WKBfL56RAcKJh/mYNImk2XTtEl/u4KZn4e IgTtfc6FlHk75x+4gfSvuEuhKOcaDaWarJHKN7lCDSiDnqXNJjc8tDm6Cuyur5T0gODb YvDUA+QviNv68AA4h44snG9qsJrwi8MOi8A5qZO7Jg8lawqLa5pZfmHJ6r0WL4CI6phR uPv4ouug5YUwpdfarNJiAhzr39zXbxpJiQw7iprTBogo0aTwQSR5mKvTWAo2R2QMfDM7 ymgRbBpbIilGwYGvK1yIyQFWreHsEjCrVqSBb0uptDdoP6owZNl033knTzIbchuLVhb8 fJXw== X-Gm-Message-State: AFqh2krPfEFSAdYTf14FPbf6+iFsyQkUHYe1+9RH1HDc+jf6rI8K1Ct+ YngDET9FKVeHZhL8ccR1XiggwWGUN1RMW5WS X-Google-Smtp-Source: AMrXdXvekVViLs1tUeUVkSMwaLjtb1c8c5zocSxz/fjAOURufpy4j+1M5p1pmHvR1fX2oZWYfXLVQw== X-Received: by 2002:a92:909:0:b0:30d:71a3:a90c with SMTP id y9-20020a920909000000b0030d71a3a90cmr3483706ilg.32.1673977793251; Tue, 17 Jan 2023 09:49:53 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:52 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 58/70] bootstd: Add a new pre-scan priority for bootdevs Date: Tue, 17 Jan 2023 10:48:08 -0700 Message-Id: <20230117174820.1281477-59-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean We need extensions to be set up before we start trying to boot any of the bootdevs. Add a new priority before all the others for tht sort of thing. Also add a 'none' option, so that the first one is not 0. While we are here, comment enum bootdev_prio_t fully and expand the test for the 'bootdev hunt' command. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 8 ++++++ doc/develop/bootstd.rst | 2 +- drivers/block/ide.c | 4 +-- drivers/mmc/mmc_bootdev.c | 4 +-- drivers/mtd/spi/sf_bootdev.c | 4 +-- drivers/nvme/nvme-uclass.c | 4 +-- drivers/scsi/scsi_bootdev.c | 4 +-- drivers/usb/host/usb_bootdev.c | 4 +-- drivers/virtio/virtio-uclass.c | 4 +-- include/bootdev.h | 35 ++++++++++++++++++----- net/eth_bootdev.c | 4 +-- test/boot/bootdev.c | 51 +++++++++++++++++++++------------- 12 files changed, 84 insertions(+), 44 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index e8686159f2b..5ed310c554f 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -630,6 +630,7 @@ static int build_order(struct udevice *bootstd, struct udevice **order, int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) { struct udevice *bootstd, *dev = *devp, **order; + bool show = iter->flags & BOOTFLOWF_SHOW; struct uclass *uc; int count, upto; int ret; @@ -640,6 +641,13 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) return log_msg_ret("std", ret); } + /* hunt for any pre-scan devices */ + if (iter->flags & BOOTFLOWF_HUNT) { + ret = bootdev_hunt_prio(BOOTDEVP_1_PRE_SCAN, show); + if (ret) + return log_msg_ret("pre", ret); + } + /* Handle scanning a single device */ if (dev) { iter->flags |= BOOTFLOWF_SINGLE_DEV; diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst index 1ccc49424eb..bfa8cbd7561 100644 --- a/doc/develop/bootstd.rst +++ b/doc/develop/bootstd.rst @@ -211,7 +211,7 @@ A bootdev driver is typically fairly simple. Here is one for mmc:: { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_0_INTERNAL_FAST; + ucp->prio = BOOTDEVP_2_INTERNAL_FAST; return 0; } diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 80c8b64de2f..1ad9b6c1267 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1060,7 +1060,7 @@ static int ide_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_3_SCAN_SLOW; + ucp->prio = BOOTDEVP_5_SCAN_SLOW; return 0; } @@ -1089,7 +1089,7 @@ U_BOOT_DRIVER(ide_bootdev) = { }; BOOTDEV_HUNTER(ide_bootdev_hunter) = { - .prio = BOOTDEVP_3_SCAN_SLOW, + .prio = BOOTDEVP_5_SCAN_SLOW, .uclass = UCLASS_IDE, .hunt = ide_bootdev_hunt, .drv = DM_DRIVER_REF(ide_bootdev), diff --git a/drivers/mmc/mmc_bootdev.c b/drivers/mmc/mmc_bootdev.c index 300208f0c71..b57b8a62276 100644 --- a/drivers/mmc/mmc_bootdev.c +++ b/drivers/mmc/mmc_bootdev.c @@ -15,7 +15,7 @@ static int mmc_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_0_INTERNAL_FAST; + ucp->prio = BOOTDEVP_2_INTERNAL_FAST; return 0; } @@ -37,7 +37,7 @@ U_BOOT_DRIVER(mmc_bootdev) = { }; BOOTDEV_HUNTER(mmc_bootdev_hunter) = { - .prio = BOOTDEVP_0_INTERNAL_FAST, + .prio = BOOTDEVP_2_INTERNAL_FAST, .uclass = UCLASS_MMC, .drv = DM_DRIVER_REF(mmc_bootdev), }; diff --git a/drivers/mtd/spi/sf_bootdev.c b/drivers/mtd/spi/sf_bootdev.c index 2272e8567ce..d6b47b11ce4 100644 --- a/drivers/mtd/spi/sf_bootdev.c +++ b/drivers/mtd/spi/sf_bootdev.c @@ -53,7 +53,7 @@ static int sf_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_2_SCAN_FAST; + ucp->prio = BOOTDEVP_4_SCAN_FAST; return 0; } @@ -76,7 +76,7 @@ U_BOOT_DRIVER(sf_bootdev) = { }; BOOTDEV_HUNTER(sf_bootdev_hunter) = { - .prio = BOOTDEVP_2_SCAN_FAST, + .prio = BOOTDEVP_4_SCAN_FAST, .uclass = UCLASS_SPI_FLASH, .drv = DM_DRIVER_REF(sf_bootdev), }; diff --git a/drivers/nvme/nvme-uclass.c b/drivers/nvme/nvme-uclass.c index 7a8ff06e78c..f3af6a27b63 100644 --- a/drivers/nvme/nvme-uclass.c +++ b/drivers/nvme/nvme-uclass.c @@ -17,7 +17,7 @@ static int nvme_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_2_SCAN_FAST; + ucp->prio = BOOTDEVP_4_SCAN_FAST; return 0; } @@ -62,7 +62,7 @@ U_BOOT_DRIVER(nvme_bootdev) = { }; BOOTDEV_HUNTER(nvme_bootdev_hunter) = { - .prio = BOOTDEVP_2_SCAN_FAST, + .prio = BOOTDEVP_4_SCAN_FAST, .uclass = UCLASS_NVME, .hunt = nvme_bootdev_hunt, .drv = DM_DRIVER_REF(nvme_bootdev), diff --git a/drivers/scsi/scsi_bootdev.c b/drivers/scsi/scsi_bootdev.c index 2367b33da9c..991013fe1ef 100644 --- a/drivers/scsi/scsi_bootdev.c +++ b/drivers/scsi/scsi_bootdev.c @@ -16,7 +16,7 @@ static int scsi_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_2_SCAN_FAST; + ucp->prio = BOOTDEVP_4_SCAN_FAST; return 0; } @@ -55,7 +55,7 @@ U_BOOT_DRIVER(scsi_bootdev) = { }; BOOTDEV_HUNTER(scsi_bootdev_hunter) = { - .prio = BOOTDEVP_2_SCAN_FAST, + .prio = BOOTDEVP_4_SCAN_FAST, .uclass = UCLASS_SCSI, .hunt = scsi_bootdev_hunt, .drv = DM_DRIVER_REF(scsi_bootdev), diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c index 66d0b6ae8f5..32919f99286 100644 --- a/drivers/usb/host/usb_bootdev.c +++ b/drivers/usb/host/usb_bootdev.c @@ -15,7 +15,7 @@ static int usb_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_3_SCAN_SLOW; + ucp->prio = BOOTDEVP_5_SCAN_SLOW; return 0; } @@ -42,7 +42,7 @@ U_BOOT_DRIVER(usb_bootdev) = { }; BOOTDEV_HUNTER(usb_bootdev_hunter) = { - .prio = BOOTDEVP_3_SCAN_SLOW, + .prio = BOOTDEVP_5_SCAN_SLOW, .uclass = UCLASS_USB, .hunt = usb_bootdev_hunt, .drv = DM_DRIVER_REF(usb_bootdev), diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 27efac0d48e..91af412ec1d 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -360,7 +360,7 @@ static int virtio_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_2_SCAN_FAST; + ucp->prio = BOOTDEVP_4_SCAN_FAST; return 0; } @@ -405,7 +405,7 @@ U_BOOT_DRIVER(virtio_bootdev) = { }; BOOTDEV_HUNTER(virtio_bootdev_hunter) = { - .prio = BOOTDEVP_2_SCAN_FAST, + .prio = BOOTDEVP_4_SCAN_FAST, .uclass = UCLASS_VIRTIO, .hunt = virtio_bootdev_hunt, .drv = DM_DRIVER_REF(virtio_bootdev), diff --git a/include/bootdev.h b/include/bootdev.h index b7973fa5760..65d14f24686 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -21,15 +21,36 @@ struct udevice; * * Smallest value is the highest priority. By default, bootdevs are scanned from * highest to lowest priority + * + * BOOTDEVP_0_NONE: Invalid value, do not use + * @BOOTDEVP_6_PRE_SCAN: Scan bootdevs with this priority always, before + * starting any bootflow scan + * @BOOTDEVP_2_INTERNAL_FAST: Internal devices which don't need scanning and + * generally very quick to access, e.g. less than 100ms + * @BOOTDEVP_3_INTERNAL_SLOW: Internal devices which don't need scanning but + * take a significant fraction of a second to access + * @BOOTDEVP_4_SCAN_FAST: Extenal devices which need scanning or bus + * enumeration to find, but this enumeration happens quickly, typically under + * 100ms + * @BOOTDEVP_5_SCAN_SLOW: Extenal devices which need scanning or bus + * enumeration to find. The enumeration takes significant fraction of a second + * to complete + * @BOOTDEVP_6_NET_BASE: Basic network devices which are quickly and easily + * available. Typically used for an internal Ethernet device + * @BOOTDEVP_7_NET_FALLBACK: Secondary network devices which require extra time + * to start up, or are less desirable. Typically used for secondary Ethernet + * devices. Note that USB ethernet devices are found during USB enumeration, + * so do not use this priority */ enum bootdev_prio_t { - BOOTDEVP_0_INTERNAL_FAST = 10, - BOOTDEVP_1_INTERNAL_SLOW = 20, - BOOTDEVP_2_SCAN_FAST = 30, - BOOTDEVP_3_SCAN_SLOW = 40, - BOOTDEVP_4_NET_BASE = 50, - BOOTDEVP_5_NET_FALLBACK = 60, - BOOTDEVP_6_SYSTEM = 70, + BOOTDEVP_0_NONE, + BOOTDEVP_1_PRE_SCAN, + BOOTDEVP_2_INTERNAL_FAST, + BOOTDEVP_3_INTERNAL_SLOW, + BOOTDEVP_4_SCAN_FAST, + BOOTDEVP_5_SCAN_SLOW, + BOOTDEVP_6_NET_BASE, + BOOTDEVP_7_NET_FALLBACK, BOOTDEVP_COUNT, }; diff --git a/net/eth_bootdev.c b/net/eth_bootdev.c index bcbb35a74cd..13e5fcd3bdf 100644 --- a/net/eth_bootdev.c +++ b/net/eth_bootdev.c @@ -60,7 +60,7 @@ static int eth_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); - ucp->prio = BOOTDEVP_4_NET_BASE; + ucp->prio = BOOTDEVP_6_NET_BASE; return 0; } @@ -112,7 +112,7 @@ U_BOOT_DRIVER(eth_bootdev) = { }; BOOTDEV_HUNTER(eth_bootdev_hunt) = { - .prio = BOOTDEVP_4_NET_BASE, + .prio = BOOTDEVP_6_NET_BASE, .uclass = UCLASS_ETH, .hunt = eth_bootdev_hunt, .drv = DM_DRIVER_REF(eth_bootdev), diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index f9653633a68..86607f7695e 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -247,14 +247,14 @@ static int bootdev_test_hunter(struct unit_test_state *uts) bootdev_list_hunters(std); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline(" 50 ethernet eth_bootdev"); - ut_assert_nextline(" 40 ide ide_bootdev"); - ut_assert_nextline(" 10 mmc mmc_bootdev"); - ut_assert_nextline(" 30 nvme nvme_bootdev"); - ut_assert_nextline(" 30 scsi scsi_bootdev"); - ut_assert_nextline(" 30 spi_flash sf_bootdev"); - ut_assert_nextline(" 40 usb usb_bootdev"); - ut_assert_nextline(" 30 virtio virtio_bootdev"); + ut_assert_nextline(" 6 ethernet eth_bootdev"); + ut_assert_nextline(" 5 ide ide_bootdev"); + ut_assert_nextline(" 2 mmc mmc_bootdev"); + ut_assert_nextline(" 4 nvme nvme_bootdev"); + ut_assert_nextline(" 4 scsi scsi_bootdev"); + ut_assert_nextline(" 4 spi_flash sf_bootdev"); + ut_assert_nextline(" 5 usb usb_bootdev"); + ut_assert_nextline(" 4 virtio virtio_bootdev"); ut_assert_nextline("(total hunters: 8)"); ut_assert_console_end(); @@ -284,17 +284,28 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); + ut_assert_nextline(" 6 ethernet eth_bootdev"); + ut_assert_skip_to_line("(total hunters: 8)"); + ut_assert_console_end(); + + /* Use the MMC hunter and see that it updates */ + ut_assertok(run_command("bootdev hunt mmc", 0)); + ut_assertok(run_command("bootdev hunt -l", 0)); + ut_assert_skip_to_line(" 5 ide ide_bootdev"); + ut_assert_nextline(" 2 * mmc mmc_bootdev"); ut_assert_skip_to_line("(total hunters: 8)"); ut_assert_console_end(); /* Scan all hunters */ sandbox_set_eth_enable(false); - + test_set_skip_delays(true); ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); ut_assert_nextline("Hunting with: ide"); ut_assert_nextline("Bus 0: not available "); - ut_assert_nextline("Hunting with: mmc"); + + /* mmc hunter has already been used so should not run again */ + ut_assert_nextline("Hunting with: nvme"); ut_assert_nextline("Hunting with: scsi"); ut_assert_nextline("scanning bus for devices..."); @@ -309,14 +320,14 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); - ut_assert_nextline(" 50 * ethernet eth_bootdev"); - ut_assert_nextline(" 40 * ide ide_bootdev"); - ut_assert_nextline(" 10 * mmc mmc_bootdev"); - ut_assert_nextline(" 30 * nvme nvme_bootdev"); - ut_assert_nextline(" 30 * scsi scsi_bootdev"); - ut_assert_nextline(" 30 * spi_flash sf_bootdev"); - ut_assert_nextline(" 40 * usb usb_bootdev"); - ut_assert_nextline(" 30 * virtio virtio_bootdev"); + ut_assert_nextline(" 6 * ethernet eth_bootdev"); + ut_assert_nextline(" 5 * ide ide_bootdev"); + ut_assert_nextline(" 2 * mmc mmc_bootdev"); + ut_assert_nextline(" 4 * nvme nvme_bootdev"); + ut_assert_nextline(" 4 * scsi scsi_bootdev"); + ut_assert_nextline(" 4 * spi_flash sf_bootdev"); + ut_assert_nextline(" 5 * usb usb_bootdev"); + ut_assert_nextline(" 4 * virtio virtio_bootdev"); ut_assert_nextline("(total hunters: 8)"); ut_assert_console_end(); @@ -370,14 +381,14 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts) test_set_skip_delays(true); console_record_reset_enable(); - ut_assertok(bootdev_hunt_prio(BOOTDEVP_2_SCAN_FAST, false)); + ut_assertok(bootdev_hunt_prio(BOOTDEVP_4_SCAN_FAST, false)); ut_assert_nextline("scanning bus for devices..."); ut_assert_skip_to_line(" Type: Hard Disk"); ut_assert_nextlinen(" Capacity:"); ut_assert_console_end(); /* now try a different priority, verbosely */ - ut_assertok(bootdev_hunt_prio(BOOTDEVP_3_SCAN_SLOW, true)); + ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true)); ut_assert_nextline("Hunting with: ide"); ut_assert_nextline("Bus 0: not available "); ut_assert_nextline("Hunting with: usb"); From patchwork Tue Jan 17 17:48:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727661 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YRJzKbUJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGsk2Lx1z23fT for ; Wed, 18 Jan 2023 05:01:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3C2585713; Tue, 17 Jan 2023 18:51:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="YRJzKbUJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 434C185663; Tue, 17 Jan 2023 18:50:54 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 71B2885656 for ; Tue, 17 Jan 2023 18:50:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id i17so10916324ila.9 for ; Tue, 17 Jan 2023 09:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HvNa6Ab3ip1FLs+g41RRy+64H7+gFZfLO2FWctBDBHk=; b=YRJzKbUJpIQw+Dk0DbWZEcF+7qyIfZP+AeXGQGpkzAZuwxUSLU7L6KC2e+EPPUwR9s YBwAbGfI2ADDzFt7yuwfV03/KyhTzL8kCEXX4UDe+Hb8M5YkWvXQn0u2zg+24sEJ7gOG /46+Nn9FMqUo9XOvnLY8uyLNP7DcEE7QqMVM8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HvNa6Ab3ip1FLs+g41RRy+64H7+gFZfLO2FWctBDBHk=; b=B1/GSxMI8Wjr4xkatw3jojADPGBZnPCEOzp7Qat0nUu49ZP5KyOH2mgfZXpA7mpR0f s/+aeCRBs78ei8BErIbvFeqsOwHgDKmyjtRGIOQ1SW/cjWux/m7F+J97Zzc3VRvNK2Mt XXMa3JIAnMlQlbYsXm58fSF0uJVk49ngBvxjPAS1/a61spuDOXCFe7CqHfc/ccnUTJcN 7HoshygtYKy7VjfB+dWgZCwImD1saWQxjcwxq73qQn04AVE6xNilfwcnssUHOhQuHhl/ mefxpKFtPXWvpRP0bewdbbwzHfhSRdwY8qa09v51+ad8jvDE5/V9/UN1Pi+2jBtX5TzC jY6Q== X-Gm-Message-State: AFqh2kpDNvsLgYpDRA1h9EIoSP+8Nlkc3XRkNdeXp1loHN4ikbxeWPnE CmUzffZiQywTDzrQyASHFOgpfPEuUPmloicI X-Google-Smtp-Source: AMrXdXsKxiq16rq5EhTdfX+/4t0BdXFaIO1WkLkbY6r6ITPEz3s4HL9zjxoWPg5n4l0xECUnvOVoEQ== X-Received: by 2002:a92:cf4c:0:b0:30e:d7f3:216b with SMTP id c12-20020a92cf4c000000b0030ed7f3216bmr3356954ilr.8.1673977794479; Tue, 17 Jan 2023 09:49:54 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:54 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 59/70] bootstd: Allow hunting for a bootdev by label Date: Tue, 17 Jan 2023 10:48:09 -0700 Message-Id: <20230117174820.1281477-60-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a function to hunt for a bootdev label and find the bootdev produced by the hunter (or already present). Add a few extra flags so that we can distinguish between "mmc1", "mmc" and "1" which all need to be handled differently. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 27 ++++++++- include/bootdev.h | 17 ++++++ include/bootflow.h | 14 ++++- test/boot/bootdev.c | 115 ++++++++++++++++++++++++++++++++++++- test/boot/bootstd_common.c | 19 ++++++ test/boot/bootstd_common.h | 8 +++ 6 files changed, 195 insertions(+), 5 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 5ed310c554f..dcaed4c2692 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -442,6 +442,13 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, if (!ret) { log_debug("- found %s\n", bdev->name); *devp = bdev; + + /* + * if no sequence number was provided, we must scan all + * bootdevs for this media uclass + */ + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && seq == -1) + method_flags |= BOOTFLOW_METHF_SINGLE_UCLASS; if (method_flagsp) *method_flagsp = method_flags; return 0; @@ -458,7 +465,7 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, { struct udevice *dev; int method_flags = 0; - int ret, seq; + int ret = -ENODEV, seq; char *endp; seq = simple_strtol(name, &endp, 16); @@ -480,8 +487,9 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, ret); return log_msg_ret("pro", ret); } - } else { + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL)) { ret = uclass_get_device_by_seq(UCLASS_BOOTDEV, seq, &dev); + method_flags |= BOOTFLOW_METHF_SINGLE_DEV; } if (ret) { printf("Cannot find '%s' (err=%d)\n", name, ret); @@ -495,6 +503,21 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, return 0; } +int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp, + int *method_flagsp) +{ + int ret; + + ret = bootdev_hunt(label, false); + if (ret) + return log_msg_ret("scn", ret); + ret = bootdev_find_by_label(label, devp, method_flagsp); + if (ret) + return log_msg_ret("fnd", ret); + + return 0; +} + static int default_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, struct bootflow *bflow) { diff --git a/include/bootdev.h b/include/bootdev.h index 65d14f24686..b1e320a7d8e 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -316,6 +316,23 @@ int bootdev_hunt(const char *spec, bool show); */ int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show); +/** + * bootdev_hunt_and_find_by_label() - Hunt for bootdevs by label + * + * Runs the hunter for the label, then tries to find the bootdev, possible + * created by the hunter + * + * @label: Label to look up (e.g. "mmc1" or "mmc0") + * @devp: Returns the bootdev device found, or NULL if none (note it does not + * return the media device, but its bootdev child) + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails + * Return: 0 if OK, -EINVAL if the uclass is not supported by this board, + * -ENOENT if there is no device with that number + */ +int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp, + int *method_flagsp); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/include/bootflow.h b/include/bootflow.h index 4012f4b8a82..81dbcd6754b 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -99,7 +99,10 @@ struct bootflow { * Internal flags: * @BOOTFLOWF_SINGLE_DEV: (internal) Just scan one bootdev * @BOOTFLOWF_SKIP_GLOBAL: (internal) Don't scan global bootmeths - * this uclass + * @BOOTFLOWF_SINGLE_UCLASS: (internal) Keep scanning through all devices in + * this uclass (used with things like "mmc") + * @BOOTFLOWF_SINGLE_MEDIA: (internal) Scan one media device in the uclass (used + * with things like "mmc1") */ enum bootflow_flags_t { BOOTFLOWF_FIXED = 1 << 0, @@ -113,6 +116,8 @@ enum bootflow_flags_t { */ BOOTFLOWF_SINGLE_DEV = 1 << 16, BOOTFLOWF_SKIP_GLOBAL = 1 << 17, + BOOTFLOWF_SINGLE_UCLASS = 1 << 18, + BOOTFLOWF_SINGLE_MEDIA = 1 << 19, }; /** @@ -124,10 +129,17 @@ enum bootflow_flags_t { * * @BOOTFLOW_METHF_DHCP_ONLY: Only use dhcp (scripts and EFI) * @BOOTFLOW_METHF_PXE_ONLY: Only use pxe (PXE boot) + * @BOOTFLOW_METHF_SINGLE_DEV: Scan only a single bootdev (used for labels like + * "3"). This is used if a sequence number is provided instead of a label + * @BOOTFLOW_METHF_SINGLE_UCLASS: Scan all bootdevs in this one uclass (used + * with things like "mmc"). If this is not set, then the bootdev has an integer + * value in the label (like "mmc2") */ enum bootflow_meth_flags_t { BOOTFLOW_METHF_DHCP_ONLY = 1 << 0, BOOTFLOW_METHF_PXE_ONLY = 1 << 1, + BOOTFLOW_METHF_SINGLE_DEV = 1 << 2, + BOOTFLOW_METHF_SINGLE_UCLASS = 1 << 3, }; /** diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 86607f7695e..1fa0909e893 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -113,9 +113,11 @@ static int bootdev_test_labels(struct unit_test_state *uts) /* Check method flags */ ut_assertok(bootdev_find_by_label("pxe", &dev, &mflags)); - ut_asserteq(BOOTFLOW_METHF_PXE_ONLY, mflags); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS | BOOTFLOW_METHF_PXE_ONLY, + mflags); ut_assertok(bootdev_find_by_label("dhcp", &dev, &mflags)); - ut_asserteq(BOOTFLOW_METHF_DHCP_ONLY, mflags); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS | BOOTFLOW_METHF_DHCP_ONLY, + mflags); /* Check invalid uclass */ ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags)); @@ -128,6 +130,62 @@ static int bootdev_test_labels(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_labels, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); +/* Check bootdev_find_by_any() */ +static int bootdev_test_any(struct unit_test_state *uts) +{ + struct udevice *dev, *media; + int mflags; + + /* + * with ethernet enabled we have 8 devices ahead of the mmc ones: + * + * ut_assertok(run_command("bootdev list", 0)); + * Seq Probed Status Uclass Name + * --- ------ ------ -------- ------------------ + * 0 [ + ] OK ethernet eth@10002000.bootdev + * 1 [ ] OK ethernet eth@10003000.bootdev + * 2 [ ] OK ethernet sbe5.bootdev + * 3 [ ] OK ethernet eth@10004000.bootdev + * 4 [ ] OK ethernet phy-test-eth.bootdev + * 5 [ ] OK ethernet dsa-test-eth.bootdev + * 6 [ ] OK ethernet dsa-test@0.bootdev + * 7 [ ] OK ethernet dsa-test@1.bootdev + * 8 [ ] OK mmc mmc2.bootdev + * 9 [ + ] OK mmc mmc1.bootdev + * a [ ] OK mmc mmc0.bootdev + */ + console_record_reset_enable(); + ut_assertok(bootdev_find_by_any("8", &dev, &mflags)); + ut_asserteq(UCLASS_BOOTDEV, device_get_uclass_id(dev)); + ut_asserteq(BOOTFLOW_METHF_SINGLE_DEV, mflags); + media = dev_get_parent(dev); + ut_asserteq(UCLASS_MMC, device_get_uclass_id(media)); + ut_asserteq_str("mmc2", media->name); + ut_assert_console_end(); + + /* there should not be this many bootdevs */ + ut_asserteq(-ENODEV, bootdev_find_by_any("50", &dev, &mflags)); + ut_assert_nextline("Cannot find '50' (err=-19)"); + ut_assert_console_end(); + + /* Check method flags */ + ut_assertok(bootdev_find_by_any("pxe", &dev, &mflags)); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS | BOOTFLOW_METHF_PXE_ONLY, + mflags); + + /* Check invalid uclass */ + mflags = 123; + ut_asserteq(-EINVAL, bootdev_find_by_any("fred0", &dev, &mflags)); + ut_assert_nextline("Unknown uclass 'fred0' in label"); + ut_assert_nextline("Cannot find bootdev 'fred0' (err=-22)"); + ut_asserteq(123, mflags); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_any, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_ETH_BOOTDEV); + /* Check bootdev ordering with the bootdev-order property */ static int bootdev_test_order(struct unit_test_state *uts) { @@ -399,3 +457,56 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_hunt_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check hunting for bootdevs with a particular label */ +static int bootdev_test_hunt_label(struct unit_test_state *uts) +{ + struct udevice *dev, *old; + struct bootstd_priv *std; + int mflags; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + /* scan an unknown uclass */ + console_record_reset_enable(); + old = (void *)&mflags; /* arbitrary pointer to check against dev */ + dev = old; + mflags = 123; + ut_asserteq(-EINVAL, + bootdev_hunt_and_find_by_label("fred", &dev, &mflags)); + ut_assert_nextline("Unknown uclass 'fred' in label"); + ut_asserteq_ptr(old, dev); + ut_asserteq(123, mflags); + ut_assert_console_end(); + ut_asserteq(0, std->hunters_used); + + /* scan an invalid mmc controllers */ + ut_asserteq(-ENOENT, + bootdev_hunt_and_find_by_label("mmc4", &dev, &mflags)); + ut_asserteq_ptr(old, dev); + ut_asserteq(123, mflags); + ut_assert_nextline("Unknown seq 4 for label 'mmc4'"); + ut_assert_console_end(); + + ut_assertok(bootstd_test_check_mmc_hunter(uts)); + + /* scan for a particular mmc controller */ + ut_assertok(bootdev_hunt_and_find_by_label("mmc1", &dev, &mflags)); + ut_assertnonnull(dev); + ut_asserteq_str("mmc1.bootdev", dev->name); + ut_asserteq(0, mflags); + ut_assert_console_end(); + + /* scan all of usb */ + test_set_skip_delays(true); + ut_assertok(bootdev_hunt_and_find_by_label("usb", &dev, &mflags)); + ut_assertnonnull(dev); + ut_asserteq_str("usb_mass_storage.lun0.bootdev", dev->name); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS, mflags); + ut_assert_nextlinen("Bus usb@1: scanning bus usb@1"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_hunt_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT); diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index 7a40836507a..e71a2975c53 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -67,6 +68,24 @@ int bootstd_test_drop_bootdev_order(struct unit_test_state *uts) return 0; } +int bootstd_test_check_mmc_hunter(struct unit_test_state *uts) +{ + struct bootdev_hunter *start, *mmc; + struct bootstd_priv *std; + uint seq; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + /* check that the hunter was used */ + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + mmc = BOOTDEV_HUNTER_GET(mmc_bootdev_hunter); + seq = mmc - start; + ut_asserteq(BIT(seq), std->hunters_used); + + return 0; +} + int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test); diff --git a/test/boot/bootstd_common.h b/test/boot/bootstd_common.h index c5e0fd1ceab..0eb48fa1537 100644 --- a/test/boot/bootstd_common.h +++ b/test/boot/bootstd_common.h @@ -40,4 +40,12 @@ int bootstd_test_drop_bootdev_order(struct unit_test_state *uts); */ int bootstd_setup_for_tests(void); +/** + * bootstd_test_check_mmc_hunter() - Check that the mmc bootdev hunter was used + * + * @uts: Unit test state to use for ut_assert...() functions + * Returns: 0 if OK (used), other value on error (not used) + */ +int bootstd_test_check_mmc_hunter(struct unit_test_state *uts); + #endif From patchwork Tue Jan 17 17:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727662 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Vk12HyyI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGsz55T1z23fT for ; Wed, 18 Jan 2023 05:01:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 371908571B; Tue, 17 Jan 2023 18:51:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Vk12HyyI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 16BA685663; Tue, 17 Jan 2023 18:50:55 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 BF32685678 for ; Tue, 17 Jan 2023 18:50:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id f8so9671150ilj.5 for ; Tue, 17 Jan 2023 09:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k2sFZLNMQlA/+mrIK4dbRfOc1S6vMiDyedQhKPmtzDw=; b=Vk12HyyI2eP6jhgGvEA0pKB1MUEb+MZpV4ng/fE2mrLoUHUD+Dh+WKhlpDD95bYuEu rjVQlJVmQCVUtWbAxrGqB6891LE1lp7tHhwAcnrj5m+P4cYMQsSm6ObE/0BV4EV2/UXj 6VztuC31tvKH+iUefYBeItKvZJqKBv/oCuJkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k2sFZLNMQlA/+mrIK4dbRfOc1S6vMiDyedQhKPmtzDw=; b=2fJmW5DXeZwm8yeSrF9kdIZq/Xho7WhmpnJcE8U5TSR1X+hrdlM8lwvhb1emFLh2+S WMxqWf6K6YUsgMV5m5QKuKTupaSfFoF94BjPwhEfPhwkG9Aog2hPAZCOmihCLSn2uFUH ajE7bJmZlfmMmF3MX7u/TisxXU1Ct5cjzC43gIzySLb8uq4xNyGd7T3AJb+8A1TroFc7 MyKe5fPzQYV12+j5O4sXx37U9FStM+2WaDKqwHwhMGXCvpSn9e/d7oooHHAva4p6BL+3 FMykxLJF/cYfd/CA+95W5xMboPvKiEuQursnTegKLH9+AMrJCM/R7uxBeMXmCvN671ee oL0g== X-Gm-Message-State: AFqh2kqzbKNganLbqBJd7ht3myJzqwXOfMM5VIq2OnqWAnh5U3dw7MKF eNmNe4b7KRO/qsz5SxRcScxTvNWqtZMiyZJp X-Google-Smtp-Source: AMrXdXt32OSn+ND4dUb7TvcCvdgZzLe4kdbgVanOlDn2rK+hoNAEkOh5AX6qLYS32OWadzQHf2FakQ== X-Received: by 2002:a05:6e02:b45:b0:30e:f171:6617 with SMTP id f5-20020a056e020b4500b0030ef1716617mr4478141ilu.10.1673977795619; Tue, 17 Jan 2023 09:49:55 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:55 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 60/70] bootstd: Allow iterating to the next label in a list Date: Tue, 17 Jan 2023 10:48:10 -0700 Message-Id: <20230117174820.1281477-61-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a function which moves to the next label in a list of labels. This allows processing the boot_targets environment variable. This works using a new label list in the bootflow iterator. The logic to set this up is included in a subsequent commit. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 26 ++++++++++++-- include/bootdev.h | 16 +++++++++ include/bootflow.h | 4 +++ test/boot/bootdev.c | 80 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index dcaed4c2692..ae08430ca8c 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -566,6 +566,25 @@ void bootdev_clear_bootflows(struct udevice *dev) } } +int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, + int *method_flagsp) +{ + struct udevice *dev; + + log_debug("next\n"); + for (dev = NULL; !dev && iter->labels[++iter->cur_label];) { + log_debug("Scanning: %s\n", iter->labels[iter->cur_label]); + bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label], + &dev, method_flagsp); + } + + if (!dev) + return log_msg_ret("fin", -ENODEV); + *devp = dev; + + return 0; +} + /** * h_cmp_bootdev() - Compare two bootdevs to find out which should go first * @@ -763,8 +782,11 @@ int bootdev_hunt(const char *spec, bool show) log_debug("looking at %.*s for %s\n", (int)max(strlen(name), len), spec, name); - if (spec && strncmp(spec, name, max(strlen(name), len))) - continue; + if (spec && strncmp(spec, name, max(strlen(name), len))) { + if (info->uclass != UCLASS_ETH || + (strcmp("dhcp", spec) && strcmp("pxe", spec))) + continue; + } ret = bootdev_hunt_drv(info, i, show); if (ret) result = ret; diff --git a/include/bootdev.h b/include/bootdev.h index b1e320a7d8e..300bc736427 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -333,6 +333,22 @@ int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show); int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp, int *method_flagsp); +/** + * bootdev_next_label() - Move to the next bootdev in the label sequence + * + * Looks through the remaining labels until it finds one that matches a bootdev. + * Bootdev scanners are used as needed. For example a label "mmc1" results in + * running the "mmc" bootdrv. + * + * @iter: Interation info, containing iter->cur_label + * @devp: New bootdev found, if any was found + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none + * Returns 0 if OK, -ENODEV if no bootdev was found + */ +int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, + int *method_flagsp); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/include/bootflow.h b/include/bootflow.h index 81dbcd6754b..8ab32ffd666 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -175,6 +175,8 @@ enum bootflow_meth_flags_t { * @cur_dev: Current bootdev number, an index into @dev_order[] * @dev_order: List of bootdevs to scan, in order of priority. The scan starts * with the first one on the list + * @labels: List of labels to scan for bootdevs + * @cur_label: Current label being processed * @num_methods: Number of bootmeth devices in @method_order * @cur_method: Current method number, an index into @method_order * @first_glob_method: First global method, if any, else -1 @@ -196,6 +198,8 @@ struct bootflow_iter { int num_devs; int cur_dev; struct udevice **dev_order; + const char *const *labels; + int cur_label; int num_methods; int cur_method; int first_glob_method; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 1fa0909e893..608aef15265 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -355,7 +355,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_console_end(); /* Scan all hunters */ - sandbox_set_eth_enable(false); + test_set_eth_enable(false); test_set_skip_delays(true); ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); @@ -510,3 +510,81 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_hunt_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check iterating to the next label in a list */ +static int bootdev_test_next_label(struct unit_test_state *uts) +{ + const char *const labels[] = {"mmc0", "scsi", "dhcp", "pxe", NULL}; + struct bootflow_iter iter; + struct bootstd_priv *std; + struct bootflow bflow; + struct udevice *dev; + int mflags; + + test_set_eth_enable(false); + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + memset(&iter, '\0', sizeof(iter)); + memset(&bflow, '\0', sizeof(bflow)); + iter.part = 0; + uclass_first_device(UCLASS_BOOTMETH, &bflow.method); + iter.cur_label = -1; + iter.labels = labels; + + dev = NULL; + mflags = 123; + ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); + console_record_reset_enable(); + ut_assert_console_end(); + ut_assertnonnull(dev); + ut_asserteq_str("mmc0.bootdev", dev->name); + ut_asserteq(0, mflags); + + ut_assertok(bootstd_test_check_mmc_hunter(uts)); + + ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); + ut_assert_nextline("scanning bus for devices..."); + ut_assert_skip_to_line( + " Capacity: 1.9 MB = 0.0 GB (4095 x 512)"); + ut_assert_console_end(); + ut_assertnonnull(dev); + ut_asserteq_str("scsi.id0lun0.bootdev", dev->name); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS, mflags); + + /* SCSI is fifth in the list, so bit 4 */ + ut_asserteq(BIT(2) | BIT(4), std->hunters_used); + + ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); + ut_assert_console_end(); + ut_assertnonnull(dev); + ut_asserteq_str("eth@10002000.bootdev", dev->name); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS | BOOTFLOW_METHF_DHCP_ONLY, + mflags); + + /* dhcp: Ethernet is first so bit 0 */ + ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + + ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); + ut_assert_console_end(); + ut_assertnonnull(dev); + ut_asserteq_str("eth@10002000.bootdev", dev->name); + ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS | BOOTFLOW_METHF_PXE_ONLY, + mflags); + + /* pxe: Ethernet is first so bit 0 */ + ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + + mflags = 123; + ut_asserteq(-ENODEV, bootdev_next_label(&iter, &dev, &mflags)); + ut_asserteq(123, mflags); + ut_assert_console_end(); + + /* no change */ + ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + + return 0; +} +BOOTSTD_TEST(bootdev_test_next_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_ETH_BOOTDEV | UT_TESTF_SF_BOOTDEV); From patchwork Tue Jan 17 17:48:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727664 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=npn9zKeP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGtR4D0sz23fT for ; Wed, 18 Jan 2023 05:01:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F7E185710; Tue, 17 Jan 2023 18:52:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="npn9zKeP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 944D7856A0; Tue, 17 Jan 2023 18:51:05 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 563C585663 for ; Tue, 17 Jan 2023 18:51:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id i17so10916385ila.9 for ; Tue, 17 Jan 2023 09:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dzskZlo0+F+HzEhI3KKVQMKaAkrfZp3nltMiFmMkPfM=; b=npn9zKePi/NNMppg2OPEQVD963LaluQ3N3hewBXzbtlq8msNYgL/ZLN+iE2O87i4gG /5qbTwmcrymF50eBKGpym54EvwerbADtjq66NaTYzwa0RMiDOM6PkvxYMxnKgJ+ITlMB PHmCw7R42evQlTJigEIMQ9fzc+Kklo2G+ZQ4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dzskZlo0+F+HzEhI3KKVQMKaAkrfZp3nltMiFmMkPfM=; b=2x05CbCLO7eI9gcLbMEhEMVejxcxTj9OZrrG3RZ9+7DJSR0ZKU+2yowLQ+ZNYzNngm 8S3oVd0vITJ5miUz+EhgXBJXofoiuaWPqu4Gxv9tScSX9vg79dE5nlTFrCccNo7b4gqE BWMPRLjn6VqhWa0tlLDGjUVHL7a4HyjIO/OdZNoQbyQXmx/nsRfirtJGEQ+6KmqECYkS HVrcmZQd0hA0sEjC2snBo618j5pZFbH3RtyoQO+RllsERjroB8CgaEkXAujrbcIteEgq /fUJrbSxAazCx4jtkAfQQvyP7Qlx684zONmnbXLKXLUNFuB9DDNb8aPVFIEmheXzkCc+ EaEA== X-Gm-Message-State: AFqh2kodxP3YJW9kHnOQ2ReVrvvwFuc9ukhIQaM7SyA293J7uvkZLIU4 d5b2gC9+eTXItqkP3jHuUI0WYJ7EtI2byQ6i X-Google-Smtp-Source: AMrXdXunpbyg4Skk5MDqhThfG+ANPcJcffdzLTpOtrsfMufqncHnu8g1orTFFOInlNC1XPKn0aLKxA== X-Received: by 2002:a05:6e02:1d86:b0:30d:c671:48c5 with SMTP id h6-20020a056e021d8600b0030dc67148c5mr4475608ila.16.1673977796725; Tue, 17 Jan 2023 09:49:56 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:56 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 61/70] bootstd: Allow iterating to the next bootdev priortiy Date: Tue, 17 Jan 2023 10:48:11 -0700 Message-Id: <20230117174820.1281477-62-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a function which moves to the next priority to be processed. This works by storing the current priority in the bootflow iterator. The logic to set this up is included in a subsequent commit. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 64 +++++++++++++++++++++++++++++++++ include/bootdev.h | 14 ++++++++ include/bootflow.h | 3 ++ test/boot/bootdev.c | 84 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 165 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index ae08430ca8c..63005140061 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -585,6 +585,70 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, return 0; } +int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp) +{ + struct udevice *dev = *devp; + bool found; + int ret; + + /* find the next device with this priority */ + *devp = NULL; + log_debug("next prio %d: dev=%p/%s\n", iter->cur_prio, dev, + dev ? dev->name : "none"); + do { + /* + * Don't probe devices here since they may not be of the + * required priority + */ + if (!dev) + uclass_find_first_device(UCLASS_BOOTDEV, &dev); + else + uclass_find_next_device(&dev); + found = false; + + /* scan for the next device with the correct priority */ + while (dev) { + struct bootdev_uc_plat *plat; + + plat = dev_get_uclass_plat(dev); + log_debug("- %s: %d, want %d\n", dev->name, plat->prio, + iter->cur_prio); + if (plat->prio == iter->cur_prio) + break; + uclass_find_next_device(&dev); + } + + /* none found for this priority, so move to the next */ + if (!dev) { + log_debug("None found at prio %d, moving to %d\n", + iter->cur_prio, iter->cur_prio + 1); + if (++iter->cur_prio == BOOTDEVP_COUNT) + return log_msg_ret("fin", -ENODEV); + + if (iter->flags & BOOTFLOWF_HUNT) { + /* hunt to find new bootdevs */ + ret = bootdev_hunt_prio(iter->cur_prio, + iter->flags & + BOOTFLOWF_SHOW); + log_debug("- hunt ret %d\n", ret); + if (ret) + return log_msg_ret("hun", ret); + } + } else { + ret = device_probe(dev); + if (ret) { + log_debug("Device '%s' failed to probe\n", + dev->name); + dev = NULL; + } + } + } while (!dev); + + *devp = dev; + + return 0; +} + /** * h_cmp_bootdev() - Compare two bootdevs to find out which should go first * diff --git a/include/bootdev.h b/include/bootdev.h index 300bc736427..4b6a8eb8d8f 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -349,6 +349,20 @@ int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp, int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, int *method_flagsp); +/** + * bootdev_next_prio() - Find the next bootdev in priority order + * + * This moves @devp to the next bootdev with the current priority. If there is + * none, then it moves to the next priority and scans for new bootdevs there. + * + * @iter: Interation info, containing iter->cur_prio + * @devp: On entry this is the previous bootdev that was considered. On exit + * this is the new bootdev, if any was found + * Returns 0 on success (*devp is updated), -ENODEV if there are no more + * bootdevs at any priority + */ +int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/include/bootflow.h b/include/bootflow.h index 8ab32ffd666..69ac90483c6 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -7,6 +7,7 @@ #ifndef __bootflow_h #define __bootflow_h +#include #include #include @@ -180,6 +181,7 @@ enum bootflow_meth_flags_t { * @num_methods: Number of bootmeth devices in @method_order * @cur_method: Current method number, an index into @method_order * @first_glob_method: First global method, if any, else -1 + * @cur_prio: Current priority being scanned * @method_order: List of bootmeth devices to use, in order. The normal methods * appear first, then the global ones, if any * @doing_global: true if we are iterating through the global bootmeths (which @@ -203,6 +205,7 @@ struct bootflow_iter { int num_methods; int cur_method; int first_glob_method; + enum bootdev_prio_t cur_prio; struct udevice **method_order; bool doing_global; int method_flags; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 608aef15265..1090b92e510 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -588,3 +588,87 @@ static int bootdev_test_next_label(struct unit_test_state *uts) } BOOTSTD_TEST(bootdev_test_next_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV | UT_TESTF_SF_BOOTDEV); + + +/* Check iterating to the next prioirty in a list */ +static int bootdev_test_next_prio(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootstd_priv *std; + struct bootflow bflow; + struct udevice *dev; + int ret; + + sandbox_set_eth_enable(false); + test_set_skip_delays(true); + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + memset(&iter, '\0', sizeof(iter)); + memset(&bflow, '\0', sizeof(bflow)); + iter.part = 0; + uclass_first_device(UCLASS_BOOTMETH, &bflow.method); + iter.cur_prio = 0; + iter.flags = BOOTFLOWF_SHOW; + + dev = NULL; + console_record_reset_enable(); + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_assertnonnull(dev); + ut_asserteq_str("mmc2.bootdev", dev->name); + + /* hunt flag not set, so this should not use any hunters */ + ut_asserteq(0, std->hunters_used); + ut_assert_console_end(); + + /* now try again with hunting enabled */ + iter.flags = BOOTFLOWF_SHOW | BOOTFLOWF_HUNT; + iter.cur_prio = 0; + iter.part = 0; + + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_asserteq_str("mmc2.bootdev", dev->name); + ut_assert_nextline("Hunting with: mmc"); + ut_assert_console_end(); + + ut_assertok(bootstd_test_check_mmc_hunter(uts)); + + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_asserteq_str("mmc1.bootdev", dev->name); + + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_asserteq_str("mmc0.bootdev", dev->name); + ut_assert_console_end(); + + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_asserteq_str("spi.bin@0.bootdev", dev->name); + ut_assert_skip_to_line("Hunting with: spi_flash"); + + /* + * this scans all bootdevs of priority BOOTDEVP_4_SCAN_FAST before it + * starts looking at the devices, so we se virtio as well + */ + ut_assert_nextline("Hunting with: virtio"); + ut_assert_nextlinen("SF: Detected m25p16"); + + ut_assertok(bootdev_next_prio(&iter, &dev)); + ut_asserteq_str("spi.bin@1.bootdev", dev->name); + ut_assert_nextlinen("SF: Detected m25p16"); + ut_assert_console_end(); + + /* keep going until there are no more bootdevs */ + do { + ret = bootdev_next_prio(&iter, &dev); + } while (!ret); + ut_asserteq(-ENODEV, ret); + ut_assertnull(dev); + ut_asserteq(GENMASK(7, 0), std->hunters_used); + + ut_assert_skip_to_line("Hunting with: ethernet"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_next_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_SF_BOOTDEV); From patchwork Tue Jan 17 17:48:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727666 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=L0wlv+E0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGth4mLQz23fT for ; Wed, 18 Jan 2023 05:02:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7F5E8571F; Tue, 17 Jan 2023 18:52:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="L0wlv+E0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2EEE285693; Tue, 17 Jan 2023 18:51:08 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 6195C85691 for ; Tue, 17 Jan 2023 18:51:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id w2so2063558ilg.1 for ; Tue, 17 Jan 2023 09:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yed0CtHEdH/6ICYHpAzKlJHPE3HelzHUZe222X+8yAo=; b=L0wlv+E0T8pwMrD91W6JYKP3WSUDKcivEMipPv1sID0xQfFHZmWvmfCcjrB74MRgVc LjTZhkkSbB8dsvw8FET8UziN2ugr+UUgRspM7kk5Nk7zBDPZWLkQiOzZlNb3UHzUp8hQ ItOY70p+U8rBsHxHSg7ezHeaSQW7/PFRB1ozw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yed0CtHEdH/6ICYHpAzKlJHPE3HelzHUZe222X+8yAo=; b=VI99xRGhnM8x0zLbwYOG9p46/Qma2cS3ToiF6wbc238tnrB7WkD283hucPUjVZOwFv fKAeS/XpvGc3TMfUELYuUEUWxaZUeXpZyw34SqVw/ZCbNFg/ifexAjsd9WViiB4mMQ/t vb4zSUaIKNha0m1uJsxuIcoGw1YNzzVDfbwV8qY/6F9/CUiwFOPx5p5gQUJmPeOQnv4g otsQqb1H0HrVfV4l2gjR/3/4e+22rkorgxpbFtLyVGk00ExUI4zj83jOPmob0/+2qyWe /RMA3gqiL0pLL4YqQH2EhxmfwCZdUh4yZU5NNVvjB/jk9ZqyNTNh6ZuAJxu1xvgReSwe xjhw== X-Gm-Message-State: AFqh2kp1CnWEn8tiJwu9+z5BghFIYTSdI4Fcvi4gNDj19tpKf9wNGo7F /TgpBsutt7TWgkswu4G3AFd1qHAWRqip4xYn X-Google-Smtp-Source: AMrXdXt8M20dR+9qfpj/q/juEQCRGrRhRMaemVk3UALwBW7Dr/KUN6vXQEDJWh9rB3DEpyT5tR23aA== X-Received: by 2002:a92:b007:0:b0:30e:f02f:f1bf with SMTP id x7-20020a92b007000000b0030ef02ff1bfmr9602162ilh.30.1673977797833; Tue, 17 Jan 2023 09:49:57 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:57 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 62/70] extension: Refactor to allow non-command usage Date: Tue, 17 Jan 2023 10:48:12 -0700 Message-Id: <20230117174820.1281477-63-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean The current extension code is designed to be used from commands. We want to add a boot driver which uses it. To help with this, split the code into the command processing and a function which actually does the scan. Really the extension code should be in common/ or use driver model, but this is a start. Signed-off-by: Simon Glass --- (no changes since v1) cmd/extension_board.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/extension_board.c b/cmd/extension_board.c index f94abd612d5..f7685d47b8b 100644 --- a/cmd/extension_board.c +++ b/cmd/extension_board.c @@ -80,8 +80,7 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } -static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, - int argc, char *const argv[]) +static int extension_scan(bool show) { struct extension *extension, *next; int extension_num; @@ -91,12 +90,23 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, free(extension); } extension_num = extension_board_scan(&extension_list); + if (show && extension_num >= 0) + printf("Found %d extension board(s).\n", extension_num); + + /* either the number of extensions, or -ve for error */ + return extension_num; +} + +static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + int extension_num; + + extension_num = extension_scan(true); if (extension_num < 0) return CMD_RET_FAILURE; - printf("Found %d extension board(s).\n", extension_num); - return CMD_RET_SUCCESS; } From patchwork Tue Jan 17 17:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727674 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dkL+GO9p; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGwf0S1hz23fT for ; Wed, 18 Jan 2023 05:03:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A317685747; Tue, 17 Jan 2023 18:52:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="dkL+GO9p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D50CE856BE; Tue, 17 Jan 2023 18:51:22 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 5F4F3856AD for ; Tue, 17 Jan 2023 18:51:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id s26so7410775ioa.11 for ; Tue, 17 Jan 2023 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MT/oBryJWD6e9wiwoNf0y5duUmrc4yWBTkavtBw4hQM=; b=dkL+GO9p2BNTOzTiCW1Q58PHnv497KvZ8SBquL+SOTB8aszwYeHWcZKIprUCItShiQ STlH4xixjJtrX0nU1SDtAkTakf0kDJ9gpczCP2yEw3yrXnvcYS0jp26kTZ5L1jQp4Ays HSDtTE07RtVpAH+2ga79x5KeAkf1IdkEbyRRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MT/oBryJWD6e9wiwoNf0y5duUmrc4yWBTkavtBw4hQM=; b=DOsFZcHQ9XHHSj3zhRbWP1AmPxXGPeO8Ds6ZIFqYaCKrz6wNb2CATRIU/kY0SqeK7J tjMfd8+30zKv6t3qcEsn32FB4Ny9yz5c/6ttmf7tnCoYGe0bB9hx5RUu8RQzvTS55MZx hZXZ/qYngs66cXv9LitPnzkH2TAgD8G6oWN64t4AJ23dVfIJyafkgnsuUTCh+SRu9/lI Rq//BL4gPD7Ux+kGUnYYDDC+uMANDERF3mIyiQKaExMLBlS8IXrW4Bn40TAOssH62Gwi P6MeJOwJCx9zP2WXpN3AqUBsDvcbcu15C9LrFOSe8pQCkvvsZ+mTnGKOSQialHtGQzR5 D/vw== X-Gm-Message-State: AFqh2krecz0ViRfixUOo/sEeClnRZ+U/H74Rl5aDyQBedKo45vBXoCbm 4FIGbspdliLMJFQtsOdf/BkytNOuJCTaITTB X-Google-Smtp-Source: AMrXdXsMnlV9r9gc6GJTtF4RV+yTVh22Rsv+d7+h4TnP1vHS3IPw4ZU0dy47IhBj6EKUJTTnGdyLxQ== X-Received: by 2002:a5d:8b99:0:b0:704:998f:a6d8 with SMTP id p25-20020a5d8b99000000b00704998fa6d8mr2416993iol.4.1673977798878; Tue, 17 Jan 2023 09:49:58 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:58 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 63/70] bootstd: Add a hunter for the extension feature Date: Tue, 17 Jan 2023 10:48:13 -0700 Message-Id: <20230117174820.1281477-64-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This needs to run before any bootdev is used, so add a hunter for it. Signed-off-by: Simon Glass --- (no changes since v1) cmd/extension_board.c | 25 +++++++++++++++++++++++++ test/boot/bootdev.c | 37 +++++++++++++++++++++++-------------- test/boot/bootflow.c | 20 ++++++++++---------- test/boot/bootstd_common.h | 5 +++++ 4 files changed, 63 insertions(+), 24 deletions(-) diff --git a/cmd/extension_board.c b/cmd/extension_board.c index f7685d47b8b..2b672d888c6 100644 --- a/cmd/extension_board.c +++ b/cmd/extension_board.c @@ -5,7 +5,9 @@ */ #include +#include #include +#include #include #include #include @@ -176,3 +178,26 @@ U_BOOT_CMD(extension, 3, 1, do_extensionops, "extension list - lists available extension(s) board(s)\n" "extension apply - applies DT overlays corresponding to extension boards\n" ); + +static int extension_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + int ret; + + ret = env_set_hex("extension_overlay_addr", + env_get_hex("fdtoverlay_addr_r", 0)); + if (ret) + return log_msg_ret("env", ret); + + ret = extension_scan(show); + if (ret < 0) + return log_msg_ret("ext", ret); + + return 0; +} + +/* extensions should have a uclass - for now we use UCLASS_SIMPLE_BUS uclass */ +BOOTDEV_HUNTER(extension_bootdev_hunter) = { + .prio = BOOTDEVP_1_PRE_SCAN, + .uclass = UCLASS_SIMPLE_BUS, + .hunt = extension_bootdev_hunt, +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 1090b92e510..8ebc27a6435 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -306,6 +306,7 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); ut_assert_nextline(" 6 ethernet eth_bootdev"); + ut_assert_nextline(" 1 simple_bus (none)"); ut_assert_nextline(" 5 ide ide_bootdev"); ut_assert_nextline(" 2 mmc mmc_bootdev"); ut_assert_nextline(" 4 nvme nvme_bootdev"); @@ -313,7 +314,7 @@ static int bootdev_test_hunter(struct unit_test_state *uts) ut_assert_nextline(" 4 spi_flash sf_bootdev"); ut_assert_nextline(" 5 usb usb_bootdev"); ut_assert_nextline(" 4 virtio virtio_bootdev"); - ut_assert_nextline("(total hunters: 8)"); + ut_assert_nextline("(total hunters: 9)"); ut_assert_console_end(); ut_assertok(bootdev_hunt("usb1", false)); @@ -321,8 +322,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); - /* USB is fifth in the list, so bit 6 */ - ut_asserteq(BIT(6), std->hunters_used); + /* USB is sixth in the list, so bit 7 */ + ut_asserteq(BIT(7), std->hunters_used); return 0; } @@ -343,7 +344,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); ut_assert_nextline(" 6 ethernet eth_bootdev"); - ut_assert_skip_to_line("(total hunters: 8)"); + ut_assert_skip_to_line("(total hunters: 9)"); ut_assert_console_end(); /* Use the MMC hunter and see that it updates */ @@ -351,7 +352,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_skip_to_line(" 5 ide ide_bootdev"); ut_assert_nextline(" 2 * mmc mmc_bootdev"); - ut_assert_skip_to_line("(total hunters: 8)"); + ut_assert_skip_to_line("(total hunters: 9)"); ut_assert_console_end(); /* Scan all hunters */ @@ -359,6 +360,10 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) test_set_skip_delays(true); ut_assertok(run_command("bootdev hunt", 0)); ut_assert_nextline("Hunting with: ethernet"); + + /* This is the extension feature which has no uclass at present */ + ut_assert_nextline("Hunting with: simple_bus"); + ut_assert_nextline("Found 2 extension board(s)."); ut_assert_nextline("Hunting with: ide"); ut_assert_nextline("Bus 0: not available "); @@ -379,6 +384,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); ut_assert_nextline(" 6 * ethernet eth_bootdev"); + ut_assert_nextline(" 1 * simple_bus (none)"); ut_assert_nextline(" 5 * ide ide_bootdev"); ut_assert_nextline(" 2 * mmc mmc_bootdev"); ut_assert_nextline(" 4 * nvme nvme_bootdev"); @@ -386,10 +392,10 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline(" 4 * spi_flash sf_bootdev"); ut_assert_nextline(" 5 * usb usb_bootdev"); ut_assert_nextline(" 4 * virtio virtio_bootdev"); - ut_assert_nextline("(total hunters: 8)"); + ut_assert_nextline("(total hunters: 9)"); ut_assert_console_end(); - ut_asserteq(GENMASK(7, 0), std->hunters_used); + ut_asserteq(GENMASK(MAX_HUNTER, 0), std->hunters_used); return 0; } @@ -553,8 +559,8 @@ static int bootdev_test_next_label(struct unit_test_state *uts) ut_asserteq_str("scsi.id0lun0.bootdev", dev->name); ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS, mflags); - /* SCSI is fifth in the list, so bit 4 */ - ut_asserteq(BIT(2) | BIT(4), std->hunters_used); + /* SCSI is sixth in the list, so bit 5 */ + ut_asserteq(BIT(MMC_HUNTER) | BIT(5), std->hunters_used); ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); ut_assert_console_end(); @@ -564,7 +570,7 @@ static int bootdev_test_next_label(struct unit_test_state *uts) mflags); /* dhcp: Ethernet is first so bit 0 */ - ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + ut_asserteq(BIT(MMC_HUNTER) | BIT(5) | BIT(0), std->hunters_used); ut_assertok(bootdev_next_label(&iter, &dev, &mflags)); ut_assert_console_end(); @@ -574,7 +580,7 @@ static int bootdev_test_next_label(struct unit_test_state *uts) mflags); /* pxe: Ethernet is first so bit 0 */ - ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + ut_asserteq(BIT(MMC_HUNTER) | BIT(5) | BIT(0), std->hunters_used); mflags = 123; ut_asserteq(-ENODEV, bootdev_next_label(&iter, &dev, &mflags)); @@ -582,7 +588,7 @@ static int bootdev_test_next_label(struct unit_test_state *uts) ut_assert_console_end(); /* no change */ - ut_asserteq(BIT(2) | BIT(4) | BIT(0), std->hunters_used); + ut_asserteq(BIT(MMC_HUNTER) | BIT(5) | BIT(0), std->hunters_used); return 0; } @@ -629,10 +635,13 @@ static int bootdev_test_next_prio(struct unit_test_state *uts) ut_assertok(bootdev_next_prio(&iter, &dev)); ut_asserteq_str("mmc2.bootdev", dev->name); + ut_assert_nextline("Hunting with: simple_bus"); + ut_assert_nextline("Found 2 extension board(s)."); ut_assert_nextline("Hunting with: mmc"); ut_assert_console_end(); - ut_assertok(bootstd_test_check_mmc_hunter(uts)); + /* extension in second in the list , so bit 1 */ + ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); ut_assertok(bootdev_next_prio(&iter, &dev)); ut_asserteq_str("mmc1.bootdev", dev->name); @@ -663,7 +672,7 @@ static int bootdev_test_next_prio(struct unit_test_state *uts) } while (!ret); ut_asserteq(-ENODEV, ret); ut_assertnull(dev); - ut_asserteq(GENMASK(7, 0), std->hunters_used); + ut_asserteq(GENMASK(MAX_HUNTER, 0), std->hunters_used); ut_assert_skip_to_line("Hunting with: ethernet"); ut_assert_console_end(); diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index b71ec52eb7a..3a65d06696b 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -51,7 +51,7 @@ static int bootflow_cmd(struct unit_test_state *uts) console_record_reset_enable(); ut_assertok(run_command("bootdev select 1", 0)); ut_assert_console_end(); - ut_assertok(run_command("bootflow scan -l", 0)); + ut_assertok(run_command("bootflow scan -lH", 0)); ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); @@ -77,17 +77,17 @@ BOOTSTD_TEST(bootflow_cmd, UT_TESTF_DM | UT_TESTF_SCAN_FDT); static int bootflow_cmd_label(struct unit_test_state *uts) { console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -l mmc1", 0)); + ut_assertok(run_command("bootflow scan -lH mmc1", 0)); ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'"); ut_assert_skip_to_line("(1 bootflow, 1 valid)"); ut_assert_console_end(); - ut_assertok(run_command("bootflow scan -l mmc0.bootdev", 0)); + ut_assertok(run_command("bootflow scan -lH mmc0.bootdev", 0)); ut_assert_nextline("Scanning for bootflows in bootdev 'mmc0.bootdev'"); ut_assert_skip_to_line("(0 bootflows, 0 valid)"); ut_assert_console_end(); - ut_assertok(run_command("bootflow scan -l 0", 0)); + ut_assertok(run_command("bootflow scan -lH 0", 0)); ut_assert_nextline("Scanning for bootflows in bootdev 'mmc2.bootdev'"); ut_assert_skip_to_line("(0 bootflows, 0 valid)"); ut_assert_console_end(); @@ -102,7 +102,7 @@ static int bootflow_cmd_glob(struct unit_test_state *uts) ut_assertok(bootstd_test_drop_bootdev_order(uts)); console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -lG", 0)); + ut_assertok(run_command("bootflow scan -lGH", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); @@ -134,7 +134,7 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts) ut_assertok(bootstd_test_drop_bootdev_order(uts)); console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -aleG", 0)); + ut_assertok(run_command("bootflow scan -aleGH", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); @@ -352,7 +352,7 @@ static int bootflow_system(struct unit_test_state *uts) /* We should get a single 'bootmgr' method right at the end */ bootstd_clear_glob(); console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -l", 0)); + ut_assertok(run_command("bootflow scan -lH", 0)); ut_assert_skip_to_line( " 0 efi_mgr ready (none) 0 "); ut_assert_skip_to_line("No more bootdevs"); @@ -383,7 +383,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) bootstd_clear_glob(); console_record_reset_enable(); ut_assertok(inject_response(uts)); - ut_assertok(run_command("bootflow scan -lb", 0)); + ut_assertok(run_command("bootflow scan -lbH", 0)); /* Try to boot the bootmgr flow, which will fail */ console_record_reset_enable(); @@ -419,7 +419,7 @@ static int bootflow_scan_glob_bootmeth(struct unit_test_state *uts) */ console_record_reset_enable(); ut_assertok(bootmeth_set_order("efi firmware0")); - ut_assertok(run_command("bootflow scan -lG", 0)); + ut_assertok(run_command("bootflow scan -lGH", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline( "Seq Method State Uclass Part Name Filename"); @@ -428,7 +428,7 @@ static int bootflow_scan_glob_bootmeth(struct unit_test_state *uts) ut_assert_nextline("(0 bootflows, 0 valid)"); ut_assert_console_end(); - ut_assertok(run_command("bootflow scan -l", 0)); + ut_assertok(run_command("bootflow scan -lH", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline( "Seq Method State Uclass Part Name Filename"); diff --git a/test/boot/bootstd_common.h b/test/boot/bootstd_common.h index 0eb48fa1537..136a79b5178 100644 --- a/test/boot/bootstd_common.h +++ b/test/boot/bootstd_common.h @@ -20,6 +20,11 @@ #define TEST_VERSION "U-Boot v2022.04-local2" #define TEST_VERNUM 0x00010002 +enum { + MAX_HUNTER = 8, + MMC_HUNTER = 3, /* ID of MMC hunter */ +}; + struct unit_test_state; /** From patchwork Tue Jan 17 17:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727668 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=b95CQPDk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGvB3j8tz23fT for ; Wed, 18 Jan 2023 05:02:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E4C78572A; Tue, 17 Jan 2023 18:52:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="b95CQPDk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 95856856D4; Tue, 17 Jan 2023 18:51:14 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 A6282856B2 for ; Tue, 17 Jan 2023 18:51:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id h184so5814829iof.9 for ; Tue, 17 Jan 2023 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h1endAoFu8Sy8QWUc8EZQrCzx+khqfvuZaPaPntZZls=; b=b95CQPDkIyrshg0nJfA0G3GVkKxxobbueN3zwgmw5PO7Szii8X9UGF9GhZql5wsy11 f2oZxEiaCDmVqEMi/7Po7t1Zg7lIDPe8zYHil5Nrv0wFRpZavljVk3HxVFj3eQ/KPrqo sXHcw4Lay6208usrJ152g9Hilnq7l20NuEUI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h1endAoFu8Sy8QWUc8EZQrCzx+khqfvuZaPaPntZZls=; b=qOT4O3EbkuSJNxXlJBIf+Xg5UEYivaMaFAQwzB5jLjS+da6TE1YXiNu/2eOpEzQwiB yoPnubrjzBaBhMXBDYZYVb1XFZ4e7xQxjrLkfLPYRBzRpWgY7YJ9RGmjuEt8LoFRSgYs 8MdKxA2EJ/qS18tG03y2OIWkEhEi3o9ela2bi7DriJncAIp1BckAni3dklMbHMrNwGJc CUs1o0Vd4DtZlD9uIGWyKXFKwZpS47hWenI3fbEFsvsLik2loFT/nq5Hv6Od37QkZKwm OQXBrWEV4g1Yapux4o04F5HWpy9+SiPaIyr0pu5duUxukBDFvOfBNGh2AluiITpf5Bxw wl6w== X-Gm-Message-State: AFqh2kqR7vQaE8aYBVTSqzPIAjE819ZG4V0JzG7j4Bre22lZ4YLvemhO 0w0nw5oM9/hIMMRvFC6ODAuzwBrDq1ZYuFUA X-Google-Smtp-Source: AMrXdXvL8vrbihUHA4szgryuXhRbeRSGBbujSqGPDqdGKV1UkyTb11CHKBO603E+Baq34oNe327uhg== X-Received: by 2002:a05:6602:2bdc:b0:6ea:6c79:d224 with SMTP id s28-20020a0566022bdc00b006ea6c79d224mr2917274iov.7.1673977800089; Tue, 17 Jan 2023 09:50:00 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:49:59 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 64/70] bootstd: Switch bootdev scanning to use labels Date: Tue, 17 Jan 2023 10:48:14 -0700 Message-Id: <20230117174820.1281477-65-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean At present we set up the bootdev order at the start, then scan the bootdevs one by one. However this approach cannot be used with hunters, since the bootdevs may not exist until the hunter is used. Nor can we just run all the hunters at the start, since that violate's U-Boot's 'lazy init' requirement. It also increases boot time. So we need to adjust the algorithm to scan by labels instead. As a first step, drop the dev_order[] array in favour of a list of labels. Update the name of bootdev_setup_iter_order() to better reflect what it does. Update some related comments and log messages. Also disable a few tests until a later commit where we can use them. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 142 ++++++++---------------------------------- boot/bootflow.c | 72 ++++++++++++++++----- include/bootdev.h | 13 ++-- include/bootflow.h | 8 +-- test/boot/bootdev.c | 22 ++++++- test/boot/bootflow.c | 42 +++++++++++-- 6 files changed, 147 insertions(+), 152 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 63005140061..334be7662a1 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -649,96 +649,12 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp) return 0; } -/** - * h_cmp_bootdev() - Compare two bootdevs to find out which should go first - * - * @v1: struct udevice * of first bootdev device - * @v2: struct udevice * of second bootdev device - * Return: sort order (<0 if dev1 < dev2, ==0 if equal, >0 if dev1 > dev2) - */ -static int h_cmp_bootdev(const void *v1, const void *v2) -{ - const struct udevice *dev1 = *(struct udevice **)v1; - const struct udevice *dev2 = *(struct udevice **)v2; - const struct bootdev_uc_plat *ucp1 = dev_get_uclass_plat(dev1); - const struct bootdev_uc_plat *ucp2 = dev_get_uclass_plat(dev2); - int diff; - - /* Use priority first */ - diff = ucp1->prio - ucp2->prio; - if (diff) - return diff; - - /* Fall back to seq for devices of the same priority */ - diff = dev_seq(dev1) - dev_seq(dev2); - - return diff; -} - -/** - * build_order() - Build the ordered list of bootdevs to use - * - * This builds an ordered list of devices by one of three methods: - * - using the boot_targets environment variable, if non-empty - * - using the bootdev-order devicetree property, if present - * - sorted by priority and sequence number - * - * @bootstd: BOOTSTD device to use - * @order: Bootdevs listed in default order - * @max_count: Number of entries in @order - * Return: number of bootdevs found in the ordering, or -E2BIG if the - * boot_targets string is too long, or -EXDEV if the ordering produced 0 results - */ -static int build_order(struct udevice *bootstd, struct udevice **order, - int max_count) -{ - const char *overflow_target = NULL; - const char *const *labels; - struct udevice *dev; - int i, ret, count; - bool ok; - - labels = bootstd_get_bootdev_order(bootstd, &ok); - if (!ok) - return log_msg_ret("ord", -ENOMEM); - if (labels) { - int upto; - - upto = 0; - for (i = 0; labels[i]; i++) { - ret = bootdev_find_by_label(labels[i], &dev, NULL); - if (!ret) { - if (upto == max_count) { - overflow_target = labels[i]; - break; - } - order[upto++] = dev; - } - } - count = upto; - } else { - /* sort them into priority order */ - count = max_count; - qsort(order, count, sizeof(struct udevice *), h_cmp_bootdev); - } - - if (overflow_target) { - log_warning("Expected at most %d bootdevs, but overflowed with boot_target '%s'\n", - max_count, overflow_target); - } - - if (!count) - return log_msg_ret("targ", -EXDEV); - - return count; -} - -int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) +int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, + int *method_flagsp) { - struct udevice *bootstd, *dev = *devp, **order; + struct udevice *bootstd, *dev = *devp; bool show = iter->flags & BOOTFLOWF_SHOW; - struct uclass *uc; - int count, upto; + int method_flags; int ret; ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd); @@ -757,39 +673,33 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) /* Handle scanning a single device */ if (dev) { iter->flags |= BOOTFLOWF_SINGLE_DEV; - return 0; - } - - count = uclass_id_count(UCLASS_BOOTDEV); - if (!count) - return log_msg_ret("count", -ENOENT); - - order = calloc(count, sizeof(struct udevice *)); - if (!order) - return log_msg_ret("order", -ENOMEM); - - /* Get the list of bootdevs */ - uclass_id_foreach_dev(UCLASS_BOOTDEV, dev, uc) - order[upto++] = dev; - log_debug("Found %d bootdevs\n", count); - if (upto != count) - log_debug("Expected %d bootdevs, found %d using aliases\n", - count, upto); - - ret = build_order(bootstd, order, upto); - if (ret < 0) { - free(order); - return log_msg_ret("build", ret); + log_debug("Selected boodev: %s\n", dev->name); + method_flags = 0; + } else { + bool ok; + + /* This either returns a non-empty list or NULL */ + iter->labels = bootstd_get_bootdev_order(bootstd, &ok); + if (!ok) + return log_msg_ret("ord", -ENOMEM); + log_debug("setup labels %p\n", iter->labels); + if (iter->labels) { + iter->cur_label = -1; + ret = bootdev_next_label(iter, &dev, &method_flags); + } else { + ret = bootdev_next_prio(iter, &dev); + method_flags = 0; + } + if (!dev) + return log_msg_ret("fin", -ENOENT); + log_debug("Selected bootdev: %s\n", dev->name); } - iter->num_devs = ret; - iter->dev_order = order; - iter->cur_dev = 0; - - dev = *order; ret = device_probe(dev); if (ret) return log_msg_ret("probe", ret); + if (method_flagsp) + *method_flagsp = method_flags; *devp = dev; return 0; diff --git a/boot/bootflow.c b/boot/bootflow.c index d2dbc9d4450..32e2aad470d 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -92,7 +92,6 @@ void bootflow_iter_init(struct bootflow_iter *iter, int flags) void bootflow_iter_uninit(struct bootflow_iter *iter) { - free(iter->dev_order); free(iter->method_order); } @@ -113,12 +112,25 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, return 0; } +/** + * bootflow_iter_set_dev() - switch to the next bootdev when iterating + * + * This sets iter->dev, records the device in the dev_used[] list and shows a + * message if required + * + * @iter: Iterator to update + * @dev: Bootdev to use, or NULL if there are no more + */ static void bootflow_iter_set_dev(struct bootflow_iter *iter, - struct udevice *dev) + struct udevice *dev, int method_flags) { struct bootmeth_uc_plat *ucp = dev_get_uclass_plat(iter->method); + log_debug("iter: Setting dev to %s, flags %x\n", + dev ? dev->name : "(none)", method_flags); iter->dev = dev; + iter->method_flags = method_flags; + if ((iter->flags & (BOOTFLOWF_SHOW | BOOTFLOWF_SINGLE_DEV)) == BOOTFLOWF_SHOW) { if (dev) @@ -144,6 +156,7 @@ static int iter_incr(struct bootflow_iter *iter) bool global; int ret; + log_debug("entry: err=%d\n", iter->err); global = iter->doing_global; if (iter->err == BF_NO_MORE_DEVICES) @@ -182,7 +195,7 @@ static int iter_incr(struct bootflow_iter *iter) return 0; } - /* No more partitions; start at the first one and...*/ + /* No more partitions; start at the first one and... */ iter->part = 0; /* @@ -196,16 +209,32 @@ static int iter_incr(struct bootflow_iter *iter) if (iter->flags & BOOTFLOWF_SINGLE_DEV) { ret = -ENOENT; } else { - if (inc_dev) - iter->cur_dev++; - if (iter->cur_dev == iter->num_devs) { - ret = -ENOENT; - bootflow_iter_set_dev(iter, NULL); + int method_flags; + + ret = 0; + dev = iter->dev; + log_debug("inc_dev=%d\n", inc_dev); + if (!inc_dev) { + ret = bootdev_setup_iter(iter, &dev, &method_flags); + } else { + log_debug("labels %p\n", iter->labels); + if (iter->labels) { + ret = bootdev_next_label(iter, &dev, + &method_flags); + } else { + ret = bootdev_next_prio(iter, &dev); + method_flags = 0; + } + } + log_debug("ret=%d, dev=%p %s\n", ret, dev, + dev ? dev->name : "none"); + if (ret) { + bootflow_iter_set_dev(iter, NULL, 0); } else { - dev = iter->dev_order[iter->cur_dev]; ret = device_probe(dev); + log_debug("probe %s %d\n", dev->name, ret); if (!log_msg_ret("probe", ret)) - bootflow_iter_set_dev(iter, dev); + bootflow_iter_set_dev(iter, dev, method_flags); } } @@ -230,7 +259,7 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow) int ret; if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) { - bootflow_iter_set_dev(iter, NULL); + bootflow_iter_set_dev(iter, NULL, 0); ret = bootmeth_get_bootflow(iter->method, bflow); if (ret) return log_msg_ret("glob", ret); @@ -274,18 +303,27 @@ int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, flags |= BOOTFLOWF_SKIP_GLOBAL; bootflow_iter_init(iter, flags); - ret = bootdev_setup_iter_order(iter, &dev); - if (ret) - return log_msg_ret("obdev", -ENODEV); - + /* + * Set up the ordering of bootmeths. This sets iter->doing_global and + * iter->first_glob_method if we are starting with the global bootmeths + */ ret = bootmeth_setup_iter_order(iter, !(flags & BOOTFLOWF_SKIP_GLOBAL)); if (ret) return log_msg_ret("obmeth", -ENODEV); /* Find the first bootmeth (there must be at least one!) */ iter->method = iter->method_order[iter->cur_method]; - if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) || !iter->doing_global) - bootflow_iter_set_dev(iter, dev); + + if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) || !iter->doing_global) { + struct udevice *dev = NULL; + int method_flags; + + ret = bootdev_setup_iter(iter, &dev, &method_flags); + if (ret) + return log_msg_ret("obdev", -ENODEV); + + bootflow_iter_set_dev(iter, dev, method_flags); + } ret = bootflow_check(iter, bflow); if (ret) { diff --git a/include/bootdev.h b/include/bootdev.h index 4b6a8eb8d8f..8fa67487c63 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -265,21 +265,22 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, int *method_flagsp); /** - * bootdev_setup_iter_order() - Set up the ordering of bootdevs to scan + * bootdev_setup_iter() - Set up iteration through bootdevs * - * This sets up the ordering information in @iter, based on the priority of each - * bootdev and the bootdev-order property in the bootstd node - * - * If a single device is requested, no ordering is needed + * This sets up the an interation, based on the priority of each bootdev, the + * bootdev-order property in the bootstd node (or the boot_targets env var). * * @iter: Iterator to update with the order * @devp: On entry, *devp is NULL to scan all, otherwise this is the (single) * device to scan. Returns the first device to use, which is the passed-in * @devp if it was non-NULL + * @method_flagsp: If non-NULL, returns any flags implied by the label + * (enum bootflow_meth_flags_t), 0 if none * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve * on other error */ -int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp); +int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, + int *method_flagsp); /** * bootdev_list_hunters() - List the available bootdev hunters diff --git a/include/bootflow.h b/include/bootflow.h index 69ac90483c6..bdb37352ab9 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -163,7 +163,8 @@ enum bootflow_meth_flags_t { * @flags: Flags to use (see enum bootflow_flags_t). If BOOTFLOWF_GLOBAL_FIRST is * enabled then the global bootmeths are being scanned, otherwise we have * moved onto the bootdevs - * @dev: Current bootdev, NULL if none + * @dev: Current bootdev, NULL if none. This is only ever updated in + * bootflow_iter_set_dev() * @part: Current partition number (0 for whole device) * @method: Current bootmeth * @max_part: Maximum hardware partition number in @dev, 0 if there is no @@ -173,9 +174,6 @@ enum bootflow_meth_flags_t { * forward (e.g. to skip the current partition because it is not valid) * -ESHUTDOWN: try next bootdev * @num_devs: Number of bootdevs in @dev_order - * @cur_dev: Current bootdev number, an index into @dev_order[] - * @dev_order: List of bootdevs to scan, in order of priority. The scan starts - * with the first one on the list * @labels: List of labels to scan for bootdevs * @cur_label: Current label being processed * @num_methods: Number of bootmeth devices in @method_order @@ -198,8 +196,6 @@ struct bootflow_iter { int first_bootable; int err; int num_devs; - int cur_dev; - struct udevice **dev_order; const char *const *labels; int cur_label; int num_methods; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 8ebc27a6435..679ffc4d8df 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -186,6 +186,7 @@ static int bootdev_test_any(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_any, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); +#if 0 /* disable for now */ /* Check bootdev ordering with the bootdev-order property */ static int bootdev_test_order(struct unit_test_state *uts) { @@ -290,6 +291,7 @@ static int bootdev_test_prio(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +#endif /* Check listing hunters */ static int bootdev_test_hunter(struct unit_test_state *uts) @@ -402,6 +404,25 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_cmd_hunt, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); +/* Check searching for bootdevs using the hunters */ +static int bootdev_test_hunt_scan(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootstd_priv *std; + struct bootflow bflow; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + ut_assertok(bootflow_scan_first(&iter, BOOTFLOWF_SHOW | BOOTFLOWF_HUNT | + BOOTFLOWF_SKIP_GLOBAL, &bflow)); + ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); + + return 0; +} +BOOTSTD_TEST(bootdev_test_hunt_scan, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + /* Check that only bootable partitions are processed */ static int bootdev_test_bootable(struct unit_test_state *uts) { @@ -640,7 +661,6 @@ static int bootdev_test_next_prio(struct unit_test_state *uts) ut_assert_nextline("Hunting with: mmc"); ut_assert_console_end(); - /* extension in second in the list , so bit 1 */ ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); ut_assertok(bootdev_next_prio(&iter, &dev)); diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 3a65d06696b..1a2c54c1119 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -55,7 +55,10 @@ static int bootflow_cmd(struct unit_test_state *uts) ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); + ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':"); + ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':"); ut_assert_nextline(" 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf"); + ut_assert_nextline("No more bootdevs"); ut_assert_nextlinen("---"); ut_assert_nextline("(1 bootflow, 1 valid)"); ut_assert_console_end(); @@ -73,28 +76,55 @@ static int bootflow_cmd(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_cmd, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -/* Check 'bootflow scan' with a name / label / seq */ +#if 0 /* disable for now */ +/* Check 'bootflow scan' with a label / seq */ static int bootflow_cmd_label(struct unit_test_state *uts) { + test_set_eth_enable(false); + console_record_reset_enable(); ut_assertok(run_command("bootflow scan -lH mmc1", 0)); - ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'"); + ut_assert_nextline("Scanning for bootflows with label 'mmc1'"); ut_assert_skip_to_line("(1 bootflow, 1 valid)"); ut_assert_console_end(); - ut_assertok(run_command("bootflow scan -lH mmc0.bootdev", 0)); - ut_assert_nextline("Scanning for bootflows in bootdev 'mmc0.bootdev'"); + ut_assertok(run_command("bootflow scan -lH 0", 0)); + ut_assert_nextline("Scanning for bootflows with label '0'"); ut_assert_skip_to_line("(0 bootflows, 0 valid)"); ut_assert_console_end(); + /* + * with ethernet enabled we have 8 devices ahead of the mmc ones: + * + * ut_assertok(run_command("bootdev list", 0)); + * Seq Probed Status Uclass Name + * --- ------ ------ -------- ------------------ + * 0 [ + ] OK ethernet eth@10002000.bootdev + * 1 [ ] OK ethernet eth@10003000.bootdev + * 2 [ ] OK ethernet sbe5.bootdev + * 3 [ ] OK ethernet eth@10004000.bootdev + * 4 [ ] OK ethernet phy-test-eth.bootdev + * 5 [ ] OK ethernet dsa-test-eth.bootdev + * 6 [ ] OK ethernet dsa-test@0.bootdev + * 7 [ ] OK ethernet dsa-test@1.bootdev + * 8 [ ] OK mmc mmc2.bootdev + * 9 [ + ] OK mmc mmc1.bootdev + * a [ ] OK mmc mmc0.bootdev + */ + ut_assertok(run_command("bootflow scan -lH 9", 0)); + ut_assert_nextline("Scanning for bootflows with label '9'"); + ut_assert_skip_to_line("(1 bootflow, 1 valid)"); + ut_assertok(run_command("bootflow scan -lH 0", 0)); - ut_assert_nextline("Scanning for bootflows in bootdev 'mmc2.bootdev'"); + ut_assert_nextline("Scanning for bootflows with label '0'"); ut_assert_skip_to_line("(0 bootflows, 0 valid)"); ut_assert_console_end(); return 0; } -BOOTSTD_TEST(bootflow_cmd_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +BOOTSTD_TEST(bootflow_cmd_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT | + UT_TESTF_ETH_BOOTDEV); +#endif /* Check 'bootflow scan/list' commands using all bootdevs */ static int bootflow_cmd_glob(struct unit_test_state *uts) From patchwork Tue Jan 17 17:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727667 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BgGwDxsM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGtx2Bmmz23fT for ; Wed, 18 Jan 2023 05:02:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F0D1785725; Tue, 17 Jan 2023 18:52:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="BgGwDxsM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 45D01856AF; Tue, 17 Jan 2023 18:51:14 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 B557A85622 for ; Tue, 17 Jan 2023 18:51:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd30.google.com with SMTP id h184so5814861iof.9 for ; Tue, 17 Jan 2023 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tyw3mqw+vMNZSFFdl7owcvCeseZSECKCwbBxmnX9qjw=; b=BgGwDxsMpD/RfvzNps0201/janV8Y9OokeGivUcWlWD5qTOlT8mzI/U/ZYTwGsTNwh NaTminGUTczrelP3btrD0EcfjlfwfoZWF2ADg9LTiKbU6RbAEk0cyb0j+IQHaIl/lbbv ft4+SfGf0xQe53DtlyftTqp1dNlJKt6OcAjdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tyw3mqw+vMNZSFFdl7owcvCeseZSECKCwbBxmnX9qjw=; b=4TrlB3jIDBs0cS3H1Tz30Lcse37sKSBNhSh3pcEmLE07CPzo1cfSebFtndUy3p4vr4 XffVsgu+uvLOqLBR31CZtxCfIh+DHyi3GQXywKMuBdrh9CagOKYGwUYW4k040R7lbFE/ LiZg7kQHRYOeGfqlcKUAtyBIRc53eZsUDpB9uerMljN0CHkvb6rQ2+76Ln2Xvtgs7uqk HGpwP/J/BVYneYTc+R6HES41bUFqabEURiPM+h+gqQE7yOwndipzwLL2P/dnrHfejjJk 90tUnAIPDEhEZfTMWGid5YEEFoWxX31DfvjEK9KuKpmLC9+lbFzQzVizj5EcU+bl1Sw1 Lqvw== X-Gm-Message-State: AFqh2koqb774DMoIM614yyYjlD6pujaV0JQyCeRfV6BnfhPVAJ+AK9K+ LfvZfNqmtg2IJzKuF/czZo8R7cXZoxTViCit X-Google-Smtp-Source: AMrXdXvWltmpvz5MhCcJ9eGsWzYpkJ8qlDQGfcFXSVRXI1CBJqmaADAa+2mVAsR0cqmbm7iJnDq75w== X-Received: by 2002:a6b:8fc1:0:b0:704:5276:7ba7 with SMTP id r184-20020a6b8fc1000000b0070452767ba7mr2982585iod.19.1673977801359; Tue, 17 Jan 2023 09:50:01 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:00 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 65/70] bootstd: Allow scanning a single bootdev label Date: Tue, 17 Jan 2023 10:48:15 -0700 Message-Id: <20230117174820.1281477-66-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean We want to support scanning a single label, like 'mmc' or 'usb0'. Add this feature by plumbing the label through to the iterator, setting a flag to indicate that only siblings of the initial device should be used. This means that scanning a bootdev by its name is not supported anymore. That feature doesn't seem very useful in practice, so it is no great loss. Add a test for bootdev_find_by_any() while we are here. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 28 ++++++++++---- boot/bootflow.c | 43 +++++++++++++++++++--- cmd/bootflow.c | 86 +++++++++++++++++-------------------------- include/bootdev.h | 11 ++++-- include/bootflow.h | 10 +++-- test/boot/bootdev.c | 2 +- test/boot/bootflow.c | 62 ++++++++++++++++++++++++++++++- 7 files changed, 166 insertions(+), 76 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 334be7662a1..522ecf38eb3 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -649,10 +649,10 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp) return 0; } -int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, - int *method_flagsp) +int bootdev_setup_iter(struct bootflow_iter *iter, const char *label, + struct udevice **devp, int *method_flagsp) { - struct udevice *bootstd, *dev = *devp; + struct udevice *bootstd, *dev = NULL; bool show = iter->flags & BOOTFLOWF_SHOW; int method_flags; int ret; @@ -671,10 +671,24 @@ int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, } /* Handle scanning a single device */ - if (dev) { - iter->flags |= BOOTFLOWF_SINGLE_DEV; - log_debug("Selected boodev: %s\n", dev->name); - method_flags = 0; + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && label) { + if (iter->flags & BOOTFLOWF_HUNT) { + ret = bootdev_hunt(label, show); + if (ret) + return log_msg_ret("hun", ret); + } + ret = bootdev_find_by_any(label, &dev, &method_flags); + if (ret) + return log_msg_ret("lab", ret); + + log_debug("method_flags: %x\n", method_flags); + if (method_flags & BOOTFLOW_METHF_SINGLE_UCLASS) + iter->flags |= BOOTFLOWF_SINGLE_UCLASS; + else if (method_flags & BOOTFLOW_METHF_SINGLE_DEV) + iter->flags |= BOOTFLOWF_SINGLE_DEV; + else + iter->flags |= BOOTFLOWF_SINGLE_MEDIA; + log_debug("Selected label: %s, flags %x\n", label, iter->flags); } else { bool ok; diff --git a/boot/bootflow.c b/boot/bootflow.c index 32e2aad470d..50d9c2e813a 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -215,7 +215,37 @@ static int iter_incr(struct bootflow_iter *iter) dev = iter->dev; log_debug("inc_dev=%d\n", inc_dev); if (!inc_dev) { - ret = bootdev_setup_iter(iter, &dev, &method_flags); + ret = bootdev_setup_iter(iter, NULL, &dev, + &method_flags); + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && + (iter->flags & BOOTFLOWF_SINGLE_UCLASS)) { + /* Move to the next bootdev in this uclass */ + uclass_find_next_device(&dev); + if (!dev) { + log_debug("finished uclass %s\n", + dev_get_uclass_name(dev)); + ret = -ENODEV; + } + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && + iter->flags & BOOTFLOWF_SINGLE_MEDIA) { + log_debug("next in single\n"); + method_flags = 0; + do { + /* + * Move to the next bootdev child of this media + * device. This ensures that we cover all the + * available SCSI IDs and LUNs. + */ + device_find_next_child(&dev); + log_debug("- next %s\n", + dev ? dev->name : "(none)"); + } while (dev && device_get_uclass_id(dev) != + UCLASS_BOOTDEV); + if (!dev) { + log_debug("finished uclass %s\n", + dev_get_uclass_name(dev)); + ret = -ENODEV; + } } else { log_debug("labels %p\n", iter->labels); if (iter->labels) { @@ -294,12 +324,13 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow) return 0; } -int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, - int flags, struct bootflow *bflow) +int bootflow_scan_bootdev(struct udevice *dev, const char *label, + struct bootflow_iter *iter, int flags, + struct bootflow *bflow) { int ret; - if (dev) + if (dev || label) flags |= BOOTFLOWF_SKIP_GLOBAL; bootflow_iter_init(iter, flags); @@ -318,7 +349,7 @@ int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, struct udevice *dev = NULL; int method_flags; - ret = bootdev_setup_iter(iter, &dev, &method_flags); + ret = bootdev_setup_iter(iter, label, &dev, &method_flags); if (ret) return log_msg_ret("obdev", -ENODEV); @@ -345,7 +376,7 @@ int bootflow_scan_first(struct bootflow_iter *iter, int flags, { int ret; - ret = bootflow_scan_bootdev(NULL, iter, flags, bflow); + ret = bootflow_scan_bootdev(NULL, NULL, iter, flags, bflow); if (ret) return log_msg_ret("start", ret); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index fe58de5fa59..72d5a8424e9 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -93,11 +93,12 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, { struct bootstd_priv *std; struct bootflow_iter iter; - struct udevice *dev; + struct udevice *dev = NULL; struct bootflow bflow; bool all = false, boot = false, errors = false, no_global = false; bool list = false, no_hunter = false; int num_valid = 0; + const char *label = NULL; bool has_args; int ret, i; int flags; @@ -105,7 +106,6 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, ret = bootstd_get_priv(&std); if (ret) return CMD_RET_FAILURE; - dev = std->cur_bootdev; has_args = argc > 1 && *argv[1] == '-'; if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL)) { @@ -119,12 +119,10 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, argc--; argv++; } - if (argc > 1) { - const char *label = argv[1]; - - if (bootdev_find_by_any(label, &dev, NULL)) - return CMD_RET_FAILURE; - } + if (argc > 1) + label = argv[1]; + if (!label) + dev = std->cur_bootdev; } else { if (has_args) { printf("Flags not supported: enable CONFIG_BOOTFLOW_FULL\n"); @@ -148,54 +146,36 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, /* * If we have a device, just scan for bootflows attached to that device */ - if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && dev) { - if (list) { - printf("Scanning for bootflows in bootdev '%s'\n", - dev->name); - show_header(); - } + if (list) { + printf("Scanning for bootflows "); + if (dev) + printf("in bootdev '%s'\n", dev->name); + else if (label) + printf("with label '%s'\n", label); + else + printf("in all bootdevs\n"); + show_header(); + } + if (dev) bootdev_clear_bootflows(dev); - for (i = 0, - ret = bootflow_scan_bootdev(dev, &iter, flags, &bflow); - i < 1000 && ret != -ENODEV; - i++, ret = bootflow_scan_next(&iter, &bflow)) { - bflow.err = ret; - if (!ret) - num_valid++; - ret = bootdev_add_bootflow(&bflow); - if (ret) { - printf("Out of memory\n"); - return CMD_RET_FAILURE; - } - if (list) - show_bootflow(i, &bflow, errors); - if (boot && !bflow.err) - bootflow_run_boot(&iter, &bflow); - } - } else { - if (list) { - printf("Scanning for bootflows in all bootdevs\n"); - show_header(); - } + else bootstd_clear_glob(); - - for (i = 0, - ret = bootflow_scan_first(&iter, flags, &bflow); - i < 1000 && ret != -ENODEV; - i++, ret = bootflow_scan_next(&iter, &bflow)) { - bflow.err = ret; - if (!ret) - num_valid++; - ret = bootdev_add_bootflow(&bflow); - if (ret) { - printf("Out of memory\n"); - return CMD_RET_FAILURE; - } - if (list) - show_bootflow(i, &bflow, errors); - if (boot && !bflow.err) - bootflow_run_boot(&iter, &bflow); + for (i = 0, + ret = bootflow_scan_bootdev(dev, label, &iter, flags, &bflow); + i < 1000 && ret != -ENODEV; + i++, ret = bootflow_scan_next(&iter, &bflow)) { + bflow.err = ret; + if (!ret) + num_valid++; + ret = bootdev_add_bootflow(&bflow); + if (ret) { + printf("Out of memory\n"); + return CMD_RET_FAILURE; } + if (list) + show_bootflow(i, &bflow, errors); + if (boot && !bflow.err) + bootflow_run_boot(&iter, &bflow); } bootflow_iter_uninit(&iter); if (list) diff --git a/include/bootdev.h b/include/bootdev.h index 8fa67487c63..b92ff4d4f15 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -267,10 +267,13 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, /** * bootdev_setup_iter() - Set up iteration through bootdevs * - * This sets up the an interation, based on the priority of each bootdev, the - * bootdev-order property in the bootstd node (or the boot_targets env var). + * This sets up the an interation, based on the provided device or label. If + * neither is provided, the iteration is based on the priority of each bootdev, + * the * bootdev-order property in the bootstd node (or the boot_targets env + * var). * * @iter: Iterator to update with the order + * @label: label to scan, or NULL to scan all * @devp: On entry, *devp is NULL to scan all, otherwise this is the (single) * device to scan. Returns the first device to use, which is the passed-in * @devp if it was non-NULL @@ -279,8 +282,8 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve * on other error */ -int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, - int *method_flagsp); +int bootdev_setup_iter(struct bootflow_iter *iter, const char *label, + struct udevice **devp, int *method_flagsp); /** * bootdev_list_hunters() - List the available bootdev hunters diff --git a/include/bootflow.h b/include/bootflow.h index bdb37352ab9..1b7920a9572 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -255,14 +255,18 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, * * @dev: Boot device to scan, NULL to work through all of them until it * finds one that can supply a bootflow + * @label: Label to control the scan, NULL to work through all devices + * until it finds one that can supply a bootflow * @iter: Place to store private info (inited by this call) - * @flags: Flags for iterator (enum bootflow_flags_t) + * @flags: Flags for iterator (enum bootflow_flags_t). Note that if @dev + * is NULL, then BOOTFLOWF_SKIP_GLOBAL is set automatically by this function * @bflow: Place to put the bootflow if found * Return: 0 if found, -ENODEV if no device, other -ve on other error * (iteration can continue) */ -int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, - int flags, struct bootflow *bflow); +int bootflow_scan_bootdev(struct udevice *dev, const char *label, + struct bootflow_iter *iter, int flags, + struct bootflow *bflow); /** * bootflow_scan_first() - find the first bootflow diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 679ffc4d8df..1724e34af3e 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -626,7 +626,7 @@ static int bootdev_test_next_prio(struct unit_test_state *uts) struct udevice *dev; int ret; - sandbox_set_eth_enable(false); + test_set_eth_enable(false); test_set_skip_delays(true); /* get access to the used hunters */ diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 1a2c54c1119..0b3a2fa6acc 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -76,7 +76,6 @@ static int bootflow_cmd(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_cmd, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -#if 0 /* disable for now */ /* Check 'bootflow scan' with a label / seq */ static int bootflow_cmd_label(struct unit_test_state *uts) { @@ -124,7 +123,6 @@ static int bootflow_cmd_label(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_cmd_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); -#endif /* Check 'bootflow scan/list' commands using all bootdevs */ static int bootflow_cmd_glob(struct unit_test_state *uts) @@ -564,6 +562,66 @@ static int bootflow_cmd_menu(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_cmd_menu, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +/* Check searching for a single bootdev using the hunters */ +static int bootflow_cmd_hunt_single(struct unit_test_state *uts) +{ + struct bootstd_priv *std; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + + console_record_reset_enable(); + ut_assertok(run_command("bootflow scan -l mmc1", 0)); + ut_assert_nextline("Scanning for bootflows with label 'mmc1'"); + ut_assert_skip_to_line("(1 bootflow, 1 valid)"); + ut_assert_console_end(); + + /* check that the hunter was used */ + ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); + + return 0; +} +BOOTSTD_TEST(bootflow_cmd_hunt_single, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check searching for a uclass label using the hunters */ +static int bootflow_cmd_hunt_label(struct unit_test_state *uts) +{ + struct bootstd_priv *std; + + /* get access to the used hunters */ + ut_assertok(bootstd_get_priv(&std)); + + test_set_skip_delays(true); + test_set_eth_enable(false); + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + + console_record_reset_enable(); + ut_assertok(run_command("bootflow scan -l mmc", 0)); + + /* check that the hunter was used */ + ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); + + /* check that we got the mmc1 bootflow */ + ut_assert_nextline("Scanning for bootflows with label 'mmc'"); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextline("Hunting with: simple_bus"); + ut_assert_nextline("Found 2 extension board(s)."); + ut_assert_nextline("Hunting with: mmc"); + ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':"); + ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':"); + ut_assert_nextline( + " 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf"); + ut_assert_nextline("Scanning bootdev 'mmc0.bootdev':"); + ut_assert_skip_to_line("(1 bootflow, 1 valid)"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_cmd_hunt_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + /** * check_font() - Check that the font size for an item matches expectations * From patchwork Tue Jan 17 17:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727669 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Sz1FxxyS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGvR0Zpmz23fT for ; Wed, 18 Jan 2023 05:02:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA73785733; Tue, 17 Jan 2023 18:52:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Sz1FxxyS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE68A856C8; Tue, 17 Jan 2023 18:51:15 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 BBE6E856B0 for ; Tue, 17 Jan 2023 18:51:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id u8so15739742ilq.13 for ; Tue, 17 Jan 2023 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Dk668lnRImqZuCWhU9cUx+dwdMZ9nHevE6pg6fRXa8=; b=Sz1FxxySrP/zIcpoXqzhMAuUJK45HBOUfsWjRMHcs/SMZqlQlh29332OTgG2+Aa2LL U0hRBSBtlI6D3tW43cXcYuIGE93y+74boZ5USQmn9P7KFxQudfxZD4l2P7l4K9wcKkJQ HOQA3l8UjU+44eD8UvuaK22hCcbUUIPOpwzg4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Dk668lnRImqZuCWhU9cUx+dwdMZ9nHevE6pg6fRXa8=; b=ZSrF9vKgxoZfL2g8j0vwUGtynRCfxZfZMhrt+slD2D7sfbppOsoWQmmO8+voB/phKB x+mnF0wQwrshnhzhNhbD8CCgcKukOnRM6KxlCodSRQgcCLGu7exuT5z4h/hF1UkA8y9a tE6bzrcL1AdJffawy86/xaLW94fNA0XE3RdsUDMGbxuTFQ9ZhMIY7MgFHxS0gAnBPYhJ vZpXy9+tUEXgVJA2iWmz6L7QnIRW8IhMfrTdOqnv+izzCfiaqgBWFdrfnDufsrVw+Uy3 +N88+VXpV15XdbFlMYgEQV+1gAE55OwsnOMJy64+8Ux88U4yxB6NyR1Asm88FhBJjUXG QDBQ== X-Gm-Message-State: AFqh2krCy7vSdu8ZnxnC5ymjp86fDQidDBmbbt86kxeWqPbOQUWQY4Nl 6fXXR5HC3EaiSLVu1tjQcb49NhE8CG5+pg1f X-Google-Smtp-Source: AMrXdXvag5AiNZcb+G8XzAwARe0/DwUDwQXmOnirXvvZWemyzlWy8uuGxbYgNU4558SwlqT/JowZtA== X-Received: by 2002:a05:6e02:4a4:b0:30e:f6ad:55da with SMTP id e4-20020a056e0204a400b0030ef6ad55damr3056109ils.8.1673977802541; Tue, 17 Jan 2023 09:50:02 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:02 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 66/70] bootstd: Drop the old bootflow_scan_first() Date: Tue, 17 Jan 2023 10:48:16 -0700 Message-Id: <20230117174820.1281477-67-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean This function is not used outside tests. Drop it and rename bootflow_scan_dev() since it is how we start a scan now. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 18 +++--------------- cmd/bootflow.c | 2 +- include/bootflow.h | 23 +++-------------------- test/boot/bootdev.c | 16 +++++++++------- test/boot/bootflow.c | 5 +++-- 5 files changed, 19 insertions(+), 45 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 50d9c2e813a..750732f7083 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -324,9 +324,9 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow) return 0; } -int bootflow_scan_bootdev(struct udevice *dev, const char *label, - struct bootflow_iter *iter, int flags, - struct bootflow *bflow) +int bootflow_scan_first(struct udevice *dev, const char *label, + struct bootflow_iter *iter, int flags, + struct bootflow *bflow) { int ret; @@ -371,18 +371,6 @@ int bootflow_scan_bootdev(struct udevice *dev, const char *label, return 0; } -int bootflow_scan_first(struct bootflow_iter *iter, int flags, - struct bootflow *bflow) -{ - int ret; - - ret = bootflow_scan_bootdev(NULL, NULL, iter, flags, bflow); - if (ret) - return log_msg_ret("start", ret); - - return 0; -} - int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) { int ret; diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 72d5a8424e9..692bc6d117f 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -161,7 +161,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, else bootstd_clear_glob(); for (i = 0, - ret = bootflow_scan_bootdev(dev, label, &iter, flags, &bflow); + ret = bootflow_scan_first(dev, label, &iter, flags, &bflow); i < 1000 && ret != -ENODEV; i++, ret = bootflow_scan_next(&iter, &bflow)) { bflow.err = ret; diff --git a/include/bootflow.h b/include/bootflow.h index 1b7920a9572..c2368912061 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -249,7 +249,7 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, const struct udevice *bmeth); /** - * bootflow_scan_bootdev() - find the first bootflow in a bootdev + * bootflow_scan_first() - find the first bootflow for a device or label * * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too * @@ -264,25 +264,8 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, * Return: 0 if found, -ENODEV if no device, other -ve on other error * (iteration can continue) */ -int bootflow_scan_bootdev(struct udevice *dev, const char *label, - struct bootflow_iter *iter, int flags, - struct bootflow *bflow); - -/** - * bootflow_scan_first() - find the first bootflow - * - * This works through the available bootdev devices until it finds one that - * can supply a bootflow. It then returns that - * - * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too - * - * @iter: Place to store private info (inited by this call), with - * @flags: Flags for bootdev (enum bootflow_flags_t) - * @bflow: Place to put the bootflow if found - * Return: 0 if found, -ENODEV if no device, other -ve on other error (iteration - * can continue) - */ -int bootflow_scan_first(struct bootflow_iter *iter, int flags, +int bootflow_scan_first(struct udevice *dev, const char *label, + struct bootflow_iter *iter, int flags, struct bootflow *bflow); /** diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 1724e34af3e..5d5ce7f48cf 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -203,7 +203,7 @@ static int bootdev_test_order(struct unit_test_state *uts) * mmc2 - nothing connected */ ut_assertok(env_set("boot_targets", NULL)); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(2, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name); @@ -211,7 +211,7 @@ static int bootdev_test_order(struct unit_test_state *uts) /* Use the environment variable to override it */ ut_assertok(env_set("boot_targets", "mmc1 mmc2")); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(2, iter.num_devs); ut_asserteq_str("mmc1.bootdev", iter.dev_order[0]->name); ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name); @@ -224,7 +224,7 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(env_set("boot_targets", NULL)); ut_assertok(bootstd_test_drop_bootdev_order(uts)); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(3, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name); @@ -239,7 +239,7 @@ static int bootdev_test_order(struct unit_test_state *uts) iter.dev_order[2]->seq_ = 2; bootflow_iter_uninit(&iter); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(3, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); ut_asserteq_str("mmc0.bootdev", iter.dev_order[1]->name); @@ -268,7 +268,7 @@ static int bootdev_test_prio(struct unit_test_state *uts) /* 3 MMC and 3 USB bootdevs: MMC should come before USB */ console_record_reset_enable(); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(6, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); ut_asserteq_str("usb_mass_storage.lun0.bootdev", @@ -282,7 +282,8 @@ static int bootdev_test_prio(struct unit_test_state *uts) ucp->prio = 1; bootflow_iter_uninit(&iter); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWF_HUNT, + &bflow)); ut_asserteq(6, iter.num_devs); ut_asserteq_str("usb_mass_storage.lun0.bootdev", iter.dev_order[0]->name); @@ -415,7 +416,8 @@ static int bootdev_test_hunt_scan(struct unit_test_state *uts) ut_assertok(bootstd_get_priv(&std)); ut_assertok(bootstd_test_drop_bootdev_order(uts)); - ut_assertok(bootflow_scan_first(&iter, BOOTFLOWF_SHOW | BOOTFLOWF_HUNT | + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, + BOOTFLOWF_SHOW | BOOTFLOWF_HUNT | BOOTFLOWF_SKIP_GLOBAL, &bflow)); ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used); diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 0b3a2fa6acc..b9284fc464a 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -276,7 +276,8 @@ static int bootflow_iter(struct unit_test_state *uts) /* The first device is mmc2.bootdev which has no media */ ut_asserteq(-EPROTONOSUPPORT, - bootflow_scan_first(&iter, BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow)); + bootflow_scan_first(NULL, NULL, &iter, + BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow)); ut_asserteq(2, iter.num_methods); ut_asserteq(0, iter.cur_method); ut_asserteq(0, iter.part); @@ -415,7 +416,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* Try to boot the bootmgr flow, which will fail */ console_record_reset_enable(); - ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(3, iter.num_methods); ut_asserteq_str("sandbox", iter.method->name); ut_assertok(inject_response(uts)); From patchwork Tue Jan 17 17:48:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727670 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TSoNqIUh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGvg5fWDz23fT for ; Wed, 18 Jan 2023 05:02:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0DF4A8572E; Tue, 17 Jan 2023 18:52:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="TSoNqIUh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 279A7856A2; Tue, 17 Jan 2023 18:51:19 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 C81A2856AE for ; Tue, 17 Jan 2023 18:51:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id d10so15739146ilc.12 for ; Tue, 17 Jan 2023 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rNa3ILOJC+XQaXVfL470hU6AnLDX7fEA29XA22cJE/0=; b=TSoNqIUhbdIZNwoLnK5/zkz036+m4H4LpxQ5ILDVGwq6Bzw09Eu6QQRugSTMuHvFfv M1P6fYnpxyZ54ZUWoIOg7CD6Ee/Kj4LgPul5qtW4nyj3oO+OP/AzzkbJwpVbjTNrvjbI qLutXZZpv90dzWRXbs/E0TGImPfRMnbxXJRPo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rNa3ILOJC+XQaXVfL470hU6AnLDX7fEA29XA22cJE/0=; b=HeJNjfBkExs5tCGcrqY8bnoCrNtvkMf31djyBt2mN/zmks6DmfBsXRe/BN/NRfJ+It UEd96UWDqI583FDBpWqW5C2MQQ2UBZsEGEmGv4FyQsNq3NYjCl1f5wNPyY8xj/qZR3hn hS9YUvriaIZCr3oxGawLA/Q+i5O/T17pxagP5P50EBMjGtU+0H3i7RAcPgVR3V26spa0 Z7ltpuLhOrJfYUHwVIkB3SRNq/fc9RtXFzYxL809Tf7PfovEqjZpeFyiWHz22sYn7o1K EpaZU8lk0SAZaiW9zPCyv5DoeKuIWXusepaY4AR210hqN1mUOa0M2NrfKb7jNFcYy6od fLJQ== X-Gm-Message-State: AFqh2koymt2Pm8BLGHRdCbCbB5EspIhqApYJDptL9w163lYgo/ewIoKG hpNEw8d8tR8yZJKUB7hWB2lGx11ErUphelk9 X-Google-Smtp-Source: AMrXdXsE9BiGmUtgMpu8CigbyHiPOJgHCK6nyS4iCsh79iMO8XIdC4JDUsLGzw47Q8iCw8ZuFos0Sw== X-Received: by 2002:a05:6e02:1003:b0:30e:df55:7e2 with SMTP id n3-20020a056e02100300b0030edf5507e2mr3050021ilj.10.1673977803679; Tue, 17 Jan 2023 09:50:03 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:03 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 67/70] bootstd: Record the bootdevs used during scanning Date: Tue, 17 Jan 2023 10:48:17 -0700 Message-Id: <20230117174820.1281477-68-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add a way to record the bootdevs used when scanning for bootflows. This is useful for testing. Enable this only with BOOTSTD_FULL and do the same for the progress reporting. Re-enable and update the affected tests now that we have this feature. For bootdev_test_order_default() there is no-longer any support for using the bootdev aliases to specify an ordering, so drop that part of the test. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 29 +++++++++++++------- include/bootflow.h | 10 ++++++- test/boot/bootdev.c | 67 +++++++++++++++++++++++---------------------- 3 files changed, 63 insertions(+), 43 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 750732f7083..03a180bcddc 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -88,6 +88,9 @@ void bootflow_iter_init(struct bootflow_iter *iter, int flags) memset(iter, '\0', sizeof(*iter)); iter->first_glob_method = -1; iter->flags = flags; + + /* remember the first bootdevs we see */ + iter->max_devs = BOOTFLOW_MAX_USED_DEVS; } void bootflow_iter_uninit(struct bootflow_iter *iter) @@ -131,16 +134,22 @@ static void bootflow_iter_set_dev(struct bootflow_iter *iter, iter->dev = dev; iter->method_flags = method_flags; - if ((iter->flags & (BOOTFLOWF_SHOW | BOOTFLOWF_SINGLE_DEV)) == - BOOTFLOWF_SHOW) { - if (dev) - printf("Scanning bootdev '%s':\n", dev->name); - else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && - ucp->flags & BOOTMETHF_GLOBAL) - printf("Scanning global bootmeth '%s':\n", - iter->method->name); - else - printf("No more bootdevs\n"); + if (IS_ENABLED(CONFIG_BOOTSTD_FULL)) { + /* record the device for later */ + if (dev && iter->num_devs < iter->max_devs) + iter->dev_used[iter->num_devs++] = dev; + + if ((iter->flags & (BOOTFLOWF_SHOW | BOOTFLOWF_SINGLE_DEV)) == + BOOTFLOWF_SHOW) { + if (dev) + printf("Scanning bootdev '%s':\n", dev->name); + else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && + ucp->flags & BOOTMETHF_GLOBAL) + printf("Scanning global bootmeth '%s':\n", + iter->method->name); + else + printf("No more bootdevs\n"); + } } } diff --git a/include/bootflow.h b/include/bootflow.h index c2368912061..f516bf8dea4 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -14,6 +14,10 @@ struct bootstd_priv; struct expo; +enum { + BOOTFLOW_MAX_USED_DEVS = 16, +}; + /** * enum bootflow_state_t - states that a particular bootflow can be in * @@ -173,7 +177,9 @@ enum bootflow_meth_flags_t { * @err: Error obtained from checking the last iteration. This is used to skip * forward (e.g. to skip the current partition because it is not valid) * -ESHUTDOWN: try next bootdev - * @num_devs: Number of bootdevs in @dev_order + * @num_devs: Number of bootdevs in @dev_used + * @max_devs: Maximum number of entries in @dev_used + * @dev_used: List of bootdevs used during iteration * @labels: List of labels to scan for bootdevs * @cur_label: Current label being processed * @num_methods: Number of bootmeth devices in @method_order @@ -196,6 +202,8 @@ struct bootflow_iter { int first_bootable; int err; int num_devs; + int max_devs; + struct udevice *dev_used[BOOTFLOW_MAX_USED_DEVS]; const char *const *labels; int cur_label; int num_methods; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 5d5ce7f48cf..ef5215bbcec 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -186,7 +186,6 @@ static int bootdev_test_any(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_any, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); -#if 0 /* disable for now */ /* Check bootdev ordering with the bootdev-order property */ static int bootdev_test_order(struct unit_test_state *uts) { @@ -205,18 +204,29 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(env_set("boot_targets", NULL)); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(2, iter.num_devs); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); - ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); bootflow_iter_uninit(&iter); /* Use the environment variable to override it */ ut_assertok(env_set("boot_targets", "mmc1 mmc2")); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(2, iter.num_devs); - ut_asserteq_str("mmc1.bootdev", iter.dev_order[0]->name); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name); bootflow_iter_uninit(&iter); + return 0; +} +BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check default bootdev ordering */ +static int bootdev_test_order_default(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootflow bflow; + /* * Now drop both orderings, to check the default (prioriy/sequence) * ordering @@ -225,30 +235,18 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(bootstd_test_drop_bootdev_order(uts)); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); - ut_asserteq(3, iter.num_devs); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); - ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name); - ut_asserteq_str("mmc0.bootdev", iter.dev_order[2]->name); - - /* - * Check that adding aliases for the bootdevs works. We just fake it by - * setting the sequence numbers directly. - */ - iter.dev_order[0]->seq_ = 0; - iter.dev_order[1]->seq_ = 3; - iter.dev_order[2]->seq_ = 2; - bootflow_iter_uninit(&iter); + ut_asserteq(2, iter.num_devs); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); - ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(3, iter.num_devs); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); - ut_asserteq_str("mmc0.bootdev", iter.dev_order[1]->name); - ut_asserteq_str("mmc1.bootdev", iter.dev_order[2]->name); + ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); bootflow_iter_uninit(&iter); return 0; } -BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +BOOTSTD_TEST(bootdev_test_order_default, UT_TESTF_DM | UT_TESTF_SCAN_FDT); /* Check bootdev ordering with the uclass priority */ static int bootdev_test_prio(struct unit_test_state *uts) @@ -260,6 +258,9 @@ static int bootdev_test_prio(struct unit_test_state *uts) test_set_skip_delays(true); + /* disable ethernet since the hunter will run dhcp */ + test_set_eth_enable(false); + /* Start up USB which gives us three additional bootdevs */ usb_started = false; ut_assertok(run_command("usb start", 0)); @@ -269,30 +270,32 @@ static int bootdev_test_prio(struct unit_test_state *uts) /* 3 MMC and 3 USB bootdevs: MMC should come before USB */ console_record_reset_enable(); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(6, iter.num_devs); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); ut_asserteq_str("usb_mass_storage.lun0.bootdev", - iter.dev_order[3]->name); + iter.dev_used[3]->name); - ut_assertok(bootdev_get_sibling_blk(iter.dev_order[3], &blk)); + ut_assertok(bootdev_get_sibling_blk(iter.dev_used[3], &blk)); ut_asserteq_str("usb_mass_storage.lun0", blk->name); /* adjust the priority of the first USB bootdev to the highest */ - ucp = dev_get_uclass_plat(iter.dev_order[3]); - ucp->prio = 1; + ucp = dev_get_uclass_plat(iter.dev_used[3]); + ucp->prio = BOOTDEVP_1_PRE_SCAN; + /* try again but enable hunting, which brings in SCSI */ bootflow_iter_uninit(&iter); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWF_HUNT, &bflow)); - ut_asserteq(6, iter.num_devs); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(7, iter.num_devs); ut_asserteq_str("usb_mass_storage.lun0.bootdev", - iter.dev_order[0]->name); - ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name); + iter.dev_used[0]->name); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name); return 0; } BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -#endif /* Check listing hunters */ static int bootdev_test_hunter(struct unit_test_state *uts) From patchwork Tue Jan 17 17:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727672 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JwT0RF6J; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGw91Q1Bz23fT for ; Wed, 18 Jan 2023 05:03:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B7738573A; Tue, 17 Jan 2023 18:52:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="JwT0RF6J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9A08E856BA; Tue, 17 Jan 2023 18:51:20 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 15F9A856BD for ; Tue, 17 Jan 2023 18:51:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id u8so15739805ilq.13 for ; Tue, 17 Jan 2023 09:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kn61WcZI6iQ0F7clT5z5RlprpNSSAiPBxEUI87S7C4A=; b=JwT0RF6J3f314KUIulIEeZJaHo8Zo82oOCZdBGK6O+V6qB92kH1tryrjlSzqAg6qDU 4p05Sr2qPN6m9D4WPeLmYGp/OQYzJsPV1BaMMryZ3jPa2Jb5shUM/yHhPWn5r3W3O1CB JeCriZyGbovvC7jxOQpSpalyHuPT5Sk59V+UM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kn61WcZI6iQ0F7clT5z5RlprpNSSAiPBxEUI87S7C4A=; b=dM1Yqfofb5jSYTknyJ+X1qxWZuB82LaSflmB59HKpHgwj68Du1Lifw3ASlOeSDLEVH Q6ASEtPU5aZBLCUQ74nbJWiRjqzB5qVK+jRHBlWtOurSS52DFyfvvZomhmGgpjgR62Mb IQAj9lkGGhI+31gHQfTx2JFeVHvHhdJc1arSLTrYzcaLuhmqqJSjMDwCuyH3DtbSdA3B +wqwlR8BYWT+91hRtS5+Byc/XN8SCf36GCHNeeidaUqisXEtlXv657ldbdVSbFfstQfX EivUmr1qqQx/fcgSoE5/3nZr9bYGneLsZ2imWx1h+a7bUnwxU6M807bcHZOzwvLfBBI/ M6Hw== X-Gm-Message-State: AFqh2krmMVYl89ausURMGeEUnZLeuQHSde2cDjYLHiGY5NhXp8FMzGdp k8CoH/9Q5x8/P0GkuKp9EvVXNCgYPu3nYGV+ X-Google-Smtp-Source: AMrXdXvWbPG38fmOwvIMETUO+U9IKx6kdV6EA2q+ZKAteFa8wpnnZhwYzzLhLehNMNhOVKI/JtROsQ== X-Received: by 2002:a05:6e02:11ac:b0:30d:b083:16a6 with SMTP id 12-20020a056e0211ac00b0030db08316a6mr2745963ilj.26.1673977804804; Tue, 17 Jan 2023 09:50:04 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:04 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 68/70] bootstd: Add a little more logging of bootflows Date: Tue, 17 Jan 2023 10:48:18 -0700 Message-Id: <20230117174820.1281477-69-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Add some logging to aid debugging of problems with bootflows. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 1 + boot/bootflow.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 522ecf38eb3..99ee08e3353 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -546,6 +546,7 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, { const struct bootdev_ops *ops = bootdev_get_ops(dev); + log_debug("->get_bootflow %s=%p\n", dev->name, ops->get_bootflow); bootflow_init(bflow, dev, iter->method); if (!ops->get_bootflow) return default_get_bootflow(dev, iter, bflow); diff --git a/boot/bootflow.c b/boot/bootflow.c index 03a180bcddc..dc3f1f0c731 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -367,6 +367,7 @@ int bootflow_scan_first(struct udevice *dev, const char *label, ret = bootflow_check(iter, bflow); if (ret) { + log_debug("check - ret=%d\n", ret); if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) { if (iter->flags & BOOTFLOWF_ALL) return log_msg_ret("all", ret); @@ -386,11 +387,13 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) do { ret = iter_incr(iter); + log_debug("iter_incr: ret=%d\n", ret); if (ret == BF_NO_MORE_DEVICES) return log_msg_ret("done", ret); if (!ret) { ret = bootflow_check(iter, bflow); + log_debug("check - ret=%d\n", ret); if (!ret) return 0; iter->err = ret; @@ -399,6 +402,7 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) return log_msg_ret("all", ret); } } else { + log_debug("incr failed, err=%d\n", ret); iter->err = ret; } From patchwork Tue Jan 17 17:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727673 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BI78NfYw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGwP2KcPz23fT for ; Wed, 18 Jan 2023 05:03:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3F6B8573F; Tue, 17 Jan 2023 18:52:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="BI78NfYw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38AEA856D4; Tue, 17 Jan 2023 18:51:21 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 13BE2856BB for ; Tue, 17 Jan 2023 18:51:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id a3so9813003ilp.6 for ; Tue, 17 Jan 2023 09:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yRvytCiuyHdlJuFuQ9Xa1XfmV/W1yBJVBSLqvjkIgrs=; b=BI78NfYwFRDtgF17A6D+tWJwIwefAj7ffPX6wmrROu1zeaX88mGWWs1ggXdbJKrQ98 kZzAf+3kpgD+M75PxLhpaCP6Ac9d5i0Y3uGA0i9rYI0mzAqeCgWPEKYr7VPFst3IUHEj Osh2xAGa+cyCj7jOoVqh1y30wV7dZBjZOOtso= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yRvytCiuyHdlJuFuQ9Xa1XfmV/W1yBJVBSLqvjkIgrs=; b=Pifkdn28b94Tu6a+cy0O5lqWJNtkEqfkEpaoHtCu/5oQ/SAfMCmhtQTml0liJ/Wxon q+Sf13CvpevrEXoDygMQa5boAyvvJijnH3et5XBB+beqKteXy+C+HdAuHbBgfav8TCDt SLaFEub7mXKDzwCVjmZmtmkjwKDBu5HgSw2t/uNkYWCShZVZu8F6PyCRzpRn/THF7YAm LmDTdCse/8nCSd6L4Ds82Cva1qsIRoDvHY2naBzf+ipjORIztBWuv3uYFU58fZazo6o8 VoQNwhz+t9Fi3m7Ba4Dh7qlfnp6dZS6mVH/ROa8RGFa5OX+iEpS0c/mIMd3esUgqhet7 E63A== X-Gm-Message-State: AFqh2krQ0YyQqcaP8zCTd/7c8bfYeoBPB99oRBtImj5/e1N7reRl77Z2 exy5ZNVntAbiqWx1R54vAiolqtSjjuHttpXq X-Google-Smtp-Source: AMrXdXvvqghlJU88K/E5P99INOfnSbPN4ED1zikuKeBo4mNJMVOpsCZkFuwO/lzeKFcYN0YbJTJ6jQ== X-Received: by 2002:a05:6e02:1313:b0:30e:f03e:a765 with SMTP id g19-20020a056e02131300b0030ef03ea765mr3264764ilr.1.1673977805910; Tue, 17 Jan 2023 09:50:05 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:05 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH v3 69/70] bootstd: Update documentation for new features Date: Tue, 17 Jan 2023 10:48:19 -0700 Message-Id: <20230117174820.1281477-70-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Document the hunters and the new way that iteration works. Signed-off-by: Simon Glass --- (no changes since v1) doc/develop/bootstd.rst | 219 +++++++++++++++++++++--------- doc/develop/driver-model/nvme.rst | 2 +- doc/usage/cmd/bootdev.rst | 48 ++++++- doc/usage/cmd/bootflow.rst | 17 ++- 4 files changed, 216 insertions(+), 70 deletions(-) diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst index bfa8cbd7561..281aabf74b2 100644 --- a/doc/develop/bootstd.rst +++ b/doc/develop/bootstd.rst @@ -71,8 +71,14 @@ MMC, NVMe). The bootdev accesses the device, including partitions and filesystems that might contain things related to an operating system. For example, an MMC bootdev provides access to the individual partitions on the -MMC device. It scans through these to find filesystems, then provides a list of -these for consideration. +MMC device. It scans through these to find filesystems with the boot flag set, +then provides a list of these for consideration. + +Some bootdevs are not visible until a bus is enumerated, e.g. flash sticks +attached via USB. To deal with this, each bootdev has an associated 'hunter' +which can hunt for bootdevs of a particular uclass type. For example, the SCSI +bootdev scans the SCSI bus looking for devices, creating a bootdev for each +Logical Unit Number (LUN) that it finds. Bootmeth @@ -175,7 +181,10 @@ reading from, but each is responsible for returning a valid bootflow if available. A helper called `bootdev_find_in_blk()` makes it fairly easy to implement this -function for each media device uclass, in a few lines of code. +function for each media device uclass, in a few lines of code. For many types +ot bootdevs, the `get_bootflow` member can be NULL, indicating that the default +handler is used. This is called `default_get_bootflow()` and it only works with +block devices. Bootdev drivers @@ -183,30 +192,6 @@ Bootdev drivers A bootdev driver is typically fairly simple. Here is one for mmc:: - static int mmc_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, - struct bootflow *bflow) - { - struct udevice *mmc_dev = dev_get_parent(dev); - struct udevice *blk; - int ret; - - ret = mmc_get_blk(mmc_dev, &blk); - /* - * If there is no media, indicate that no more partitions should be - * checked - */ - if (ret == -EOPNOTSUPP) - ret = -ESHUTDOWN; - if (ret) - return log_msg_ret("blk", ret); - assert(blk); - ret = bootdev_find_in_blk(dev, blk, iter, bflow); - if (ret) - return log_msg_ret("find", ret); - - return 0; - } - static int mmc_bootdev_bind(struct udevice *dev) { struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); @@ -217,7 +202,6 @@ A bootdev driver is typically fairly simple. Here is one for mmc:: } struct bootdev_ops mmc_bootdev_ops = { - .get_bootflow = mmc_get_bootflow, }; static const struct udevice_id mmc_bootdev_ids[] = { @@ -233,15 +217,77 @@ A bootdev driver is typically fairly simple. Here is one for mmc:: .of_match = mmc_bootdev_ids, }; -The implementation of the `get_bootflow()` method is simply to obtain the -block device and call a bootdev helper function to do the rest. The +You may notice that the `get_bootflow` memory is not provided, so is NULL. This +means that `default_get_bootflow()` is used. This simply obtains the +block device and calls a bootdev helper function to do the rest. The implementation of `bootdev_find_in_blk()` checks the partition table, and attempts to read a file from a filesystem on the partition number given by the -`@iter->part` parameter. +`@iter->part` parameter. If there are any bootable partitions in the table, +then only bootable partitions are considered. + +Each bootdev has a priority, which indicates the order in which it is used, +if `boot_targets` is not used. Faster bootdevs are used first, since they are +more likely to be able to boot the device quickly. + + +Environment Variables +--------------------- + +Various environment variables are used by standard boot. These allow the board +to control where things are placed when booting the OS. You should ensure that +your boards sets values for these. + +fdtfile + Name of the flattened device tree (FDT) file to load, e.g. + "rockchip/rk3399-rockpro64.dtb" + +fdtaddr_addr_r + Address at which to load the FDT, e.g. 0x01f00000 + +fdtoverlay_addr_r (needed if overlays are used) + Address at which to load the overlay for the FDT, e.g. 0x02000000 + +kernel_addr_r + Address at which to load the kernel, e.g. 0x02080000 + +kernel_comp_addr_r + Address to which to decompress the kernel, e.g. 0x08000000 + +kernel_comp_size + Size of available space for decompressed kernel, e.g. 0x2000000 + +pxefile_addr_r + Address at which to load the PXE file, e.g. 0x00600000 + +ramdisk_addr_r + Address at which to load the ramdisk, e.g. 0x06000000 + +scriptaddr + Address at which to load the U-Boot script, e.g. 0x00500000 + +script_offset_f + SPI flash offset from which to load the U-Boot script, e.g. 0xffe000 -Each bootdev has a priority, which indicates the order in which it is used. -Faster bootdevs are used first, since they are more likely to be able to boot -the device quickly. +script_size_f + Size of the script to load, e.g. 0x2000 + +Some variables are set by script bootmeth: + +devtype + Device type being used for boot, e.g. mmc + +devnum + Device number being used for boot, e.g. 1 + +distro_bootpart + Partition being used for boot, e.g. 2 + +prefix + Directory containing the script + +mmc_bootdev + Device number being used for boot (e.g. 1). This is only used by MMC on + sunxi boards. Device hierarchy @@ -259,13 +305,22 @@ media device:: bootdev 1 [ ] mmc_bootdev | | `-- sdhci@7e300000.bootdev The bootdev device is typically created automatically in the media uclass' -`post_bind()` method by calling `bootdev_setup_for_dev()`. The code typically -something like this:: +`post_bind()` method by calling `bootdev_setup_for_dev()` or +`bootdev_setup_sibling_blk()`. The code typically something like this:: + /* dev is the Ethernet device */ ret = bootdev_setup_for_dev(dev, "eth_bootdev"); if (ret) return log_msg_ret("bootdev", ret); +or:: + + /* blk is the block device (child of MMC device) + ret = bootdev_setup_sibling_blk(blk, "mmc_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); + + Here, `eth_bootdev` is the name of the Ethernet bootdev driver and `dev` is the ethernet device. This function is safe to call even if standard boot is not enabled, since it does nothing in that case. It can be added to all uclasses @@ -337,6 +392,10 @@ Standard boot is enabled with `CONFIG_BOOTSTD`. Each bootmeth has its own CONFIG option also. For example, `CONFIG_BOOTMETH_DISTRO` enables support for distro boot from a disk. +To enable all feature sof standard boot, use `CONFIG_BOOTSTD_FULL`. This +includes the full set of commands, more error messages when things go wrong and +bootmeth ordering with the bootmeths environment variable. + Available bootmeth drivers -------------------------- @@ -345,7 +404,8 @@ Bootmeth drivers are provided for: - distro boot from a disk (syslinux) - distro boot from a network (PXE) - - EFI boot using bootefi + - U-Boot scripts from disk, network or SPI flash + - EFI boot using bootefi from disk - VBE - EFI boot using boot manager @@ -412,26 +472,49 @@ those bootdevs. So, all up, we need a single bootstd device, one or more bootdev devices and one or more bootmeth devices. Once these are ready, typically a `bootflow scan` command is issued. This kicks -of the iteration process, which involves looking through the bootdevs and their -partitions one by one to find bootflows. +of the iteration process, which involves hunting for bootdevs and looking +through the bootdevs and their partitions one by one to find bootflows. -Iteration is kicked off using `bootflow_scan_first()`, which calls -`bootflow_scan_bootdev()`. +Iteration is kicked off using `bootflow_scan_first()`. The iterator is set up with `bootflow_iter_init()`. This simply creates an empty one with the given flags. Flags are used to control whether each iteration is displayed, whether to return iterations even if they did not result in a valid bootflow, whether to iterate through just a single bootdev, etc. -Then the ordering of bootdevs is determined, by `bootdev_setup_iter_order()`. By -default, the bootdevs are used in the order specified by the `boot_targets` -environment variable (e.g. "mmc2 mmc0 usb"). If that is missing then their -sequence order is used, as determined by the `/aliases` node, or failing that -their order in the devicetree. For BOOTSTD_FULL, if there is a `bootdev-order` -property in the bootstd node, then this is used as a final fallback. In any -case, the iterator ends up with a `dev_order` array containing the bootdevs that -are going to be used, with `num_devs` set to the number of bootdevs and -`cur_dev` starting at 0. +Then the iterator is set up to according to the parameters given: + +- When `dev` is provided, then a single bootdev is scanned. In this case, + `BOOTFLOWF_SKIP_GLOBAL` and `BOOTFLOWF_SINGLE_DEV` are set. No hunters are + used in this case + +- Otherwise, when `label` is provided, then a single label or named bootdev is + scanned. In this case `BOOTFLOWF_SKIP_GLOBAL` is set and there are three + options (with an effect on the `iter_incr()` function described later): + + - If `label` indicates a numeric bootdev number (e.g. "2") then + `BOOTFLOW_METHF_SINGLE_DEV` is set. In this case, moving to the next bootdev + simple stops, since there is only one. No hunters are used. + - If `label` indicates a particular media device (e.g. "mmc1") then + `BOOTFLOWF_SINGLE_MEDIA` is set. In this case, moving to the next bootdev + processes just the children of the media device. Hunters are used, in this + example just the "mmc" hunter. + - If `label` indicates a media uclass (e.g. "mmc") then + `BOOTFLOWF_SINGLE_UCLASS` is set. In this case, all bootdevs in that uclass + are used. Hunters are used, in this example just the "mmc" hunter + +- Otherwise, none of the above flags is set and iteration is set up to work + through `boot_targets` environment variable (or `bootdev-order` device tree + property) in order, running the relevant hunter first. In this case + `cur_label` is used to indicate the label being processed. If there is no list + of labels, then all bootdevs are processed in order of priority, running the + hunters as it goes. + +With the above it is therefore possible to iterate in a variety of ways. + +No attempt is made to determine the ordering of bootdevs, since this cannot be +known in advance if we are using the hunters. Any hunter might discover a new +bootdev and disturb the original ordering. Next, the ordering of bootmeths is determined, by `bootmeth_setup_iter_order()`. By default the ordering is again by sequence number, i.e. the `/aliases` node, @@ -446,21 +529,21 @@ present, `cur_method` is set to the first one, so that global bootmeths are done first. Once all have been used, these bootmeths are dropped from the iteration. When there are no global bootmeths, `cur_method` is set to 0. -At this point the iterator is ready to use, with the first bootdev and bootmeth -selected. Most of the other fields are 0. This means that the current partition +At this point the iterator is ready to use, with the first bootmeth selected. +Most of the other fields are 0. This means that the current partition is 0, which is taken to mean the whole device, since partition numbers start at 1. It also means that `max_part` is 0, i.e. the maximum partition number we know about is 0, meaning that, as far as we know, there is no partition table on this bootdev. -With the iterator ready, `bootflow_scan_bootdev()` checks whether the current +With the iterator ready, `bootflow_scan_first()` checks whether the current settings produce a valid bootflow. This is handled by `bootflow_check()`, which either returns 0 (if it got something) or an error if not (more on that later). If the `BOOTFLOWF_ALL` iterator flag is set, even errors are returned as incomplete bootflows, but normally an error results in moving onto the next iteration. -Note that `bootflow_check()` handles global bootmeths explicitly, but calling +Note that `bootflow_check()` handles global bootmeths explicitly, by calling `bootmeth_get_bootflow()` on each one. The `doing_global` flag indicates when the iterator is in that state. @@ -468,7 +551,7 @@ The `bootflow_scan_next()` function handles moving onto the next iteration and checking it. In fact it sits in a loop doing that repeatedly until it finds something it wants to return. -The actual 'moving on' part is implemented in `iter_incr()`. This is a very +The actual 'moving on' part is implemented in `iter_incr()`. This is a fairly simple function. It increments the first counter. If that hits its maximum, it sets it to zero and increments the second counter. You can think of all the counters together as a number with three digits which increment in order, with @@ -522,6 +605,12 @@ like this: The changeover of the value of `doing_global` from true to false is handled in `iter_incr()` as well. +Note that the value in the `bootdev` column above is not actually stored - it is +just for illustration. In practice, `iter_incr()` uses the flags to determine +whether to move to the next bootdev in the uclass, the next child of the media +device, the next label, or the next priority level, depending on the flag +settings (see `BOOTFLOW_METHF_SINGLE_DEV`, etc. above). + There is no expectation that iteration will actually finish. Quite often a valid bootflow is found early on. With `bootflow scan -b`, that causes the bootflow to be immediately booted. Assuming it is successful, the iteration never @@ -567,9 +656,9 @@ global bootmeth). Each one can adopt its own approach. Going down a level, what does the bootdev do in its `get_bootflow()` method? Let us consider the MMC bootdev. In that case the call to -`bootdev_get_bootflow()` ends up in `mmc_get_bootflow()`. It locates the parent -device of the bootdev, i.e. the `UCLASS_MMC` device itself, then finds the block -device associated with it. It then calls the helper function +`bootdev_get_bootflow()` ends up in `default_get_bootflow()`. It locates the +parent device of the bootdev, i.e. the `UCLASS_MMC` device itself, then finds +the block device associated with it. It then calls the helper function `bootdev_find_in_blk()` to do all the work. This is common with just about any bootdev that is based on a media device. @@ -586,7 +675,9 @@ calls the bootmeth device once more, this time to read the bootflow. Note: At present a filesystem is needed for the bootmeth to be called on block devices, simply because we don't have any examples where this is not the case. -This feature can be added as needed. +This feature can be added as needed. Note that sandbox is a special case, since +in that case the host filesystem can be accessed even though the block device +is NULL. If we take the example of the `bootmeth_distro` driver, this call ends up at `distro_read_bootflow()`. It has the filesystem ready, so tries various @@ -594,9 +685,9 @@ filenames to try to find the `extlinux.conf` file, reading it if possible. If all goes well the bootflow ends up in the `BOOTFLOWST_READY` state. At this point, we fall back from the bootmeth driver, to -`bootdev_find_in_blk()`, then back to `mmc_get_bootflow()`, then to +`bootdev_find_in_blk()`, then back to `default_get_bootflow()`, then to `bootdev_get_bootflow()`, then to `bootflow_check()` and finally to its caller, -either `bootflow_scan_bootdev()` or `bootflow_scan_next()`. In either case, +either `bootflow_scan_first()` or `bootflow_scan_next()`. In either case, the bootflow is returned as the result of this iteration, assuming it made it to the `BOOTFLOWST_READY` state. @@ -625,9 +716,9 @@ Tests are located in `test/boot` and cover the core functionality as well as the commands. All tests use sandbox so can be run on a standard Linux computer and in U-Boot's CI. -For testing, a DOS-formatted disk image is used with a single FAT partition on -it. This is created in `setup_bootflow_image()`, with a canned one from the -source tree used if it cannot be created (e.g. in CI). +For testing, a DOS-formatted disk image is used with a FAT partition on it and +a second unused partition. This is created in `setup_bootflow_image()`, with a +canned one from the source tree used if it cannot be created (e.g. in CI). Bootflow internals diff --git a/doc/develop/driver-model/nvme.rst b/doc/develop/driver-model/nvme.rst index fd0c0f00d2d..75518133121 100644 --- a/doc/develop/driver-model/nvme.rst +++ b/doc/develop/driver-model/nvme.rst @@ -27,7 +27,7 @@ How it works ------------ There is an NVMe uclass driver (driver name "nvme"), an NVMe host controller driver (driver name "nvme") and an NVMe namespace block driver (driver name -"nvme-blk"). The host controller driver is supposed to probe the hardware and +"nvme_blk"). The host controller driver is supposed to probe the hardware and do necessary initialization to put the controller into a ready state at which it is able to scan all available namespaces attached to it. Scanning namespace is triggered by the NVMe uclass driver and the actual work is done in the NVMe diff --git a/doc/usage/cmd/bootdev.rst b/doc/usage/cmd/bootdev.rst index 5e02e32c514..6c68d0bf840 100644 --- a/doc/usage/cmd/bootdev.rst +++ b/doc/usage/cmd/bootdev.rst @@ -8,9 +8,10 @@ Synopis :: - bootdev list [-p] - list all available bootdevs (-p to probe)\n" - bootdev select - select a bootdev by name\n" - bootdev info [-p] - show information about a bootdev"; + bootdev list [-p] - list all available bootdevs (-p to probe) + bootdev hunt [-l|] - use hunt drivers to find bootdevs + bootdev select - select a bootdev by name + bootdev info [-p] - show information about a bootdev Description ----------- @@ -63,6 +64,17 @@ Name: with `.bootdev` +bootdev hunt +~~~~~~~~~~~~ + +This hunts for new bootdevs, or shows a list of hunters. + +Use `-l` to list the available bootdev hunters. + +To run hunters, specify the name of the hunter to run, e.g. "mmc". If no +name is provided, all hunters are run. + + bootdev select ~~~~~~~~~~~~~~~~~ @@ -83,7 +95,7 @@ This shows information on the current bootdev, with the format looking like this: ========= ======================= -Name mmc@7e202000.bootdev +Name `mmc@7e202000.bootdev` Sequence 0 Status Probed Uclass mmc @@ -128,6 +140,34 @@ one of them:: Uclass: mmc Bootflows: 1 (1 valid) +This shows using one of the available hunters, then listing them:: + + => bootdev hunt usb + Hunting with: usb + Bus usb@1: scanning bus usb@1 for devices... + 3 USB Device(s) found + => bootdev hunt -l + Prio Used Uclass Hunter + ---- ---- --------------- --------------- + 6 ethernet eth_bootdev + 1 simple_bus (none) + 5 ide ide_bootdev + 2 mmc mmc_bootdev + 4 nvme nvme_bootdev + 4 scsi scsi_bootdev + 4 spi_flash sf_bootdev + 5 * usb usb_bootdev + 4 virtio virtio_bootdev + (total hunters: 9) + => usb stor + Device 0: Vendor: sandbox Rev: 1.0 Prod: flash + Type: Hard Disk + Capacity: 4.0 MB = 0.0 GB (8192 x 512) + Device 1: Vendor: sandbox Rev: 1.0 Prod: flash + Type: Hard Disk + Capacity: 0.0 MB = 0.0 GB (1 x 512) + => + Return value ------------ diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst index aa12dc2e3ab..cad09bbec9a 100644 --- a/doc/usage/cmd/bootflow.rst +++ b/doc/usage/cmd/bootflow.rst @@ -8,7 +8,7 @@ Synopis :: - bootflow scan [-abel] [bootdev] + bootflow scan [-abelGH] [bootdev] bootflow list [-e] bootflow select [] bootflow info [-d] @@ -57,6 +57,16 @@ Flags are: is happening during scanning. Use it with the `-b` flag to see which bootdev and bootflows are being tried. +-G + Skip global bootmeths when scanning. By default these are tried first, but + this flag disables them. + +-H + Don't use bootdev hunters. By default these are used before each boot + priority or label is tried, to see if more bootdevs can be discovered, but + this flag disables that process. + + The optional argument specifies a particular bootdev to scan. This can either be the name of a bootdev or its sequence number (both shown with `bootdev list`). Alternatively a convenience label can be used, like `mmc0`, which is the type of @@ -145,6 +155,7 @@ Subdir (none) Filename /extlinux/extlinux.conf Buffer 3db7ad48 Size 232 (562 bytes) +FDT: Error 0 ========= =============================== @@ -169,6 +180,10 @@ Buffer Size Size of the bootflow file +FDT: + Filename of the device tree, if supported. The EFI bootmeth uses this to + remember the filename to load. If `` then there is none. + Error Error number returned from scanning for the bootflow. This is 0 if the bootflow is in the 'loaded' state, or a negative error value on error. You From patchwork Tue Jan 17 17:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1727671 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FdPRpi6d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxGvw1RBXz23fT for ; Wed, 18 Jan 2023 05:03:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 11C9685731; Tue, 17 Jan 2023 18:52:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="FdPRpi6d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB5F9855BA; Tue, 17 Jan 2023 18:51:19 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 13A6C856BA for ; Tue, 17 Jan 2023 18:51:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd31.google.com with SMTP id q130so2273442iod.4 for ; Tue, 17 Jan 2023 09:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jl7uZ4GgpHw50R3iik6ZLSGxi7DqfrNhfaI/qh9KPYk=; b=FdPRpi6dC+tVuwn5/3fZztXYtsTKsqzyz/GIy+3qq8rPNZe0VEpdyJo7GCjV+Fsw+b +m0tJmSrUZtV4mecxb9RCo4WL3QvhcNxAAUkTckd2Aro/W3Vms6yhhip7vfQgyYGNpVS /wnCA3nJCzL/9G3EK5z48mPxVYXdrsKx9HBzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jl7uZ4GgpHw50R3iik6ZLSGxi7DqfrNhfaI/qh9KPYk=; b=apJtfSTM5dh8Houy1Q/D28exaicIYQUJr7kzIssxvPo10ydOW77hYS7KhicRxlXgQu L2nj28bfgbS9RvtNgM2KTKQofJ71rsq4q/c1paXgxcpMkOnN5AT0fWWGujUT5KwQMI3D JiMBuPQOuRHGgnG1omNDwGAiHG63Nic6ViRokDiaMwl3yLI59A9kdLLvGTjTZOJJoiNs qrDRYB+0gmOjnIOkBRXl9rOvR76sJqAGMHYo6XnLIld/5JuR4YqkFaPo7dKSYMDFIJcZ vRkvD7W4CLFfkYjwd0qGSvo9/YSchZNUhwgj+KpoVSNz7dGAAykLjwkgC1SvBo9Un53t pSeA== X-Gm-Message-State: AFqh2kqfiz1sJj7Ts4rRLVUmPYUt89zTUlQVnDThX5IgSy4jR15ALzlK 9hfGfPs9X0LwqozjC/3s+xYeNtRO4Yjhz0UE X-Google-Smtp-Source: AMrXdXvGghQHwp/kX2Bix34TQyNQW/TTcXIitqjpQZ5ZILZ+4sxbxmFn/2dconSFgxfYUUan9fgaow== X-Received: by 2002:a5d:8502:0:b0:6bc:d71a:570e with SMTP id q2-20020a5d8502000000b006bcd71a570emr2735580ion.16.1673977806883; Tue, 17 Jan 2023 09:50:06 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:28d1:224:8617:3704]) by smtp.gmail.com with ESMTPSA id c32-20020a023f60000000b0038a01eba60fsm9631668jaf.69.2023.01.17.09.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:50:06 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Cc: Simon Glass , Kever Yang , Philipp Tomsich Subject: [PATCH v3 70/70] rockchip: Convert rockpro64-rk3399 to use standard boot Date: Tue, 17 Jan 2023 10:48:20 -0700 Message-Id: <20230117174820.1281477-71-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230117174820.1281477-1-sjg@chromium.org> References: <20230117174820.1281477-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean Drop the use of scripts and rely on standard boot for all operation. Signed-off-by: Simon Glass Reviewed-by: Kever Yang --- Changes in v3: - Rebase to -master Changes in v2: - Rebase to -next include/configs/rk3399_common.h | 5 +---- include/configs/rockchip-common.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 95cb27c8951..3ef9ffa2e9c 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -48,15 +48,12 @@ #define ROCKCHIP_DEVICE_SETTINGS #endif -#include -#include #define CFG_EXTRA_ENV_SETTINGS \ ENV_MEM_LAYOUT_SETTINGS \ "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \ "partitions=" PARTS_DEFAULT \ ROCKCHIP_DEVICE_SETTINGS \ - BOOTENV \ - BOOTENV_SF \ + "boot_targets=" BOOT_TARGETS "\0" \ "altbootcmd=" \ "setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \ "run distro_bootcmd\0" diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h index 1f6b82f2d02..0b23e4c0433 100644 --- a/include/configs/rockchip-common.h +++ b/include/configs/rockchip-common.h @@ -65,12 +65,14 @@ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func) \ BOOT_TARGET_SF(func) +#define BOOT_TARGETS "mmc1 mmc0 nvme scsi usb pxe dhcp spi" #else #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func) +#define BOOT_TARGETS "mmc1 mmc0 usb pxe dhcp" #endif #ifdef CONFIG_ARM64