]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
4 months agoMerge patch series "clk: mediatek: mt7981: clk migration for OF_UPSTREAM"
Tom Rini [Mon, 19 Aug 2024 22:13:51 +0000 (16:13 -0600)]
Merge patch series "clk: mediatek: mt7981: clk migration for OF_UPSTREAM"

Christian Marangi <ansuelsmth@gmail.com> says:

These are all the required patches to migrate clk and correctly support
OF_UPSTREAM. This will align the clk index to upstream to support the same
clk implementation with downstream and upstream DTS.

4 months agoclk: mediatek: mt7981: rename CK to CLK
Christian Marangi [Fri, 2 Aug 2024 13:53:15 +0000 (15:53 +0200)]
clk: mediatek: mt7981: rename CK to CLK

Rename each entry from CK to CLK to match the include in upstream kernel
linux.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: convert to unified infracfg gates + muxes
Christian Marangi [Fri, 2 Aug 2024 13:53:14 +0000 (15:53 +0200)]
clk: mediatek: mt7981: convert to unified infracfg gates + muxes

Convert to infracfg gates + muxes implementation now that it's
supported.

Drop infracfg-ao nodes and rename all infracfg-ao clocks to infracfg.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix support for pwm3 clock
Christian Marangi [Fri, 2 Aug 2024 13:53:13 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix support for pwm3 clock

Add and fix support for pwm3 clock. In the pwm DTSI node we were
actually using PWM2 clock for PWM3. Now that we have correct ID also add
the missing entry of gate and mux to support PWM3 clock.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: replace infracfg ID with upstream linux
Christian Marangi [Fri, 2 Aug 2024 13:53:12 +0000 (15:53 +0200)]
clk: mediatek: mt7981: replace infracfg ID with upstream linux

Replace infracfg clk ID with upstream linux version.

Add some missing clk for PWM3 and for PCIe. The same format is used here
with the factor first, then mux and then gates.

To correctly reference the gates in clk_gate function, define the
gates_offs value in clk_tree now that they are at an offset from mux and
factor.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: drop 1/1 spurious factor
Christian Marangi [Fri, 2 Aug 2024 13:53:11 +0000 (15:53 +0200)]
clk: mediatek: mt7981: drop 1/1 spurious factor

Now that we can have advanced parent handling for mux, we can drop
spurious infracfg 1/1 factor. This is in preparation to make the clk
ID match the ID in upstream include for mt7981.

Drop the factor entry from mt7981-clk.h and reference to them in
mt7981.dtsi. Muxes and gates are updated to reference the topckgen clk
following how it's done in upstream kernel linux. Add relevant clk type
flag in clk_tree for infracfg and topckgen.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: implement sgmii0/1 clock
Christian Marangi [Fri, 2 Aug 2024 13:53:10 +0000 (15:53 +0200)]
clk: mediatek: mt7981: implement sgmii0/1 clock

Implement missing sgmii0/1 clock and update the compatible the DTS to
match upstream kernel linux and in preparation for OF_UPSTREAM support
since the ethernet node define these additional clocks.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix wrong parent list for INFRA_PWM1_SEL mux
Christian Marangi [Fri, 2 Aug 2024 13:53:09 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix wrong parent list for INFRA_PWM1_SEL mux

Fix wrong parent list for INFRA_PWM1_SEL mux. The list is incorrect and
the parents are just 2. This also match the upstream linux
implementation.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix wrong parent for TOP_FAUD clock
Christian Marangi [Fri, 2 Aug 2024 13:53:08 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix wrong parent for TOP_FAUD clock

Fix wrong parent for TOP_FAUD clock. Upstream linux sets the parent for
TOP_FAUD to TOP_AUD_SEL instead of CB_CKSQ_40M.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: swap wrong clock-names for spi nodes
Christian Marangi [Fri, 2 Aug 2024 13:53:07 +0000 (15:53 +0200)]
clk: mediatek: mt7981: swap wrong clock-names for spi nodes

Swap wrong clock-names for spi nodes as they were wrong and the spi-clk
was referencing the sel-clk and the sel-clk was referencing the spi-clk.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: add missing clock for spi1 node
Christian Marangi [Fri, 2 Aug 2024 13:53:06 +0000 (15:53 +0200)]
clk: mediatek: mt7981: add missing clock for spi1 node

Add missing clock for spi1 node. Clocks taken from upstream clock
definition and clock mux.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix wrong clock definition for spi2
Christian Marangi [Fri, 2 Aug 2024 13:53:05 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix wrong clock definition for spi2

Fix wrong clock definition for spi2 node as they reference spi0 clock
instead of spi2.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix wrong mux width for pwm2 and pwm1 clock
Christian Marangi [Fri, 2 Aug 2024 13:53:04 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix wrong mux width for pwm2 and pwm1 clock

Fix wrong mux width for pwm2 and pwm1. Upstream have width 1 but U-Boot
have width set to 2. Change the value to follow upstream implementation.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: fix typo for infra_i2c0_ck
Christian Marangi [Fri, 2 Aug 2024 13:53:03 +0000 (15:53 +0200)]
clk: mediatek: mt7981: fix typo for infra_i2c0_ck

Fix a typo for infra_i2c0_ck where 0 was misspelled as O.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7981: add missing clock for infra_ipcie_pipe
Christian Marangi [Fri, 2 Aug 2024 13:53:02 +0000 (15:53 +0200)]
clk: mediatek: mt7981: add missing clock for infra_ipcie_pipe

Add missing clock for infra_ipcie_pipe to make PCIe correctly work. This
clock is a parent of the fixed clock from topckgen cb_cksq_40m.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoMerge patch series "clk: mediatek: mt7623: clk migration for OF_UPSTREAM"
Tom Rini [Mon, 19 Aug 2024 22:13:01 +0000 (16:13 -0600)]
Merge patch series "clk: mediatek: mt7623: clk migration for OF_UPSTREAM"

Christian Marangi <ansuelsmth@gmail.com> says:

These are all the required patches to migrate clk and correctly support
OF_UPSTREAM. This will align the clk index to upstream to support the same
clk implementation with downstream and upstream DTS.

4 months agoclk: mediatek: mt7623: remap peri clock ID and add MUX
Christian Marangi [Fri, 2 Aug 2024 13:45:05 +0000 (15:45 +0200)]
clk: mediatek: mt7623: remap peri clock ID and add MUX

Upstream kernel linux makes use of peri clock MUX to setup UART.

Add definition for these and add remap table as in the upstream clock ID
order gates are before MUX but we require MUX first and then clocks in
our downstream driver.

Convert the peri clk tree to MUX + GATE implementation.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Tested-by: Frank Wunderlich <frank-w@public-files.de>
4 months agoclk: mediatek: mt7623: remap apmixedsys clock ID
Christian Marangi [Fri, 2 Aug 2024 13:45:04 +0000 (15:45 +0200)]
clk: mediatek: mt7623: remap apmixedsys clock ID

Define remap table also for apmixedsys clock ID. The clock ID starts
from 1 instead of 0 in upstream kernel linux.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7623: define id_offs_map and import clk ID from upstream
Christian Marangi [Fri, 2 Aug 2024 13:45:03 +0000 (15:45 +0200)]
clk: mediatek: mt7623: define id_offs_map and import clk ID from upstream

Define id_offs_map and use clk ID form upstream linux kernel to have a
1:1 match for the TOPCKGEN clock and permit usage of OF_UPSTREAM with
upstream dtsi.

For all the gate clock, the clk ID starts from 1 instead of zero. Define
an additional clock tree for them and set the .gates_offs to 1 to
account for this.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7623: split clk tree to dedicated topckgen and apmixed
Christian Marangi [Fri, 2 Aug 2024 13:45:02 +0000 (15:45 +0200)]
clk: mediatek: mt7623: split clk tree to dedicated topckgen and apmixed

Split clk tree to dedicated topckgen and apmixed in preparation for
remap table.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoclk: mediatek: mt7623: fix broken peri_cgs clk with XTAL parents
Christian Marangi [Fri, 2 Aug 2024 13:45:01 +0000 (15:45 +0200)]
clk: mediatek: mt7623: fix broken peri_cgs clk with XTAL parents

Fix broken peri_cgs and infra_cgs clock with XTAL parents as they have
wrong definition of the parent type.

Correctly fix them and use CLK_PARENT_XTAL for them.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
4 months agoext4: Fix zalloc()
Richard Weinberger [Fri, 9 Aug 2024 09:54:30 +0000 (11:54 +0200)]
ext4: Fix zalloc()

Currently, zalloc() calls uncondtionally memset(),
if the allocation failes, memset() will write to a null pointer.

Fix by using kzalloc().

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 months agocompiler: Ensure __builtin_*_overflow() support
Richard Weinberger [Fri, 9 Aug 2024 09:54:29 +0000 (11:54 +0200)]
compiler: Ensure __builtin_*_overflow() support

Both gcc and clang support this for a long time.
Make sure the feature is present.

Signed-off-by: Richard Weinberger <richard@nod.at>
4 months agoext4: Fix integer overflow in ext4fs_read_symlink()
Richard Weinberger [Fri, 9 Aug 2024 09:54:28 +0000 (11:54 +0200)]
ext4: Fix integer overflow in ext4fs_read_symlink()

While zalloc() takes a size_t type, adding 1 to the le32 variable
will overflow.
A carefully crafted ext4 filesystem can exhibit an inode size of 0xffffffff
and as consequence zalloc() will do a zero allocation.

Later in the function the inode size is again used for copying data.
So an attacker can overwrite memory.

Avoid the overflow by using the __builtin_add_overflow() helper.

Signed-off-by: Richard Weinberger <richard@nod.at>
4 months agosquashfs: Fix heap corruption in sqfs_search_dir()
Richard Weinberger [Fri, 2 Aug 2024 20:05:09 +0000 (22:05 +0200)]
squashfs: Fix heap corruption in sqfs_search_dir()

res needs to be large enough to store both strings rem and target,
plus the path separator and the terminator.
Currently the space for the path separator is not accounted, so
the heap is corrupted by one byte.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
4 months agosquashfs: Fix stack overflow while symlink resolving
Richard Weinberger [Fri, 2 Aug 2024 16:36:47 +0000 (18:36 +0200)]
squashfs: Fix stack overflow while symlink resolving

The squashfs driver blindly follows symlinks, and calls sqfs_size()
recursively. So an attacker can create a crafted filesystem and with
a deep enough nesting level a stack overflow can be achieved.

Fix by limiting the nesting level to 8.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
4 months agosquashfs: Check sqfs_find_inode() return value
Richard Weinberger [Fri, 2 Aug 2024 16:36:46 +0000 (18:36 +0200)]
squashfs: Check sqfs_find_inode() return value

The function can fail and return NULL.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
4 months agosquashfs: Fix integer overflow in sqfs_inode_size()
Richard Weinberger [Fri, 2 Aug 2024 16:36:45 +0000 (18:36 +0200)]
squashfs: Fix integer overflow in sqfs_inode_size()

A carefully crafted squashfs filesystem can exhibit an extremly large
inode size and overflow the calculation in sqfs_inode_size().
As a consequence, the squashfs driver will read from wrong locations.

Fix by using __builtin_add_overflow() to detect the overflow.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
4 months agosquashfs: Fix integer overflow in sqfs_resolve_symlink()
Richard Weinberger [Fri, 2 Aug 2024 16:36:44 +0000 (18:36 +0200)]
squashfs: Fix integer overflow in sqfs_resolve_symlink()

A carefully crafted squashfs filesystem can exhibit an inode size of 0xffffffff,
as a consequence malloc() will do a zero allocation.
Later in the function the inode size is again used for copying data.
So an attacker can overwrite memory.
Avoid the overflow by using the __builtin_add_overflow() helper.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
4 months agodlmalloc: Make sure allocation size is within malloc area
Richard Weinberger [Fri, 2 Aug 2024 10:08:46 +0000 (12:08 +0200)]
dlmalloc: Make sure allocation size is within malloc area

Since U-Boot does not support memory overcommit we can
enforce that the allocation size is within the malloc area.
This is a simple and efficient hardening measure to mitigate
further integer overflows in dlmalloc.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agodlmalloc: Fix integer overflow in sbrk()
Richard Weinberger [Fri, 2 Aug 2024 10:08:45 +0000 (12:08 +0200)]
dlmalloc: Fix integer overflow in sbrk()

Make sure that the new break is within mem_malloc_start
and mem_malloc_end before making progress.
ulong new = old + increment; can overflow for extremely large
increment values and memset() can get wrongly called.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agodlmalloc: Fix integer overflow in request2size()
Richard Weinberger [Fri, 2 Aug 2024 10:08:44 +0000 (12:08 +0200)]
dlmalloc: Fix integer overflow in request2size()

req is of type size_t, casting it to long opens the door
for an integer overflow.
Values between LONG_MAX - (SIZE_SZ + MALLOC_ALIGN_MASK) - 1 and LONG_MAX
cause and overflow such that request2size() returns MINSIZE.

Fix by removing the cast.
The origin of the cast is unclear, it's in u-boot and ppcboot since ever
and predates the CVS history.
Doug Lea's original dlmalloc implementation also doesn't have it.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agox86: Fix ptrdiff_t for x86_64
Richard Weinberger [Fri, 2 Aug 2024 10:08:43 +0000 (12:08 +0200)]
x86: Fix ptrdiff_t for x86_64

sbrk() assumes ptrdiff_t is large enough to enlarge/shrink the heap
by LONG_MIN/LONG_MAX.
So, use the long type, also to match the rest of the Linux ecosystem.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agobootstage: Fix out-of-bounds read in reloc_bootstage()
Richard Weinberger [Wed, 31 Jul 2024 16:07:54 +0000 (18:07 +0200)]
bootstage: Fix out-of-bounds read in reloc_bootstage()

bootstage_get_size() returns the total size of the data structure
including associated records.
When copying from gd->bootstage, only the allocation size of gd->bootstage
must be used. Otherwise too much memory is copied.

This bug caused no harm so far because gd->new_bootstage is always
large enough and reading beyond the allocation length of gd->bootstage
caused no problem due to the U-Boot memory layout.

Fix by using the correct size and perform the initial copy directly
in bootstage_relocate() to have the whole relocation process in the
same function.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agoext4: Improve feature checking
Richard Weinberger [Mon, 29 Jul 2024 21:37:31 +0000 (23:37 +0200)]
ext4: Improve feature checking

Evaluate the filesystem incompat and ro_compat bit fields to judge
whether the filesystem can be read or written.
For the read side only a scary warning is shown so far.
I'd love to abort mounting too, but I fear this will break some setups
where the driver works by chance.

Signed-off-by: Richard Weinberger <richard@nod.at>
4 months agolib: elf: Fix bootelf -p crash issue
JianfengA.Zhu@sony.com [Wed, 7 Aug 2024 02:20:07 +0000 (02:20 +0000)]
lib: elf: Fix bootelf -p crash issue

Do not load and flush segments whose program header type is not
PT_LOAD to avoid crash happen.

bootelf will load all program headers and then flush cache.
Since PT_GNU_STACK start address is 0x0, crash happens when
it flushes PT_GNU_STACK area for target that memory cannot be
accessed from address 0x0.

crash call stack:
====================================================================
bootelf -p
|-> do_bootelf (cmd/elf.c)
 |-> load_elf_image_phdr (lib/elf.c) /* Load each program header */
  |-> for (i = 0; i < ehdr->e_phnum; ++i) { /* e_phnum is 2 */
   |-> flush_cache(start=0, size=0) (arch/arm/lib/cache.c) (*1)
    |-> flush_dcache_range(start=0, 0); (arch/arm/cpu/armv8/cache_v8.c)
     |-> __asm_flush_dcache_range(start=0, 0) (arch/arm/cpu/armv8/cache.S)
      |-> /* clean & invalidate data or unified cache */
      |-> dc      civac, x0       <<== crash happen x0:start=0
====================================================================
*1 Here the p_paddr and p_filesz of the GNU_STACK program are 0.

hello_world elf image program headers
====================================================================
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000080ff0000 0x0000000080ff0000
                 0x0000000000010390 0x0000000000010390  R E    0x10000
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .eh_frame
   01
====================================================================

bootelf -p crash error log
====================================================================
bootelf -p 0x80f00000
"Synchronous Abort" handler, esr 0x96000147, far 0x0
elr: 000000008f6035bc lr : 000000008f66ff54 (reloc)
elr: 00000000bd9475bc lr : 00000000bd9b3f54
x0 : 0000000000000000 x1 : 0000000000000000
x2 : 0000000000000040 x3 : 000000000000003f
x4 : 0000000081000390 x5 : 00000000bd12da98
x6 : 0000000000000010 x7 : 0000000000000010
x8 : 000000000000000a x9 : 00000000bd156b30
x10: 00000000bd1526e0 x11: 0000000000000000
x12: 0000000000000004 x13: 00000000bda00000
x14: 00000000ffffffff x15: 00000000bd12dab7
x16: 00000000bd957b14 x17: 0000000000000000
x18: 00000000bd13fd90 x19: 0000000080f000b0
x20: 0000000080f00000 x21: 0000000000000002
x22: 0000000000000000 x23: 0000000000000003
x24: 00000000bd9eacc0 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 00000000bd154c80 x29: 00000000bd12da70

Code: d2800082 9ac32042 d1000443 8a230000 (d50b7e20)
====================================================================

Signed-off-by: Jianfeng Zhu <JianfengA.Zhu@sony.com>
Reviewed-by: Jacky Cao <Jacky.Cao@sony.com>
Reviewed-by: Toyama, Yoshihiro <Yoshihiro.Toyama@sony.com>
4 months agoarm: dts: keystone: Move to OF_UPSTREAM
Andrew Davis [Wed, 7 Aug 2024 14:56:51 +0000 (09:56 -0500)]
arm: dts: keystone: Move to OF_UPSTREAM

Enable OF_UPSTREAM for Keystone boards. Remove DT files that
are now available in dts/upstream.

Signed-off-by: Andrew Davis <afd@ti.com>
Acked-by: Neha Malcom Francis <n-francis@ti.com>
4 months agopinmux: generic: Use ENOENT instead of ENOSYS
Sean Anderson [Sat, 10 Aug 2024 13:59:37 +0000 (09:59 -0400)]
pinmux: generic: Use ENOENT instead of ENOSYS

ENOSYS should only be used when a subsystem is completely absent.
Convert its use in pinctrl-generic to ENOENT, which better reflects the
error condition (that a function/group/pin is missing).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agoenv: remove vars that are not in default env
Ravi Minnikanti [Sun, 11 Aug 2024 18:44:15 +0000 (11:44 -0700)]
env: remove vars that are not in default env

current env_set_default_vars() doesn't delete
var that are not in the imported env. hashtable
removes vars that are not in the imported
env but present in the current env only if H_NOCLEAR
flag is not set.

This change is to avoid passing H_NOCLEAR flag if
specific vars are passed to env_set_default_vars()

Without this change:
Marvell>> env default boot_mode
Marvell>>

With the change:
Marvell>> env default boot_mode
WARNING: 'boot_mode' not in imported env, deleting it!

Signed-off-by: Ravi Minnikanti <rminnikanti@marvell.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: fix wget test failure after fixing wget issue
Yasuharu Shibata [Wed, 14 Aug 2024 12:41:07 +0000 (21:41 +0900)]
sandbox: fix wget test failure after fixing wget issue

After applying the following patch, wget test on sandbox failed[1].

  Commit: cab7867cff ("net: wget: Support retransmission a dropped packet")

Here are two reasons why the test is failed and how to fix it:

1. tcp_ack is calculated by the wrong value.
   tcp_ack needs to be calculated by the received TCP payload size.
2. wget command may have a problem that HTTP response from server
   must be divided into more than two packets.
   In this commit, HTTP response is divided into two packets.

In addition, I fixed the HTTP response returned at the correct timing.

[1] https://lore.kernel.org/u-boot/CAFLszThEbk2Jr8OZ6Hj21wPSnJjgJhaDe037RqwHvwt1KjB3_A@mail.gmail.com/

Signed-off-by: Yasuharu Shibata <yasuharu.shibata@gmail.com>
Reported-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Enable wget command
Yasuharu Shibata [Wed, 14 Aug 2024 12:41:06 +0000 (21:41 +0900)]
sandbox: Enable wget command

Enable this so that the tests run.

Fix a few warnings in the code so that CI passes.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Yasuharu Shibata <yasuharu.shibata@gmail.com>
4 months agocmd: led: fix led command usage for the LED_SW_BLINK enabled case
Mikhail Kshevetskiy [Wed, 14 Aug 2024 10:08:30 +0000 (14:08 +0400)]
cmd: led: fix led command usage for the LED_SW_BLINK enabled case

CONFIG_LED_BLINK and CONFIG_LED_SW_BLINK can be defined independently.
Led blinking works if any (or both) of them is enabled. Unfortunately
the led command help does not display blinking option if only
CONFIG_LED_SW_BLINK is enabled. This is definitely wrong.

This patch fix an issue.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Alexander Dahl <ada@thorsis.com>
4 months agospi: soft_spi: Parse cs-gpios only if num-chipselects is not <0>
Michael Polyntsov [Wed, 31 Jul 2024 04:11:29 +0000 (08:11 +0400)]
spi: soft_spi: Parse cs-gpios only if num-chipselects is not <0>

Some boards don't have chipselect lines for leds so cs-gpios is not
specified in the dts leading to probing error. Fix it by making
behavior similar to the one in Linux, parse num-chipselects and
if it is zero, ignore cs-gpios.

Signed-off-by: Michael Polyntsov <michael.polyntsov@iopsys.eu>
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
4 months agospi: soft_spi: fix miso gpio property name
Mikhail Kshevetskiy [Wed, 31 Jul 2024 04:11:28 +0000 (08:11 +0400)]
spi: soft_spi: fix miso gpio property name

The patch fix a missprint introduced in commit 2e9fe73a883a ("spi: soft_spi:
Support the recommended soft spi properties").

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
4 months agoMerge tag 'i2c-dm-updates-for-v2024-10-next' of https://source.denx.de/u-boot/custodi...
Tom Rini [Tue, 13 Aug 2024 16:09:45 +0000 (10:09 -0600)]
Merge tag 'i2c-dm-updates-for-v2024-10-next' of https://source.denx.de/u-boot/custodians/u-boot-i2c into next

i2c DM updates for v2024.10 next

- Add series from Simon, which removes old content in i2c.h
  so that we can move towards having just the dm API.

  It does not remove any boards, but instead removes functionality.

4 months agoi2c: Remove CFG_SYS_I2C_DIRECT_BUS
Simon Glass [Sun, 11 Aug 2024 14:50:47 +0000 (08:50 -0600)]
i2c: Remove CFG_SYS_I2C_DIRECT_BUS

Now that this is always 1, remove it and the associated dead code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove CFG_SYS_I2C_MAX_HOPS
Simon Glass [Sun, 11 Aug 2024 14:50:46 +0000 (08:50 -0600)]
i2c: Remove CFG_SYS_I2C_MAX_HOPS

Now that this is always 0, remove it and the associated dead code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Drop i2c_get_bus_num_fdt() and i2c_reset_port_fdt()
Simon Glass [Sun, 11 Aug 2024 14:50:45 +0000 (08:50 -0600)]
i2c: Drop i2c_get_bus_num_fdt() and i2c_reset_port_fdt()

These functions are 11 years old and are only used by one board. Drop
them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Drop CFG_SYS_MAX_I2C_BUS
Simon Glass [Sun, 11 Aug 2024 14:50:44 +0000 (08:50 -0600)]
i2c: Drop CFG_SYS_MAX_I2C_BUS

Only one board uses this option and it is very old. Let's drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove I2C_GET_BUS()
Simon Glass [Sun, 11 Aug 2024 14:50:43 +0000 (08:50 -0600)]
i2c: Remove I2C_GET_BUS()

This is very old, predating even the legacy I2C support, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove I2C_SET_BUS()
Simon Glass [Sun, 11 Aug 2024 14:50:42 +0000 (08:50 -0600)]
i2c: Remove I2C_SET_BUS()

This is very old, predating even the legacy I2C support, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoocteon: Drop OCTEON_I2C_FDT dead code
Simon Glass [Sun, 11 Aug 2024 14:50:41 +0000 (08:50 -0600)]
octeon: Drop OCTEON_I2C_FDT dead code

This option is not defined by any board, so drop the code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Drop reference to SYS_I2C_INIT_BOARD
Simon Glass [Sun, 11 Aug 2024 14:50:40 +0000 (08:50 -0600)]
i2c: Drop reference to SYS_I2C_INIT_BOARD

This is not now used by any boards, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agofsl: mxc: Drop legacy I2c
Simon Glass [Sun, 11 Aug 2024 14:50:39 +0000 (08:50 -0600)]
fsl: mxc: Drop legacy I2c

Drop some old code from the mxc_i2c and ddr/fsl drivers. This will allow
removal of very old common I2C code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agodate: Drop the legacy I2C code
Simon Glass [Sun, 11 Aug 2024 14:50:38 +0000 (08:50 -0600)]
date: Drop the legacy I2C code

Drop two generations of old code in this command. All boards should use
driver model for I2C from 2021.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agortc: Drop CFG_SYS_RTC_BUS_NUM
Simon Glass [Sun, 11 Aug 2024 14:50:37 +0000 (08:50 -0600)]
rtc: Drop CFG_SYS_RTC_BUS_NUM

This option is very old and the migration deadline was years ago. Drop
it so that the I2C system can be simplified.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoMPC837XERDB: ethernut5: work_92105: Drop CMD_DATE
Simon Glass [Sun, 11 Aug 2024 14:50:36 +0000 (08:50 -0600)]
MPC837XERDB: ethernut5: work_92105: Drop CMD_DATE

These use pre-driver model code and it is several years since the
migration deadline. Disable the 'date' command so that this old code can
be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agomx28 / mx51: Drop CMD_DATE
Simon Glass [Sun, 11 Aug 2024 14:50:35 +0000 (08:50 -0600)]
mx28 / mx51: Drop CMD_DATE

These use pre-driver model code and it is several years since the
migration deadline. Disable the 'date' command so that this old code can
be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoarmv8: ls2085a: Drop CMD_DATE
Simon Glass [Sun, 11 Aug 2024 14:50:34 +0000 (08:50 -0600)]
armv8: ls2085a: Drop CMD_DATE

These boards use pre-driver model code and it is several years since the
migration deadline. Disable the 'date' command so that this old code can
be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agomips: malta: Drop CMD_DATE
Simon Glass [Sun, 11 Aug 2024 14:50:33 +0000 (08:50 -0600)]
mips: malta: Drop CMD_DATE

These boards use pre-driver model code and it is several years since the
migration deadline. Disable the 'date' command so that this old code can
be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove CFG_I2C_MULTI_BUS
Simon Glass [Sun, 11 Aug 2024 14:50:32 +0000 (08:50 -0600)]
i2c: Remove CFG_I2C_MULTI_BUS

This is used by a few boards but we are years past the migration date,
so let's drop it now.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove IC2_xxx enum
Simon Glass [Sun, 11 Aug 2024 14:50:31 +0000 (08:50 -0600)]
i2c: Remove IC2_xxx enum

This is only used by devkit3250 which is being removed. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoi2c: Remove board_i2c_init()
Simon Glass [Sun, 11 Aug 2024 14:50:30 +0000 (08:50 -0600)]
i2c: Remove board_i2c_init()

This function is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoMerge patch series "Universal Payload initial series"
Tom Rini [Fri, 9 Aug 2024 22:03:21 +0000 (16:03 -0600)]
Merge patch series "Universal Payload initial series"

Simon Glass <sjg@chromium.org> says:

Universal Payload (UPL) is an Industry Standard for firmware
components[1]. UPL is designed to improve interoperability within the
firmware industry, allowing mixing and matching of projects with less
friction and fewer project-specific implementations. UPL is
cross-platform, supporting ARM, x86 and RISC-V initially.

This series provides some initial support for this, targeting 0.9.1 and
sandbox only.

Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability tests

4 months agoupl: Add an end-to-end test
Simon Glass [Wed, 7 Aug 2024 22:47:39 +0000 (16:47 -0600)]
upl: Add an end-to-end test

Now that sandbox_vpl supports UPL, add a test that checks that the
payload can be loaded by SPL and the handoff information passed through
to U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Add an SPL loader for UPL
Simon Glass [Wed, 7 Aug 2024 22:47:38 +0000 (16:47 -0600)]
sandbox: Add an SPL loader for UPL

Add support for loading a UPL image from SPL. This uses the simple FIT
implementation, but also loads the full FIT just to permit more testing.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Add a flag to enable UPL
Simon Glass [Wed, 7 Aug 2024 22:47:37 +0000 (16:47 -0600)]
sandbox: Add a flag to enable UPL

UPL significantly alters the boot flow for sandbox. Add a flag to enable
this so that it can be enabled only on tests which need it.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add initial documentation
Simon Glass [Wed, 7 Aug 2024 22:47:36 +0000 (16:47 -0600)]
upl: Add initial documentation

Add some documentation to explain the basic concept along with a link
to the full spec.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox_vpl: Enable Universal Payload
Simon Glass [Wed, 7 Aug 2024 22:47:35 +0000 (16:47 -0600)]
sandbox_vpl: Enable Universal Payload

Use the sandbox_vpl build to test UPL since it supports a real devicetree
in SPL. The sandbox_spl build uses OF_PLATDATA.

Enable writing the UPL handoff in SPL and reading it in U-Boot proper.
Provide a test to check that this handoff works.

Note that the test uses the standard devicetree rather than the test one,
since it is a lot smaller and fits in the existing bloblist.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Plumb in universal payload to the init process
Simon Glass [Wed, 7 Aug 2024 22:47:34 +0000 (16:47 -0600)]
upl: Plumb in universal payload to the init process

Read the UPL early in boot so that it is available. For now none of the
information is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agospl: Plumb in the Universal Payload handoff
Simon Glass [Wed, 7 Aug 2024 22:47:33 +0000 (16:47 -0600)]
spl: Plumb in the Universal Payload handoff

Specify the FIT and include information about each loaded image, as
required by the UPL handoff.

Write the UPL handoff into the bloblist before jumping to the next phase.

Control this using a runtime flag to avoid conflicting with other
handoff mechanisms.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agospl: Set SPL_FIT_FOUND for full FIT also
Simon Glass [Wed, 7 Aug 2024 22:47:32 +0000 (16:47 -0600)]
spl: Set SPL_FIT_FOUND for full FIT also

This flag is set for simple FIT, so set it for full FIT too.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add support for Universal Payload in SPL
Simon Glass [Wed, 7 Aug 2024 22:47:31 +0000 (16:47 -0600)]
upl: Add support for Universal Payload in SPL

Add the basic code to create a handoff structure in SPL, so it can be
passed to the next phase. For now this is not plumbed in.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add a command
Simon Glass [Wed, 7 Aug 2024 22:47:30 +0000 (16:47 -0600)]
upl: Add a command

Add a 'upl' command to work with Universal Payload features. For now it
only supports reading and writing a handoff structure.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add basic tests
Simon Glass [Wed, 7 Aug 2024 22:47:29 +0000 (16:47 -0600)]
upl: Add basic tests

Add some unit tests to check that we can write a UPL handoff and read it
back.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add support for writing a upl handoff
Simon Glass [Wed, 7 Aug 2024 22:47:28 +0000 (16:47 -0600)]
upl: Add support for writing a upl handoff

Universal Payload provides a standard way of handing off control between
two firmware phases. Add support for writing the handoff information from
a structure.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agoupl: Add support for reading a upl handoff
Simon Glass [Wed, 7 Aug 2024 22:47:27 +0000 (16:47 -0600)]
upl: Add support for reading a upl handoff

Universal Payload provides a standard way of handing off control between
two firmware phases. Add support for reading the handoff information into
a structure.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Set up global_data earlier
Simon Glass [Wed, 7 Aug 2024 22:47:26 +0000 (16:47 -0600)]
sandbox: Set up global_data earlier

It is possible for U-Boot functions such as printf() to be called
within state_init(). This can end up checking gd->flags (e.g. in putc())
before global_data is set up.

Move the setup earlier to avoid this. This fixes the suppression of some
debug output in memory allocation (when enabled).

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Add ELF file to VPL u-boot.img
Simon Glass [Wed, 7 Aug 2024 22:47:25 +0000 (16:47 -0600)]
sandbox: Add ELF file to VPL u-boot.img

At present sandbox builds package up u-boot.bin in the .img file. This
cannot actually be executed, since it is not an ELF file.

For sandbox_vpl we want to be able to run the full boot flow.

Adjust the build rule for sandbox_vpl to package the ELF file and
thereby allow full testing of the sandbox transition from SPL to U-Boot
proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Return error code from read/write/seek
Simon Glass [Wed, 7 Aug 2024 22:47:24 +0000 (16:47 -0600)]
sandbox: Return error code from read/write/seek

The existing API for these functions is different from the rest of
U-Boot, in that any error code must be obtained from the errno variable
on failure. This variable is part of the C library, so accessing it
outside of the special 'sandbox' shim-functions is not ideal.

Adjust the API to return an error code, to avoid this. Update existing
uses to check for any negative value, rather than just -1.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: fdt: Avoid overwriting an existing fdt
Simon Glass [Wed, 7 Aug 2024 22:47:23 +0000 (16:47 -0600)]
sandbox: fdt: Avoid overwriting an existing fdt

Since the removal of OF_HOSTFILE logic in board_fdt_blob_setup(), the
logic for obtaining the DT is handled in the OF_BOARD option. If a
devicetree comes from a bloblist it is immediately overwritten by this
function.

Fix this by skipping the function if a devicetree is already present.

This is sort-of a fix for e7fb7896 ("sandbox: Remove OF_HOSTFILE") but
it has only come to light since bloblist was added, so I have not added
a Fixes tag.

Unfortunately it is not possible to report the correct FDT source with
the current code. It might be best to use an error-return code for
board_fdt_blob_setup() so that an error can be reported if the board
does not provide the DT.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agofdt: Don't overwrite bloblist devicetree
Simon Glass [Wed, 7 Aug 2024 22:47:22 +0000 (16:47 -0600)]
fdt: Don't overwrite bloblist devicetree

When the devicetree comes from a bloblist, it is currently overwritten
by the appended one, if present. It should be preserved.

Adjust the logic to support this.

Fixes: 70fe2385943 ("fdt: Allow the devicetree to come from a bloblist")
Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agotest: Move some SPL-loading test-code into sandbox common
Simon Glass [Wed, 7 Aug 2024 22:47:21 +0000 (16:47 -0600)]
test: Move some SPL-loading test-code into sandbox common

This code is useful for loading an image in sandbox_spl so move it into
a place where it can be called as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agosandbox: Fix a comment in os_find_u_boot()
Simon Glass [Wed, 7 Aug 2024 22:47:20 +0000 (16:47 -0600)]
sandbox: Fix a comment in os_find_u_boot()

Fix a missing dot in a comment, since '..' is confusing.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
4 months agosandbox: Use const in os_jump_to_file()
Simon Glass [Wed, 7 Aug 2024 22:47:19 +0000 (16:47 -0600)]
sandbox: Use const in os_jump_to_file()

The argument array is not changed by the callee, so mark it const.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
4 months agoMerge tag 'i2cupdates-for-v2024-10-next' of https://source.denx.de/u-boot/custodians...
Tom Rini [Fri, 9 Aug 2024 14:22:50 +0000 (08:22 -0600)]
Merge tag 'i2cupdates-for-v2024-10-next' of https://source.denx.de/u-boot/custodians/u-boot-i2c into next

i2c updates for v2024.10 next

- DM_I2C conversion for some remaining boards
  from Anatolij

4 months agoboard: vining_2000: convert to DM_I2C
Anatolij Gustschin [Wed, 7 Aug 2024 22:34:38 +0000 (00:34 +0200)]
board: vining_2000: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: cm_fx6: convert to DM_I2C
Anatolij Gustschin [Wed, 7 Aug 2024 13:09:33 +0000 (15:09 +0200)]
board: cm_fx6: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board
removal warning. Convert EEPROM access to use DM_I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
4 months agoboard: vf610twr: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:13 +0000 (18:15 +0200)]
board: vf610twr: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: novena: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:09 +0000 (18:15 +0200)]
board: novena: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning. Convert EEPROM
and IT6251 access to use DM_I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
4 months agoboard: rut: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:08 +0000 (18:15 +0200)]
board: rut: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: sl50: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:07 +0000 (18:15 +0200)]
board: sl50: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: igep003x: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:06 +0000 (18:15 +0200)]
board: igep003x: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: cm-t43: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:05 +0000 (18:15 +0200)]
board: cm-t43: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: chiliboard: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:04 +0000 (18:15 +0200)]
board: chiliboard: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 months agoboard: shc: convert to DM_I2C
Anatolij Gustschin [Sat, 3 Aug 2024 16:15:03 +0000 (18:15 +0200)]
board: shc: convert to DM_I2C

