summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2025-06-02Merge patch series "Audit include list for include/[a-m]*.h"Tom Rini
Tom Rini <trini@konsulko.com> says: Hey all, Related to my other series I've posted recently on cleaning up some headers, this series here is the result of at least lightly auditing the #includes used in include/[a-m]*.h. This ignores subdirectories, as at least in part I think the top-level includes we've constructed are the most likely places to have some extra transitive include paths. I'm sure there's exceptions and I'll likely audit deeper once this first pass is done. This only gets as far as "include/m*.h" because I didn't want this to get too big. This also sets aside <miiphy.h> and <phy.h>. While miiphy.h does not directly need <phy.h> there are *so* many users and I think I had half of the tree just about not building when I first tried. It might be worth further investigation, but it might just be OK as-is. Link: https://lore.kernel.org/r/20250521230119.2084088-1-trini@konsulko.com
2025-06-02include/mtd.h: Cleanup usageTom Rini
There are only a few things found in <mtd.h> today. Go through and audit the C files which include <mtd.h> and remove it when not required. Then, add it to the files which had either missed it or had an indirect inclusion of it. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-06-02include/ide.h: Cleanup usageTom Rini
At this point in time, <ide.h> provides the IDE_BUS macro and the function prototype for ide_set_reset, which is used with IDE_RESET. The only files which should include this header are the ones that either use that macro or that function. Remove <blk.h> from <ide.h> and remove <ide.h> from places which do not need it. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-30abuf: Add a way to printf() into a bufferSimon Glass
It is useful to format a string into a buffer, with the sizing handled automatically. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a function to copy a bufferSimon Glass
It is useful to be able to copy an abuf, to allow changes while preserving the original. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a helper for initing and allocating a bufferSimon Glass
This construct appears in various places. Reduce code size by adding a function for it. It inits the abuf, then allocates it to the requested size. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-29Merge patch series "Remove <env.h> from <net.h>"Tom Rini
Tom Rini <trini@konsulko.com> says: Hey all, This is a v3 of Simon's series[1] and depends on the series[2] I posted the other day that removes <env.h> from <command.h>. With this series done, I believe we've tackled all of the current cases of headers which include <env.h> without directly needing it. Much of this series is in fact Simon's v2 with the main differneces being: - Removing <env.h> from <net.h> at the end - Removing env_to_ip() given how little it's used rather than shuffling around where it's declared and un-inline'ing it. For a rarely used helper, this ends up being cleaner I think. Especially looking at some of the users (which called env_get repeatedly). If there's strong opinion here about using the other method[3] we can do that instead. - Setting aside for now how to handle CMD_ELF=y and NO_NET=y because today it's actually fine as we unconditionally build lib/net_utils.c where string_to_ip() is defined. I'm unsure if a further series is warranted here or not. We rely on link-time optimization to keep code readable too. [1]: https://lore.kernel.org/all/20250501010456.3930701-1-sjg@chromium.org [2]: https://lore.kernel.org/all/20250514225002.15361-1-trini@konsulko.com [3]: https://lore.kernel.org/all/20250501010456.3930701-23-sjg@chromium.org Link: https://lore.kernel.org/r/20250515234154.1859366-1-trini@konsulko.com
2025-05-29global: Avoid indirect inclusion of <env.h> from <net.h>Tom Rini
Now that env_get_ip() has been removed, the include file <net.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <net.h> fix all of the remaining places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # net/lwip Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Martyn Welch <martyn.welch@collabora.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-29Merge patch series "Start removing <env.h> from headers when not required"Tom Rini
Tom Rini <trini@konsulko.com> says: Given Simon's series at [1] I started looking in to what brings in <env.h> when not strictly required and in turn has some unintended implicit includes. This series takes care of the places where, commonly, <linux/string.h> or <env.h> itself were required along with a few other less common cases. This sets aside for the moment what to do about net-common.h and env_get_ip() as I'm not entirely sure what's best there. [1]: https://patchwork.ozlabs.org/project/uboot/list/?series=454939&state=* Link: https://lore.kernel.org/r/20250514225002.15361-1-trini@konsulko.com
2025-05-29global: Avoid indirect inclusion of <env.h> from <command.h>Tom Rini
The include file <command.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <command.h> fix all of the places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> # android, bcb Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # spawn Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-29Merge patch series "regex patches"Tom Rini
Rasmus Villemoes <ravi@prevas.dk> says: This started as a rather simple patch, 1/12, adding the ability to more conveniently do regex matching in shell. But with that, it became very easy to see what the slre library can and especially what it cannot do, and that way I found both outright bugs and a "wow, doesn't it support that syntax" gotcha. I couldn't find any tests ('git grep slre -- test/' was empty), so I added a small test suite and tweaked slre.c. Link: https://lore.kernel.org/r/20250513084034.654865-1-ravi@prevas.dk
2025-05-29slre: implement support for ranges in character classesRasmus Villemoes
When trying to use U-Boot's regex facility, it is a rather large gotcha that [a-z] range syntax is not supported. It doesn't require a lot of extra code to implement that; we just let the regular parsing emit the start and end literal symbols as usual, and add a new "escape" code RANGE. At match time, this means the code will first just see an 'a' and try to match that, and only then recognize that it's actually part of a range and then do the 'a' <= ch <= 'z' test. Of course, this means that a - in the middle of a [] pair no longer matches a literal dash, but I highly doubt anybody relies on that. Putting it first or last, or escaping it with \, as in most other RE engines, continues to work. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-05-29slre: fix matching of escape sequence used inside character classRasmus Villemoes
At the compile stage, the anyof() function clearly intends to handle escape sequences like \d (for digits) inside square brackets, since the logic emits a 0 byte followed by the code representing the character class (NONSPACE, SPACE or DIGIT). However, this is not handled in the corresponding match helper is_any_of(); it just naively loops over all the bytes in the ->data array emitted by anyof() and compares those directly to the current character. For example, this means that the string "\x11" (containing the single character with value 17) is matched by the regex "[#%\d]", because DIGIT happens to be 17. Fix that by recognizing a zero byte as indicating something special and act accordingly. In order not to repeat the "increment *ofs and return 1" in all places, put those two lines after a new match: label. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-05-29slre: refactor is_any_but()Rasmus Villemoes
As preparation for fixing the handling of backslash-escapes used inside a character class, refactor is_any_but() to be defined in terms of is_any_of() so we don't have to repeat the same logic in two places. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-05-29slre: drop wrong "anchored" optimizationRasmus Villemoes
The regex '^a|b' means "does the string start with a, or does it have a b anywhere", not "does the string start with a or b" (the latter should be spelled '^[ab]' or '^(a|b)'). It should match exactly the same strings as 'b|^a'. But the current implementation hard-codes an assumption that when the regex starts with a ^, the whole regex must match from the beginning, i.e. it only attempts at offset 0. It really should be completely symmetrical to 'b|c$' ("does it have a b anywhere or end with c?"), which is treated correctly. Another quirk is that currently the regex 'x*$', which should match all strings (because it just means "does the string end with 0 or more x'es"), does not, because in the unanchored case we never attempt to match at ofs==len. In the anchored case, '^x*$', this works correctly and matches exactly strings (including the empty string) consisting entirely of x'es. Fix both of these issues by dropping all use of the slre->anchored member and always test at all possible offsets. If the regex does have a ^ somewhere (including after a | branch character), that is correctly handled by the match engine by only matching when *ofs is 0. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-05-27binman: Read the skip-at-start value on startupSimon Glass
This value provides an offset for all image-pos values in the image. Read it on startup so that we can take account of it when calculating positions. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-26Merge tag 'v2025.07-rc3' into nextTom Rini
Prepare v2025.07-rc3
2025-05-25efi_loader: Run dhcp if an http boot option is selectedIlias Apalodimas
The EFI boot manager relies on having an IP address before trying to boot an EFI HTTP(s) boot entry. However, defining it as a boot or pre-boot command is not always the right answer since it will unconditionally add delay to the board boot, even if we don't boot over the network. So let's do a DHCP request from the boot manager, if 'ipaddr' is empty and fail early if we don't have an address. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Michal Simek <michal.simek@amd.com>
2025-05-25efi: Rename END to EFI_DP_ENDSimon Glass
This exported symbol has a very generic name. Rename it to indicate that it relates to EFI and device-paths. Fix checkpatch warnings related to use of multiple assignments. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-25efi_loader: Separate device path into its own headerSimon Glass
These functions are useful for the EFI app. As a first step towards making these available outside lib/efi_loader, create a separate header file and include it where needed. Add proper comments to the functions, since many are missing at present. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-23Merge patch series "BOOTP/DHCPv4 enhancements"Tom Rini
Sean Edmond <seanedmond@microsoft.com> says: In our datacenter application, a single DHCP server is servicing 36000+ clients. Improvements are required to the DHCPv4 retransmission behavior to align with RFC and ensure less pressure is exerted on the server: - retransmission backoff interval maximum is configurable (environment variable bootpretransmitperiodmax) - initial retransmission backoff interval is configurable (environment variable bootpretransmitperiodinit) - transaction ID is kept the same for each BOOTP/DHCPv4 request (not recreated on each retry) For our application we'll use: - bootpretransmitperiodmax=16000 - bootpretransmitperiodinit=2000 A new configuration BOOTP_RANDOM_XID has been added to enable a randomized BOOTP/DHCPv4 transaction ID. Enhance DHCPv4 sending/parsing option 209 (PXE config file). A previous patch was accepted. A new patch fixes a possible double free() and addresses latest review comments. Link: https://lore.kernel.org/r/20240509023918.2504185-1-seanedmond@microsoft.com
2025-05-23net: bootp: BOOTP/DHCPv4 retransmission improvementsSean Edmond
This patch introduces 3 improvements to align with RFC 951: - retransmission backoff interval maximum is configurable - initial retranmission backoff interval is configurable - transaction ID is kept the same for each BOOTP/DHCPv4 request In applications where thousands of nodes are serviced by a single DHCP server, maximizing the retransmission backoff interval at 2 seconds (the current u-boot default) exerts high pressure on the DHCP server and network layer. RFC 951 “7.2. Client Retransmission Strategy” states that the retransmission backoff interval should be limited to 60 seconds. This patch allows the interval to be configurable using the environment variable "bootpretransmitperiodmax" The initial retranmission backoff period defaults to 250ms, which is also too small for these scenarios with many clients. This patch makes the initial retransmission interval to be configurable using the environment variable "bootpretransmitperiodinit". Also, on a retransmission it is not expected for the transaction ID to change (only the 'secs' field should be updated). Let's save the transaction ID and use the same transaction ID for each BOOTP/DHCPv4 exchange. Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
2025-05-22tiny-printf: Handle formatting of %p with an extra KconfigChristoph Niedermaier
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning Kconfig SPL_USE_TINY_PRINTF_POINTER_SUPPORT for pointer formatting has been added. If it is enabled, the output of %pa / %pap should be correct, and if it is disabled, the pointer formatting is completely unsupported. In addition to indicate unsupported formatting, '?' will be output. This allows enabling pointer formatting only when needed. For SPL_NET it is selected by default. Then it also supports the formatting with %pm, %pM and %pI4. In summery this level of %p support for tiny printf is possible now: 1) The standard tiny printf won't have support for pointer formatting. So it doesn't print misleading values for %pa, instead '?' will be output: %p => ? %pa => ?a %pap => ?ap 2) If SPL_USE_TINY_PRINTF_POINTER_SUPPORT is enabled or DEBUG is defined tiny printf supports formatting %p and %pa / %pap. 3) If SPL_NET is enabled the support of pointers is extended for %pm, %pM and %pI4. Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
2025-05-20net, net-lwip: wget: suppress console output when called by EFIJerome Forissier
Functions called from EFI applications should not do console output. Refactor the wget code to implement this requirement. The wget_http_info struct is used to hold the boolean that signifies whether the output is allowed or not. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-18efi_loader: Disable ANSI output for testsSimon Glass
We don't want ANSI escape-sequences written in tests since it is a pain to check the output with ut_assert_nextline() et al. Provide a way to tests to request that these characters not be sent. Add a proper function comment while we are here, to encourage others. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16strim: Sync up with Linux versionSimon Glass
Linux changed the behaviour of strim() so that a string with only spaces reduces places the terminator at the start of the string, rather than returning a pointer to the end of the string. Bring in this version, from Linux v6.14 Add a comment about the new behaviour. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-14global: Avoid indirect inclusion of <env.h> from <command.h>Tom Rini
The include file <command.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <command.h> fix all of the places which had relied on this indirect inclusion to instead include <env.h> directly. Signed-off-by: Tom Rini <trini@konsulko.com> --- Cc: Anatolij Gustschin <agust@denx.de> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jaehoon Chung <jh80.chung@samsung.com> Cc: Jerome Forissier <jerome.forissier@linaro.org> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Lukasz Majewski <lukma@denx.de> Cc: Marek Vasut <marex@denx.de> Cc: Mark Kettenis <kettenis@openbsd.org> Cc: Masahisa Kojima <kojima.masahisa@socionext.com> Cc: Mattijs Korpershoek <mkorpershoek@kernel.org> Cc: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com> Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com> Cc: Simon Glass <sjg@chromium.org> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Cc: Stefan Bosch <stefan_b@posteo.net> Cc: Tien Fong Chee <tien.fong.chee@altera.com> Cc: Tingting Meng <tingting.meng@altera.com> Cc: Tobias Waldekranz <tobias@waldekranz.com>
2025-05-11efi_loader: fix dtbdump output color and formatAdriano Cordova
Imitate in dtbdump what initrddump does for color, newlines and input handling. The output parsing in the CI is strict and with the current output the CI is not recongnizing the prompt '=>'. Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-05bootm: improve error message when gzip decompression buffer is too smallAristo Chen
Currently, when decompressing a gzip-compressed image during bootm, a generic error such as "inflate() returned -5" is shown when the buffer is too small. However, it is not immediately clear that this is caused by CONFIG_SYS_BOOTM_LEN being too small. This patch improves error handling by: - Detecting Z_BUF_ERROR (-5) returned from the inflate() call - Suggesting the user to increase CONFIG_SYS_BOOTM_LEN when applicable - Preserving the original return code from zunzip() instead of overwriting it with -1 By providing clearer hints when decompression fails due to insufficient buffer size, this change helps users diagnose and fix boot failures more easily. Signed-off-by: Aristo Chen <aristo.chen@canonical.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-05-02Merge patch series "Qualcomm: cleanup OF_LIVE fixup and fix RB1/2"Tom Rini
Caleb Connolly <caleb.connolly@linaro.org> says: Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3). With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages). Finally, some minor fixes are made for the QCM2290 RB1 board, the sdcard is enabled and it now uses USB host mode in U-Boot like it's bigger sibling the RB2. Link: https://lore.kernel.org/r/20250411-livetree-fixup-v2-0-1236823377bb@linaro.org
2025-05-02event: signal when livetree has been builtCaleb Connolly
OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages). Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2025-05-01Merge tag 'dm-pull-mayday' of git://git.denx.de/u-boot-dmTom Rini
Support for calculating video damage
2025-05-01efi_loader: GOP: Add damage notification on BLTAlexander Graf
Now that we have a damage tracking API, let's populate damage done by UEFI payloads when they BLT data onto the screen. Signed-off-by: Alexander Graf <agraf@csgraf.de> Reported-by: Da Xue <da@libre.computer> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [Alper: Add struct comment for new member] Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/u-boot/20230821135111.3558478-10-alpernebiyasak@gmail.com/
2025-05-01efi_loader: fix typo initd_sz to initrd_szAdriano Cordova
Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-01efi_loader: bootbin: do not load an initrd if none is providedAdriano Cordova
Do not try to create an initrd device path nor try to register an initrd with the EFI_LOAD_FILE2_PROTOCOL if none is provided. Handle initrd installation in efi_binary_run_dp with efi_install_initrd, imitating what is done for the fdt. Fixes: 36835a9105c ("efi_loader: binary_run: register an initrd") Reported-by: Weizhao Ouyang <o451686892@gmail.com> Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com> Tested-by: Weizhao Ouyang <o451686892@gmail.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-04-28Merge patch series "bloblist: fix the overriding of fdt from bloblist"Tom Rini
This series from Raymond Mao <raymond.mao@linaro.org> fixes some cases of passing the device tree to U-Boot via standard passage and then ensures that we set the environment variable of the device tree correctly in this case. Link: https://lore.kernel.org/r/20250331224011.2734284-1-raymond.mao@linaro.org
2025-04-28bloblist: fix the overriding of fdt from bloblistRaymond Mao
When a bloblist is valid and contains fdt, it explicitly means a previous boot stage is passing transfer list compliant with Firmware Handoff specification, thus the fdt from bloblist should not be overridden with the ones from board or env variables. Fixes: 70fe23859437 ("fdt: Allow the devicetree to come from a bloblist") Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-04-25efi_loader: print image load address in StartImageHeinrich Schuchardt
When starting image add the image load address to the debug output. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-04-25efi_loader: build with HII configuration protocolHeinrich Schuchardt
Without the HII configuration protocol the debug version of the UEFI shell cannot be used. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-04-24smbios: Do not look up children of invalid nodesSamuel Holland
If there is no UCLASS_SYSINFO device available, parent_node will be ofnode_null(). Calling ofnode_find_subnode() then triggers an assertion: drivers/core/ofnode.c:598: ofnode_find_subnode: Assertion `ofnode_valid(node)' failed. Check for a valid parent_node, not just that OF_CONTROL is enabled. Fixes: 44ffb6f0ecaf ("smbios: Allow properties to come from the device tree") Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
2025-04-23Merge patch series "Uthreads"Tom Rini
Jerome Forissier <jerome.forissier@linaro.org> says: This series introduces threads and uses them to improve the performance of the USB bus scanning code and to implement background jobs in the shell via two new commands: 'spawn' and 'wait'. The threading framework is called 'uthread' and is inspired from the barebox threads [2]. setjmp() and longjmp() are used to save and restore contexts, as well as a non-standard extension called initjmp(). This new function is added in several patches, one for each architecture that supports HAVE_SETJMP. A new symbol is defined: HAVE_INITJMP. Two tests, one for initjmp() and one for the uthread scheduling, are added to the lib suite. After introducing threads and making schedule() and udelay() a thread re-scheduling point, the USB stack initialization is modified to benefit from concurrency when UTHREAD is enabled, where uthreads are used in usb_init() to initialize and scan multiple busses at the same time. The code was tested on arm64 and arm QEMU with 4 simulated XHCI buses and some devices. On this platform the USB scan takes 2.2 s instead of 5.6 s. Tested on i.MX93 EVK with two USB hubs, one ethernet adapter and one webcam on each, "usb start" takes 2.4 s instead of 4.6 s. Finally, the spawn and wait commands are introduced, allowing the use of threads from the shell. Tested on the i.MX93 EVK with a spinning HDD connected to USB1 and the network connected to ENET1. The USB plus DHCP init sequence "spawn usb start; spawn dhcp; wait" takes 4.5 seconds instead of 8 seconds for "usb start; dhcp". [1] https://patchwork.ozlabs.org/project/uboot/list/?series=446674 [2] https://github.com/barebox/barebox/blob/master/common/bthread.c Link: https://lore.kernel.org/r/20250418141114.2056981-1-jerome.forissier@linaro.org
2025-04-23lib: time: hook uthread_schedule() into udelay()Jerome Forissier
Introduce a uthread scheduling loop into udelay() when CONFIG_UTHREAD is enabled. This means that any uthread calling into udelay() may yield to uthread and be scheduled again later. There is no delay in the scheduling loop because tests have shown that such a delay can have a detrimental effect on the console (input drops characters). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-04-23uthread: add uthread_mutexJerome Forissier
Add struct uthread_mutex and uthread_mutex_lock(), uthread_mutex_trylock(), uthread_mutex_unlock() to protect shared data structures from concurrent modifications. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-23uthread: add cooperative multi-tasking interfaceJerome Forissier
Add a new internal API called uthread (Kconfig symbol: UTHREAD) which provides cooperative multi-tasking. The goal is to be able to improve the performance of some parts of U-Boot by overlapping lengthy operations, and also implement background jobs in the U-Boot shell. Each uthread has its own stack allocated on the heap. The default stack size is defined by the UTHREAD_STACK_SIZE symbol and is used when uthread_create() receives zero for the stack_sz argument. The implementation is based on context-switching via initjmp()/setjmp()/ longjmp() and is inspired from barebox threads [1]. A notion of thread group helps with dependencies, such as when a thread needs to block until a number of other threads have returned. The name "uthread" comes from "user-space threads" because the scheduling happens with no help from a higher privileged mode, contrary to more complex models where kernel threads are defined. But the 'u' may as well stand for 'U-Boot' since the bootloader may actually be running at any privilege level and the notion of user vs. kernel may not make much sense in this context. [1] https://github.com/barebox/barebox/blob/master/common/bthread.c Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-04-22Merge patch series "ut: fix print_guid() and enable UNIT_TEST for qemu_arm64"Tom Rini
Jerome Forissier <jerome.forissier@linaro.org> says: There is a bug in the print_guid() unit test in test/common/print.c when PARTITION_TYPE_GUID is not enabled but either CMD_EFIDEBUG or EFI are. The first patch fixes the issue and the second one enables UNIT_TEST in the qemu_arm64 defconfig so that the unit tests are run in CI (this platform has CMD_EFIDEBUG so the bug applies). Link: https://lore.kernel.org/r/20250416074839.1267396-1-jerome.forissier@linaro.org
2025-04-22lib/uuid.c: use unique name for PARTITION_SYSTEM_GUIDJerome Forissier
The name defined for PARTITION_SYSTEM_GUID in list_guid[] depends on configuration options. It is "system" if CONFIG_PARTITION_TYPE_GUID is enabled or "System Partition" if CONFIG_CMD_EFIDEBUG or CONFIG_EFI are enabled. In addition, the unit test in test/common/print.c is incorrect because it expects only "system" (or a hex GUID). Make things more consistent by using a clear and unique name: "EFI System Partition" whatever the configuration, and update the unit test accordingly. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-04-19efi_selftest: check executing in EL2Heinrich Schuchardt
UEFI binaries should be executed in EL2 or EL1 even if U-Boot is started in EL3. Provide a unit test. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-04-14Merge patch series "Static initcalls"Tom Rini
Jerome Forissier <jerome.forissier@linaro.org> says: This series replaces the dynamic initcalls (with function pointers) with static calls, and gets rid of initcall_run_list(), init_sequence_f, init_sequence_f_r and init_sequence_r. This makes the code simpler and the binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510 bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig). Execution time doesn't seem to change noticeably. There is no impact on the SPL. The inline assembly fixes, although they look unrelated, are triggered on some platforms with LTO enabled. For example: kirkwood_defconfig. CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514 Link: https://lore.kernel.org/r/20250404135038.2134570-1-jerome.forissier@linaro.org
2025-04-14initcall: remove initcall_run_list()Jerome Forissier
Now that all initcalls have been converted to static calls, remove initcall_run_list(). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-13efi_loader: Moved the generated ESL file to objtreeIlias Apalodimas
Tom reports that generating the ESL file we need for authenticated capsule updates fails to work on azure which expects a RO git tree. Move it to $(objtree) Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>