Re: [PATCH v2 03/10] arm: K3: Add basic support for J784S4 SoC definition

2023-05-08 Thread Vignesh Raghavendra
[...]

On 21/03/23 19:40, Hari Nagalla wrote:
>   default 0x43c3f290 if SOC_K3_AM62A7 && CPU_V7R
> @@ -172,7 +175,7 @@ config K3_ATF_LOAD_ADDR
>  
>  config K3_DM_FW
>   bool "Separate DM firmware image"
> - depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || 
> SOC_K3_AM625 || SOC_K3_AM62A7) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
> + depends on SPL && CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || 
> SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_J784S4) && !CLK_TI_SCI && 
> !TI_SCI_POWER_DOMAIN
>   default y
>   help
> Enabling this will indicate that the system has separate DM
> @@ -194,4 +197,5 @@ source "board/ti/am62ax/Kconfig"
>  source "board/ti/j721e/Kconfig"
>  source "board/siemens/iot2050/Kconfig"
>  source "board/ti/j721s2/Kconfig"
> +source "board/ti/j784s4/Kconfig"

You are adding file to Kconfig here, but the actual file itself is
introduced only in 9/10. This breaks git bisect.  Please make sure each
individual each compile patch fine when applied in the order of posting.

>  endif

[...]

-- 
Regards
Vignesh


Re: [PATCH 05/13] x86: coreboot: Collect the address of the ACPI tables

2023-05-08 Thread Bin Meng
Hi Simon,