Conversion to DM_I2C is mandatory, rework to remove
use of legacy I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
4 months agoMerge patch series "alist: Implement a pointer list / array of structs"
Tom Rini [Wed, 7 Aug 2024 14:49:18 +0000 (08:49 -0600)]
Merge patch series "alist: Implement a pointer list / array of structs"

Simon Glass <sjg@chromium.org> says:

This data structure provides a list of pointers / array of structures.
I was planning to use it for the lmb restructure, to allow it to
support any number of entries, but then I gave up on it.

There are quite a few places in U-Boot where such a list would be
useful, since it supports growing the array.

[...]
Example:

 struct my_struct obj;
 struct my_struct *ptr = alist_add(&lst, &obj, struct my_struct);

 // now ptr is in the list

[trini: Reword the cover letter slightly, do not merge the RFC portion]

4 months agoalist: Add support for an allocated pointer list
Simon Glass [Tue, 30 Jul 2024 14:39:37 +0000 (08:39 -0600)]
alist: Add support for an allocated pointer list

In various places it is useful to have an array of structures, but allow
it to grow. In some cases we work around it by setting maximum number of
entries, using a Kconfig option. In other places we use a linked list,
which does not provide for random access and can complicate the code.

Introduce a new data structure, which is a variable-sized list of structs
each of the same, pre-set size. It provides O(1) access and is reasonably
efficient at expanding linearly, since it doubles in size when it runs out
of space.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agolib: Handle a special case with str_to_list()
Simon Glass [Tue, 30 Jul 2024 14:39:36 +0000 (08:39 -0600)]
lib: Handle a special case with str_to_list()

The current implementation can return an extra result at the end when
the string ends with a space. Fix this by adding a special case.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 months agomalloc: Support testing with realloc()
Simon Glass [Tue, 30 Jul 2024 14:39:35 +0000 (08:39 -0600)]
malloc: Support testing with realloc()

At present in tests it is possible to cause an out-of-memory condition
with malloc() but not realloc(). Add support to realloc() too, so code
which uses that function can be tested.

Signed-off-by: Simon Glass <sjg@chromium.org>