From patchwork Wed Dec 7 08:50:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713067 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=W5lx429V; 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 4NRrgF2xyJz23ns for ; Wed, 7 Dec 2022 19:54:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E786183E57; Wed, 7 Dec 2022 09:53: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="W5lx429V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B18CC85442; Wed, 7 Dec 2022 09:53: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 0A17D853FE for ; Wed, 7 Dec 2022 09:53:50 +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-pl1-x62d.google.com with SMTP id m4so9488879pls.4 for ; Wed, 07 Dec 2022 00:53: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=SFqnPhoaR3CNzpBPXgN6RnZJr1+jXct58Z+Rf4b9o58=; b=W5lx429VUVcggpcbPowcJ+yfICK7vjPLVW0wlwN+bOLTzQrOYh1oabsqwxCwdBFypj hfDJt1LIa8pRvFHPpSPvE0UO3PHA0huNksJH6Lr+WAMRcsqw6aFxPzfvDqjlW0vPyZvC EbrSzau9ZGWkkawzqniVqI7pY+j0Mio8WotL0= 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=SFqnPhoaR3CNzpBPXgN6RnZJr1+jXct58Z+Rf4b9o58=; b=qyce4DJdQBX69/hM9rmGWnWmbk4Uxm8KD44y4mgNk6glT7hZIFLmNU5hGDHHf0OpIo ThIeilLWDa21H84O72NNKZVL3Jb1CuccjACWXZA6Sk6tfbPon16i1Xw2sKBlKaxKGobi na9JNXjRyKAIZs8uZctD+InXBbZL9jibRz8nxcNNkip+8bv1HwihSsQ7tUSxV+8gRbLI bX7jt5LjdtOdZpw0Jx98Y7vDimY2Z1+27vdmbeCqAt+OQ9yNZNLlJig+wYav7GApm67L UwFPdD9Am3g8mDI/JO9QSytbFG01WGGNSVzTVltv55sMP/yBrcYxDld3w9aj3MRqPdhW wn8g== X-Gm-Message-State: ANoB5pkAKthxKEzJmtMRN0K5ZU/h841XqtYwdzm/JVKq6Gqp9paxvumW j6Q3eglHkLkSFSU0N145HZzoktfopE91iZMk X-Google-Smtp-Source: AA0mqf4GtlbjpJppjR7agt3D8Tn3pp8i5NsO8o5G5CnOC3LdJ7PYRSOpT1E5of3eB/5A2gtK9Tvn3g== X-Received: by 2002:a17:902:d711:b0:188:c7b2:2dd with SMTP id w17-20020a170902d71100b00188c7b202ddmr74774852ply.88.1670403228029; Wed, 07 Dec 2022 00:53:48 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:53:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 01/71] dm: core: Correct ordering of uclasses IDs Date: Wed, 7 Dec 2022 21:50:27 +1300 Message-Id: <20221207085137.445249-2-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713069 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=iC14gG2c; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRrgY0TWXz23ns for ; Wed, 7 Dec 2022 19:54:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0DCCB82F6A; Wed, 7 Dec 2022 09:54: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="iC14gG2c"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0854985106; Wed, 7 Dec 2022 09:53: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 BDC8E853FB for ; Wed, 7 Dec 2022 09:53: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-pj1-x1035.google.com with SMTP id cm20so16958831pjb.1 for ; Wed, 07 Dec 2022 00:53: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=1kqvumD46ZbjLhLPBj58POg2j2KOH1KOdCoX+guGTR4=; b=iC14gG2cOmNlEUHWPC768OTnvYplg9ytn3yZk+JFwSOUeo8oNBU/vZKQ/mvL7pbUaX +kDheCf+jnXv+1pF4BWsAXpGWbhhL4S4+y4m+hBoMw8cBivGQanHWv/5G+f3tCgZNLVf I6EJ4Sk3JQ5DF/ssxEEvOq8eFuvWjEspwFYog= 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=1kqvumD46ZbjLhLPBj58POg2j2KOH1KOdCoX+guGTR4=; b=lidUiVn+Zs6tCjwSN8kpfCJ+hZfqluoirm+jmaDwHwKx4z4R8zqRTyfvEv5trGa9bP 6g3RVWpSzfKxVcH97yz+Qh3OXAfkbc0d93oayXhV8/AUEagkCfyqYEBa8YHlvH2sSlYR LZLPJMpuY8tVJZsDHotvsPBKfJe0qIxtZNJwjDhuQSCO1Knwhyy9YtV04kJQy/uIf/tS HP+qofgD/PA3rRkI9WxTbzeYdiU5bv6TBzzCH3SzC9PuhW6H7N8d3dxo4xNWe5rTGaOW 4fzackGgYL10d3S2l/WTwpmZ5zwwFATcLq2MxdZm4RSNMiia1kqi4eksxhRMc258odYP Mf6w== X-Gm-Message-State: ANoB5plVWfZhTMF3xudN2+OxePquwoo50mJc1pmcXx9a6xW4vlTxjmfB kwF3LxH1V1t894CNsWitE4o/ehfE3+Z1mBWL X-Google-Smtp-Source: AA0mqf5qHUMUgFM0XUPRyh4Q8FD5dNUroBxLJyjIl1NYKlU8AgCuz3WYHRtuDFJ440/ASV7c4jf6yg== X-Received: by 2002:a17:90a:a88e:b0:213:13ab:c309 with SMTP id h14-20020a17090aa88e00b0021313abc309mr97483454pjq.80.1670403232745; Wed, 07 Dec 2022 00:53:52 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:53:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Michal Simek , Ovidiu Panait , Pavel Herrmann , Sergei Antonov Subject: [PATCH 02/71] dm: core: Support sorting devices with dm tree Date: Wed, 7 Dec 2022 21:50:28 +1300 Message-Id: <20221207085137.445249-3-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713070 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=kG1MSRQg; 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 4NRrgq4Scdz23ns for ; Wed, 7 Dec 2022 19:54:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4D0A85431; Wed, 7 Dec 2022 09:54: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=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="kG1MSRQg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6674E84EA1; Wed, 7 Dec 2022 09:54:01 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 1F5C385161 for ; Wed, 7 Dec 2022 09:53: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=sjg@chromium.org Received: by mail-pj1-x1032.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so826458pje.5 for ; Wed, 07 Dec 2022 00:53:58 -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=eZ3tErvXiVeiSPiye429rzGPINDBdPT1Y6xSqnQXPzw=; b=kG1MSRQgvhIkAXyHobeD7g7YHaMpqyJpbR8vFdOpo9QeWFhTICJbubG65mzm65ejDM bAzIQlDc9MLiss5GZ7R2RKIoPKTCizyVrpZwRxS96+j2ZhjQFQCrxgHjLG12Nhh1PjFk nN8nk7j3ltFskYfdF8/+Le85GwDgEP6BIKkJ0= 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=eZ3tErvXiVeiSPiye429rzGPINDBdPT1Y6xSqnQXPzw=; b=NnZqY70WhCPfGKFU0FBO+hWM2/MiY/0Cv6ZYOW+o/kOQxXoK2JIsKnc4S9oRYogtrV 7axXE1IEOG0po3FFIz+8Cjuxar35uzZMjco03WWfdAS4/f0hVmHibzdCjxcEEr34OMwU b9bvIli8hc36qpNQudxKRCIc9sIIXdFy1xij8lx1D7ph6CUAHybySlM05RxwBavaG/lL B5yWVCF7gRv22j+9nSOLxsGYYMW6mIsy/PiweZ9otCBx8tboQlzieLlg3hAfs2lmbnJg FnuPiO24m3aMxmMlLsbQ4YLoECqJhCEDMooopnqfk32FOu+tm5aJlFg3yX43epX02uiQ Esjw== X-Gm-Message-State: ANoB5plUir0G1C5m4YgDkDm31H1f7yirapnPT90Y97O85iXIJQmylQfq J7u8knqQzp97TROigBEM5V0wK8CvgtRjaRMZ X-Google-Smtp-Source: AA0mqf5kATosQVtNQQ49EhmkVn174RUcHKKLogNLuRrH+/nx+BPnbk6tTrwZ/jAWVqhubAMobfC1pA== X-Received: by 2002:a17:902:7482:b0:189:855c:eb56 with SMTP id h2-20020a170902748200b00189855ceb56mr44261108pll.54.1670403236261; Wed, 07 Dec 2022 00:53:56 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:53:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 03/71] dm: test: Correct assertion in dm_test_part() Date: Wed, 7 Dec 2022 21:50:29 +1300 Message-Id: <20221207085137.445249-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713071 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=PTnFjMCi; 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 4NRrh61X9gz23ns for ; Wed, 7 Dec 2022 19:54:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 184548555E; Wed, 7 Dec 2022 09:54: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="PTnFjMCi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA11085527; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 DB87485161 for ; Wed, 7 Dec 2022 09:54: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-pf1-x42a.google.com with SMTP id g1so8912150pfk.2 for ; Wed, 07 Dec 2022 00:54: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=hlIj52Im9ObWBi5o47IvRY+RmbQnLKBxhV9BNh4tfgg=; b=PTnFjMCiv5Qbc8wFsb6liHqznwOM7uWb+yWx4O/78YuT89CS2QnhjAcbN5aeYOT41S DuEkv8SeerLIkSu/kXLPkYiRF2500ncJn7of09EQ7+A6y3nUrrj1Jj7B96cBa4YHpueo +017AM+nXHoPR27Jl8WtDPGTiQxjUI4tgBrtA= 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=hlIj52Im9ObWBi5o47IvRY+RmbQnLKBxhV9BNh4tfgg=; b=vtpYJ9XyOjTjFw//EPMC5N3gkaJXkb+YmhzojPVxd1GqTOw8iwxDH7NGJ58+hGy3I8 Z2lOZPy9ixGcvjMPw7wurdKob44C660LxD+ax5naNCk52r+xKAOoaYPwxTKezqFYT3PT UyK7rud3E8coHh3X5PYil4WgqIHFLIdWHagRGhPmIOKhCw6zxQbaSnKPWywj+tYdAX9s y0ZVS8MU/DtFi2JeV725nXcgAA415uc0uAiBb6mgLejTjMnEfwRIFvih8exRlMALfW4Y cYo53Cb2sil1aF/rPoLUO4IqiEUQrj6Bo8/1Slr0t+AGfvj6gQXBYB6f0AO3gAnC7wbQ QM6g== X-Gm-Message-State: ANoB5pm1o+9mKDDkmacu094PSOXdTCMOkYWlgn7SNRIpmxwnvZbCb2eq UdLhpymKzc0Mmo8E281txzTULZ3Bb9h0M06f X-Google-Smtp-Source: AA0mqf4P7TlfVzGAffP7FMVpdxgUS3M7OFsgjvwaPQkmvg7zBIE32kqQEAlyRQv03+yR6O/JfZC+vw== X-Received: by 2002:a63:fd01:0:b0:478:c026:d059 with SMTP id d1-20020a63fd01000000b00478c026d059mr11468129pgh.447.1670403239837; Wed, 07 Dec 2022 00:53:59 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:53:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Samuel Dionne-Riel Subject: [PATCH 04/71] lib: Add a function to split a string into substrings Date: Wed, 7 Dec 2022 21:50:30 +1300 Message-Id: <20221207085137.445249-5-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713073 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=MI8eTrjb; 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 4NRrhN0r0Pz23ns for ; Wed, 7 Dec 2022 19:55:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F9DC85582; Wed, 7 Dec 2022 09:54: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=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="MI8eTrjb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FB088557A; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 D746485467 for ; Wed, 7 Dec 2022 09:54: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-pf1-x431.google.com with SMTP id 140so16953012pfz.6 for ; Wed, 07 Dec 2022 00:54: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=gdnqDcNn9bQSsob8nBsBGor/5oARsf2NMaFOdGRCUa8=; b=MI8eTrjbujYTissEcf9l4WRhdz3YW+8NbTyYCrZ2koZVYaEM+ZXLZMO/zgMEsGi9by IN2R35eQ61ZWvHt45JSHfuqF0D3dIXdAIrzG7rOhXq9WiK8qa7Atna8pDVFdkMmBWXbJ Qm5ip6CgrgDWEFsl5vepSOE34oH1xfM3CBdKI= 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=gdnqDcNn9bQSsob8nBsBGor/5oARsf2NMaFOdGRCUa8=; b=36z2asV/w7Cv62LB7A1407+Gt14WRSE7doSJlweNtaCI/g8raDwZz4CqJgIMYAdKW7 foc+QyxO3UbOtCBNOjarz+ModnGJf2Lo9olVXhx8u7pdFSBcKOlBDUab2d7aJzltjI+i q7jiXMMzRmh0sIhbmGHyOzqBYDfIjNF7NmnZhx/J7Tkot0s6Jnz32DahSuVs1w+ZNVpU jjO26UFMMXuEtw9P4bzyKvDsmACChyoEoPzPwRLNE/ykzBjxdluiefvtr5dCaOD3efi+ vx1tDXsUUFZ10qa+ycaFW3Zk7APLRmuuX757Hn4+AjzNqKwH4aaJZgdf/4hewha9+AM2 xfJA== X-Gm-Message-State: ANoB5plNFZxp3Yo/284hvIWS5fVZdeaSqcGP5fm6ujip6petj7g9gMrn AP0nbxZAcdelQeVBSpqvI4NoUEUuCL8qdtxF X-Google-Smtp-Source: AA0mqf51ARbx4VIXsn0Ks1r8g9xUTHDRqnI5m4sRNSBQk/m6thv6WGY9qyn254LFKF3A3mRTmt7oyg== X-Received: by 2002:a62:648a:0:b0:572:76dd:3756 with SMTP id y132-20020a62648a000000b0057276dd3756mr74178529pfb.9.1670403242747; Wed, 07 Dec 2022 00:54:02 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 05/71] bootstd: Remove special-case code for boot_targets Date: Wed, 7 Dec 2022 21:50:31 +1300 Message-Id: <20221207085137.445249-6-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 565c22a36e7..8b44edc42a8 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -70,9 +71,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 01be249d16e..a826bd5f247 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -20,7 +20,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 @@ -31,6 +34,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; @@ -47,9 +51,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 Wed Dec 7 08:50:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713076 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=iNeKiV/O; 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 4NRrhg0hWmz23yq for ; Wed, 7 Dec 2022 19:55:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EEDEF85442; Wed, 7 Dec 2022 09:54: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="iNeKiV/O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 967E485442; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 963F58556A for ; Wed, 7 Dec 2022 09:54: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=sjg@chromium.org Received: by mail-pg1-x52e.google.com with SMTP id v3so15690166pgh.4 for ; Wed, 07 Dec 2022 00:54: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=o5VFG3nkPILUiX0sGrQFCPBzVuOQ44EsqKz12Eyzhj4=; b=iNeKiV/OyAUdYZqZZjiNrLk5sOpReXtqHVtvcm/Qlfg31D/hLTsHgixHWKhJslOPNM VZUOT9FOlx/1SDz5NxEcQtx5/LZxUe3HYrpBqnWB8/E4Dm0w/gcVS3jbuiq57FR7TnvS fyTSIkjDSp1eS1HJIINhFqGYxo4qOzDjwzVuI= 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=o5VFG3nkPILUiX0sGrQFCPBzVuOQ44EsqKz12Eyzhj4=; b=TwBWLU7tGAhKFTr6FV0jwF5YFkz2iurLLJlz51kX8qkM3Gtlt+EVTaGpX0GOtcZvfp if4XlZv2rVjBXAfDgTXw7iCR5iVsJ4yBY5xnwAraPqTWQ7P9ennVnlzzdp7AQAzunzbr yfGcK5mDKUs2kGv9tmhPNw+fdQTuspK9v4I/Z5gRTaFcMSTx1D3Ycvp74xYdIzJIu4fe C0yBTT9lPqx0WQIOraD1Zx7mAct4uy1Q1mgXeY/1Uvg538ZPlSE7KfnGQABjAaSF/kLd 2J/xk0V/IfIezf52xMfZon0ZbLbaqwWDxVakAMKqeUun0MHBiaLxEhXLMqNdrf6/+juw 6p8g== X-Gm-Message-State: ANoB5pnqJmnI8l5YzV90JwIqGouI5M+3CKkdrhJDftL7qgwMi7BBy0hy mUdWk2zA9PbsYgR0tK3ESp6f5H0m6dbBiIa6 X-Google-Smtp-Source: AA0mqf7GyEAa230DqO/7Fx/F9efqjhPaprh6ERNfuT0acsT+bTeeU8p+hEyAxYUeTBY+flnkvovy1g== X-Received: by 2002:aa7:9911:0:b0:576:796e:8128 with SMTP id z17-20020aa79911000000b00576796e8128mr22115583pff.68.1670403245683; Wed, 07 Dec 2022 00:54:05 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 06/71] bootstd: Simplify locating existing bootdevs Date: Wed, 7 Dec 2022 21:50:32 +1300 Message-Id: <20221207085137.445249-7-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713077 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=Yx+41wd2; 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 4NRrhw42YMz23yq for ; Wed, 7 Dec 2022 19:55:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C799285580; Wed, 7 Dec 2022 09:54: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="Yx+41wd2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDD4185161; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 4BA39843A1 for ; Wed, 7 Dec 2022 09:54: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-pj1-x102e.google.com with SMTP id o12so16933599pjo.4 for ; Wed, 07 Dec 2022 00:54: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=YZ6QeaHWeolJHJEbVunPvRwDwXssZXTmydx8tApnQLY=; b=Yx+41wd2B6AVAYlPxRTP6EWXVzmzqAeyD7cXrk/21WOtyqx0hxv3p4YL/DrXje5mmF boOLDHFNaH6IE2ZoRXyAu9xruan3R+0EZbTUewfrvpuRoDFL9M6JStF0hKyzjJ6nKyJN nD4wiE+GP2MsDQBug0VLRv+gxIefXKrxEWrFM= 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=YZ6QeaHWeolJHJEbVunPvRwDwXssZXTmydx8tApnQLY=; b=eAAGdZpUkEhudH5ts43kWNDiAuyaC+QBDyDx0lPv5KfbeBC+InCRxhU8rbEk6N4DrJ w9gM54CVWD3RKHLT7ZNU9EJz7HOS+cntXeV4qYP4R8Enc6s+fQX5bXEAGpFCLGx9Y6Si 5WHFqFApd+imMlyyuOQDcqpqmMMnY39brQ17BR32zByCxlB+cMr5wSQ70Y80aRUFoZnq u99wCJbBOzMbQS0q9SJe7JuskaDUpvNtWZCd063HT0GUVF8EQVJEW7toya9YceZsl4ss EobWvIItC2V9X16qdgRO3APPDhu6hdzaIKLvcGdSCguV1uaHV9vVuFa+5fH3mQqhM8Xa hL/Q== X-Gm-Message-State: ANoB5pkkwyuoKk9/90BIaSkLOH0hXJTB3/tO5zz6qcaH4dQbRrtyD7ah ntsXzhchz/q+tZW6RKkOURgtqRMvaakMswsf X-Google-Smtp-Source: AA0mqf7uANjwZkwRKQfRAmnj47igACrL38jPhXw/xuURvgaLKf8fzdw20ktj71+QNukDDNYCkczGpQ== X-Received: by 2002:a17:902:b182:b0:189:dc5e:887d with SMTP id s2-20020a170902b18200b00189dc5e887dmr12051988plr.55.1670403249227; Wed, 07 Dec 2022 00:54:09 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Rui Miguel Silva Subject: [PATCH 07/71] test: Fix the help for the ut command Date: Wed, 7 Dec 2022 21:50:33 +1300 Message-Id: <20221207085137.445249-8-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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") --- 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 2736582f11c..82231c9b369 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -188,7 +188,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 Wed Dec 7 08:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713078 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=V4kw55hZ; 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 4NRrjB5l0xz23yq for ; Wed, 7 Dec 2022 19:55:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 45EA485596; Wed, 7 Dec 2022 09:54: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="V4kw55hZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B48848558F; Wed, 7 Dec 2022 09:54:17 +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-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 274F38531C for ; Wed, 7 Dec 2022 09:54: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-pf1-x429.google.com with SMTP id 124so17000013pfy.0 for ; Wed, 07 Dec 2022 00:54: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=Vww8FQLhgaGz5t7EMzYfm5d1oCiIO4dIXDRttSWyrRw=; b=V4kw55hZ0X8yZCpsMgoaoDYK3yY6X4Cglca8I0dCjg7rF/MpRU2jb096CtFM+SS6Wj EkLSF1x1UOfbpMow5F89K3+EZ6EhoVmHSf2sqC9PwZ2+BapWdG7slGk0phVpXzgBd9Q1 J94fygMJy3TPbnym6kGMBmgRKvWGhBo26VIuU= 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=Vww8FQLhgaGz5t7EMzYfm5d1oCiIO4dIXDRttSWyrRw=; b=5lWcNlJDyCcw2b0/D42zNVWOUfB5l/DSX9Fh7ab8nRoF8xbE3L3epR28y+OD97NxY0 LjPg4QDHr9eKsOJ+gQ0DJrYUTa73epv/CQuB6i+vBCUQr7lMqiV6URURaeOYmMBD+4Qj hkiocULVQpLKt3qZCtYvhADR33YCxqfLsamyH46M1PX4A0089WgLNbLQhKK2hsKzz6oS 8wGaGfpbydk7HKgVQXW7oPnpNIi/FWJbyzHmzL9stXK7ksP9y5sj9Cl2mHQoNcIvrVGU J6A+ES883jJQHolm7vPKCmVlURZ58PPJaGx6uFg9gcEIe7tGzFfpu0Ogmc8icCVZ9XJX MAPw== X-Gm-Message-State: ANoB5pksz8p99+oNil+9CcwpPoXzOfNs2Fz/4jPvM2hNd6hzCGtRz/Rb eq6X9s0mLRY5ETThRltnAiufYQMn+CpGSpvD X-Google-Smtp-Source: AA0mqf5BQHWjZh54GrRDFUmsRNAtqjio8Zav0OpipIGMsqcp9K5YZzgi+Q7+Ip7mARc6TBhblUJqzg== X-Received: by 2002:a63:4081:0:b0:46f:e657:7d25 with SMTP id n123-20020a634081000000b0046fe6577d25mr79724541pga.347.1670403253240; Wed, 07 Dec 2022 00:54:13 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:12 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Michal Suchanek , Stefan Roese Subject: [PATCH 08/71] test: Drop duplicate restore of DM state Date: Wed, 7 Dec 2022 21:50:34 +1300 Message-Id: <20221207085137.445249-9-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713079 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=kofhu/04; 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 4NRrjV2wj7z23yq for ; Wed, 7 Dec 2022 19:55:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76BEA8555D; Wed, 7 Dec 2022 09:54: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="kofhu/04"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3DC05855A8; Wed, 7 Dec 2022 09:54: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-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 8CE468558D for ; Wed, 7 Dec 2022 09:54: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=sjg@chromium.org Received: by mail-pf1-x429.google.com with SMTP id 124so17000116pfy.0 for ; Wed, 07 Dec 2022 00:54:17 -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=01dJjAHRNfOSrREIrWVmsW0pHjAGuwfR2ipI7kewnKE=; b=kofhu/043C65CoILIi6aQt7TOUU4etk1Hq9Cl3hCNpIBhWxyuAzE/LxMjl2FYO3GH0 jRDjbG5YeYjLmwEFqURGfvd6yMGvutfRA0qumdLgPzRB0pRTft6oXK+vJq00Q8v7tydj muhEEc+XF1eVQjqAOVJSN2s2vf/iiLgjqrhq8= 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=01dJjAHRNfOSrREIrWVmsW0pHjAGuwfR2ipI7kewnKE=; b=GAuEkkV51TVh1pxjqVH7+JXXuWlvjjKi5OR9eCmhRmZeHgfd2gi1xii+Nf8Zs3CuBZ AcSqSoOGa8gKBU7lE6vz9WRHneSLyEIpu6Dooxhx8spetv4sQ3MnRqJ2bkTPj3B9CmF+ WvyDXth+vS/+6hPUYpWd+niFdPyWZoi6cgipD9G4/hZWQHgIPvjl+bJI/8VgHHWVkZjv 8DrBRJIWu4ibzFYvq6NiJ8bE6uOkO6Wfj+DB+LVCDVkZ9Uxa1kbZ98lJ45mo8wogdeY8 QZrFtt/+Ad2YWiLFz0qzszIW2aOCpR5KHO481VKphlUFI+maY6QT+evBDOWm4HsRMRdH HikA== X-Gm-Message-State: ANoB5plHtqwpcVa6M3go9SwSfB3GHSjgbLvjDlY97tWlKYEGp1kF81iq GJzc9KtOWFb3dCdUVDS+DyTcnZdv4cUzI7q6 X-Google-Smtp-Source: AA0mqf7c1T2DhNeKhbqS4LxXWHlUfjd9Nm9dV+RVwuEfnW3FgbnyQxv0xJxjfIfSDL2Hwmk2Ot5lZg== X-Received: by 2002:a63:6446:0:b0:478:c3a2:bbcc with SMTP id y67-20020a636446000000b00478c3a2bbccmr10446948pgb.183.1670403256767; Wed, 07 Dec 2022 00:54:16 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:16 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jaehoon Chung , Peng Fan Subject: [PATCH 09/71] sandbox: mmc: Start off with a zeroed file Date: Wed, 7 Dec 2022 21:50:35 +1300 Message-Id: <20221207085137.445249-10-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713081 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=CEE4bNQq; 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 4NRrjm4y4Kz23yq for ; Wed, 7 Dec 2022 19:56:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EDCDE8559C; Wed, 7 Dec 2022 09:54: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="CEE4bNQq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E381385565; Wed, 7 Dec 2022 09:54:23 +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-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 56D808558F for ; Wed, 7 Dec 2022 09:54: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-pg1-x52e.google.com with SMTP id v3so15690598pgh.4 for ; Wed, 07 Dec 2022 00:54: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=OePHrMLnxZFUZh4Q65iwUP2nj+ZG0OmpKPb6CGWt7CY=; b=CEE4bNQqzCkQcidy8D0Ze6DNNd8RiId3HhNJY8jQOQyL7j9TzzY+b+s7s3rznK2+Qu ZpXzdmf2XFaTP0kmXEI5edbvWs9q9OTqkAiQ/WV3/o0fPFTuBoGNSnbiUKPStZhvbKNq tlWKqWibtfp/nWGOiM4BkocOz8kDpmhLApGjg= 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=OePHrMLnxZFUZh4Q65iwUP2nj+ZG0OmpKPb6CGWt7CY=; b=SLVBO8OdnVMe2/lYDcZcfx/98g08JWkWYgtJNDpCv6AqOYk4W2jjQ/ByAOkGtVrw4Y wFIdjAv3kWS4qVUsXGPZL0N25UPveajJZYqt1984MX2kPItdpPin2joffLCSJYAQuWBl eFI6ZkrcRUAc+FVqzyhKhmf+f4VGO7Z+pyocc/N6N7wxtvBCK2gpf5oL32ACULX6M0/6 8rKtgxyLJg8X0fvCkxvoPfd7f1u7nVIB/nNI6DMeOJ+jHJ11YjgHPICIxYUq4L5+IHRj fGPadsT6TndRLqchwFqSpFrQVwol7hbFWRNzZI/ioBOXP7dmKE5ygGJzX/tiTB1Ad17q xtIA== X-Gm-Message-State: ANoB5plSDoUvO5h1fTMJn7lB754d/Bjm8SVzh+mGT+/2Y+g7whJt5MH0 zYFB3Py3HCYOAwYY73yQdSRC0IT70HMzzoT5 X-Google-Smtp-Source: AA0mqf5XZB3m4i6BxA1MtE6XZqwFLRGSMq2S5k1p66qeGP9A+oT7mRN3XhFuI/6dPCDI/GwNf+ZiEg== X-Received: by 2002:a05:6a00:4488:b0:577:599d:b2b7 with SMTP id cu8-20020a056a00448800b00577599db2b7mr4473918pfb.25.1670403259668; Wed, 07 Dec 2022 00:54:19 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:19 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 10/71] vbe: Avoid a build failure when bloblist is not enabled Date: Wed, 7 Dec 2022 21:50:36 +1300 Message-Id: <20221207085137.445249-11-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713084 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=hf7/+nVu; 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 4NRrk23yB1z23yq for ; Wed, 7 Dec 2022 19:56:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7337C8559A; Wed, 7 Dec 2022 09:54: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=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="hf7/+nVu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A094855A8; Wed, 7 Dec 2022 09:54:28 +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-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 C9B868531C for ; Wed, 7 Dec 2022 09:54: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-pf1-x42f.google.com with SMTP id 130so16941554pfu.8 for ; Wed, 07 Dec 2022 00:54:25 -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=egPAKvMjZ7z7uKu6OPRARcX4G5bfvf3qf8udrIYRgB8=; b=hf7/+nVugU5K7jtNATt26szet2tPa9Kiyl846rbJiT6oSpV54jyUn7RhJGRs3Djl03 8B/MvpxZUIpxym3theemSc+A2qVfL3KIUgO1TchNczr8S7tmEJsJ3Y3q+JdOGXAK5UCv ZoXk96+VHPMzB6ps8ZlZZWQTF2H2pGf5HKhck= 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=egPAKvMjZ7z7uKu6OPRARcX4G5bfvf3qf8udrIYRgB8=; b=hOmvX6aqvM2EgcHumIez5SLOSF2MxixGqx+7qQQcmaeRV8OuPrwWGNIfC4YeKIatat cGEBQHtPNRoMwILdzz+na5EJ9nrXqZhgGHr923uPbFXzDyiOnOl7z1aKKtz8/J1rq9rW YjWaJnetGqmcxKfR/TDEpStfDfhMETBz8aMunDFYX86v9bbyj4rT05FZMjlMS2KzgPpv F62Br4Wx5u0xD+3h7yOuZu2WAulnMvTS24TNF1NWBzujI9Utyx6qBE/okZVJEr4mnqfI IEbbL0bsGiJFrJswX/WMXWybt/uVdQ7ZyzLHFXx+n/9VYdL02hYt/qtvLt+kCxZ/XUXn G+RA== X-Gm-Message-State: ANoB5pkHdjnxzB467swXOVxoBWnJXZVL/9ta55JApYCu6iaYVQ1MN4Ix 9I18bG+ILi6XmAL04CNvTLb7RV2aFWvBQpmq X-Google-Smtp-Source: AA0mqf43JATf1hjq2lHF6m31aMYZKQuLSthOoBZyDvB/8H582VNn+NtjvCSGH1uhPdjMqegl7Fq2UA== X-Received: by 2002:a05:6a00:368e:b0:574:ead0:7c22 with SMTP id dw14-20020a056a00368e00b00574ead07c22mr32667867pfb.9.1670403263917; Wed, 07 Dec 2022 00:54:23 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Michal Suchanek , Philippe Reynes , Rasmus Villemoes , Robert Marko Subject: [PATCH 11/71] vbe: sandbox: Drop VBE node in chosen Date: Wed, 7 Dec 2022 21:50:37 +1300 Message-Id: <20221207085137.445249-12-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713165 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=OIXbEAgy; 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 4NRs2S2hRpz23yq for ; Wed, 7 Dec 2022 20:10:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E8A684BD1; Wed, 7 Dec 2022 10:04: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="OIXbEAgy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD85384BD1; Wed, 7 Dec 2022 10:03: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 75C6A855AA for ; Wed, 7 Dec 2022 09:54:29 +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-pg1-x529.google.com with SMTP id q1so15660174pgl.11 for ; Wed, 07 Dec 2022 00:54:29 -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=zBm7bvSxiTxxHB/2oSeYEk3GKQj9KYprNd4cdJkxQu8=; b=OIXbEAgydxIOCBtoGvgee+SOMBwO8TEH1ln2buHEzEzhHPequXJFCLwHb8n5L9wF0u I5ZlXqvxWiG7esoGIv5HBlvke8fyUgK/7nIeyCsFxzLUKQc8KO3hL18ugHlZF83cj+HL Ox2ZcXplld3PySZck4QrjKDafIOaRJjlnnzWc= 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=zBm7bvSxiTxxHB/2oSeYEk3GKQj9KYprNd4cdJkxQu8=; b=0Pn6mPXGaPs/FuHq6/L6vYt1BAgchoE4UTiTDHjAoMyDRqUqux+TK+RNYyARk78aSn /key0w+aHrfAr9NmuqyfN3trVTTpzlaf6qzfj0hJDpETL7swyuCg4xff+yFB7Gku4kRv oQWoULPgBiEkK80bm7eFphAOju1Uy8JOkO42WrcOmfSHC/XX6ycIqxAy9qle8ILGKJPL J2pein1uo7LAPwxgXxA8qObcrHic5OUz5zt9yd2z0uSuYY5VXdfsuKL9X+uTHildu1fx U7weT3yhlcO1s3lqdy6iEc65X27cVhtGkp/ROVH6u5iaNGFBWwvhzVVDlj4eekCwJkna eObA== X-Gm-Message-State: ANoB5pnMn5CENeKDGFbxJxllT9JzSx249R8xoMCAxtsfruUNfLpVGl/5 NgcNjcRWw64XMYUxwDP5606/+TSv+4ymnTDm X-Google-Smtp-Source: AA0mqf5bwI+PxxK84a/ZoOlAq4x9QaOq9TEHGUbb+vnlQVzQLD8csxt71apd5Ue72P89aelwzixYmg== X-Received: by 2002:a65:694e:0:b0:474:6749:407d with SMTP id w14-20020a65694e000000b004746749407dmr62212190pgq.425.1670403267593; Wed, 07 Dec 2022 00:54:27 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 12/71] dm: part: Update test to use mmc2 Date: Wed, 7 Dec 2022 21:50:38 +1300 Message-Id: <20221207085137.445249-13-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713086 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=mEFEpyeh; 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 4NRrkK3T27z23yq for ; Wed, 7 Dec 2022 19:56:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD3AD8557D; Wed, 7 Dec 2022 09:54: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="mEFEpyeh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E5155855BB; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 2F729855B0 for ; Wed, 7 Dec 2022 09:54: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-pj1-x1036.google.com with SMTP id cm20so16960224pjb.1 for ; Wed, 07 Dec 2022 00:54: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=HGMKGJVZp2OUDpt1RyHWB2JziahFVNPz1xN8Q1BNDH4=; b=mEFEpyehceePvD0QDcRjqPUdV6xDiY59trRtnD0gj96B05Pt3Wlrj3Xjnc2+EQNMXn Xx1ZDBW0bl5l3lvhq0sLqexSf8bjKL03OWWkfs9+TzvzPQ8VAmbd5qkd4o4poxYtL6EC LGY/Ta+VzJjABkMaVpQjtgo5lIGmgYR47lbdg= 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=HGMKGJVZp2OUDpt1RyHWB2JziahFVNPz1xN8Q1BNDH4=; b=N/SJ+8oNbUf0VHILt9TE1pZX9yLK4RTt4GGR8uTh2wbdCTwTgBoavS7g8J7M6QxLyN IwQilpuk8nE/2Jc1Sed8BhvmFTOGGG0vSWX57/GvMRFsxCaVakvX4bPcqBaZrrraQO6R daIfoGLa4UrGJri7hf9ReUsKMMotJeZUVLs3Dp9pUOjNXlO8Jc4SJPOnSQVWM9btcHmc ckvVs7MXti4Rybzw1KjEFG4XGNyC5iQfbn5estdyK/t9YD2tBs/4RzWIxMOouBMg6npA 4ZJktBP2p3IKu+HhOXxgkaBAH13UrBQa78jYCMfybB6NP9ePEkv8+VsXiJxRD8yoixBX 3+bg== X-Gm-Message-State: ANoB5pmuhDCh398f71mBfZvZDWsQTA6vZozwgcEyDn0V1AirhDUkRHFA t0ykK5Nwqcr9aPGM/fJmlsRr4j5D74Gbkgyr X-Google-Smtp-Source: AA0mqf4Rer0Mw2A6N8yrgP/yo2DKwvozRI1pdICGKQiKJoBqKWvZ4Zw8s2KIb96jzJpop1b6/qxvvA== X-Received: by 2002:a17:90a:7444:b0:219:d415:d7cd with SMTP id o4-20020a17090a744400b00219d415d7cdmr14286897pjk.89.1670403272311; Wed, 07 Dec 2022 00:54:32 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Marek Vasut , Michal Suchanek , Pavel Herrmann , Stefan Roese Subject: [PATCH 13/71] dm: test: Correct ordering of DM setup Date: Wed, 7 Dec 2022 21:50:39 +1300 Message-Id: <20221207085137.445249-14-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- test/boot/bootflow.c | 11 +++++++---- test/test-main.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index e1e07082105..aac14d30673 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -15,6 +15,7 @@ #ifdef CONFIG_SANDBOX #include #endif +#include #include #include #include @@ -327,12 +328,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 */ @@ -342,7 +345,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 Wed Dec 7 08:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713090 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=ZonEji0B; 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 4NRrkt09YTz23yq for ; Wed, 7 Dec 2022 19:57:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 557B1855B0; Wed, 7 Dec 2022 09:54: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="ZonEji0B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7ADF3855CD; Wed, 7 Dec 2022 09:54:51 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 05E4685565 for ; Wed, 7 Dec 2022 09:54: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-pl1-x62d.google.com with SMTP id m4so9490454pls.4 for ; Wed, 07 Dec 2022 00:54:38 -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=xwnPhmw5jHHBS0P+PkSIDgNzPufK0w+NtFDEqGMmCqQ=; b=ZonEji0Bf8X1uO20GOXpCUnws0HLBnHB6sI0xIRBliCfpHQ3yk2liQi8oGlda36Qzl 0mEgndcI11WBeRTvu7/dJPSP8P4lcg6unap64QJ2i36gK4uFnAOoCs1ycfcEsQeSfLkI pBQFo2gs+xmzb2pdXjaKdGPrkpMvce/o/we3Q= 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=xwnPhmw5jHHBS0P+PkSIDgNzPufK0w+NtFDEqGMmCqQ=; b=kiHzMMOakPwiuS9eppmq/CUAm/+CqLHV37RDRydNRbLdYsrqcvCJ9/QXklUtWAfaZ+ lUChcz+HhWq8Wrs6gQ0WXD8Tw/XoDUIloURywyQ+ItK9SrgKtuY3uhfHs+gJFb/5CXzi nkZcm7WmCaRIJaBZhSLXSuY7ZQkaRl3K0kLJ+SViw9G01EyoYx5CzK5GQO7T8rB/QbZw unyZZRK0MtKL/04B4WIPEdPWvkL8Hvsn5dN7o34ddb3EEQANok5o5fYt5gP1fWfswfQr U8z54aQy6SE609RizOL9PbaYB2iRY0xWbHFT9R2lQCxrfZdRFHC7Mbt/n/rWjKIrP7SB AGrA== X-Gm-Message-State: ANoB5pmwubQIRxEP9r7a6Y8udvl9gR4Q+CBvppGR1HKhFOPq1AQjlGOJ BGXSPsp7wzdttoI/ZzcBXz2PCT+laLWcsj+k X-Google-Smtp-Source: AA0mqf4azMjzhPffbxqyIVPY0Ua9twd+34218Z6WPYyJzEBCdff06o7FfIMtn6/95OHX7tk9ZndkRw== X-Received: by 2002:a17:90a:5d08:b0:218:770c:9a40 with SMTP id s8-20020a17090a5d0800b00218770c9a40mr81940154pji.158.1670403275962; Wed, 07 Dec 2022 00:54:35 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Stefan Roese Subject: [PATCH 14/71] ide: Drop non-DM code for BLK Date: Wed, 7 Dec 2022 21:50:40 +1300 Message-Id: <20221207085137.445249-15-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713088 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=KdQhYV42; 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 4NRrkc1DcQz23yq for ; Wed, 7 Dec 2022 19:56:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5126D855C7; Wed, 7 Dec 2022 09:54: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="KdQhYV42"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4045E855BD; Wed, 7 Dec 2022 09:54: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-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 112878557C for ; Wed, 7 Dec 2022 09:54: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-pj1-x1030.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so830592pjs.4 for ; Wed, 07 Dec 2022 00:54: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=sYR1t2FKgDoWybD4iQRljNHgk4I7SH7PipLy5nsV23Y=; b=KdQhYV42J/OQrk7Gtk4798fUb43VLbftWSwi9hGjbK7/50xNwGIWzDdjazSFUczX0r XqZV/pIycOPvMWi1D018C8IvyDkrOFxUX3W4k9YdlVwY1Bx071Vv3Ale13wfrvM3MOVN Idblm/e5FZ6z+VDY7/mjlWZCaiJQju5dnYkzM= 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=sYR1t2FKgDoWybD4iQRljNHgk4I7SH7PipLy5nsV23Y=; b=0cP+wWTIN5WigA9XMO/gY6HDR4eRFkFUk7hOnl3rKwM1m2lwMOjVQNqQopw16gTB9j nR4JKbAhGrX0zRtdpRUx1t+/5jEqij6G+N1V9zgvikSF+zk4dnE5IQ8SBK20/gl3ANDF /o2hqoVdbXeZpwhZlb5rUiXgw57XnR6o59WpRSuRSOo+TvZw4XOVZ/ksQE7s2CkSDAhn UBUGQaGRfVJhirxgY6zJW4cnu4V4CFw3UOsvl3dyb7pUoipGtlxrIBDgiVQIUfPm3719 axizCLfIwITusrfGlphUzHFbAMjbwABu7DjDToI68V/c6k1kcUVuhSl9dcFo1uRwflND KaJg== X-Gm-Message-State: ANoB5pkn+AsGycRSJDgf2kvgKA1y+biKDIpsY5zgoq6HdA8jYeL/ZP5S I0lrw3DR0rrnd2OpUTPKGL7tmfUWtsiIj/Ai X-Google-Smtp-Source: AA0mqf68+ISeJaRVS9Sg8kgK8da6io+XKrZrFJA+QPQ5ObzYwlMx6RWYI0E0K7squmkAO5glukdyWA== X-Received: by 2002:a17:90b:30cf:b0:219:b8f9:bae5 with SMTP id hi15-20020a17090b30cf00b00219b8f9bae5mr18839632pjb.242.1670403280350; Wed, 07 Dec 2022 00:54:40 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jaehoon Chung , Marek Vasut , Pavel Herrmann , Peng Fan Subject: [PATCH 15/71] dm: mmc: Use bootdev_setup_sibling_blk() Date: Wed, 7 Dec 2022 21:50:41 +1300 Message-Id: <20221207085137.445249-16-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713093 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=IG+CPRdg; 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 4NRrl96FsHz23yq for ; Wed, 7 Dec 2022 19:57:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 676A485590; Wed, 7 Dec 2022 09:54: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=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="IG+CPRdg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FEC88557C; Wed, 7 Dec 2022 09:54:51 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 08FCE855D1 for ; Wed, 7 Dec 2022 09:54: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-pj1-x1036.google.com with SMTP id cm20so16960635pjb.1 for ; Wed, 07 Dec 2022 00:54:44 -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=LvzDIjxup7tI20I85/+ELahyQJDlbzvJ96c1be8A7CE=; b=IG+CPRdgtiOT+vL3RlNThDj9oLQgZ7fkQPUJ4nQ0Vp7H/K1t3dTQ0enyBvFbzXH0ma 8GhC1Ai3RPXQXd48Lb/SndvlgvXxNSirHpeagPcf6tPl7bae/AGP6L/685NRS4BvKECE nAM1GwZ7qMJm8Uau2/NBIfShrD+lEEemLw5kU= 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=LvzDIjxup7tI20I85/+ELahyQJDlbzvJ96c1be8A7CE=; b=mXrnWLkFWs7FVNl182TaWTY6aipGXDT8nsdrs9UOagMdWiyF9Fn83wgyaYhV+K8rtE yB4h7ScwUkDeBUvaGOB5S/falY1WFd9d+U12tlU3bd68/jmBZNi2FzruQVGVpegNVKIH k/EX/JFskXDM0zdAd/U7PiMIzk/F2OkU0PKQBLmzksjE//TkM7iG2eXhGEHappPDAmEt Q+pH+ATlJDKFjjsXZRh0ZAefrXrRwo0SFkY1J29xzVIoxcu7kHOqABr1L2AxxF3k56NX /91Rin7gUJ2JFHroJBMGh+WcKTQA1isYx++2Ut3i9NaEIJuEncZAglFZr3/aR6Gu1MWl Y/4w== X-Gm-Message-State: ANoB5pkk/7b4wzZGJraNaDXsGn4PyLCHYHQHoSZUt29UU4jFKRqlS8X4 +zLLUkPoZRehqrB433bbaQ3HpxP2ZOLjDdww X-Google-Smtp-Source: AA0mqf5Vp1cV+psMAjAHPV+rSC711s2HKUsDk9Dda9OS23f3sZ+5cHFEy+icJxH3GdTthsmjdwMgqw== X-Received: by 2002:a17:902:784c:b0:189:65c5:4507 with SMTP id e12-20020a170902784c00b0018965c54507mr56691124pln.172.1670403284323; Wed, 07 Dec 2022 00:54:44 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jaehoon Chung , Marek Vasut , Peng Fan Subject: [PATCH 16/71] bootstd: Add a default method to get bootflows Date: Wed, 7 Dec 2022 21:50:42 +1300 Message-Id: <20221207085137.445249-17-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713094 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=HAfT9vfw; 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 4NRrlQ064Nz23yq for ; Wed, 7 Dec 2022 19:57:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E83A8554D; Wed, 7 Dec 2022 09:55: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="HAfT9vfw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FF48855B0; Wed, 7 Dec 2022 09:54: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,T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 A5EE185565 for ; Wed, 7 Dec 2022 09:54: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-pl1-x62d.google.com with SMTP id p24so16439704plw.1 for ; Wed, 07 Dec 2022 00:54: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=nyRaz94Legd5Udzb8UIor01QGV9ooC2AY8LwPJf8OaE=; b=HAfT9vfwZSurSJdNUe/aIYS84emplYxxMnwn90ta+oI5Bge1Y1kh/gTQNpXTFXhQfd noMQTUH8tPRnjwX+HXWlhmZEK/ZPOPsbYF3BGr232oypn7cNQdCdgDOV/hePCy4ts21h SrQGfRYVHXaM681TPGzxedyXeUfWyn0pIYJfc= 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=nyRaz94Legd5Udzb8UIor01QGV9ooC2AY8LwPJf8OaE=; b=IrLGBbWZErPvoSxA+6V20pX2PkAL3QMcQW6/CakX8/f2KvYZ7Anbt6M+taPnYrlgwm lyjyrP7A4mAW2EVwqXFmOqakgWmuFlbES99xI9wm4zGmcXKhVCroOMe/kS4yJYqCy2/s vdXJhpv1/V/97mIhz1EJrHDu703S9OR9uewcnxyFBhk1PhZb2Y+aS87M+YCG9yr1mlfN 2TNgafhEFKTdbVugV3kw0HGnv3owbik+FMxKhb13czhv0nw+aJWu87MX/aKc09ZUs5GR gMYL1IfUxpMX+5Ek43Cvq1JH7bqbGRoWAwprncem+ktkV3LOOLvaUn0SJXwSIz5Buz7Y yIDg== X-Gm-Message-State: ANoB5pn1X25pGLtesDzngfu1FwULIjn8ylA6Y9hoWBFIYFNIVsYv9xPh 6/isMA3j5He3iugc9AXX7ASWeS6zB8Y0qNyw X-Google-Smtp-Source: AA0mqf4/cZPp4nlhhPSC/3D8KobdtFpR8lFkxYnmhtFI3+9TaZbUr0jd/yPvr5qZF4RBstHIFadXrw== X-Received: by 2002:a17:90a:bd01:b0:21a:557:bb72 with SMTP id y1-20020a17090abd0100b0021a0557bb72mr5695954pjr.46.1670403288915; Wed, 07 Dec 2022 00:54:48 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Joe Hershberger , =?utf-8?q?Pali_Roh=C3=A1r?= , Ramon Fried , Stefan Roese Subject: [PATCH 17/71] sandbox: Allow ethernet to be disabled at runtime Date: Wed, 7 Dec 2022 21:50:43 +1300 Message-Id: <20221207085137.445249-18-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 a681e472ab6..76e65741424 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 1c39acc4936..8f7d3c3b305 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 Wed Dec 7 08:50:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713095 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=AzpLdgBc; 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 4NRrlg5zzLz23yq for ; Wed, 7 Dec 2022 19:57:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6045C855EB; Wed, 7 Dec 2022 09:55: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="AzpLdgBc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3CDEC84EA1; Wed, 7 Dec 2022 09:54: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 8D6D585590 for ; Wed, 7 Dec 2022 09:54: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=sjg@chromium.org Received: by mail-pj1-x102f.google.com with SMTP id b11so16960320pjp.2 for ; Wed, 07 Dec 2022 00:54: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=21/iO76L5ru58VsRak/iqfh6zKKHyO2f+oUfIfXqnfw=; b=AzpLdgBctT9ElRajvUVHU8TWqW++6O0cXtxRs7ygsmgPwr4IHTRRv6mLPJ70sx6OxV LmpqbCtIOq3gXsjUVq1Z5FAYTpeHHVu2z+buRs4y/FYSySHsqajjdMI9dpmI9tR+B6XE uRbwa0zRI+0lj0yFQ16JgafpGyN78NKs6ubL4= 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=21/iO76L5ru58VsRak/iqfh6zKKHyO2f+oUfIfXqnfw=; b=E+zjSR3e7TQFT6iAkBrbLB2Zblv7V0NzRnC3Re6EeKlvCmjIYuzIs99eXRZjgM4cQv tzhgmSDZqdyPpqmQkOcwplgo7BdCpI+xmoiZEyA75mJo2sjNUPUC8rjT6krIm3Jd457r UB90NLtXw/ZAGXR+i6nRYH4jY7VAX0biuLJtbQ62fCJXJFKNqCwksN+yDcsPmUicBm4G yS6FrvoeWzQ3mELwkpunIWr3QmMletuvKYXIb/FomKs2uAVCAQlK0XoI3xYTr/RvBs2j sLwdXfA8o6hiKnDajdfdu1hBbkYZUG5FVqrheOiryD27OEf0jUFaQzT+3Xc/FY3jZaAd 40Uw== X-Gm-Message-State: ANoB5pmQkBqZG20phzLNETlLK12S1uKFuPMdd1QscWZJvqGQHAAeNzFI nOI+bWDizJ8dpmnlFfIrA1GIETQpMK77pO08 X-Google-Smtp-Source: AA0mqf7v+ATsQD5H7+KVZh5N4ICyf0MgakMezhO3cOhwOdzU8XCSp/cQvW2eLxRbamHZH+2xO3BEAA== X-Received: by 2002:a17:902:6b8b:b0:188:a40b:47c9 with SMTP id p11-20020a1709026b8b00b00188a40b47c9mr74207614plk.75.1670403293707; Wed, 07 Dec 2022 00:54:53 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Joe Hershberger , Michal Suchanek , Ramon Fried , Stefan Roese Subject: [PATCH 18/71] sandbox: Allow ethernet bootdevs to be disabled for tests Date: Wed, 7 Dec 2022 21:50:44 +1300 Message-Id: <20221207085137.445249-19-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 1a99009959d..749f20fa967 100644 --- a/include/net.h +++ b/include/net.h @@ -957,4 +957,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 Wed Dec 7 08:50:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713098 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=NWPBtp/3; 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 4NRrm03h3xz23yq for ; Wed, 7 Dec 2022 19:58:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B2D385565; Wed, 7 Dec 2022 09:55: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="NWPBtp/3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2EB8F8556A; Wed, 7 Dec 2022 09:55:04 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 48049855E7 for ; Wed, 7 Dec 2022 09:54: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-pj1-x102a.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so828462pje.5 for ; Wed, 07 Dec 2022 00:54: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=6Khvoz/5LeoXxU/BwMdOpzFg1SNjBZgHSnhTedFbNCU=; b=NWPBtp/3EeGtj/+f7CzRng0lXh5C84FWG+ZbwaagsV2Fne6CljLsnlNNiTUyn9AJhH tVPdUdG/cf8Oza9TaaqbzN1gEl6dLIioUxgwb1T5qobYDVo4A1BbMPYAza3ohOMKqVPC Z3iUJrXK84CRfHSNCNaC3bvoy9v2W2bOq9dzI= 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=6Khvoz/5LeoXxU/BwMdOpzFg1SNjBZgHSnhTedFbNCU=; b=xekuvkdcgkWmdQzUwTQScWmVJaBMfbBASsxwUgbnh/N1bB4BWd7NkQyz+TwX5VjM1p M97zJe2G795fUYFHIToId7xayJ12YjD5jYkPfNjtBJdYWQWpbC+UjeQyEQ0nmYCLYp1O UnDarkEJqCzfrtRyRKL4a966Z0dhGdnEcCi/uxtA/HVa23ARiynAj3w+4fyhh3nfoGqc ss6WXWSIl9otFbG8sLNoKpeFLGVzB2kcRwa8PL5gLq9x70vvT8j1a6X1HhasR2l/05+2 S0zes+MSjnywBG82ZzGRKsaaOaXWaC+lm8lS+lcW67qi6AwR2xsqkYnxrqph3Sypc4zU AS6w== X-Gm-Message-State: ANoB5pn/K1JulzjonDNgcULWdvMhINkbadF/kZDxCz9DgGmezq+zrkae o0sZpJwc5qCUV5axBUaPyjNEJgXb8/kmq+zA X-Google-Smtp-Source: AA0mqf7TFNS9KnuJKt/TNo7K7u6gHfCURsVjftXQaOWQb1k3TJn1STmLy0EoJ5dlkPCexTIF7H30Bw== X-Received: by 2002:a17:902:d711:b0:188:c7b2:2dd with SMTP id w17-20020a170902d71100b00188c7b202ddmr74777626ply.88.1670403296557; Wed, 07 Dec 2022 00:54:56 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 19/71] sandbox: Enable the Ethernet bootdev Date: Wed, 7 Dec 2022 21:50:45 +1300 Message-Id: <20221207085137.445249-20-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 404e4a3324a..02bf0e5df25 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -130,7 +130,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 7237efe6857..df41efbe9ac 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -73,7 +73,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 Wed Dec 7 08:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713100 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=NU/+XK0i; 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 4NRrmD08MSz23yq for ; Wed, 7 Dec 2022 19:58:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E473985161; Wed, 7 Dec 2022 09:55: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=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="NU/+XK0i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DDC085431; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 59CD7855A2 for ; Wed, 7 Dec 2022 09:55: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-pj1-x1032.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so929891pjd.5 for ; Wed, 07 Dec 2022 00:55: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=kT5MZQzrOpBWaCbzuTL5Cj7O92Eqb+xLO4fG3pDBxB4=; b=NU/+XK0igeApR9A83CENrL4PQxeRJVpF5h3BPHue6vG/iyvHMMj7E1tdhDRBqpMdsg cJ42s6Oc3VQTST0xeZ5MM5S3mF/jKMZSG1IWDrkkvBV6NUtBDklkVxAeAWAbmb1jHtRW 8Z7DP+gFEoV0iPHfkKXN8HL7N17gDoMmMdp5M= 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=kT5MZQzrOpBWaCbzuTL5Cj7O92Eqb+xLO4fG3pDBxB4=; b=DFN+NT7Kjy+xVWwkA5881EFQbwE+JFRux4CcrEO4fE2QZYwlEP00Uyc0epyUNVUheg sVM63Kbt4Ulhx3eDVYvufReW4lw295fKJi4Ozc8j+TrD5O4aUVhG8vl88TeYzeZS2BN2 QwpssWNsuuP628TF9Wi1/VPlI5jjx9iKbcweD7lTPovil0YM8pmMdkWekmcaXpjTwjmU NcTnyDupzagwn0Xon0k/cS/K9tshx25oK421A+PtcG9PQRd+ckG4NNJ/T0k7DHQ0OVg3 bhFb9U8RnbEgo6LqCLuVOymqU7+A1juC2WQ1pVZ/LFoz/fFPQWK8qi5etA5ZO+FQN6Er qWOA== X-Gm-Message-State: ANoB5pn7I7jVXxKhRm4es8/82DPOUb8rsCwJ4qPcXM4T+lanpZiQ9Yps mXLwPpUBP6u5MU0sjSGWCkxsON59NOootk4e X-Google-Smtp-Source: AA0mqf79D1Z4py+tiu5vBRKA511jeCt6hKOQQ0C2nvIbscOGK0QWfZBvgbOTJiTWdLf22V9TnwF+JQ== X-Received: by 2002:a17:90a:8c96:b0:218:7e9d:8d0a with SMTP id b22-20020a17090a8c9600b002187e9d8d0amr92539239pjo.41.1670403300580; Wed, 07 Dec 2022 00:55:00 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Ramon Fried , Viacheslav Mitrofanov Subject: [PATCH 20/71] lib: Support printing an error string Date: Wed, 7 Dec 2022 21:50:46 +1300 Message-Id: <20221207085137.445249-21-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713101 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=XeU79NTo; 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 4NRrmV0HrHz23yq for ; Wed, 7 Dec 2022 19:58:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2A97855B2; Wed, 7 Dec 2022 09:55: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="XeU79NTo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1039855A2; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 3F67B855B6 for ; Wed, 7 Dec 2022 09:55: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=sjg@chromium.org Received: by mail-pf1-x42e.google.com with SMTP id g1so8914355pfk.2 for ; Wed, 07 Dec 2022 00:55: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=FX927QmgGCUVZbVDUGqfCQs+7pmLG8iVqrDlZoh69Ik=; b=XeU79NTobT05zuiE1e14UvdAwv35kIfiE7yUPZ5fCRsXJMxzNirf0vBUW6aKBILfgr PJKheE5TN+viGXurv3t6WV3ap4BKehH6nrm1KEVhDVfuRrLYACX2+gXZnLeEhmI3iDaJ xkr3N5DY32vHttlQiwpM8dHTe4MGPeF7TAoZQ= 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=FX927QmgGCUVZbVDUGqfCQs+7pmLG8iVqrDlZoh69Ik=; b=Las4Sxjy4p2aTdG7FNAg0KNfF2ogjjiZ4uSRsc9s/v+1rJXJ02UwGNdyUcuY7HmiU4 2wSQ3qHpv4EdIvdhf+T3SHnQBMk+UZYRs4mba0Y9j1Z3k+lcwPdaInmlaIDOYLw3cBuR tRXmVJC2+19qkQ1boO3XyogqsUrGA/63EEBlkegDAIFMIpv+J453uNHoOB/CJo62pBz6 BPmBDCsJq4QlVEXFPMWkPjtnWu5iLrRplaYkPqdJbPwDaUqzGDqhqipDkr00iy7rCDsy E+0yKaicNv1p+JivCkWbmYU+uJKWs0s/YnBWNrrYfUR5bgb0BceHczC8QLHDA75+mole vq7Q== X-Gm-Message-State: ANoB5pn/CWDjcZn83gAkdYfdV6Fu46vwd0RUIlALTaQ4+nQgv5eaiGTf XmnkArDDZy3r3egmirjNc8CMe/ptUW6fKTAR X-Google-Smtp-Source: AA0mqf7Xs481GcFXJ77C08auYTeIFNTnAIPNi+VakgU2qHSt/EClKtS5njVFI1D3bmCSglVvm/faTg== X-Received: by 2002:aa7:8d5a:0:b0:560:eec2:d0ab with SMTP id s26-20020aa78d5a000000b00560eec2d0abmr93614028pfe.43.1670403303721; Wed, 07 Dec 2022 00:55:03 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 21/71] event: Correct duplicate log message in event_notify() Date: Wed, 7 Dec 2022 21:50:47 +1300 Message-Id: <20221207085137.445249-22-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713103 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=lbLm0WR3; 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 4NRrml2QJnz23yx for ; Wed, 7 Dec 2022 19:58:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E488785601; Wed, 7 Dec 2022 09:55: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="lbLm0WR3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51FF8855B4; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 50781855EC for ; Wed, 7 Dec 2022 09:55: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=sjg@chromium.org Received: by mail-pg1-x52b.google.com with SMTP id 142so257965pga.1 for ; Wed, 07 Dec 2022 00:55:09 -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=An24V7UwbXlLQKImy13KddJWwtQG5wg+vMe1OmFiIbw=; b=lbLm0WR3POB8fUeaBmWznjzW9Hzsn51j68Nn1x44aNY1VfmIMEdtm3cBANzAl7sdzk o5r+vdqJU17kBAI5/rJ3hzs+0QIwFK9wIgwSDApsrJj40UBcEKtHgrLSkUCBmcvvJmSd 3GAifUIGv+wtRkO0vfCMi9c/IfFt0YfOjWeOE= 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=An24V7UwbXlLQKImy13KddJWwtQG5wg+vMe1OmFiIbw=; b=s34jCDkYLoJaG8tYdafrXBJIzGoG5HTNSQ1QzEdeH1+ZtCuP1SnDIKJ8ZwVUSAh6aO 5p9Pl4v+chCBp+ZLoI615I7oFrsqLAhLvQ5XI+cnOu978ryWMEUufAeYh5V6bpdnAP2R /1rr4kbwheW9ePBuhdD8nprms3wAWJ/CVaOB7JT99SE7UdM9fZTnZPw8VtuUg0Dojx33 JRuG+mHZYBXRz574ZP/Ybv/RqSVfeK4So0XxAnowzVF9hm5xiY7uoskaq0yeVJtK7MpY BY1WGnhana2Zp1upLsoZtqq6pyXcNXM3QrIUJAikJ9DfVFxgF2GkxexKqjfKyRHdr97W oDBw== X-Gm-Message-State: ANoB5pnfgo8Z8ADY3gxPgh6uub54J2qnBc2duQwTRekTgR4e4uvHtVsb S9QvM0e/zxzkFYlKzcjhMoHPlDqg/mf57iH4 X-Google-Smtp-Source: AA0mqf6N4PDy6BuA9u12uicmjrDaQ4nkSqc+qmU4JT15m3YXN8ok+78aybi5ShSzdTLRewbBbsw32Q== X-Received: by 2002:a05:6a00:a88:b0:574:2c5e:b18c with SMTP id b8-20020a056a000a8800b005742c5eb18cmr69423944pfl.10.1670403307483; Wed, 07 Dec 2022 00:55:07 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:07 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH 22/71] efi: Improve logging in efi_disk Date: Wed, 7 Dec 2022 21:50:48 +1300 Message-Id: <20221207085137.445249-23-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 7ea0334083f..37123dd2474 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -421,13 +421,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 @@ -436,8 +439,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); @@ -468,8 +473,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 @@ -482,8 +489,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; @@ -552,18 +561,21 @@ static int efi_disk_create_raw(struct udevice *dev) ret = efi_disk_add_dev(NULL, NULL, desc, diskid, NULL, 0, &disk); 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 Wed Dec 7 08:50:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713107 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=nUGk0CN9; 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 4NRrn00Zs4z23yq for ; Wed, 7 Dec 2022 19:59:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72D2B855D1; Wed, 7 Dec 2022 09:55:29 +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="nUGk0CN9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81F7C855BD; Wed, 7 Dec 2022 09:55:17 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 339BE855B6 for ; Wed, 7 Dec 2022 09:55: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-pl1-x62d.google.com with SMTP id p24so16440381plw.1 for ; Wed, 07 Dec 2022 00:55: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=7WCYOfLrHUYah0W32N+CErBh+++75U0nYwKBiVHFwdM=; b=nUGk0CN9XWaqPGGRC9/L7KLW6pXFG7hbl6jlfHQBlpcbllfjlxJMmvYr9v+ZBtgjKH Hc7OhjlFpFMXowhCBI3eTckrsdyHtm/JkIOcejNLPH5plZqfM0apmVEnLh5V1kCeDFv6 Hz6rdUwcPYkfHFukgDhFRWD1ndcQcf+r2C2fI= 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=7WCYOfLrHUYah0W32N+CErBh+++75U0nYwKBiVHFwdM=; b=4K+LnNAayh/l/hksJMsJSRjQTK64SC1ZSTEowejs3SajtDm7mrwSy1qY6nF8n2YXNs c9le1ZbIClIvFuZmdNa9urvk2axUpZVHtu7ZtLDijT1R4tqsK0VO5gWT7KEWKTs46XGZ ho7OjtGHB+7bayBzb7bpxVLgo5xKTmLliVyErr1/MEq52oqji/+NJucw48kz4sG4xrO+ F94gzJU5CRn++3+0mNjQqHVbP8gzJdJGbKpj8rOrZnnssvl6UXmrFLahLytmL0dvx77j pXqIaMtVXAK7Ivap9TYGz/Ulb+RV6g3VzGIAGjI1M6Z2+OriZGwQz5zbNjkeoah6h9wE 7ksQ== X-Gm-Message-State: ANoB5pktT8GYjSF38eWqUEIjAToONrvZ5pRzmjoBUt1B/WVZ4FYcBu3k dYSO9Gf4yWXIZDSR40yAbDkSYvlvTvJ+MrPm X-Google-Smtp-Source: AA0mqf69wyTXrvLB2i0LLSUcAeLpBSAPhTS+dOYQYCiKSvYetS789TUI7AOj3NzQNK2LNKMf05khkQ== X-Received: by 2002:a17:902:f792:b0:186:b32c:4cdc with SMTP id q18-20020a170902f79200b00186b32c4cdcmr74195162pln.166.1670403310475; Wed, 07 Dec 2022 00:55:10 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:10 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 23/71] bootstd: Add the concept of a bootdev hunter Date: Wed, 7 Dec 2022 21:50:49 +1300 Message-Id: <20221207085137.445249-24-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 a826bd5f247..2f0bdccf407 100644 --- a/include/bootstd.h +++ b/include/bootstd.h @@ -30,6 +30,8 @@ struct udevice; * @bootmeth_count: Number of bootmeth devices in @bootmeth_order * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none + * @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; @@ -41,6 +43,7 @@ struct bootstd_priv { int bootmeth_count; struct udevice **bootmeth_order; struct udevice *vbe_bootmeth; + 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 Wed Dec 7 08:50:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713108 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=c65WWcJ2; 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 4NRrnP3mx9z23yq for ; Wed, 7 Dec 2022 19:59:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19C2D85631; Wed, 7 Dec 2022 09:55: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="c65WWcJ2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 311078531C; Wed, 7 Dec 2022 09:55: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-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 6FFB7855D5 for ; Wed, 7 Dec 2022 09:55: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-pl1-x62f.google.com with SMTP id y17so16434306plp.3 for ; Wed, 07 Dec 2022 00:55: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=B2/LMO3Ffj1x97e2DuT3sL5AmJimUbEnqrA64jfNACw=; b=c65WWcJ2sHwiURk+tEAToO9sM0MEris22bLI+VbIt18MwXuqgMv1KQ9InmKoceAJrU RW2SWmX50eXQCSWp/IW7KRtIC69617UkTb7+qsWxYm8NIp8dSoRfm6oCjHxKI8LPyslR AfcTEC+K7WZ3Grgk6NmxwuBhrOhvSfCVKE434= 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=B2/LMO3Ffj1x97e2DuT3sL5AmJimUbEnqrA64jfNACw=; b=IS2UV+vzTc5dGJaHW49Ux56LE2iuGFP4rZ6p+cOAdisL09npuDiopYrLYEx3L8wbs6 EYyIOp1i/UznFlFvDwA+Fb9UopLhdhmYWbTj3sOCy10fBCH9hTIlLinIvT4k0M8UJUF1 J6sA7qyXJFr6nQ+0NOx3THBxNQ5YmjPsM6XY7rt7WTca7hm7XdHMOHYiM2bw4sFBhrfI qwbE4hIZZSs46nOeysrwgU1OO4Diuvh6fwkQNHhX5svXD8Mf4kHRWJrQ18FIJC3oybmS UfUr7l4w33u0ZayirEEy+T+HQMJRgJo8Wp8iRKd1OYpNLZuW3fb6ap9WkOHl8FZ16IYL qOhA== X-Gm-Message-State: ANoB5pn3icHHYeiQYVQG9uxeXdaMwfmJFKskKKB4sK4k4j3sPd7Vps6Z UdmaFA3lpBJPisYUjY+X5XYjc/dFl622U0Gp X-Google-Smtp-Source: AA0mqf55hD9WBOVKMnXq7t2VK6rxjDCFmryRUFnvZVbLfX2+vDT+LzNuTL0riGeHSbQMrOosrw9XFA== X-Received: by 2002:a17:902:e983:b0:189:651c:efb4 with SMTP id f3-20020a170902e98300b00189651cefb4mr59446499plb.89.1670403313322; Wed, 07 Dec 2022 00:55:13 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 24/71] bootstd: Support running bootdev hunters Date: Wed, 7 Dec 2022 21:50:50 +1300 Message-Id: <20221207085137.445249-25-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713110 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=Eun0FAyk; 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 4NRrnj07t8z23yq for ; Wed, 7 Dec 2022 19:59:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 392C4855E8; Wed, 7 Dec 2022 09:55:44 +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="Eun0FAyk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CA10855D1; Wed, 7 Dec 2022 09:55:25 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 18AD9855FD for ; Wed, 7 Dec 2022 09:55: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-pl1-x62d.google.com with SMTP id s7so16415405plk.5 for ; Wed, 07 Dec 2022 00:55:19 -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=HUHN2Bs/P56sRSVrJzSgI5EuGHFtJIvquEJhDQmUTx0=; b=Eun0FAykpeKzyT2U4HxPophymUGWEEhLpAICmI1Qe/QdPd3OReCBh2Ns3BQrbJLwYQ rzrm5aW//RQyyrnHt/5B/3LbeyaZkY8OyB9kNKK+hjCsF951STj1Cr2elRE6laMm69/0 vWkfaIfDFKCT0nd4JlpfbiKzXO31HlcgZqOoc= 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=HUHN2Bs/P56sRSVrJzSgI5EuGHFtJIvquEJhDQmUTx0=; b=SnqVhT8l9OwLULwZqf+MbIYxQJ8hg/CfVdEFmG5T/7OF5j52NLYkjOOfhBXi962bZg 6/5ULojK7jgVxdBN49xpdv6L8JopsMNISCyAAz6xlIUBRPDw7c3BbY8N2NVUQA018sFn xBrZSkTKjnPvLbNF+fEs0urZaXk5jJUyYpwm6xEfais9gMfNpRUG8Q1JdxPs/LhePVl6 I0mk7rDmlDG25axe9ndquQLluf02FHvH6KrTA/eRUJyJv+nSJVJkaWC82MGbF4o2Nn1M FCZDkCx1pVkPxt9PRpsNrzO0ureLTLxDauWQ0Rbf7dAvCZJg2k1PT6KWlajecuVCJMnL ScdA== X-Gm-Message-State: ANoB5pm6/H/h1e97wwJw4XnE7wadkEH4WrDWd0WETkEmT/QRBAoJ6Loi keteLmJnKkEteRTYjIhswdwDWzSjJ4RKSb3A X-Google-Smtp-Source: AA0mqf5e5XPK5zz5pf+cSHJ0ZFTFAc4YzayilFOhs4eJ52czP2RHwgJ7AcoAgOrDaE/fnqBDsCPsEg== X-Received: by 2002:a17:90b:148f:b0:21a:720:b206 with SMTP id js15-20020a17090b148f00b0021a0720b206mr5050311pjb.100.1670403318060; Wed, 07 Dec 2022 00:55:18 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann , Sean Anderson Subject: [PATCH 25/71] dm: usb: Drop some dead code Date: Wed, 7 Dec 2022 21:50:51 +1300 Message-Id: <20221207085137.445249-26-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 DM_USB migration is complete this code is not used any more. Drop it. Signed-off-by: Simon Glass --- drivers/usb/host/usb-uclass.c | 43 ----------------------------------- 1 file changed, 43 deletions(-) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 060f3441df0..956e2a4e8e4 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -346,49 +346,6 @@ int usb_init(void) return usb_started ? 0 : -1; } -/* - * TODO(sjg@chromium.org): Remove this legacy function. At present it is needed - * to support boards which use driver model for USB but not Ethernet, and want - * to use USB Ethernet. - * - * The #if clause is here to ensure that remains the only case. - */ -#if !defined(CONFIG_DM_ETH) && defined(CONFIG_USB_HOST_ETHER) -static struct usb_device *find_child_devnum(struct udevice *parent, int devnum) -{ - struct usb_device *udev; - struct udevice *dev; - - if (!device_active(parent)) - return NULL; - udev = dev_get_parent_priv(parent); - if (udev->devnum == devnum) - return udev; - - for (device_find_first_child(parent, &dev); - dev; - device_find_next_child(&dev)) { - udev = find_child_devnum(dev, devnum); - if (udev) - return udev; - } - - return NULL; -} - -struct usb_device *usb_get_dev_index(struct udevice *bus, int index) -{ - struct udevice *dev; - int devnum = index + 1; /* Addresses are allocated from 1 on USB */ - - device_find_first_child(bus, &dev); - if (!dev) - return NULL; - - return find_child_devnum(dev, devnum); -} -#endif - int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) { struct usb_plat *plat; From patchwork Wed Dec 7 08:50:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713112 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=kMGIR8Nd; 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 4NRrny6CfDz23yx for ; Wed, 7 Dec 2022 19:59:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E201855F2; Wed, 7 Dec 2022 09:55: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="kMGIR8Nd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABB6185613; Wed, 7 Dec 2022 09:55:27 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (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 C6CB88560B for ; Wed, 7 Dec 2022 09:55: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-pg1-x533.google.com with SMTP id w37so15682833pga.5 for ; Wed, 07 Dec 2022 00:55: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=qZsbM0NxTF48N9RWcF7y6a8mgKso7Veqrwt0M9t5UXs=; b=kMGIR8NdXJKfyVycm9/clc68N8Ute/D+c8BKy2dbumI0uea91dQyPDoDudm9k98YkO zd7U6lHvH8ioVsuRAx29GPcJDTKi3z1eC/BjQavO+0vAv4ol/Rxf/P7JZYvmZ7RveGZU gLm8fnunmcZsUkx7GiPID21jsE7AnABwRndJM= 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=qZsbM0NxTF48N9RWcF7y6a8mgKso7Veqrwt0M9t5UXs=; b=B2bSlUxECCSQXayVfY9Q6xFbnvJ7ZsBzne1NG0g+lnhO6t/DTgpyTC2rXCmA1qFD0M mOLtsO6+1u74GhALp3ojlBU3Z0q0B2IRTQZbOdwoQ3y7GL+kNfuNYNRIMhsrYb9MJgTf 0AwXZscXMF23Sa0QVadQ9QSwvLAK92UBuY7TpWx52+tIwvoJMvPQn/6cVWpkO432kkqn UD66lZARUPnp2XZXL+aIky1tgd7yaXI3J3XaNVfbojI+zpsW/TX9VDDnGQLIEpneXM7h dF0zrPTy2b3XuNcsgIgxC2ujpYZ661PUxGE1i3L9u61KXJ4uUleXq5CuWxzvIXb7Uc/h 9R7A== X-Gm-Message-State: ANoB5pl9mM0nreOPjhlcg2ty07igODC1shi70WGcTVz1tCp0xp7uUFwO r5+33RCtKUbdHAquRap1Ep4RDWrTmgyQ5r6L X-Google-Smtp-Source: AA0mqf7lXldypD615/dGkqJ5u982Hs+/norrkKk1lGt7gUvMBEH3NPw/7Jq/AE3D0tjZF3wmnPez0w== X-Received: by 2002:a63:f346:0:b0:477:b53d:19 with SMTP id t6-20020a63f346000000b00477b53d0019mr59075712pgj.166.1670403321958; Wed, 07 Dec 2022 00:55:21 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann , Sean Anderson Subject: [PATCH 26/71] dm: usb: Mark the device name as alloced when binding Date: Wed, 7 Dec 2022 21:50:52 +1300 Message-Id: <20221207085137.445249-27-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 956e2a4e8e4..04256eff879 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -559,6 +559,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 Wed Dec 7 08:50:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713113 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=URmc222i; 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 4NRrpC6jXJz23yq for ; Wed, 7 Dec 2022 20:00:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4CE618560E; Wed, 7 Dec 2022 09:55: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="URmc222i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EFA4085582; Wed, 7 Dec 2022 09:55:28 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 C00DF855F2 for ; Wed, 7 Dec 2022 09:55: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-pl1-x62d.google.com with SMTP id s7so16415626plk.5 for ; Wed, 07 Dec 2022 00:55:25 -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=aBn+oUSMHkXMtvS1/XPEd67rm0BY+bOFGuogyJy4u/U=; b=URmc222izHe2uQW3kYV1qwjv/hbzfA8ANW1hUb7vNockp0jB9M4wsUonJrk6q2GytT bPRRZwBdxr+Q7oP9W+ErMOA6gYOs8p5tZ5mYu5X2TmZLMvM6MqNbuPmGhiDYECgKBKEi x4w+ZVqlQje+zi+OwkP+NCuNJslTsIrSAzADw= 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=aBn+oUSMHkXMtvS1/XPEd67rm0BY+bOFGuogyJy4u/U=; b=qQV7q7o8wAaFaTRrIbU0yr+Imz6SeoH1a/EBWIw1QLAfsxOkUy/Qxa3sVuzc21KsqU c/Kngphr4fxamDwfG4+hxsbjLKXolegrvw8tNy/hED+bLltq78G4tZQ655qPS2ILr+kX NPfTfBmYr+qaTh3DkQ4HlzgIBtZJJMbZvsxmGDGsrvsZngs2AUp7/G2EIvVStjeVKqq6 OYGvV/kAQgnjqqEAFUOfcu5aCPt1vlTYxOygQekQEGESz8Z9IUQf8AKApNFehusfPP2o o861Cvl1GiZuY+WqqqMfb7qq3OOq7jAUvRk974k9FmXHzNs9RI8NciYOhKcwvNFiPRxv cl+w== X-Gm-Message-State: ANoB5plgfLPdXpof4C4o5XWUzoqxRNOmf7+btg+hcBHQtGno9yRlO1U3 Og4LZiYYns0raC+QvfrY6A2ETqHi+WjBQK4n X-Google-Smtp-Source: AA0mqf7D6rC0WcU1KHJNx3PkY6DbM+LWbX8zy+sCeSHGbrWnELul0qNRsi0C9M5ugXMKKAxigpNPdg== X-Received: by 2002:a17:902:e394:b0:189:6b31:dc48 with SMTP id g20-20020a170902e39400b001896b31dc48mr56361952ple.67.1670403325117; Wed, 07 Dec 2022 00:55:25 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt Subject: [PATCH 27/71] test: Add a generic function to skip delays Date: Wed, 7 Dec 2022 21:50:53 +1300 Message-Id: <20221207085137.445249-28-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713115 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=fm2nwMAK; 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 4NRrpS4Rdtz23pB for ; Wed, 7 Dec 2022 20:00:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8AFF285658; Wed, 7 Dec 2022 09:55: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="fm2nwMAK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F137855F2; Wed, 7 Dec 2022 09:55:32 +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-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 F3F84855BD for ; Wed, 7 Dec 2022 09:55:28 +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-pg1-x52b.google.com with SMTP id 142so258606pga.1 for ; Wed, 07 Dec 2022 00:55:28 -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=6/l+FTg568SOj+veAiv5wsm1+jNCWJlyS0vS1TFQesg=; b=fm2nwMAKeEOtzBaKNo7lU8v2QxylEzh+32QAbVsgF8EnLoqXSbA+rSPe72BVqx4ReR 57VyQ4ZatN8H6qkEz0HwEHzpkJRm4lEZp4MoH2QxRAhan1124nf1X0I7DbbwbSVraVhi gCUpIeA0EOq40A8H4MYccy5as0goIbpFdlLZM= 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=6/l+FTg568SOj+veAiv5wsm1+jNCWJlyS0vS1TFQesg=; b=uIH1AKqaHzebeD3KX+uYD+/maku8huv16Uaoe7qxFwhS+sIsjcCSHLrWXrr3o8CrQu t0KfXTfXYmqkaGS0VN5lgEZC2MNZdDT8p88+AjmnvtnLSGGgEJTLKbstHYYoTNMc9+pQ obNySGFFNueR0oqRBwOu/xldR5Mw8GJVErFFtZOKyt6vLdzNwmOQcRRXXt4nyaOMAFST mCjcU9pdl4pD3vTKsceYSA4mh+nigto/+kRo+m+/q1j4ljRxnht5fNa8x772JY8454Uj CRS1rTiLJ5LELZfEkizk3pzG6s5qIF8K8n/oAnZKl1vyIVfDaheFYQn8AQPesDIYW40h ZHBg== X-Gm-Message-State: ANoB5plolfjYtwycwsr71XgSDZq9dtBAAvao65WX6gFcubuXBMrRBNnu I/D56b00ykMzB2n7jxg0PzOr+kvKc+C9Q/QH X-Google-Smtp-Source: AA0mqf5YNt2/eQ3SazUhSXBdS4mZDuUfaXMyKs4it5OOd66DeGp4wqbQ7qJ1DHz2IJzD9BUoJM6XWg== X-Received: by 2002:a65:64d1:0:b0:478:980a:53fb with SMTP id t17-20020a6564d1000000b00478980a53fbmr17631281pgv.484.1670403328317; Wed, 07 Dec 2022 00:55:28 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut Subject: [PATCH 28/71] bootstd: Add a USB hunter Date: Wed, 7 Dec 2022 21:50:54 +1300 Message-Id: <20221207085137.445249-29-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713116 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=B6dmFOeT; 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 4NRrpk10pNz23pB for ; Wed, 7 Dec 2022 20:00:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2112F85665; Wed, 7 Dec 2022 09:55: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="B6dmFOeT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7D6378560B; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 B3E1385623 for ; Wed, 7 Dec 2022 09:55:33 +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-pg1-x52f.google.com with SMTP id 82so15729566pgc.0 for ; Wed, 07 Dec 2022 00:55:33 -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=LDpZjSTsGRor8JT+C6tM5L5Z0CN291tn5zP9IAS7tig=; b=B6dmFOeTndqsHio7ZRRmGZU30KxaHHwal9d6ob37M+ZlbzT/NId+YDWfSqcz2qaI06 FTuM1e3afzZE5W175iutbT8MNARmeaqFxDLlofXdl4Y1DaAVsKIPSXfvLQ2qLNaKvdbT DG7BQBTKl6vx8kvvZSuGBlcdN7yeQVdwiR6/E= 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=LDpZjSTsGRor8JT+C6tM5L5Z0CN291tn5zP9IAS7tig=; b=dpQxPv+SybwYxfznSX1vqooHsQtGxyohj/xqdaPS0BG+v8UGtJp35x1t+nyPIm4iNa A0yLcJ2AX0m+p+o34mlOiEeCIS8I+FPZdMIHYSsRqI0OX1b/pKsrRIu3FXb8FLUrydcH tM4lT1yh9qwoUReoBMqND4T6aYtOdBa+YTN5xxR6KpNlrdsr0f7DDRtSFiSJ1qvaljpp TVjoD0kCsnviNb3ilqcElGFPlpjlfKXYBVm3jcpubCFGP22J/xfKSrXkNAObNtVcKtj6 FUIF0zG1K2L/oHnSFk0TcpIwcZ+z6cPicW5U6HgzcbhLJoXq+qzixll8NlUFuU+VrOfS BKbQ== X-Gm-Message-State: ANoB5pml89O5rBKwTUrvTQrbsKKUvgjnwJm7ly+oREB4tTU5c4cwOQO0 LPEnGxGePxYAbTzzDvsDFvzPvZ5bYOMu4+w7 X-Google-Smtp-Source: AA0mqf5783ajPGP47pWyJAzlnCkXOX7ZxZF8FyRGpxEJtRjyJhx9Ow75bX0tjJPXl3UY7Ol9mlXUPQ== X-Received: by 2002:a63:d84c:0:b0:478:6bad:dc4 with SMTP id k12-20020a63d84c000000b004786bad0dc4mr27482699pgj.405.1670403331885; Wed, 07 Dec 2022 00:55:31 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jaehoon Chung , Peng Fan Subject: [PATCH 29/71] bootstd: Add an MMC hunter Date: Wed, 7 Dec 2022 21:50:55 +1300 Message-Id: <20221207085137.445249-30-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713117 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=P5kC+b8X; 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 4NRrpz1qfQz23pB for ; Wed, 7 Dec 2022 20:00:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B22FB8562C; Wed, 7 Dec 2022 09:55: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=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="P5kC+b8X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17EC9855FC; Wed, 7 Dec 2022 09:55: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-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 EF20B8557C for ; Wed, 7 Dec 2022 09:55: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=sjg@chromium.org Received: by mail-pj1-x102d.google.com with SMTP id o12so16936484pjo.4 for ; Wed, 07 Dec 2022 00:55:38 -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=hq8oUI6O1HwdBfb6jjmBIFN4xdzabjPe76CI3LkaQ5Q=; b=P5kC+b8XT2d+fmaPXYr/6T2dTEoA9Pekqz8nWZaLBnas2hZkPdzbTyldd8bMBbZpkG BeEuq5DpU5SOcr4t4+zdFVCLaEr4DMiCUnBEtCXl9d99A2EKOgv4gyAzK/efKjNhSb59 U0dY1THMfd6//ecOrk51oadu27tUlGrdWvdkQ= 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=hq8oUI6O1HwdBfb6jjmBIFN4xdzabjPe76CI3LkaQ5Q=; b=zsQ1t/+xuXXFJiX37QkAB6HUWzbUg7jS49DWXVMXMXau2idu+n+mqsSujb76G7fnoN VdGeuKa/xW8r2xcTnZH27Y/gteGoaNgwR0cimzrlA5Lq78vN8GrAVxk6KDkC4i06+5OY zHWcE423tnzdDwDyXkTTFTtMAi9SCgQlJQeJDZyxhDIaLXiYvPOqXZtCNibe0qYGlCgT wXSs+s8wvBioa8HMOvDDLvjeMzc1fFx9uvTLP5xs80wJxGdQeOrnyOOwx9hHXHVs/fLx 9B4bnyTl6nLiylodk3cUtnQrZggLJsQvGjF7NiC/vf+sWUkRTvFp1gvFb4necwI2GJl+ 9ntg== X-Gm-Message-State: ANoB5pmZhY0ekMiY3FrQwQ6dO14fc14aBMgGplJEuzgpuZSQvidmc/0d G1zDptBQotCSgYqsfmoFmu/q1H+oP9SOJ0XX X-Google-Smtp-Source: AA0mqf6+DFxq/jtrueT9Os7LRtSEsvHJkisqUbfijPKm4mcDMR3HDsIuz/oMOYOGMDz447mEcz1+PA== X-Received: by 2002:a17:90b:33c8:b0:219:94b2:2004 with SMTP id lk8-20020a17090b33c800b0021994b22004mr23607894pjb.215.1670403337115; Wed, 07 Dec 2022 00:55:37 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Heinrich Schuchardt , Joe Hershberger , Ramon Fried , Samuel Mendoza-Jonas , Viacheslav Mitrofanov , "Ying-Chun Liu (PaulLiu)" Subject: [PATCH 30/71] net: Add a function to run dhcp Date: Wed, 7 Dec 2022 21:50:56 +1300 Message-Id: <20221207085137.445249-31-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- cmd/net.c | 35 +++++++++++++++++++++++++++++++++++ include/net.h | 15 +++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/cmd/net.c b/cmd/net.c index 0e9f200ca97..6b3774bfe7c 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 749f20fa967..c296d06c266 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 Wed Dec 7 08:50:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713118 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=niR4C3Dg; 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 4NRrqD0rJRz23pB for ; Wed, 7 Dec 2022 20:00:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4DF4185684; Wed, 7 Dec 2022 09:56: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=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="niR4C3Dg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A50C855DA; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 4892F85637 for ; Wed, 7 Dec 2022 09:55: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-pj1-x102d.google.com with SMTP id u5so7578834pjy.5 for ; Wed, 07 Dec 2022 00:55: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=MkDBlFgaqY+URAjq0Q/Ycuc7O693r43LnKaFUxjg0lM=; b=niR4C3Dgy+XY0X9m6OP4W3iAflhfUGreusH2gT57I8Q9XA8q0k1NHvDDrZvIIL8ugt XVZSOSWgGIItKSSBJjvZFii2nGIeGTqWNXNDCziHDK9tKEMnenAvvzSchcp+twgzzGig LmibhJYHW8Mgion+HtaXcGoGlIfI72Y/qsf4o= 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=MkDBlFgaqY+URAjq0Q/Ycuc7O693r43LnKaFUxjg0lM=; b=s6jlMJ7CvX6NiR59cOMbuRq6u5dnuayaTXQJKH2Fa+bOUT/9c1rlGJK011uzGm2ppU HOQoVehrt8ha7pBbcB4rZ6hZN+4QX8Hh9HP7i1OjfjS6VQBdL+9aGmcJVsPPMH3iPas9 Krr+I8mY2NLZ/yz8DAzpJ9gKR9nq/cWg39E0hy4ncgGfnM8XAlRkdKspugAggGXwH0bl ULrgyr3xu+nEXuf8e+DpvRuSOR8NJBbjx9gqlu3FBwruLm8rEdjftt85KyJKUcpHZYzB 3vnujiCIZAHTdNEgSXwAXKPQMqCrZSTJ247aDa2ANKIIDBp5Vh73fcVf6apATC5/HIjk qscA== X-Gm-Message-State: ANoB5pmOTIX0Qn9IMampuL75K4JHVCAPGZPXYQ3Nlr9ynz0jdMEkfnL8 bvKCZw2H+dClC4//zf/RUaPZsSXnn0obNuqf X-Google-Smtp-Source: AA0mqf6gP1MZFaPnTI01bGsO8DLej/YEAnJDBmuoeY7mzVvMDJKiallguSVlAbM6npAFh6RlQW+wug== X-Received: by 2002:a17:90a:f298:b0:219:a032:1760 with SMTP id fs24-20020a17090af29800b00219a0321760mr21472322pjb.88.1670403340615; Wed, 07 Dec 2022 00:55:40 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Joe Hershberger , Ramon Fried Subject: [PATCH 31/71] bootstd: Add a hunter for ethernet Date: Wed, 7 Dec 2022 21:50:57 +1300 Message-Id: <20221207085137.445249-32-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:50:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713120 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=RVy0+xyo; 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 4NRrqj4yHSz23pB for ; Wed, 7 Dec 2022 20:01:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8EDC085659; Wed, 7 Dec 2022 09:56: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=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="RVy0+xyo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B49918562C; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 3EE6C8564D for ; Wed, 7 Dec 2022 09:55: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-pl1-x62f.google.com with SMTP id g10so16405587plo.11 for ; Wed, 07 Dec 2022 00:55: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=NbR1YxwkPTWBFo+cedft1V+SLEZvVUBzMC0KN8zMuds=; b=RVy0+xyogry13Vv/kGSQJhnBthXBG9XLAi1uOxjPhCNtjWoAg3w1H/OY+8cDHgU5Uz Jk+VKHG8OAQyRm6HigZvCg0uE1/xxBqUTzk2X/v0+WLkJtA0JkSK+/7ku42L6Uu0Ob+e hajyCNThqz/PszbMy0/I39APv0fqgaKFSH7B0= 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=NbR1YxwkPTWBFo+cedft1V+SLEZvVUBzMC0KN8zMuds=; b=YYqdf8q+yKhB88La1rfMOPubWvyOlImRff2Rm1uN3p8Jdzh8zqTJpp8/+58APuUjWX xNHA18rmyoV19R1ZAvO5UqS5pYTEhIrObC+IG3SUEbMQ54t7xOvIHvOmq619opQ/mIjW /zktZVg82YQPvmTZn/wQ46wzgvd55m2geCtGCk+ZRmof3yyHkTWjboRfD6dakcD4q1Og LAun16XWuXPBp582WUslXdyhH5FEcSSWKHH7JgYkVTF7VMpECzYZWiT1U7vmSBs15vIO yM3AGBDG5G/DIhJzSucyW9jqsMJXjZoyIpLb8AOq3Mor1/SUPEhLs4C1Gk8jR+Vhx/Tw xeIg== X-Gm-Message-State: ANoB5pnsdVqZ4QKHikHOUHTTnWB4V8jzhCyzFb7AOT9TeQzd9nmIlb+T QZNlE0cmlkhrRnQrnIO8z18k7Dx72BQ4MS+e X-Google-Smtp-Source: AA0mqf720MZYc64dtyLMX8BgatKbNT8rL9vGnHinu+xH/z4NkPDnfCq/flMMtL6t42oqYeE758Nycw== X-Received: by 2002:a17:902:8307:b0:189:ca4e:422e with SMTP id bd7-20020a170902830700b00189ca4e422emr18360705plb.75.1670403346268; Wed, 07 Dec 2022 00:55:46 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Heiko Schocher , Heinrich Schuchardt , Marcel Ziswiler , Oleksii Bidnichenko , Philippe Reynes , Sean Anderson , Stefan Herbrechtsmeier Subject: [PATCH 32/71] part: Add a function to find the first bootable partition Date: Wed, 7 Dec 2022 21:50:58 +1300 Message-Id: <20221207085137.445249-33-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 aac14d30673..54649f077c7 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -305,15 +305,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 Wed Dec 7 08:50:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713119 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=I1I8LtP9; 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 4NRrqS45XVz23pB for ; Wed, 7 Dec 2022 20:01:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5696D85645; Wed, 7 Dec 2022 09:56: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="I1I8LtP9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D18C1855A4; Wed, 7 Dec 2022 09:55: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 0B0B885652 for ; Wed, 7 Dec 2022 09:55: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-pj1-x1030.google.com with SMTP id w15-20020a17090a380f00b0021873113cb4so958605pjb.0 for ; Wed, 07 Dec 2022 00:55:50 -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=FmQY7i5s8e/a8UF/BwRY5mJj64t77ByAXTKC5A7TQBM=; b=I1I8LtP9dPddAqDBnGA42uz5HMNtSMIq+4j1H4VAd7utA8sq7+FDvKRVB9w5jL1ugE Krr5XIFGSRAZKT+9YtS1wlzlzb4j00FEDzvwIzebn9CoLyu/ZSwu7DJWZFZagtK6XMI/ 42GucgSz7M1ob+7dVF4aYLmmGS2ZfJS4x95uQ= 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=FmQY7i5s8e/a8UF/BwRY5mJj64t77ByAXTKC5A7TQBM=; b=gd2RSQwxiiQW+upfgEZIJGD4pmLJM16KK5kyuRKmcjBYD9EdBsZu43tsPzvMJN+fLH vVvgZpi5/61fgW8a8NLEm0roTl5pgMbDvlPFBoWeqIfiatd56kq0JZGGqQQ4taUOL1WB UpUqkAA8aWkdAWyoCIklmhqOptmwFO6wGj24w6hr+ICMocqv7f4ZXBR7LX3CDnTZM6W7 maNGLZFVji0GqRKUttgeUrDMLMEmkbB9ukVbpD6JgGJ4cydUcf5tSY1TS/U/GEWj6ELz Mc76apKOOTtzlRF/o8K81G8labu27GJf8t/FhAtGEkUn6hkdeboVWuaKhQ4sZKPeVraD 5/nw== X-Gm-Message-State: ANoB5pmKEvQ+yPtx9hpiV9LNBAGbvN780k9JR26KpfQtGW8HD4L+N3CW A8FLKkzL2h9Zlyaitq6bPaT+48mbBvDLBJSQ X-Google-Smtp-Source: AA0mqf4LHnzbt2FVnbjQxWiU6pO0WPmAPlEqELeoLdpDlLyW+yn3UPzmkqLrxkapTwRn8Oqa8hESPw== X-Received: by 2002:a17:902:7682:b0:182:6c84:7ff4 with SMTP id m2-20020a170902768200b001826c847ff4mr81789705pll.25.1670403349158; Wed, 07 Dec 2022 00:55:49 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 33/71] bootstd: Only scan bootable partitions Date: Wed, 7 Dec 2022 21:50:59 +1300 Message-Id: <20221207085137.445249-34-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 32dbbbbe261..7d50ca2a45d 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -112,6 +112,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 @@ -133,6 +134,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 54649f077c7..9e9a3e4061c 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -306,14 +306,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 Wed Dec 7 08:51:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713121 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=gbFwxoxi; 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 4NRrqz5x9Tz23pB for ; Wed, 7 Dec 2022 20:01:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A0D985694; Wed, 7 Dec 2022 09:56: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="gbFwxoxi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3ABC585674; Wed, 7 Dec 2022 09:56:00 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (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 DA13885608 for ; Wed, 7 Dec 2022 09:55: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-pf1-x435.google.com with SMTP id c7so13580371pfc.12 for ; Wed, 07 Dec 2022 00:55: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=XWDVSlMjygoeFag77MzG7jDEtkkBkoIEhAlWoyQoWW8=; b=gbFwxoxivw0xiaiRCV/woNH7TqkZvLZ2VYxE/cxPKpo1mkpMARszidGM/x3XaKA76w Jd1HVdxpfM0DqkKTaQugTxE/bZqK+jh4BOc6JFq4RSfeWyupCpAEyKdp/b2gqVfuJCzg nPsbCZKCD357fFC/fzbvK9gINfjG/h3zQS3Lc= 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=XWDVSlMjygoeFag77MzG7jDEtkkBkoIEhAlWoyQoWW8=; b=qZxOEqABEPOzAjpzz6c4VpCEP2BnyIHLwoTTFCL0Q6nt524NVhAQVpN9Jcr5deMBuq j8w+ANvuAdVCNtMAFtrhc9fTHwsXs1wO9+zzHCDSQMzbmDhATpucFpEgqIml4MykvFDW rvu4p8Xf+SsooRABXXcgL6+iKpYj7toFqLTymK/jNd029hdmRDapC1EzueU1lX+sHvD8 f38fFZpD4iQuPg7OPm0km3HMrF8jH9eewGq/4PaJq+T+5KLY+o1ikA5gRiCsphE1z5yU Tf5DjT3808mPRk5VNreZ62NDsWdTgGxkalE8agKy3w6bdLfgZsUN8E8X0TijqylU6xLo lq5A== X-Gm-Message-State: ANoB5plb8UEN/8YUjq4DoqgJRwdNbAwX1UuHmsFklCfNwg87PsuaG33L bPNqWF+W8C1H4jRXO0WUa6h4qasPj9fwlSf6 X-Google-Smtp-Source: AA0mqf6LLPu6YHW3tBkc6dujHHzVOSjWAl9mBc1ku5zuAppkXn6MdCO01v8ZfjbF20+6N5Fd7dPE6g== X-Received: by 2002:a63:f90d:0:b0:477:7f9:aecd with SMTP id h13-20020a63f90d000000b0047707f9aecdmr69921802pgi.242.1670403353055; Wed, 07 Dec 2022 00:55:53 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Rob Herring , Stefan Roese Subject: [PATCH 34/71] scsi: Correct allocation of block-device name Date: Wed, 7 Dec 2022 21:51:00 +1300 Message-Id: <20221207085137.445249-35-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 3e769b0843f..6419f4be210 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 Wed Dec 7 08:51:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713127 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=ko0iIk5M; 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 4NRrrn1X71z23pB for ; Wed, 7 Dec 2022 20:02:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A1FC85670; Wed, 7 Dec 2022 09:56: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="ko0iIk5M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6095585608; Wed, 7 Dec 2022 09:56:02 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 CE9AB85652 for ; Wed, 7 Dec 2022 09:55: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=sjg@chromium.org Received: by mail-pl1-x632.google.com with SMTP id jl24so16419798plb.8 for ; Wed, 07 Dec 2022 00:55:58 -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=xtIU8RUfT8cVHzbarhsyLG9Ageo3osY8iBUgffqITg8=; b=ko0iIk5M6mzSGgeQKDax3B8pQsONeYtTmpVOOZjwUiwa0o+eMJzLAAHHD6suRyznHX Bzd8yvTzjX0hFGce4O9Yo66U5Lo2xSqIu1+xS1EpOXaxMro0WcoUb6qChZeYHs8HDx/A ctLjqhVFakxQadjD23uzlr+PkiIUCLXhdMgiA= 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=xtIU8RUfT8cVHzbarhsyLG9Ageo3osY8iBUgffqITg8=; b=6/Wjl9MLRIiJ1cN5yaaRdiXNNh8/dOhNHy9Sw8byHuMO4H8/xFNiEO8nOA2kQ7g7Rf zvU2ktb78aIc0Fs3OIz8FHoTMsRHAlSF3Iv60/CWyhCgwfKn5C8CiqMwkmey1aEu/slg kt5scKFEFFm7dfhu17M8Eu/s1x6AbxZNt3YACvXHE2TPqdhN622TYRl0zueXu/5mfLVs T9ybG05LHO3BHKU8dz9jmyk3o3g76LLxQCGOUj2AQoW+Re6De7Y7rrhWWYr+AXZKvtIm SNUatqtWrcdDmCXeBvRY60vn0dpU37ktChjc/InXFJ7HjN0Ou+Src46ftESS0uNVko// Tyxw== X-Gm-Message-State: ANoB5pn5SoaBOkmpCHy+9gAYMUhb8lT9opjzvnqJyu0Nt29NZ97rI0NB SFZMhdABH47ING/ULrUCMOEbCsQkNsCIBzmW X-Google-Smtp-Source: AA0mqf7fqkCQRGE5YanNn8GgjDJjyELZ/zF+hX6Z/XQeCWn3fUQsMEm8t6I07pgATl2sFfV0OHlLiA== X-Received: by 2002:a17:902:8d98:b0:189:8e39:3c88 with SMTP id v24-20020a1709028d9800b001898e393c88mr47246063plo.102.1670403356968; Wed, 07 Dec 2022 00:55:56 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Rob Herring , Stefan Roese Subject: [PATCH 35/71] scsi: Remove all children of SCSI devices before rescanning Date: Wed, 7 Dec 2022 21:51:01 +1300 Message-Id: <20221207085137.445249-36-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 6419f4be210..2ae96e171eb 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 Wed Dec 7 08:51:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713129 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=koLS3zTB; 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 4NRrs024Pdz23pB for ; Wed, 7 Dec 2022 20:02:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F1B9B856AE; Wed, 7 Dec 2022 09:56: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=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="koLS3zTB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E24785645; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (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 648CD8556A for ; Wed, 7 Dec 2022 09:56: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-pf1-x434.google.com with SMTP id 140so16957051pfz.6 for ; Wed, 07 Dec 2022 00:56: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=OLPar2FSoTjcKOnFLbHOrC9ZKtN9/yDZCrHOeK4J6e4=; b=koLS3zTBNWoiPwmhodclMcMtUkqyZdcFcbi1UGrc66GZ2u32PZWOP0Nk7Su5IBguAQ hdiDrDuJfZHmW/Oe2F2cJXFayNvNthM68qdkNhw/y/FK91pOgD6Diyk5gcZrMxxmgSwR S0aI16H+wICTspyXqbgzpxVGmJDE+JMKJ7tvY= 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=OLPar2FSoTjcKOnFLbHOrC9ZKtN9/yDZCrHOeK4J6e4=; b=bl/aXMEBNgBfaKxJA+x01gw9FlzPZrPcz1dT+vPbjsQdSp8FklJLBw+Vo/seRdYqms flm2oj4Jzq3SpljEvf9ejnt3jWhbTVsiaSI2+XPMJVjw7siF72coleLns+zDCGnZMpDs wLlRdUoStLs3P3j2wyQbWx2bmpplGb9M1XjzN6+qSQr0lbc9WyLsiet765WVZYW0fC3O fkAssLleNlgW3STe6agc7axKApiMdocsKliYJugo1vKQnNXVHX2D+qDUjym7mHH1Ic/z Rz8aYQ+UyTXt0NlyWdaVATwm1icXzX/cIwwBvKrMOu+8fVtygNiAli0/ZMGQSVxwDMGQ yZqw== X-Gm-Message-State: ANoB5pk5TePOgyPljGp8jIfPxEbQmkh1i2dEi+H7hzEgOXaZPB8GefNa xXIzctplCUVFn06Bn/zO/iWEySUZpZHNPpq5 X-Google-Smtp-Source: AA0mqf7tB4z3FuJ29I/NVtdPtXq1ZH4bwbCtmIK7aAXI8YNMxic3bFruRiVarLtgnhqHatzy9hOqUQ== X-Received: by 2002:a05:6a02:187:b0:46b:26a6:51bc with SMTP id bj7-20020a056a02018700b0046b26a651bcmr81389595pgb.204.1670403360536; Wed, 07 Dec 2022 00:56:00 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Stefan Roese Subject: [PATCH 36/71] bootstd: Add a SCSI bootdev Date: Wed, 7 Dec 2022 21:51:02 +1300 Message-Id: <20221207085137.445249-37-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 2ae96e171eb..8d6af2a5068 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 Wed Dec 7 08:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713130 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=GXI0OJL3; 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 4NRrsD1mRDz23pB for ; Wed, 7 Dec 2022 20:02:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FAF4856BC; Wed, 7 Dec 2022 09:56: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=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="GXI0OJL3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E093185674; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 EA240855E1 for ; Wed, 7 Dec 2022 09:56: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=sjg@chromium.org Received: by mail-pj1-x1035.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so833500pjs.4 for ; Wed, 07 Dec 2022 00:56:05 -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=bOwEydbBVxuKzteltpntbUC9xf1QUA9tM3t19ck5/64=; b=GXI0OJL3E1I+KU15QQ/eL2ygNag+rOKgPzWJ+JcDxuk8QaDdr2novK6IBEX0C5VlPe kTKJvjl/+SxOqBtllDyDqeZS6S6ldtX6pscRSXEGoa5wo9pFhymoDgBqCItr7pNjWG28 qYIQiq1dbYj/ijWjO+zjcKfYNxviCAoWzk3k4= 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=bOwEydbBVxuKzteltpntbUC9xf1QUA9tM3t19ck5/64=; b=uoVRI9WiILaOb2qpJCfkb9cs6KC/XH9+IPZG75Ifhay3zKov3ufEXhLQG/+Hd+AFaH btn/vD4qPNn43fO4y50X8ZkBoh7cRT4/KbuzX4R8HAme4EP9Om3zBj89XpA1yOE3CVcw S9b/9pfCXUthh8QaE87CJGGoxLvKBm9wt9CsE3hUXyS6/cOTPhaJgdimUV8nrHkF2zZi 1s5kxbG5IehBFjBFR8WgMVpBbZnJUOsm+dG8PRqM3I7eK/xrUJv9AoZ/j9bKBdl1DrdA OFC9k4qSLqoNN5wWwKNbrfE6m7WUXLtHRP9UuBp/3gq+UOV2PnMgPhks9SzsqOPEWrfT yZmg== X-Gm-Message-State: ANoB5pmlek7dnzI4+V4DowJ2Aqmya68wkrPzvGSacwBh+OWmhqnPu8mi MdzmMj2/nN4M+QCY88YGUEznvXzYhrp/Vi55 X-Google-Smtp-Source: AA0mqf4wUCfBIqpA10AInuUOBtHnVPZOl7OepmDufpZcDKDSSIYCCtG3hNUG9c3jrbhS1eNt5ZHldw== X-Received: by 2002:a17:90a:5d08:b0:218:770c:9a40 with SMTP id s8-20020a17090a5d0800b00218770c9a40mr81944386pji.158.1670403364062; Wed, 07 Dec 2022 00:56:04 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Stefan Roese Subject: [PATCH 37/71] bootstd: Add an IDE bootdev Date: Wed, 7 Dec 2022 21:51:03 +1300 Message-Id: <20221207085137.445249-38-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 df41efbe9ac..ff4e6a46cc5 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -39,6 +39,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_OSD=y CONFIG_CMD_PCI=y @@ -87,6 +88,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 Wed Dec 7 08:51:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713131 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=JT+cERks; 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 4NRrsV1b2hz23pB for ; Wed, 7 Dec 2022 20:02:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F2FF85688; Wed, 7 Dec 2022 09:56:22 +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="JT+cERks"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0BD285666; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 24D4D85670 for ; Wed, 7 Dec 2022 09:56: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=sjg@chromium.org Received: by mail-pf1-x42f.google.com with SMTP id x66so16970455pfx.3 for ; Wed, 07 Dec 2022 00:56:09 -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=JR/l7x7AMBv3/2pP8lRfMSxgFltG+2+oWUhGoTu4lcI=; b=JT+cERksqQysoZ2Y20u3bn+sxWqoLT/jgjQB8QTrIXMTF3EiPMCP//ckQWxuuLbiSO D777Ppb3eZbJfImFXi5NX7SN0rj/ojFJ4HZI/S/yuaHY8zB0m1MJZ1BU7vvwNugcKFWy CSJRSKMHqon2PKeTDyB+OEVVY4vMrDL1KrNyQ= 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=JR/l7x7AMBv3/2pP8lRfMSxgFltG+2+oWUhGoTu4lcI=; b=bKezyGme+i1+kKNACKigU3PV+4D3HXeStEDijpL9PehoFEmzWbZsDBn5lPOczv/P1k rM9wFtv4A2ZrOaKHalordK7OmZkEUUOexf3mkZULADVxoCdt43cedsOni6czGOVHfDYA FhQzLD2VwX0OSii+sc1cQHYUh30HxwWDhRsCJpUnpIUbIb7wciI1pZi7wKnGjr6+J/bM 12bvHYihr89SPU38ancUcEKzMDv6n7QjBOcbRoaAF7LqrmZPYiRqiObCwH9eWOk93rfJ lSWexji7fVHbd+XQHuzgZROLs2w4bbCBLo38hqCBlNvC6yorBfU0lPwlGtAh+xCJXC2Y LRrQ== X-Gm-Message-State: ANoB5pkAvtIsMI6YbCZZTWRmbWxURsekVcJGE4SB1uPyLcpeQO6be9CV VDSdyFkf+o9hBV+zfXD5nAbngAx/v/4mvDpn X-Google-Smtp-Source: AA0mqf43eUn2+QGpgADRqJ+YLga7dHzGxz5+eu4E6PC5OsBzaSH0hmnBdojw9BPpaVupsXCGyJm+/Q== X-Received: by 2002:a62:be01:0:b0:575:caf6:5cd8 with SMTP id l1-20020a62be01000000b00575caf65cd8mr34925398pff.22.1670403367281; Wed, 07 Dec 2022 00:56:07 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:07 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 38/71] bootstd: Add an NVMe bootdev Date: Wed, 7 Dec 2022 21:51:04 +1300 Message-Id: <20221207085137.445249-39-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713132 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=O2lShDSS; 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 4NRrsm4MzJz23pB for ; Wed, 7 Dec 2022 20:03:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1D59856C7; Wed, 7 Dec 2022 09:56: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="O2lShDSS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7AAD185652; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (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 3BA1585674 for ; Wed, 7 Dec 2022 09:56: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-pj1-x1033.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so935840pjo.3 for ; Wed, 07 Dec 2022 00:56: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=OVPBAV8cepJ5DONYQsKJq7Zw2wNGGRTYUKtLMCXGqOM=; b=O2lShDSSwO7wOZ6oE46RGqbeB3twIAFwH/xWfmKOYi90Bw1KTgG34JS2MxS7eIZYrp BCvzNk27slC5pF+6KbUkBcmG6m7EEu1xVaDVAHQblk7Fkn/o5eAFDv8Z60QbXc6WLXPS DoK8OfGRoFphhu6RPvdDU07GjSJjwy9kXNJrs= 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=OVPBAV8cepJ5DONYQsKJq7Zw2wNGGRTYUKtLMCXGqOM=; b=Xm6FxY1y1A3oRQ8wAFy7k8+8mNzRjkh3bvixtujcR/9yVerTZVPaB9/xX0laucKPjs OwamCw2qzZuBpmnMqib+Q6DaOjyWlrcVtCr0P8mGy3+FfErHvlC/PF7GzbT9u9fpIvxZ RbLJr9H4iPKJXDWQSJ1ueZ6DPGP9OJRaOM1LLefyQ2KSqvGguJrxlx9edggQb+yoyBN/ Q+tsx3I+hc9f2Sno9wY8n4JwsbyEm8CatXjjLwqPrAf9rveHEInsx9Omq3VxNvTf0Ey+ GLvJjla7PEH8jk17c4RRl3adDv3gr9MrVOoRNhHTLbJMCurMiXWR4idg/KWpxUbxm5tO 8r7w== X-Gm-Message-State: ANoB5pka07747/TCx1i10VMx/cPchJPv6XWT7My/Bma1CBcttO5H3VHc jkegqpY4YLTj0EPw03nrHcj3mDxl01OO2Kya X-Google-Smtp-Source: AA0mqf45TW4oIZ8r58xZs8BCFxyITER5GPSBIhSMIkf8c8Uwt2c7NwNKgJezaQoHRsDQZp0xFz8jDw== X-Received: by 2002:a17:902:b40b:b0:188:ca57:ce0c with SMTP id x11-20020a170902b40b00b00188ca57ce0cmr79315370plr.57.1670403370415; Wed, 07 Dec 2022 00:56:10 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:10 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 39/71] virtio: Avoid repeating a long expression Date: Wed, 7 Dec 2022 21:51:05 +1300 Message-Id: <20221207085137.445249-40-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713133 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=hVo4gsUN; 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 4NRrt21PMBz23pB for ; Wed, 7 Dec 2022 20:03:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 09115856D1; Wed, 7 Dec 2022 09:56: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="hVo4gsUN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 36FC98569E; Wed, 7 Dec 2022 09:56:17 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 4DA8485670 for ; Wed, 7 Dec 2022 09:56: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-pj1-x1030.google.com with SMTP id w15-20020a17090a380f00b0021873113cb4so959525pjb.0 for ; Wed, 07 Dec 2022 00:56: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=IbAa2HavDZ+lM9TgNiRF7jy/JSNJmaDn8LsVhphFzb0=; b=hVo4gsUNb69ETBaf8E1bcNbYSb66tAtpJBvHG09ZgS+jlwV19fOrn/HHDU92cy8yHb bMY7v1VZB8aMAeNVhwwUK5izC2yCfmrPFexKXeIZ3aY4AV1RfePya+Opo/QbgV7y319W LcOS58P2nKB9AC4MEz2xcIQCfs+BsSERooYBA= 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=IbAa2HavDZ+lM9TgNiRF7jy/JSNJmaDn8LsVhphFzb0=; b=oTKsl44RAIYFxXIU1ax16qnZr8qwdyFJARmPqhH36GQs7mf0IGx9+wI8G+EAzbYjsq lujI2pf5iPF+2zRFJ4adFcqoFABJ+98YkmnTKNeKlf1/V1OIv392jHagV+4HGkCY9p9z pJmY5X6/z/w6epbq4jEslNZZDnfgu3QUo9eLl6I80TbzmCBH1Z9Lp8BMwsS9JTE76gsU BSzeFK/PYaTW1LXNCLHRsjiqjhCbS8LAz1tm+5thfKRRhLRMdD74eyPG2jB20YWYkG1D GBRlZvpbZ9xL1sFMiEcFEuQ85/SFh4RRt/gWRflDLicjR0aJ361LyH7GS31slazAognf Ccjg== X-Gm-Message-State: ANoB5pl3aWOCO1fOOHB4lTMOIYV+LuMj9S7V92BCfiL/ybbxDX/mKjFB 5z+RE2vqOJW5BCMf0o6l6NGlTzkQ2+iT4+Gd X-Google-Smtp-Source: AA0mqf64d71Gs0rgTHYuLw7LBT0ALS61mZr6XnXGdL38tuklxNP/7+SQnq7Kkv5eWEuNIM9+MnoOcA== X-Received: by 2002:a17:90a:fcf:b0:219:861b:b108 with SMTP id 73-20020a17090a0fcf00b00219861bb108mr27198788pjz.121.1670403373627; Wed, 07 Dec 2022 00:56:13 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 40/71] virtio: Fix returning -ENODEV Date: Wed, 7 Dec 2022 21:51:06 +1300 Message-Id: <20221207085137.445249-41-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713134 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=W6WxtOfS; 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 4NRrtH3rD6z23pB for ; Wed, 7 Dec 2022 20:03:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C42B5856DD; Wed, 7 Dec 2022 09:56: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="W6WxtOfS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6AB685643; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 98125856A6 for ; Wed, 7 Dec 2022 09:56: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-pj1-x102d.google.com with SMTP id fa4-20020a17090af0c400b002198d1328a0so3351198pjb.0 for ; Wed, 07 Dec 2022 00:56: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=R9MEjfs27ZJAjVeKLv3f7CUxFSjgPUmSmgcQtJ7mSeo=; b=W6WxtOfS0YjCgaSe+MFNR/7a0xUNBrvBLQ1Pq7rKSE+QiWNFrL0od6JQCBGMyHBQPy s1g7Oi2uQw4P9WPAgBYv4qw1DOCZmZtpxxqVHzJj8BEXDeCc51jA9wWk0Ge6Xug7lybv qN25WUBkvgLvre2NoSNiOfrwnwoMK6G2uCesM= 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=R9MEjfs27ZJAjVeKLv3f7CUxFSjgPUmSmgcQtJ7mSeo=; b=u3ECcbPXpiZ8QmCx+hSkb3VeZni4dt8s5UsZDFKBpit1MX4+VJooMzNSdVxxv032wx h/Ty5WLVEF9oXSt6x0RtSfvDNMiUr3K4Qccbb02aZ3lccAobVSUKvVpXTwXUkcN/PyK0 LWp+1YekVp9PBq6+1ikjw+/ylIlUaeJ744MAld9jNwSYzUcXtV5o8FAEyXDIumQQmP5E Hjf/cbvVxxT0wRwuQzcjQTEjrz5GTneWFk9EP2UEoKOVvZHCOxwXpRq1q42tLROUoeXU b9KPIvnTHAzcK1CWpXRS2je9hstQ/GGz9yFMflioXCMm2jHjgjIJbv4YS8IkBICKInsc 00JQ== X-Gm-Message-State: ANoB5pmohYiZizzVX54RGA7+MPtlyycbi2eOFWBbvPxUNUPBJ9tUi51V nRUCN77oHe8wbtqO7krXMWt0qW6cHn+LQjIU X-Google-Smtp-Source: AA0mqf7atNsZCTaN4BR8M9+diseDz11ilZu99w/Lvgru9UoW9BAfsH6LEKuN9WNBOrMZYRVC1pC1Ig== X-Received: by 2002:a17:90a:6c8f:b0:219:661f:9916 with SMTP id y15-20020a17090a6c8f00b00219661f9916mr35493687pjj.200.1670403376810; Wed, 07 Dec 2022 00:56:16 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:16 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 41/71] virtio: Avoid strange behaviour on removal Date: Wed, 7 Dec 2022 21:51:07 +1300 Message-Id: <20221207085137.445249-42-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713135 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=WWYy+Qwe; 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 4NRrtY1wktz23pB for ; Wed, 7 Dec 2022 20:03:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92EA4856EB; Wed, 7 Dec 2022 09:56: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=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="WWYy+Qwe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21FB3856C1; Wed, 7 Dec 2022 09:56:26 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 997C9856C8 for ; Wed, 7 Dec 2022 09:56: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-pl1-x629.google.com with SMTP id d3so16419814plr.10 for ; Wed, 07 Dec 2022 00:56: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=0WEnnZjBvYsCskBswYlyeo3jm2romWw03fp8IiG7maU=; b=WWYy+Qwef0qfe48QzaL9JjRPBSw/L5xHRrEFQZPVTfA4CEqEgLpukSv8aT5Dit2gyv 1P5PrT7oVB2nmUfKcWB1lQ2zIxKU2ue9VpXRU7z0D2sJ9ie+GjMiz/zT54joy7u0Lzz0 +7HkNTrgD/o0+3DQAW4JqKdOm7JIMcVdbsaqQ= 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=0WEnnZjBvYsCskBswYlyeo3jm2romWw03fp8IiG7maU=; b=LWmMjlSSbKpjV1/b9Q0LCdeVYbR5teqLGCus8pHbAnlIGRW3IZyHy/l++wDbN5Y+lt Q19tMDBnFMI0ir3LYNgcJOcgKN7VV+dTbgmSr+M4poXvCIZm0MptAscKg6gIFwQmVCg1 pzc6YrryYG8+hCoCUWih3Iw3bBZ7GmCJuryH3Ah5vlMX+u9va4MCBZ7qCC4EpM+FGMid VH5G7i+ZwpA0q+C4N9Jz42HMhZStkCa28fgsTWQlvK5jmVm6RLZ4O2furkyZofEJb0Tn e1FJm8POQYyY1p6M2nWu4Dtf70JE0g2CWlRCopQHNqdVD6seBqD585PVO6ZOCfcf1sx4 mbBA== X-Gm-Message-State: ANoB5pkeaeQxd2yck9Tiq/mHmLNzCsPQc1Peali7pYuLV6/sBQmZQ1dw wmbCwovadNvtKevaizg4hE2fAxFb6GJ8eTRi X-Google-Smtp-Source: AA0mqf59kqpV3UTjVvo4eJoeNdl75rno9PKWjHOpF0YdfIMRx8XAG9JuWgBB5JewyF/f9hCCHfEVrg== X-Received: by 2002:a17:903:2ce:b0:186:e852:b271 with SMTP id s14-20020a17090302ce00b00186e852b271mr74630288plk.117.1670403381732; Wed, 07 Dec 2022 00:56:21 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Andrew Scull , Bin Meng , Etienne Carriere , =?utf-8?q?Marek_Beh=C3=BAn?= , Ramon Fried , Sean Anderson Subject: [PATCH 42/71] virtio: Add a block device Date: Wed, 7 Dec 2022 21:51:08 +1300 Message-Id: <20221207085137.445249-43-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 dffe10adbf4..72f3853b79f 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1516,12 +1516,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 Wed Dec 7 08:51:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713136 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=gK4Ahfx4; 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 4NRrtr1NWFz23pB for ; Wed, 7 Dec 2022 20:04:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4C2C0856F1; Wed, 7 Dec 2022 09:56:33 +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="gK4Ahfx4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECB24856C8; Wed, 7 Dec 2022 09:56:30 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 B97D8856C1 for ; Wed, 7 Dec 2022 09:56: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=sjg@chromium.org Received: by mail-pg1-x534.google.com with SMTP id 142so260422pga.1 for ; Wed, 07 Dec 2022 00:56:26 -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=IBDI5wDczVbVTKKMGqTazkdA7Cs8+BV0Ln/S5pRxIp8=; b=gK4Ahfx4e3lq7lR5n1DO9r9oqci8dxtDW865Yd1vSJWUON1wN4OMKBjiWgdJOt7piq oLr8w8T23FdNGTFWBiPoyrYiS3BAxQf+uNysQTxkxkT4ciF/is8u1Tccar5XBVdK33ET bT7arly3r3WadxcyIGqTpvLOB5s1eCD4AkSgc= 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=IBDI5wDczVbVTKKMGqTazkdA7Cs8+BV0Ln/S5pRxIp8=; b=IIK6JGj+NcufkfCzTQDyida51pBJjs/kZYHSCkMIooMFHmOSP2Lu+aQd9t82j626ni PF6QDpCwfiUYMM+hGyaaynOiEyCPFLsmf9LQSPrpIr5xuv4IVOZGbx25mhTQ7sjde4YJ wv8CKLKyBrvHMOpBxWW1oNetOVdMJZrhYDRHNPEdbhpwwGzhf2wBHaKFlJY7LVv1pa6X i6xYcrv3u1lc7ZJxL3bsZbtOCGfHxbqxbLAqhjA7Q0YufstwIAfpxObrdujeHulPrnMG jeZY0A5kIBqf7e0IRrIW8ZgOUuTJkpaQfKGcHahOPytr3MvlX2LqERYK9NTHAK8W8aY4 QUIQ== X-Gm-Message-State: ANoB5pk1ARO+2US7/s1suL1y6C3+/qcD38K48nb0GNdeqxiLSU3u8JY3 +eG+nBdQyMkI1ZYsTNkbvBjzP3h6DmWLg1Bn X-Google-Smtp-Source: AA0mqf4+hzNRpKc4c9JCYvMM9Y8Zttu3pj7ynFLC6H3uUToRgXe38s7YrQwfSYrP7LMuxz/InqsboQ== X-Received: by 2002:aa7:8d8f:0:b0:56b:b112:4a16 with SMTP id i15-20020aa78d8f000000b0056bb1124a16mr96950710pfr.66.1670403384903; Wed, 07 Dec 2022 00:56:24 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 43/71] bootstd: Add a virtio bootdev Date: Wed, 7 Dec 2022 21:51:09 +1300 Message-Id: <20221207085137.445249-44-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713137 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=Kna0wbeY; 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 4NRrv74l5jz23pB for ; Wed, 7 Dec 2022 20:04:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30802856E8; Wed, 7 Dec 2022 09:56: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=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="Kna0wbeY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9670C85573; Wed, 7 Dec 2022 09:56: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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 48423856E5 for ; Wed, 7 Dec 2022 09:56: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-pj1-x1035.google.com with SMTP id u5so7580427pjy.5 for ; Wed, 07 Dec 2022 00:56: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=3gbHyP0FNP3aWyvSYjZ05kYh4qVBcey/KQfQPDn86Os=; b=Kna0wbeYhQQJTTwDNN59YYOZgBbnIbb18RsISUXaULk1nb96UjxWsN4QXgysVk1s35 R910esjt/L22pvH2paVpUfqweGg2FEIDxdW8+1xE6ukj2wAE63M51ZE3gqUyma3+S3Jg XXeGdGg5npYP3VjPvULRirf/NFY25Mst/8xW8= 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=3gbHyP0FNP3aWyvSYjZ05kYh4qVBcey/KQfQPDn86Os=; b=yxHV0qAcTyOMRLQSBt/2lXhoJ0wl0gsks0mXDqS7LbJQ3HI4PJOxyFNrkLXrboeeez /enGssAeHsjT4+HTx9ydAx4tR25FvZKRsmkShh8m49PQ+JY0POsp5gCcf/0S4zcI/Iu+ VkfXeyW06bfKdg/VCRLpwyaGedgI5fxXr5aXgR/Ng657rx1IW7CcNsxMyr5PC8fHhDS3 tdFleZLSnhMDI6SOvt7rZCH5pgFkI3d17TuSVD+Pz3ul/1OHNlgLeP6IXzdBJJDit2lm eJb1ZBzg3CXXzdaIj0hNBIMV1dlgNLE+giqbUyg90jhOeI8gKYcTfDU9skH49/BwadF/ lr3g== X-Gm-Message-State: ANoB5pne/USqYqJKDhFLyH995e1bJOjMT4g5uM0XSsDiYzXF56TqcaWC fxfxPOsps7WPvfyd5yHJXPJrYYsL/7pXFctf X-Google-Smtp-Source: AA0mqf5mdFXfB6DRGY4/aRyoyuVKUq1veu9Wilfs2uQdJ+cBEtXhAkP2g0FUwEDTVomRn2MbxMbM/g== X-Received: by 2002:a17:902:f792:b0:186:b32c:4cdc with SMTP id q18-20020a170902f79200b00186b32c4cdcmr74198411pln.166.1670403388475; Wed, 07 Dec 2022 00:56:28 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Andrew Scull , Bin Meng Subject: [PATCH 44/71] ata: Don't try to use non-existent ports Date: Wed, 7 Dec 2022 21:51:10 +1300 Message-Id: <20221207085137.445249-45-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713138 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=nG9sq1hn; 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 4NRrvP6tVWz23pB for ; Wed, 7 Dec 2022 20:04:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D40A856FA; Wed, 7 Dec 2022 09:56: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="nG9sq1hn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11640856C2; Wed, 7 Dec 2022 09:56:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 B81AA856C2 for ; Wed, 7 Dec 2022 09:56:32 +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-pl1-x62b.google.com with SMTP id y4so16435164plb.2 for ; Wed, 07 Dec 2022 00:56:32 -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=ocsfgGmZOF2LTFfUqQFpQ6HQUgxHkAw7b8W7V1PuPtc=; b=nG9sq1hnsWgXD9zPHfEcWp2GffqMq9/nj1SG5sK9ZNG/vprZN53Swq5ulCUI+ivwy7 jMLj5hBO8DLYapiPxL5G6wJ4Cb8I0FeHYANYPmv4l44VrUGxYl2z8zAmhaUCb53ZEyZA h9HsgA39U/KEcTWANV9+vNw9v+nOTsTwWel3s= 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=ocsfgGmZOF2LTFfUqQFpQ6HQUgxHkAw7b8W7V1PuPtc=; b=A9kfm0qsya90yTzsO7FFXd3tv5ke4AG4jny5bWdLmcDey9usbJji3eOKellsERk/1n em9lbfFamvZGepjEnICuWA6Zxl7uVznCGehh5KXuyGUr0Y1hgK6GGlEpegDCrowKUCBA asUWOEaSNyl0tmDohr7zPtM5tgSeEe2+pJrZbUL2ykUnrasHqi5oegY2gajq0ER3ZzM3 pbslxp8hNg4/YB9Fd5Bc81KpWx7Rg3yGwb0NQpGDIPm2JcHESzQpCqGHupk5TwbpetCE dDzghlPIPjQFtTb9nBp6nZzl+famlEe1SglJbXSPgaBsMz3ue10WW5jaicu3DQSVpUBN kr5Q== X-Gm-Message-State: ANoB5pmQ9MFwqd4eEuHdRlDe6a0B/FfslPkPnvhD1+z7OswIYzwxrHMz puHvSNst6GhvBMu+JRc72Ut4xiz9ty6J0GWH X-Google-Smtp-Source: AA0mqf6ZAvnhBjqA9onpz1300+avY21BFc7VAiIds1ePGzz43MOuTG2hQMe1RPOWgj5mKqmwXC1ZJg== X-Received: by 2002:a17:902:e983:b0:189:651c:efb4 with SMTP id f3-20020a170902e98300b00189651cefb4mr59449797plb.89.1670403392040; Wed, 07 Dec 2022 00:56:32 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Joe Hershberger , Ramon Fried Subject: [PATCH 45/71] bootstd: Rename bootdev checkers Date: Wed, 7 Dec 2022 21:51:11 +1300 Message-Id: <20221207085137.445249-46-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 f9ad4099244..8c01a4efdc9 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -426,7 +426,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); @@ -438,7 +438,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); @@ -450,7 +450,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 5c6c687f0a6..4f8f9cfe5e9 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 d1c3f940037..e438580d9e1 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 7d50ca2a45d..905410974c8 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -303,32 +303,32 @@ 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); #endif 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 Wed Dec 7 08:51:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713139 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=U3420iGJ; 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 4NRrvg0XSYz23pB for ; Wed, 7 Dec 2022 20:04:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B67C85680; Wed, 7 Dec 2022 09:56: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="U3420iGJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF856856EF; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (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 B4345856C9 for ; Wed, 7 Dec 2022 09:56: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=sjg@chromium.org Received: by mail-pg1-x52c.google.com with SMTP id h33so15665008pgm.9 for ; Wed, 07 Dec 2022 00:56:36 -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=Yj+4W4ku7zDhp6oPvg0u1TkRyRwKHHAqTg62ILEpjNg=; b=U3420iGJJjrO6BcvWFYupbqgE27G6Co5YjTZv+PUnvtR7JlE4xKQAxXKXGMIHHQxtk WXUoD5wtzuHqAJINVXr/zYEjdR8NW1QhUFHJZQC62Q1bqzPBrQMcD/D4bx4yXPivOXZV Fh8KNNlYZeavOV2xEhAk3gkrBIsfod7VYfjr0= 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=Yj+4W4ku7zDhp6oPvg0u1TkRyRwKHHAqTg62ILEpjNg=; b=3gV3WtEYNwo8rTltwPlPzwR4/kTf4Zbmq/XioWxBrKZu+HOmsjmf27qKgI8YCVywsa t1w0muk2Gq//ENxJuSTTKQVAQEeruIHwRUiVKZC5Rrwu+OaH4/cOIanNacXUPTQDdAzB TGehr0i46e4oJXOBrSiz3+KXQWdAOeIUaPvdJ6UCy0qaWneWug9rNlStjSrVEtoiUrnJ TJGGhKSsJ4oXJZF7winsGerjt7MIR8TO4BEe4IObkf/9oVBrDVdtm8QEeffCx0rJzrH1 gYAyji5mCswYg95Cjz2z2qNg8jch8o/4l157g7JXJQ0CHw9JRKNFWvwVw+laXtY1tJEe s5ZA== X-Gm-Message-State: ANoB5pkjUA1SK1t0Zk7ceJNg7s6SVQhhRu01K/ixROcHyaFYAZhxyQCK k3lsdebudHfbVoFeJQhaEwK5QMEcivmGlGcI X-Google-Smtp-Source: AA0mqf5xZYtZPWMSEpA5reCLznSV6kIzsHq3pU5e8/114lHeh7hLNt7uPxUdJ8yM6MldAd3hmIcDMQ== X-Received: by 2002:a65:580b:0:b0:478:ff8b:6976 with SMTP id g11-20020a65580b000000b00478ff8b6976mr112370pgr.501.1670403394865; Wed, 07 Dec 2022 00:56:34 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 46/71] bootstd: Allow reading an EFI file from the network Date: Wed, 7 Dec 2022 21:51:12 +1300 Message-Id: <20221207085137.445249-47-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713140 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=eaev4Zjs; 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 4NRrvw4tbGz23pB for ; Wed, 7 Dec 2022 20:05:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79D7A856FF; Wed, 7 Dec 2022 09:56: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="eaev4Zjs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6984B856D9; Wed, 7 Dec 2022 09:56: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-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 8E8C8856E1 for ; Wed, 7 Dec 2022 09:56: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-pf1-x42c.google.com with SMTP id 124so17005189pfy.0 for ; Wed, 07 Dec 2022 00:56: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=O69prlR6vG6QDwsCSzbGhjkcYveW6o4H8pk1vkbh3N8=; b=eaev4Zjs/ZGmZNk9x+m9//ZykWhkwuB9EOBEWH0MzJcH2jh75TN0jrjUNbvljTDNGM 3/Ac8q9MvLr7MTPEUUsTeKW7KKEOXDcvPcNrPfveB0mUmM75I66PEZoC7yr3e1gaFOAR mhyWuzugcpRHQYlTA9yIUXyAIpSEj0LJ4b4g8= 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=O69prlR6vG6QDwsCSzbGhjkcYveW6o4H8pk1vkbh3N8=; b=EoEAedoMiPuQcQd83NpCCz/DS7FQVS4mEkWVf1iHOrPyS9k4GPxOc+YYVngQpEjgBe Z2M/7LLa71Lpw5/58QKRrJKefcaSb1u5Kil9T0PQuaYwlPUwJisMLoKUWui3cCGyLHxw aJeIpmQDybtQFizZxQ9ZqSSHTQc3Fa0jQOXJlG5ztC1diorXKMCs7YpUl7RyOSHLjJeP rBHFoEUTyNFPidZ5k13gU3xF6y/NA4fMzgBJTZaET3JYWAPUOuOfoDe5QDKRrafF1wd+ DdkY6pzUy38fp/B8V6jtylNjFCHW5PrQ4IpvMNAoBx2G3vqoDioRPl7qvVJz2JmnFdbc B1Cw== X-Gm-Message-State: ANoB5pmEeCYILgljaLWx8V16N4lgbCb/oxAhvVV4Vqff6/NxlFLYwq2e xALz3HnK3C6Nit8fZDaK8jDOD1LQeozTi/JO X-Google-Smtp-Source: AA0mqf4C5Zj8dlB+f9KclwUuQlZgvdHyXpEfGlpAIaM+JG6TM6eBdwokuPnNJGKjYTe2pUa6DiW2Aw== X-Received: by 2002:a05:6a00:290f:b0:56b:e15a:7215 with SMTP id cg15-20020a056a00290f00b0056be15a7215mr72497474pfb.27.1670403397698; Wed, 07 Dec 2022 00:56:37 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 47/71] bootstd: Include the device tree in the bootflow Date: Wed, 7 Dec 2022 21:51:13 +1300 Message-Id: <20221207085137.445249-48-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 8c01a4efdc9..21d4f6b5a9a 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -354,6 +354,7 @@ void bootflow_free(struct bootflow *bflow) free(bflow->subdir); free(bflow->fname); free(bflow->buf); + free(bflow->fdt_fname); } void bootflow_remove(struct bootflow *bflow) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 313103d2775..98c0d757b06 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -337,6 +337,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("Filename: %s\n", bflow->fname); printf("Buffer: %lx\n", (ulong)map_to_sysmem(bflow->buf)); printf("Size: %x (%d bytes)\n", bflow->size, bflow->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 905410974c8..f7b821fa10e 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -52,6 +52,9 @@ enum bootflow_state_t { * @buf: Bootflow file contents (allocated) * @size: Size of bootflow file in bytes * @err: Error number received (0 if OK) + * @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; @@ -68,6 +71,9 @@ struct bootflow { char *buf; int size; int err; + char *fdt_fname; + int fdt_size; + ulong fdt_addr; }; /** diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 9e9a3e4061c..7cbcfe1f08e 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -189,6 +189,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts) ut_assert_nextline("Filename: /extlinux/extlinux.conf"); ut_assert_nextlinen("Buffer: "); ut_assert_nextline("Size: 253 (595 bytes)"); + ut_assert_nextline("FDT: "); ut_assert_nextline("Error: 0"); ut_assert_console_end(); From patchwork Wed Dec 7 08:51:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713141 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=HhfTq4G7; 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 4NRrw95BZ3z23ns for ; Wed, 7 Dec 2022 20:05:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FE5885656; Wed, 7 Dec 2022 09:56: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="HhfTq4G7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 031CE85705; Wed, 7 Dec 2022 09:56: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 64170856E5 for ; Wed, 7 Dec 2022 09:56: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-pl1-x62d.google.com with SMTP id k7so16417439pll.6 for ; Wed, 07 Dec 2022 00:56: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=rYMVoZl/T+vU0JgMZr5iqJzqXWZoWZkZQQBJUeXHUVM=; b=HhfTq4G7xPn1Z5YNy2hx9+J0DjdVl3Ar888z/xCgv7PsN3NuoRoE++73YNnrpQMnqs h8asQipvUMDOVS4mNeApBOhE/WVyTuhlOw/oykj4XJHh4gr/RZ/GKfaOndPotUiQf52Q NW73LKuL7VztYyk909wlEi5j4YgTQjPixDaY0= 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=rYMVoZl/T+vU0JgMZr5iqJzqXWZoWZkZQQBJUeXHUVM=; b=hq+GJUZCkN/1GVHPBpTVVruC9TV96S93ohNLJecGoXClyQ3iXzz1RvNJ9yNyWmm3eC f6x1u54VFS0mPzHcsvOLRMRq4oUSchy+nzSIEAnIhmaCUdL52p+vj9yZbSXFdJLcS7C2 XdXrVYse4cgg2opGT6NwigRX0qbC1rCd1m8UwfF/mWNizLi3q+EFWolQZGnKxnqQzVNo 9c5YSo7bDm/zgeLqfuKBh2iinRfJmmsZ9Bq5sBGQ//nVD6hhvE72dvP3H/lAGflt+j2G L0ESRkAGa9csobXG9ezBBT24SmZgfaAUxAEzDfL3MlNlLImb9lAxYJTCzMoShsWEGkXq oiig== X-Gm-Message-State: ANoB5pmwcgiy49faow4mb/5opsQmk5psiHINAl806Coh+ZX3PkIdKKuh G3j30JS3SnZOZhIz2jq7SyrkrLvCSQh2FbMD X-Google-Smtp-Source: AA0mqf7/iI6tsy6JhkkIdoBaTxFvGqqe72r7MLP5eZxKUUrjjdXm7GgWMUX8PXxGdLVQm1oWTelyxw== X-Received: by 2002:a17:902:cf05:b0:188:53bd:878a with SMTP id i5-20020a170902cf0500b0018853bd878amr72912123plg.12.1670403400555; Wed, 07 Dec 2022 00:56:40 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 48/71] bootstd: Support reading the device tree with EFI Date: Wed, 7 Dec 2022 21:51:14 +1300 Message-Id: <20221207085137.445249-49-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713142 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=LgiVq34d; 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 4NRrx94gfdz23ns for ; Wed, 7 Dec 2022 20:06:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1FA7856F9; Wed, 7 Dec 2022 09:56: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="LgiVq34d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 468868570E; Wed, 7 Dec 2022 09:56: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-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 410FA856F9 for ; Wed, 7 Dec 2022 09:56: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-pg1-x52f.google.com with SMTP id 82so15731934pgc.0 for ; Wed, 07 Dec 2022 00:56: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=zUcykbdpMAC/8K9zNT1Z721PMrtw3zWnyrl+YzcW+gg=; b=LgiVq34dp22DTBlW/fKgl7Y6qLfGy8myrTuv5bGp1Rz2Vv2Lz94iJ7YE+wicUAseDn DYVXt1D2zMopIh1OR4oEKGE28Zz3zbXCuUiupO5TDiVOtvfIWBZaXQRVY3wEiwrw0THH HLuR6u++wTrBH7tjORjoDbFVMHwgZvaTsDuS8= 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=zUcykbdpMAC/8K9zNT1Z721PMrtw3zWnyrl+YzcW+gg=; b=npOs9y/K72rE43f2VHqv6Xmcm3U5kliPcc4DNEtUCenVkEBMNA9A3z9c5ei8mDO2zk bYTne026pParzmngeguOeehiv5ScS+QSAD8AMdAC1BF5n53Tyo4CvR+6z7iceNq+gK9N zo5G6rxFn/f2J4ufruzIbIMcQD9HpCfDACplXbT3kEPy3e5iYR84AImPyB9GC1EFaGqp O3E4txxeqn5py5KOhAMx2fFOQY9uZT8y0+Y7wkOtYxDb8JVH+Su3AdKEgn78ePiJHW5h Cpp13vqMktnpOf+bTFvNeSHbuXCcitWNJwFMhHixCDDFw+IENblm015b5t/EMWSvAEvi 952g== X-Gm-Message-State: ANoB5pkSibv3zedmePCD9G3Z9c8Lti5/kMnHbqVWSIbY7Dj9sI6ttiPg USkhrIefcLEGNXr4ijIIQdOW/E77ry1bsh4P X-Google-Smtp-Source: AA0mqf7AJ4qiiV/RO3bfMhLxgwy2XrZ6PQehDQ6FCT5507schzc71Mtdkgaq3DzPcWcDWWYN6ikhZA== X-Received: by 2002:a65:694e:0:b0:474:6749:407d with SMTP id w14-20020a65694e000000b004746749407dmr62217770pgq.425.1670403403387; Wed, 07 Dec 2022 00:56:43 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 49/71] bootstd: Set the distro_bootpart env var with scripts Date: Wed, 7 Dec 2022 21:51:15 +1300 Message-Id: <20221207085137.445249-50-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 e438580d9e1..a1d31524efc 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -87,6 +87,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) && @@ -97,6 +99,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 f7b821fa10e..75f2064f47c 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -133,6 +133,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; @@ -150,6 +152,7 @@ struct bootflow_iter { int first_glob_method; struct udevice **method_order; bool doing_global; + int method_flags; }; /** From patchwork Wed Dec 7 08:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713143 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=Sf909cGF; 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 4NRrxN63gpz23ns for ; Wed, 7 Dec 2022 20:06:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9EE2485707; Wed, 7 Dec 2022 09:56: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="Sf909cGF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3C2C856DB; Wed, 7 Dec 2022 09:56:51 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 1F808856DB for ; Wed, 7 Dec 2022 09:56: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-pj1-x1032.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so937180pjo.3 for ; Wed, 07 Dec 2022 00:56: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=czfHLI6KTY2HlrxVanHnv+0SbGOk8baBZObrrEFBXLY=; b=Sf909cGFqi1zFKb9oAZCRb2xXx6WdfUlJQxy1iyjrVNY+ddFKzIM0hez/xIDnGzpWo 2/ChRgz4NZey+QPnOGz1mlkTF478KGFhvgrF/FoLQIsLQPqKIKcc7Z54vCIK8mbzokib zkg+Wq+KnXTVb4hOrk39vy66mhhhmpcqweCXk= 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=czfHLI6KTY2HlrxVanHnv+0SbGOk8baBZObrrEFBXLY=; b=a01Q8Em4xyHUHAIWEtDVyk4pJJxbgGhJWnlYZ/cm3vJuQpa/bDznuXzTEsA69PieM2 0F1lGeka+v5wHNanZ9KFIE93fHY4lC+MB26B7Ktwm4zNWqsa0qxZS7Dpv4qB9lx8t68V YsZ3OJcXx5e7UqauyPU16X5EtEKja0eKnqLG1Z/A4pufEm0WsdT/3mmWAi6WFdwKlPJw 7tpdYriTj2FwdTqco2PA3IYij1+hK/F370zxpo1RfqNOgvZeB/HCwP2eVw/UxoQ/Z71j s5bMRTClcfUMcMJtNDRsak5LsRrI2nnOz/Kid7OSc/ekh6mM5/yyraNZT0bm1+btN9R+ DMZg== X-Gm-Message-State: ANoB5pkDWfzmTt9YssIZB6iRYY9yOBwfGd9TfjhFuBHVdUlBc9qAMbLb AMPBw1QYV81SFDuTMJmv+YelVxihlmDOLZik X-Google-Smtp-Source: AA0mqf7iuMvZkETr7iNqkSbkEjivuPufpFqw/J7XXLJ9NKAYojycMoF2sXOu+FCx6RYr12idFiEZjQ== X-Received: by 2002:a17:90a:8c96:b0:218:7e9d:8d0a with SMTP id b22-20020a17090a8c9600b002187e9d8d0amr92544110pjo.41.1670403406270; Wed, 07 Dec 2022 00:56:46 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 50/71] bootstd: Update docs on bootmeth_try_file() for sandbox Date: Wed, 7 Dec 2022 21:51:16 +1300 Message-Id: <20221207085137.445249-51-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 75f2064f47c..f77bfb6eace 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -39,7 +39,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 50ded055f3f..ba9e3667e52 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 Wed Dec 7 08:51:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713144 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=BpTFvODs; 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 4NRrxc2lNdz23ns for ; Wed, 7 Dec 2022 20:06:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 787E385713; Wed, 7 Dec 2022 09:56: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=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="BpTFvODs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3572D8566D; Wed, 7 Dec 2022 09:56: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-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 EFE2D856ED for ; Wed, 7 Dec 2022 09:56:50 +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-pj1-x1034.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so852859pjp.1 for ; Wed, 07 Dec 2022 00:56:50 -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=ejaDGz4tw1lbpZ2QDY8dD+oO9TQrhAXNaI6ry8hOMf0=; b=BpTFvODs96UH4/62d5XybortJOr1BKFG0nWc5gOQLZuXRgR/ioFju6n9iy3K3ee6B4 6GmW77NTWw6tMlNhOnfOqIBhBuyCUj3kCC273YyGDk/DtTDo499oUAeteocUioJHb/iX E8Ni9UP/qUXeMvSndVU2IGeFuaHD96JIOejvg= 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=ejaDGz4tw1lbpZ2QDY8dD+oO9TQrhAXNaI6ry8hOMf0=; b=M9GFdw+s/CTTgQHqhmk9gDqcKWWcqVTTVguPC7Ctg4l7sAf51WQdStrWDfVYS3HtYh FtZAQwXMYdDpY9up0OFE1vu1y1ZQgDkWHxFmwBhurAzDnCooO+zDziP0TqDh8WTDbhe/ mk14GeoDNC1d1yy5gO757XSaDlJeo2LOJeKCUqhluKklb+CoFwI/xNPDvZCmNEe36B8r peUiEuOWhFLiYxm0SRLFERBZ6chnRSSYmjM1SmJ/lfdBJEAKS0BRLIi7itz81Rq2sUbe m36EeFoV/LL5shYfyRM0CAHYq2bKzEzy0tJIYr2w7ivENfPIFs38BHfQ6t+5v2ZQE6xV bt0g== X-Gm-Message-State: ANoB5plwsSTnqdPUthGF7G+iw2BMqo7tKQBFwbcbK6z8A9BWnhV5bi3q D9/aiNreYyaVnZvrUNNE2ow+bdcZDQBskew8 X-Google-Smtp-Source: AA0mqf523jvFFgtEi7A95PyIFBaDKdGOMWwOKN5AoH66jlY8aDBkVIa5/hOR/SKzUElI2IGjXC3lfQ== X-Received: by 2002:a17:902:ff02:b0:189:8795:ef75 with SMTP id f2-20020a170902ff0200b001898795ef75mr47489186plj.1.1670403409126; Wed, 07 Dec 2022 00:56:49 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 51/71] bootstd: Move label parsing into its own function Date: Wed, 7 Dec 2022 21:51:17 +1300 Message-Id: <20221207085137.445249-52-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713145 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=Bshm/aJK; 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 4NRrxs1VM2z23ns for ; Wed, 7 Dec 2022 20:06:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9CC6856FE; Wed, 7 Dec 2022 09:57: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=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="Bshm/aJK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A7894856DB; Wed, 7 Dec 2022 09:56:56 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 BE401856DB for ; Wed, 7 Dec 2022 09:56: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-pf1-x433.google.com with SMTP id 130so16946803pfu.8 for ; Wed, 07 Dec 2022 00:56: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=9MnNV6x3LuzMgLSWoxp9XJLEWaApaH/yRDo6iw7HDLA=; b=Bshm/aJKjw/xTgyQX+/au4YP+Za2XeAwPEauj2WYsVp9bbDYqQMWZuvhnvpHZSv1Bi jrgMdGlrN7iogQKf/oWXxY7ct+p03UZ/vrdsTmJibielTl/F1YzgzjDRbs/B8K0Gtb5P wf6V5qXzdGeule0IJZbPajhFUP0dP4x+iCLe8= 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=9MnNV6x3LuzMgLSWoxp9XJLEWaApaH/yRDo6iw7HDLA=; b=Wl7kNkMhZl0o7Zqy1F8EOBkAsQL2oTR8J/YLAaEEulU6ImI8HlIiIIQLM1xsF1y3QW j26eOdlyAhkMqXg490QLEPi+yMxZobwJle60CyII0xg2ei6MlYFixK7PkARJ4MVSsoET z5KFObLSNStCf5q32ArEYZesf3orhvBb9NHOaWxsbVmcFa9R2OiTULs04kIUrjIwB5ls py5n3jlwjIkZw9rLQeGVpptmp1OOx7/yUHq6kuRC9QbAMujzqC1PteqBNTr/so2aI82P t64YBIzX9Wsw6JJPp2TzYeQlRX/3EGU6whzx7UoKGqw59ikry+2TiIGZMS6AHhwGNkL2 wWNg== X-Gm-Message-State: ANoB5plKK7ncPMI4A88MD3ReTkH51FN/JSl04BcZjDCUgyKGl4M9tToz jQIQDBxk9kw7O1dkTN3nQbidr/nHUB9b4NYO X-Google-Smtp-Source: AA0mqf6l6UkyNW/k6srFx3c6RygQkz6ESLeCWBiiz0DJyvsX4ZTQsI2JrU1NwLEBU8ZSbZTzxYeKwQ== X-Received: by 2002:a62:1b05:0:b0:576:91fa:8ed0 with SMTP id b5-20020a621b05000000b0057691fa8ed0mr20063342pfb.15.1670403411907; Wed, 07 Dec 2022 00:56:51 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 52/71] bootstd: Add a new bootmeth method to set the bootflow Date: Wed, 7 Dec 2022 21:51:18 +1300 Message-Id: <20221207085137.445249-53-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 25552dd96f6..e8eb650efd0 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 ba9e3667e52..c28962773f0 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 Wed Dec 7 08:51:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713146 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=RMftu5tO; 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 4NRry60Rbrz23ns for ; Wed, 7 Dec 2022 20:06:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69AC085715; Wed, 7 Dec 2022 09:57: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="RMftu5tO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CA5C8570F; Wed, 7 Dec 2022 09:57:03 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 F16BD856E1 for ; Wed, 7 Dec 2022 09:56: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-pf1-x430.google.com with SMTP id 21so16963196pfw.4 for ; Wed, 07 Dec 2022 00:56: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=xfMYGN5er9/yt/OTiFKiD0fedBpTmtJAydfAjcJnmSQ=; b=RMftu5tOU0oXZklIzfHBV1/l7QIQ0ZB0ngX1D3Mb3rJBimJp0U97nflBCUEx1Jzyq1 mndexfqYu+v3z4eId2nlWONbe+OAGPq4GudyfrwmSL6uB6+d1xsymh1db5J4CCcUygyr uCgjgjCKN2bTpBlXI+gipFd7sy5QwKmA8vRLM= 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=xfMYGN5er9/yt/OTiFKiD0fedBpTmtJAydfAjcJnmSQ=; b=i4vsCswjTGJW7OtW9QMG4sRlun4yW0unp3MYeYAPU/ivhm7WJAcH2h4ewlCT6O3chg c1MMtvjvQqAIrbtiFnzZ900ZePqhvlX+XPUhDlnSoTuVE9NGXkHa1KhANIEIYcPwSl9F qSl5YB7Bz6ILXOC6/SedprE5pLK/hs0LuG9zOnvajMdacmOMQzX9AD2G6Yy5fAZZ9Rki WIJrAyS1QJLnpx8xu6vjPass405sT9/R3daIxYLnAoGACzzQTQ9OZk0q4Y1BxPv8wQ+Z zcYdtSBx8YQUm5IA3dAY7Wg5xSMJ12v9xdUdJeygGebBQ7zNDNMQV8ZNCPbSMLdnvGi3 g+xg== X-Gm-Message-State: ANoB5pm0u5rnzJl6JMet5LeCECV70LpaPwNtHe0WnrLEqSwNd0yo2ojM UeC4uVew5ckiDpPLLjnggWVqayVVGMCkmpiu X-Google-Smtp-Source: AA0mqf5pjjTfKzzuEieUSFOamQ7nI6BSkj2skhRdzPR22Obbel060drfjSihJOcdDefy1KAgzj/ByA== X-Received: by 2002:a63:1812:0:b0:476:85ee:aee2 with SMTP id y18-20020a631812000000b0047685eeaee2mr63831106pgl.582.1670403416117; Wed, 07 Dec 2022 00:56:56 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Michal Suchanek , =?utf-8?q?Pali_Roh=C3=A1r?= , Stefan Roese Subject: [PATCH 53/71] sandbox: Allow SPI flash bootdevs to be disabled for tests Date: Wed, 7 Dec 2022 21:51:19 +1300 Message-Id: <20221207085137.445249-54-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 76e65741424..4105fd5366e 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 Wed Dec 7 08:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713147 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=SE7XrWZG; 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 4NRryL1qN3z23ns for ; Wed, 7 Dec 2022 20:07:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A6A085718; Wed, 7 Dec 2022 09:57: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=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="SE7XrWZG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C885A85689; Wed, 7 Dec 2022 09:57: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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 908DA85718 for ; Wed, 7 Dec 2022 09:57: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-pj1-x1035.google.com with SMTP id u5so7581546pjy.5 for ; Wed, 07 Dec 2022 00:57: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=M67FiYreoTAV9r1x6v4fycPmS75QPMIHp2qLB7FkUnQ=; b=SE7XrWZGo4epwTBfakCMSgwga8+blAWU0VHLCyGZlLqj2TrnNx7M1+FOKQQh6y8Uj4 EQl4KJJeamq52z4kOKrBeQ0yT85hsTVZXEBTn6zZrlmbDhd1cHyLgICWdBNAgVoIzTRu WsvJlYsmwKbEWGIROo0D1dJ1/j9Z2SJ08EQrY= 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=M67FiYreoTAV9r1x6v4fycPmS75QPMIHp2qLB7FkUnQ=; b=OUVuzy4jCFZeqVxK9nIZUfsaIGocJmBjGgR4Fg6sjV4Wxa7o/r4JBWSWFsUdp+w8bh v4NWoaOxZQznr+4vN7bH/aXsHQxelL0TaJ38nvQMF1L7c31uBZ+lBAt2WSgoJqt2DPtI es9nouK0h87MDJewsnCIU+N5qtiMmHLjbx/3EyOXqrprAVaZXsTTk+zAXdsf5WeHrk0U qn6s/Y+obvN5qtbXNZ+lHk4dnhf2eR/h1wveIcAzCRzQG2sHNN14bKHYGp7jnDo65FpG LjS4rU1ZDQ1Kvfd3jzX6GU7f4eLJHTKCztC00apDJqI5jGv2UYqV42PnlggbhGL/sp9Q g0hA== X-Gm-Message-State: ANoB5pn4UBNQJMEkKW0v7ttMfh1hkL+bTLqfcD7278sX2xBqG5jJEtZE DEz/Nwewk+tjas7y9ykFBUjBM7ZlYEgysaYn X-Google-Smtp-Source: AA0mqf4qf8XK6cVgXAE6jJKnLA20+PUV7Fh74D7L/NSBXPfjzujiuOtpB/WhASbOKJYZgH5geeCc1w== X-Received: by 2002:a17:903:187:b0:189:de92:ab2c with SMTP id z7-20020a170903018700b00189de92ab2cmr11045353plg.113.1670403419713; Wed, 07 Dec 2022 00:56:59 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jagan Teki , Vignesh R Subject: [PATCH 54/71] bootstd: Add a SPI flash bootdev Date: Wed, 7 Dec 2022 21:51:20 +1300 Message-Id: <20221207085137.445249-55-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 21d4f6b5a9a..463d58c01d8 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -439,6 +439,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 02bf0e5df25..6ec2462cf91 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -208,6 +208,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 ff4e6a46cc5..bd166ef63d9 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -135,6 +135,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 f77bfb6eace..1a240954494 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -320,6 +320,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 Wed Dec 7 08:51:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713148 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=Jrlo1YVy; 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 4NRryZ42vFz23ns for ; Wed, 7 Dec 2022 20:07:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 50E1885724; Wed, 7 Dec 2022 09:57: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="Jrlo1YVy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B33988570C; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 8D37D85697 for ; Wed, 7 Dec 2022 09:57: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-pj1-x102e.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so939888pjm.2 for ; Wed, 07 Dec 2022 00:57: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=f3TqBTkheEHGxtFieVlkXZrm3klvwuoXdvNGjCK5/dY=; b=Jrlo1YVy7j5yZ6SBolhL5DeQp5YrTfQQ3dqTWQYu2N4hdlohAyKYRnueOp/HJ+jXqc EJxptPtQRw+w9rypKmyHghdqNGzmWzZ8QOtVtGghcVwrLoI+2gSpM7B0H0XBFe/HdBwl 8aMNgZer05Y4zNbTxh0pJFvtwYp5lyqokH9Eo= 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=f3TqBTkheEHGxtFieVlkXZrm3klvwuoXdvNGjCK5/dY=; b=csOnLS/3wXtsyYQ9vthgtxIM7onPfWcicLGMxza7s0k//3TJsIEl/eGvyFtxsTnL0P nSAlR9L2ktybaSQE1xWQDtFNLB+DaGNz0mAcPsP/2pyePF9ZVmt5CGmb36HRFtoZpKhO vrZOmtaPADZSIyYSLBVpPR4qyUsQpQhUfBHkuuQg3FgC9BYl+KLUr7QYUWdMDGXnF04s +wOV6sDwHrEHOuKn3AJXOfr474jiDaRRyxHbcsKDyzgIzoOWYqI4Xmuv4t0A+opE4mRJ QPgdK6pngwkXqbF7//3WsIgGNX+CbYcl7LI3pkUJp/L8pI3xWmZbW+YsHNfJtAwEH8kF Ji8A== X-Gm-Message-State: ANoB5pnUbeMdkTCqMYsxgou8eccUtndQbDq2ibvNpCXSga+QBXogUI2N peDewEUnxl1818mBIDdtKfC/+CxB/rKT1bve X-Google-Smtp-Source: AA0mqf6v2RCbBvIB9glgl+RDj2JUfvsXuBtBoxFP+4RIh8RkZeuF4d01CSk1Fr6cMggFcoc/0uYqjg== X-Received: by 2002:a17:90b:148f:b0:21a:720:b206 with SMTP id js15-20020a17090b148f00b0021a0720b206mr5055122pjb.100.1670403422715; Wed, 07 Dec 2022 00:57:02 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 55/71] bootstd: Support reading a script from network or SPI flash Date: Wed, 7 Dec 2022 21:51:21 +1300 Message-Id: <20221207085137.445249-56-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 a1d31524efc..b257abec9a9 100644 --- a/boot/bootmeth_script.c +++ b/boot/bootmeth_script.c @@ -19,27 +19,23 @@ #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; } -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; @@ -47,12 +43,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; @@ -78,6 +74,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); @@ -124,6 +190,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 Wed Dec 7 08:51:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713149 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=Kb3qaE/J; 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 4NRryp4CZNz23ns for ; Wed, 7 Dec 2022 20:07:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1AF7C8572E; Wed, 7 Dec 2022 09:57: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="Kb3qaE/J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 45995856F2; Wed, 7 Dec 2022 09:57: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-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 6F120856B5 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pj1-x1032.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so937839pjo.3 for ; Wed, 07 Dec 2022 00:57: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=zXofJckt8Nzb3iV79JnHexpOLHO/hZ8KWz5cOr11c94=; b=Kb3qaE/Jb8epIP0DItZR2LbX0nFep+GVP+qDZHA6GKyxvN4cUjwYDIVhsGPjQNWskb As7dhxtnnwWWnJK4cEDzxVqhb2cQSB3SWeuFbXZ9F1t8f/FsVJwbwCuvs9ZRhI9PCVaO 1mmr2hjvz6Tnv+7aaWz2e8FYtZPlIn9rWkVKM= 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=zXofJckt8Nzb3iV79JnHexpOLHO/hZ8KWz5cOr11c94=; b=j1tGozH7Snk3YdbqEBwuTTyO2+/r+Hk5kvpXYhDmmdaOZLNW+ZXJWDV7X7wX9dYDk6 GpQlyo2+Wu8Xc5WewaKZIZVpQ/H30V7QC4dG42mmccyFS/8Jax+8g64CsEcgQw1/3MbW fg532ZyeXJ7P9/oSOFXWZwSKMYMT8ZDyQWJ20C+gtlmI93BH9301GM8udNSCU7l1dkaq IHRlZ4ANdmVrpLPBPM/Hf2KDqyZxRajvfz7O19L7E8nHd3DurprsxKC8CvQdolZP2NRm GCAwh50GG6oPcOfzhVdFHie8XPKP9Y3Zk6MkkYw68Gnyskhit809VSynJmeeqqSPbJba tLmQ== X-Gm-Message-State: ANoB5pnTMUr7rb5GEHDHFxxabaEGeTxy4iJLfhkcOXw4TQncY2uURJS9 b9SlASLp8Y5fKSjN/QwymgTttF+D6P1kxe9L X-Google-Smtp-Source: AA0mqf6zM72QCiimF+s3BR9YOR/5RrQv7EWck+bAcWCyxulikyiKQmbRMlUPOYeoAc/lTFxCaMtmgA== X-Received: by 2002:a17:90a:77c4:b0:219:8132:70db with SMTP id e4-20020a17090a77c400b00219813270dbmr28465815pjs.183.1670403425614; Wed, 07 Dec 2022 00:57:05 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 56/71] bootstd: Treat DHCP and PXE as bootdev labels Date: Wed, 7 Dec 2022 21:51:22 +1300 Message-Id: <20221207085137.445249-57-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 b257abec9a9..20a1f972e39 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 98c0d757b06..c4bb68196f2 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 1a240954494..70bed29355f 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -93,6 +93,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 Wed Dec 7 08:51:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713150 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=PEFW+89/; 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 4NRrz233Tlz23ns for ; Wed, 7 Dec 2022 20:07:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F3B4285730; Wed, 7 Dec 2022 09:57: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="PEFW+89/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF9DF856B1; Wed, 7 Dec 2022 09:57: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-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 35FC2855D5 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pj1-x102c.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so934622pjd.5 for ; Wed, 07 Dec 2022 00:57:09 -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=zRSohTIoBP62O6a+ND9TmpaTRRVEy11AbB0bNqGb2Kc=; b=PEFW+89/oIKYx4CztQODSrrbSsyr7yD/YcKJ0wgloalf0+i1S5SGc88/T3qxRuUHiJ x1oHGXbOZq6rV4AfocDTvCuzlJ+YC+xCTNJXA1XPAHvziH1TaAxXlNvsOpyQTBCOWp8m EQjBQXM9cxAgrsotGCAfvCsmlqZypn0ZRi0+A= 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=zRSohTIoBP62O6a+ND9TmpaTRRVEy11AbB0bNqGb2Kc=; b=1r+vPX/QFQaDSO1N31Juj9jMR9yCNVrdD1WrfPzssHOaBRZ8L2vXeqsT2aLpkk158q neFatoR7FnsGmWPbCXcBrd9ynDQOMdgVZ8NgdcFsgigU+YXxV8HrBESuvKlGTdX+YJPJ RYBP/E/95GCjIKT5X6mizIhzD08hm5epmjss9UzUd94DhAp9UxIoeQM8LKJSvrxc09Dz Fcw2Vdjbe8LQI7sqGdbc1LHxmAbfU7cN4BVohMxjH3ShYzCPXAZiKsx0BkNrQORwa0rV YjMPjfLCq1aOXohyIO0npiOldXY+AfAsf2893qk0UYoQRQPWPq/bDoIoBJokH8cyZpKF waDA== X-Gm-Message-State: ANoB5pmH5K2TOrf+Vo/fq9g+PQDoLkYjIeBp4BxitEselNvSwqOi8alK 28e232Y9yIzjEYxFV96zg2WXnIMvxIcTMSB1 X-Google-Smtp-Source: AA0mqf59UdGa53LbkjazTcwTvA/ezknNU+J96qamz01EGIMqfEh8bRfDZsV8bwFBLC8R/EiqNvJT8w== X-Received: by 2002:a17:90a:6b4e:b0:219:6a07:c6d0 with SMTP id x14-20020a17090a6b4e00b002196a07c6d0mr34693068pjl.178.1670403428490; Wed, 07 Dec 2022 00:57:08 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 57/71] bootstd: Use hunters when scanning for bootflows Date: Wed, 7 Dec 2022 21:51:23 +1300 Message-Id: <20221207085137.445249-58-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 c4bb68196f2..fdccb775a15 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 70bed29355f..b3d7509a6d5 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -80,17 +80,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 Wed Dec 7 08:51:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713151 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=l5OLOZiJ; 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 4NRrzG3kkmz23ns for ; Wed, 7 Dec 2022 20:07:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A10D85742; Wed, 7 Dec 2022 09:57: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="l5OLOZiJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 091AE855D5; Wed, 7 Dec 2022 09:57:17 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 2E240856F2 for ; Wed, 7 Dec 2022 09:57: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-pj1-x102b.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so840150pjr.3 for ; Wed, 07 Dec 2022 00:57: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=Z7/RA1V3W4Ax2+sp9+Q3+7K8v69RkT+hBtNkngPZ+GM=; b=l5OLOZiJWJrkvGRJJ3vo2waW4t1cwPB1X/J8KvNg5BEteDZIz5K7JTK5TdRm0o5Uy5 Tg/fnSN3g9w6W2gX3BH8Mtdrnmc+1G9iM1Rmp8UDW2UrIV+47D2rEOvqxYjllJVqcyhD nxF6b0H+KtrS8PIz70D03QDGe6RD+KBDJn9W0= 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=Z7/RA1V3W4Ax2+sp9+Q3+7K8v69RkT+hBtNkngPZ+GM=; b=N4CkWYV6ToSsC49P29olWs+8ucBCp/DptUoDBvtKQo3DP59FgaQhB7Fq/9zb0Sn4yM hXzYHmJ19yaXxltx1cZws5wgYyXfGazUYHr3SVYQM6Nmxlnd21WbRrUj7pxwSMrRGX9R +M4dPdIoq+1MCv3rtPLXfw12KBAidH8jIJ/UbwLg+xhwWMVH7oKhNT51Da2fhd1PRW6t EM8DwnYyG53llEGX2qZkffu/oVeUVZGtmcAUy4wzSIp7IGzR0XLm9VaGxo4Xvv3j8Jl+ dRGKyT+3EOpdkyQHz4i/BqtNtJVIxb23+S8F01ev3jxIW4Ndv4609lOkr8pl4Xn4gZ5V NEWg== X-Gm-Message-State: ANoB5pnhzgedbQwGtaLMp7gnBL7ygl7iDoOwhnr1IMNn/Fp3JE+sfgZO RFdTV7KYzlCKe3bgTrcQLvdwOqYB2HFI8Jvw X-Google-Smtp-Source: AA0mqf76613v+/9U8MmtoUdSKYOMI3PXp6WKLFXeCIIB9wSka0GWTk2TJRZVQ2p8aYTDqOC4bS1O6A== X-Received: by 2002:a17:90a:fb50:b0:219:5e9:f260 with SMTP id iq16-20020a17090afb5000b0021905e9f260mr61706117pjb.16.1670403431348; Wed, 07 Dec 2022 00:57:11 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:11 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 58/71] bootstd: Allow hunting for bootdevs of a given priority Date: Wed, 7 Dec 2022 21:51:24 +1300 Message-Id: <20221207085137.445249-59-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713152 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=OBnJd90S; 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 4NRrzW26Ptz23ns for ; Wed, 7 Dec 2022 20:08:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4D578574A; Wed, 7 Dec 2022 09:57:28 +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="OBnJd90S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B177385748; Wed, 7 Dec 2022 09:57:26 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 C067D85573 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pl1-x636.google.com with SMTP id y4so16436690plb.2 for ; Wed, 07 Dec 2022 00:57:19 -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=5at/OZG3/OKlGeQ7uuWw450QeblfUInK5KVN/MJeLf8=; b=OBnJd90ShcvfGvXMS/uzw1yCinN/qDFta8vOjarjD+W2TYGu6nh2BEH/DJRvO0sX7R 9HDAvkTGjK3rO+bMp82QtPsOrmwVFXqtDTGtz9ETFYOejd8GfLA1/brOoXTfsoJRD3rd zcmG97SlmdIFubg9M9XU1kIqzCE9UUynDvUOE= 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=5at/OZG3/OKlGeQ7uuWw450QeblfUInK5KVN/MJeLf8=; b=eIEKN9TYmKXjPENxt0Y7vGp6Vv29cSV5LsdrZobyr06wPtypnGuUZ4W8CyFwm0lnUx QvoRhAGSxVileFydV2/QR/eF03oSBBHJDxuY+7glWse77d6TKEjhoaT1PzGEHKIcrF0M 6tWg5X51i0Zw9i1Hh2udaSrJy6P1dwosDRw7yuhpOtAphYrqtLrVHMMJPmEnIqRjPJ0s s0Yhso/afft59FzpGqrg3FouN5qFr7zkNPC4wYhftGVY0E8P9azH9EVfUK1+o4Y485ak 6vo/cnSWR881iS4QDx+GYXieXsyDGRN0NatEQki8LAuegaLB8uMLqtHfqvSqLbcnhD+w HoKg== X-Gm-Message-State: ANoB5plSWvfFDm9zUMvdos6g45p+yZD66oAGKhT9kELGYcoKSM956FSb yXuhHSWJ4jBc6pJ21nj/KYpW9a2KUS6L0D3A X-Google-Smtp-Source: AA0mqf5EAw3Dx22s06Gs2kMw12K84Do7pT9EYDy096Xj47qgLBN0YrTYWcTzb/Qa410HUcgfdgXn7g== X-Received: by 2002:a17:90b:2744:b0:218:7675:ba83 with SMTP id qi4-20020a17090b274400b002187675ba83mr64690367pjb.61.1670403437709; Wed, 07 Dec 2022 00:57:17 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , AKASHI Takahiro , Bin Meng , Jaehoon Chung , Jagan Teki , Joe Hershberger , Marek Vasut , Peng Fan , Ramon Fried , Stefan Roese , Vignesh R Subject: [PATCH 59/71] bootstd: Add a new pre-scan priority for bootdevs Date: Wed, 7 Dec 2022 21:51:25 +1300 Message-Id: <20221207085137.445249-60-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713153 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=VbDcPbin; 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 4NRrzm2pjyz23ns for ; Wed, 7 Dec 2022 20:08:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A306856D7; Wed, 7 Dec 2022 09:57:33 +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="VbDcPbin"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10DD485573; Wed, 7 Dec 2022 09:57:27 +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-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 6554685745 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pf1-x42c.google.com with SMTP id 124so17006646pfy.0 for ; Wed, 07 Dec 2022 00:57:21 -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=oMMZAlTLZzXx1VehOf8YoWTsmJ0Ry4fGsYbrEYZ3x00=; b=VbDcPbinAA5MyEjX2sLqaR9PDja623/HZlU8XaC04wzHvn5c/b6t0SZVCukTbQvSVI 4sY7DplBAhaYsJqnTOq+0OqObDH8ofxN4bLunY4s0Mt8zj31qi9RfTe/dH2Ki1G3Msen eMoNLm1HkMUExn07RiPzg4vXTginOSbIlQZ/o= 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=oMMZAlTLZzXx1VehOf8YoWTsmJ0Ry4fGsYbrEYZ3x00=; b=1nIX8Rl4fUGDaz4WzgVXDdJbnswUgpub3S5/XNTaOTfFDXSeZXEEXbWZHPUtP6yQFW +h1MqpAdjbhbx1hZbM5oOKbhwNrGq+tu/eUGj0hiALLvalCazJcyHq1POHYZTcgy/Rzh r5YLFauTOBgfZ6Jl52GNZM9Is1MULLbsfWLjjxt6txCTy0quXAR24lbdRVxFIemh6fc6 FqkuF5TV+dGGgzQEgqKZNNMYUWxd4poOpq98YdZf+gHejOULw1jctp5Vs2BWLKJEJ8Ik hINECemntEgiRq8d/WSzzPVWRuhf3iAX3U2HOR/Kxvs8ZakZCJc1oBm+paSXWb4WCbGh COPQ== X-Gm-Message-State: ANoB5pnrElQt3KYUmaF3RQN9E9b8EbwDBmZWu0SSGfX22jOVFqMMLvra A2/w24EFqn5Iuq/HFuNOf0jcXxYEpb9mHlku X-Google-Smtp-Source: AA0mqf7sBe4ZSkXYNMDoGrB7UR4kH//yO321+5jm4V216mGjHggL4LqWd/qk3iSIYAutR6zpoT+HRA== X-Received: by 2002:a05:6a00:a88:b0:574:2c5e:b18c with SMTP id b8-20020a056a000a8800b005742c5eb18cmr69429929pfl.10.1670403440561; Wed, 07 Dec 2022 00:57:20 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 60/71] bootstd: Allow hunting for a bootdev by label Date: Wed, 7 Dec 2022 21:51:26 +1300 Message-Id: <20221207085137.445249-61-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 b3d7509a6d5..a912088deb0 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -88,7 +88,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, @@ -102,6 +105,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, }; /** @@ -113,10 +118,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 Wed Dec 7 08:51:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713154 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=avTUeV53; 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 4NRs005C2nz23ns for ; Wed, 7 Dec 2022 20:08:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3311585747; Wed, 7 Dec 2022 09:57: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=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="avTUeV53"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5026D85704; Wed, 7 Dec 2022 09:57:33 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 506E5856CD for ; Wed, 7 Dec 2022 09:57: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-pj1-x102a.google.com with SMTP id fa4-20020a17090af0c400b002198d1328a0so3353084pjb.0 for ; Wed, 07 Dec 2022 00:57:25 -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=ozmdMmPHLbB2zBd37yGt+FwaKoO50GZGDRSQSQR4UJM=; b=avTUeV537tQXb0uzt1q1qa24djF1YPj0kcqi2hofMK96o93/kjveSyGvgaSTLwsxA+ qMQpLxr7NI3u6amnNDblF24dm1dXb9kG6x+qVpBiiKLJc4JVx4Gr8n+fPmF6a5XVAYOE zgFoN+WUuVrUykLJFv8TRCcLlarGUx9SyqYXc= 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=ozmdMmPHLbB2zBd37yGt+FwaKoO50GZGDRSQSQR4UJM=; b=xov+Zrox8EK1fxwLJUQP0iGuiqOhm48w1jwbGX1EnaFDMojteHclaDFERn+BpdCFo0 +raxwe+7kghVqVU/hupuKybn+jpYBzJG/gIUXztS3xAZ7JFY2lNPlsYTw3sAVJvrpyue GHhZY/QOmpUwoFul16uTqkxvcmaDph+SNm+TrhB799MF3p4X5r5MOheuT0GAhjlSowCk ejRLeHKfVib7+95O4jsJZrpkToUABda8MDEEV6r09VdwH3J6GHfXzu6dBvnneDPgivz/ I5ryR1Ypiibbg+I+vM8NyBywqzZCpT4isZsjdGdn5gAHQF3aXCf3o4YzOLKQRTxj8SKk iCEg== X-Gm-Message-State: ANoB5pkO2gXhAAystEdIjVe9AWY0By7RZbaASm/I9GgRm6aiC0PEAl5l moEwDz50TCmBjKBwRmyD5ffLWbwGIto5z+fD X-Google-Smtp-Source: AA0mqf6dVS3ixSVJ6zrgryK6P/pvNiKewIBlJ20ClUykPGcPZ269+XmU1VfcX+XBP03B49us0Lx4zQ== X-Received: by 2002:a17:902:6b8b:b0:188:a40b:47c9 with SMTP id p11-20020a1709026b8b00b00188a40b47c9mr74214220plk.75.1670403443478; Wed, 07 Dec 2022 00:57:23 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 61/71] bootstd: Allow iterating to the next label in a list Date: Wed, 7 Dec 2022 21:51:27 +1300 Message-Id: <20221207085137.445249-62-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 a912088deb0..5d845b3a6f0 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -164,6 +164,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 @@ -185,6 +187,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 Wed Dec 7 08:51:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713155 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=A9+YZA+y; 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 4NRs0D2n1Bz23ns for ; Wed, 7 Dec 2022 20:08:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A076385743; Wed, 7 Dec 2022 09:57: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="A9+YZA+y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA3C585745; Wed, 7 Dec 2022 09:57:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 4CC5B855D5 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pj1-x1035.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso873379pjt.0 for ; Wed, 07 Dec 2022 00:57:27 -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=smcfIlXH9+UKbDrcnfvkWjhkmqsqUV6pK5Vzw9G1I7k=; b=A9+YZA+yA+ITQAx7mw8xZqwhF+wVzRyCurfmGsGF2wFxpZsJf6S1tha1QuKTBaBPJH MCbZnL6uVIZN366v/hZdNZ5PzBqXYxvV93js2vSfvDU/eBocoj+d9B148LY3JWnCwIaz GwD6papb4lUuQOaSdmWG4naGgwWBpzNS6fyPY= 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=smcfIlXH9+UKbDrcnfvkWjhkmqsqUV6pK5Vzw9G1I7k=; b=AwBA+KtGK3BAsxhC0HmEGaK82gCP0+tJgd1jbRFXi0YdTswHa4EhdU17ugggf1i2pB NnniPeCn+2pGMa4+5ZVv5mcDsUGJXAOAG57cpO8Za4i/4qkm5fP2nL+jv0IqU2B4qGVh 2BD+wvK9fnb/CXxoHN7xYD5sajTilHJU+ruc39PAAYrF7dBKBvf/eQ9evhjmhvxDPE9C rLUQDMzjoMRcw0DvYcKD+DXWwT4jYCzH+6kwy1x0cTZiE8uHodUJVymv2LA01zOjb+LC 7iAcnd43sgt0wmKeuabBIjgJwWntPCILPzFojnyyUlnA43fG6XILQjz6NbWwisIFVSH5 FDvA== X-Gm-Message-State: ANoB5pkt+lbLOxgBr9GUTp1QPgnUCoIq9z7kiOzFCDo4bWyfval2u4nM t0A5ClMj+0bWvHAy8Rwd76pGRUqcW4KK+jVm X-Google-Smtp-Source: AA0mqf4il64K4VJ4Ao1Pnd3akE/m0FWrhgxAb9MJa0Usbc7t2yw900vHVtIu4SVXerejr2oMXIakXA== X-Received: by 2002:a17:902:b40b:b0:188:ca57:ce0c with SMTP id x11-20020a170902b40b00b00188ca57ce0cmr79318575plr.57.1670403446508; Wed, 07 Dec 2022 00:57:26 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 62/71] bootstd: Allow iterating to the next bootdev priortiy Date: Wed, 7 Dec 2022 21:51:28 +1300 Message-Id: <20221207085137.445249-63-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 5d845b3a6f0..953a9776a29 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -7,6 +7,7 @@ #ifndef __bootflow_h #define __bootflow_h +#include #include /** @@ -169,6 +170,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 @@ -192,6 +194,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 Wed Dec 7 08:51:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713156 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=kOpVMjbC; 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 4NRs0S1F2kz23ns for ; Wed, 7 Dec 2022 20:08:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 368B985754; Wed, 7 Dec 2022 09:57:44 +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="kOpVMjbC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DBDC9855C7; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 CA4EC85651 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pj1-x102a.google.com with SMTP id q15so15913905pja.0 for ; Wed, 07 Dec 2022 00:57:31 -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=ZmgCqpTPmOGg/XRPR8TUMrpLFF+x3KUHsbyXTHVGSNc=; b=kOpVMjbCJnTXmP6INrTEsCerFaP8oWu4REcLH1QD2TyrGAzqySBzq0ig7qbxbyzSOH KyBgFfyGKLw1HOYfC9Q7u772xkDdsgpw+j0dtgE6h39rK2t0BeCxD3HrvQ4JQBL7523d RUNVt52SjvUzsOqm9X5eGAAgf02CI30WmkQfg= 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=ZmgCqpTPmOGg/XRPR8TUMrpLFF+x3KUHsbyXTHVGSNc=; b=v9kh0mBSGWRR83lw0BBpt21SG12FN01YFwWrzQZJ8zdtArvbdWdbWIsD/DGTCeCunv BrbF9V3aHV5bWX3+Fs9TLuAIAsNYFurphh51eSl1TEZDaERB1BR41NTFXv1kx9wXzYFl 89B97t90cyPASkC6vNNU8BGqHvESON+bOJNZYm9jH2Fi6oTDMEZ7yn2pbeWH/3iw2TFq PkJhoLgZSV4jFyfOv/ytrPsMHfX5o1SdGRY3AfxeIHdZrRWQ5M+VamCx8gYxsENlt10S hvbc6SYoIJ8bfprukHN7SqA+dqg5zJPSI+EGj2goGaEj3soTIRo3WuKwmzxpzlmKbDI0 55Ug== X-Gm-Message-State: ANoB5plH94T/7cRi3gy+ZQ2g4cx85n20EbJ3Rk+ZDK//HCJEKDfuBQrn uk7fpchhcQiRAhmMk8qdDvKcw83naWki3Wy5 X-Google-Smtp-Source: AA0mqf7glWsrdE5uB8VFw6pqrUNPvKNOaYyQNJwnZp7z6Ku1qMwRnhUrdvDagDN+mqTVxqehJxuYOA== X-Received: by 2002:a17:902:8c97:b0:189:13df:9dac with SMTP id t23-20020a1709028c9700b0018913df9dacmr71642897plo.34.1670403450043; Wed, 07 Dec 2022 00:57:30 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Kory Maincent Subject: [PATCH 63/71] extension: Refactor to allow non-command usage Date: Wed, 7 Dec 2022 21:51:29 +1300 Message-Id: <20221207085137.445249-64-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713158 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=fiVeMyoV; 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 4NRs120HCXz23yx for ; Wed, 7 Dec 2022 20:09:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2B61F85593; Wed, 7 Dec 2022 09:57: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="fiVeMyoV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF1F78575B; Wed, 7 Dec 2022 09:57: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-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 865618573A for ; Wed, 7 Dec 2022 09:57:35 +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-pl1-x632.google.com with SMTP id 4so16464885pli.0 for ; Wed, 07 Dec 2022 00:57:35 -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=m11+izzUEqFuybI8aRk+2hpdrnVn78MzE9aD3SwUd54=; b=fiVeMyoVREfiH+0wMdnOm/Jbkt41mlZHYIUNcdY6jksrXVhdqLQeK6+7KVGInVPEHw rl8dbd9bciY3IVgHE9q+Iw/RnPkLuv9iq3OM/0cz0faafvagCwMjpW/9W9HIL87ckr/w UK6HnG1rU0vx2o0iAI9X3LF4YP9r0n/XS29Hs= 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=m11+izzUEqFuybI8aRk+2hpdrnVn78MzE9aD3SwUd54=; b=XzbkJHAzq2gmKARTD7p6Ocz5mfO7Vcr25zBgXS1y704/11vFNZ9UGxkReMhKU6YG/e 4YdWUHJt2i+jOdHHnDfs5A9O9dUiHSIjPhfGGD1+ehSh3/DSq3GSu8kwILqdAHxzzMTP 7GXf8XCvMQPBatggKryfxeXpQ7c+c20asp2nwOSh1ja9H0o0sDfyjYjV4QMjUvlan8QV AvJfZ72cV+n6sKPSUbDWIwCE4uJkog6w/VX6q2OCAgRSwYocA3NvMOgM1OgW3IUZyyWs lYbz6N6k3za4mxLQOfgVvIFBsY6hn/pGhhADm45uKu5fYnPiMS1HBqoqw+m6TKEdJMUR EzJQ== X-Gm-Message-State: ANoB5pkVGhgrgXaK66ENeRJ52nKZ1Xc5R6tYXw6SlieGimiSb072bZaV Va8G9QZIn4MNWoJqlkKDmtoPQi6eiDEeRSHd X-Google-Smtp-Source: AA0mqf7D+kOAwpX1MYmUPB2Zfh31Kxe2sAIZOffcVnfXnapgcSEyw4AxWmRMsrdMfnxYElViK8DQ2w== X-Received: by 2002:a17:90b:33c8:b0:219:94b2:2004 with SMTP id lk8-20020a17090b33c800b0021994b22004mr23613229pjb.215.1670403453597; Wed, 07 Dec 2022 00:57:33 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Kory Maincent Subject: [PATCH 64/71] bootstd: Add a hunter for the extension feature Date: Wed, 7 Dec 2022 21:51:30 +1300 Message-Id: <20221207085137.445249-65-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 7cbcfe1f08e..ba00c13820f 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -43,7 +43,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("---"); @@ -69,17 +69,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(); @@ -94,7 +94,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("---"); @@ -126,7 +126,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("---"); @@ -342,7 +342,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"); @@ -373,7 +373,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(); @@ -409,7 +409,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"); @@ -418,7 +418,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 Wed Dec 7 08:51:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713157 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=RPKizqjr; 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 4NRs0n2wTXz23ns for ; Wed, 7 Dec 2022 20:09:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAD3285756; Wed, 7 Dec 2022 09:57: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=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="RPKizqjr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA98E85739; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 8669D8574F for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pf1-x430.google.com with SMTP id k79so16955680pfd.7 for ; Wed, 07 Dec 2022 00:57:38 -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=6rIoHOcoeTv5EdGzdIY/WKeVt8nOxBkfPbgzRRF1gzg=; b=RPKizqjr/zoWLQF9ZilmWTT1ti5A4UcHQ4jX4B+1fyVFh0mLJx/8f2Z1P1MgBR8Swl o61U4LVNTC8SdWfue9qpt/LBJO9uZNpqYDcq/TSRCHtXb4tlwI+D7MnxU4LW8bGYrtPi gPtDmV4Q+y4v4acGvGVoOJIS+Y/EtOUj/RzD8= 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=6rIoHOcoeTv5EdGzdIY/WKeVt8nOxBkfPbgzRRF1gzg=; b=WTQ91BUSvnT0USNb/lU6MpdWE9NeZRQBD0wca65omZXnWDonfXKunSq8rKghn2i0V4 ElHm217cZzpwDTJzt5uwQINKpzhbQkbNmcLaYdAPxkc57Y2ne2NfQG9AmPO+3sszaj3i NeWFfGRmRxCm2pp71pVKB04a6T1BhgltdsPWYXX/tgXW2zAmX/LZ3xHj6FZiEV40ykla inYPUmfZXvJtU4UVtkOZ9bsc7ANiOJU29hQ/IPvXRDWxwOVP7VUQnsSYQD7Gd7v4TahX 1GV3d+KXxccd3Cqc/GTqROaLwMiETqlaDnBobEihtl3qnaQ5Fz1xGEcKys4k2cVO/LwO pYcA== X-Gm-Message-State: ANoB5pmVVNaC79s3i9I8DXhTuqmUh4APqG15Rkocise0/Kqljzd4KVxV v8e6LOSM5CKlTRgoRLmHl+ApugqCBC0nMo/S X-Google-Smtp-Source: AA0mqf4AZwS+Akb+eDyF6q5tUmJfnqaiLTw6yGdz0v3qnrqn3pJzc+8/vK7thRhWAxke+U6oiEqZ+Q== X-Received: by 2002:a65:45c5:0:b0:46e:c7be:16fc with SMTP id m5-20020a6545c5000000b0046ec7be16fcmr61953353pgr.462.1670403456449; Wed, 07 Dec 2022 00:57:36 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 65/71] bootstd: Switch bootdev scanning to use labels Date: Wed, 7 Dec 2022 21:51:31 +1300 Message-Id: <20221207085137.445249-66-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 463d58c01d8..b84df6fefbe 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 953a9776a29..bd97162c309 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -152,7 +152,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 @@ -162,9 +163,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 @@ -187,8 +185,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 ba00c13820f..1d1d88934a4 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -47,7 +47,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(); @@ -65,28 +68,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 Wed Dec 7 08:51:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713166 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=cQYCqHxI; 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 4NRs2h1Mt9z23yq for ; Wed, 7 Dec 2022 20:10:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65589855AA; Wed, 7 Dec 2022 10:04: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=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="cQYCqHxI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 686B984BD1; Wed, 7 Dec 2022 10:03: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 61B3685748 for ; Wed, 7 Dec 2022 09:57: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-pf1-x429.google.com with SMTP id c13so9851073pfp.5 for ; Wed, 07 Dec 2022 00:57: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=n/gOUJPhduG4/Ue3SztJArVn08OWNiGTpsDFHKYmLHQ=; b=cQYCqHxIOfX8tFVb+5rAbG7OubreAIXrkTcUAD2+GyABL+2jzlD+AROCk/2vWgVqoj +Vr86FCUfg9qViD8Ljoy9ddFrWFbCFe7aXiAFx3IIO1XFca7J3lL0EV0S+4ldKnWEJxR MVm5Fl2nOR2ie/BTM2AcaCOMuOXgD8FYJuk1I= 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=n/gOUJPhduG4/Ue3SztJArVn08OWNiGTpsDFHKYmLHQ=; b=AZRwxtGwk+kHQlS7gBWaBkryxI4Fbr45+oEkvcnth/R3jKq2MTLlw5jx5r3UAXc3VG 7JypNSGy7Imfz4T6S/u8hVHH1duW5KNLivsxNiX025HY0fSi72yDybo9zyTolveI+w57 d1UgS8TEpABjV79uRjLx+rPnuMC64dT/h44vA6bCDpDRaWSwxSZ+QH6eMM9g94P9w+Lw ZtwPhvw6M2NkN9vgR0ZjQtbkL/auW5UKffgrfZP4mFNbIIHOQjr3QShmsVrrun5+s1/i vxDVQOkI2jEl+peVFZigbcknpBVTBKJv50Dgf50Id5DbFQASuSpsMS5gGl5dF9mj3/e9 XzcA== X-Gm-Message-State: ANoB5plgbzTTp4Nn8Y6GySsfygYxiN8yTbc2O3jK1u11UygdoXgK9+FR dcGRz0oi38yiBWa8UZmTTU2oQ8WASstHd64/ X-Google-Smtp-Source: AA0mqf6m5dHUU6dpNSydTHCIHyEFeyso5EHdVyWopf6IzlPT0kyKL9k5fzx7rNaiL9RyhHFv33j2Tw== X-Received: by 2002:a62:aa15:0:b0:576:dc64:2dee with SMTP id e21-20020a62aa15000000b00576dc642deemr14966767pff.2.1670403459281; Wed, 07 Dec 2022 00:57:39 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 66/71] bootstd: Allow scanning a single bootdev label Date: Wed, 7 Dec 2022 21:51:32 +1300 Message-Id: <20221207085137.445249-67-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 b84df6fefbe..da462a6ffdc 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 fdccb775a15..040ecf3a088 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 bd97162c309..738edd22a0a 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -244,14 +244,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 1d1d88934a4..6c7e7c813f3 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -68,7 +68,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) { @@ -116,7 +115,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) @@ -494,3 +492,63 @@ static int bootflow_cmd_boot(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_cmd_boot, 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); From patchwork Wed Dec 7 08:51:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713160 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=ij0IEeby; 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 4NRs1V66v2z23ns for ; Wed, 7 Dec 2022 20:09:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 97D3B85769; Wed, 7 Dec 2022 09:57: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=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="ij0IEeby"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EAB4385717; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (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 1D0FB85751 for ; Wed, 7 Dec 2022 09:57:44 +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-pg1-x52c.google.com with SMTP id q71so15688043pgq.8 for ; Wed, 07 Dec 2022 00:57:44 -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=JqwjKQ39Pbw6S4nlQ2HE+KVcXejZkQMiOu7YdwyjEpI=; b=ij0IEebydXHxxf5/EzhR1QGG9/cSk3pTk0tJksGzaNRsduRj9Y/MEoW1mdkp5pNwrM aVQHWPp2uKTIWugmuWbRirygBjMF6nTqOIye5ynkzwx9Iov1gPslvPCWzRyuBSUT60NX 6hng5UkHNNZQEqY7gZBKGnEcnsycRPf9Opo/8= 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=JqwjKQ39Pbw6S4nlQ2HE+KVcXejZkQMiOu7YdwyjEpI=; b=pXstTBVyHovq7Bl7m3xwWOTXud8IQ0zK33pYYYP5d4jo4acbS50ijjRhhc24Yh2FvM dkAWwta9alAb1CFbIjDUCTyK7yVNbbzZIoeEN/3IKThfGAJhFOVbTb/xcW+bP6xmk+3A 6Z0HuLlm3uG2DsNrtzGCK02q/R7CkEWdEYwJRKHGM6bT4SzczS3MBFeEKKp1bmRqK5TO RuhKeBD3i67q4bKm+E6wZUhRbGAVeMVnWJhZLYQXjPywao6/idGHAmZh1HJnxXzO8Y4F cY1G9OWJqrph9Af2F0gFD2kUVl5G/mU3Bel76U3BaA/UpqU9xjg4cQShXKizxszOIkaL WjIg== X-Gm-Message-State: ANoB5pngXLjwaHK34eATz5lz/xC5kpLdH79FMT6rL5xpOn2IfVasBChC zKOqHoY2OKjXEwaJbu/jkmWzuc0DcKjPSmkv X-Google-Smtp-Source: AA0mqf5yo6Qszj0m65T/kZ/NJeZ3FItsiZ8xYa2wHKhl4gQ8opfl+zaOIL4B4WEQTQZCeFNTxvLAZA== X-Received: by 2002:a05:6a00:792:b0:575:c692:3813 with SMTP id g18-20020a056a00079200b00575c6923813mr36731479pfu.7.1670403462199; Wed, 07 Dec 2022 00:57:42 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 67/71] bootstd: Drop the old bootflow_scan_first() Date: Wed, 7 Dec 2022 21:51:33 +1300 Message-Id: <20221207085137.445249-68-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 da462a6ffdc..61a4f16599c 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 040ecf3a088..2a3e47ebccb 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 738edd22a0a..5b0bdc7e684 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -238,7 +238,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 * @@ -253,25 +253,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 6c7e7c813f3..25186e3f820 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -266,7 +266,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); @@ -405,7 +406,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 Wed Dec 7 08:51:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713159 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=S6zhsP50; 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 4NRs1G58Klz23ns for ; Wed, 7 Dec 2022 20:09:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC16385766; Wed, 7 Dec 2022 09:57: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="S6zhsP50"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 906B685710; Wed, 7 Dec 2022 09:57:51 +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-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 E923285662 for ; Wed, 7 Dec 2022 09:57: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=sjg@chromium.org Received: by mail-pg1-x52e.google.com with SMTP id q1so15666470pgl.11 for ; Wed, 07 Dec 2022 00:57:46 -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=pqr4mEBFwpE5z2MUMuk6ipFyUPz4AghKu+f3Od27xlU=; b=S6zhsP50N7szU9QLVbmlsiJSHf8MNZBZdze27DWmVG+GsQQ69OyNb4Mp3EBiAUbGsb xm7mHjzXMK3JZ50AXIrniyNSs368McMoQmzawgXnTlfAUz3nOFKWd2fLSw/NKfpqp3QO SP+Koy1QushvQvfH5x85ID1EHEk7xwQyKQBD0= 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=pqr4mEBFwpE5z2MUMuk6ipFyUPz4AghKu+f3Od27xlU=; b=Z4pdBuHauNDG39QYk2GxZFCuZJt/63vaOTnIPfvoR7nSTNX1BVeyqRXJUUIn27gDtf r7lRkLyUr0Mwg0cMsliwSrbZmWb2h6NHZkluEDfauFZPHxOMFpO3bYx3g/bbF/qA5xt/ GFUIYwHvmywIr2YroOROXgCNJTRFqNUy/eT03TfrGTuIJlXFvJ50qWiOBhnssDTDcGN9 HcVjzpL3zKp1wPSSblIUNbg01t/UbgDD69o0iXBkORhAU5RGh6K4y5+cPH29o7sHBuH0 PN9OnGB38wXtqDZ7zG7KzeKgjjgIHXnakkKbJSQP4jRGJ+MczjMRe97R+N0k3S2kv6J6 Of3w== X-Gm-Message-State: ANoB5pl3AUskfx+9Kd9SKKN9EHNwxORkIJlD5HAwFTCS7t+weZlPTdbl maGfD4EbgujSqMwtJQWK/9Dmsc/yYMCbHQ+9 X-Google-Smtp-Source: AA0mqf6HHpxu/Oeym2gaZD01F3fN+ocnqH2J8aectQxF8bkCsbmF9DhlxBQcx2v/a8YzKrCyEQEdZQ== X-Received: by 2002:a65:64d1:0:b0:478:980a:53fb with SMTP id t17-20020a6564d1000000b00478980a53fbmr17636972pgv.484.1670403465037; Wed, 07 Dec 2022 00:57:45 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 68/71] bootstd: Record the bootdevs used during scanning Date: Wed, 7 Dec 2022 21:51:34 +1300 Message-Id: <20221207085137.445249-69-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 61a4f16599c..a351dc5fdf1 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 5b0bdc7e684..d96afc249cf 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -10,6 +10,10 @@ #include #include +enum { + BOOTFLOW_MAX_USED_DEVS = 16, +}; + /** * enum bootflow_state_t - states that a particular bootflow can be in * @@ -162,7 +166,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 @@ -185,6 +191,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 Wed Dec 7 08:51:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713161 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=KGD+EJpM; 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 4NRs1l502pz23ns for ; Wed, 7 Dec 2022 20:10:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1AC685729; Wed, 7 Dec 2022 09:58: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=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="KGD+EJpM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35D238570A; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 AB8768570B for ; Wed, 7 Dec 2022 09:57: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-pg1-x535.google.com with SMTP id f9so15680812pgf.7 for ; Wed, 07 Dec 2022 00:57: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=hjSYGlwf66g+8pSoVpOaVcG3eIitqJovtQ4pVN2qu88=; b=KGD+EJpMcaax/WmKwtGPiIlhurS2DeKN1l/XbZWwimQpTp0Cgl4zTtzEWeC0IQGdXj vNwMTGP7fhg9hbz7Pd0lR4EIWBQ3jL9CQozk12WVskDfsoJie8L/TsS+RqokLA4Y40Gg yQcfS88jPCBWMWwaVoa8WWKBDqs1YLnQrpaoY= 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=hjSYGlwf66g+8pSoVpOaVcG3eIitqJovtQ4pVN2qu88=; b=fxxT7ya/gXwCtEgomHNcmUtrjRjQdRAs4q/O/Zlef5XaKh1tjvlftffNb9BLK/pZtc +04Ed0zFeTB+LRtnflsA4D29CorWqWRlB+9yVuz81+3LVtFt7S87REFaN5wWRinIUwK8 G82n6kOXI/UWqcKJknoSUGdgF8kVDoGmf+ByZ8GuCTXkJ2Z5wHjZflOqK9oWuBm8hiRX WAOYgMknEeVkrY1IzSCIB4Hn4bb9IXInVyAh+rLVfMgofeeW48EOQWazKCSyGf9hJCXX WAaZYRoB2Jnc/SLRc4tqwhs0ACRLUQPClkUtzQq47gZoo9M9c2+chfeSt9LDB+r339w1 ie4g== X-Gm-Message-State: ANoB5plwhoF1uWql0RMEVAEea30Mn/40hSb2ccGHKzoJPHkXmgRdAaFT GJ9CfCb3KQreyCB+mpI1Kx++oK9n27CZ6AFq X-Google-Smtp-Source: AA0mqf77oJb6WEzza/EULe7vax9ULX7IJqlTlKzcqjdxLO9sBrwrz3Y30NneprWfaXJqJFU+ASQHmQ== X-Received: by 2002:a05:6a00:1623:b0:577:4baf:f412 with SMTP id e3-20020a056a00162300b005774baff412mr5727985pfc.77.1670403467870; Wed, 07 Dec 2022 00:57:47 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 69/71] bootstd: Add a little more logging of bootflows Date: Wed, 7 Dec 2022 21:51:35 +1300 Message-Id: <20221207085137.445249-70-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 a351dc5fdf1..85d3d6c71ce 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 Wed Dec 7 08:51:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713162 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=ipf3w0fH; 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 4NRs1z4JZJz23yq for ; Wed, 7 Dec 2022 20:10:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 227008576C; Wed, 7 Dec 2022 09:58: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="ipf3w0fH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B5F37856EF; Wed, 7 Dec 2022 09:57: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 B7BB78575C for ; Wed, 7 Dec 2022 09:57: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-pl1-x62b.google.com with SMTP id jn7so16417878plb.13 for ; Wed, 07 Dec 2022 00:57: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=eXPqe7nXxAWaGwvZNUsny5qNf1mP0Oxl+KLGS/vcjCE=; b=ipf3w0fH5Go2P36gUFWzNWsRpGslSbbCRGQnCat+1V/TVm8opE6O+PTtZ5biO3qbjl D3fJNlDw1h3b2gLsbA0mZH19Q9/ZLIi0ZSZO7HfAk0x1fpDNaQ3s6+2oAi4DttUF5rB3 c71OiYDIX4nUbbIQjQqEcMgQIkar0prcXpaYk= 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=eXPqe7nXxAWaGwvZNUsny5qNf1mP0Oxl+KLGS/vcjCE=; b=OpzQseqxiSEDSupngOao+aV9hOm3oFoz7m8XGhuZYbemkrtCPXyPoxxkkBFz3rwHL9 PmzQKCAynJgHK/vc25bH1f0mDVQPcv7IX4QDc7fg6j571qLbw2ss1WSZBDR+FM+tqjoJ foTz5I9JQ372rdAOzHgMY0/IRBPpvb4GX0nv11dfmhUJ6p5K5Feml8TH9Ai2iirBu3US ePXmeo95XBnBSQcvCVKE0UGM2wsKds1MO4HysGN/pcByKjRrnVAhlnE2LYvNyVX/YT6a oiQw+PGiSDVrfO8ZfBmDosB9FiYRYjUTWRAGE/htXMy3VZZFlHCujD0SaMA7TdxRtCYN R8GQ== X-Gm-Message-State: ANoB5pl58ucaBTPkVYnLbBl7CuX7TJXiZoX2Xo8Lj7y8VvflXKN2+3St tsYyIS1Wc/KY7C9fK+cU8diR1u4w6q1PMG+e X-Google-Smtp-Source: AA0mqf6lAH8WAseKXuk1XV/kLGZpJgLraXgdYSSxkLfHqyObCgIR/bQavpI73d+Q0M9Jtl+GLuwMkA== X-Received: by 2002:a17:902:b182:b0:189:dc5e:887d with SMTP id s2-20020a170902b18200b00189dc5e887dmr12061403plr.55.1670403471268; Wed, 07 Dec 2022 00:57:51 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 70/71] bootstd: Update documentation for new features Date: Wed, 7 Dec 2022 21:51:36 +1300 Message-Id: <20221207085137.445249-71-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 Wed Dec 7 08:51:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1713163 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=Q882reJN; 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 4NRs2D41RXz23yq for ; Wed, 7 Dec 2022 20:10:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78EE285771; Wed, 7 Dec 2022 09:58: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="Q882reJN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 06F6A85740; Wed, 7 Dec 2022 09:58:01 +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-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 8CF0185767 for ; Wed, 7 Dec 2022 09:57: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-pf1-x42e.google.com with SMTP id d82so8204276pfd.11 for ; Wed, 07 Dec 2022 00:57: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=yOBpT7tf0tFJV7TFcG+MzIHHxeK2tJJt30HXJCV6L2c=; b=Q882reJNDnlBBC+n+UlbL4rQtHjcC+cGx4h4Wh1wpcVPBNPbCfHLehGIyYForeXACC 6RemCTizZBN6WCDp91gefmtTevhCUGvU9HDF1eu5v2X7MZSJfWqGQTGl4jckqx+ALsHc uwytE1JQzEeT2ZyNZwCIfUJLxHTEgoqfd9aPo= 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=yOBpT7tf0tFJV7TFcG+MzIHHxeK2tJJt30HXJCV6L2c=; b=GTeVx4qh6rdika4whM5ItlLvl9DlSohHjB1KzIncTf5icCe2l1J1DwMORt5O4mM9d8 fkDpsHb3EvjEMTZ8CoIyTT4tzr6qqRhVsnOhPX05zTFJCPuWCR50wNPdjZlRpYHMSxcm /0yephIlZgvKEj7vRMxBBWAIFbHxu1u7HqiN/9WpnbSr8mJpPXMyg+lAaQqTFJjz+05W pVW3neoCGXpTXDlzkhWlaDq2t1pknbiA9KNDuKjxaqueb7+CbQhA+jC9QnyxBkZeXR9O JWKheGY8EJ5ENOrD1d+yM+qLJiBq0zHshGJQxX12xNP4jrWdLNYx29ePu4eJwrL6D8iC cBqA== X-Gm-Message-State: ANoB5plzVV7X9u1/OTqRLM3XQsYmk6zz1SagTfxndXztHvb06hheIc9J PpXFVoa8aeFlJfcBCp0vGToiDe5pwY+UVj5h X-Google-Smtp-Source: AA0mqf7BAkakmgmlG/g+G3nVGWlOWWfrhYefHa39dKm2OVj+tuKMKzx4JjcwNEWvRyMc5S+/Z/aAYg== X-Received: by 2002:a05:6a00:298e:b0:576:d016:ace2 with SMTP id cj14-20020a056a00298e00b00576d016ace2mr15840712pfb.45.1670403476923; Wed, 07 Dec 2022 00:57:56 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:57:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Jeffy Chen , Johan Jonker , Kever Yang , Peng Fan , Philipp Tomsich , Philipp Tomsich , Vagrant Cascadian , huang lin Subject: [PATCH 71/71] rockchip: Convert rockpro64-rk3399 to use standard boot Date: Wed, 7 Dec 2022 21:51:37 +1300 Message-Id: <20221207085137.445249-72-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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 2f9aee58197..f2c231dd978 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -42,15 +42,12 @@ #define ROCKCHIP_DEVICE_SETTINGS #endif -#include -#include #define CONFIG_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 4c964cc3770..5a06365c760 100644 --- a/include/configs/rockchip-common.h +++ b/include/configs/rockchip-common.h @@ -67,12 +67,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