On Tue, May 9, 2023 at 5:23 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On Sat, 6 May 2023 at 00:05, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Fri, Mar 24, 2023 at 1:55 AM Simon Glass  wrote:
> > >
> > > Hi Bin,
> > >
> > > On Mon, 20 Mar 2023 at 20:44, Bin Meng  wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Tue, Feb 21, 2023 at 3:49 AM Simon Glass  wrote:
> > > > >
> > > > > Pick this up from the sysinfo tables and display it with the cbsysinfo
> > > > > command. This allows the 'acpi list' command to work when booting from
> > > > > coreboot.
> > > > >
> > > > > Signed-off-by: Simon Glass 
> > > > > ---
> > > > >
> > > > >  arch/x86/include/asm/cb_sysinfo.h  |  2 ++
> > > > >  arch/x86/include/asm/coreboot_tables.h |  2 ++
> > > > >  arch/x86/lib/coreboot/cb_sysinfo.c | 11 +++
> > > > >  cmd/x86/cbsysinfo.c|  1 +
> > > > >  4 files changed, 16 insertions(+)
> > > > >
> > > > > diff --git a/arch/x86/include/asm/cb_sysinfo.h 
> > > > > b/arch/x86/include/asm/cb_sysinfo.h
> > > > > index 0201ac6b03a..6b266149cf6 100644
> > > > > --- a/arch/x86/include/asm/cb_sysinfo.h
> > > > > +++ b/arch/x86/include/asm/cb_sysinfo.h
> > > > > @@ -133,6 +133,7 @@
> > > > >   * @mtc_size: Size of MTC region
> > > > >   * @chromeos_vpd: Chromium OS Vital Product Data region, typically 
> > > > > NULL, meaning
> > > > >   * not used
> > > > > + * @rsdp: Pointer to ACPI RSDP table
> > > > >   */
> > > > >  struct sysinfo_t {
> > > > > unsigned int cpu_khz;
> > > > > @@ -211,6 +212,7 @@ struct sysinfo_t {
> > > > > u64 mtc_start;
> > > > > u32 mtc_size;
> > > > > void*chromeos_vpd;
> > > > > +   void *rsdp;
> > > > >  };
> > > > >
> > > > >  extern struct sysinfo_t lib_sysinfo;
> > > > > diff --git a/arch/x86/include/asm/coreboot_tables.h 
> > > > > b/arch/x86/include/asm/coreboot_tables.h
> > > > > index f131de56a40..2d6f3db3a5f 100644
> > > > > --- a/arch/x86/include/asm/coreboot_tables.h
> > > > > +++ b/arch/x86/include/asm/coreboot_tables.h
> > > > > @@ -422,6 +422,8 @@ struct cb_tsc_info {
> > > > >  #define CB_TAG_SERIALNO0x002a
> > > > >  #define CB_MAX_SERIALNO_LENGTH 32
> > > > >
> > > > > +#define CB_TAG_ACPI_RSDP0x0043
> > > >
> > > > This is using space but should be tab.
> > > >
> > > > > +
> > > > >  #define CB_TAG_CMOS_OPTION_TABLE   0x00c8
> > > > >
> > > > >  struct cb_cmos_option_table {
> > > > > diff --git a/arch/x86/lib/coreboot/cb_sysinfo.c 
> > > > > b/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > > index 748fa4ee53b..a11a2587f66 100644
> > > > > --- a/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > > +++ b/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > > @@ -264,6 +264,13 @@ static void cb_parse_mrc_cache(void *ptr, struct 
> > > > > sysinfo_t *info)
> > > > > info->mrc_cache = map_sysmem(cbmem->cbmem_tab, 0);
> > > > >  }
> > > > >
> > > > > +static void cb_parse_acpi_rsdp(void *ptr, struct sysinfo_t *info)
> > > > > +{
> > > > > +   struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
> > > > > +
> > > > > +   info->rsdp = map_sysmem(cbmem->cbmem_tab, 0);
> > > > > +}
> > > > > +
> > > > >  __weak void cb_parse_unhandled(u32 tag, unsigned char *ptr)
> > > > >  {
> > > > >  }
> > > > > @@ -428,6 +435,9 @@ static int cb_parse_header(void *addr, int len, 
> > > > > struct sysinfo_t *info)
> > > > > case CB_TAG_MRC_CACHE:
> > > > > cb_parse_mrc_cache(rec, info);
> > > > > break;
> > > > > +   case CB_TAG_ACPI_RSDP:
> > > > > +   cb_parse_acpi_rsdp(rec, info);
> > > > > +   break;
> > > > > default:
> > > > > cb_parse_unhandled(rec->tag, ptr);
> > > > > break;
> > > > > @@ -454,6 +464,7 @@ int get_coreboot_info(struct sysinfo_t *info)
> > > > > if (!ret)
> > > > > return -ENOENT;
> > > > > gd->arch.coreboot_table = addr;
> > > > > +   gd_set_acpi_start(map_to_sysmem(info->rsdp));
> > > > > gd->flags |= GD_FLG_SKIP_LL_INIT;
> > > > >
> > > > > return 0;
> > >
> > > >
> > > > Regards,
> > > > Bin
> > > > > diff --git a/cmd/x86/cbsysinfo.c b/cmd/x86/cbsysinfo.c
> > > > > index 34fdaf5b1b1..07570b00c9a 100644
> > > > > --- a/cmd/x86/cbsysinfo.c
> > > > > +++ b/cmd/x86/cbsysinfo.c
> > > > > @@ -363,6 +363,7 @@ static void show_table(struct sysinfo_t *info, 
> > > > > bool verbose)
> > > > > print_hex("MTC size", info->mtc_size);
> > > > >
> > > > > print_ptr("Chrome OS VPD", info->chromeos_vpd);
> > > > > +   print_ptr("RSDP", info->rsdp);
> > > > >  }
> > > > >
> > > > >  static int do_cbsysinfo(struct cmd_tbl *cmdtp, int flag, int argc,
> > > >
> > > > I tested this patch on top of coreboot with U-Boot as a payload
> > > > running on QEMU i440fx, but U-Boot does not list acpi tables.
> > > >
> > > > => 

Re: [PATCH v2 08/10] soc: ti: k3-socinfo: Add entry for J784S4 SoC

2023-05-08 Thread Vignesh Raghavendra



On 21/03/23 19:40, Hari Nagalla wrote:
> Add support for J784S4 SoC Identification.
> 
> Signed-off-by: Hari Nagalla 
> ---
>  drivers/soc/soc_ti_k3.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c
> index 8af0ac7051..caf8db9574 100644
> --- a/drivers/soc/soc_ti_k3.c
> +++ b/drivers/soc/soc_ti_k3.c
> @@ -17,6 +17,7 @@
>  #define J721S2   0xbb75
>  #define AM62X0xbb7e
>  #define AM62AX   0xbb8d
> +#define J784S4   0xbb80
>  
>  #define JTAG_ID_VARIANT_SHIFT28
>  #define JTAG_ID_VARIANT_MASK (0xf << 28)
> @@ -54,9 +55,14 @@ static const char *get_family_string(u32 idreg)
>   case AM62X:
>   family = "AM62X";
>   break;
> +
>   case AM62AX:
>   family = "AM62AX";
> +

You are missing a break here. This will render AM62Ax unbootable as we
end up returning family as J784S4

> + case J784S4:
> + family = "J784S4";
>   break;
> +
>   default:
>   family = "Unknown Silicon";
>   };

-- 
Regards
Vignesh


Re: [PATCH v3 12/17] x86: Return mtrr_add_request() to its old purpose

2023-05-08 Thread Simon Glass
Hi Bin,

On Mon, 8 May 2023 at 08:51, Bin Meng  wrote:
>
> On Mon, May 8, 2023 at 10:48 PM Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Fri, May 5, 2023 at 6:51 AM Simon Glass  wrote:
> > >
> > > This function used to be for adding a list of requests to be actioned on
> > > relocation. Revert it back to this purpose, to avoid problems with boards
> > > which need control of their MTRRs (i.e. those which don't use FSP).
> > >
> > > The mtrr_set_next_var() function is available when the next free
> > > variable-MTRR must be set, so this can be used instead.
> > >
> > > Signed-off-by: Simon Glass 
> > > Fixes: 3bcd6cf89ef ("x86: mtrr: Skip MSRs that were already programmed..")
> > > Fixes: 596bd0589ad ("x86: mtrr: Do not clear the unused ones..")
> > > ---
> > >
> > > Changes in v3:
> > > - Fix invalid commit IDs obtained from another branch
> > >
> > >  arch/x86/cpu/mtrr.c | 6 +-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
> > > index e69dfb552b1..c174dd9b3ad 100644
> > > --- a/arch/x86/cpu/mtrr.c
> > > +++ b/arch/x86/cpu/mtrr.c
> > > @@ -156,8 +156,12 @@ int mtrr_commit(bool do_caches)
> > > debug("open done\n");
> > > qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr);
> > > for (i = 0; i < gd->arch.mtrr_req_count; i++, req++)
> > > -   mtrr_set_next_var(req->type, req->start, req->size);
> > > +   set_var_mtrr(i, req->type, req->start, req->size);
> >
> > This change actually reverts 3bcd6cf89ef ("x86: mtrr: Skip MSRs that
> > were already programmed.."), but as 3bcd6cf89ef commit message says:
> >
> > At present mtrr_commit() programs the MTRR MSRs starting from
> > index 0, which may overwrite MSRs that were already programmed
> > by previous boot stage or FSP.
> >
> > So this change will cause regression.
> >
> > >
> > > +   /* Clear the ones that are unused */
> > > +   debug("clear\n");
> > > +   for (; i < mtrr_get_var_count(); i++)
> > > +   wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
> >
> > This change actually reverts 596bd0589ad ("x86: mtrr: Do not clear the
> > unused ones.."), which will also create regression unfortunately..
> >
> > > debug("close\n");
> > > mtrr_close(, do_caches);
> > > debug("mtrr done\n");
> > > --
>
> The regression mentioned above will cause Intel Crown Bay fail to
> boot. See 
> https://lore.kernel.org/u-boot/20210731084529.7524-1-bmeng...@gmail.com/

Can that board perhaps use the other functoin to set MTRRs? It is
mtrr_set_next_var()

The change in the API has broken two of the Chromebooks which is why I
am trying to go back to the way it was. Does this board set up the
MTRRs in FSP? If so, perhaps we need a Kconfig for that? It is not
what the newer FSPs do, but perhaps we could use that behaviour for
FSPv1?

Regards,
Simon


Re: [PATCH v5 08/10] board: schneider: add RZN1 board support

2023-05-08 Thread Marek Vasut

On 5/8/23 20:23, Ralph Siemsen wrote:

On Sun, May 07, 2023 at 06:06:40PM +0200, Marek Vasut wrote:

On 4/24/23 03:15, Ralph Siemsen wrote:

Add support for Schneider Electronics RZ/N1D and RZ/N1S boards, which
are based on the Reneasas RZ/N1 SoC devices.

The intention is to support both boards using a single defconfig, and to
handle the differences at runtime.


The DT comes from Linux kernel, right ? Please include commit ID from 
which the DT is imported in the commit message, I suspect that would 
be Linux 6.3 commit ID.


Yes, the DT is copied verbatim from Linux. I have updated the commit 
message to mention 6.3 and include the hash. (There have been no changes


Thanks

diff --git a/board/schneider/rzn1-snarc/ddr_async.c 
b/board/schneider/rzn1-snarc/ddr_async.c

new file mode 100644
index 00..4b4c280e45
--- /dev/null
+++ b/board/schneider/rzn1-snarc/ddr_async.c


Please correct me if I'm wrong, but shouldn't this be in drivers/ram/ ?


I had it there originally, but moved it in v5 of the patch series. There 
is a lot of board-specific (or at least architecture-specific) logic in 
this file. For example the sequence of steps to setup the clocks and 
interconnect, prior to bringing the DDR controller out of reset. This 
depends on choices made by the RZ/N1 designers, rather than the CDNS IP 
that drivers/ram/cadence is aiming to cover.


Likewise for some board-specific PHY settings, and choices such as 
operating in async mode.


I moved it to board-specific directory as an interim step. Hopefully we 
can do some consolidation of the multiple CDNS DDR controller 
implementations, and then figure out the right way to split things up.


For now this seemed like the less-bad option.


How about putting it into drivers/soc/ ?


Re: [PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format

2023-05-08 Thread Marek Vasut

On 5/8/23 19:50, Ralph Siemsen wrote:

On Sun, May 07, 2023 at 06:08:33PM +0200, Marek Vasut wrote:

[...]


+static int spkgimage_parse_config_file(char *filename)
+{
+    FILE *fcfg;
+    char line[256];
+    size_t line_num = 0;
+
+    fcfg = fopen(filename, "r");
+    if (!fcfg)
+    return -EINVAL;
+
+    conf = calloc(1, sizeof(struct config_file));
+    if (!conf)
+    return -ENOMEM;
+
+    while (fgets(line, sizeof(line), fcfg)) {
+    line_num += 1;
+
+    /* Skip blank lines and comments */
+    if (line[0] == '\n' || line[0] == '#')
+    continue;
+
+    /* Strip any trailing newline */
+    line[strcspn(line, "\n")] = 0;
+
+    /* Parse the line */
+    if (spkgimage_parse_config_line(line, line_num))
+    return -EINVAL;


Wouldn't this return -EINVAL; leak memory allocated by the calloc() 
above?


You are correct. But note that in the normal (non-error) code path, the 
structure remains allocated as well, and there is no good place to 
free() it, given the available callbacks in struct image_type_params.


So I am relying on the OS to free all memory upon program exit, both in 
the error and non-error case. I would think this is reasonable for a 
small one-shot utility program, keeps things simple.


If this is not acceptable, I can rework it, but there are quite a few 
other spots which would also need to free resources before bailing out.


The usual fail path handling like:

"
if (there is an error)
  goto exit;
...

exit:
 free(data);
 return ret;
"

does not work here ?


Re: [RESEND PATCH v2] netconsole: various improvements

2023-05-08 Thread Tony Dinh
On Mon, May 8, 2023 at 3:53 PM Tony Dinh  wrote:
>
> Hi Simon,
>
> On Mon, May 8, 2023 at 2:23 PM Simon Glass  wrote:
> >
> > Hi Tony,
> >
> > On Sun, 7 May 2023 at 22:25, Tony Dinh  wrote:
> > >
> > > Hi Tom,
> > >
> > > On Fri, May 5, 2023 at 11:34 AM Tom Rini  wrote:
> > > >
> > > > On Mon, Apr 03, 2023 at 02:41:52PM -0700, Tony Dinh wrote:
> > > >
> > > > > Use CONFIG_CONSOLE_MUX for netconsole. When netconsole is running,
> > > > > stdin/stdout/stder must be set to some primary console, in addtion to 
> > > > > nc.
> > > > > For example, stdin=serial,nc. Some recent Linux kernels will not boot 
> > > > > with
> > > > > only nc on the stdout list, ie. stdout=nc. When netconsole exits, 
> > > > > remove
> > > > > nc from the list of devices in stdin/stdout/stderr.
> > > > >
> > > > > Signed-off-by: Tony Dinh 
> > > >
> > > > This breaks the ut_bootstd_bootflow_cmd_boot test on sandbox. I'm not
> > > > sure if it's a test issue or something else.
> > >
> > > Thanks for trying, I'm having some difficulty building a sandbox
> > > u-boot, so I can't get to the point where I can see what's the problem
> > > yet.
> >
> > What is going wrong? Does this help?
> >
> > https://u-boot.readthedocs.io/en/latest/build/gcc.html
>
> Yes, I've done that when I realized my ARM development box setup
> missed several Debian packages building sandbox (I only build Linux
> kernels and U-Boot boards natively on ARM). However, after installing
> all those packages it is still not possible to build a sandbox on ARM.
> So currently I am switching to cross compiling on my Intel laptop.
> Later, I'll come back to the ARM box to see whether we need some
> documentation update for doc/build/gcc.rst.

FYI, what's missing in the doc/build/gcc.rst is the SDL option. I
could not build without NO_SDL=1.

make sandbox_defconfig all NO_SDL=1

All the best,
Tony


Re: [RESEND PATCH v2] netconsole: various improvements

2023-05-08 Thread Tony Dinh
Hi Simon,

On Mon, May 8, 2023 at 2:23 PM Simon Glass  wrote:
>
> Hi Tony,
>
> On Sun, 7 May 2023 at 22:25, Tony Dinh  wrote:
> >
> > Hi Tom,
> >
> > On Fri, May 5, 2023 at 11:34 AM Tom Rini  wrote:
> > >
> > > On Mon, Apr 03, 2023 at 02:41:52PM -0700, Tony Dinh wrote:
> > >
> > > > Use CONFIG_CONSOLE_MUX for netconsole. When netconsole is running,
> > > > stdin/stdout/stder must be set to some primary console, in addtion to 
> > > > nc.
> > > > For example, stdin=serial,nc. Some recent Linux kernels will not boot 
> > > > with
> > > > only nc on the stdout list, ie. stdout=nc. When netconsole exits, remove
> > > > nc from the list of devices in stdin/stdout/stderr.
> > > >
> > > > Signed-off-by: Tony Dinh 
> > >
> > > This breaks the ut_bootstd_bootflow_cmd_boot test on sandbox. I'm not
> > > sure if it's a test issue or something else.
> >
> > Thanks for trying, I'm having some difficulty building a sandbox
> > u-boot, so I can't get to the point where I can see what's the problem
> > yet.
>
> What is going wrong? Does this help?
>
> https://u-boot.readthedocs.io/en/latest/build/gcc.html

Yes, I've done that when I realized my ARM development box setup
missed several Debian packages building sandbox (I only build Linux
kernels and U-Boot boards natively on ARM). However, after installing
all those packages it is still not possible to build a sandbox on ARM.
So currently I am switching to cross compiling on my Intel laptop.
Later, I'll come back to the ARM box to see whether we need some
documentation update for doc/build/gcc.rst.

Thanks,
Tony

>
> Regards,
> Simon


Re: [PATCH 05/13] x86: coreboot: Collect the address of the ACPI tables

2023-05-08 Thread Simon Glass
Hi Bin,

On Sat, 6 May 2023 at 00:05, Bin Meng  wrote:
>
> Hi Simon,
>
> On Fri, Mar 24, 2023 at 1:55 AM Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On Mon, 20 Mar 2023 at 20:44, Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Tue, Feb 21, 2023 at 3:49 AM Simon Glass  wrote:
> > > >
> > > > Pick this up from the sysinfo tables and display it with the cbsysinfo
> > > > command. This allows the 'acpi list' command to work when booting from
> > > > coreboot.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > >  arch/x86/include/asm/cb_sysinfo.h  |  2 ++
> > > >  arch/x86/include/asm/coreboot_tables.h |  2 ++
> > > >  arch/x86/lib/coreboot/cb_sysinfo.c | 11 +++
> > > >  cmd/x86/cbsysinfo.c|  1 +
> > > >  4 files changed, 16 insertions(+)
> > > >
> > > > diff --git a/arch/x86/include/asm/cb_sysinfo.h 
> > > > b/arch/x86/include/asm/cb_sysinfo.h
> > > > index 0201ac6b03a..6b266149cf6 100644
> > > > --- a/arch/x86/include/asm/cb_sysinfo.h
> > > > +++ b/arch/x86/include/asm/cb_sysinfo.h
> > > > @@ -133,6 +133,7 @@
> > > >   * @mtc_size: Size of MTC region
> > > >   * @chromeos_vpd: Chromium OS Vital Product Data region, typically 
> > > > NULL, meaning
> > > >   * not used
> > > > + * @rsdp: Pointer to ACPI RSDP table
> > > >   */
> > > >  struct sysinfo_t {
> > > > unsigned int cpu_khz;
> > > > @@ -211,6 +212,7 @@ struct sysinfo_t {
> > > > u64 mtc_start;
> > > > u32 mtc_size;
> > > > void*chromeos_vpd;
> > > > +   void *rsdp;
> > > >  };
> > > >
> > > >  extern struct sysinfo_t lib_sysinfo;
> > > > diff --git a/arch/x86/include/asm/coreboot_tables.h 
> > > > b/arch/x86/include/asm/coreboot_tables.h
> > > > index f131de56a40..2d6f3db3a5f 100644
> > > > --- a/arch/x86/include/asm/coreboot_tables.h
> > > > +++ b/arch/x86/include/asm/coreboot_tables.h
> > > > @@ -422,6 +422,8 @@ struct cb_tsc_info {
> > > >  #define CB_TAG_SERIALNO0x002a
> > > >  #define CB_MAX_SERIALNO_LENGTH 32
> > > >
> > > > +#define CB_TAG_ACPI_RSDP0x0043
> > >
> > > This is using space but should be tab.
> > >
> > > > +
> > > >  #define CB_TAG_CMOS_OPTION_TABLE   0x00c8
> > > >
> > > >  struct cb_cmos_option_table {
> > > > diff --git a/arch/x86/lib/coreboot/cb_sysinfo.c 
> > > > b/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > index 748fa4ee53b..a11a2587f66 100644
> > > > --- a/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > +++ b/arch/x86/lib/coreboot/cb_sysinfo.c
> > > > @@ -264,6 +264,13 @@ static void cb_parse_mrc_cache(void *ptr, struct 
> > > > sysinfo_t *info)
> > > > info->mrc_cache = map_sysmem(cbmem->cbmem_tab, 0);
> > > >  }
> > > >
> > > > +static void cb_parse_acpi_rsdp(void *ptr, struct sysinfo_t *info)
> > > > +{
> > > > +   struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
> > > > +
> > > > +   info->rsdp = map_sysmem(cbmem->cbmem_tab, 0);
> > > > +}
> > > > +
> > > >  __weak void cb_parse_unhandled(u32 tag, unsigned char *ptr)
> > > >  {
> > > >  }
> > > > @@ -428,6 +435,9 @@ static int cb_parse_header(void *addr, int len, 
> > > > struct sysinfo_t *info)
> > > > case CB_TAG_MRC_CACHE:
> > > > cb_parse_mrc_cache(rec, info);
> > > > break;
> > > > +   case CB_TAG_ACPI_RSDP:
> > > > +   cb_parse_acpi_rsdp(rec, info);
> > > > +   break;
> > > > default:
> > > > cb_parse_unhandled(rec->tag, ptr);
> > > > break;
> > > > @@ -454,6 +464,7 @@ int get_coreboot_info(struct sysinfo_t *info)
> > > > if (!ret)
> > > > return -ENOENT;
> > > > gd->arch.coreboot_table = addr;
> > > > +   gd_set_acpi_start(map_to_sysmem(info->rsdp));
> > > > gd->flags |= GD_FLG_SKIP_LL_INIT;
> > > >
> > > > return 0;
> >
> > >
> > > Regards,
> > > Bin
> > > > diff --git a/cmd/x86/cbsysinfo.c b/cmd/x86/cbsysinfo.c
> > > > index 34fdaf5b1b1..07570b00c9a 100644
> > > > --- a/cmd/x86/cbsysinfo.c
> > > > +++ b/cmd/x86/cbsysinfo.c
> > > > @@ -363,6 +363,7 @@ static void show_table(struct sysinfo_t *info, bool 
> > > > verbose)
> > > > print_hex("MTC size", info->mtc_size);
> > > >
> > > > print_ptr("Chrome OS VPD", info->chromeos_vpd);
> > > > +   print_ptr("RSDP", info->rsdp);
> > > >  }
> > > >
> > > >  static int do_cbsysinfo(struct cmd_tbl *cmdtp, int flag, int argc,
> > >
> > > I tested this patch on top of coreboot with U-Boot as a payload
> > > running on QEMU i440fx, but U-Boot does not list acpi tables.
> > >
> > > => acpi list
> > > No ACPI tables present
> >
> > Can you try 'cbsysinfo' to see what it is passing in as the RSDP?
> >
>
> 'cbsysinfo' shows RSDP is 0.
>
> => cbsysinfo
> Coreboot table at 500, decoded to 06f558a0, forwarded to 07f99000
> ...
> RSDP: 
> Unimpl. : 10 37 40
> => acpi list
> No ACPI tables 

Re: [ANN] U-Boot v2023.07-rc2 released

2023-05-08 Thread Simon Glass
Hi Tom,

On Mon, 8 May 2023 at 12:18, Tom Rini  wrote:
>
> Hey all,
>
> It's the scheduled day for -rc2, and I've pulled in a few more changes
> before putting this out.  I think my queue is in good shape, and overall
> I'm hoping for more PRs against the next branch than master branch.  If
> there's long-standing substantive changes out there, please speak up so
> we can get this resolved sooner rather than later. I will be updating
> the next branch shortly.
>
> In terms of a changelog,
> git log --merges v2023.07-rc1..v2023.07-rc2
> contains what I've pulled but as always, better PR messages and tags
> will provide better results here.
>
> Continuing on schedule now and that means the rest of the rcs every
> other Monday, and with final release on July 3rd, 2023.  Thanks all!

We still have two x86 series pending, I think.

Regards,
Simon


Re: [RFC PATCH 0/5] LWIP stack integration

2023-05-08 Thread Simon Glass
Hi Maxim,

On Fri, 5 May 2023 at 04:50, Maxim Uvarov  wrote:
>
> Greetings,
>
> This RFC patchset is an attempt to try to use an already existing IP network 
> stack inside U-boot.
> U-Boot recently got basic TCP/IP support, implementing wget, but in order to 
> get a full IP stack
> with new features (e.g ipv6), it would be preferable to use an established 
> embedded ip library,
> instead of rewriting the code from scratch.
>
> For this experiment LWIP network stack was selected:
> https://savannah.nongnu.org/git/?group=lwip
>
> LWIP main features include:
> - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE
> - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA 
> (Zeroconf),
>   SNMP agent (v1, v2c, v3, private MIB support & MIB compiler)
> - APIs: specialized APIs for enhanced performance, optional Berkeley-alike 
> socket API
> - Extended features: IP forwarding over multiple network interfaces, TCP 
> congestion control,
>   RTT estimation and fast recovery/fast retransmit
> - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, 
> NetBIOS nameserver,
>   mDNS responder, MQTT client, TFTP server.
>
> This RFC work is a demo to enable lwIP (lightweight IP) which is a widely 
> used open-source
> TCP/IP stack designed for embedded systems for U-boot. That will allow using 
> already
> written network applications for microcontrollers.
>
> lwIP is licensed under a BSD-style license: 
> http://lwip.wikia.com/wiki/License.
> Which should be compatible with u-boot.
>
> In the current RFC I tried to use minimal changes to better see how LWIP code 
> can be embedded into
> U-boot. Patches implement ping and wget commands work. Both commands are 
> currently copy pasting and
> reusing lwIP examples.  Whether we want to add the final application in 
> U-Boot or lwIP is up to
> discussion, but the current approach was the easiest one for an RFC.
>
> Looking for your comments,
> Best regards,
> Maxim.
>
> Maxim Uvarov (5):
>   add lwip-external submodule
>   lib/lwip: compile-in core files
>   add doc/README.lwip
>   add doc/README.lwip.size
>   lwip: implement wget command from http_client.c example
>
>  .gitignore |   5 +
>  .gitmodules|   3 +
>  doc/README.lwip|  90 +
>  doc/README.lwip.size   | 291 +++
>  include/net.h  |   2 +-
>  lib/Kconfig|   2 +
>  lib/Makefile   |   2 +
>  lib/lwip/Kconfig   |  12 +
>  lib/lwip/Makefile  |  86 +
>  lib/lwip/apps/http/lwip-wget.c |  67 
>  lib/lwip/apps/http/rmstatic.patch  |  47 +++
>  lib/lwip/apps/ping/lwip_ping.c |  33 ++
>  lib/lwip/apps/ping/lwip_ping.h |  19 +
>  lib/lwip/apps/ping/ping.h  |   0
>  lib/lwip/apps/ping/rmstatic.patch  |  32 ++
>  lib/lwip/cmd-lwip.c| 129 +++
>  lib/lwip/lwip-external |   1 +
>  lib/lwip/lwipopts.h| 484 +
>  lib/lwip/port/if.c | 256 +
>  lib/lwip/port/include/arch/cc.h|  41 +++
>  lib/lwip/port/include/arch/sys_arch.h  |  78 
>  lib/lwip/port/include/arch/u-sockets.h |  26 ++
>  lib/lwip/port/include/limits.h |   0
>  lib/lwip/port/sys-arch.c   |   7 +
>  net/eth-uclass.c   |   4 +-
>  net/net.c  |  14 +
>  26 files changed, 1729 insertions(+), 2 deletions(-)
>  create mode 100644 .gitmodules
>  create mode 100644 doc/README.lwip
>  create mode 100644 doc/README.lwip.size
>  create mode 100644 lib/lwip/Kconfig
>  create mode 100644 lib/lwip/Makefile
>  create mode 100644 lib/lwip/apps/http/lwip-wget.c
>  create mode 100644 lib/lwip/apps/http/rmstatic.patch
>  create mode 100644 lib/lwip/apps/ping/lwip_ping.c
>  create mode 100644 lib/lwip/apps/ping/lwip_ping.h
>  create mode 100644 lib/lwip/apps/ping/ping.h
>  create mode 100644 lib/lwip/apps/ping/rmstatic.patch
>  create mode 100644 lib/lwip/cmd-lwip.c
>  create mode 16 lib/lwip/lwip-external
>  create mode 100644 lib/lwip/lwipopts.h
>  create mode 100644 lib/lwip/port/if.c
>  create mode 100644 lib/lwip/port/include/arch/cc.h
>  create mode 100644 lib/lwip/port/include/arch/sys_arch.h
>  create mode 100644 lib/lwip/port/include/arch/u-sockets.h
>  create mode 100644 lib/lwip/port/include/limits.h
>  create mode 100644 lib/lwip/port/sys-arch.c
>
> --
> 2.30.2
>

I don't know much about lwip but I certainly think we should be open
to changing the network stack, if it is better.

Regards,
Simon


Re: [PATCH v2 2/3] X86: Add support for distro boot

2023-05-08 Thread Simon Glass
Hi,

On Fri, 5 May 2023 at 02:23, Mittelstaedt Thomas (XC-CT/EBV3)
 wrote:
>
> Hi Simon,
>
> U-Boot can't start with boot script boot.scr, if BOOTSTD_DEFAULT is set. With 
> this setting "bootflow scan -lb" is not supported.
> Booting with extlinux.conf works somehow.
>
> = Bootlog ===
> U-Boot 2023.04-01135-g4ea415461d-dirty (May 05 2023 - 05:56:36 +)
>
> CPU: x86_64, vendor Intel, device a0652h
> DRAM:  8 GiB
> Core:  12 devices, 11 uclasses, devicetree: separate
> MMC:
> Loading Environment from FAT... scanning bus for devices...
> Target spinup took 0 ms.
> AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
> flags: 64bit ncq stag only ccc
>   Device 0: (0:0) Vendor: ATA Prod.: VBOX HARDDISK Rev: 1.0
> Type: Hard Disk
> Capacity: 32768.0 MB = 32.0 GB (67108864 x 512)
> Unable to read "uboot.env" from scsi0:1...
> No video mode configured in EFI!
> No video mode configured in EFI!
> Model: EFI x86 Payload
> Net:   e1000: 08:00:27:1c:36:6f
>
> Warning: e1000#0 failed to set MAC address
> eth0: e1000#0
> Bus xhci_pci: Register e000820 NbrPorts 14
> Starting the controller
> USB XHCI 1.00
> scanning bus xhci_pci for devices... 2 USB Device(s) found
> Hit any key to stop autoboot:  0
> scanning bus for devices...
>   Device 0: (0:0) Vendor: ATA Prod.: VBOX HARDDISK Rev: 1.0
> Type: Hard Disk
> Capacity: 32768.0 MB = 32.0 GB (67108864 x 512)
> Bus 0: OK Bus 1: not available
>   Device 0: Model: VBOX Firm: 1.0 Ser#: CD-ROM
> Type: Removable CD ROM
> Capacity: 50.5 MB = 0.0 GB (25902 x 2048)
>   Device 1: not available
> Error (no IRQ) dev 0 blk 0: status 0x11
> Error (no IRQ) dev 0 blk 0: status 0x11
> Error (no IRQ) dev 0 blk 10: status 0x11
> Error (no IRQ) dev 0 blk 0: status 0x11
> Bus xhci_pci: scanning bus xhci_pci for devices... Device not responding to 
> set address.
>
>   USB device not accepting new address (error=8000)
> failed, error -71
>
> => printenv bootcmd
> bootcmd=bootflow scan
> => bootflow scan -lb
> Flags not supported: enable CONFIG_BOOTFLOW_FULL
> bootflow - Boot flows
>
> Usage:
> bootflow scan - boot first available bootflow
>
> ===
>
> With BOOTSTD_FULL it's so far fine, but I'm missing the handling of 
> U-Boot-Menu compared to U-Boot (2023.01) at Apertis.
> I could not find a real difference but version.
> But also with DISTROBOOT enabled at earlier patch sets I see following 
> differences:
>
> The U-Boot image created with this patch set
> - doesn't provide any output toTTY screen at Virtualbox, only at serial 
> console
> - doesn't provide U-Boot-Menu at screen (U-Boot of Apertis provides it also 
> at serial console)
> But I'll proceed investigating these differences. Perhaps they are caused by 
> Debian patches not upstreamed yet. Atm it's not critical.
>
> = Bootlog ===
> U-Boot 2023.04-01135-g4ea415461d-dirty (May 05 2023 - 05:56:36 +)
>
> CPU: x86_64, vendor Intel, device a0652h
> DRAM:  5.6 GiB
> Core:  12 devices, 11 uclasses, devicetree: separate
> MMC:
> Loading Environment from FAT... scanning bus for devices...
> Target spinup took 0 ms.
> AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
> flags: 64bit ncq stag only ccc
>   Device 0: (0:0) Vendor: ATA Prod.: VBOX HARDDISK Rev: 1.0
> Type: Hard Disk
> Capacity: 33792.0 MB = 33.0 GB (69206016 x 512)
> Unable to read "uboot.env" from scsi0:1...
> No video mode configured in EFI!
> No video mode configured in EFI!
> Model: EFI x86 Payload
> Net:   No ethernet found.
> No working controllers found
> Hit any key to stop autoboot:  0
> scanning bus for devices...
>   Device 0: (0:0) Vendor: ATA Prod.: VBOX HARDDISK Rev: 1.0
> Type: Hard Disk
> Capacity: 33792.0 MB = 33.0 GB (69206016 x 512)
> ** Booting bootflow 'ahci_scsi.id0lun0.bootdev.part_2' with distro
> 1:  Apertis pro v2022 5.15.0-trunk-amd64
> Retrieving file: /boot/vmlinuz-5.15.0-trunk-amd64
> Retrieving file: /boot/initrd.img-5.15.0-trunk-amd64
> append: root=UUID=8ab7a6d1-a3fa-4fff-8de0-e381551b7cc4 console=tty0 
> console=ttyS0,115200n8 rootwait ro quiet splash plymouth.ignor 
> e-serial-consoles fsck.mode=auto fsck.repair=yes
> Valid Boot Flag
> ===
>
> Mit freundlichen Grüßen / Best regards
>
> Thomas Mittelstaedt
>
> Cross-Domain Computing Solutions

Can you please try these four patches?

https://patchwork.ozlabs.org/project/uboot/list/?series=353761
https://patchwork.ozlabs.org/project/uboot/patch/20230506142709.1382495-1-...@chromium.org/

Regards,
Simon


Re: [PATCH 3/3] bootstd: Require HUSH_PARSER for script booting

2023-05-08 Thread Simon Glass
Hi Jonas,

On Sat, 6 May 2023 at 10:03, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2023-05-06 04:03, Simon Glass wrote:
> > Armbian uses a script which needs the HUSH parser. It is likely that
> > other distros will do the same. Enable it by default, just in case.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  boot/Kconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >
>
> With this and following two config options it is now possible to boot
> Armbian_23.02.1_Rockpro64_bullseye_current_5.15.96_minimal using bootstd.
>
> CONFIG_BOOTMETH_SCRIPT=y
> CONFIG_LEGACY_IMAGE_FORMAT=y
>
> Tested-by: Jonas Karlman 

The second one looks like it is already set for that board.

Tom suggested a new BOOTSTD_DISTRO which I am going to try, to cover
every conceivable thing that might be used by distros.

Regards,
Simon


Re: [PATCH] cmd: fs: document where 'size' stores its result

2023-05-08 Thread Simon Glass
On Sun, 7 May 2023 at 04:48, Baruch Siach  wrote:
>
> Make it a little bit easier for the user to utilize the 'size' command.
>
> Signed-off-by: Baruch Siach 
> ---
>  cmd/fs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Simon Glass 


> diff --git a/cmd/fs.c b/cmd/fs.c
> index 5ad11647c2d3..6044f73af5b4 100644
> --- a/cmd/fs.c
> +++ b/cmd/fs.c
> @@ -20,7 +20,7 @@ U_BOOT_CMD(
> "determine a file's size",
> "  \n"
> "- Find file 'filename' from 'dev' on 'interface'\n"
> -   "  and determine its size."
> +   "  determine its size, and store in the 'filesize' variable."
>  );
>
>  static int do_load_wrapper(struct cmd_tbl *cmdtp, int flag, int argc,
> --
> 2.39.2
>


Re: [RESEND PATCH v2] netconsole: various improvements

2023-05-08 Thread Simon Glass
Hi Tony,

On Sun, 7 May 2023 at 22:25, Tony Dinh  wrote:
>
> Hi Tom,
>
> On Fri, May 5, 2023 at 11:34 AM Tom Rini  wrote:
> >
> > On Mon, Apr 03, 2023 at 02:41:52PM -0700, Tony Dinh wrote:
> >
> > > Use CONFIG_CONSOLE_MUX for netconsole. When netconsole is running,
> > > stdin/stdout/stder must be set to some primary console, in addtion to nc.
> > > For example, stdin=serial,nc. Some recent Linux kernels will not boot with
> > > only nc on the stdout list, ie. stdout=nc. When netconsole exits, remove
> > > nc from the list of devices in stdin/stdout/stderr.
> > >
> > > Signed-off-by: Tony Dinh 
> >
> > This breaks the ut_bootstd_bootflow_cmd_boot test on sandbox. I'm not
> > sure if it's a test issue or something else.
>
> Thanks for trying, I'm having some difficulty building a sandbox
> u-boot, so I can't get to the point where I can see what's the problem
> yet.

What is going wrong? Does this help?

https://u-boot.readthedocs.io/en/latest/build/gcc.html

Regards,
Simon


Re: How should I build u-boot for qemu_arm64_defconfig and run it on arm64 qemu virt machine?

2023-05-08 Thread Simon Glass
Hi Chan,

On Mon, 8 May 2023 at 03:41, Chan Kim  wrote:
>
> Hello experts,
>
>
>
> Today I tried this test from scratch.
>
> In my environment, CROSS_COMPILE=aarch64-none-elf.
>
> Under u-boot directory, when I do 'make CROSS_COMPILE=aarch64-none-elf-
> qemu_arm64_defconfig' and 'make -j28', I see this error at the end.
>
>
>
> aarch64-none-elf-ld.bfd: invalid length for memory region .sram
>
>
>
> after examining it, I added in include/configs/qemu-arm.h,
>
>
>
> #define CONFIG_SPL_MAX_SIZE value to 0x40
>
>
>
> After fixing it, I got another similar error for .sdram and I added in
> include/configs/qemu-arm.h,
>
>
>
> #define CONFIG_SPL_BSS_START_ADDR 0x4080
>
> #define CONFIG_SPL_BSS_MAX_SIZE 0x10
>
>
>
> Now I can do 'make -j28' with no error.
>
> But I found I have both 'u-boot' and 'spl/u-boot-spl' generated and I
> realized for this qemu_arm64_defconfig, CONFIG_SPL=y and I get both u-boot
> proper and u-boot spl. (SPL: secondary program loader, proper: main
> bootloader. SPL runs first and the proper runs next).
>
>
>
> Until now I did objcopy of the u-boot(proper) and then extended it to
> 0x40 byte. (the pflash size of the virt machine which starts at address
> 0x).
>
> $ aarch64-none-elf-objcopy -O binary u-boot.v2022.07/u-boot pflashp.img
>
> $ dd if=/dev/zero of=pflashp.img bs=1c count=1 seek=67108863
>
>
>
> And the qemu command is :
>
> $ qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine
> virt,gic-version=max,secure=on,virtualization=true -cpu max -drive
> if=pflash,file=pflashp.img -m 2G -nographic -device
> loader,file=linux-5.15.68/arch/arm64/boot/Image,addr=0x8020
>
>
>
> The qemu virt machine has RAM from 0x4000 until 0xbfff.
>
> And I could see u-boot runs and it waits input for 3 seconds and outputs the
> u-boot prompt.
>
> This is running u-boot (proper) from address 0 but since I have u-boot-spl
> too, I should run it from u-boot-spl first, shouldn't I?
>
>
>
> How am I supposed to run u-boot-spl and u-boot on this qemu machine? (from
> lds files, it looks like they both start at address 0).
>
> (qemu machine is arm64 virt machine, qemu 6.2.0).

Have you tried the docs here?

https://u-boot.readthedocs.io/en/latest/board/emulation/qemu-arm.html

Why are you trying to run SPL?

Regards,
Simon


Re: [PATCH 1/6] net: split IP_TCP header into separate IP/IP6 and TCP headers

2023-05-08 Thread Paul Liu
Hi Dmitrii,

It seems to me that this series of patches breaks the unittest of TCP stack
in sandbox.

I'll see if I have some time to fix the unittest too.

The unittest can be built by the following commands.
 1. "make sandbox64_defconfig"
 2. turn on the options that need to be tested. For example, CMD_WGET
 3. "make"
 4. "sudo ./u-boot -D"
 5. "ut lib net_test_wget" in the U-boot prompt.

Yours,
Paul


On Tue, 9 May 2023 at 01:15, Dmitrii Merkurev  wrote:

> This allows us to reuse TCP logic between IP and IP6 stack.
>
> Signed-off-by: Dmitrii Merkurev 
> Cc: Ying-Chun Liu (PaulLiu) 
> Cc: Simon Glass 
> Сс: Joe Hershberger 
> Сс: Ramon Fried 
> ---
>  include/net/tcp.h | 50 ++---
>  net/tcp.c | 70 +++
>  test/cmd/wget.c   | 16 +--
>  3 files changed, 64 insertions(+), 72 deletions(-)
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index c29d4ce24a..5ab1127d8b 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -5,20 +5,16 @@
>   * Copyright 2017 Duncan Hare, All rights reserved.
>   */
>
> +#ifndef __TCP_H__
> +#define __TCP_H__
> +
>  #define TCP_ACTIVITY 127   /* Number of packets received   */
> /* before console progress mark */
> +
> +#define GET_TCP_HDR_LEN_IN_BYTES(x) ((x) >> 2)
> +
>  /**
> - * struct ip_tcp_hdr - IP and TCP header
> - * @ip_hl_v: header length and version
> - * @ip_tos: type of service
> - * @ip_len: total length
> - * @ip_id: identification
> - * @ip_off: fragment offset field
> - * @ip_ttl: time to live
> - * @ip_p: protocol
> - * @ip_sum: checksum
> - * @ip_src: Source IP address
> - * @ip_dst: Destination IP address
> + * struct tcp_hdr - TCP header
>   * @tcp_src: TCP source port
>   * @tcp_dst: TCP destination port
>   * @tcp_seq: TCP sequence number
> @@ -28,18 +24,8 @@
>   * @tcp_win: TCP windows size
>   * @tcp_xsum: Checksum
>   * @tcp_ugr: Pointer to urgent data
> - */
> -struct ip_tcp_hdr {
> -   u8  ip_hl_v;
> -   u8  ip_tos;
> -   u16 ip_len;
> -   u16 ip_id;
> -   u16 ip_off;
> -   u8  ip_ttl;
> -   u8  ip_p;
> -   u16 ip_sum;
> -   struct in_addr  ip_src;
> -   struct in_addr  ip_dst;
> +*/
> +struct tcp_hdr {
> u16 tcp_src;
> u16 tcp_dst;
> u32 tcp_seq;
> @@ -51,8 +37,8 @@ struct ip_tcp_hdr {
> u16 tcp_ugr;
>  } __packed;
>
> -#define IP_TCP_HDR_SIZE(sizeof(struct ip_tcp_hdr))
> -#define TCP_HDR_SIZE   (IP_TCP_HDR_SIZE  - IP_HDR_SIZE)
> +#define TCP_HDR_SIZE   (sizeof(struct tcp_hdr))
> +#define IP_TCP_HDR_SIZE (IP_HDR_SIZE + TCP_HDR_SIZE)
>
>  #define TCP_DATA   0x00/* Data Packet - internal use only  */
>  #define TCP_FIN0x01/* Finish flag
>   */
> @@ -178,7 +164,8 @@ struct tcp_t_opt {
>
>  /**
>   * struct ip_tcp_hdr_o - IP + TCP header + TCP options
> - * @hdr: IP + TCP header
> + * @ip_hdr: IP + TCP header
> + * @tcp_hdr: TCP header
>   * @mss: TCP MSS Option
>   * @scale: TCP Windows Scale Option
>   * @sack_p: TCP Sack-Permitted Option
> @@ -186,7 +173,8 @@ struct tcp_t_opt {
>   * @end: end of options
>   */
>  struct ip_tcp_hdr_o {
> -   struct  ip_tcp_hdr hdr;
> +   struct  ip_hdr ip_hdr;
> +   struct  tcp_hdrtcp_hdr;
> struct  tcp_mssmss;
> struct  tcp_scale  scale;
> struct  tcp_sack_p sack_p;
> @@ -198,13 +186,15 @@ struct ip_tcp_hdr_o {
>
>  /**
>   * struct ip_tcp_hdr_s - IP + TCP header + TCP options
> - * @hdr: IP + TCP header
> + * @ip_hdr: IP + TCP header
> + * @tcp_hdr: TCP header
>   * @t_opt: TCP Timestamp Option
>   * @sack_v: TCP SACK Option
>   * @end: end of options
>   */
>  struct ip_tcp_hdr_s {
> -   struct  ip_tcp_hdr  hdr;
> +   struct  ip_hdr ip_hdr;
> +   struct  tcp_hdrtcp_hdr;
> struct  tcp_t_opt   t_opt;
> struct  tcp_sack_v  sack_v;
> u8  end;
> @@ -303,3 +293,5 @@ void rxhand_tcp_f(union tcp_build_pkt *b, unsigned int
> len);
>
>  u16 tcp_set_pseudo_header(uchar *pkt, struct in_addr src, struct in_addr
> dest,
>   int tcp_len, int pkt_len);
> +
> +#endif // __TCP_H__
> diff --git a/net/tcp.c b/net/tcp.c
> index a713e1dd60..10ce799814 100644
> --- a/net/tcp.c
> +++ b/net/tcp.c
> @@ -155,7 +155,7 @@ u16 tcp_set_pseudo_header(uchar *pkt, struct in_addr
> src, struct in_addr dest,
>   */
>  int net_set_ack_options(union tcp_build_pkt *b)
>  {
> -   b->sack.hdr.tcp_hlen =
> SHIFT_TO_TCPHDRLEN_FIELD(LEN_B_TO_DW(TCP_HDR_SIZE));
> +   b->sack.tcp_hdr.tcp_hlen =
> SHIFT_TO_TCPHDRLEN_FIELD(LEN_B_TO_DW(TCP_HDR_SIZE));
>
> b->sack.t_opt.kind = TCP_O_TS;
> b->sack.t_opt.len = TCP_OPT_LEN_A;
> @@ -187,12 +187,12 @@ int 

Fwd: New Defects reported by Coverity Scan for Das U-Boot

2023-05-08 Thread Tom Rini
Here's the latest defect report:

-- Forwarded message -
From: 
Date: Mon, May 8, 2023, 2:29 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: 


Hi,

Please find the latest report on new defect(s) introduced to Das U-Boot
found with Coverity Scan.

5 new defect(s) introduced to Das U-Boot found with Coverity Scan.
1 defect(s), reported by Coverity Scan earlier, were marked fixed in the
recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 5 of 5 defect(s)


** CID 453851:  Memory - corruptions  (OVERLAPPING_COPY)
/cmd/net.c: 279 in netboot_update_env()



*** CID 453851:  Memory - corruptions  (OVERLAPPING_COPY)
/cmd/net.c: 279 in netboot_update_env()
273
274 if (IS_ENABLED(CONFIG_IPV6)) {
275 if (!ip6_is_unspecified_addr(_ip6) ||
276 net_prefix_length != 0) {
277 sprintf(tmp, "%pI6c", _ip6);
278 if (net_prefix_length != 0)
>>> CID 453851:  Memory - corruptions  (OVERLAPPING_COPY)
>>> In the call to function "sprintf", the arguments "tmp" and "tmp"
may point to the same object.
279 sprintf(tmp, "%s/%d", tmp,
net_prefix_length);
280
281 env_set("ip6addr", tmp);
282 }
283
284 if (!ip6_is_unspecified_addr(_server_ip6)) {

** CID 450971:  Insecure data handling  (TAINTED_SCALAR)
/net/ndisc.c: 391 in process_ra()



*** CID 450971:  Insecure data handling  (TAINTED_SCALAR)
/net/ndisc.c: 391 in process_ra()
385 /* Ignore the packet if router lifetime is 0. */
386 if (!icmp->icmp6_rt_lifetime)
387 return -EOPNOTSUPP;
388
389 /* Processing the options */
390 option = msg->opt;
>>> CID 450971:  Insecure data handling  (TAINTED_SCALAR)
>>> Using tainted variable "remaining_option_len" as a loop boundary.
391 while (remaining_option_len > 0) {
392 /* The 2nd byte of the option is its length. */
393 option_len = option[1];
394 /* All included options should have a positive
length. */
395 if (option_len == 0)
396 return -EINVAL;

** CID 450969:  Security best practices violations  (DC.WEAK_CRYPTO)
/net/ndisc.c: 209 in ip6_send_rs()



*** CID 450969:  Security best practices violations  (DC.WEAK_CRYPTO)
/net/ndisc.c: 209 in ip6_send_rs()
203icmp_len, PROT_ICMPV6, pcsum);
204 msg->icmph.icmp6_cksum = csum;
205 pkt += icmp_len;
206
207 /* Wait up to 1 second if it is the first try to get the RA
*/
208 if (retry_count == 0)
>>> CID 450969:  Security best practices violations  (DC.WEAK_CRYPTO)
>>> "rand" should not be used for security-related applications,
because linear congruential algorithms are too easy to break.
209 udelay(((unsigned int)rand() % 100) *
MAX_SOLICITATION_DELAY);
210
211 /* send it! */
212 net_send_packet(net_tx_packet, (pkt - net_tx_packet));
213
214 retry_count++;

** CID 436282:(DC.WEAK_CRYPTO)
/net/dhcpv6.c: 621 in dhcp6_state_machine()
/net/dhcpv6.c: 627 in dhcp6_state_machine()
/net/dhcpv6.c: 628 in dhcp6_state_machine()
/net/dhcpv6.c: 662 in dhcp6_state_machine()
/net/dhcpv6.c: 613 in dhcp6_state_machine()



*** CID 436282:(DC.WEAK_CRYPTO)
/net/dhcpv6.c: 621 in dhcp6_state_machine()
615 /* handle state machine entry conditions */
616 if (sm_params.curr_state != sm_params.next_state) {
617 sm_params.retry_cnt = 0;
618
619 if (sm_params.next_state == DHCP6_SOLICIT) {
620 /* delay a random ammount (special for
SOLICIT) */
>>> CID 436282:(DC.WEAK_CRYPTO)
>>> "rand" should not be used for security-related applications,
because linear congruential algorithms are too easy to break.
621 udelay((rand() % SOL_MAX_DELAY_MS) * 1000);
622 /* init timestamp variables after SOLICIT
delay */
623 sm_params.dhcp6_start_ms = get_timer(0);
624 sm_params.dhcp6_retry_start_ms =
sm_params.dhcp6_start_ms;
625 sm_params.dhcp6_retry_ms =
sm_params.dhcp6_start_ms;
626 /* init transaction and ia_id */

Re: [PATCH v5 08/10] board: schneider: add RZN1 board support

2023-05-08 Thread Ralph Siemsen

On Sun, May 07, 2023 at 06:06:40PM +0200, Marek Vasut wrote:

On 4/24/23 03:15, Ralph Siemsen wrote:

Add support for Schneider Electronics RZ/N1D and RZ/N1S boards, which
are based on the Reneasas RZ/N1 SoC devices.

The intention is to support both boards using a single defconfig, and to
handle the differences at runtime.


The DT comes from Linux kernel, right ? Please include commit ID from 
which the DT is imported in the commit message, I suspect that would 
be Linux 6.3 commit ID.


Yes, the DT is copied verbatim from Linux. I have updated the commit 
message to mention 6.3 and include the hash. (There have been no changes 




diff --git a/board/schneider/rzn1-snarc/ddr_async.c 
b/board/schneider/rzn1-snarc/ddr_async.c
new file mode 100644
index 00..4b4c280e45
--- /dev/null
+++ b/board/schneider/rzn1-snarc/ddr_async.c


Please correct me if I'm wrong, but shouldn't this be in drivers/ram/ ?


I had it there originally, but moved it in v5 of the patch series. There 
is a lot of board-specific (or at least architecture-specific) logic in 
this file. For example the sequence of steps to setup the clocks and 
interconnect, prior to bringing the DDR controller out of reset. This 
depends on choices made by the RZ/N1 designers, rather than the CDNS IP 
that drivers/ram/cadence is aiming to cover.


Likewise for some board-specific PHY settings, and choices such as 
operating in async mode.


I moved it to board-specific directory as an interim step. Hopefully we 
can do some consolidation of the multiple CDNS DDR controller 
implementations, and then figure out the right way to split things up.


For now this seemed like the less-bad option.


+
+   /* Step 15 Wait for 200us or more, or wait for DFIINITCOMPLETE to be 
"1" */
+   while (!(phy_readl(DLLCTRL) & DLLCTRL_ASDLLOCK))
+   ;


Please avoid endless loops, use readl_poll_timeout() or 
wait_for_bit*() where possible.


Will do.


+int board_init(void)
+{
+   /*
+* Initial values for gd->ram_base and gd->ram_size
+* are obtained from the "/memory" node in devicetree.
+* The size will be updated in later when probing DDR.
+*/
+   fdtdec_setup_mem_size_base();


Are you absolutely sure this call ^ is needed at all ?


I was sure at the time when I wrote it, however I just tried removing it 
now and it seems to work fine.



You can just do this here:

err = uclass...();
if (err)
 debug(...);

return err;


Done.


+#ifndef __RZN1_H


Better use __RZN1_SNARC_H , so that when other boards get added, there 
won't be trouble.


Good catch, done.

Ralph


[ANN] U-Boot v2023.07-rc2 released

2023-05-08 Thread Tom Rini
Hey all,

It's the scheduled day for -rc2, and I've pulled in a few more changes
before putting this out.  I think my queue is in good shape, and overall
I'm hoping for more PRs against the next branch than master branch.  If
there's long-standing substantive changes out there, please speak up so
we can get this resolved sooner rather than later. I will be updating
the next branch shortly.

In terms of a changelog, 
git log --merges v2023.07-rc1..v2023.07-rc2
contains what I've pulled but as always, better PR messages and tags
will provide better results here.

Continuing on schedule now and that means the rest of the rcs every
other Monday, and with final release on July 3rd, 2023.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format

2023-05-08 Thread Ralph Siemsen

On Sun, May 07, 2023 at 06:08:33PM +0200, Marek Vasut wrote:

[...]


+static int spkgimage_parse_config_file(char *filename)
+{
+   FILE *fcfg;
+   char line[256];
+   size_t line_num = 0;
+
+   fcfg = fopen(filename, "r");
+   if (!fcfg)
+   return -EINVAL;
+
+   conf = calloc(1, sizeof(struct config_file));
+   if (!conf)
+   return -ENOMEM;
+
+   while (fgets(line, sizeof(line), fcfg)) {
+   line_num += 1;
+
+   /* Skip blank lines and comments */
+   if (line[0] == '\n' || line[0] == '#')
+   continue;
+
+   /* Strip any trailing newline */
+   line[strcspn(line, "\n")] = 0;
+
+   /* Parse the line */
+   if (spkgimage_parse_config_line(line, line_num))
+   return -EINVAL;


Wouldn't this return -EINVAL; leak memory allocated by the calloc() above?


You are correct. But note that in the normal (non-error) code path, the 
structure remains allocated as well, and there is no good place to 
free() it, given the available callbacks in struct image_type_params.


So I am relying on the OS to free all memory upon program exit, both in 
the error and non-error case. I would think this is reasonable for a 
small one-shot utility program, keeps things simple.


If this is not acceptable, I can rework it, but there are quite a few 
other spots which would also need to free resources before bailing out.



[...]

With that fixed:

Reviewed-by: Marek Vasut 


I'll wait to hear back from you before applying this tag.

Regards,
Ralph


Re: Please pull u-boot-marvell/master

2023-05-08 Thread Tom Rini
On Mon, May 08, 2023 at 10:47:54AM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull the following Marvell MVEBU related patches into next:
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] board: ti: am64x: Add support for AM64B SK

2023-05-08 Thread Tom Rini
On Thu, 06 Apr 2023 11:49:01 +0530, Vignesh Raghavendra wrote:

> The AM64x SR2.0 SK board uses "AM64B-SKEVM" as the EEPROM identifier.
> This board is similar to the AM64x SKEVM except that it has a new
> PMIC that will be enabled in the future and consequently could use a
> different device tree file in the future.
> 
> For now we treat the board same as an AM64x SK.
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



Re: [PATCH U-BOOT v2] btrfs: fix offset when reading compressed extents

2023-05-08 Thread Tom Rini
On Tue, 18 Apr 2023 15:41:55 +0900, Dominique Martinet wrote:

> btrfs_read_extent_reg correctly computed the extent offset in the
> BTRFS_COMPRESS_NONE case, but did not account for the 'offset - key.offset'
> part correctly in the compressed case, making the function read
> incorrect data.
> 
> In the case I examined, the last 4k of a file was corrupted and
> contained data from a few blocks prior, e.g. reading a 10k file with a
> single extent:
> btrfs_file_read()
>  -> btrfs_read_extent_reg
> (aligned part loop, until 8k)
>  -> read_and_truncate_page
>-> btrfs_read_extent_reg
>   (re-reads the last extent from 8k to the end,
>   incorrectly reading the first 2k of data)
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



[PATCH 6/6] net: update net_ip6 from link_local address when eth device is changed

2023-05-08 Thread Dmitrii Merkurev
Current active eth device may be changed (due to ethprime), so make
sure current net_ip6 is updated as a reaction.

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 net/net.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/net.c b/net/net.c
index 3fc6681898..a52c110d93 100644
--- a/net/net.c
+++ b/net/net.c
@@ -359,10 +359,10 @@ static int net_init_loop(void)
 
if (IS_ENABLED(CONFIG_IPV6)) {
ip6_make_lladdr(_link_local_ip6, net_ethaddr);
-   if (!memcmp(_ip6, _null_addr_ip6,
-   sizeof(struct in6_addr)))
-   memcpy(_ip6, _link_local_ip6,
-  sizeof(struct in6_addr));
+   if (memcmp(_link_local_ip6, _null_addr_ip6,
+  sizeof(struct in6_addr))) {
+   net_copy_ip6(_ip6, _link_local_ip6);
+   }
}
}
else
-- 
2.40.1.521.gf1e218fcd8-goog



[PATCH 5/6] net: add fastboot TCP documentation and IP6-only mode

2023-05-08 Thread Dmitrii Merkurev
Command to start IP6 only TCP fastboot:
fastboot tcp -ipv6

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 cmd/fastboot.c   | 29 +
 doc/android/fastboot.rst |  8 +++-
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 3d5ff951eb..36f744ae01 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -121,10 +122,23 @@ static int do_fastboot(struct cmd_tbl *cmdtp, int flag, 
int argc,
 {
uintptr_t buf_addr = (uintptr_t)NULL;
size_t buf_size = 0;
+   bool is_ipv6_only = false;
+   bool is_usb = false;
+   bool is_udp = false;
+   bool is_tcp = false;
 
if (argc < 2)
return CMD_RET_USAGE;
 
+   if (IS_ENABLED(CONFIG_IPV6)) {
+   use_ip6 = false;
+   /* IPv6 parameter has to be always *last* */
+   if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) {
+   is_ipv6_only = true;
+   --argc;
+   }
+   }
+
while (argc > 1 && **(argv + 1) == '-') {
char *arg = *++argv;
 
@@ -159,11 +173,18 @@ NXTARG:
 
fastboot_init((void *)buf_addr, buf_size);
 
-   if (!strcmp(argv[1], "udp"))
+   is_usb = strcmp(argv[1], "usb") == 0;
+   is_udp = strcmp(argv[1], "udp") == 0;
+   is_tcp = strcmp(argv[1], "tcp") == 0;
+
+   if (is_ipv6_only && is_tcp)
+   use_ip6 = true;
+
+   if (is_udp)
return do_fastboot_udp(argc, argv, buf_addr, buf_size);
-   if (!strcmp(argv[1], "tcp"))
+   if (is_tcp)
return do_fastboot_tcp(argc, argv, buf_addr, buf_size);
-   if (!strcmp(argv[1], "usb")) {
+   if (is_usb) {
argv++;
argc--;
}
@@ -174,7 +195,7 @@ NXTARG:
 U_BOOT_CMD(
fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
"run as a fastboot usb or udp device",
-   "[-l addr] [-s size] usb  | udp\n"
+   "[-l addr] [-s size] usb  | udp [-ipv6] | tcp [-ipv6]\n"
"\taddr - address of buffer used during data transfers ("
__stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
"\tsize - size of buffer used during data transfers ("
diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst
index 1ad8a897c8..aa6e9e5a9e 100644
--- a/doc/android/fastboot.rst
+++ b/doc/android/fastboot.rst
@@ -181,13 +181,19 @@ Enter into fastboot by executing the fastboot command in 
U-Boot for either USB::
 
=> fastboot usb 0
 
-or UDP::
+UDP::
 
=> fastboot udp
link up on port 0, speed 100, full duplex
Using ethernet@4a10 device
Listening for fastboot command on 192.168.0.102
 
+or TCP::
+
+   => fastboot tcp
+   Using ethernet@4a10 device
+   Listening for fastboot command on 192.168.0.102
+
 On the client side you can fetch the bootloader version for instance::
 
$ fastboot getvar version-bootloader
-- 
2.40.1.521.gf1e218fcd8-goog



[PATCH 4/6] net: add fastboot TCP6 support

2023-05-08 Thread Dmitrii Merkurev
fastboot tcp command remains the same, but started
listening IP6 in case it's enabled.

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 include/net/fastboot_tcp.h |  2 +-
 net/fastboot_tcp.c | 72 --
 2 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/include/net/fastboot_tcp.h b/include/net/fastboot_tcp.h
index 6cf29d52e9..98986fa10a 100644
--- a/include/net/fastboot_tcp.h
+++ b/include/net/fastboot_tcp.h
@@ -7,7 +7,7 @@
 #define __NET_FASTBOOT_TCP_H__
 
 /**
- * Wait for incoming tcp fastboot comands.
+ * Wait for incoming TCP fastboot comands.
  */
 void fastboot_tcp_start_server(void);
 
diff --git a/net/fastboot_tcp.c b/net/fastboot_tcp.c
index 2eb52ea256..d93b52ede5 100644
--- a/net/fastboot_tcp.c
+++ b/net/fastboot_tcp.c
@@ -6,8 +6,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 static char command[FASTBOOT_COMMAND_LEN] = {0};
 static char response[FASTBOOT_RESPONSE_LEN] = {0};
@@ -20,18 +22,30 @@ static u16 curr_dport;
 static u32 curr_tcp_seq_num;
 static u32 curr_tcp_ack_num;
 static unsigned int curr_request_len;
+static bool is_ipv6;
+static size_t ip_header_size;
 static enum fastboot_tcp_state {
FASTBOOT_CLOSED,
FASTBOOT_CONNECTED,
FASTBOOT_DISCONNECTING
 } state = FASTBOOT_CLOSED;
 
+static int command_handled_id;
+static bool command_handled_success;
+
 static void fastboot_tcp_answer(u8 action, unsigned int len)
 {
const u32 response_seq_num = curr_tcp_ack_num;
const u32 response_ack_num = curr_tcp_seq_num +
  (curr_request_len > 0 ? curr_request_len : 1);
 
+#if defined(CONFIG_IPV6)
+   if (is_ipv6) {
+   net_send_tcp_packet6(len, htons(curr_sport), htons(curr_dport),
+action, response_seq_num, 
response_ack_num);
+   return;
+   }
+#endif
net_send_tcp_packet(len, htons(curr_sport), htons(curr_dport),
action, response_seq_num, response_ack_num);
 }
@@ -47,7 +61,7 @@ static void fastboot_tcp_send_packet(u8 action, const uchar 
*data, unsigned int
uchar *pkt = net_get_async_tx_pkt_buf();
 
memset(pkt, '\0', PKTSIZE);
-   pkt += net_eth_hdr_size() + IP_TCP_HDR_SIZE + TCP_TSOPT_SIZE + 2;
+   pkt += net_eth_hdr_size() + ip_header_size + TCP_HDR_SIZE + 
TCP_TSOPT_SIZE + 2;
memcpy(pkt, data, len);
fastboot_tcp_answer(action, len);
memset(pkt, '\0', PKTSIZE);
@@ -59,7 +73,7 @@ static void fastboot_tcp_send_message(const char *message, 
unsigned int len)
uchar *pkt = net_get_async_tx_pkt_buf();
 
memset(pkt, '\0', PKTSIZE);
-   pkt += net_eth_hdr_size() + IP_TCP_HDR_SIZE + TCP_TSOPT_SIZE + 2;
+   pkt += net_eth_hdr_size() + ip_header_size + TCP_HDR_SIZE + 
TCP_TSOPT_SIZE + 2;
// Put first 8 bytes as a big endian message length
memcpy(pkt, _be, 8);
pkt += 8;
@@ -68,10 +82,9 @@ static void fastboot_tcp_send_message(const char *message, 
unsigned int len)
memset(pkt, '\0', PKTSIZE);
 }
 
-static void fastboot_tcp_handler_ipv4(uchar *pkt, u16 dport,
- struct in_addr sip, u16 sport,
- u32 tcp_seq_num, u32 tcp_ack_num,
- u8 action, unsigned int len)
+static void fastboot_tcp_handler(uchar *pkt, u16 dport, u16 sport,
+u32 tcp_seq_num, u32 tcp_ack_num,
+u8 action, unsigned int len)
 {
int fastboot_command_id;
u64 command_size;
@@ -88,7 +101,6 @@ static void fastboot_tcp_handler_ipv4(uchar *pkt, u16 dport,
case FASTBOOT_CLOSED:
if (tcp_push) {
if (len != handshake_length ||
-   strlen(pkt) != handshake_length ||
memcmp(pkt, handshake, handshake_length) != 0) {
fastboot_tcp_reset();
break;
@@ -111,18 +123,25 @@ static void fastboot_tcp_handler_ipv4(uchar *pkt, u16 
dport,
pkt += 8;
 
// Only single packet messages are supported ATM
-   if (strlen(pkt) != command_size) {
+   if (len != command_size) {
fastboot_tcp_reset();
break;
}
strlcpy(command, pkt, len + 1);
fastboot_command_id = fastboot_handle_command(command, 
response);
fastboot_tcp_send_message(response, strlen(response));
-   fastboot_handle_boot(fastboot_command_id,
-strncmp("OKAY", response, 4) == 0);
+
+   command_handled_id = fastboot_command_id;

[PATCH 3/6] net: introduce TCP/IP6 support

2023-05-08 Thread Dmitrii Merkurev
Add TCP/IP6 related headers and reuse refactored TCP/IP
implementation

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 include/net/tcp6.h | 103 +
 include/net6.h |  14 ++
 net/Makefile   |   1 +
 net/net.c  |   6 +++
 net/net6.c |  43 ++-
 net/tcp6.c |  95 +
 6 files changed, 260 insertions(+), 2 deletions(-)
 create mode 100644 include/net/tcp6.h
 create mode 100644 net/tcp6.c

diff --git a/include/net/tcp6.h b/include/net/tcp6.h
new file mode 100644
index 00..102f5a240a
--- /dev/null
+++ b/include/net/tcp6.h
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ */
+
+#ifndef __TCP6_H__
+#define __TCP6_H__
+
+#include 
+#include 
+
+/**
+ * typedef rxhand_tcp6_f() - An incoming TCP IPv6 packet handler.
+ * @pkt: pointer to the application packet
+ * @dport: destination TCP port
+ * @sip: source IP6 address
+ * @sport: source TCP port
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ * @action: TCP packet type (SYN, ACK, FIN, etc)
+ */
+typedef void rxhand_tcp6_f(uchar *pkt, u16 dport,
+  struct in6_addr sip, u16 sport,
+  u32 tcp_seq_num, u32 tcp_ack_num,
+  u8 action, unsigned int len);
+
+/**
+ * struct ip6_tcp_hdr_o - IP6 + TCP header + TCP options
+ * @ip_hdr: IP6 + TCP header
+ * @tcp_hdr: TCP header
+ * @tcp_o: TCP options
+ * @end: end of IP6/TCP header
+ */
+struct ip6_tcp_hdr_o {
+   struct  ip6_hdrip_hdr;
+   struct  tcp_hdrtcp_hdr;
+   struct  tcp_hdr_o  tcp_o;
+   u8  end;
+} __packed;
+
+#define IP6_TCP_O_SIZE (sizeof(struct ip6_tcp_hdr_o))
+
+/**
+ * struct ip6_tcp_hdr_s - IP6 + TCP header + TCP options
+ * @ip_hdr: IP6 + TCP header
+ * @tcp_hdr: TCP header
+ * @t_opt: TCP Timestamp Option
+ * @sack_v: TCP SACK Option
+ * @end: end of options
+ */
+struct ip6_tcp_hdr_s {
+   struct  ip6_hdrip_hdr;
+   struct  tcp_hdrtcp_hdr;
+   struct  tcp_t_opt  t_opt;
+   struct  tcp_sack_v sack_v;
+   u8  end;
+} __packed;
+
+#define IP6_TCP_SACK_SIZE (sizeof(struct ip6_tcp_hdr_s))
+
+/**
+ * union tcp6_build_pkt - union for building TCP/IP6 packet.
+ * @ip: IP6 and TCP header plus TCP options
+ * @sack: IP6 and TCP header plus SACK options
+ * @raw: buffer
+ */
+union tcp6_build_pkt {
+   struct ip6_tcp_hdr_o ip;
+   struct ip6_tcp_hdr_s sack;
+   uchar  raw[1600];
+} __packed;
+
+/**
+ * net_set_tcp6_handler6() - set application TCP6 packet handler
+ * @param f pointer to callback function
+ */
+void net_set_tcp_handler6(rxhand_tcp6_f *f);
+
+/**
+ * net_set_tcp_header6() - set
+ * @pkt: pointer to IP6/TCP headers
+ * @dport: destination TCP port
+ * @sport: source TCP port
+ * @payload_len: payload length
+ * @action: TCP packet type (SYN, ACK, FIN, etc)
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ *
+ * returns TCP header size
+ */
+int net_set_tcp_header6(uchar *pkt, u16 dport, u16 sport, int payload_len,
+   u8 action, u32 tcp_seq_num, u32 tcp_ack_num);
+
+void net_set_tcp_handler6(rxhand_tcp6_f *f);
+
+/**
+ * rxhand_tcp6() - handle incoming IP6 TCP packet
+ * @param b pointer to IP6/TCP packet builder struct
+ * @param len full packet length
+ */
+void rxhand_tcp6(union tcp6_build_pkt *b, unsigned int len);
+
+#endif // __TCP6_H__
diff --git a/include/net6.h b/include/net6.h
index beafc05338..fa926f07ac 100644
--- a/include/net6.h
+++ b/include/net6.h
@@ -344,6 +344,20 @@ int ip6_add_hdr(uchar *xip, struct in6_addr *src, struct 
in6_addr *dest,
 int net_send_udp_packet6(uchar *ether, struct in6_addr *dest, int dport,
 int sport, int len);
 
+/**
+ * net_send_tcp_packet6() - Make up TCP packet and send it
+ *
+ * @payload_len: TCP payload length
+ * @dport:  destination port
+ * @sport:  source port
+ * @action: TCP flag (SYN, ACL, PUSH, etc)
+ * @tcp_seq_num: TCP sequence number
+ * @tcp_ack_num: TCP ackno
+ * Return: 0 if send successfully, -1 otherwise
+ */
+int net_send_tcp_packet6(int payload_len, int dport, int sport, u8 action,
+u32 tcp_seq_num, u32 tcp_ack_num);
+
 /**
  * net_ip6_handler() - Handle IPv6 packet
  *
diff --git a/net/Makefile b/net/Makefile
index 3e2d061338..002b0f68a2 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_TCP_FUNCTION_FASTBOOT)  += fastboot_tcp.o
 obj-$(CONFIG_CMD_WOL)  += wol.o
 obj-$(CONFIG_PROT_UDP) += udp.o
 obj-$(CONFIG_PROT_TCP) += tcp.o
+obj-$(CONFIG_IPV6) += tcp6.o
 obj-$(CONFIG_CMD_WGET) += wget.o
 
 # Disable this warning as it is triggered by:
diff --git a/net/net.c b/net/net.c
index 0b68bf7b13..3fc6681898 100644
--- a/net/net.c
+++ b/net/net.c
@@ 

[PATCH 2/6] net: prepare existing TCP stack to be reused by IP6

2023-05-08 Thread Dmitrii Merkurev
Changes:
1. Separate reusable part from net_set_tcp_header to
net_set_tcp_header_common
2. Make TCP signatures reusable by receiving particular
IP agnostic TCP headers
3. Extract net_send_ip_packet6 from net_send_udp_packet6
to reuse the code
4. Expose TCP state machine related functions

This allows us to reuse TCP logic between IP and IP6 stack.

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 include/net/tcp.h | 109 +--
 net/net.c |  18 ++-
 net/net6.c|  78 ---
 net/tcp.c | 337 --
 4 files changed, 372 insertions(+), 170 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5ab1127d8b..1332f19153 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -8,10 +8,20 @@
 #ifndef __TCP_H__
 #define __TCP_H__
 
+#include 
+
 #define TCP_ACTIVITY 127   /* Number of packets received   */
/* before console progress mark */
 
+/*
+ * TCP lengths are stored as a rounded up number of 32 bit words.
+ * Add 3 to length round up, rounded, then divided into the
+ * length in 32 bit words.
+ */
+#define LEN_B_TO_DW(x) ((x) >> 2)
+#define ROUND_TCPHDR_LEN(x) (LEN_B_TO_DW((x) + 3))
 #define GET_TCP_HDR_LEN_IN_BYTES(x) ((x) >> 2)
+#define SHIFT_TO_TCPHDRLEN_FIELD(x) ((x) << 4)
 
 /**
  * struct tcp_hdr - TCP header
@@ -24,7 +34,7 @@
  * @tcp_win: TCP windows size
  * @tcp_xsum: Checksum
  * @tcp_ugr: Pointer to urgent data
-*/
+ */
 struct tcp_hdr {
u16 tcp_src;
u16 tcp_dst;
@@ -163,18 +173,14 @@ struct tcp_t_opt {
  */
 
 /**
- * struct ip_tcp_hdr_o - IP + TCP header + TCP options
- * @ip_hdr: IP + TCP header
- * @tcp_hdr: TCP header
+ * struct tcp_hdr_o - TCP options
  * @mss: TCP MSS Option
  * @scale: TCP Windows Scale Option
  * @sack_p: TCP Sack-Permitted Option
  * @t_opt: TCP Timestamp Option
  * @end: end of options
  */
-struct ip_tcp_hdr_o {
-   struct  ip_hdr ip_hdr;
-   struct  tcp_hdrtcp_hdr;
+struct tcp_hdr_o {
struct  tcp_mssmss;
struct  tcp_scale  scale;
struct  tcp_sack_p sack_p;
@@ -182,6 +188,22 @@ struct ip_tcp_hdr_o {
u8  end;
 } __packed;
 
+#define TCP_O_SIZE (sizeof(struct tcp_hdr_o))
+
+/**
+ * struct ip_tcp_hdr_o - IP + TCP header + TCP options
+ * @ip_hdr: IP + TCP header
+ * @tcp_hdr: TCP header
+ * @tcp_o: TCP options
+ * @end: end of IP/TCP header
+ */
+struct ip_tcp_hdr_o {
+   struct  ip_hdr ip_hdr;
+   struct  tcp_hdrtcp_hdr;
+   struct  tcp_hdr_o  tcp_o;
+   u8  end;
+} __packed;
+
 #define IP_TCP_O_SIZE (sizeof(struct ip_tcp_hdr_o))
 
 /**
@@ -209,7 +231,7 @@ struct ip_tcp_hdr_s {
 
 /**
  * struct pseudo_hdr - Pseudo Header
- * @padding: pseudo hdr size = ip_tcp hdr size
+ * @padding: pseudo hdr size = ip hdr size
  * @p_src: Source IP address
  * @p_dst: Destination IP address
  * @rsvd: reserved
@@ -236,7 +258,6 @@ struct pseudo_hdr {
  *
  * Build Pseudo header in packed buffer
  * first, calculate TCP checksum, then build IP header in packed buffer.
- *
  */
 union tcp_build_pkt {
struct pseudo_hdr ph;
@@ -269,9 +290,77 @@ enum tcp_state {
 
 enum tcp_state tcp_get_tcp_state(void);
 void tcp_set_tcp_state(enum tcp_state new_state);
-int tcp_set_tcp_header(uchar *pkt, int dport, int sport, int payload_len,
+
+/**
+ * net_set_tcp_header_common() - IP version agnostic TCP header building 
implementation
+ *
+ * @tcp_hdr: pointer to TCP header struct
+ * @tcp_o: pointer to TCP options header struct
+ * @sack_t_opt: pointer to TCP sack options header struct
+ * @sack_v: pointer to TCP sack header struct
+ * @dport: destination TCP port
+ * @sport: source TCP port
+ * @payload_len: TCP payload len
+ * @action: TCP action (SYN, ACK, FIN, etc)
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ *
+ * returns TCP header
+ */
+int net_set_tcp_header_common(struct tcp_hdr *tcp_hdr, struct tcp_hdr_o *tcp_o,
+ struct tcp_t_opt *sack_t_opt, struct tcp_sack_v 
*sack_v,
+ u16 dport, u16 sport, int payload_len, u8 action,
+ u32 tcp_seq_num, u32 tcp_ack_num);
+
+/**
+ * net_set_tcp_header() - IPv4 TCP header bulding implementation
+ *
+ * @pkt: pointer to the IP header
+ * @dport: destination TCP port
+ * @sport: source TCP port
+ * @payload_len: TCP payload len
+ * @action: TCP action (SYN, ACK, FIN, etc)
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ *
+ * returns TCP header
+ */
+int net_set_tcp_header(uchar *pkt, u16 dport, u16 sport, int payload_len,
   u8 action, u32 tcp_seq_num, u32 tcp_ack_num);
 
+/**
+ * tcp_parse_options() - parsing TCP options
+ *
+ * @o: pointer to the option field.
+ * @o_len: length of the option field.
+ */
+void 

[PATCH 1/6] net: split IP_TCP header into separate IP/IP6 and TCP headers

2023-05-08 Thread Dmitrii Merkurev
This allows us to reuse TCP logic between IP and IP6 stack.

Signed-off-by: Dmitrii Merkurev 
Cc: Ying-Chun Liu (PaulLiu) 
Cc: Simon Glass 
Сс: Joe Hershberger 
Сс: Ramon Fried 
---
 include/net/tcp.h | 50 ++---
 net/tcp.c | 70 +++
 test/cmd/wget.c   | 16 +--
 3 files changed, 64 insertions(+), 72 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index c29d4ce24a..5ab1127d8b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -5,20 +5,16 @@
  * Copyright 2017 Duncan Hare, All rights reserved.
  */
 
+#ifndef __TCP_H__
+#define __TCP_H__
+
 #define TCP_ACTIVITY 127   /* Number of packets received   */
/* before console progress mark */
+
+#define GET_TCP_HDR_LEN_IN_BYTES(x) ((x) >> 2)
+
 /**
- * struct ip_tcp_hdr - IP and TCP header
- * @ip_hl_v: header length and version
- * @ip_tos: type of service
- * @ip_len: total length
- * @ip_id: identification
- * @ip_off: fragment offset field
- * @ip_ttl: time to live
- * @ip_p: protocol
- * @ip_sum: checksum
- * @ip_src: Source IP address
- * @ip_dst: Destination IP address
+ * struct tcp_hdr - TCP header
  * @tcp_src: TCP source port
  * @tcp_dst: TCP destination port
  * @tcp_seq: TCP sequence number
@@ -28,18 +24,8 @@
  * @tcp_win: TCP windows size
  * @tcp_xsum: Checksum
  * @tcp_ugr: Pointer to urgent data
- */
-struct ip_tcp_hdr {
-   u8  ip_hl_v;
-   u8  ip_tos;
-   u16 ip_len;
-   u16 ip_id;
-   u16 ip_off;
-   u8  ip_ttl;
-   u8  ip_p;
-   u16 ip_sum;
-   struct in_addr  ip_src;
-   struct in_addr  ip_dst;
+*/
+struct tcp_hdr {
u16 tcp_src;
u16 tcp_dst;
u32 tcp_seq;
@@ -51,8 +37,8 @@ struct ip_tcp_hdr {
u16 tcp_ugr;
 } __packed;
 
-#define IP_TCP_HDR_SIZE(sizeof(struct ip_tcp_hdr))
-#define TCP_HDR_SIZE   (IP_TCP_HDR_SIZE  - IP_HDR_SIZE)
+#define TCP_HDR_SIZE   (sizeof(struct tcp_hdr))
+#define IP_TCP_HDR_SIZE (IP_HDR_SIZE + TCP_HDR_SIZE)
 
 #define TCP_DATA   0x00/* Data Packet - internal use only  */
 #define TCP_FIN0x01/* Finish flag  
*/
@@ -178,7 +164,8 @@ struct tcp_t_opt {
 
 /**
  * struct ip_tcp_hdr_o - IP + TCP header + TCP options
- * @hdr: IP + TCP header
+ * @ip_hdr: IP + TCP header
+ * @tcp_hdr: TCP header
  * @mss: TCP MSS Option
  * @scale: TCP Windows Scale Option
  * @sack_p: TCP Sack-Permitted Option
@@ -186,7 +173,8 @@ struct tcp_t_opt {
  * @end: end of options
  */
 struct ip_tcp_hdr_o {
-   struct  ip_tcp_hdr hdr;
+   struct  ip_hdr ip_hdr;
+   struct  tcp_hdrtcp_hdr;
struct  tcp_mssmss;
struct  tcp_scale  scale;
struct  tcp_sack_p sack_p;
@@ -198,13 +186,15 @@ struct ip_tcp_hdr_o {
 
 /**
  * struct ip_tcp_hdr_s - IP + TCP header + TCP options
- * @hdr: IP + TCP header
+ * @ip_hdr: IP + TCP header
+ * @tcp_hdr: TCP header
  * @t_opt: TCP Timestamp Option
  * @sack_v: TCP SACK Option
  * @end: end of options
  */
 struct ip_tcp_hdr_s {
-   struct  ip_tcp_hdr  hdr;
+   struct  ip_hdr ip_hdr;
+   struct  tcp_hdrtcp_hdr;
struct  tcp_t_opt   t_opt;
struct  tcp_sack_v  sack_v;
u8  end;
@@ -303,3 +293,5 @@ void rxhand_tcp_f(union tcp_build_pkt *b, unsigned int len);
 
 u16 tcp_set_pseudo_header(uchar *pkt, struct in_addr src, struct in_addr dest,
  int tcp_len, int pkt_len);
+
+#endif // __TCP_H__
diff --git a/net/tcp.c b/net/tcp.c
index a713e1dd60..10ce799814 100644
--- a/net/tcp.c
+++ b/net/tcp.c
@@ -155,7 +155,7 @@ u16 tcp_set_pseudo_header(uchar *pkt, struct in_addr src, 
struct in_addr dest,
  */
 int net_set_ack_options(union tcp_build_pkt *b)
 {
-   b->sack.hdr.tcp_hlen = 
SHIFT_TO_TCPHDRLEN_FIELD(LEN_B_TO_DW(TCP_HDR_SIZE));
+   b->sack.tcp_hdr.tcp_hlen = 
SHIFT_TO_TCPHDRLEN_FIELD(LEN_B_TO_DW(TCP_HDR_SIZE));
 
b->sack.t_opt.kind = TCP_O_TS;
b->sack.t_opt.len = TCP_OPT_LEN_A;
@@ -187,12 +187,12 @@ int net_set_ack_options(union tcp_build_pkt *b)
b->sack.sack_v.hill[3].r = TCP_O_NOP;
}
 
-   b->sack.hdr.tcp_hlen = 
SHIFT_TO_TCPHDRLEN_FIELD(ROUND_TCPHDR_LEN(TCP_HDR_SIZE +
+   b->sack.tcp_hdr.tcp_hlen = 
SHIFT_TO_TCPHDRLEN_FIELD(ROUND_TCPHDR_LEN(TCP_HDR_SIZE +

 TCP_TSOPT_SIZE +

 tcp_lost.len));
} else {
b->sack.sack_v.kind = 0;
-   b->sack.hdr.tcp_hlen = 
SHIFT_TO_TCPHDRLEN_FIELD(ROUND_TCPHDR_LEN(TCP_HDR_SIZE +
+   b->sack.tcp_hdr.tcp_hlen = 

Re: [PATCH] pci: ecm generic: use dev_read_() interface

2023-05-08 Thread Tom Rini
On Mon, May 08, 2023 at 08:30:15PM +0530, Mayuresh Chitale wrote:
> On Thu, May 4, 2023 at 2:04 AM Tom Rini  wrote:
> >
> > On Sat, Feb 18, 2023 at 05:55:25PM +0530, Mayuresh Chitale wrote:
> >
> > > Use dev_read_() api instead of the fdtdec API to fetch the host
> > > controller's reg property value. This is similar to the other host
> > > controller drivers such as Sifive, Rockchip etc. Without this change,
> > > enabling CONFIG_OF_LIVE breaks the PCIe enumeration on Qemu Risc-V virt
> > > machine. The issue is described in the link below:
> > >
> > > Link: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/1
> > > Signed-off-by: Mayuresh Chitale 
> > > Reviewed-by: Simon Glass 
> > > ---
> > >  drivers/pci/pcie_ecam_generic.c | 21 -
> > >  1 file changed, 8 insertions(+), 13 deletions(-)
> >
> > This breaks some platforms such as qemu_arm at a minimum.
> 
> Ok. How do I reproduce the issue?

Right, sorry.  So the failure log is:
https://source.denx.de/u-boot/u-boot/-/jobs/622397
And https://u-boot.readthedocs.io/en/latest/develop/py_testing.html
talks about running the pytest suite outside of CI and
https://u-boot.readthedocs.io/en/latest/develop/ci_testing.html about
how to trigger CI yourself.  One thing that's not documented well enough
is that you'll likely want
https://source.denx.de/u-boot/u-boot-test-hooks as well as you can just
use as-is the "travis-ci" directories (legacy name, used by both gitlab
and azure as-is) as the configuration hooks for your system as well and
then the network tests will run easily, locally.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] pci: ecm generic: use dev_read_() interface

2023-05-08 Thread Mayuresh Chitale
On Thu, May 4, 2023 at 2:04 AM Tom Rini  wrote:
>
> On Sat, Feb 18, 2023 at 05:55:25PM +0530, Mayuresh Chitale wrote:
>
> > Use dev_read_() api instead of the fdtdec API to fetch the host
> > controller's reg property value. This is similar to the other host
> > controller drivers such as Sifive, Rockchip etc. Without this change,
> > enabling CONFIG_OF_LIVE breaks the PCIe enumeration on Qemu Risc-V virt
> > machine. The issue is described in the link below:
> >
> > Link: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/1
> > Signed-off-by: Mayuresh Chitale 
> > Reviewed-by: Simon Glass 
> > ---
> >  drivers/pci/pcie_ecam_generic.c | 21 -
> >  1 file changed, 8 insertions(+), 13 deletions(-)
>
> This breaks some platforms such as qemu_arm at a minimum.

Ok. How do I reproduce the issue?

>
> --
> Tom


Re: [PATCH v3 14/17] spl: Commit MTRRs only in board_init_f_r()

2023-05-08 Thread Bin Meng
On Fri, May 5, 2023 at 6:51 AM Simon Glass  wrote:
>
> We don't need to commit the SPI-flash MTRR change immediately, since it is
> now done in the board_init_f_r(). Also this causes chromebook_link64 to
> hang, presumably since we are still running from CAR (Cache-as-RAM) in
> SPL. Coral handles this OK, perhaps since it is running from a different
> memory area, but it has no effect on Coral anyway.
>
> Drop the extra mtrr_commit() in the SPL implementation.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3:
> - Add more detail about why it might be hanging
>
>  arch/x86/lib/spl.c | 1 -
>  1 file changed, 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v3 12/17] x86: Return mtrr_add_request() to its old purpose

2023-05-08 Thread Bin Meng
On Mon, May 8, 2023 at 10:48 PM Bin Meng  wrote:
>
> Hi Simon,
>
> On Fri, May 5, 2023 at 6:51 AM Simon Glass  wrote:
> >
> > This function used to be for adding a list of requests to be actioned on
> > relocation. Revert it back to this purpose, to avoid problems with boards
> > which need control of their MTRRs (i.e. those which don't use FSP).
> >
> > The mtrr_set_next_var() function is available when the next free
> > variable-MTRR must be set, so this can be used instead.
> >
> > Signed-off-by: Simon Glass 
> > Fixes: 3bcd6cf89ef ("x86: mtrr: Skip MSRs that were already programmed..")
> > Fixes: 596bd0589ad ("x86: mtrr: Do not clear the unused ones..")
> > ---
> >
> > Changes in v3:
> > - Fix invalid commit IDs obtained from another branch
> >
> >  arch/x86/cpu/mtrr.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
> > index e69dfb552b1..c174dd9b3ad 100644
> > --- a/arch/x86/cpu/mtrr.c
> > +++ b/arch/x86/cpu/mtrr.c
> > @@ -156,8 +156,12 @@ int mtrr_commit(bool do_caches)
> > debug("open done\n");
> > qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr);
> > for (i = 0; i < gd->arch.mtrr_req_count; i++, req++)
> > -   mtrr_set_next_var(req->type, req->start, req->size);
> > +   set_var_mtrr(i, req->type, req->start, req->size);
>
> This change actually reverts 3bcd6cf89ef ("x86: mtrr: Skip MSRs that
> were already programmed.."), but as 3bcd6cf89ef commit message says:
>
> At present mtrr_commit() programs the MTRR MSRs starting from
> index 0, which may overwrite MSRs that were already programmed
> by previous boot stage or FSP.
>
> So this change will cause regression.
>
> >
> > +   /* Clear the ones that are unused */
> > +   debug("clear\n");
> > +   for (; i < mtrr_get_var_count(); i++)
> > +   wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
>
> This change actually reverts 596bd0589ad ("x86: mtrr: Do not clear the
> unused ones.."), which will also create regression unfortunately..
>
> > debug("close\n");
> > mtrr_close(, do_caches);
> > debug("mtrr done\n");
> > --

The regression mentioned above will cause Intel Crown Bay fail to
boot. See 
https://lore.kernel.org/u-boot/20210731084529.7524-1-bmeng...@gmail.com/

Regards,
Bin


Re: [PATCH v3 12/17] x86: Return mtrr_add_request() to its old purpose

2023-05-08 Thread Bin Meng
Hi Simon,

On Fri, May 5, 2023 at 6:51 AM Simon Glass  wrote:
>
> This function used to be for adding a list of requests to be actioned on
> relocation. Revert it back to this purpose, to avoid problems with boards
> which need control of their MTRRs (i.e. those which don't use FSP).
>
> The mtrr_set_next_var() function is available when the next free
> variable-MTRR must be set, so this can be used instead.
>
> Signed-off-by: Simon Glass 
> Fixes: 3bcd6cf89ef ("x86: mtrr: Skip MSRs that were already programmed..")
> Fixes: 596bd0589ad ("x86: mtrr: Do not clear the unused ones..")
> ---
>
> Changes in v3:
> - Fix invalid commit IDs obtained from another branch
>
>  arch/x86/cpu/mtrr.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
> index e69dfb552b1..c174dd9b3ad 100644
> --- a/arch/x86/cpu/mtrr.c
> +++ b/arch/x86/cpu/mtrr.c
> @@ -156,8 +156,12 @@ int mtrr_commit(bool do_caches)
> debug("open done\n");
> qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr);
> for (i = 0; i < gd->arch.mtrr_req_count; i++, req++)
> -   mtrr_set_next_var(req->type, req->start, req->size);
> +   set_var_mtrr(i, req->type, req->start, req->size);

This change actually reverts 3bcd6cf89ef ("x86: mtrr: Skip MSRs that
were already programmed.."), but as 3bcd6cf89ef commit message says:

At present mtrr_commit() programs the MTRR MSRs starting from
index 0, which may overwrite MSRs that were already programmed
by previous boot stage or FSP.

So this change will cause regression.

>
> +   /* Clear the ones that are unused */
> +   debug("clear\n");
> +   for (; i < mtrr_get_var_count(); i++)
> +   wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);

This change actually reverts 596bd0589ad ("x86: mtrr: Do not clear the
unused ones.."), which will also create regression unfortunately..

> debug("close\n");
> mtrr_close(, do_caches);
> debug("mtrr done\n");
> --

Regards,
Bin


Re: [RFC PATCH 1/5] add lwip-external submodule

2023-05-08 Thread Simon Glass
Hi Maxim,

On Fri, 5 May 2023 at 04:50, Maxim Uvarov  wrote:
>
> Signed-off-by: Maxim Uvarov 
> ---
>  .gitmodules| 3 +++
>  lib/lwip/lwip-external | 1 +
>  2 files changed, 4 insertions(+)
>  create mode 100644 .gitmodules
>  create mode 16 lib/lwip/lwip-external
>

Please no submodules. They are such a pain. If we want the code in
U-Boot, let's put it in U-Boot and upstream our changes as needed.

Regards,
Simon


Re: [[PATCH v2] 4/4] cmd: tlv_eeprom: enable 'dev' subcommand before 'read'

2023-05-08 Thread Simon Glass
Hi,

On Fri, 5 May 2023 at 02:22, Josua Mayer  wrote:
>
> Move the handler for "tlv_eeprom dev X" command to the beginning of
> do_tlv_eeprom, to allow using it before issuing a "read" command for
> currently selected eeprom.
>
> Also remove the check if eeprom exists, since that can only work after
> the first execution of read_eeprom triggered device lookup.
> Instead accept values up to the defined array size (MAX_TLV_DEVICES).
>
> Signed-off-by: Josua Mayer 
> Reviewed-by: Stefan Roese 
> Cc: Stefan Roese 
> Cc: Baruch Siach 
> Cc: Heinrich Schuchardt 
> ---
>  cmd/tlv_eeprom.c | 26 --
>  1 file changed, 16 insertions(+), 10 deletions(-)

Can someone take a look at fixing up the driver model code?

For example:
- it maintains its own array of eproms, when it should use driver
model to find them.
- the has_been_read flag seems to track only one EEPROM, but the code
indicates there might be two (should be in the device's private data)
- current_dev should be a pointer to a device
- ideally all state should be either in the device or the uclass, so
it can be used before relocation, etc.

Regards,
Simon


Re: [UBOOT PATCH 0/3] Port the usb reset patches from linux

2023-05-08 Thread Marek Vasut

On 5/8/23 05:00, Venkatesh Yadav Abbarapu wrote:

Port the usb reset patches from linux kernel.


What kind of patches are these ?
What sort of problem are those patches attempting to address ?


Venkatesh Yadav Abbarapu (3):
   usb: dwc3: core: improve reset sequence
   usb: dwc3: gadget: Don't send unintended link state change
   usb: dwc3: core: Only handle soft-reset in DCTL


These seem to be randomly picked patches from Linux 4.7, 5.5 ... but 
there seem to be a huge amount of backports missing inbetween, which 
would create a tremendous maintenance burden of the DWC3 driver.


Can you please instead pick ALL the missing patches from Linux, so that 
the DWC3 driver is instead synchronized with Linux, rather than 
diverging and growing partial backports ?


It shouldn't be difficult, one approach I can think of is roughly this:
- figure out the original merge base from which the DWC3 driver was 
imported to U-Boot

- in U-Boot, revert all dwc3 patches on top of that import patch
- pick all Linux kernel dwc3 patches from that merge base and apply on 
top of this U-Boot with reverts

- Run rebase and drop the reverts, let git drop duplicate patches

Thank you


Booting verdin-imx8mm_defconfig fails

2023-05-08 Thread Manuel Traut
Hi,

I am not able to run u-boot for the Toradex Verdin i.MX8MMini.
I am not sure if I built/using u-boot as intended for this platform.

DDR firmware used from:
https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.19.bin
and arm-trusted-firmware 2.8.0

u-boot was built with the following commands:

--8<--
debian$ export CROSS_COMPILE=aarch64-linux-gnu-
debian$ export ARCH=arm64 BL31=/usr/lib/arm-trusted-firmware/imx8mm/bl31.bin
debian$ make verdin-imx8mm_defconfig
debian$ make -j6 flash.bin
--8<--

1) running via serial download:
===

--8<--
debian$ sudo uuu SDP: boot -f flash.bin
uuu (Universal Update Utility) for nxp imx chips -- lib1.4.193

Success 0Failure 0


1:4  1/ 1 [=100%=] SDP: boot -f flash.bin
Okay
--8<--

Produces the following output:

--8<--
U-Boot SPL 2023.07-rc1-00199-g1917a1a8a8 (May 08 2023 - 13:11:50 +0200)
WDT:   Started watchdog@3028 with servicing every 1000ms (60s timeout)
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
--8<--


2) running from SDCard:
===

--8<--
debian$ sudo dd if=flash.bin of=/dev/sdb bs=1024 seek=33
1206+1 records in
1206+1 records out
1234992 bytes (1.2 MB, 1.2 MiB) copied, 0.260789 s, 4.7 MB/s
debian$ sync
--8<--

Pressing the 'recovery' switch while reseting the board:
Boots into Serial Download Mode

Just reseting the board:
Boots into Serial Download Mode

3) running from eMMC:
=

(no sdcard plugged in)

--8<--
imx8mm$ echo 0 > /sys/block/mmcblk1boot0/force_ro
imx8mm$ dd if=flash.bin of=/dev/mmcblk1boot0
imx8mm$ echo 1 > /sys/block/mmcblk1boot0/force_ro
imx8mm$ reboot
--8<--

Boots into Serial Download Mode

Any ideas?

Kind regards
Manuel


Re: [PATCH 1/1] fwu: fix config FWU_MULTI_BANK_UPDATE

2023-05-08 Thread Ilias Apalodimas
On Sun, 7 May 2023 at 09:39, Heinrich Schuchardt
 wrote:
>
> Symbol CONFIG_EFI_SETUP_EARLY does not exist anymore.
>
> CONFIG_FWU_MULTI_BANK_UPDATE without CONFIG_FWU_MDATA results in
>
> lib/fwu_updates/fwu.c:49: undefined reference to `fwu_get_mdata'
>
> Fixes: 86794052418b ("FWU: Add support for the FWU Multi Bank Update feature")
> Fixes: 023d9c93932c ("efi_loader: remove CONFIG_EFI_SETUP_EARLY")
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/fwu_updates/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
> index 78759e6618..71f34793d9 100644
> --- a/lib/fwu_updates/Kconfig
> +++ b/lib/fwu_updates/Kconfig
> @@ -2,7 +2,7 @@ config FWU_MULTI_BANK_UPDATE
> bool "Enable FWU Multi Bank Update Feature"
> depends on EFI_CAPSULE_ON_DISK
> select PARTITION_TYPE_GUID
> -   select EFI_SETUP_EARLY
> +   select FWU_MDATA
> imply EFI_CAPSULE_ON_DISK_EARLY
> select EVENT
> help
> --
> 2.39.2
>\

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v5 1/4] efi_loader: get version information from device tree

2023-05-08 Thread Heinrich Schuchardt

On 5/8/23 10:15, Masahisa Kojima wrote:

Hi Heinrich,

On Thu, 27 Apr 2023 at 15:09, Heinrich Schuchardt  wrote:


On 4/10/23 11:07, Masahisa Kojima wrote:

Current FMP->GetImageInfo() always return 0 for the firmware
version, user can not identify which firmware version is currently
running through the EFI interface.

This commit gets the version information from device tree,
then fills the firmware version, lowest supported version
in FMP->GetImageInfo().

Now FMP->GetImageInfo() and ESRT have the meaningful version number.

Signed-off-by: Masahisa Kojima 
---
Changes in v5:
- newly implement a device tree based versioning

   .../firmware/firmware-version.txt | 25 
   lib/efi_loader/efi_firmware.c | 63 +--
   2 files changed, 84 insertions(+), 4 deletions(-)
   create mode 100644 doc/device-tree-bindings/firmware/firmware-version.txt

diff --git a/doc/device-tree-bindings/firmware/firmware-version.txt 
b/doc/device-tree-bindings/firmware/firmware-version.txt
new file mode 100644
index 00..6112de4a1d
--- /dev/null
+++ b/doc/device-tree-bindings/firmware/firmware-version.txt
@@ -0,0 +1,25 @@
+firmware-version bindings
+---
+
+Required properties:
+- image-type-id  : guid for image blob type
+- image-index: image index
+- fw-version : firmware version
+- lowest-supported-version   : lowest supported version
+
+Example:
+
+ firmware-version {
+ image1 {
+ image-type-id = "09D7CF52-0720-4710-91D1-08469B7FE9C8";
+ image-index = <1>;
+ fw-version = <5>;
+ lowest-supported-version = <3>;
+ };
+ image2 {
+ image-type-id = "5A7021F5-FEF2-48B4-AABA-832E777418C0";
+ image-index = <2>;
+ fw-version = <10>;
+ lowest-supported-version = <7>;
+ };
+ };
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 93e2b01c07..1c6ef468bf 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -102,6 +102,56 @@ efi_status_t EFIAPI 
efi_firmware_set_package_info_unsupported(
   return EFI_EXIT(EFI_UNSUPPORTED);
   }

+/**
+ * efi_firmware_get_firmware_version - get firmware version from dtb
+ * @image_index: Image index
+ * @image_type_id:   Image type id
+ * @fw_version:  Pointer to store the version number
+ * @lsv: Pointer to store the lowest supported version
+ *
+ * Authenticate the capsule if authentication is enabled.
+ * The image pointer and the image size are updated in case of success.
+ */
+void efi_firmware_get_firmware_version(u8 image_index,
+efi_guid_t *image_type_id,
+u32 *fw_version, u32 *lsv)
+{
+ const void *fdt = gd->fdt_blob;
+ const fdt32_t *val;
+ const char *guid_str;
+ int len, offset, index;
+ int parent;
+
+ parent = fdt_subnode_offset(fdt, 0, "firmware-version");
+ if (parent < 0)
+ return;
+
+ fdt_for_each_subnode(offset, fdt, parent) {
+ efi_guid_t guid;
+
+ guid_str = fdt_getprop(fdt, offset, "image-type-id", );
+ if (!guid_str)
+ continue;
+ uuid_str_to_bin(guid_str, guid.b, UUID_STR_FORMAT_GUID);
+
+ val = fdt_getprop(fdt, offset, "image-index", );
+ if (!val)
+ continue;
+ index = fdt32_to_cpu(*val);
+
+ if (!guidcmp(, image_type_id) && index == image_index) {
+ val = fdt_getprop(fdt, offset, "fw-version", );
+ if (val)
+ *fw_version = fdt32_to_cpu(*val);
+
+ val = fdt_getprop(fdt, offset,
+   "lowest-supported-version", );
+ if (val)
+ *lsv = fdt32_to_cpu(*val);
+ }
+ }
+}
+
   /**
* efi_fill_image_desc_array - populate image descriptor array
* @image_info_size:Size of @image_info
@@ -148,13 +198,19 @@ static efi_status_t efi_fill_image_desc_array(
   *package_version_name = NULL; /* not supported */

   for (i = 0; i < num_image_type_guids; i++) {


Currently we define num_image_type_guids per board in a C file. Using
the same line of code once per board makes no sense to me. Please, move
the definition of that variable to lib/efi_loader/efi_firmware.c.


Sorry for the late reply.

num_image_type_guids is calculated with "ARRAY_SIZE(fw_images)",
fw_images[] array is also defined in each board file,
so we can not simply move num_image_type_guids into
lib/efi_loader/efi_firmware.c.


Why can't we have

  int num_image_type_guids = ARRAY_SIZE(fw_images);

in lib/efi_loader/efi_firmware.c?


How should I build u-boot for qemu_arm64_defconfig and run it on arm64 qemu virt machine?

2023-05-08 Thread Chan Kim
Hello experts,

 

Today I tried this test from scratch. 

In my environment, CROSS_COMPILE=aarch64-none-elf. 

Under u-boot directory, when I do 'make CROSS_COMPILE=aarch64-none-elf-
qemu_arm64_defconfig' and 'make -j28', I see this error at the end.

 

aarch64-none-elf-ld.bfd: invalid length for memory region .sram

 

after examining it, I added in include/configs/qemu-arm.h, 

 

#define CONFIG_SPL_MAX_SIZE value to 0x40

 

After fixing it, I got another similar error for .sdram and I added in
include/configs/qemu-arm.h,

 

#define CONFIG_SPL_BSS_START_ADDR 0x4080

#define CONFIG_SPL_BSS_MAX_SIZE 0x10

 

Now I can do 'make -j28' with no error.

But I found I have both 'u-boot' and 'spl/u-boot-spl' generated and I
realized for this qemu_arm64_defconfig, CONFIG_SPL=y and I get both u-boot
proper and u-boot spl. (SPL: secondary program loader, proper: main
bootloader. SPL runs first and the proper runs next).

 

Until now I did objcopy of the u-boot(proper) and then extended it to
0x40 byte. (the pflash size of the virt machine which starts at address
0x).

$ aarch64-none-elf-objcopy -O binary u-boot.v2022.07/u-boot pflashp.img

$ dd if=/dev/zero of=pflashp.img bs=1c count=1 seek=67108863

 

And the qemu command is :

$ qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine
virt,gic-version=max,secure=on,virtualization=true -cpu max -drive
if=pflash,file=pflashp.img -m 2G -nographic -device
loader,file=linux-5.15.68/arch/arm64/boot/Image,addr=0x8020

 

The qemu virt machine has RAM from 0x4000 until 0xbfff. 

And I could see u-boot runs and it waits input for 3 seconds and outputs the
u-boot prompt.

This is running u-boot (proper) from address 0 but since I have u-boot-spl
too, I should run it from u-boot-spl first, shouldn't I?

 

How am I supposed to run u-boot-spl and u-boot on this qemu machine? (from
lds files, it looks like they both start at address 0).

(qemu machine is arm64 virt machine, qemu 6.2.0).

 

 

Thank you.

 

Chan Kim

 



Re: [[PATCH v2] 1/4] cmd: tlv_eeprom: remove use of global variable current_dev

2023-05-08 Thread Stefan Roese

On 5/5/23 10:20, Josua Mayer wrote:

Make tlv_eeprom command device selection an explicit parameter of all
function calls.

Signed-off-by: Josua Mayer 
Cc: Stefan Roese 
Cc: Baruch Siach 
Cc: Heinrich Schuchardt 


All patches:

Applied to u-boot-marvell/master

Thanks,
Stefan


---
  cmd/tlv_eeprom.c | 50 ++--
  include/tlv_eeprom.h |  3 ++-
  2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
index 4591ff336bb..8049bf9843c 100644
--- a/cmd/tlv_eeprom.c
+++ b/cmd/tlv_eeprom.c
@@ -29,18 +29,18 @@ DECLARE_GLOBAL_DATA_PTR;
  
  /* File scope function prototypes */

  static bool is_checksum_valid(u8 *eeprom);
-static int read_eeprom(u8 *eeprom);
-static void show_eeprom(u8 *eeprom);
+static int read_eeprom(int devnum, u8 *eeprom);
+static void show_eeprom(int devnum, u8 *eeprom);
  static void decode_tlv(struct tlvinfo_tlv *tlv);
  static void update_crc(u8 *eeprom);
-static int prog_eeprom(u8 *eeprom);
+static int prog_eeprom(int devnum, u8 *eeprom);
  static bool tlvinfo_find_tlv(u8 *eeprom, u8 tcode, int *eeprom_index);
  static bool tlvinfo_delete_tlv(u8 *eeprom, u8 code);
  static bool tlvinfo_add_tlv(u8 *eeprom, int tcode, char *strval);
  static int set_mac(char *buf, const char *string);
  static int set_date(char *buf, const char *string);
  static int set_bytes(char *buf, const char *string, int *converted_accum);
-static void show_tlv_devices(void);
+static void show_tlv_devices(int current_dev);
  
  /* Set to 1 if we've read EEPROM into memory */

  static int has_been_read;
@@ -48,7 +48,6 @@ static int has_been_read;
  static u8 eeprom[TLV_INFO_MAX_LEN];
  
  static struct udevice *tlv_devices[MAX_TLV_DEVICES];

-static unsigned int current_dev;
  
  #define to_header(p) ((struct tlvinfo_header *)p)

  #define to_entry(p) ((struct tlvinfo_tlv *)p)
@@ -125,7 +124,7 @@ static bool is_checksum_valid(u8 *eeprom)
   *
   *  Read the EEPROM into memory, if it hasn't already been read.
   */
-static int read_eeprom(u8 *eeprom)
+static int read_eeprom(int devnum, u8 *eeprom)
  {
int ret;
struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
@@ -135,12 +134,11 @@ static int read_eeprom(u8 *eeprom)
return 0;
  
  	/* Read the header */

-   ret = read_tlv_eeprom((void *)eeprom_hdr, 0, HDR_SIZE, current_dev);
+   ret = read_tlv_eeprom((void *)eeprom_hdr, 0, HDR_SIZE, devnum);
/* If the header was successfully read, read the TLVs */
if (ret == 0 && is_valid_tlvinfo_header(eeprom_hdr))
ret = read_tlv_eeprom((void *)eeprom_tlv, HDR_SIZE,
- be16_to_cpu(eeprom_hdr->totallen),
- current_dev);
+ be16_to_cpu(eeprom_hdr->totallen), 
devnum);
  
  	// If the contents are invalid, start over with default contents

if (!is_valid_tlvinfo_header(eeprom_hdr) ||
@@ -165,7 +163,7 @@ static int read_eeprom(u8 *eeprom)
   *
   *  Display the contents of the EEPROM
   */
-static void show_eeprom(u8 *eeprom)
+static void show_eeprom(int devnum, u8 *eeprom)
  {
int tlv_end;
int curr_tlv;
@@ -180,7 +178,7 @@ static void show_eeprom(u8 *eeprom)
return;
}
  
-	printf("TLV: %u\n", current_dev);

+   printf("TLV: %u\n", devnum);
printf("TlvInfo Header:\n");
printf("   Id String:%s\n", eeprom_hdr->signature);
printf("   Version:  %d\n", eeprom_hdr->version);
@@ -389,7 +387,7 @@ static void update_crc(u8 *eeprom)
   *
   *  Write the EEPROM data from CPU memory to the hardware.
   */
-static int prog_eeprom(u8 *eeprom)
+static int prog_eeprom(int devnum, u8 *eeprom)
  {
int ret = 0;
struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
@@ -398,7 +396,7 @@ static int prog_eeprom(u8 *eeprom)
update_crc(eeprom);
  
  	eeprom_len = HDR_SIZE + be16_to_cpu(eeprom_hdr->totallen);

-   ret = write_tlv_eeprom(eeprom, eeprom_len);
+   ret = write_tlv_eeprom(eeprom, eeprom_len, devnum);
if (ret) {
printf("Programming failed.\n");
return -1;
@@ -433,11 +431,12 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
  {
char cmd;
struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
+   static unsigned int current_dev;
  
  	// If no arguments, read the EERPOM and display its contents

if (argc == 1) {
-   read_eeprom(eeprom);
-   show_eeprom(eeprom);
+   read_eeprom(current_dev, eeprom);
+   show_eeprom(current_dev, eeprom);
return 0;
}
  
@@ -448,7 +447,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])

// Read the EEPROM contents
if (cmd == 'r') {
has_been_read = 0;
-   if (!read_eeprom(eeprom))
+   

Please pull u-boot-marvell/master

2023-05-08 Thread Stefan Roese

Hi Tom,

please pull the following Marvell MVEBU related patches into next:


- cmd: tlv_eeprom: Misc cleanups & improvements (Josua)


Here the Azure build, without any issues:

https://dev.azure.com/sr0718/u-boot/_build/results?buildId=301=results

Thanks,
Stefan

The following changes since commit 1917a1a8a8bad28170cd464e5ea61ff0d738310b:

  Merge branch 'for-2023.07-2' of 
https://source.denx.de/u-boot/custodians/u-boot-mpc8xx (2023-05-07 
09:44:27 -0400)


are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-marvell.git

for you to fetch changes up to fa0af90a0ebd3557490640798ea4f5fad211d382:

  cmd: tlv_eeprom: enable 'dev' subcommand before 'read' (2023-05-08 
10:47:13 +0200)



Josua Mayer (4):
  cmd: tlv_eeprom: remove use of global variable current_dev
  cmd: tlv_eeprom: remove use of global variable has_been_read
  cmd: tlv_eeprom: handle -ENODEV error from read_eeprom function
  cmd: tlv_eeprom: enable 'dev' subcommand before 'read'

 cmd/tlv_eeprom.c | 107 
+--

 include/tlv_eeprom.h |   3 +-
 2 files changed, 64 insertions(+), 46 deletions(-)


Re: [PATCH v5 1/4] efi_loader: get version information from device tree

2023-05-08 Thread Masahisa Kojima
Hi Heinrich,

On Thu, 27 Apr 2023 at 15:09, Heinrich Schuchardt  wrote:
>
> On 4/10/23 11:07, Masahisa Kojima wrote:
> > Current FMP->GetImageInfo() always return 0 for the firmware
> > version, user can not identify which firmware version is currently
> > running through the EFI interface.
> >
> > This commit gets the version information from device tree,
> > then fills the firmware version, lowest supported version
> > in FMP->GetImageInfo().
> >
> > Now FMP->GetImageInfo() and ESRT have the meaningful version number.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > Changes in v5:
> > - newly implement a device tree based versioning
> >
> >   .../firmware/firmware-version.txt | 25 
> >   lib/efi_loader/efi_firmware.c | 63 +--
> >   2 files changed, 84 insertions(+), 4 deletions(-)
> >   create mode 100644 doc/device-tree-bindings/firmware/firmware-version.txt
> >
> > diff --git a/doc/device-tree-bindings/firmware/firmware-version.txt 
> > b/doc/device-tree-bindings/firmware/firmware-version.txt
> > new file mode 100644
> > index 00..6112de4a1d
> > --- /dev/null
> > +++ b/doc/device-tree-bindings/firmware/firmware-version.txt
> > @@ -0,0 +1,25 @@
> > +firmware-version bindings
> > +---
> > +
> > +Required properties:
> > +- image-type-id  : guid for image blob type
> > +- image-index: image index
> > +- fw-version : firmware version
> > +- lowest-supported-version   : lowest supported version
> > +
> > +Example:
> > +
> > + firmware-version {
> > + image1 {
> > + image-type-id = 
> > "09D7CF52-0720-4710-91D1-08469B7FE9C8";
> > + image-index = <1>;
> > + fw-version = <5>;
> > + lowest-supported-version = <3>;
> > + };
> > + image2 {
> > + image-type-id = 
> > "5A7021F5-FEF2-48B4-AABA-832E777418C0";
> > + image-index = <2>;
> > + fw-version = <10>;
> > + lowest-supported-version = <7>;
> > + };
> > + };
> > diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
> > index 93e2b01c07..1c6ef468bf 100644
> > --- a/lib/efi_loader/efi_firmware.c
> > +++ b/lib/efi_loader/efi_firmware.c
> > @@ -102,6 +102,56 @@ efi_status_t EFIAPI 
> > efi_firmware_set_package_info_unsupported(
> >   return EFI_EXIT(EFI_UNSUPPORTED);
> >   }
> >
> > +/**
> > + * efi_firmware_get_firmware_version - get firmware version from dtb
> > + * @image_index: Image index
> > + * @image_type_id:   Image type id
> > + * @fw_version:  Pointer to store the version number
> > + * @lsv: Pointer to store the lowest supported version
> > + *
> > + * Authenticate the capsule if authentication is enabled.
> > + * The image pointer and the image size are updated in case of success.
> > + */
> > +void efi_firmware_get_firmware_version(u8 image_index,
> > +efi_guid_t *image_type_id,
> > +u32 *fw_version, u32 *lsv)
> > +{
> > + const void *fdt = gd->fdt_blob;
> > + const fdt32_t *val;
> > + const char *guid_str;
> > + int len, offset, index;
> > + int parent;
> > +
> > + parent = fdt_subnode_offset(fdt, 0, "firmware-version");
> > + if (parent < 0)
> > + return;
> > +
> > + fdt_for_each_subnode(offset, fdt, parent) {
> > + efi_guid_t guid;
> > +
> > + guid_str = fdt_getprop(fdt, offset, "image-type-id", );
> > + if (!guid_str)
> > + continue;
> > + uuid_str_to_bin(guid_str, guid.b, UUID_STR_FORMAT_GUID);
> > +
> > + val = fdt_getprop(fdt, offset, "image-index", );
> > + if (!val)
> > + continue;
> > + index = fdt32_to_cpu(*val);
> > +
> > + if (!guidcmp(, image_type_id) && index == image_index) {
> > + val = fdt_getprop(fdt, offset, "fw-version", );
> > + if (val)
> > + *fw_version = fdt32_to_cpu(*val);
> > +
> > + val = fdt_getprop(fdt, offset,
> > +   "lowest-supported-version", );
> > + if (val)
> > + *lsv = fdt32_to_cpu(*val);
> > + }
> > + }
> > +}
> > +
> >   /**
> >* efi_fill_image_desc_array - populate image descriptor array
> >* @image_info_size:Size of @image_info
> > @@ -148,13 +198,19 @@ static efi_status_t efi_fill_image_desc_array(
> >   *package_version_name = NULL; /* not supported */
> >
> >   for (i = 0; i < num_image_type_guids; i++) {
>
> Currently we define num_image_type_guids per board in a C file. Using
> the same line of code once per board makes no sense 

Re: [PATCH v3 0/6] Add video drivers for endeavoru and p880/p895

2023-05-08 Thread Anatolij Gustschin
On Tue, 25 Apr 2023 10:51:41 +0300
Svyatoslav Ryhel clamo...@gmail.com wrote:
...
> ---
> Changes from v2:
> - added comments to panel drivers
> - fixed typo in ssd2825 driver
> 
> Changes from v1:
> - used lower-case hex for command sequences
> - ssd2825 switched to dm_spi_xfer
> - used log_* instead of printf
> - tweaked lm3533 help description
> 
> ---
> 
> Svyatoslav Ryhel (6):
>   video: add lm3533 backlight driver
>   video: bridge: add Solomon SSD2825 DSI/LVDS driver
>   video: panel: add Renesas R61307 MIPI DSI panel driver
>   video: panel: add Renesas R69328 MIPI DSI panel driver
>   video: tegra: add DC based PWM backlight driver
>   video: panel: add generic endeavoru panel
> 
>  drivers/video/Kconfig   |  38 ++
>  drivers/video/Makefile  |   4 +
>  drivers/video/bridge/Kconfig|   7 +
>  drivers/video/bridge/Makefile   |   1 +
>  drivers/video/bridge/ssd2825.c  | 520 
>  drivers/video/endeavoru-panel.c | 252 ++
>  drivers/video/lm3533_backlight.c| 134 +
>  drivers/video/renesas-r61307.c  | 302 
>  drivers/video/renesas-r69328.c  | 238 +
>  drivers/video/tegra20/Kconfig   |   7 +
>  drivers/video/tegra20/Makefile  |   1 +
>  drivers/video/tegra20/tegra-pwm-backlight.c | 155 ++
>  12 files changed, 1659 insertions(+)
>  create mode 100644 drivers/video/bridge/ssd2825.c
>  create mode 100644 drivers/video/endeavoru-panel.c
>  create mode 100644 drivers/video/lm3533_backlight.c
>  create mode 100644 drivers/video/renesas-r61307.c
>  create mode 100644 drivers/video/renesas-r69328.c
>  create mode 100644 drivers/video/tegra20/tegra-pwm-backlight.c

Patch series applied to u-boot-video/master, thanks!

--
Anatolij