Re: [PATCH 2/2] configs: am62x_evm_a53: Enable ethernet

2022-12-19 Thread Sjoerd Simons
On Tue, 2022-12-20 at 10:17 +0530, Dhruva Gole wrote:
> 
> 
> On 19/12/22 21:45, Sjoerd Simons wrote:
> > Enable configuration ethernet for u-boot on am62x; Some unrelated
> > things
> > also got moved around due to running through savedefconfig.
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> >   configs/am62x_evm_a53_defconfig | 11 ---
> >   1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/configs/am62x_evm_a53_defconfig
> > b/configs/am62x_evm_a53_defconfig
> > index e6ffd166927..30b19428e9e 100644
> > --- a/configs/am62x_evm_a53_defconfig
> > +++ b/configs/am62x_evm_a53_defconfig
> > @@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2
> [...]
> >   CONFIG_K3_SEC_PROXY=y
> > @@ -71,7 +73,10 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
> >   CONFIG_SPI_FLASH_SOFT_RESET=y
> >   CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
> >   CONFIG_SPI_FLASH_SPANSION=y
> > -CONFIG_SPI_FLASH_S28HS512T=y
> 
> Removing this might break  S28HS512T Octal SPI NOR Flash. Please let
> this stay if it isn't related to the eth configs.

This got removed by savedefconfig ; CONFIG_SPI_FLASH_S28HS512T doesn't
exist in u-boot anymore[0], it's been replaced by
CONFIG_SPI_FLASH_S28HX_T.   

I can do quick respin to seperate out cleaning the defconfig,
correcting that option and then add ethernet on top to make things more
clear.


0:https://source.denx.de/u-boot/u-boot/-/commit/f422c4bec7c654d185abb9bb29f79738e3115323

-- 
Sjoerd Simons
Collabora Ltd.


Pull request for tpm-20122022

2022-12-19 Thread Ilias Apalodimas
Hi Tom,

The following changes since commit 2243922edca9f56a9d5519b9d6e36f5d7a18434d:

  Prepare v2023.01-rc4 (2022-12-19 08:45:26 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-tpm/ tags/tpm-20122022

for you to fetch changes up to 33ba80303e93869c439828dd289fb8ef64ed3bfc:

  tpm2: ftpm: open session with privileged ree login (2022-12-20 09:37:36 +0200)


Etienne enabled privileged logins on the firmware TPM running
under OP-TEE.

We don't expect any substantial changes to the current functionality.
This is useful since fTPM may restrict access to that login when
Linux based OS is running and applications are expected to got through
the Linux TPMv2 driver instead of being accessed directly from a userspace
Trusted application


Etienne Carriere (1):
  tpm2: ftpm: open session with privileged ree login

 drivers/tpm/tpm2_ftpm_tee.c | 1 +
 1 file changed, 1 insertion(+)


Re: [ANN] U-Boot v2023.01-rc4 released

2022-12-19 Thread Jagan Teki
Hi Kever,

On Tue, 20 Dec 2022 at 12:37, Kever Yang  wrote:
>
> Hi Jagan,
>
> On 2022/12/20 14:41, Jagan Teki wrote:
> > On Mon, 19 Dec 2022 at 19:16, Tom Rini  wrote:
> >> Hey all,
> >>
> >> Here's -rc4, on schedule. I believe this should resolve the case Fedora
> >> showed where some binaries are allowed to be missing, IF a flag is also
> >> passed to make. We've got one more patch to make external optional
> >> binaries be more clearly supported, to pull in still.
> >>
> >> In terms of a changelog,
> >> git log --merges v2023.01-rc3..v2023.01-rc4
> >> contains what I've pulled but as always, better PR messages and tags
> >> will provide better results here.
> >>
> >> Looking forward, the schedule is for now rcs every other Monday, and
> >> with final release on January 9th, 2023.  Thanks all!
> > Any chance to pick rv1126 series for this rc so-that it will include
> > in the release? It's been there for a while.
> >
> > https://patchwork.ozlabs.org/project/uboot/cover/20221214175111.477134-1-ja...@edgeble.ai/
>
>
> This patch set is on my for-next list, I will send the PR once ready.
>
> But seems something wrong on board which is not rockchip soc:
>
> https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/14468

This link not opening for me.

Jagan.


Re: [ANN] U-Boot v2023.01-rc4 released

2022-12-19 Thread Kever Yang

Hi Jagan,

On 2022/12/20 14:41, Jagan Teki wrote:

On Mon, 19 Dec 2022 at 19:16, Tom Rini  wrote:

Hey all,

Here's -rc4, on schedule. I believe this should resolve the case Fedora
showed where some binaries are allowed to be missing, IF a flag is also
passed to make. We've got one more patch to make external optional
binaries be more clearly supported, to pull in still.

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

Looking forward, the schedule is for now rcs every other Monday, and
with final release on January 9th, 2023.  Thanks all!

Any chance to pick rv1126 series for this rc so-that it will include
in the release? It's been there for a while.

https://patchwork.ozlabs.org/project/uboot/cover/20221214175111.477134-1-ja...@edgeble.ai/



This patch set is on my for-next list, I will send the PR once ready.

But seems something wrong on board which is not rockchip soc:

https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/14468


Thanks,

- Kever



Jagan.


Re: [PATCH] eficonfig: EFI_VARIABLE_APPEND_WRITE is not set for null key

2022-12-19 Thread Ilias Apalodimas
On Tue, Dec 20, 2022 at 12:12:56AM +0900, Masahisa Kojima wrote:
> The signed null key with authenticated header is used to clear
> the PK, KEK, db and dbx. When CONFIG_EFI_MM_COMM_TEE is enabled
> (StMM and OP-TEE based RPMB storage is used as the EFI variable
> storage), clearing KEK, db and dbx by enrolling a signed null
> key does not work as expected if EFI_VARIABLE_APPEND_WRITE
> attritube is set.
>
> This commit checks the selected file is null key, then
> EFI_VARIABLE_APPEND_WRITE attibute will not be used for the null key.
>
> Signed-off-by: Masahisa Kojima 
> ---
>  cmd/eficonfig_sbkey.c | 40 ++--
>  1 file changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/cmd/eficonfig_sbkey.c b/cmd/eficonfig_sbkey.c
> index 6e0bebf1d4..bd2671bf8f 100644
> --- a/cmd/eficonfig_sbkey.c
> +++ b/cmd/eficonfig_sbkey.c
> @@ -72,6 +72,30 @@ static bool file_have_auth_header(void *buf, efi_uintn_t 
> size)
>   return true;
>  }
>
> +/**
> + * file_is_null_key() - check the file is an authenticated and signed null 
> key
> + * @auth:pointer to the file
> + * @size:file size
> + * @null_key:pointer to store the result
> + * Return:   status code
> + */
> +static efi_status_t file_is_null_key(struct efi_variable_authentication_2 
> *auth,
> +  efi_uintn_t size, bool *null_key)
> +{
> + efi_status_t ret = EFI_SUCCESS;
> +
> + if (size < (sizeof(auth->time_stamp) + auth->auth_info.hdr.dwLength))
> + return EFI_INVALID_PARAMETER;
> +
> + size -= (sizeof(auth->time_stamp) + auth->auth_info.hdr.dwLength);
> + if (size == 0) /* No payload */

s/size == 0/!size

> + *null_key = true;
> + else
> + *null_key = false;
> +
> + return ret;
> +}
> +
>  /**
>   * eficonfig_process_enroll_key() - enroll key into signature database
>   *
> @@ -84,6 +108,7 @@ static efi_status_t eficonfig_process_enroll_key(void 
> *data)
>   char *buf = NULL;
>   efi_uintn_t size;
>   efi_status_t ret;
> + bool null_key = false;
>   struct efi_file_handle *f = NULL;
>   struct efi_device_path *full_dp = NULL;
>   struct eficonfig_select_file_info file_info;
> @@ -149,13 +174,24 @@ static efi_status_t eficonfig_process_enroll_key(void 
> *data)
>   goto out;
>   }
>
> + ret = file_is_null_key((struct efi_variable_authentication_2 *)buf,
> +size, &null_key);
> + if (ret != EFI_SUCCESS) {
> + eficonfig_print_msg("ERROR! Invalid file format.");
> + goto out;
> + }
> +
>   attr = EFI_VARIABLE_NON_VOLATILE |
>  EFI_VARIABLE_BOOTSERVICE_ACCESS |
>  EFI_VARIABLE_RUNTIME_ACCESS |
>  EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
>
> - /* PK can enroll only one certificate */
> - if (u16_strcmp(data, u"PK")) {
> + /*
> +  * PK can enroll only one certificate.
> +  * The signed null key is used to clear KEK, db and dbx.
> +  * EFI_VARIABLE_APPEND_WRITE attribute must not be set in these cases.
> +  */
> + if (u16_strcmp(data, u"PK") && !null_key) {
>   efi_uintn_t db_size = 0;
>
>   /* check the variable exists. If exists, add APPEND_WRITE 
> attribute */
> --
> 2.17.1
>

Reviewed-by: Ilias Apalodimas 



Re: [PATCH v2 2/2] eficonfig: avoid SetVariable between GetNextVariableName calls

2022-12-19 Thread Ilias Apalodimas
On Mon, Dec 19, 2022 at 11:33:13AM +0900, Masahisa Kojima wrote:
> The current code calls efi_set_variable_int() to delete the
> invalid boot option between calls to efi_get_next_variable_name_int(),
> it may produce unpredictable results.
>
> This commit moves removal of the invalid boot option outside
> of the efi_get_next_variable_name_int() calls.
> EFI_NOT_FOUND returned from efi_get_next_variable_name_int()
> indicates we retrieved all EFI variables, it should be treated
> as EFI_SUCEESS.
>
> To address the checkpatch warning of too many leading tabs,
> combine two if statement into one.
>
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v2:
> - fix typos
> - use '!guidcmp()' instead of 'guidcmp() == 0'
> - remove superfluous malloc() branch
>
>  cmd/eficonfig.c | 54 ++---
>  1 file changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 0b07dfc958..ce7175a566 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -2310,13 +2310,14 @@ out:
>  efi_status_t eficonfig_delete_invalid_boot_option(struct 
> eficonfig_media_boot_option *opt,
> efi_status_t count)
>  {
> - u32 i;
>   efi_uintn_t size;
>   void *load_option;
> + u32 i, list_size = 0;
>   struct efi_load_option lo;
>   u16 *var_name16 = NULL;
>   u16 varname[] = u"Boot";
>   efi_status_t ret = EFI_SUCCESS;
> + u16 *delete_index_list = NULL, *p;
>   efi_uintn_t buf_size;
>
>   buf_size = 128;
> @@ -2331,8 +2332,14 @@ efi_status_t 
> eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op
>   efi_uintn_t tmp;
>
>   ret = efi_next_variable_name(&buf_size, &var_name16, &guid);
> - if (ret == EFI_NOT_FOUND)
> + if (ret == EFI_NOT_FOUND) {
> + /*
> +  * EFI_NOT_FOUND indicates we retrieved all EFI 
> variables.
> +  * This should be treated as success.
> +  */
> + ret = EFI_SUCCESS;
>   break;
> + }
>   if (ret != EFI_SUCCESS)
>   goto out;
>
> @@ -2349,31 +2356,46 @@ efi_status_t 
> eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op
>   if (ret != EFI_SUCCESS)
>   goto next;
>
> - if (size >= sizeof(efi_guid_bootmenu_auto_generated)) {
> - if (guidcmp(lo.optional_data, 
> &efi_guid_bootmenu_auto_generated) == 0) {
> - for (i = 0; i < count; i++) {
> - if (opt[i].size == tmp &&
> - memcmp(opt[i].lo, load_option, tmp) 
> == 0) {
> - opt[i].exist = true;
> - break;
> - }
> + if (size >= sizeof(efi_guid_bootmenu_auto_generated) &&
> + !guidcmp(lo.optional_data, 
> &efi_guid_bootmenu_auto_generated)) {
> + for (i = 0; i < count; i++) {
> + if (opt[i].size == tmp &&
> + memcmp(opt[i].lo, load_option, tmp) == 0) {
> + opt[i].exist = true;
> + break;
>   }
> + }
>
> - if (i == count) {
> - ret = delete_boot_option(i);
> - if (ret != EFI_SUCCESS) {
> - free(load_option);
> - goto out;
> - }
> + /*
> +  * The entire list of variables must be retrieved by
> +  * efi_get_next_variable_name_int() before deleting the 
> invalid
> +  * boot option, just save the index here.
> +  */
> + if (i == count) {
> + p = realloc(delete_index_list, sizeof(u32) *
> + (list_size + 1));
> + if (!p) {
> + ret = EFI_OUT_OF_RESOURCES;
> + goto out;
>   }
> + delete_index_list = p;
> + delete_index_list[list_size++] = index;
>   }
>   }
>  next:
>   free(load_option);
>   }
>
> + /* delete all invalid boot options */
> + for (i = 0; i < list_size; i++) {
> + ret = delete_boot_option(delete_index_list[i]);
> + if (ret != EFI_SUCCESS)
> + goto out;
> + }
> +

Re: [PATCH v2 1/2] eficonfig: carve out efi_get_next_variable_name_int calls

2022-12-19 Thread Ilias Apalodimas
On Mon, Dec 19, 2022 at 11:33:12AM +0900, Masahisa Kojima wrote:
> To retrieve the EFI variable name by efi_get_next_variable_name_int(),
> the sequence of alloc -> efi_get_next_variable_name_int ->
> realloc -> efi_get_next_variable_name_int is required.
> In current code, this sequence repeatedly appears in
> the several functions. It should be curved out a common function.
>
> This commit also fixes the missing free() of var_name16
> in eficonfig_delete_invalid_boot_option().
>
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v2:
> - fix typo in the commit message
> - rename efi_get_variable_name to efi_next_variable_name
>
>  cmd/eficonfig.c | 62 +
>  include/efi_loader.h|  2 ++
>  lib/efi_loader/efi_helper.c | 34 
>  3 files changed, 51 insertions(+), 47 deletions(-)
>
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 394ae67cce..0b07dfc958 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -1683,7 +1683,7 @@ static efi_status_t 
> eficonfig_show_boot_selection(unsigned int *selected)
>   u32 i;
>   u16 *bootorder;
>   efi_status_t ret;
> - u16 *var_name16 = NULL, *p;
> + u16 *var_name16 = NULL;
>   efi_uintn_t num, size, buf_size;
>   struct efimenu *efi_menu;
>   struct list_head *pos, *n;
> @@ -1718,24 +1718,12 @@ static efi_status_t 
> eficonfig_show_boot_selection(unsigned int *selected)
>   int index;
>   efi_guid_t guid;
>
> - size = buf_size;
> - ret = efi_get_next_variable_name_int(&size, var_name16, &guid);
> + ret = efi_next_variable_name(&buf_size, &var_name16, &guid);
>   if (ret == EFI_NOT_FOUND)
>   break;
> - if (ret == EFI_BUFFER_TOO_SMALL) {
> - buf_size = size;
> - p = realloc(var_name16, buf_size);
> - if (!p) {
> - free(var_name16);
> - return EFI_OUT_OF_RESOURCES;
> - }
> - var_name16 = p;
> - ret = efi_get_next_variable_name_int(&size, var_name16, 
> &guid);
> - }
> - if (ret != EFI_SUCCESS) {
> - free(var_name16);
> - return ret;
> - }
> + if (ret != EFI_SUCCESS)
> + goto out;
> +
>   if (efi_varname_is_load_option(var_name16, &index)) {
>   /* If the index is included in the BootOrder, skip it */
>   if (search_bootorder(bootorder, num, index, NULL))
> @@ -2026,7 +2014,7 @@ static efi_status_t 
> eficonfig_create_change_boot_order_entry(struct efimenu *efi
>   u32 i;
>   char *title;
>   efi_status_t ret;
> - u16 *var_name16 = NULL, *p;
> + u16 *var_name16 = NULL;
>   efi_uintn_t size, buf_size;
>
>   /* list the load option in the order of BootOrder variable */
> @@ -2054,19 +2042,9 @@ static efi_status_t 
> eficonfig_create_change_boot_order_entry(struct efimenu *efi
>   break;
>
>   size = buf_size;
> - ret = efi_get_next_variable_name_int(&size, var_name16, &guid);
> + ret = efi_next_variable_name(&buf_size, &var_name16, &guid);
>   if (ret == EFI_NOT_FOUND)
>   break;
> - if (ret == EFI_BUFFER_TOO_SMALL) {
> - buf_size = size;
> - p = realloc(var_name16, buf_size);
> - if (!p) {
> - ret = EFI_OUT_OF_RESOURCES;
> - goto out;
> - }
> - var_name16 = p;
> - ret = efi_get_next_variable_name_int(&size, var_name16, 
> &guid);
> - }
>   if (ret != EFI_SUCCESS)
>   goto out;
>
> @@ -2336,10 +2314,10 @@ efi_status_t 
> eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op
>   efi_uintn_t size;
>   void *load_option;
>   struct efi_load_option lo;
> - u16 *var_name16 = NULL, *p;
> + u16 *var_name16 = NULL;
>   u16 varname[] = u"Boot";
>   efi_status_t ret = EFI_SUCCESS;
> - efi_uintn_t varname_size, buf_size;
> + efi_uintn_t buf_size;
>
>   buf_size = 128;
>   var_name16 = malloc(buf_size);
> @@ -2352,24 +2330,12 @@ efi_status_t 
> eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op
>   efi_guid_t guid;
>   efi_uintn_t tmp;
>
> - varname_size = buf_size;
> - ret = efi_get_next_variable_name_int(&varname_size, var_name16, 
> &guid);
> + ret = efi_next_variable_name(&buf_size, &var_name16, &guid);
>   if (ret == EFI_NOT_FOUND)
>   break;
> - if (ret == EFI_BUFFER_TOO_SMALL) {
> - buf_size

Re: [ANN] U-Boot v2023.01-rc4 released

2022-12-19 Thread Jagan Teki
On Mon, 19 Dec 2022 at 19:16, Tom Rini  wrote:
>
> Hey all,
>
> Here's -rc4, on schedule. I believe this should resolve the case Fedora
> showed where some binaries are allowed to be missing, IF a flag is also
> passed to make. We've got one more patch to make external optional
> binaries be more clearly supported, to pull in still.
>
> In terms of a changelog,
> git log --merges v2023.01-rc3..v2023.01-rc4
> contains what I've pulled but as always, better PR messages and tags
> will provide better results here.
>
> Looking forward, the schedule is for now rcs every other Monday, and
> with final release on January 9th, 2023.  Thanks all!

Any chance to pick rv1126 series for this rc so-that it will include
in the release? It's been there for a while.

https://patchwork.ozlabs.org/project/uboot/cover/20221214175111.477134-1-ja...@edgeble.ai/

Jagan.


[PATCH v2 2/2] test: cmd: exit: Add unit test for exit and partly run commands

2022-12-19 Thread Marek Vasut
Add a test which validates that exit from environment script works as
expected, including return value propagation and clipping to positive
integers.

Reviewed-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Adrian Vovk 
Cc: Hector Palacios 
Cc: Pantelis Antoniou 
Cc: Simon Glass 
Cc: Tom Rini 
---
V2: Add RB from Simon
---
 include/test/suites.h |   1 +
 test/cmd/Makefile |   2 +-
 test/cmd/exit.c   | 135 ++
 test/cmd_ut.c |   1 +
 4 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 test/cmd/exit.c

diff --git a/include/test/suites.h b/include/test/suites.h
index a01000e127b..9ce49cbb031 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -38,6 +38,7 @@ int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int 
argc,
  char *const argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index bc961df3dce..09e410ec30e 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -8,7 +8,7 @@ endif
 ifdef CONFIG_CONSOLE_RECORD
 obj-$(CONFIG_CMD_PAUSE) += test_pause.o
 endif
-obj-y += mem.o
+obj-y += exit.o mem.o
 obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
 obj-$(CONFIG_CMD_FDT) += fdt.o
 obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o
diff --git a/test/cmd/exit.c b/test/cmd/exit.c
new file mode 100644
index 000..ca34abef899
--- /dev/null
+++ b/test/cmd/exit.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for exit command
+ *
+ * Copyright 2022 Marek Vasut 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Declare a new exit test */
+#define EXIT_TEST(_name, _flags)   UNIT_TEST(_name, _flags, exit_test)
+
+/* Test 'exit addr' getting/setting address */
+static int cmd_exit_test(struct unit_test_state *uts)
+{
+   int i;
+
+   /*
+* Test 'exit' with parameter -3, -2, -1, 0, 1, 2, 3 . Use all those
+* parameters to cover also the special return value -2 that is used
+* in HUSH to detect exit command.
+*
+* Always test whether 'exit' command:
+* - exits out of the 'run' command
+* - return value is propagated out of the 'run' command
+* - return value can be tested on outside of 'run' command
+* - return value can be printed outside of 'run' command
+*/
+   for (i = -3; i <= 3; i++) {
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit %d ; echo 
baz' ; run foo ; echo $?", i));
+   ut_assert_nextline("bar");
+   ut_assert_nextline("%d", i > 0 ? i : 0);
+   ut_assertok(ut_check_console_end(uts));
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit %d ; echo 
baz' ; run foo && echo quux ; echo $?", i));
+   ut_assert_nextline("bar");
+   if (i <= 0)
+   ut_assert_nextline("quux");
+   ut_assert_nextline("%d", i > 0 ? i : 0);
+   ut_assertok(ut_check_console_end(uts));
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit %d ; echo 
baz' ; run foo || echo quux ; echo $?", i));
+   ut_assert_nextline("bar");
+   if (i > 0)
+   ut_assert_nextline("quux");
+   /* Either 'exit' returns 0, or 'echo quux' returns 0 */
+   ut_assert_nextline("0");
+   ut_assertok(ut_check_console_end(uts));
+   }
+
+   /* Validate that 'exit' behaves the same way as 'exit 0' */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit ; echo baz' ; run 
foo ; echo $?", i));
+   ut_assert_nextline("bar");
+   ut_assert_nextline("0");
+   ut_assertok(ut_check_console_end(uts));
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit ; echo baz' ; run 
foo && echo quux ; echo $?", i));
+   ut_assert_nextline("bar");
+   ut_assert_nextline("quux");
+   ut_assert_nextline("0");
+   ut_assertok(ut_check_console_end(uts));
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("setenv foo 'echo bar ; exit ; echo baz' ; run 
foo || echo quux ; echo $?", i));
+   ut_assert_nextline("bar");
+   /* Ei

[PATCH v2 1/2] cmd: exit: Fix return value propagation out of environment scripts

2022-12-19 Thread Marek Vasut
Make sure the 'exit' command as well as 'exit $val' command exits
from environment scripts immediately and propagates return value
out of those scripts fully. That means the following behavior is
expected:

"
=> setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
bar
1
=> setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
bar
0
"

As well as the followin behavior:

"
=> setenv foo 'echo bar ; exit 3 ; echo fail'; run foo; echo $?
bar
3
=> setenv foo 'echo bar ; exit 1 ; echo fail'; run foo; echo $?
bar
1
=> setenv foo 'echo bar ; exit 0 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit -1 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit ; echo fail'; run foo; echo $?
bar
0
"

Fixes: 8c4e3b79bd0 ("cmd: exit: Fix return value")
Reviewed-by: Hector Palacios 
Signed-off-by: Marek Vasut 
---
Cc: Adrian Vovk 
Cc: Hector Palacios 
Cc: Pantelis Antoniou 
Cc: Simon Glass 
Cc: Tom Rini 
---
V2: - Add RB from Hector
- Update exit.rst
---
 cmd/exit.c |  7 +--
 common/cli.c   |  7 ---
 common/cli_hush.c  | 21 +++--
 doc/usage/cmd/exit.rst |  4 +++-
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/cmd/exit.c b/cmd/exit.c
index 2c7132693ad..7bf241ec732 100644
--- a/cmd/exit.c
+++ b/cmd/exit.c
@@ -10,10 +10,13 @@
 static int do_exit(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[])
 {
+   int r;
+
+   r = 0;
if (argc > 1)
-   return dectoul(argv[1], NULL);
+   r = simple_strtoul(argv[1], NULL, 10);
 
-   return 0;
+   return -r - 2;
 }
 
 U_BOOT_CMD(
diff --git a/common/cli.c b/common/cli.c
index a47d6a3f2b4..ba45dad2db5 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -146,7 +146,7 @@ int run_commandf(const char *fmt, ...)
 #if defined(CONFIG_CMD_RUN)
 int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-   int i;
+   int i, ret;
 
if (argc < 2)
return CMD_RET_USAGE;
@@ -160,8 +160,9 @@ int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[])
return 1;
}
 
-   if (run_command(arg, flag | CMD_FLAG_ENV) != 0)
-   return 1;
+   ret = run_command(arg, flag | CMD_FLAG_ENV);
+   if (ret)
+   return ret;
}
return 0;
 }
diff --git a/common/cli_hush.c b/common/cli_hush.c
index 1467ff81b35..b8940b19735 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -1902,7 +1902,7 @@ static int run_list_real(struct pipe *pi)
last_return_code = -rcode - 2;
return -2;  /* exit */
}
-   last_return_code=(rcode == 0) ? 0 : 1;
+   last_return_code = rcode;
 #endif
 #ifndef __U_BOOT__
pi->num_progs = save_num_progs; /* restore number of programs */
@@ -3212,7 +3212,15 @@ static int parse_stream_outer(struct in_str *inp, int 
flag)
printf("exit not allowed from main 
input shell.\n");
continue;
}
-   break;
+   /*
+* DANGER
+* Return code -2 is special in this context,
+* it indicates exit from inner pipe instead
+* of return code itself, the return code is
+* stored in 'last_return_code' variable!
+* DANGER
+*/
+   return -2;
}
if (code == -1)
flag_repeat = 0;
@@ -3249,9 +3257,9 @@ int parse_string_outer(const char *s, int flag)
 #endif /* __U_BOOT__ */
 {
struct in_str input;
+   int rcode;
 #ifdef __U_BOOT__
char *p = NULL;
-   int rcode;
if (!s)
return 1;
if (!*s)
@@ -3263,11 +3271,12 @@ int parse_string_outer(const char *s, int flag)
setup_string_in_str(&input, p);
rcode = parse_stream_outer(&input, flag);
free(p);
-   return rcode;
+   return rcode == -2 ? last_return_code : rcode;
} else {
 #endif
setup_string_in_str(&input, s);
-   return parse_stream_outer(&input, flag);
+   rcode = parse_stream_outer(&input, flag);
+   return rcode == -2 ? last_return_code : rcode;
 #ifdef __U_BOOT__
}
 #endif
@@ -3287,7 +3296,7 @@ int parse_file_outer(void)
setup_file_in_str(&input);
 #endif
rcode = parse_stream_outer(&input, FLAG_PARSE_SEMICOLON);
-   return rcod

Re: Converting to DM SERIAL for Kirkwood boards

2022-12-19 Thread Stefan Roese

Hi Tony,

On 12/20/22 02:36, Tony Dinh wrote:

Hi Stefan,

On Mon, Dec 19, 2022 at 4:06 PM Tony Dinh  wrote:


Hi Stefan,

On Mon, Dec 19, 2022 at 1:22 PM Tony Dinh  wrote:


Hi Stefan,

On Sun, Dec 18, 2022 at 11:29 PM Stefan Roese  wrote:


Hi Tony,

On 12/19/22 07:17, Stefan Roese wrote:




git checkout 37bb396669b27aa62fe8bc5eeb6bfde92e09c2d3
Previous HEAD position was 3b44b3fdf2 arm: mvebu: Add support for
programming LD0 and LD1 eFuse
HEAD is now at 37bb396669 timer: orion-timer: Only init timer once

This is where the Pogo V4 was frozen during boot. Among the Kirkwood
boards that I have and used for testing, it is the only one that has
CONFIG_BOOTSTAGE=y.


Thanks for testing and git bi-secting.


Should I create a new post for would like to continue this topic here
in this thread?


Let me check, if I can find the root cause and this problem quickly. If
not, then we should probably disable CONFIG_BOOTSTAGE on the Pogo v4 for
a short while until we've fixed this issue.


I fail to spot the problem with this small commit 37bb396669b27a. I can
also not reproduce this on my Armada XP board - it uses SPL though, this
might make a difference.

Could you perhaps apply this attached debug patch and make sure, that
you have DEBUG_UART enabled in your Pogo v4 config. And boot into the
resulting image.


Here is the kwboot log with DEBUG_UART. Note that number 322322 below
is part of the log.

322322

U-Boot 2023.01-rc3-00057-g9bd3d354a1-dirty (Dec 19 2022 - 01:29:21 -0800)
Pogoplug V4

SoC:   Kirkwood 88F6281_A1
Model: Cloud Engines PogoPlug Series 4
DRAM:  128 MiB
322322322Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  4



Going a bit further with your debug patch, I've added more prints.

  static void orion_timer_init(void *base, enum input_clock_type type)
  {
 /* Only init the timer once */
-   if (early_init_done)
+   if (early_init_done) {
+   printch('6'); // test-only
 return;
+   }

And the boot log below shows somehow the early_init_done is already
true by the time the orion_timer_init is called. Pretty weird, to say
the least!

--BEGIN LOG--
3262632626

U-Boot 2023.01-rc4-dirty (Dec 19 2022 - 15:35:26 -0800)
Pogoplug V4

SoC:   Kirkwood 88F6281_A1
Model: Cloud Engines PogoPlug Series 4
DRAM:  128 MiB
326263262632626Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  456
--END LOG--



I tried this change in drivers/timer/orion-timer.c and it seems to
work consistently.

-static bool early_init_done __section(".data") = false;
+static bool early_init_done = false;

I still can't see why it would make a difference. Why does the
__section macro not work? does the reallocation timing have anything
to do with this variable being of the wrong value?


Hmmm, so we might have a problem with memory being overwritten? You
should perhaps where the sections (especially data) are located and
where the stack etc is located. I suggest to also enable DEBUG in
board_f/c.c to see a bit more of the addresses being used.

Thanks,
Stefan


Re: Converting to DM SERIAL for Kirkwood boards

2022-12-19 Thread Stefan Roese

Hi Tony,

On 12/19/22 22:22, Tony Dinh wrote:

Hi Stefan,

On Sun, Dec 18, 2022 at 11:29 PM Stefan Roese  wrote:


Hi Tony,

On 12/19/22 07:17, Stefan Roese wrote:




git checkout 37bb396669b27aa62fe8bc5eeb6bfde92e09c2d3
Previous HEAD position was 3b44b3fdf2 arm: mvebu: Add support for
programming LD0 and LD1 eFuse
HEAD is now at 37bb396669 timer: orion-timer: Only init timer once

This is where the Pogo V4 was frozen during boot. Among the Kirkwood
boards that I have and used for testing, it is the only one that has
CONFIG_BOOTSTAGE=y.


Thanks for testing and git bi-secting.


Should I create a new post for would like to continue this topic here
in this thread?


Let me check, if I can find the root cause and this problem quickly. If
not, then we should probably disable CONFIG_BOOTSTAGE on the Pogo v4 for
a short while until we've fixed this issue.


I fail to spot the problem with this small commit 37bb396669b27a. I can
also not reproduce this on my Armada XP board - it uses SPL though, this
might make a difference.

Could you perhaps apply this attached debug patch and make sure, that
you have DEBUG_UART enabled in your Pogo v4 config. And boot into the
resulting image.


Here is the kwboot log with DEBUG_UART. Note that number 322322 below
is part of the log.

322322

U-Boot 2023.01-rc3-00057-g9bd3d354a1-dirty (Dec 19 2022 - 01:29:21 -0800)
Pogoplug V4

SoC:   Kirkwood 88F6281_A1
Model: Cloud Engines PogoPlug Series 4
DRAM:  128 MiB
322322322Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  4


Ah, I totally forgot that this board did not hang before the first UART
output but later after the NAND stage. I added these UART debug infos to
debug an early boot problem before any normal UART output.

Thanks,
Stefan


[PATCH v5 6/6] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the project name, which is not a
useful thing to do in $HOME/.patman.  A new test is added, along
updated documentation.

Signed-off-by: Maxim Cournoyer 
---

Changes in v5:
- Use try/finally in cleared_command_line_args context manager

Changes in v4:
- Use tools.run to invoke git in test suite

Changes in v3:
- Clear command line arguments in test_git_local_config
- Also test overriding a 'send' command line argument

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

 tools/patman/patman.rst   |  8 -
 tools/patman/settings.py  | 24 ++---
 tools/patman/test_settings.py | 67 +++
 3 files changed, 94 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 395fc0cd75..d7994c888b 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -74,7 +74,7 @@ out where to send patches pretty well.
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
 
-To add your own, create a file ~/.patman like this::
+To add your own, create a file `~/.patman` like this::
 
 # patman alias file
 
@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
 wolfgang: Wolfgang Denk 
 others: Mike Frysinger , Fred Bloggs 

 
+Patman will also look for a `.patman` configuration file at the root
+of the current project git repository, which makes it possible to
+override the `project` settings variable or anything else in a
+project-specific way. The values of this "local" configuration file
+take precedence over those of the "global" one.
+
 Aliases are recursive.
 
 The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c05efd2475..636983e32d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
+# Copyright (c) 2022 Maxim Cournoyer 
 #
 
 try:
@@ -336,6 +337,12 @@ def GetItems(config, section):
 def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
+Unless `config_fname` is specified, a `.patman` config file local
+to the git repository is consulted, followed by the global
+`$HOME/.patman`. If none exists, the later is created. Values
+defined in the local config file take precedence over those
+defined in the global one.
+
 Args:
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
@@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
 
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
+has_config = os.path.exists(config_fname)
 
-if not os.path.exists(config_fname):
-print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(config_fname)
+git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
+has_git_local_config = os.path.exists(git_local_config_fname)
 
-config.read(config_fname)
+# Read the git local config last, so that its values override
+# those of the global config, if any.
+if has_config:
+config.read(config_fname)
+if has_git_local_config:
+config.read(git_local_config_fname)
+
+if not (has_config or has_git_local_config):
+print("No config file found.\nCreating ~/.patman...\n")
+CreatePatmanConfigFile(config_fname)
 
 for name, value in GetItems(config, 'alias'):
 alias[name] = value.split(',')
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
new file mode 100644
index 00..c768a2fc64
--- /dev/null
+++ b/tools/patman/test_settings.py
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2022 Maxim Cournoyer 
+#
+
+import argparse
+import contextlib
+import os
+import sys
+import tempfile
+
+from patman import settings
+from patman import tools
+
+
+@contextlib.contextmanager
+def empty_git_repository():
+with tempfile.TemporaryDirectory() as tmpdir:
+os.chdir(tmpdir)
+tools.run('git', 'init', raise_on_error=True)
+yield tmpdir
+
+
+@contextlib.contextmanager
+def cleared_command_line_args():
+old_value = sys.argv[:]
+sys.argv = [sys.argv[0]]
+try:
+yield
+finally:
+sys.argv = old_value
+
+
+def test_git_local_config():
+# Clearing the command line arguments is required, otherwise
+# arguments passed to the test running such as in 'pytest -k
+# filter' would be processed by _UpdateDefaults and fail.
+with cleared_command_line_args():
+wi

[PATCH v5 5/6] patman: fail early in Setup when provided config file does not exist

2022-12-19 Thread Maxim Cournoyer
Rationale: if the user explicitly provide this argument, they probably
intend for it to be used.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 8b846799df..c05efd2475 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -340,12 +340,16 @@ def Setup(parser, project_name, config_fname=None):
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read.
+config_fname:   Config filename to read.  An error is raised if it
+does not exist.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
 
+if config_fname and not os.path.exists(config_fname):
+raise Exception(f'provided {config_fname} does not exist')
+
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
-- 
2.38.1



[PATCH v5 4/6] patman: set the default config_fname argument value to None

2022-12-19 Thread Maxim Cournoyer
This better matches Python conventions, allowing to easily test
whether the optional argument is provided.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 2 +-
 tools/patman/settings.py | 9 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 3f092367ec..15fd7603d7 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -118,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(parser, args.project, '')
+settings.Setup(parser, args.project)
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 5efad5ed78..8b846799df 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -333,19 +333,20 @@ def GetItems(config, section):
 return []
 
 
-def Setup(parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
 Args:
-parser: The parser to update
+parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read ('' for default)
+config_fname:   Config filename to read.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
-if config_fname == '':
+
+if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
 if not os.path.exists(config_fname):
-- 
2.38.1



[PATCH v5 3/6] patman: import gitutil module where it is needed

2022-12-19 Thread Maxim Cournoyer
Instead of propagating it from the module entry point (main script).

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 3 +--
 tools/patman/settings.py | 8 +---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 11f19281fb..3f092367ec 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -22,7 +22,6 @@ if __name__ == "__main__":
 from patman import command
 from patman import control
 from patman import func_test
-from patman import gitutil
 from patman import project
 from patman import settings
 from patman import terminal
@@ -119,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(gitutil, parser, args.project, '')
+settings.Setup(parser, args.project, '')
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 7fb9d6d5a0..5efad5ed78 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -11,6 +11,8 @@ import argparse
 import os
 import re
 
+from patman import gitutil
+
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -190,7 +192,7 @@ def ReadGitAliases(fname):
 fd.close()
 
 
-def CreatePatmanConfigFile(gitutil, config_fname):
+def CreatePatmanConfigFile(config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
 Args:
@@ -331,7 +333,7 @@ def GetItems(config, section):
 return []
 
 
-def Setup(gitutil, parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
 
 Args:
@@ -348,7 +350,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 if not os.path.exists(config_fname):
 print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(gitutil, config_fname)
+CreatePatmanConfigFile(config_fname)
 
 config.read(config_fname)
 
-- 
2.38.1



[PATCH v5 2/6] patman: replace deprecated SafeConfigParser with ConfigParser

2022-12-19 Thread Maxim Cournoyer
The SafeConfigParser class has been renamed in Python 3.2 to
ConfigParser, and the old alias has been deprecated since.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index b6884a073e..7fb9d6d5a0 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -30,7 +30,7 @@ _default_settings = {
 }
 
 
-class _ProjectConfigParser(ConfigParser.SafeConfigParser):
+class _ProjectConfigParser(ConfigParser.ConfigParser):
 """ConfigParser that handles projects.
 
 There are two main goals of this class:
@@ -81,14 +81,14 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this
-also loads project defaults.
+In addition to standard ConfigParser initialization, this also
+loads project defaults.
 
 Args:
 project_name: The name of the project.
 """
 self._project_name = project_name
-ConfigParser.SafeConfigParser.__init__(self)
+ConfigParser.ConfigParser.__init__(self)
 
 # Update the project settings in the config based on
 # the _default_settings global.
@@ -100,31 +100,31 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 self.set(project_settings, setting_name, setting_value)
 
 def get(self, section, option, *args, **kwargs):
-"""Extend SafeConfigParser to try project_section before section.
+"""Extend ConfigParser to try project_section before section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 try:
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, "%s_%s" % (self._project_name, section), option,
 *args, **kwargs
 )
 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, section, option, *args, **kwargs
 )
 return val
 
 def items(self, section, *args, **kwargs):
-"""Extend SafeConfigParser to add project_section to section.
+"""Extend ConfigParser to add project_section to section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 project_items = []
 has_project_section = False
@@ -132,7 +132,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get items from the project section
 try:
-project_items = ConfigParser.SafeConfigParser.items(
+project_items = ConfigParser.ConfigParser.items(
 self, "%s_%s" % (self._project_name, section), *args, **kwargs
 )
 has_project_section = True
@@ -141,7 +141,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get top-level items
 try:
-top_items = ConfigParser.SafeConfigParser.items(
+top_items = ConfigParser.ConfigParser.items(
 self, section, *args, **kwargs
 )
 except ConfigParser.NoSectionError:
-- 
2.38.1



[PATCH v5 1/6] patman: fix pep8 warnings in settings module

2022-12-19 Thread Maxim Cournoyer
Remove extraneous imports, variables and comply to PEP 8 maximum line
width, among other PEP 8 changes suggested by Pyflake.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 38 +-
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 903d6fcb0b..b6884a073e 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -4,16 +4,13 @@
 
 try:
 import configparser as ConfigParser
-except:
+except Exception:
 import ConfigParser
 
 import argparse
 import os
 import re
 
-from patman import command
-from patman import tools
-
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -32,6 +29,7 @@ _default_settings = {
 },
 }
 
+
 class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 """ConfigParser that handles projects.
 
@@ -83,8 +81,8 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this also 
loads
-project defaults.
+In addition to standard SafeConfigParser initialization, this
+also loads project defaults.
 
 Args:
 project_name: The name of the project.
@@ -155,6 +153,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 item_dict.update(project_items)
 return {(item, val) for item, val in item_dict.items()}
 
+
 def ReadGitAliases(fname):
 """Read a git alias file. This is in the form used by git:
 
@@ -170,7 +169,7 @@ def ReadGitAliases(fname):
 print("Warning: Cannot find alias file '%s'" % fname)
 return
 
-re_line = re.compile('alias\s+(\S+)\s+(.*)')
+re_line = re.compile(r'alias\s+(\S+)\s+(.*)')
 for line in fd.readlines():
 line = line.strip()
 if not line or line[0] == '#':
@@ -190,6 +189,7 @@ def ReadGitAliases(fname):
 
 fd.close()
 
+
 def CreatePatmanConfigFile(gitutil, config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
@@ -200,12 +200,12 @@ def CreatePatmanConfigFile(gitutil, config_fname):
 None
 """
 name = gitutil.get_default_user_name()
-if name == None:
+if name is None:
 name = input("Enter name: ")
 
 email = gitutil.get_default_user_email()
 
-if email == None:
+if email is None:
 email = input("Enter email: ")
 
 try:
@@ -220,7 +220,8 @@ me: %s <%s>
 [bounces]
 nxp = Zhikang Zhang 
 ''' % (name, email), file=f)
-f.close();
+f.close()
+
 
 def _UpdateDefaults(main_parser, config):
 """Update the given OptionParser defaults based on config.
@@ -242,8 +243,8 @@ def _UpdateDefaults(main_parser, config):
 # Find all the parsers and subparsers
 parsers = [main_parser]
 parsers += [subparser for action in main_parser._actions
-  if isinstance(action, argparse._SubParsersAction)
-  for _, subparser in action.choices.items()]
+if isinstance(action, argparse._SubParsersAction)
+for _, subparser in action.choices.items()]
 
 # Collect the defaults from each parser
 defaults = {}
@@ -270,8 +271,9 @@ def _UpdateDefaults(main_parser, config):
 # Set all the defaults and manually propagate them to subparsers
 main_parser.set_defaults(**defaults)
 for parser, pdefs in zip(parsers, parser_defaults):
-parser.set_defaults(**{ k: v for k, v in defaults.items()
-if k in pdefs })
+parser.set_defaults(**{k: v for k, v in defaults.items()
+   if k in pdefs})
+
 
 def _ReadAliasFile(fname):
 """Read in the U-Boot git alias file if it exists.
@@ -298,6 +300,7 @@ def _ReadAliasFile(fname):
 if bad_line:
 print(bad_line)
 
+
 def _ReadBouncesFile(fname):
 """Read in the bounces file if it exists
 
@@ -311,6 +314,7 @@ def _ReadBouncesFile(fname):
 continue
 bounces.add(line.strip())
 
+
 def GetItems(config, section):
 """Get the items from a section of the config.
 
@@ -323,10 +327,9 @@ def GetItems(config, section):
 """
 try:
 return config.items(section)
-except ConfigParser.NoSectionError as e:
+except ConfigParser.NoSectionError:
 return []
-except:
-raise
+
 
 def Setup(gitutil, parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
@@ -358,6 +361,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 _UpdateDefaults(parser, config)
 
+
 # These are the aliases we understand, indexed by alias. Each member is a list.
 alias = {}
 bounces = set()
-- 
2.38.1



[PATCH v5 0/6] add support for repository-local .patman config file

2022-12-19 Thread Maxim Cournoyer
This series is based on top of series #45.  It adds support for a
.patman config file local to the git repository.  A new test
'test_settings.py' test module is added; it is automatically
discovered and run via pytest, e.g.: 'cd tools/patman && pytest'.

Changes in v5:
- Use try/finally in cleared_command_line_args context manager

Changes in v4:
- Use tools.run to invoke git in test suite

Changes in v3:
- Clear command line arguments in test_git_local_config
- Also test overriding a 'send' command line argument

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

Maxim Cournoyer (6):
  patman: fix pep8 warnings in settings module
  patman: replace deprecated SafeConfigParser with ConfigParser
  patman: import gitutil module where it is needed
  patman: set the default config_fname argument value to None
  patman: fail early in Setup when provided config file does not exist
  patman: additionally honor a local .patman config file

 tools/patman/__main__.py  |   3 +-
 tools/patman/patman.rst   |   8 ++-
 tools/patman/settings.py  | 101 +-
 tools/patman/test_settings.py |  67 ++
 4 files changed, 139 insertions(+), 40 deletions(-)
 create mode 100644 tools/patman/test_settings.py


base-commit: 609e301d41284dbca3e6d03fe038ea0807b3df93
-- 
2.38.1



Re: [PATCH] patman: add '--get-maintainer-script' argument

2022-12-19 Thread Maxim Cournoyer
Hi Simon,

Simon Glass  writes:

> Hi Maxim,
>
> On Mon, 19 Dec 2022 at 15:12, Maxim Cournoyer  
> wrote:
>>
>> This makes it possible to configure a project to use some other
>> location or script than the default scripts/get_maintainer.pl one
>> used in the U-Boot and Linux projects. It can be configured via a
>> .patman configuration file and accepts arguments, as documented.
>>
>> Signed-off-by: Maxim Cournoyer 
>> ---
>>
>>  tools/patman/__main__.py   |  7 +
>>  tools/patman/control.py| 12 ---
>>  tools/patman/func_test.py  |  4 ++-
>>  tools/patman/get_maintainer.py | 57 +-
>>  tools/patman/gitutil.py|  3 +-
>>  tools/patman/patman.rst| 30 +-
>>  tools/patman/series.py |  9 --
>>  7 files changed, 83 insertions(+), 39 deletions(-)
>
> Can you do a little test update for this?

Done in the v2 just sent!

Thanks for the reviewing work!

-- 
Maxim


[PATCH v2] patman: add '--get-maintainer-script' argument

2022-12-19 Thread Maxim Cournoyer
This makes it possible to configure a project to use some other
location or script than the default scripts/get_maintainer.pl one used
in the U-Boot and Linux projects. It can be configured via a .patman
configuration file and accepts arguments, as documented.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

Changes in v2:
- Add functional test
- Fix 'os.path.exist' typo in 'find_get_maintainer'

 tools/patman/__main__.py   |  7 +
 tools/patman/control.py| 12 ---
 tools/patman/func_test.py  | 49 +++--
 tools/patman/get_maintainer.py | 57 +-
 tools/patman/gitutil.py|  3 +-
 tools/patman/patman.rst| 30 +-
 tools/patman/series.py |  9 --
 7 files changed, 127 insertions(+), 40 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 15fd7603d7..05968037ed 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -22,6 +22,7 @@ if __name__ == "__main__":
 from patman import command
 from patman import control
 from patman import func_test
+from patman import gitutil
 from patman import project
 from patman import settings
 from patman import terminal
@@ -65,6 +66,12 @@ send.add_argument('-l', '--limit-cc', dest='limit', 
type=int, default=None,
 send.add_argument('-m', '--no-maintainers', action='store_false',
dest='add_maintainers', default=True,
help="Don't cc the file maintainers automatically")
+send.add_argument(
+'--get-maintainer-script', dest='get_maintainer_script', type=str,
+action='store',
+default=os.path.join(gitutil.get_top_level(), 'scripts',
+ 'get_maintainer.pl') + ' --norolestats',
+help='File name of the get_maintainer.pl (or compatible) script.')
 send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
default=False, help="Do a dry run (create but don't email patches)")
 send.add_argument('-r', '--in-reply-to', type=str, action='store',
diff --git a/tools/patman/control.py b/tools/patman/control.py
index bf426cf7bc..38e98dab84 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -94,8 +94,8 @@ def check_patches(series, patch_files, run_checkpatch, 
verbose, use_tree):
 
 
 def email_patches(col, series, cover_fname, patch_files, process_tags, 
its_a_go,
-  ignore_bad_tags, add_maintainers, limit, dry_run, 
in_reply_to,
-  thread, smtp_server):
+  ignore_bad_tags, add_maintainers, get_maintainer_script, 
limit,
+  dry_run, in_reply_to, thread, smtp_server):
 """Email patches to the recipients
 
 This emails out the patches and cover letter using 'git send-email'. Each
@@ -123,6 +123,8 @@ def email_patches(col, series, cover_fname, patch_files, 
process_tags, its_a_go,
 ignore_bad_tags (bool): True to just print a warning for unknown tags,
 False to halt with an error
 add_maintainers (bool): Run the get_maintainer.pl script for each patch
+get_maintainer_script (str): The script used to retrieve which
+maintainers to cc
 limit (int): Limit on the number of people that can be cc'd on a single
 patch or the cover letter (None if no limit)
 dry_run (bool): Don't actually email the patches, just print out what
@@ -134,7 +136,7 @@ def email_patches(col, series, cover_fname, patch_files, 
process_tags, its_a_go,
 smtp_server (str): SMTP server to use to send patches (None for 
default)
 """
 cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags,
-add_maintainers, limit)
+add_maintainers, limit, get_maintainer_script)
 
 # Email the patches out (giving the user time to check / cancel)
 cmd = ''
@@ -174,8 +176,8 @@ def send(args):
 email_patches(
 col, series, cover_fname, patch_files, args.process_tags,
 its_a_go, args.ignore_bad_tags, args.add_maintainers,
-args.limit, args.dry_run, args.in_reply_to, args.thread,
-args.smtp_server)
+args.get_maintainer_script, args.limit, args.dry_run,
+args.in_reply_to, args.thread, args.smtp_server)
 
 def patchwork_status(branch, count, start, end, dest_branch, force,
  show_comments, url):
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7fa4a00786..c25a47bdeb 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -6,6 +6,7 @@
 
 """Functional tests for checking that patman behaves correctly"""
 
+import contextlib
 import os
 import pathlib
 import re
@@ -29,8 +30,19 @@ from patman.test_util import capture_sys_output
 import pygit2
 from patman import status
 
+PATMAN_DIR = pathlib.Path(__file__).parent
+TEST_DATA_DIR = PATMAN_DIR / 'test/'
 
-TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+@contextlib.conte

Re: [PATCH 2/2] configs: am62x_evm_a53: Enable ethernet

2022-12-19 Thread Dhruva Gole




On 19/12/22 21:45, Sjoerd Simons wrote:

Enable configuration ethernet for u-boot on am62x; Some unrelated things
also got moved around due to running through savedefconfig.

Signed-off-by: Sjoerd Simons 

---

  configs/am62x_evm_a53_defconfig | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index e6ffd166927..30b19428e9e 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2

[...]

  CONFIG_K3_SEC_PROXY=y
@@ -71,7 +73,10 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
  CONFIG_SPI_FLASH_SOFT_RESET=y
  CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
  CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HS512T=y


Removing this might break  S28HS512T Octal SPI NOR Flash. Please let
this stay if it isn't related to the eth configs.


+CONFIG_PHY_TI_DP83867=y
+CONFIG_PHY_FIXED=y
+CONFIG_TI_AM65_CPSW_NUSS=y
+CONFIG_PHY=y
  CONFIG_PINCTRL=y
  CONFIG_SPL_PINCTRL=y
  CONFIG_PINCTRL_SINGLE=y


--
Thanks and Regards,
Dhruva Gole


Re: [PATCH 6/6] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
Hi Simon,

Simon Glass  writes:

> Hi Maxim,
>
> On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  
> wrote:
>>
>> This enables versioning a project specific patman configuration file.
>> It also makes it possible to declare the the project name is,
>> which is not a useful thing to do in $HOME/.patman.  A new test is
>> added, along updated documentation.
>>
>> Signed-off-by: Maxim Cournoyer 
>> ---
>>
>>  tools/patman/patman.rst   |  8 ++-
>>  tools/patman/settings.py  | 24 +++
>>  tools/patman/test_settings.py | 43 +++
>>  3 files changed, 70 insertions(+), 5 deletions(-)
>>  create mode 100644 tools/patman/test_settings.py

[...]

>> diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
>> new file mode 100644
>> index 00..9c14b4aaa3
>> --- /dev/null
>> +++ b/tools/patman/test_settings.py
>> @@ -0,0 +1,43 @@
>> +# SPDX-License-Identifier: GPL-2.0+
>> +#
>> +# Copyright (c) 2022 Maxim Cournoyer 
>> +#
>> +
>> +import argparse
>> +import contextlib
>> +import os
>> +import subprocess
>> +import tempfile
>> +
>> +from patman import settings
>> +
>> +
>> +@contextlib.contextmanager
>> +def empty_git_repository():
>> +with tempfile.TemporaryDirectory() as tmpdir:
>> +os.chdir(tmpdir)
>> +subprocess.check_call(['git', 'init'])
>
> We normally use tools.run()

Adjusted like so:

--8<---cut here---start->8---
modified   tools/patman/test_settings.py
@@ -6,18 +6,18 @@
 import argparse
 import contextlib
 import os
-import subprocess
 import sys
 import tempfile
 
 from patman import settings
+from patman import tools
 
 
 @contextlib.contextmanager
 def empty_git_repository():
 with tempfile.TemporaryDirectory() as tmpdir:
 os.chdir(tmpdir)
-subprocess.check_call(['git', 'init'])
+tools.run('git', 'init', raise_on_error=True)
 yield tmpdir
--8<---cut here---end--->8---

>> +yield tmpdir
>> +
>> +
>> +def test_git_local_config():
>> +with empty_git_repository():
>> +with tempfile.NamedTemporaryFile() as global_config:
>> +global_config.write(b'[settings]\n'
>> +b'project=u-boot\n')
>> +global_config.flush()
>> +parser = argparse.ArgumentParser()
>> +parser.add_argument('-p', '--project', default='unknown')
>> +
>> +# Test "global" config is used.
>> +settings.Setup(parser, 'unknown', global_config.name)
>> +args, _ = parser.parse_known_args()
>> +assert args.project == 'u-boot'
>> +
>> +# Test local config can shadow it.
>> +with open('.patman', 'w', buffering=1) as f:
>
> Can this be created in the temporary dir? At present it looks like it
> might overwrite a file in the current dir?

The 'empty_git_repository' context manager chdir to a temporary
directory upon entry, so anything that runs in its block such as the
open call above will be executed in that temporary directory.  See the
'os.chdir(tmpdir)' line above.

I sent a v4 with the above change.

-- 
Thanks,
Maxim


[PATCH v4 6/6] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the project name, which is not a
useful thing to do in $HOME/.patman.  A new test is added, along
updated documentation.

Signed-off-by: Maxim Cournoyer 
---

Changes in v4:
- Use tools.run to invoke git in test suite

Changes in v3:
- Clear command line arguments in test_git_local_config
- Also test overriding a 'send' command line argument

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

 tools/patman/patman.rst   |  8 -
 tools/patman/settings.py  | 24 ++---
 tools/patman/test_settings.py | 65 +++
 3 files changed, 92 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 395fc0cd75..d7994c888b 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -74,7 +74,7 @@ out where to send patches pretty well.
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
 
-To add your own, create a file ~/.patman like this::
+To add your own, create a file `~/.patman` like this::
 
 # patman alias file
 
@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
 wolfgang: Wolfgang Denk 
 others: Mike Frysinger , Fred Bloggs 

 
+Patman will also look for a `.patman` configuration file at the root
+of the current project git repository, which makes it possible to
+override the `project` settings variable or anything else in a
+project-specific way. The values of this "local" configuration file
+take precedence over those of the "global" one.
+
 Aliases are recursive.
 
 The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c05efd2475..636983e32d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
+# Copyright (c) 2022 Maxim Cournoyer 
 #
 
 try:
@@ -336,6 +337,12 @@ def GetItems(config, section):
 def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
+Unless `config_fname` is specified, a `.patman` config file local
+to the git repository is consulted, followed by the global
+`$HOME/.patman`. If none exists, the later is created. Values
+defined in the local config file take precedence over those
+defined in the global one.
+
 Args:
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
@@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
 
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
+has_config = os.path.exists(config_fname)
 
-if not os.path.exists(config_fname):
-print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(config_fname)
+git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
+has_git_local_config = os.path.exists(git_local_config_fname)
 
-config.read(config_fname)
+# Read the git local config last, so that its values override
+# those of the global config, if any.
+if has_config:
+config.read(config_fname)
+if has_git_local_config:
+config.read(git_local_config_fname)
+
+if not (has_config or has_git_local_config):
+print("No config file found.\nCreating ~/.patman...\n")
+CreatePatmanConfigFile(config_fname)
 
 for name, value in GetItems(config, 'alias'):
 alias[name] = value.split(',')
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
new file mode 100644
index 00..6c87fdc601
--- /dev/null
+++ b/tools/patman/test_settings.py
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2022 Maxim Cournoyer 
+#
+
+import argparse
+import contextlib
+import os
+import sys
+import tempfile
+
+from patman import settings
+from patman import tools
+
+
+@contextlib.contextmanager
+def empty_git_repository():
+with tempfile.TemporaryDirectory() as tmpdir:
+os.chdir(tmpdir)
+tools.run('git', 'init', raise_on_error=True)
+yield tmpdir
+
+
+@contextlib.contextmanager
+def cleared_command_line_args():
+old_value = sys.argv[:]
+sys.argv = [sys.argv[0]]
+yield
+sys.argv = old_value
+
+
+def test_git_local_config():
+# Clearing the command line arguments is required, otherwise
+# arguments passed to the test running such as in 'pytest -k
+# filter' would be processed by _UpdateDefaults and fail.
+with cleared_command_line_args():
+with empty_git_repository():
+with tempfile.NamedTemporaryFile() as global_config:
+g

[PATCH v4 5/6] patman: fail early in Setup when provided config file does not exist

2022-12-19 Thread Maxim Cournoyer
Rationale: if the user explicitly provide this argument, they probably
intend for it to be used.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 8b846799df..c05efd2475 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -340,12 +340,16 @@ def Setup(parser, project_name, config_fname=None):
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read.
+config_fname:   Config filename to read.  An error is raised if it
+does not exist.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
 
+if config_fname and not os.path.exists(config_fname):
+raise Exception(f'provided {config_fname} does not exist')
+
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
-- 
2.38.1



[PATCH v4 4/6] patman: set the default config_fname argument value to None

2022-12-19 Thread Maxim Cournoyer
This better matches Python conventions, allowing to easily test
whether the optional argument is provided.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 2 +-
 tools/patman/settings.py | 9 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 3f092367ec..15fd7603d7 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -118,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(parser, args.project, '')
+settings.Setup(parser, args.project)
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 5efad5ed78..8b846799df 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -333,19 +333,20 @@ def GetItems(config, section):
 return []
 
 
-def Setup(parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
 Args:
-parser: The parser to update
+parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read ('' for default)
+config_fname:   Config filename to read.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
-if config_fname == '':
+
+if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
 if not os.path.exists(config_fname):
-- 
2.38.1



[PATCH v4 3/6] patman: import gitutil module where it is needed

2022-12-19 Thread Maxim Cournoyer
Instead of propagating it from the module entry point (main script).

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 3 +--
 tools/patman/settings.py | 8 +---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 11f19281fb..3f092367ec 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -22,7 +22,6 @@ if __name__ == "__main__":
 from patman import command
 from patman import control
 from patman import func_test
-from patman import gitutil
 from patman import project
 from patman import settings
 from patman import terminal
@@ -119,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(gitutil, parser, args.project, '')
+settings.Setup(parser, args.project, '')
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 7fb9d6d5a0..5efad5ed78 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -11,6 +11,8 @@ import argparse
 import os
 import re
 
+from patman import gitutil
+
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -190,7 +192,7 @@ def ReadGitAliases(fname):
 fd.close()
 
 
-def CreatePatmanConfigFile(gitutil, config_fname):
+def CreatePatmanConfigFile(config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
 Args:
@@ -331,7 +333,7 @@ def GetItems(config, section):
 return []
 
 
-def Setup(gitutil, parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
 
 Args:
@@ -348,7 +350,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 if not os.path.exists(config_fname):
 print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(gitutil, config_fname)
+CreatePatmanConfigFile(config_fname)
 
 config.read(config_fname)
 
-- 
2.38.1



[PATCH v4 2/6] patman: replace deprecated SafeConfigParser with ConfigParser

2022-12-19 Thread Maxim Cournoyer
The SafeConfigParser class has been renamed in Python 3.2 to
ConfigParser, and the old alias has been deprecated since.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index b6884a073e..7fb9d6d5a0 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -30,7 +30,7 @@ _default_settings = {
 }
 
 
-class _ProjectConfigParser(ConfigParser.SafeConfigParser):
+class _ProjectConfigParser(ConfigParser.ConfigParser):
 """ConfigParser that handles projects.
 
 There are two main goals of this class:
@@ -81,14 +81,14 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this
-also loads project defaults.
+In addition to standard ConfigParser initialization, this also
+loads project defaults.
 
 Args:
 project_name: The name of the project.
 """
 self._project_name = project_name
-ConfigParser.SafeConfigParser.__init__(self)
+ConfigParser.ConfigParser.__init__(self)
 
 # Update the project settings in the config based on
 # the _default_settings global.
@@ -100,31 +100,31 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 self.set(project_settings, setting_name, setting_value)
 
 def get(self, section, option, *args, **kwargs):
-"""Extend SafeConfigParser to try project_section before section.
+"""Extend ConfigParser to try project_section before section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 try:
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, "%s_%s" % (self._project_name, section), option,
 *args, **kwargs
 )
 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, section, option, *args, **kwargs
 )
 return val
 
 def items(self, section, *args, **kwargs):
-"""Extend SafeConfigParser to add project_section to section.
+"""Extend ConfigParser to add project_section to section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 project_items = []
 has_project_section = False
@@ -132,7 +132,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get items from the project section
 try:
-project_items = ConfigParser.SafeConfigParser.items(
+project_items = ConfigParser.ConfigParser.items(
 self, "%s_%s" % (self._project_name, section), *args, **kwargs
 )
 has_project_section = True
@@ -141,7 +141,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get top-level items
 try:
-top_items = ConfigParser.SafeConfigParser.items(
+top_items = ConfigParser.ConfigParser.items(
 self, section, *args, **kwargs
 )
 except ConfigParser.NoSectionError:
-- 
2.38.1



[PATCH v4 1/6] patman: fix pep8 warnings in settings module

2022-12-19 Thread Maxim Cournoyer
Remove extraneous imports, variables and comply to PEP 8 maximum line
width, among other PEP 8 changes suggested by Pyflake.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/settings.py | 38 +-
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 903d6fcb0b..b6884a073e 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -4,16 +4,13 @@
 
 try:
 import configparser as ConfigParser
-except:
+except Exception:
 import ConfigParser
 
 import argparse
 import os
 import re
 
-from patman import command
-from patman import tools
-
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -32,6 +29,7 @@ _default_settings = {
 },
 }
 
+
 class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 """ConfigParser that handles projects.
 
@@ -83,8 +81,8 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this also 
loads
-project defaults.
+In addition to standard SafeConfigParser initialization, this
+also loads project defaults.
 
 Args:
 project_name: The name of the project.
@@ -155,6 +153,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 item_dict.update(project_items)
 return {(item, val) for item, val in item_dict.items()}
 
+
 def ReadGitAliases(fname):
 """Read a git alias file. This is in the form used by git:
 
@@ -170,7 +169,7 @@ def ReadGitAliases(fname):
 print("Warning: Cannot find alias file '%s'" % fname)
 return
 
-re_line = re.compile('alias\s+(\S+)\s+(.*)')
+re_line = re.compile(r'alias\s+(\S+)\s+(.*)')
 for line in fd.readlines():
 line = line.strip()
 if not line or line[0] == '#':
@@ -190,6 +189,7 @@ def ReadGitAliases(fname):
 
 fd.close()
 
+
 def CreatePatmanConfigFile(gitutil, config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
@@ -200,12 +200,12 @@ def CreatePatmanConfigFile(gitutil, config_fname):
 None
 """
 name = gitutil.get_default_user_name()
-if name == None:
+if name is None:
 name = input("Enter name: ")
 
 email = gitutil.get_default_user_email()
 
-if email == None:
+if email is None:
 email = input("Enter email: ")
 
 try:
@@ -220,7 +220,8 @@ me: %s <%s>
 [bounces]
 nxp = Zhikang Zhang 
 ''' % (name, email), file=f)
-f.close();
+f.close()
+
 
 def _UpdateDefaults(main_parser, config):
 """Update the given OptionParser defaults based on config.
@@ -242,8 +243,8 @@ def _UpdateDefaults(main_parser, config):
 # Find all the parsers and subparsers
 parsers = [main_parser]
 parsers += [subparser for action in main_parser._actions
-  if isinstance(action, argparse._SubParsersAction)
-  for _, subparser in action.choices.items()]
+if isinstance(action, argparse._SubParsersAction)
+for _, subparser in action.choices.items()]
 
 # Collect the defaults from each parser
 defaults = {}
@@ -270,8 +271,9 @@ def _UpdateDefaults(main_parser, config):
 # Set all the defaults and manually propagate them to subparsers
 main_parser.set_defaults(**defaults)
 for parser, pdefs in zip(parsers, parser_defaults):
-parser.set_defaults(**{ k: v for k, v in defaults.items()
-if k in pdefs })
+parser.set_defaults(**{k: v for k, v in defaults.items()
+   if k in pdefs})
+
 
 def _ReadAliasFile(fname):
 """Read in the U-Boot git alias file if it exists.
@@ -298,6 +300,7 @@ def _ReadAliasFile(fname):
 if bad_line:
 print(bad_line)
 
+
 def _ReadBouncesFile(fname):
 """Read in the bounces file if it exists
 
@@ -311,6 +314,7 @@ def _ReadBouncesFile(fname):
 continue
 bounces.add(line.strip())
 
+
 def GetItems(config, section):
 """Get the items from a section of the config.
 
@@ -323,10 +327,9 @@ def GetItems(config, section):
 """
 try:
 return config.items(section)
-except ConfigParser.NoSectionError as e:
+except ConfigParser.NoSectionError:
 return []
-except:
-raise
+
 
 def Setup(gitutil, parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
@@ -358,6 +361,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 _UpdateDefaults(parser, config)
 
+
 # These are the aliases we understand, indexed by alias. Each member is a list.
 alias = {}
 bounces = set()
-- 
2.38.1



[PATCH v4 0/6] add support for repository-local .patman config file

2022-12-19 Thread Maxim Cournoyer
This series is based on top of series #45.  It adds support for a
.patman config file local to the git repository.  A new test
'test_settings.py' test module is added; it is automatically
discovered and run via pytest, e.g.: 'cd tools/patman && pytest'.

Changes in v4:
- Use tools.run to invoke git in test suite

Changes in v3:
- Clear command line arguments in test_git_local_config
- Also test overriding a 'send' command line argument

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

Maxim Cournoyer (6):
  patman: fix pep8 warnings in settings module
  patman: replace deprecated SafeConfigParser with ConfigParser
  patman: import gitutil module where it is needed
  patman: set the default config_fname argument value to None
  patman: fail early in Setup when provided config file does not exist
  patman: additionally honor a local .patman config file

 tools/patman/__main__.py  |   3 +-
 tools/patman/patman.rst   |   8 ++-
 tools/patman/settings.py  | 101 +-
 tools/patman/test_settings.py |  65 ++
 4 files changed, 137 insertions(+), 40 deletions(-)
 create mode 100644 tools/patman/test_settings.py


base-commit: 609e301d41284dbca3e6d03fe038ea0807b3df93
-- 
2.38.1



Re: [PATCH v4 5/5] rockchip: add support for PX30 Ringneck SoM on Haikou Devkit

2022-12-19 Thread Kever Yang

Hi Quentin,

    For this board:

       aarch64:  w+   ringneck-px30
+  static struct px30_cru * const cru = (void *)CRU_BASE;
+ ^~~
+  static struct px30_grf * const grf = (void *)GRF_BASE;
w+arch/arm/mach-rockchip/px30/px30.c: In function ‘board_debug_uart_init’:
w+arch/arm/mach-rockchip/px30/px30.c:313:33: warning: unused variable 
‘cru’ [-Wunused-variable]
w+arch/arm/mach-rockchip/px30/px30.c:312:33: warning: unused variable 
‘grf’ [-Wunused-variable]
w+arch/arm/mach-rockchip/px30/px30.c:312:33: warning: ‘grf’ defined but 
not used [-Wunused-const-variable=]
w+arch/arm/mach-rockchip/px30/px30.c:313:33: warning: ‘cru’ defined but 
not used [-Wunused-const-variable=]


This will be treat as error on denx ci system.


Thanks,

- Kever

On 2022/11/29 20:19, Quentin Schulz wrote:

From: Quentin Schulz 

The PX30-µQ7 (Ringneck) is a system-on-module featuring the Rockchip
PX30 in a micro Qseven-compatible form-factor.

PX30-µQ7 features:
 * CPU: quad-core Cortex-A35
 * DRAM: 2GB dual-channel
 * eMMC: onboard eMMC
 * SD/MMC
 * TI DP83825I 10/100Mbps PHY
 * USB:
 * USB2.0 dual role port
 * 3x USB2.0 host via onboard USB2.0 hub
 * Display: MIPI-DSI
 * Camera: MIPI-CSI
 * onboard 2.4GHz WiFi + Bluetooth module
 * Companion Controller: on-board additional microcontroller
  (STM32 Cortex-M0 or ATtiny):
 * RTC
 * fan controller
 * CAN (only STM32)

The non-U-Boot DTS files are imported from Linux next-20221114.

Cc: Quentin Schulz 
Signed-off-by: Quentin Schulz 
---
  arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi  |  91 +
  arch/arm/dts/px30-ringneck-haikou.dts  | 232 +
  arch/arm/dts/px30-ringneck.dtsi| 382 +
  arch/arm/mach-rockchip/px30/Kconfig|  25 ++
  board/theobroma-systems/ringneck_px30/Kconfig  |  18 +
  board/theobroma-systems/ringneck_px30/MAINTAINERS  |   9 +
  board/theobroma-systems/ringneck_px30/Makefile |   7 +
  board/theobroma-systems/ringneck_px30/README   |  69 
  .../ringneck_px30/ringneck-px30.c  | 175 ++
  configs/ringneck-px30_defconfig| 128 +++
  doc/board/rockchip/rockchip.rst|   1 +
  include/configs/ringneck_px30.h|  15 +
  12 files changed, 1152 insertions(+)

diff --git a/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi 
b/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi
new file mode 100644
index 00..e8a34c7c1e
--- /dev/null
+++ b/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include "px30-u-boot.dtsi"
+
+/ {
+   config {
+   u-boot,mmc-env-offset = <0x5000>;  /* @  20KB */
+   u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
+   u-boot,boot-led = "module_led";
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   u-boot,spl-boot-order = "same-as-spl", &emmc, &sdmmc;
+   };
+};
+
+&binman {
+   simple-bin {
+   blob {
+   offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) 
* 512)>;
+   };
+   };
+};
+
+&emmc_clk {
+   u-boot,dm-pre-reloc;
+};
+
+&emmc_cmd {
+   u-boot,dm-pre-reloc;
+};
+
+&emmc_bus8 {
+   u-boot,dm-pre-reloc;
+};
+
+&gpio0 {
+   u-boot,dm-pre-reloc;
+};
+
+&gpio1 {
+   u-boot,dm-pre-reloc;
+};
+
+&gpio2 {
+   u-boot,dm-pre-reloc;
+
+   /*
+* The Qseven BIOS_DISABLE signal on the PX30-µQ7 keeps the on-module
+* eMMC powered-down initially (in fact it keeps the reset signal
+* asserted). BIOS_DISABLE_OVERRIDE pin allows to re-enable eMMC after
+* the SPL has been booted from SD Card.
+*/
+   bios-disable-override-hog {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&pinctrl {
+   u-boot,dm-pre-reloc;
+};
+
+&pcfg_pull_none_8ma {
+   u-boot,dm-pre-reloc;
+};
+
+&pcfg_pull_up_8ma {
+   u-boot,dm-pre-reloc;
+};
+
+&sdmmc_bus4 {
+   u-boot,dm-pre-reloc;
+};
+
+&sdmmc_clk {
+   u-boot,dm-pre-reloc;
+};
+
+&sdmmc_cmd {
+   u-boot,dm-pre-reloc;
+};
+
+&sdmmc_det {
+   u-boot,dm-pre-reloc;
+};
+
+&uart0 {
+   clock-frequency = <2400>;
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/px30-ringneck-haikou.dts 
b/arch/arm/dts/px30-ringneck-haikou.dts
new file mode 100644
index 00..08a3ad3e7a
--- /dev/null
+++ b/arch/arm/dts/px30-ringneck-haikou.dts
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2022 Theobroma Systems Design und Consulting GmbH
+ */
+
+/dts-v1/;
+#include "px30-ringneck.dtsi"
+#include 
+#include 
+
+/ {
+   model = "Theobroma Systems PX30-uQ7 SoM on Haikou devkit";
+   compatible = 

Re: Converting to DM SERIAL for Kirkwood boards

2022-12-19 Thread Tony Dinh
Hi Stefan,

On Mon, Dec 19, 2022 at 4:06 PM Tony Dinh  wrote:
>
> Hi Stefan,
>
> On Mon, Dec 19, 2022 at 1:22 PM Tony Dinh  wrote:
> >
> > Hi Stefan,
> >
> > On Sun, Dec 18, 2022 at 11:29 PM Stefan Roese  wrote:
> > >
> > > Hi Tony,
> > >
> > > On 12/19/22 07:17, Stefan Roese wrote:
> > >
> > > 
> > >
> > > >> git checkout 37bb396669b27aa62fe8bc5eeb6bfde92e09c2d3
> > > >> Previous HEAD position was 3b44b3fdf2 arm: mvebu: Add support for
> > > >> programming LD0 and LD1 eFuse
> > > >> HEAD is now at 37bb396669 timer: orion-timer: Only init timer once
> > > >>
> > > >> This is where the Pogo V4 was frozen during boot. Among the Kirkwood
> > > >> boards that I have and used for testing, it is the only one that has
> > > >> CONFIG_BOOTSTAGE=y.
> > > >
> > > > Thanks for testing and git bi-secting.
> > > >
> > > >> Should I create a new post for would like to continue this topic here
> > > >> in this thread?
> > > >
> > > > Let me check, if I can find the root cause and this problem quickly. If
> > > > not, then we should probably disable CONFIG_BOOTSTAGE on the Pogo v4 for
> > > > a short while until we've fixed this issue.
> > >
> > > I fail to spot the problem with this small commit 37bb396669b27a. I can
> > > also not reproduce this on my Armada XP board - it uses SPL though, this
> > > might make a difference.
> > >
> > > Could you perhaps apply this attached debug patch and make sure, that
> > > you have DEBUG_UART enabled in your Pogo v4 config. And boot into the
> > > resulting image.
> >
> > Here is the kwboot log with DEBUG_UART. Note that number 322322 below
> > is part of the log.
> >
> > 322322
> >
> > U-Boot 2023.01-rc3-00057-g9bd3d354a1-dirty (Dec 19 2022 - 01:29:21 -0800)
> > Pogoplug V4
> >
> > SoC:   Kirkwood 88F6281_A1
> > Model: Cloud Engines PogoPlug Series 4
> > DRAM:  128 MiB
> > 322322322Core:  19 devices, 15 uclasses, devicetree: separate
> > NAND:  4
> >
>
> Going a bit further with your debug patch, I've added more prints.
>
>  static void orion_timer_init(void *base, enum input_clock_type type)
>  {
> /* Only init the timer once */
> -   if (early_init_done)
> +   if (early_init_done) {
> +   printch('6'); // test-only
> return;
> +   }
>
> And the boot log below shows somehow the early_init_done is already
> true by the time the orion_timer_init is called. Pretty weird, to say
> the least!
>
> --BEGIN LOG--
> 3262632626
>
> U-Boot 2023.01-rc4-dirty (Dec 19 2022 - 15:35:26 -0800)
> Pogoplug V4
>
> SoC:   Kirkwood 88F6281_A1
> Model: Cloud Engines PogoPlug Series 4
> DRAM:  128 MiB
> 326263262632626Core:  19 devices, 15 uclasses, devicetree: separate
> NAND:  456
> --END LOG--
>

I tried this change in drivers/timer/orion-timer.c and it seems to
work consistently.

-static bool early_init_done __section(".data") = false;
+static bool early_init_done = false;

I still can't see why it would make a difference. Why does the
__section macro not work? does the reallocation timing have anything
to do with this variable being of the wrong value?

Thanks,
Tony

> Thanks,
> Tony
>
> > Thanks,
> > Tony
> >
> > > Thanks,
> > > Stefan


Re: [PATCH] patman: add '--get-maintainer-script' argument

2022-12-19 Thread Simon Glass
Hi Maxim,

On Mon, 19 Dec 2022 at 15:12, Maxim Cournoyer  wrote:
>
> This makes it possible to configure a project to use some other
> location or script than the default scripts/get_maintainer.pl one
> used in the U-Boot and Linux projects. It can be configured via a
> .patman configuration file and accepts arguments, as documented.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/__main__.py   |  7 +
>  tools/patman/control.py| 12 ---
>  tools/patman/func_test.py  |  4 ++-
>  tools/patman/get_maintainer.py | 57 +-
>  tools/patman/gitutil.py|  3 +-
>  tools/patman/patman.rst| 30 +-
>  tools/patman/series.py |  9 --
>  7 files changed, 83 insertions(+), 39 deletions(-)

Can you do a little test update for this?

Reviewed-by: Simon Glass 


Re: [u-boot][master][PATCH 1/3] pico-imx7d: add support for 2GB memory SoMs

2022-12-19 Thread Fabio Estevam
On Mon, Dec 19, 2022 at 9:12 PM Szőke Kálmán Benjamin
 wrote:
>
> Technexion did that renaming, it is better to keep in synchronized.
> https://github.com/TechNexion/u-boot-tn-imx/tree/tn-imx_v2021.04_5.10.72_2.2.0-stable/board/technexion/pico-imx7d

Sorry, that's not a good justification. Just keep the original file name.


Re: Converting to DM SERIAL for Kirkwood boards

2022-12-19 Thread Tony Dinh
Hi Stefan,

On Mon, Dec 19, 2022 at 1:22 PM Tony Dinh  wrote:
>
> Hi Stefan,
>
> On Sun, Dec 18, 2022 at 11:29 PM Stefan Roese  wrote:
> >
> > Hi Tony,
> >
> > On 12/19/22 07:17, Stefan Roese wrote:
> >
> > 
> >
> > >> git checkout 37bb396669b27aa62fe8bc5eeb6bfde92e09c2d3
> > >> Previous HEAD position was 3b44b3fdf2 arm: mvebu: Add support for
> > >> programming LD0 and LD1 eFuse
> > >> HEAD is now at 37bb396669 timer: orion-timer: Only init timer once
> > >>
> > >> This is where the Pogo V4 was frozen during boot. Among the Kirkwood
> > >> boards that I have and used for testing, it is the only one that has
> > >> CONFIG_BOOTSTAGE=y.
> > >
> > > Thanks for testing and git bi-secting.
> > >
> > >> Should I create a new post for would like to continue this topic here
> > >> in this thread?
> > >
> > > Let me check, if I can find the root cause and this problem quickly. If
> > > not, then we should probably disable CONFIG_BOOTSTAGE on the Pogo v4 for
> > > a short while until we've fixed this issue.
> >
> > I fail to spot the problem with this small commit 37bb396669b27a. I can
> > also not reproduce this on my Armada XP board - it uses SPL though, this
> > might make a difference.
> >
> > Could you perhaps apply this attached debug patch and make sure, that
> > you have DEBUG_UART enabled in your Pogo v4 config. And boot into the
> > resulting image.
>
> Here is the kwboot log with DEBUG_UART. Note that number 322322 below
> is part of the log.
>
> 322322
>
> U-Boot 2023.01-rc3-00057-g9bd3d354a1-dirty (Dec 19 2022 - 01:29:21 -0800)
> Pogoplug V4
>
> SoC:   Kirkwood 88F6281_A1
> Model: Cloud Engines PogoPlug Series 4
> DRAM:  128 MiB
> 322322322Core:  19 devices, 15 uclasses, devicetree: separate
> NAND:  4
>

Going a bit further with your debug patch, I've added more prints.

 static void orion_timer_init(void *base, enum input_clock_type type)
 {
/* Only init the timer once */
-   if (early_init_done)
+   if (early_init_done) {
+   printch('6'); // test-only
return;
+   }

And the boot log below shows somehow the early_init_done is already
true by the time the orion_timer_init is called. Pretty weird, to say
the least!

--BEGIN LOG--
3262632626

U-Boot 2023.01-rc4-dirty (Dec 19 2022 - 15:35:26 -0800)
Pogoplug V4

SoC:   Kirkwood 88F6281_A1
Model: Cloud Engines PogoPlug Series 4
DRAM:  128 MiB
326263262632626Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  456
--END LOG--

Thanks,
Tony

> Thanks,
> Tony
>
> > Thanks,
> > Stefan


[PATCH v3 8/8] patman: document default 'send' command

2022-12-19 Thread Maxim Cournoyer
Document that this command is the default and what it's intended for.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 82cef4fc0b..11f19281fb 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -56,7 +56,8 @@ parser.add_argument('-H', '--full-help', action='store_true', 
dest='full_help',
 default=False, help='Display the README file')
 
 subparsers = parser.add_subparsers(dest='cmd')
-send = subparsers.add_parser('send')
+send = subparsers.add_parser(
+'send', help='Format, check and email patches (default command)')
 send.add_argument('-i', '--ignore-errors', action='store_true',
dest='ignore_errors', default=False,
help='Send patches email even if patch errors are found')
-- 
2.38.1



[PATCH v3 7/8] patman: document how to run test suite via pytest

2022-12-19 Thread Maxim Cournoyer
Pytest offers useful features such as selecting tests by means of a
regular expression, or running the pdb debugger upon encountering a
test failure.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/patman.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index ff4c8b3ed2..395fc0cd75 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -684,6 +684,12 @@ Note that since the test suite depends on data files only 
available in
 the git checkout, the `test` command is hidden unless `patman` is
 invoked from the U-Boot git repository.
 
+Alternatively, you can run the test suite via Pytest:
+
+.. code-block:: bash
+
+$ cd tools/patman && pytest
+
 Error handling doesn't always produce friendly error messages - e.g.
 putting an incorrect tag in a commit may provide a confusing message.
 
-- 
2.38.1



[PATCH v3 6/8] patman: hide the 'test' command unless test data is available

2022-12-19 Thread Maxim Cournoyer
Some tests would fail when the test data is not available, so it
doesn't make much sense to expose the action when patman is running
outside of the u-boot git checkout.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

Changes in v3:
- Mention the test command is hidden unless run from the git repo

 tools/patman/__main__.py | 9 ++---
 tools/patman/patman.rst  | 4 
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 5a7756a221..82cef4fc0b 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -21,6 +21,7 @@ if __name__ == "__main__":
 # Our modules
 from patman import command
 from patman import control
+from patman import func_test
 from patman import gitutil
 from patman import project
 from patman import settings
@@ -96,9 +97,11 @@ send.add_argument('--smtp-server', type=str,
 
 send.add_argument('patchfiles', nargs='*')
 
-test_parser = subparsers.add_parser('test', help='Run tests')
-test_parser.add_argument('testname', type=str, default=None, nargs='?',
- help="Specify the test to run")
+# Only add the 'test' action if the test data files are available.
+if os.path.exists(func_test.TEST_DATA_DIR):
+test_parser = subparsers.add_parser('test', help='Run tests')
+test_parser.add_argument('testname', type=str, default=None, nargs='?',
+ help="Specify the test to run")
 
 status = subparsers.add_parser('status',
help='Check status of patches in patchwork')
diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 8c5c9cc2cc..ff4c8b3ed2 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -680,6 +680,10 @@ them:
 
 $ tools/patman/patman test
 
+Note that since the test suite depends on data files only available in
+the git checkout, the `test` command is hidden unless `patman` is
+invoked from the U-Boot git repository.
+
 Error handling doesn't always produce friendly error messages - e.g.
 putting an incorrect tag in a commit may provide a confusing message.
 
-- 
2.38.1



[PATCH v3 4/8] patman: rename main script to __main__.py

2022-12-19 Thread Maxim Cournoyer
This allows running the package as a Python module, like e.g.:

$ python -m patman

It also prevents Pytest from attempting to parse main.py, which
would cause errors.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/{main.py => __main__.py} | 0
 tools/patman/patman   | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/patman/{main.py => __main__.py} (100%)

diff --git a/tools/patman/main.py b/tools/patman/__main__.py
similarity index 100%
rename from tools/patman/main.py
rename to tools/patman/__main__.py
diff --git a/tools/patman/patman b/tools/patman/patman
index 11a5d8e18a..5a427d1942 12
--- a/tools/patman/patman
+++ b/tools/patman/patman
@@ -1 +1 @@
-main.py
\ No newline at end of file
+__main__.py
\ No newline at end of file
-- 
2.38.1



[PATCH v3 5/8] patman: add pytest configuration file

2022-12-19 Thread Maxim Cournoyer
With this change, a user can run the patman test suite using Pytest
the same as when using 'patman test':

$ cd tools/patman && pytest
[...]
44 passed, 8 warnings in 8.87s

$ ./patman test
Ran 44 tests in 8.460s

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/pytest.ini | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tools/patman/pytest.ini

diff --git a/tools/patman/pytest.ini b/tools/patman/pytest.ini
new file mode 100644
index 00..df3eb518d0
--- /dev/null
+++ b/tools/patman/pytest.ini
@@ -0,0 +1,2 @@
+[pytest]
+addopts = --doctest-modules
-- 
2.38.1



[PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'

2022-12-19 Thread Maxim Cournoyer
This resolves 10 out of 11 test failures seen when running './patman
test' from the 'tools/patman' subdirectory. This was caused by the
.checkpatch.conf configuration file at the root of the project not
being picked up. Make the test suite of patman independent from it by
always invoking the checkpatch.pl script with the minimally required
arguments for the test suite to pass.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

Changes in v3:
- Fix typo in commit message

Changes in v2:
- Reword the commit message with a better explanation of the problem
- Add the '--strict' argument to script invocation

 tools/patman/checkpatch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d1b902dd96..012c0d895c 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -211,7 +211,7 @@ def check_patch(fname, verbose=False, show_types=False, 
use_tree=False):
 stdout: Full output of checkpatch
 """
 chk = find_check_patch()
-args = [chk]
+args = [chk, '--u-boot', '--strict']
 if not use_tree:
 args.append('--no-tree')
 if show_types:
-- 
2.38.1



[PATCH v3 2/8] patman: locate test data files via __file__ and pathlib

2022-12-19 Thread Maxim Cournoyer
Previously it would rely on the executing script location, which could
break for example when running the tests via 'pytest'.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/func_test.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7b92bc67be..7fa4a00786 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -7,6 +7,7 @@
 """Functional tests for checking that patman behaves correctly"""
 
 import os
+import pathlib
 import re
 import shutil
 import sys
@@ -28,6 +29,10 @@ from patman.test_util import capture_sys_output
 import pygit2
 from patman import status
 
+
+TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+
 class TestFunctional(unittest.TestCase):
 """Functional tests for checking that patman behaves correctly"""
 leb = (b'Lord Edmund Blackadd\xc3\xabr '.
@@ -57,8 +62,7 @@ class TestFunctional(unittest.TestCase):
 Returns:
 str: Full path to file in the test directory
 """
-return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-'test', fname)
+return TEST_DATA_DIR / fname
 
 @classmethod
 def _get_text(cls, fname):
-- 
2.38.1



[PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module.

2022-12-19 Thread Maxim Cournoyer
This patch fixes all the PEP 8 warnings reported by Pyflake for the
gitutil module.

Reviewed-by: Simon Glass 
Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/gitutil.py | 106 
 1 file changed, 65 insertions(+), 41 deletions(-)

diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index ceaf2ce150..74c6e94494 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -2,21 +2,19 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 #
 
-import re
 import os
-import subprocess
 import sys
 
 from patman import command
 from patman import settings
 from patman import terminal
-from patman import tools
 
 # True to use --no-decorate - we check this in setup()
 use_no_decorate = True
 
+
 def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
-   count=None):
+count=None):
 """Create a command to perform a 'git log'
 
 Args:
@@ -49,6 +47,7 @@ def log_cmd(commit_range, git_dir=None, oneline=False, 
reverse=False,
 cmd.append('--')
 return cmd
 
+
 def count_commits_to_branch(branch):
 """Returns number of commits between HEAD and the tracking branch.
 
@@ -68,13 +67,14 @@ def count_commits_to_branch(branch):
 rev_range = '@{upstream}..'
 pipe = [log_cmd(rev_range, oneline=True)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- oneline=True, raise_on_error=False)
+  oneline=True, raise_on_error=False)
 if result.return_code:
 raise ValueError('Failed to determine upstream: %s' %
  result.stderr.strip())
 patch_count = len(result.stdout.splitlines())
 return patch_count
 
+
 def name_revision(commit_hash):
 """Gets the revision name for a commit
 
@@ -91,6 +91,7 @@ def name_revision(commit_hash):
 name = stdout.split(' ')[1].strip()
 return name
 
+
 def guess_upstream(git_dir, branch):
 """Tries to guess the upstream for a branch
 
@@ -109,7 +110,7 @@ def guess_upstream(git_dir, branch):
 """
 pipe = [log_cmd(branch, git_dir=git_dir, oneline=True, count=100)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+  raise_on_error=False)
 if result.return_code:
 return None, "Branch '%s' not found" % branch
 for line in result.stdout.splitlines()[1:]:
@@ -121,6 +122,7 @@ def guess_upstream(git_dir, branch):
 return name, "Guessing upstream as '%s'" % name
 return None, "Cannot find a suitable upstream for branch '%s'" % branch
 
+
 def get_upstream(git_dir, branch):
 """Returns the name of the upstream for a branch
 
@@ -135,10 +137,10 @@ def get_upstream(git_dir, branch):
 """
 try:
 remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
-   'branch.%s.remote' % branch)
+ 'branch.%s.remote' % branch)
 merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
-  'branch.%s.merge' % branch)
-except:
+'branch.%s.merge' % branch)
+except Exception:
 upstream, msg = guess_upstream(git_dir, branch)
 return upstream, msg
 
@@ -149,7 +151,8 @@ def get_upstream(git_dir, branch):
 return '%s/%s' % (remote, leaf), None
 else:
 raise ValueError("Cannot determine upstream branch for branch "
-"'%s' remote='%s', merge='%s'" % (branch, remote, merge))
+ "'%s' remote='%s', merge='%s'"
+ % (branch, remote, merge))
 
 
 def get_range_in_branch(git_dir, branch, include_upstream=False):
@@ -168,6 +171,7 @@ def get_range_in_branch(git_dir, branch, 
include_upstream=False):
 rstr = '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
 return rstr, msg
 
+
 def count_commits_in_range(git_dir, range_expr):
 """Returns the number of commits in the given range.
 
@@ -180,12 +184,13 @@ def count_commits_in_range(git_dir, range_expr):
 """
 pipe = [log_cmd(range_expr, git_dir=git_dir, oneline=True)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+  raise_on_error=False)
 if result.return_code:
 return None, "Range '%s' not found or is invalid" % range_expr
 patch_count = len(result.stdout.splitlines())
 return patch_count, None
 
+
 def count_commits_in_branch(git_dir, branch, include_upstream=False):
 """Returns the number of commits in the given branch.
 
@@ -201,6 +206,7 @@ def count_commits_in_branch(git_dir, branch, 
include_upstream=False):
 return None, msg
 return count_commits_in_range(git_dir, range_expr)
 
+
 def count_commit

[PATCH] patman: add '--get-maintainer-script' argument

2022-12-19 Thread Maxim Cournoyer
This makes it possible to configure a project to use some other
location or script than the default scripts/get_maintainer.pl one
used in the U-Boot and Linux projects. It can be configured via a
.patman configuration file and accepts arguments, as documented.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/__main__.py   |  7 +
 tools/patman/control.py| 12 ---
 tools/patman/func_test.py  |  4 ++-
 tools/patman/get_maintainer.py | 57 +-
 tools/patman/gitutil.py|  3 +-
 tools/patman/patman.rst| 30 +-
 tools/patman/series.py |  9 --
 7 files changed, 83 insertions(+), 39 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 15fd7603d7..05968037ed 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -22,6 +22,7 @@ if __name__ == "__main__":
 from patman import command
 from patman import control
 from patman import func_test
+from patman import gitutil
 from patman import project
 from patman import settings
 from patman import terminal
@@ -65,6 +66,12 @@ send.add_argument('-l', '--limit-cc', dest='limit', 
type=int, default=None,
 send.add_argument('-m', '--no-maintainers', action='store_false',
dest='add_maintainers', default=True,
help="Don't cc the file maintainers automatically")
+send.add_argument(
+'--get-maintainer-script', dest='get_maintainer_script', type=str,
+action='store',
+default=os.path.join(gitutil.get_top_level(), 'scripts',
+ 'get_maintainer.pl') + ' --norolestats',
+help='File name of the get_maintainer.pl (or compatible) script.')
 send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
default=False, help="Do a dry run (create but don't email patches)")
 send.add_argument('-r', '--in-reply-to', type=str, action='store',
diff --git a/tools/patman/control.py b/tools/patman/control.py
index bf426cf7bc..38e98dab84 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -94,8 +94,8 @@ def check_patches(series, patch_files, run_checkpatch, 
verbose, use_tree):
 
 
 def email_patches(col, series, cover_fname, patch_files, process_tags, 
its_a_go,
-  ignore_bad_tags, add_maintainers, limit, dry_run, 
in_reply_to,
-  thread, smtp_server):
+  ignore_bad_tags, add_maintainers, get_maintainer_script, 
limit,
+  dry_run, in_reply_to, thread, smtp_server):
 """Email patches to the recipients
 
 This emails out the patches and cover letter using 'git send-email'. Each
@@ -123,6 +123,8 @@ def email_patches(col, series, cover_fname, patch_files, 
process_tags, its_a_go,
 ignore_bad_tags (bool): True to just print a warning for unknown tags,
 False to halt with an error
 add_maintainers (bool): Run the get_maintainer.pl script for each patch
+get_maintainer_script (str): The script used to retrieve which
+maintainers to cc
 limit (int): Limit on the number of people that can be cc'd on a single
 patch or the cover letter (None if no limit)
 dry_run (bool): Don't actually email the patches, just print out what
@@ -134,7 +136,7 @@ def email_patches(col, series, cover_fname, patch_files, 
process_tags, its_a_go,
 smtp_server (str): SMTP server to use to send patches (None for 
default)
 """
 cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags,
-add_maintainers, limit)
+add_maintainers, limit, get_maintainer_script)
 
 # Email the patches out (giving the user time to check / cancel)
 cmd = ''
@@ -174,8 +176,8 @@ def send(args):
 email_patches(
 col, series, cover_fname, patch_files, args.process_tags,
 its_a_go, args.ignore_bad_tags, args.add_maintainers,
-args.limit, args.dry_run, args.in_reply_to, args.thread,
-args.smtp_server)
+args.get_maintainer_script, args.limit, args.dry_run,
+args.in_reply_to, args.thread, args.smtp_server)
 
 def patchwork_status(branch, count, start, end, dest_branch, force,
  show_comments, url):
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7fa4a00786..fa5352c349 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -204,6 +204,8 @@ class TestFunctional(unittest.TestCase):
 text = self._get_text('test01.txt')
 series = patchstream.get_metadata_for_test(text)
 cover_fname, args = self._create_patches_for_test(series)
+get_maintainer_script = str(pathlib.Path(__file__).parent.parent.parent
+/ 'get_maintainer.pl') + ' --norolestats'
 with capture_sys_output() as out:
 patchstream.fix_patches(series, args)
 if cover_fname and series.get('cover'):
@@ -211,7 +213,7 @@ c

[PATCH u-boot] powerpc/mpc85xx: Disable AltiVec and VSX instructions

2022-12-19 Thread Pali Rohár
All vector instructions on powerpc mpc85xx must not be used because U-Boot
does not enable them. Usage cause random crashes. SPE vector instructions
are already disabled by compiler flags, so disable also AltiVec and VSX
vector instructions.

Linux kernel disables AltiVec and VSX instructions too.

Signed-off-by: Pali Rohár 
---
 arch/powerpc/cpu/mpc85xx/config.mk | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/cpu/mpc85xx/config.mk 
b/arch/powerpc/cpu/mpc85xx/config.mk
index 482bb90cb120..71a98f05c902 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -13,6 +13,10 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 PLATFORM_CPPFLAGS += $(call cc-option,-mno-spe) \
 $(call cc-option,-mspe=no)
 
+# No AltiVec or VSX instructions when building u-boot
+PLATFORM_CPPFLAGS += $(call cc-option,-mno-altivec)
+PLATFORM_CPPFLAGS += $(call cc-option,-mno-vsx)
+
 ifdef CONFIG_E6500
 PLATFORM_CPPFLAGS += -mcpu=e6500
 else ifdef CONFIG_E5500
-- 
2.20.1



[PATCH v2] powerpc/mpc85xx: Pass correct cpu compiler flags

2022-12-19 Thread Pali Rohár
When gcc's default cpu (selected by --with-cpu= during gcc's configure
phase) does not match target U-Boot board cpu then U-Boot binary does not
have to be compiled correctly. Lot of distributions sets gcc's default cpu
to generic powerpc variant which works fine.

U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
e500 specific instructions when processing assembler source files (.S).

This affects also assembly files generated by gcc from C source files. And
because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
the generated assembly file, it basically overwrites -me500 flag by which
was GNU AS invoked (from U-boot build system).

It started to be an issue since binutils 2.38 which does not keep enabled
extra functional units selected by previous cpu. Hence issuing directive
'.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
(specifying at command line) disables usage of e500 specific instructions.

And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
assembler errors:

{standard input}: Assembler messages:
{standard input}:127: Error: unrecognized opcode: `tlbre'
{standard input}:418: Error: unrecognized opcode: `tlbre'
{standard input}:821: Error: unrecognized opcode: `msync'
{standard input}:821: Error: unrecognized opcode: `tlbwe'
{standard input}:884: Error: unrecognized opcode: `tlbsx'

This issue was already hit by Debian people and is reported in bug tracker:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490

Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
does not put '.machine ppc' directive into assembly anymore.

Also if gcc is invoked with -mcpu=8540 then it pass -me500 flag to GNU AS.
So it is unnecessary to manually specify -Wa,-me500 flag because it is
implicitly added.

Fix this issue properly by specifying correct -mcpu compiler flag for all
supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
gcc has unintuitive -mcpu=8540 and -mcpu=8548 flag names, for other cores
-mcpu matches core name.

The only difference between gcc's -mcpu=8540 and -mcpu=8548 flags is
support for double precision floating point SPE instructions. As U-Boot
does not use floating point, it is fine to use -mcpu=8540 for both e500v1
and e500v2 cores. Moreover gcc 9 completely removed e500 floating point
support, so since gcc 9 -mcpu=8548 is just alias to -mcpu=8540.

Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
as last fallback value when no other mpc85xx cpu matches.

Signed-off-by: Pali Rohár 

---
Changes in v2:
* Fix commit message and fact that -mcpu=8548 flag works also with last gcc
---
 arch/powerpc/cpu/mpc85xx/config.mk | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc85xx/config.mk 
b/arch/powerpc/cpu/mpc85xx/config.mk
index 7a1d81cf2d76..b6b5d2053aea 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -3,7 +3,7 @@
 # (C) Copyright 2002,2003 Motorola Inc.
 # Xianghua Xiao, x.x...@motorola.com
 
-PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
+PLATFORM_CPPFLAGS += -msoft-float -mno-string
 PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
@@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
 PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
   $(call cc-option,-mno-spe)
+
+ifdef CONFIG_E6500
+PLATFORM_CPPFLAGS += -mcpu=e6500
+else ifdef CONFIG_E5500
+PLATFORM_CPPFLAGS += -mcpu=e5500
+else ifdef CONFIG_E500MC
+PLATFORM_CPPFLAGS += -mcpu=e500mc
+else
+PLATFORM_CPPFLAGS += -mcpu=8540
+endif
-- 
2.20.1



Re: Converting to DM SERIAL for Kirkwood boards

2022-12-19 Thread Tony Dinh
Hi Stefan,

On Sun, Dec 18, 2022 at 11:29 PM Stefan Roese  wrote:
>
> Hi Tony,
>
> On 12/19/22 07:17, Stefan Roese wrote:
>
> 
>
> >> git checkout 37bb396669b27aa62fe8bc5eeb6bfde92e09c2d3
> >> Previous HEAD position was 3b44b3fdf2 arm: mvebu: Add support for
> >> programming LD0 and LD1 eFuse
> >> HEAD is now at 37bb396669 timer: orion-timer: Only init timer once
> >>
> >> This is where the Pogo V4 was frozen during boot. Among the Kirkwood
> >> boards that I have and used for testing, it is the only one that has
> >> CONFIG_BOOTSTAGE=y.
> >
> > Thanks for testing and git bi-secting.
> >
> >> Should I create a new post for would like to continue this topic here
> >> in this thread?
> >
> > Let me check, if I can find the root cause and this problem quickly. If
> > not, then we should probably disable CONFIG_BOOTSTAGE on the Pogo v4 for
> > a short while until we've fixed this issue.
>
> I fail to spot the problem with this small commit 37bb396669b27a. I can
> also not reproduce this on my Armada XP board - it uses SPL though, this
> might make a difference.
>
> Could you perhaps apply this attached debug patch and make sure, that
> you have DEBUG_UART enabled in your Pogo v4 config. And boot into the
> resulting image.

Here is the kwboot log with DEBUG_UART. Note that number 322322 below
is part of the log.

322322

U-Boot 2023.01-rc3-00057-g9bd3d354a1-dirty (Dec 19 2022 - 01:29:21 -0800)
Pogoplug V4

SoC:   Kirkwood 88F6281_A1
Model: Cloud Engines PogoPlug Series 4
DRAM:  128 MiB
322322322Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  4


Thanks,
Tony

> Thanks,
> Stefan


Re: [PATCH v2 2/2] eficonfig: avoid SetVariable between GetNextVariableName calls

2022-12-19 Thread Heinrich Schuchardt

On 12/19/22 02:33, Masahisa Kojima wrote:

The current code calls efi_set_variable_int() to delete the
invalid boot option between calls to efi_get_next_variable_name_int(),
it may produce unpredictable results.

This commit moves removal of the invalid boot option outside
of the efi_get_next_variable_name_int() calls.
EFI_NOT_FOUND returned from efi_get_next_variable_name_int()
indicates we retrieved all EFI variables, it should be treated
as EFI_SUCEESS.

To address the checkpatch warning of too many leading tabs,
combine two if statement into one.

Signed-off-by: Masahisa Kojima


Reviewed-by: Heinrich Schuchardt 



Re: [PATCH v2 1/2] eficonfig: carve out efi_get_next_variable_name_int calls

2022-12-19 Thread Heinrich Schuchardt

On 12/19/22 02:33, Masahisa Kojima wrote:

To retrieve the EFI variable name by efi_get_next_variable_name_int(),
the sequence of alloc -> efi_get_next_variable_name_int ->
realloc -> efi_get_next_variable_name_int is required.
In current code, this sequence repeatedly appears in
the several functions. It should be curved out a common function.

This commit also fixes the missing free() of var_name16
in eficonfig_delete_invalid_boot_option().

Signed-off-by: Masahisa Kojima 


Reviewed-by: Heinrich Schuchardt 


[PATCH 1/2] doc: ti: reorganize existing ti docs

2022-12-19 Thread Bryan Brattlof
Texas Instruments produces quite a lot of SoCs based upon a common
architecture 'generation'. (eg: OMAP, K3) TI's existing documentation
layout makes noticing this generation jump rather difficult.

To make navigation easier, split the existing documentation into
individual SoC families so we may begin grouping them according to their
generational (eg: OMAP, K3) families.

Signed-off-by: Bryan Brattlof 
---
 doc/board/ti/am335x_evm.rst | 5 -
 doc/board/ti/am62x_sk.rst   | 4 ++--
 doc/board/ti/j721e_evm.rst  | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/doc/board/ti/am335x_evm.rst b/doc/board/ti/am335x_evm.rst
index a90f32da7aea5..7db9604ce05c9 100644
--- a/doc/board/ti/am335x_evm.rst
+++ b/doc/board/ti/am335x_evm.rst
@@ -1,8 +1,11 @@
 .. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 .. sectionauthor:: Tom Rini 
 
+AM335x Generation
+=
+
 Summary
-===
+---
 
 This document covers various features of the `am335x_evm` default
 configuration, some of the related defconfigs, and how to enable hardware
diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst
index 4e68c2018a50b..b1b7d99befb92 100644
--- a/doc/board/ti/am62x_sk.rst
+++ b/doc/board/ti/am62x_sk.rst
@@ -1,8 +1,8 @@
 .. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 .. sectionauthor:: Vignesh Raghavendra 
 
-Texas Instruments AM62 Platforms
-
+AM62 Platforms
+===
 
 Introduction:
 -
diff --git a/doc/board/ti/j721e_evm.rst b/doc/board/ti/j721e_evm.rst
index ad70f15b7a418..e898601c41ea4 100644
--- a/doc/board/ti/j721e_evm.rst
+++ b/doc/board/ti/j721e_evm.rst
@@ -1,8 +1,8 @@
 .. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 .. sectionauthor:: Lokesh Vutla 
 
-Texas Instruments K3 Platforms
-==
+J721E Platforms
+===
 
 Introduction:
 -
-- 
2.39.0



[PATCH 2/2] doc: ti: add the K3 generation page

2022-12-19 Thread Bryan Brattlof
Texas Instrument's entire K3 generation of SoCs use much of the same
frameworks and boot flow, especially at the uboot level. Though there
are small differences introduced as each new K3 based SoC is developed
and as the K3 generation matures that will also need to be documented.

Rather than copying the same documentation, with the small differences
applicable to that specific SoC to a new page, introduce a new K3
page that can describe the general boot flow and design decisions for
the entire K3 generation of chips, leaving the specifics for that
particular SoC to a unique sub-page below this one.

Signed-off-by: Bryan Brattlof 
---
 doc/board/ti/index.rst |   5 +-
 doc/board/ti/k3.rst| 276 +
 2 files changed, 278 insertions(+), 3 deletions(-)
 create mode 100644 doc/board/ti/k3.rst

diff --git a/doc/board/ti/index.rst b/doc/board/ti/index.rst
index 250d9242e82bb..89d537d195196 100644
--- a/doc/board/ti/index.rst
+++ b/doc/board/ti/index.rst
@@ -1,11 +1,10 @@
 .. SPDX-License-Identifier: GPL-2.0+
 
 Texas Instruments
-=
+#
 
 .. toctree::
:maxdepth: 2
 
am335x_evm
-   j721e_evm
-   am62x_sk
+   k3
diff --git a/doc/board/ti/k3.rst b/doc/board/ti/k3.rst
new file mode 100644
index 0..941dde931
--- /dev/null
+++ b/doc/board/ti/k3.rst
@@ -0,0 +1,276 @@
+.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+.. sectionauthor:: Bryan Brattlof 
+
+K3 Generation
+=
+
+Summary
+---
+
+Texas Instrument's K3 family of SoCs utilize a heterogeneous multicore
+and highly integrated device architecture targeted to maximize
+performance and power efficiency for a wide range of industrial,
+automotive and other broad market segments.
+
+Typically the processing cores and the peripherals for these devices are
+partitioned into three functional domains to provide ultra-low power
+modes as well as accommodating application and industrial safety systems
+on the same SoC.  These functional domains are typically called the:
+
+* Wakeup (WKUP) domain
+* Micro-controller (MCU) domain
+* Main domain
+
+For a more detailed view of what peripherals are attached to each
+domain, consult the device specific documentation.
+
+K3 Based SoCs
+-
+
+.. toctree::
+   :maxdepth: 1
+
+   j721e_evm
+   am62x_sk
+
+Boot Flow Overview
+--
+
+For all K3 SoCs the first core started will be inside the Security
+Management Subsystem (SMS) which will secure the device and start a core
+in the wakeup domain to run the ROM code. ROM will then initialize the
+boot media needed to load the binaries packaged inside `tiboot3.bin`,
+including a 32bit U-Boot SPL, (called the wakup SPL) that ROM will jump
+to after it has finished loading everything into internal SRAM.
+
+.. code-block:: text
+
+   |  WKUP Domain
+ROM -> WKUP SPL ->
+
+The wakeup SPL, running on a wakeup domain core, will initialize DDR and
+any peripherals needed load the larger binaries inside the `tispl.bin`
+into DDR.  Once loaded the wakeup SPL will start one of the 'big'
+application cores inside the main domain to initialize the main domain,
+starting with ARM Trusted Firmware (ATF), before moving on to start
+OPTEE and the main domain's U-Boot SPL.
+
+.. code-block:: text
+
+   |  WKUP Domain   | Main Domain ->
+ROM -> WKUP SPL -> ATF -> OPTEE -> Main SPL
+
+The main domain's SPL, running on a 64bit application core, has
+virtually unlimited space (billions of bytes now that DDR is working) to
+initialize even more peripherals needed to load in the `u-boot.img`
+which loads more firmware into the micro-controller & wakeup domains and
+finally prepare the main domain to run Linux.
+
+.. code-block:: text
+
+   |  WKUP Domain   | Main Domain ->
+ROM -> WKUP SPL -> ATF -> OPTEE -> Main SPL -> UBoot -> Linux
+
+This is the typical boot flow for all K3 based SoCs, however this flow
+offers quite a lot in the terms of flexibility, especially on High
+Security (HS) SoCs.
+
+Boot Flow Variations
+
+
+All K3 SoCs will generally use the above boot flow with two main
+differences depending on the capabilities of the boot ROM and the number
+of cores inside the device. These differences split the bootflow into
+essentially 4 unique but very similar flows:
+
+* Split binary with a combined firmware: (eg: AM65)
+* Combined binary with a combined firmware: (eg: AM64)
+* Split binary with a split firmware: (eg: J721E)
+* Combined binary with a split firmware: (eg: AM62)
+
+For devices that utilize the split binary approach, ROM is not capable
+of loading the firmware into the SoC requiring the wakeup domain's
+U-Boot SPL to load the firmware.
+
+Devices with a split firmware will have two firmwares loaded into the
+device at different times during the bootup process. TI's Foundational
+Security (TIFS), needed to operate the Security Management Subsystem,
+will either be loaded by ROM or the WKUP U-Boot SPL, then once the
+wakeup

[PATCH 0/2] TI's K3 documentation updates

2022-12-19 Thread Bryan Brattlof
Hello everyone!

Before the holidays get started, I wanted to improve the documentation
for TI's K3 generation of SoCs. Specifically I wanted to collect all the
similarities into one file called 'K3' in doc/board/ti/ and leave the
details to each SoC specific sub-page.

My goal is to eliminate the boilerplate needed to document each new K3
SoC and instead allow the sub-pages to highlight the differences that
could trip others as they begin to develop on their new K3 device.

Thanks for reviewing!
~Bryan

Bryan Brattlof (2):
  doc: ti: reorganize existing ti docs
  doc: ti: add the K3 generation page

 doc/board/ti/am335x_evm.rst |   5 +-
 doc/board/ti/am62x_sk.rst   |   4 +-
 doc/board/ti/index.rst  |   5 +-
 doc/board/ti/j721e_evm.rst  |   4 +-
 doc/board/ti/k3.rst | 276 
 5 files changed, 286 insertions(+), 8 deletions(-)
 create mode 100644 doc/board/ti/k3.rst


base-commit: 2243922edca9f56a9d5519b9d6e36f5d7a18434d
-- 
2.39.0



Re: [PATCH v3] console: usb: kbd: Limit poll frequency to improve performance

2022-12-19 Thread Filip Žaludek




Hi Simon,


On 12/19/22 20:20, Simon Glass wrote:

Hi Filip,

On Mon, 19 Dec 2022 at 02:29, Filip Žaludek  wrote:




Hi Simon,

   is your testing framework connected to HDMI? Only notable discrepancy
from generic config is enabled 'efidebug' command.


Tested more (cycled 'U-Boot>' and 'reset'), both RPi3B and RPi3B+..
USB Keyboard failure rates:
connected console02/10
connected hdmi   06/10
connected console + hdmi 07/10
** USB Keyboard always detected by 'usb info', just does not respond.

USB Keyboard failure rates, reverted 96991e652f541323a03c5b7e075d54a117091618:
connected console + hdmi 00/10


Yes this one does have HDMI. Are you wanting me to run multiple runs?
With or without the display?



 Yes please! With HDMI as there is better chance you will hit issue I am 
experiencing,
to confirm 96991e652f541323a03c5b7e075d54a117091618 is inferior for RPi3.
You should see usb_kbd detected, but no input possible.


Thanks,
Filip







Regards,
Simon






   Just to note subsequent Grub2 menu redraw to my 180x50 console terminal
is about 5x faster when hdmi disconnected.



Thanks for testing!
Regards,
Filip



FW: rpi-firmware-20220830-1.0.1.el8.noarch
Revision: 9bd3d354a1a0712ac27c717df9ad60566b0406ee







On 12/17/22 23:24, Simon Glass wrote:

Hi Filip,

On Sat, 17 Dec 2022 at 05:50, Filip Žaludek  wrote:




Hello,
change seems to be unfriendly to RPi3B+, it allows to enter 'U-Boot>' shell 
but usb keyboard
does not respond. Keyboard is detected by 'usb info' in v2023.01-rc3, not in 
v2022.10.
When reverted, usb keyboard works as expected.

Anybody sitting front of RPi3B+ care to confirm?


Regards,
Filip





Patch:
https://urldefense.com/v3/__https://github.com/u-boot/u-boot/commit/96991e652f541323a03c5b7e075d54a117091618__;!!ACWV5N9M2RV99hQ!MunypRlNhelLw1nrbbLFCTeZK2pCAlIH_WPhgvmgFhfy3wJnPA5titNwl3o2fkc-mCqWAgJxjjc1sSD1$


Debug:
USB KBD: found interrupt EP: 0x81
USB KBD: set boot protocol
dwc2_submit_control_msg: dev='usb@7e98', udev=3af4be00,
udev->dev='usb_kbd', portnr=3
USB KBD: set idle interval...
dwc2_submit_control_msg: dev='usb@7e98', udev=3af4be00,
udev->dev='usb_kbd', portnr=3
USB KBD: enable interrupt pipe...
usb_kbd usb_kbd: Timeout poll on interrupt endpoint


Tested:
SW: v2022.10 & v2023.01-rc3 compiled from sources as 'rpiarm64'
HW: USB 1.1 and 2.0 keyboards, RPi3B+
JeOS:
https://urldefense.com/v3/__http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-raspberrypi.aarch64-2022.10.11-Snapshot20221112.raw.xz__;!!ACWV5N9M2RV99hQ!MunypRlNhelLw1nrbbLFCTeZK2pCAlIH_WPhgvmgFhfy3wJnPA5titNwl3o2fkc-mCqWAgJxjkilUmrv$
(u-boot-rpiarm64-2022.10-1.1.aarch64)




This seems to work on current master:

do-try-int.sh rpi3
Revision 9bd3d354a1a0712ac27c717df9ad60566b0406ee, board rpi3

Checking revision 9bd3d354a1a0712ac27c717df9ad60566b0406ee
/vid/software/devel/ubtest
tbot starting ...
├─Parameters:
│ rev= '9bd3d354a1a0712ac27c717df9ad60566b0406ee'
│ clean  = False
├─Calling uboot_build_and_flash ...
│   ├─Calling uboot_build ...
│   │   ├─Calling uboot_checkout ...
│   │   │   ├─Builder: rpi3
│   │   │   └─Done. (0.181s)
│   │   ├─Configuring build ...
│   │   ├─Calling uboot_make ...
│   │   │   └─Done. (1.504s)
│   │   └─Done. (2.178s)
│   ├─Calling uboot_flash ...
│   │   ├─Calling copy ...
│   │   │   └─Done. (0.004s)
│   │   └─Done. (1.119s)
│   └─Done. (3.663s)
├─
└─SUCCESS (3.799s)
tbot starting ...
├─Calling interactive_board ...
│   ├─POWERON (rpi3)
│   ├─Entering interactive shell (CTRL+D to exit) ...


U-Boot 2023.01-rc3-00057-g9bd3d354a1a (Dec 17 2022 - 15:23:14 -0700)

DRAM:  992 MiB
RPI 3 Model B (0xa22082)
Core:  66 devices, 14 uclasses, devicetree: embed
MMC:   mmc@7e202000: 0, mmc@7e30: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1...
In:serial
Out:   vidconsole
Err:   vidconsole
Net:   No ethernet found.
starting USB...
Bus usb@7e98: USB DWC2
scanning bus usb@7e98 for devices... usb_kbd usb_kbd: Timeout poll
on interrupt endpoint
Failed to get keyboard state from device 0c40:8000
6 USB Device(s) found
 scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0
U-Boot> usb info
1: Hub,  USB Revision 1.10
   -  U-Boot Root Hub
   - Class: Hub
   - PacketSize: 8  Configurations: 1
   - Vendor: 0x  Product 0x Version 0.0
 Configuration: 1
 - Interfaces: 1 Self Powered 0mA
   Interface: 0
   - Alternate Setting 0, Endpoints: 1
   - Class Hub
   - Endpoint 1 In Interrupt MaxPacket 2 Interval 255ms

2: Hub,  USB Revision 2.0
   - Class: Hub
   - PacketSize: 64  Configurations: 1
   - Vendor: 0x0424  Product 0x9514 Version 2.0
 Configuration: 1
 - Interfaces: 1 Self Powered Remote Wakeup 2mA
   Interface: 0
   - Alternate Setting 0, Endpoints: 1
   - Class Hub
   - Endpoint 1 In Int

Re: [PATCH] Prevent buffer overflow on USB control endpoint

2022-12-19 Thread Marek Vasut

On 12/19/22 19:52, Szymon Heidrich wrote:

On 16/12/2022 04:22, Marek Vasut wrote:

On 11/20/22 18:42, Szymon Heidrich wrote:

On 20/11/2022 18:25, Marek Vasut wrote:

On 11/20/22 16:29, Szymon Heidrich wrote:

On 20/11/2022 15:43, Marek Vasut wrote:

On 11/17/22 12:50, Fabio Estevam wrote:

[Adding Lukasz and Marek]

On Thu, Nov 17, 2022 at 6:50 AM Szymon Heidrich
 wrote:


Assure that the control endpoint buffer of size USB_BUFSIZ (4096)
can not be overflown during handling of USB control transfer
requests with wLength greater than USB_BUFSIZ.

Signed-off-by: Szymon Heidrich 
---
     drivers/usb/gadget/composite.c | 11 +++
     1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 2a309e624e..cb89f6dca9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1019,6 +1019,17 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
    u8  endp;
    struct usb_configuration    *c;

+   if (w_length > USB_BUFSIZ) {
+   if (ctrl->bRequestType & USB_DIR_IN) {
+   /* Cast away the const, we are going to overwrite on 
purpose. */
+   __le16 *temp = (__le16 *)&ctrl->wLength;
+   *temp = cpu_to_le16(USB_BUFSIZ);
+   w_length = USB_BUFSIZ;


Won't this end up sending corrupted packets in case they are longer than 
USB_BUFSIZ ?

Where do such long packets come from ?

What is the test-case ?


The USB host will not attempt to retrieve more than wLenght bytes during 
transfer phase.
If the device would erroneously attempt to provide more data it would result in 
an unexpected state.
In case of most implementations the buffer for endpoint 0 along with max 
control transfer is limited to 4096 bytes (USB_BUFSIZ for U-Boot and Linux 
kernel).
Still according to the USB specification wLength is two bytes an the device may 
receive requests with wLength larger than 4096 bytes e.g. in case of a 
custom/malicious USB host.
For example one may build libusb with MAX_CTRL_BUFFER_LENGTH altered to 0x 
and this will allow the host to send requests with wLength up to 0x.
In this case the original implementation may result in buffer overflows as in 
multiple locations a value directly derived from wLength is set as the transfer 
phase length.
With the change applied IN requests with wLength larger than USB_BUFSIZ will be 
trimmed to USB_BUFSIZ, otherwise the host would read wLength-USB_BUFSIZ past 
cdev->req->buf.
I am not aware of any cases where more than USB_BUFSIZ would be provided from a 
buffer other than cdev->req->buf. In case I missed such case please let me know.


Why shouldn't the patch do simple

w_length = min(w_length, USB_BUFSIZ);

?


The composite_setup function in composite.c uses w_length but function specific 
setup functions are passed the struct usb_ctrlrequest *ctrl so both must be 
updated.
If only w_length is updated using min(w_length, USB_BUFSIZ) than function 
specific setup will still receive the original request including unaltered 
wLength so it
may again return a number of bytes greater than buffer size resulting in an 
overflow.


Can you fill this sanitization into the setup wrapper here ?

https://patchwork.ozlabs.org/project/uboot/patch/20221216032047.536441-1-ma...@denx.de/

That way, it would apply for all the gadget drivers and you won't have to deal 
with the const overwrite , right ?


Sure, that should be fine.
I'll provide a patch when when this is merged, OK?


Please review/test the aforementioned patch and let me know if it works 
for you, the patch can still be tweaked one way or the other.


Re: [PATCH v2] imxtract: specify max gunzip size

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 01:05, Nikita Shubin  wrote:
>
> From: Nikita Shubin 
>
> Specify max gunzip size from config to override SYS_XIMG_LEN
> default value wich is 0x80. In case we have a large portion of FIT
> image, for example gzipped kernel with decompressed size large than
> 0x80 we should enlarge imxract area, otherwise extracting it will
> fail.
>
> It used to be a hardcoded define in cmd/ximg.c and we are moving it to
> config.
>
> Signed-off-by: Nikita Shubin 
> ---
> Hello Simon!
>
> > Can you expand what this means?
>
> Yes you are right - i should be more verbose, please check a v2 version
> of this patch.
>
> Also i thought it's a good idea to drop hardcoded define in cmd/ximg.c
> completely.
>
> v1 -> v2:
>
> - more verbosity in help
> - drop define from cmd/ximg.c, take it from config
> ---
>  cmd/Kconfig | 10 ++
>  cmd/ximg.c  |  5 -
>  2 files changed, 10 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass 


>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index d93731f2af6..516dfd102f6 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -476,6 +476,16 @@ config CMD_XIMG
> help
>   Extract a part of a multi-image.
>
> +config SYS_XIMG_LEN
> +hex "imxtract max gunzip size"
> +default 0x80
> +depends on CMD_XIMG && GZIP
> +help
> + This provides the size of the commad-line argument area
> + used by imxtract for extracting pieces of FIT image.
> + It should be large enough to fit uncompressed size of
> + FIT piece we are extracting.
> +
>  config CMD_XXD
> bool "xxd"
> help
> diff --git a/cmd/ximg.c b/cmd/ximg.c
> index 1c40fd27a05..0a41b4b3bb2 100644
> --- a/cmd/ximg.c
> +++ b/cmd/ximg.c
> @@ -27,11 +27,6 @@
>  #include 
>  #include 
>
> -#ifndef CONFIG_SYS_XIMG_LEN
> -/* use 8MByte as default max gunzip size */
> -#define CONFIG_SYS_XIMG_LEN0x80
> -#endif
> -
>  static int
>  do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  {
> --
> 2.37.4
>


Re: [PATCH 4/6] patman: set the default config_fname argument value to None

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> This better matches Python conventions, allowing to easily test
> whether the optional argument is provided.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/__main__.py | 2 +-
>  tools/patman/settings.py | 9 +
>  2 files changed, 6 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 5/8] patman: add pytest configuration file

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> With this change, a user can run the patman test suite using Pytest
> the same as when using 'patman test':
>
> $ cd tools/patman && pytest
> [...]
> 44 passed, 8 warnings in 8.87s
>
> $ ./patman test
> Ran 44 tests in 8.460s
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/pytest.ini | 2 ++
>  1 file changed, 2 insertions(+)
>  create mode 100644 tools/patman/pytest.ini

Reviewed-by: Simon Glass 


Re: [PATCH 6/6] patman: additionally honor a local .patman config file

2022-12-19 Thread Simon Glass
Hi Maxim,

On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> This enables versioning a project specific patman configuration file.
> It also makes it possible to declare the the project name is,
> which is not a useful thing to do in $HOME/.patman.  A new test is
> added, along updated documentation.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/patman.rst   |  8 ++-
>  tools/patman/settings.py  | 24 +++
>  tools/patman/test_settings.py | 43 +++
>  3 files changed, 70 insertions(+), 5 deletions(-)
>  create mode 100644 tools/patman/test_settings.py
>
> diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
> index b06399b459..02c08179af 100644
> --- a/tools/patman/patman.rst
> +++ b/tools/patman/patman.rst
> @@ -74,7 +74,7 @@ out where to send patches pretty well.
>  During the first run patman creates a config file for you by taking the 
> default
>  user name and email address from the global .gitconfig file.
>
> -To add your own, create a file ~/.patman like this::
> +To add your own, create a file `~/.patman` like this::
>
>  # patman alias file
>
> @@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
>  wolfgang: Wolfgang Denk 
>  others: Mike Frysinger , Fred Bloggs 
> 
>
> +Patman will also look for a `.patman` configuration file at the root
> +of the current project git repository, which makes it possible to
> +override the `project` settings variable or anything else in a
> +project-specific way. The values of this "local" configuration file
> +take precedence over those of the "global" one.
> +
>  Aliases are recursive.
>
>  The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
> diff --git a/tools/patman/settings.py b/tools/patman/settings.py
> index c05efd2475..636983e32d 100644
> --- a/tools/patman/settings.py
> +++ b/tools/patman/settings.py
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0+
>  # Copyright (c) 2011 The Chromium OS Authors.
> +# Copyright (c) 2022 Maxim Cournoyer 
>  #
>
>  try:
> @@ -336,6 +337,12 @@ def GetItems(config, section):
>  def Setup(parser, project_name, config_fname=None):
>  """Set up the settings module by reading config files.
>
> +Unless `config_fname` is specified, a `.patman` config file local
> +to the git repository is consulted, followed by the global
> +`$HOME/.patman`. If none exists, the later is created. Values
> +defined in the local config file take precedence over those
> +defined in the global one.
> +
>  Args:
>  parser: The parser to update.
>  project_name:   Name of project that we're working on; we'll look
> @@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
>
>  if not config_fname:
>  config_fname = '%s/.patman' % os.getenv('HOME')
> +has_config = os.path.exists(config_fname)
>
> -if not os.path.exists(config_fname):
> -print("No config file found ~/.patman\nCreating one...\n")
> -CreatePatmanConfigFile(config_fname)
> +git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
> +has_git_local_config = os.path.exists(git_local_config_fname)
>
> -config.read(config_fname)
> +# Read the git local config last, so that its values override
> +# those of the global config, if any.
> +if has_config:
> +config.read(config_fname)
> +if has_git_local_config:
> +config.read(git_local_config_fname)
> +
> +if not (has_config or has_git_local_config):
> +print("No config file found.\nCreating ~/.patman...\n")
> +CreatePatmanConfigFile(config_fname)
>
>  for name, value in GetItems(config, 'alias'):
>  alias[name] = value.split(',')
> diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
> new file mode 100644
> index 00..9c14b4aaa3
> --- /dev/null
> +++ b/tools/patman/test_settings.py
> @@ -0,0 +1,43 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (c) 2022 Maxim Cournoyer 
> +#
> +
> +import argparse
> +import contextlib
> +import os
> +import subprocess
> +import tempfile
> +
> +from patman import settings
> +
> +
> +@contextlib.contextmanager
> +def empty_git_repository():
> +with tempfile.TemporaryDirectory() as tmpdir:
> +os.chdir(tmpdir)
> +subprocess.check_call(['git', 'init'])

We normally use tools.run()

> +yield tmpdir
> +
> +
> +def test_git_local_config():
> +with empty_git_repository():
> +with tempfile.NamedTemporaryFile() as global_config:
> +global_config.write(b'[settings]\n'
> +b'project=u-boot\n')
> +global_config.flush()
> +parser = argparse.ArgumentParser()
> +parser.add_argument('-p', '--project', default='unknown')
> +
> +# Test "global" config is used.
> +settings.Setup(parser, 'unknown', global_config.nam

Re: [PATCH v2 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module.

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> This patch fixes all the PEP 8 warnings reported by Pyflake for the
> gitutil module.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/gitutil.py | 106 
>  1 file changed, 65 insertions(+), 41 deletions(-)

Reviewed-by: Simon Glass 

BTW we do have a 'make pylint' target which finds more problems (with pylint).


Re: [External] : Re: [PATCH v3] console: usb: kbd: Limit poll frequency to improve performance

2022-12-19 Thread Simon Glass
Hi Filip,

On Mon, 19 Dec 2022 at 02:29, Filip Žaludek  wrote:
>
>
>
> Hi Simon,
>
>   is your testing framework connected to HDMI? Only notable discrepancy
> from generic config is enabled 'efidebug' command.
>
>
> Tested more (cycled 'U-Boot>' and 'reset'), both RPi3B and RPi3B+..
> USB Keyboard failure rates:
> connected console02/10
> connected hdmi   06/10
> connected console + hdmi 07/10
> ** USB Keyboard always detected by 'usb info', just does not respond.
>
> USB Keyboard failure rates, reverted 96991e652f541323a03c5b7e075d54a117091618:
> connected console + hdmi 00/10

Yes this one does have HDMI. Are you wanting me to run multiple runs?
With or without the display?

Regards,
Simon


>
>
>
>   Just to note subsequent Grub2 menu redraw to my 180x50 console terminal
> is about 5x faster when hdmi disconnected.
>
>
>
> Thanks for testing!
> Regards,
> Filip
>
>
>
> FW: rpi-firmware-20220830-1.0.1.el8.noarch
> Revision: 9bd3d354a1a0712ac27c717df9ad60566b0406ee
>
>
>
>
>
>
>
> On 12/17/22 23:24, Simon Glass wrote:
> > Hi Filip,
> >
> > On Sat, 17 Dec 2022 at 05:50, Filip Žaludek  
> > wrote:
> >>
> >>
> >>
> >> Hello,
> >>change seems to be unfriendly to RPi3B+, it allows to enter 'U-Boot>' 
> >> shell but usb keyboard
> >> does not respond. Keyboard is detected by 'usb info' in v2023.01-rc3, not 
> >> in v2022.10.
> >> When reverted, usb keyboard works as expected.
> >>
> >> Anybody sitting front of RPi3B+ care to confirm?
> >>
> >>
> >> Regards,
> >> Filip
> >>
> >>
> >>
> >>
> >>
> >> Patch:
> >> https://urldefense.com/v3/__https://github.com/u-boot/u-boot/commit/96991e652f541323a03c5b7e075d54a117091618__;!!ACWV5N9M2RV99hQ!MunypRlNhelLw1nrbbLFCTeZK2pCAlIH_WPhgvmgFhfy3wJnPA5titNwl3o2fkc-mCqWAgJxjjc1sSD1$
> >>
> >>
> >> Debug:
> >> USB KBD: found interrupt EP: 0x81
> >> USB KBD: set boot protocol
> >> dwc2_submit_control_msg: dev='usb@7e98', udev=3af4be00,
> >> udev->dev='usb_kbd', portnr=3
> >> USB KBD: set idle interval...
> >> dwc2_submit_control_msg: dev='usb@7e98', udev=3af4be00,
> >> udev->dev='usb_kbd', portnr=3
> >> USB KBD: enable interrupt pipe...
> >> usb_kbd usb_kbd: Timeout poll on interrupt endpoint
> >>
> >>
> >> Tested:
> >> SW: v2022.10 & v2023.01-rc3 compiled from sources as 'rpiarm64'
> >> HW: USB 1.1 and 2.0 keyboards, RPi3B+
> >> JeOS:
> >> https://urldefense.com/v3/__http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-raspberrypi.aarch64-2022.10.11-Snapshot20221112.raw.xz__;!!ACWV5N9M2RV99hQ!MunypRlNhelLw1nrbbLFCTeZK2pCAlIH_WPhgvmgFhfy3wJnPA5titNwl3o2fkc-mCqWAgJxjkilUmrv$
> >> (u-boot-rpiarm64-2022.10-1.1.aarch64)
> >>
> >>
> >
> > This seems to work on current master:
> >
> > do-try-int.sh rpi3
> > Revision 9bd3d354a1a0712ac27c717df9ad60566b0406ee, board rpi3
> >
> > Checking revision 9bd3d354a1a0712ac27c717df9ad60566b0406ee
> > /vid/software/devel/ubtest
> > tbot starting ...
> > ├─Parameters:
> > │ rev= '9bd3d354a1a0712ac27c717df9ad60566b0406ee'
> > │ clean  = False
> > ├─Calling uboot_build_and_flash ...
> > │   ├─Calling uboot_build ...
> > │   │   ├─Calling uboot_checkout ...
> > │   │   │   ├─Builder: rpi3
> > │   │   │   └─Done. (0.181s)
> > │   │   ├─Configuring build ...
> > │   │   ├─Calling uboot_make ...
> > │   │   │   └─Done. (1.504s)
> > │   │   └─Done. (2.178s)
> > │   ├─Calling uboot_flash ...
> > │   │   ├─Calling copy ...
> > │   │   │   └─Done. (0.004s)
> > │   │   └─Done. (1.119s)
> > │   └─Done. (3.663s)
> > ├─
> > └─SUCCESS (3.799s)
> > tbot starting ...
> > ├─Calling interactive_board ...
> > │   ├─POWERON (rpi3)
> > │   ├─Entering interactive shell (CTRL+D to exit) ...
> >
> >
> > U-Boot 2023.01-rc3-00057-g9bd3d354a1a (Dec 17 2022 - 15:23:14 -0700)
> >
> > DRAM:  992 MiB
> > RPI 3 Model B (0xa22082)
> > Core:  66 devices, 14 uclasses, devicetree: embed
> > MMC:   mmc@7e202000: 0, mmc@7e30: 1
> > Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1...
> > In:serial
> > Out:   vidconsole
> > Err:   vidconsole
> > Net:   No ethernet found.
> > starting USB...
> > Bus usb@7e98: USB DWC2
> > scanning bus usb@7e98 for devices... usb_kbd usb_kbd: Timeout poll
> > on interrupt endpoint
> > Failed to get keyboard state from device 0c40:8000
> > 6 USB Device(s) found
> > scanning usb for storage devices... 1 Storage Device(s) found
> > Hit any key to stop autoboot:  0
> > U-Boot> usb info
> > 1: Hub,  USB Revision 1.10
> >   -  U-Boot Root Hub
> >   - Class: Hub
> >   - PacketSize: 8  Configurations: 1
> >   - Vendor: 0x  Product 0x Version 0.0
> > Configuration: 1
> > - Interfaces: 1 Self Powered 0mA
> >   Interface: 0
> >   - Alternate Setting 0, Endpoints: 1
> >   - Class Hub
> >   - Endpoint 1 In Interrupt MaxPacket 2 Interval 255ms
> >
> > 2: Hub,  USB Revision 2.0
> >   - Class: Hub
> >   - PacketSize: 64  Configurations: 1
>

Re: [PATCH v2 6/8] patman: hide the 'test' action unless test data is available

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> Some tests would fail when the test data is not available, so it
> doesn't make much sense to expose the action when patman is running
> outside of the u-boot git checkout.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/__main__.py | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 

This really should have an update in the docs


Re: [PATCH 2/2] test: cmd: exit: Add unit test for exit and partly run commands

2022-12-19 Thread Simon Glass
On Sun, 18 Dec 2022 at 13:47, Marek Vasut  wrote:
>
> Add a test which validates that exit from environment script works as
> expected, including return value propagation and clipping to positive
> integers.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Adrian Vovk 
> Cc: Hector Palacios 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  include/test/suites.h |   1 +
>  test/cmd/Makefile |   2 +-
>  test/cmd/exit.c   | 135 ++
>  test/cmd_ut.c |   1 +
>  4 files changed, 138 insertions(+), 1 deletion(-)
>  create mode 100644 test/cmd/exit.c

Reviewed-by: Simon Glass 


Re: [PATCH v2 8/8] patman: document default 'send' command

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> Document that this command is the default and what it's intended for.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/__main__.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [RESEND RFC PATCH 2/2] video: ti: am335x: drop pre-driver-model code

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 04:35, Dario Binacchi
 wrote:
>
> The patch removes the pre-driver-model implementation and keeps the
> code with driver model support.
>
> Signed-off-by: Dario Binacchi 
>
> ---
>
>  arch/arm/mach-omap2/am33xx/clock_am33xx.c |   4 -
>  board/bosch/guardian/board.c  |  70 -
>  configs/am335x_guardian_defconfig |   1 -
>  drivers/video/ti/Makefile |   4 -
>  drivers/video/ti/am335x-fb.c  | 318 --
>  drivers/video/ti/am335x-fb.h  |  71 -
>  6 files changed, 468 deletions(-)
>  delete mode 100644 drivers/video/ti/am335x-fb.c
>  delete mode 100644 drivers/video/ti/am335x-fb.h

Reviewed-by: Simon Glass 


Re: [PATCH v2 7/8] patman: document how to run test suite via pytest

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> Pytest offers useful features such as selecting tests by means of a
> regular expression, or running the pdb debugger upon encountering a
> test failure.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/patman.rst | 6 ++
>  1 file changed, 6 insertions(+)

Reviewed-by: Simon Glass 


>
> diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
> index 8c5c9cc2cc..b06399b459 100644
> --- a/tools/patman/patman.rst
> +++ b/tools/patman/patman.rst
> @@ -680,6 +680,12 @@ them:
>
>  $ tools/patman/patman test
>
> +Alternatively, you can run the test suite via Pytest:
> +
> +.. code-block:: bash
> +
> +$ cd tools/patman && pytest
> +
>  Error handling doesn't always produce friendly error messages - e.g.
>  putting an incorrect tag in a commit may provide a confusing message.
>
> --
> 2.38.1
>


Re: [PATCH 1/6] patman: fix pep8 warnings in settings module

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> Remove extraneous imports, variables and comply to PEP 8 maximum line
> width, among other PEP 8 changes suggested by Pyflake.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/settings.py | 38 +-
>  1 file changed, 21 insertions(+), 17 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH] rockchip: Only call binman when TPL available

2022-12-19 Thread Simon Glass
Hi Kever,

On Sun, 18 Dec 2022 at 05:50, Kever Yang  wrote:
>
> Rockchip platform use TPL to do the DRAM initialize for all the SoCs,
> if TPL is not available, means no available DRAM init program, and the
> u-boot-rockchip.bin is not functionable.
>
> Signed-off-by: Kever Yang 
> ---
>
>  arch/arm/dts/rockchip-u-boot.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Can you please look at the series to convert things to binman? I found
another problem with it so can send v8, but I'd really like some
reviews on that.

For this patch, can you explain what the problem is right now?
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi 
> b/arch/arm/dts/rockchip-u-boot.dtsi
> index 584f21eb5bf..e2b0f389711 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -11,7 +11,7 @@
> };
>  };
>
> -#ifdef CONFIG_SPL
> +#ifdef CONFIG_TPL_BUILD
>  &binman {
> simple-bin {
> filename = "u-boot-rockchip.bin";
> --
> 2.25.1
>

Regards,
Simon


Re: [PATCH 2/6] patman: replace deprecated SafeConfigParser with ConfigParser

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> The SafeConfigParser class has been renamed in Python 3.2 to
> ConfigParser, and the old alias has been deprecated since.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/settings.py | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 5/6] patman: fail early in Setup when provided config file does not exist

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> Rationale: if the user explicitly provide this argument, they probably
> intend for it to be used.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/settings.py | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 2/8] patman: locate test data files via __file__ and pathlib

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> Previously it would rely on the executing script location, which could
> break for example when running the tests via 'pytest'.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/func_test.py | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 3/6] patman: import gitutil module where it is needed

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer  wrote:
>
> Instead of propagating it from the module entry point (main script).
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
>  tools/patman/__main__.py | 3 +--
>  tools/patman/settings.py | 8 +---
>  2 files changed, 6 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v8 03/10] arm_ffa: introduce Arm FF-A low-level driver

2022-12-19 Thread Simon Glass
Hi Abdellatif,

On Mon, 19 Dec 2022 at 04:12, Abdellatif El Khlifi
 wrote:
>
> On Mon, Dec 05, 2022 at 09:49:30AM -0600, Rob Herring wrote:
> > On Sun, Dec 4, 2022 at 1:22 PM Simon Glass  wrote:
> > >
> > > Hi Rob,
> > >
> > > On Tue, 29 Nov 2022 at 05:22, Rob Herring  wrote:
> > > >
> > > > On Fri, Nov 25, 2022 at 3:18 PM Simon Glass  wrote:
> > > > >
> > > > > Hi Abdellatif,
> > > > >
> > > > > On Thu, 24 Nov 2022 at 06:21, Abdellatif El Khlifi 
> > > > >  wrote:
> > > > > >
> > > > > > On Tue, Nov 22, 2022 at 07:09:16PM -0700, Simon Glass wrote:
> > > > > > >  should be called 'priov' and should beHi Abdellatif,
> > > > > > >
> > > > >
> > > > > [..]
> > > > >
> > > > > > > > +/**
> > > > > > > > + * ffa_device_get - create, bind and probe the arm_ffa device
> > > > > > > > + * @pdev: the address of a device pointer (to be filled when 
> > > > > > > > the arm_ffa bus device is created
> > > > > > > > + *   successfully)
> > > > > > > > + *
> > > > > > > > + * This function makes sure the arm_ffa device is
> > > > > > > > + * created, bound to this driver, probed and ready to use.
> > > > > > > > + * Arm FF-A transport is implemented through a single U-Boot
> > > > > > > > + * device managing the FF-A bus (arm_ffa).
> > > > > > > > + *
> > > > > > > > + * Return:
> > > > > > > > + *
> > > > > > > > + * 0 on success. Otherwise, failure
> > > > > > > > + */
> > > > > > > > +int ffa_device_get(struct udevice **pdev)
> > > > > > > > +{
> > > > > > > > +   int ret;
> > > > > > > > +   struct udevice *dev = NULL;
> > > > > > > > +
> > > > > > > > +   ret = device_bind(dm_root(), DM_DRIVER_GET(arm_ffa), 
> > > > > > > > FFA_DRV_NAME, NULL, ofnode_null(),
> > > > > > > > + &dev);
> > > > > > >
> > > > > > > Please add a DT binding. Even if only temporary, we need 
> > > > > > > something for this.
> > > > > >
> > > > > > Thanks for the feedback. I'm happy to address all the comments.
> > > > > >
> > > > > > Regarding DT binding and FF-A discovery. We agreed with Linaro and 
> > > > > > Rob Herring
> > > > > > about the following:
> > > > > >
> > > > > > - DT is only for what we failed to make discoverable. For hardware, 
> > > > > > we're stuck
> > > > > >   with it. We shouldn't repeat that for software interfaces. This 
> > > > > > approach is
> > > > > >   already applied in the FF-A kernel driver which comes with no DT 
> > > > > > support and
> > > > > >   discovers the bus with bus_register() API [1].
> > > > >
> > > > > This may be the UEFI view, but it is not how U-Boot works. This is 
> > > > > not something we are 'stuck' with. It is how we define what is 
> > > > > present on a device. This is how the PCI bus works in U-Boot. It is 
> > > > > best practice in U-Boot to use the device tree to make this things 
> > > > > visible and configurable. Unlike with Linux there is no other way to 
> > > > > provide configuration needed by these devices.
> > > >
> > > > Where do you get UEFI out of this?
> > >
> > > I assume it was UEFI as there was no discussion about this in U-Boot.
> > > Which firmware project was consulted about this?
> > >
> > > >
> > > > It is the discoverability of hardware that is fixed (and we are stuck
> > > > with). We can't change hardware. The disoverability may be PCI
> > > > VID/PID, USB device descriptors, or nothing. We only use DT when those
> > > > are not sufficient. For a software interface, there is no reason to
> > > > make them non-discoverable as the interface can be fixed (at least for
> > > > new things like FF-A).
> > >
> > > Here I am talking about the controller itself, the top-level node in
> > > the device tree. For PCI this is a device tree node and it should be
> > > the same here. So I am not saying that the devices on the bus need to
> > > be in the device tree (that can be optional, but may be useful in some
> > > situations where it is status and known).
> >
> > Sure, the PCI host bridges are not discoverable, have a bunch of
> > resources, and do need to be in DT. The downstream devices only do if
> > they have extra resources such as when a device is soldered down on a
> > board rather than a standard slot.
> >
> > > We need something like:
> > >
> > > ff-a {
> > > compatible = "something";
> > > };
> > >
> > > I don't know what mechanism is actually used to communicate with it,
> > > but that will be enough to get the top-level driver started.
> >
> > There's discovery of FF-A itself and then discovery of FF-A features
> > (e.g. partitions). Both of those are discoverable without DT. The
> > first is done by checking the SMCCC version, then checking for FF-A
> > presence and features. Putting this into DT is redundant. Worse, what
> > if they disagree?
>
> Hi Simon,
>
> Do you agree with Rob, Ilias and myself that it makes more sense
> FF-A bus is discovered without a DT node and following the same approach as
> Linux ? (FF-A bus doesn't have a HW controller and is a purely SW bus,
> no configuration/description

Re: [PATCH v2 4/8] patman: rename main script to __main__.py

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> This allows running the package as a Python module, like e.g.:
>
> $ python -m patman
>
> It also prevents Pytest from attempting to parse main.py, which
> would cause errors.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> (no changes since v1)
>
>  tools/patman/{main.py => __main__.py} | 0
>  tools/patman/patman   | 2 +-
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename tools/patman/{main.py => __main__.py} (100%)

Reviewed-by: Simon Glass 


Re: [PATCH v2 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'

2022-12-19 Thread Simon Glass
On Mon, 19 Dec 2022 at 07:53, Maxim Cournoyer  wrote:
>
> This resolves 10 out of 11 test failures seen when running './patman
> test' from the 'tools/patman' subdirectory. This was caused by the
> .checkpatch.conf configuration file at the root of the project not
> being picked up. Make the test suite of patman independant from it by

independent

> always invoking the checkpatch.pl script with the minimally required
> arguments for the test suite to pass.
>
> Signed-off-by: Maxim Cournoyer 
> ---
>
> Changes in v2:
> - Reword the commit message with a better explanation of the problem
> - Add the '--strict' argument to script invocation
>
>  tools/patman/checkpatch.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [RESEND RFC PATCH 1/2] Revert "video: Drop CONFIG_AM335X_LCD"

2022-12-19 Thread Simon Glass
Hi Dario,

On Mon, 19 Dec 2022 at 04:35, Dario Binacchi
 wrote:
>
> This reverts commit 82f7b869f5d7aad246a4621a18a5ad04475815ba.
>
> It also removed code with driver model support.
> The commit [1], as described in its message, was also designed to make
> it easy to remove pre-driver-model code in the near future.
>
> [1] 35ab1b6ef7f3a ("video: omap: split the legacy code from the DM code")
> Signed-off-by: Dario Binacchi 
> ---
>
>  arch/arm/mach-omap2/am33xx/clock_am33xx.c |   4 +
>  board/bosch/guardian/board.c  |  70 
>  configs/am335x_guardian_defconfig |   1 +
>  drivers/video/Kconfig |   2 +
>  drivers/video/Makefile|   1 +
>  drivers/video/ti/Kconfig  |   8 +
>  drivers/video/ti/Makefile |  10 +
>  drivers/video/ti/am335x-fb.c  | 318 
>  drivers/video/ti/am335x-fb.h  |  71 
>  drivers/video/ti/tilcdc-panel.c   | 172 +
>  drivers/video/ti/tilcdc-panel.h   |  14 +
>  drivers/video/ti/tilcdc.c | 426 ++
>  drivers/video/ti/tilcdc.h |  38 ++
>  13 files changed, 1135 insertions(+)
>  create mode 100644 drivers/video/ti/Kconfig
>  create mode 100644 drivers/video/ti/Makefile
>  create mode 100644 drivers/video/ti/am335x-fb.c
>  create mode 100644 drivers/video/ti/am335x-fb.h
>  create mode 100644 drivers/video/ti/tilcdc-panel.c
>  create mode 100644 drivers/video/ti/tilcdc-panel.h
>  create mode 100644 drivers/video/ti/tilcdc.c
>  create mode 100644 drivers/video/ti/tilcdc.h

I'm sorry if I messed something up there. Can you add back just the DM
code? We don't have lcd.h anymore.

But if this is the way you want to do it:

Reviewed-by: Simon Glass 

Regards,
Simon


Re: [PATCH] Prevent buffer overflow on USB control endpoint

2022-12-19 Thread Szymon Heidrich
On 16/12/2022 04:22, Marek Vasut wrote:
> On 11/20/22 18:42, Szymon Heidrich wrote:
>> On 20/11/2022 18:25, Marek Vasut wrote:
>>> On 11/20/22 16:29, Szymon Heidrich wrote:
 On 20/11/2022 15:43, Marek Vasut wrote:
> On 11/17/22 12:50, Fabio Estevam wrote:
>> [Adding Lukasz and Marek]
>>
>> On Thu, Nov 17, 2022 at 6:50 AM Szymon Heidrich
>>  wrote:
>>>
>>> Assure that the control endpoint buffer of size USB_BUFSIZ (4096)
>>> can not be overflown during handling of USB control transfer
>>> requests with wLength greater than USB_BUFSIZ.
>>>
>>> Signed-off-by: Szymon Heidrich 
>>> ---
>>>     drivers/usb/gadget/composite.c | 11 +++
>>>     1 file changed, 11 insertions(+)
>>>
>>> diff --git a/drivers/usb/gadget/composite.c 
>>> b/drivers/usb/gadget/composite.c
>>> index 2a309e624e..cb89f6dca9 100644
>>> --- a/drivers/usb/gadget/composite.c
>>> +++ b/drivers/usb/gadget/composite.c
>>> @@ -1019,6 +1019,17 @@ composite_setup(struct usb_gadget *gadget, const 
>>> struct usb_ctrlrequest *ctrl)
>>>    u8  endp;
>>>    struct usb_configuration    *c;
>>>
>>> +   if (w_length > USB_BUFSIZ) {
>>> +   if (ctrl->bRequestType & USB_DIR_IN) {
>>> +   /* Cast away the const, we are going to 
>>> overwrite on purpose. */
>>> +   __le16 *temp = (__le16 *)&ctrl->wLength;
>>> +   *temp = cpu_to_le16(USB_BUFSIZ);
>>> +   w_length = USB_BUFSIZ;
>
> Won't this end up sending corrupted packets in case they are longer than 
> USB_BUFSIZ ?
>
> Where do such long packets come from ?
>
> What is the test-case ?

 The USB host will not attempt to retrieve more than wLenght bytes during 
 transfer phase.
 If the device would erroneously attempt to provide more data it would 
 result in an unexpected state.
 In case of most implementations the buffer for endpoint 0 along with max 
 control transfer is limited to 4096 bytes (USB_BUFSIZ for U-Boot and Linux 
 kernel).
 Still according to the USB specification wLength is two bytes an the 
 device may receive requests with wLength larger than 4096 bytes e.g. in 
 case of a custom/malicious USB host.
 For example one may build libusb with MAX_CTRL_BUFFER_LENGTH altered to 
 0x and this will allow the host to send requests with wLength up to 
 0x.
 In this case the original implementation may result in buffer overflows as 
 in multiple locations a value directly derived from wLength is set as the 
 transfer phase length.
 With the change applied IN requests with wLength larger than USB_BUFSIZ 
 will be trimmed to USB_BUFSIZ, otherwise the host would read 
 wLength-USB_BUFSIZ past cdev->req->buf.
 I am not aware of any cases where more than USB_BUFSIZ would be provided 
 from a buffer other than cdev->req->buf. In case I missed such case please 
 let me know.
>>>
>>> Why shouldn't the patch do simple
>>>
>>> w_length = min(w_length, USB_BUFSIZ);
>>>
>>> ?
>>
>> The composite_setup function in composite.c uses w_length but function 
>> specific setup functions are passed the struct usb_ctrlrequest *ctrl so both 
>> must be updated.
>> If only w_length is updated using min(w_length, USB_BUFSIZ) than function 
>> specific setup will still receive the original request including unaltered 
>> wLength so it
>> may again return a number of bytes greater than buffer size resulting in an 
>> overflow.
> 
> Can you fill this sanitization into the setup wrapper here ?
> 
> https://patchwork.ozlabs.org/project/uboot/patch/20221216032047.536441-1-ma...@denx.de/
> 
> That way, it would apply for all the gadget drivers and you won't have to 
> deal with the const overwrite , right ?

Sure, that should be fine. 
I'll provide a patch when when this is merged, OK?


[PATCH v3 1/1] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the project name, which is not a
useful thing to do in $HOME/.patman.  A new test is added, along
updated documentation.

Signed-off-by: Maxim Cournoyer 
---

Changes in v3:
- Clear command line arguments in test_git_local_config
- Also test overriding a 'send' command line argument

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

 tools/patman/patman.rst   |  8 -
 tools/patman/settings.py  | 24 ++---
 tools/patman/test_settings.py | 65 +++
 3 files changed, 92 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index b06399b459..3e12251f03 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -74,7 +74,7 @@ out where to send patches pretty well.
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
 
-To add your own, create a file ~/.patman like this::
+To add your own, create a file `~/.patman` like this::
 
 # patman alias file
 
@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
 wolfgang: Wolfgang Denk 
 others: Mike Frysinger , Fred Bloggs 

 
+Patman will also look for a `.patman` configuration file at the root
+of the current project git repository, which makes it possible to
+override the `project` settings variable or anything else in a
+project-specific way. The values of this "local" configuration file
+take precedence over those of the "global" one.
+
 Aliases are recursive.
 
 The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c05efd2475..636983e32d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
+# Copyright (c) 2022 Maxim Cournoyer 
 #
 
 try:
@@ -336,6 +337,12 @@ def GetItems(config, section):
 def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
+Unless `config_fname` is specified, a `.patman` config file local
+to the git repository is consulted, followed by the global
+`$HOME/.patman`. If none exists, the later is created. Values
+defined in the local config file take precedence over those
+defined in the global one.
+
 Args:
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
@@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
 
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
+has_config = os.path.exists(config_fname)
 
-if not os.path.exists(config_fname):
-print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(config_fname)
+git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
+has_git_local_config = os.path.exists(git_local_config_fname)
 
-config.read(config_fname)
+# Read the git local config last, so that its values override
+# those of the global config, if any.
+if has_config:
+config.read(config_fname)
+if has_git_local_config:
+config.read(git_local_config_fname)
+
+if not (has_config or has_git_local_config):
+print("No config file found.\nCreating ~/.patman...\n")
+CreatePatmanConfigFile(config_fname)
 
 for name, value in GetItems(config, 'alias'):
 alias[name] = value.split(',')
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
new file mode 100644
index 00..ff3631293b
--- /dev/null
+++ b/tools/patman/test_settings.py
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2022 Maxim Cournoyer 
+#
+
+import argparse
+import contextlib
+import os
+import subprocess
+import sys
+import tempfile
+
+from patman import settings
+
+
+@contextlib.contextmanager
+def empty_git_repository():
+with tempfile.TemporaryDirectory() as tmpdir:
+os.chdir(tmpdir)
+subprocess.check_call(['git', 'init'])
+yield tmpdir
+
+
+@contextlib.contextmanager
+def cleared_command_line_args():
+old_value = sys.argv[:]
+sys.argv = [sys.argv[0]]
+yield
+sys.argv = old_value
+
+
+def test_git_local_config():
+# Clearing the command line arguments is required, otherwise
+# arguments passed to the test running such as in 'pytest -k
+# filter' would be processed by _UpdateDefaults and fail.
+with cleared_command_line_args():
+with empty_git_repository():
+with tempfile.NamedTemporaryFile() as global_config:
+global_config.write(b'[settings]\n'
+b'

[PATCH v2 1/1] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the project name, which is not a
useful thing to do in $HOME/.patman.  A new test is added, along
updated documentation.

Signed-off-by: Maxim Cournoyer 
---

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

 tools/patman/patman.rst   |  8 ++-
 tools/patman/settings.py  | 24 +++
 tools/patman/test_settings.py | 43 +++
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index b06399b459..3e12251f03 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -74,7 +74,7 @@ out where to send patches pretty well.
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
 
-To add your own, create a file ~/.patman like this::
+To add your own, create a file `~/.patman` like this::
 
 # patman alias file
 
@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
 wolfgang: Wolfgang Denk 
 others: Mike Frysinger , Fred Bloggs 

 
+Patman will also look for a `.patman` configuration file at the root
+of the current project git repository, which makes it possible to
+override the `project` settings variable or anything else in a
+project-specific way. The values of this "local" configuration file
+take precedence over those of the "global" one.
+
 Aliases are recursive.
 
 The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c05efd2475..636983e32d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
+# Copyright (c) 2022 Maxim Cournoyer 
 #
 
 try:
@@ -336,6 +337,12 @@ def GetItems(config, section):
 def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
+Unless `config_fname` is specified, a `.patman` config file local
+to the git repository is consulted, followed by the global
+`$HOME/.patman`. If none exists, the later is created. Values
+defined in the local config file take precedence over those
+defined in the global one.
+
 Args:
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
@@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
 
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
+has_config = os.path.exists(config_fname)
 
-if not os.path.exists(config_fname):
-print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(config_fname)
+git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
+has_git_local_config = os.path.exists(git_local_config_fname)
 
-config.read(config_fname)
+# Read the git local config last, so that its values override
+# those of the global config, if any.
+if has_config:
+config.read(config_fname)
+if has_git_local_config:
+config.read(git_local_config_fname)
+
+if not (has_config or has_git_local_config):
+print("No config file found.\nCreating ~/.patman...\n")
+CreatePatmanConfigFile(config_fname)
 
 for name, value in GetItems(config, 'alias'):
 alias[name] = value.split(',')
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
new file mode 100644
index 00..b2f825f798
--- /dev/null
+++ b/tools/patman/test_settings.py
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2022 Maxim Cournoyer 
+#
+
+import argparse
+import contextlib
+import os
+import subprocess
+import tempfile
+
+from patman import settings
+
+
+@contextlib.contextmanager
+def empty_git_repository():
+with tempfile.TemporaryDirectory() as tmpdir:
+os.chdir(tmpdir)
+subprocess.check_call(['git', 'init'])
+yield tmpdir
+
+
+def test_git_local_config():
+with empty_git_repository():
+with tempfile.NamedTemporaryFile() as global_config:
+global_config.write(b'[settings]\n'
+b'project=u-boot\n')
+global_config.flush()
+parser = argparse.ArgumentParser()
+parser.add_argument('-p', '--project', default='unknown')
+
+# Test "global" config is used.
+settings.Setup(parser, 'unknown', global_config.name)
+args, _ = parser.parse_known_args([])
+assert args.project == 'u-boot'
+
+# Test local config can shadow it.
+with open('.patman', 'w', buffering=1) as f:
+f.write('[settings]\n'
+  

[PATCH v2 0/1] add support for repository-local .patman config file

2022-12-19 Thread Maxim Cournoyer
This series is based on top of series #45.  It adds support for a
.patman config file local to the git repository.  A new test
'test_settings.py' test module is added; it is automatically
discovered and run via pytest, e.g.: 'cd tools/patman && pytest'.

Changes in v2:
- Explicitly provide an empty args list to parse_known_args in test

Maxim Cournoyer (1):
  patman: additionally honor a local .patman config file

 tools/patman/patman.rst   |  8 ++-
 tools/patman/settings.py  | 24 +++
 tools/patman/test_settings.py | 43 +++
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py


base-commit: 9bd3d354a1a0712ac27c717df9ad60566b0406ee
prerequisite-patch-id: 10ced6811f0468ea30ab793f3d33a43416dc148c
prerequisite-patch-id: d841542388f09c77a7b22bc7b94d72628408fd7f
prerequisite-patch-id: 414fe8a358404113a0926217fcd75150d1aabaf6
prerequisite-patch-id: 59f0b30f075c78657a17cbbb75af471e37580bdb
prerequisite-patch-id: c7a9c4f2bd34df9da0f173c61fa40bf2f89b6929
prerequisite-patch-id: bd190cf8b6da6e8b20125f957c44cc7f7ea5dd5b
prerequisite-patch-id: 26558d3671f2a854303a959f738dfb67b25f7109
prerequisite-patch-id: 19f2332545f2c338004b1728e5cb15cce32656c0
prerequisite-patch-id: f3329676eaff32e3e53ded295da25d34c65609ea
prerequisite-patch-id: ab3bf6a5ea3620c31cff3dba52ddb7a7e374a981
prerequisite-patch-id: 4c724f56ca9479252cba51204a50c39a3ac80777
prerequisite-patch-id: 821020262c054cce9f3fe0995d115be3cca84a86
prerequisite-patch-id: e275c8b10099cc526d7b9671aba76dfbf40745c5
-- 
2.38.1



Re: [u-boot][master][PATCH 2/3] pico-imx7d: add baseboard SD card boot detect

2022-12-19 Thread Fabio Estevam
On Sun, Dec 18, 2022 at 9:53 AM  wrote:

> +   for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
> +   ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
> +   if (ret)
> +   return ret;

In patch 3/3, CONFIG_SPL_DM_MMC=y, so can't the driver do the MMC init
instead of doing this manually?

>  #define BOOT_TARGET_DEVICES(func) \
> +   func(MMC, mmc, 3) \

Shouldn't the index 2 instead?


[PATCH 1/2] arm: dts: k3-am625-sk: Enable first ethernet port

2022-12-19 Thread Sjoerd Simons
The K3 am625 sk EVM has two ethernet ports; Enable the first one for
usage in u-boot.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 92788bae3e0..f275e3b46ca 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -126,3 +126,25 @@
};
};
 };
+
+&cpsw3g {
+   reg = <0x0 0x800 0x0 0x20>,
+ <0x0 0x43000200 0x0 0x8>;
+   reg-names = "cpsw_nuss", "mac_efuse";
+   /delete-property/ ranges;
+   u-boot,dm-spl;
+
+   cpsw-phy-sel@04044 {
+   compatible = "ti,am64-phy-gmii-sel";
+   reg = <0x0 0x00104044 0x0 0x8>;
+   u-boot,dm-spl;
+   };
+};
+
+&cpsw_port1 {
+   u-boot,dm-spl;
+};
+
+&cpsw_port2 {
+   status = "disabled";
+};
-- 
2.39.0



[PATCH 2/2] configs: am62x_evm_a53: Enable ethernet

2022-12-19 Thread Sjoerd Simons
Enable configuration ethernet for u-boot on am62x; Some unrelated things
also got moved around due to running through savedefconfig.

Signed-off-by: Sjoerd Simons 

---

 configs/am62x_evm_a53_defconfig | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index e6ffd166927..30b19428e9e 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_K3_ATF_LOAD_ADDR=0x9e78
 CONFIG_TARGET_AM625_A53_EVM=y
+CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x8008
 CONFIG_SPL_MMC=y
@@ -14,6 +15,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
@@ -32,12 +34,10 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
 CONFIG_SPL_YMODEM_SUPPORT=y
@@ -57,6 +57,8 @@ CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DMA_CHANNELS=y
+CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
@@ -71,7 +73,10 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
 CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HS512T=y
+CONFIG_PHY_TI_DP83867=y
+CONFIG_PHY_FIXED=y
+CONFIG_TI_AM65_CPSW_NUSS=y
+CONFIG_PHY=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
-- 
2.39.0



[PATCH 0/2] Enable ethernet for ti am62x

2022-12-19 Thread Sjoerd Simons


These patches enable ethernet from u-boot on the ti am62x EVM. They are
based on the u-boot next branch (9c955393) to take advantage of recent dts sync
of these boards with linux


Sjoerd Simons (2):
  arm: dts: k3-am625-sk: Enable first ethernet port
  configs: am62x_evm_a53: Enable ethernet

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 ++
 configs/am62x_evm_a53_defconfig  | 11 ---
 2 files changed, 30 insertions(+), 3 deletions(-)

-- 
2.39.0



[PATCH 6/6] patman: additionally honor a local .patman config file

2022-12-19 Thread Maxim Cournoyer
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the the project name is,
which is not a useful thing to do in $HOME/.patman.  A new test is
added, along updated documentation.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/patman.rst   |  8 ++-
 tools/patman/settings.py  | 24 +++
 tools/patman/test_settings.py | 43 +++
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 tools/patman/test_settings.py

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index b06399b459..02c08179af 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -74,7 +74,7 @@ out where to send patches pretty well.
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
 
-To add your own, create a file ~/.patman like this::
+To add your own, create a file `~/.patman` like this::
 
 # patman alias file
 
@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this::
 wolfgang: Wolfgang Denk 
 others: Mike Frysinger , Fred Bloggs 

 
+Patman will also look for a `.patman` configuration file at the root
+of the current project git repository, which makes it possible to
+override the `project` settings variable or anything else in a
+project-specific way. The values of this "local" configuration file
+take precedence over those of the "global" one.
+
 Aliases are recursive.
 
 The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c05efd2475..636983e32d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
+# Copyright (c) 2022 Maxim Cournoyer 
 #
 
 try:
@@ -336,6 +337,12 @@ def GetItems(config, section):
 def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
+Unless `config_fname` is specified, a `.patman` config file local
+to the git repository is consulted, followed by the global
+`$HOME/.patman`. If none exists, the later is created. Values
+defined in the local config file take precedence over those
+defined in the global one.
+
 Args:
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
@@ -352,12 +359,21 @@ def Setup(parser, project_name, config_fname=None):
 
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
+has_config = os.path.exists(config_fname)
 
-if not os.path.exists(config_fname):
-print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(config_fname)
+git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
+has_git_local_config = os.path.exists(git_local_config_fname)
 
-config.read(config_fname)
+# Read the git local config last, so that its values override
+# those of the global config, if any.
+if has_config:
+config.read(config_fname)
+if has_git_local_config:
+config.read(git_local_config_fname)
+
+if not (has_config or has_git_local_config):
+print("No config file found.\nCreating ~/.patman...\n")
+CreatePatmanConfigFile(config_fname)
 
 for name, value in GetItems(config, 'alias'):
 alias[name] = value.split(',')
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
new file mode 100644
index 00..9c14b4aaa3
--- /dev/null
+++ b/tools/patman/test_settings.py
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2022 Maxim Cournoyer 
+#
+
+import argparse
+import contextlib
+import os
+import subprocess
+import tempfile
+
+from patman import settings
+
+
+@contextlib.contextmanager
+def empty_git_repository():
+with tempfile.TemporaryDirectory() as tmpdir:
+os.chdir(tmpdir)
+subprocess.check_call(['git', 'init'])
+yield tmpdir
+
+
+def test_git_local_config():
+with empty_git_repository():
+with tempfile.NamedTemporaryFile() as global_config:
+global_config.write(b'[settings]\n'
+b'project=u-boot\n')
+global_config.flush()
+parser = argparse.ArgumentParser()
+parser.add_argument('-p', '--project', default='unknown')
+
+# Test "global" config is used.
+settings.Setup(parser, 'unknown', global_config.name)
+args, _ = parser.parse_known_args()
+assert args.project == 'u-boot'
+
+# Test local config can shadow it.
+with open('.patman', 'w', buffering=1) as f:
+f.write('[settings]\n'
+'project=guix-patches\n')
+settings.Setup(parser, 'un

[PATCH 5/6] patman: fail early in Setup when provided config file does not exist

2022-12-19 Thread Maxim Cournoyer
Rationale: if the user explicitly provide this argument, they probably
intend for it to be used.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/settings.py | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 8b846799df..c05efd2475 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -340,12 +340,16 @@ def Setup(parser, project_name, config_fname=None):
 parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read.
+config_fname:   Config filename to read.  An error is raised if it
+does not exist.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
 
+if config_fname and not os.path.exists(config_fname):
+raise Exception(f'provided {config_fname} does not exist')
+
 if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
-- 
2.38.1



[PATCH 4/6] patman: set the default config_fname argument value to None

2022-12-19 Thread Maxim Cournoyer
This better matches Python conventions, allowing to easily test
whether the optional argument is provided.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/__main__.py | 2 +-
 tools/patman/settings.py | 9 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 3f092367ec..15fd7603d7 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -118,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(parser, args.project, '')
+settings.Setup(parser, args.project)
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 5efad5ed78..8b846799df 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -333,19 +333,20 @@ def GetItems(config, section):
 return []
 
 
-def Setup(parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=None):
 """Set up the settings module by reading config files.
 
 Args:
-parser: The parser to update
+parser: The parser to update.
 project_name:   Name of project that we're working on; we'll look
 for sections named "project_section" as well.
-config_fname:   Config filename to read ('' for default)
+config_fname:   Config filename to read.
 """
 # First read the git alias file if available
 _ReadAliasFile('doc/git-mailrc')
 config = _ProjectConfigParser(project_name)
-if config_fname == '':
+
+if not config_fname:
 config_fname = '%s/.patman' % os.getenv('HOME')
 
 if not os.path.exists(config_fname):
-- 
2.38.1



[PATCH 3/6] patman: import gitutil module where it is needed

2022-12-19 Thread Maxim Cournoyer
Instead of propagating it from the module entry point (main script).

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/__main__.py | 3 +--
 tools/patman/settings.py | 8 +---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 11f19281fb..3f092367ec 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -22,7 +22,6 @@ if __name__ == "__main__":
 from patman import command
 from patman import control
 from patman import func_test
-from patman import gitutil
 from patman import project
 from patman import settings
 from patman import terminal
@@ -119,7 +118,7 @@ status.add_argument('-f', '--force', action='store_true',
 argv = sys.argv[1:]
 args, rest = parser.parse_known_args(argv)
 if hasattr(args, 'project'):
-settings.Setup(gitutil, parser, args.project, '')
+settings.Setup(parser, args.project, '')
 args, rest = parser.parse_known_args(argv)
 
 # If we have a command, it is safe to parse all arguments
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 7fb9d6d5a0..5efad5ed78 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -11,6 +11,8 @@ import argparse
 import os
 import re
 
+from patman import gitutil
+
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -190,7 +192,7 @@ def ReadGitAliases(fname):
 fd.close()
 
 
-def CreatePatmanConfigFile(gitutil, config_fname):
+def CreatePatmanConfigFile(config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
 Args:
@@ -331,7 +333,7 @@ def GetItems(config, section):
 return []
 
 
-def Setup(gitutil, parser, project_name, config_fname=''):
+def Setup(parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
 
 Args:
@@ -348,7 +350,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 if not os.path.exists(config_fname):
 print("No config file found ~/.patman\nCreating one...\n")
-CreatePatmanConfigFile(gitutil, config_fname)
+CreatePatmanConfigFile(config_fname)
 
 config.read(config_fname)
 
-- 
2.38.1



[PATCH 2/6] patman: replace deprecated SafeConfigParser with ConfigParser

2022-12-19 Thread Maxim Cournoyer
The SafeConfigParser class has been renamed in Python 3.2 to
ConfigParser, and the old alias has been deprecated since.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/settings.py | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index b6884a073e..7fb9d6d5a0 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -30,7 +30,7 @@ _default_settings = {
 }
 
 
-class _ProjectConfigParser(ConfigParser.SafeConfigParser):
+class _ProjectConfigParser(ConfigParser.ConfigParser):
 """ConfigParser that handles projects.
 
 There are two main goals of this class:
@@ -81,14 +81,14 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this
-also loads project defaults.
+In addition to standard ConfigParser initialization, this also
+loads project defaults.
 
 Args:
 project_name: The name of the project.
 """
 self._project_name = project_name
-ConfigParser.SafeConfigParser.__init__(self)
+ConfigParser.ConfigParser.__init__(self)
 
 # Update the project settings in the config based on
 # the _default_settings global.
@@ -100,31 +100,31 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 self.set(project_settings, setting_name, setting_value)
 
 def get(self, section, option, *args, **kwargs):
-"""Extend SafeConfigParser to try project_section before section.
+"""Extend ConfigParser to try project_section before section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 try:
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, "%s_%s" % (self._project_name, section), option,
 *args, **kwargs
 )
 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
-val = ConfigParser.SafeConfigParser.get(
+val = ConfigParser.ConfigParser.get(
 self, section, option, *args, **kwargs
 )
 return val
 
 def items(self, section, *args, **kwargs):
-"""Extend SafeConfigParser to add project_section to section.
+"""Extend ConfigParser to add project_section to section.
 
 Args:
-See SafeConfigParser.
+See ConfigParser.
 Returns:
-See SafeConfigParser.
+See ConfigParser.
 """
 project_items = []
 has_project_section = False
@@ -132,7 +132,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get items from the project section
 try:
-project_items = ConfigParser.SafeConfigParser.items(
+project_items = ConfigParser.ConfigParser.items(
 self, "%s_%s" % (self._project_name, section), *args, **kwargs
 )
 has_project_section = True
@@ -141,7 +141,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
 # Get top-level items
 try:
-top_items = ConfigParser.SafeConfigParser.items(
+top_items = ConfigParser.ConfigParser.items(
 self, section, *args, **kwargs
 )
 except ConfigParser.NoSectionError:
-- 
2.38.1



[PATCH 1/6] patman: fix pep8 warnings in settings module

2022-12-19 Thread Maxim Cournoyer
Remove extraneous imports, variables and comply to PEP 8 maximum line
width, among other PEP 8 changes suggested by Pyflake.

Signed-off-by: Maxim Cournoyer 
---

 tools/patman/settings.py | 38 +-
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 903d6fcb0b..b6884a073e 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -4,16 +4,13 @@
 
 try:
 import configparser as ConfigParser
-except:
+except Exception:
 import ConfigParser
 
 import argparse
 import os
 import re
 
-from patman import command
-from patman import tools
-
 """Default settings per-project.
 
 These are used by _ProjectConfigParser.  Settings names should match
@@ -32,6 +29,7 @@ _default_settings = {
 },
 }
 
+
 class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 """ConfigParser that handles projects.
 
@@ -83,8 +81,8 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 def __init__(self, project_name):
 """Construct _ProjectConfigParser.
 
-In addition to standard SafeConfigParser initialization, this also 
loads
-project defaults.
+In addition to standard SafeConfigParser initialization, this
+also loads project defaults.
 
 Args:
 project_name: The name of the project.
@@ -155,6 +153,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 item_dict.update(project_items)
 return {(item, val) for item, val in item_dict.items()}
 
+
 def ReadGitAliases(fname):
 """Read a git alias file. This is in the form used by git:
 
@@ -170,7 +169,7 @@ def ReadGitAliases(fname):
 print("Warning: Cannot find alias file '%s'" % fname)
 return
 
-re_line = re.compile('alias\s+(\S+)\s+(.*)')
+re_line = re.compile(r'alias\s+(\S+)\s+(.*)')
 for line in fd.readlines():
 line = line.strip()
 if not line or line[0] == '#':
@@ -190,6 +189,7 @@ def ReadGitAliases(fname):
 
 fd.close()
 
+
 def CreatePatmanConfigFile(gitutil, config_fname):
 """Creates a config file under $(HOME)/.patman if it can't find one.
 
@@ -200,12 +200,12 @@ def CreatePatmanConfigFile(gitutil, config_fname):
 None
 """
 name = gitutil.get_default_user_name()
-if name == None:
+if name is None:
 name = input("Enter name: ")
 
 email = gitutil.get_default_user_email()
 
-if email == None:
+if email is None:
 email = input("Enter email: ")
 
 try:
@@ -220,7 +220,8 @@ me: %s <%s>
 [bounces]
 nxp = Zhikang Zhang 
 ''' % (name, email), file=f)
-f.close();
+f.close()
+
 
 def _UpdateDefaults(main_parser, config):
 """Update the given OptionParser defaults based on config.
@@ -242,8 +243,8 @@ def _UpdateDefaults(main_parser, config):
 # Find all the parsers and subparsers
 parsers = [main_parser]
 parsers += [subparser for action in main_parser._actions
-  if isinstance(action, argparse._SubParsersAction)
-  for _, subparser in action.choices.items()]
+if isinstance(action, argparse._SubParsersAction)
+for _, subparser in action.choices.items()]
 
 # Collect the defaults from each parser
 defaults = {}
@@ -270,8 +271,9 @@ def _UpdateDefaults(main_parser, config):
 # Set all the defaults and manually propagate them to subparsers
 main_parser.set_defaults(**defaults)
 for parser, pdefs in zip(parsers, parser_defaults):
-parser.set_defaults(**{ k: v for k, v in defaults.items()
-if k in pdefs })
+parser.set_defaults(**{k: v for k, v in defaults.items()
+   if k in pdefs})
+
 
 def _ReadAliasFile(fname):
 """Read in the U-Boot git alias file if it exists.
@@ -298,6 +300,7 @@ def _ReadAliasFile(fname):
 if bad_line:
 print(bad_line)
 
+
 def _ReadBouncesFile(fname):
 """Read in the bounces file if it exists
 
@@ -311,6 +314,7 @@ def _ReadBouncesFile(fname):
 continue
 bounces.add(line.strip())
 
+
 def GetItems(config, section):
 """Get the items from a section of the config.
 
@@ -323,10 +327,9 @@ def GetItems(config, section):
 """
 try:
 return config.items(section)
-except ConfigParser.NoSectionError as e:
+except ConfigParser.NoSectionError:
 return []
-except:
-raise
+
 
 def Setup(gitutil, parser, project_name, config_fname=''):
 """Set up the settings module by reading config files.
@@ -358,6 +361,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
 
 _UpdateDefaults(parser, config)
 
+
 # These are the aliases we understand, indexed by alias. Each member is a list.
 alias = {}
 bounces = set()
-- 
2.38.1



[PATCH 0/6] add support for repository-local .patman config file

2022-12-19 Thread Maxim Cournoyer
This series is based on top of series #45.  It adds support for a
.patman config file local to the git repository.  A new test
'test_settings.py' test module is added; it is automatically
discovered and run via pytest, e.g.: 'cd tools/patman && pytest'.


Maxim Cournoyer (6):
  patman: fix pep8 warnings in settings module
  patman: replace deprecated SafeConfigParser with ConfigParser
  patman: import gitutil module where it is needed
  patman: set the default config_fname argument value to None
  patman: fail early in Setup when provided config file does not exist
  patman: additionally honor a local .patman config file

 tools/patman/__main__.py  |   3 +-
 tools/patman/patman.rst   |   8 ++-
 tools/patman/settings.py  | 101 +-
 tools/patman/test_settings.py |  43 +++
 4 files changed, 115 insertions(+), 40 deletions(-)
 create mode 100644 tools/patman/test_settings.py


base-commit: 9bd3d354a1a0712ac27c717df9ad60566b0406ee
prerequisite-patch-id: 10ced6811f0468ea30ab793f3d33a43416dc148c
prerequisite-patch-id: d841542388f09c77a7b22bc7b94d72628408fd7f
prerequisite-patch-id: 414fe8a358404113a0926217fcd75150d1aabaf6
prerequisite-patch-id: 59f0b30f075c78657a17cbbb75af471e37580bdb
prerequisite-patch-id: c7a9c4f2bd34df9da0f173c61fa40bf2f89b6929
prerequisite-patch-id: bd190cf8b6da6e8b20125f957c44cc7f7ea5dd5b
prerequisite-patch-id: 26558d3671f2a854303a959f738dfb67b25f7109
prerequisite-patch-id: 19f2332545f2c338004b1728e5cb15cce32656c0
-- 
2.38.1



[PATCH] board: presidio-asic: Remove CONFIG_TARGET_VENUS

2022-12-19 Thread Michal Simek
Symbol is not defined anywhere that's why remove it.

Signed-off-by: Michal Simek 
---

 board/cortina/presidio-asic/lowlevel_init.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/board/cortina/presidio-asic/lowlevel_init.S 
b/board/cortina/presidio-asic/lowlevel_init.S
index 8d8842ebedfa..220ec79e87e3 100644
--- a/board/cortina/presidio-asic/lowlevel_init.S
+++ b/board/cortina/presidio-asic/lowlevel_init.S
@@ -34,10 +34,8 @@ skip_smp_setup:
 
 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
branch_if_slave x0, 1f
-#ifndef CONFIG_TARGET_VENUS
ldr x0, =GICD_BASE
bl  gic_init_secure
-#endif
 1:
 #if defined(CONFIG_GICV3)
ldr x0, =GICR_BASE
-- 
2.36.1



[PATCH] eficonfig: EFI_VARIABLE_APPEND_WRITE is not set for null key

2022-12-19 Thread Masahisa Kojima
The signed null key with authenticated header is used to clear
the PK, KEK, db and dbx. When CONFIG_EFI_MM_COMM_TEE is enabled
(StMM and OP-TEE based RPMB storage is used as the EFI variable
storage), clearing KEK, db and dbx by enrolling a signed null
key does not work as expected if EFI_VARIABLE_APPEND_WRITE
attritube is set.

This commit checks the selected file is null key, then
EFI_VARIABLE_APPEND_WRITE attibute will not be used for the null key.

Signed-off-by: Masahisa Kojima 
---
 cmd/eficonfig_sbkey.c | 40 ++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/cmd/eficonfig_sbkey.c b/cmd/eficonfig_sbkey.c
index 6e0bebf1d4..bd2671bf8f 100644
--- a/cmd/eficonfig_sbkey.c
+++ b/cmd/eficonfig_sbkey.c
@@ -72,6 +72,30 @@ static bool file_have_auth_header(void *buf, efi_uintn_t 
size)
return true;
 }
 
+/**
+ * file_is_null_key() - check the file is an authenticated and signed null key
+ * @auth:  pointer to the file
+ * @size:  file size
+ * @null_key:  pointer to store the result
+ * Return: status code
+ */
+static efi_status_t file_is_null_key(struct efi_variable_authentication_2 
*auth,
+efi_uintn_t size, bool *null_key)
+{
+   efi_status_t ret = EFI_SUCCESS;
+
+   if (size < (sizeof(auth->time_stamp) + auth->auth_info.hdr.dwLength))
+   return EFI_INVALID_PARAMETER;
+
+   size -= (sizeof(auth->time_stamp) + auth->auth_info.hdr.dwLength);
+   if (size == 0) /* No payload */
+   *null_key = true;
+   else
+   *null_key = false;
+
+   return ret;
+}
+
 /**
  * eficonfig_process_enroll_key() - enroll key into signature database
  *
@@ -84,6 +108,7 @@ static efi_status_t eficonfig_process_enroll_key(void *data)
char *buf = NULL;
efi_uintn_t size;
efi_status_t ret;
+   bool null_key = false;
struct efi_file_handle *f = NULL;
struct efi_device_path *full_dp = NULL;
struct eficonfig_select_file_info file_info;
@@ -149,13 +174,24 @@ static efi_status_t eficonfig_process_enroll_key(void 
*data)
goto out;
}
 
+   ret = file_is_null_key((struct efi_variable_authentication_2 *)buf,
+  size, &null_key);
+   if (ret != EFI_SUCCESS) {
+   eficonfig_print_msg("ERROR! Invalid file format.");
+   goto out;
+   }
+
attr = EFI_VARIABLE_NON_VOLATILE |
   EFI_VARIABLE_BOOTSERVICE_ACCESS |
   EFI_VARIABLE_RUNTIME_ACCESS |
   EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
 
-   /* PK can enroll only one certificate */
-   if (u16_strcmp(data, u"PK")) {
+   /*
+* PK can enroll only one certificate.
+* The signed null key is used to clear KEK, db and dbx.
+* EFI_VARIABLE_APPEND_WRITE attribute must not be set in these cases.
+*/
+   if (u16_strcmp(data, u"PK") && !null_key) {
efi_uintn_t db_size = 0;
 
/* check the variable exists. If exists, add APPEND_WRITE 
attribute */
-- 
2.17.1



[PATCH v2 8/8] patman: document default 'send' command

2022-12-19 Thread Maxim Cournoyer
Document that this command is the default and what it's intended for.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 82cef4fc0b..11f19281fb 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -56,7 +56,8 @@ parser.add_argument('-H', '--full-help', action='store_true', 
dest='full_help',
 default=False, help='Display the README file')
 
 subparsers = parser.add_subparsers(dest='cmd')
-send = subparsers.add_parser('send')
+send = subparsers.add_parser(
+'send', help='Format, check and email patches (default command)')
 send.add_argument('-i', '--ignore-errors', action='store_true',
dest='ignore_errors', default=False,
help='Send patches email even if patch errors are found')
-- 
2.38.1



[PATCH v2 7/8] patman: document how to run test suite via pytest

2022-12-19 Thread Maxim Cournoyer
Pytest offers useful features such as selecting tests by means of a
regular expression, or running the pdb debugger upon encountering a
test failure.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/patman.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 8c5c9cc2cc..b06399b459 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -680,6 +680,12 @@ them:
 
 $ tools/patman/patman test
 
+Alternatively, you can run the test suite via Pytest:
+
+.. code-block:: bash
+
+$ cd tools/patman && pytest
+
 Error handling doesn't always produce friendly error messages - e.g.
 putting an incorrect tag in a commit may provide a confusing message.
 
-- 
2.38.1



[PATCH v2 5/8] patman: add pytest configuration file

2022-12-19 Thread Maxim Cournoyer
With this change, a user can run the patman test suite using Pytest
the same as when using 'patman test':

$ cd tools/patman && pytest
[...]
44 passed, 8 warnings in 8.87s

$ ./patman test
Ran 44 tests in 8.460s

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/pytest.ini | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tools/patman/pytest.ini

diff --git a/tools/patman/pytest.ini b/tools/patman/pytest.ini
new file mode 100644
index 00..df3eb518d0
--- /dev/null
+++ b/tools/patman/pytest.ini
@@ -0,0 +1,2 @@
+[pytest]
+addopts = --doctest-modules
-- 
2.38.1



[PATCH v2 6/8] patman: hide the 'test' action unless test data is available

2022-12-19 Thread Maxim Cournoyer
Some tests would fail when the test data is not available, so it
doesn't make much sense to expose the action when patman is running
outside of the u-boot git checkout.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/__main__.py | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 5a7756a221..82cef4fc0b 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -21,6 +21,7 @@ if __name__ == "__main__":
 # Our modules
 from patman import command
 from patman import control
+from patman import func_test
 from patman import gitutil
 from patman import project
 from patman import settings
@@ -96,9 +97,11 @@ send.add_argument('--smtp-server', type=str,
 
 send.add_argument('patchfiles', nargs='*')
 
-test_parser = subparsers.add_parser('test', help='Run tests')
-test_parser.add_argument('testname', type=str, default=None, nargs='?',
- help="Specify the test to run")
+# Only add the 'test' action if the test data files are available.
+if os.path.exists(func_test.TEST_DATA_DIR):
+test_parser = subparsers.add_parser('test', help='Run tests')
+test_parser.add_argument('testname', type=str, default=None, nargs='?',
+ help="Specify the test to run")
 
 status = subparsers.add_parser('status',
help='Check status of patches in patchwork')
-- 
2.38.1



[PATCH v2 4/8] patman: rename main script to __main__.py

2022-12-19 Thread Maxim Cournoyer
This allows running the package as a Python module, like e.g.:

$ python -m patman

It also prevents Pytest from attempting to parse main.py, which
would cause errors.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/{main.py => __main__.py} | 0
 tools/patman/patman   | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/patman/{main.py => __main__.py} (100%)

diff --git a/tools/patman/main.py b/tools/patman/__main__.py
similarity index 100%
rename from tools/patman/main.py
rename to tools/patman/__main__.py
diff --git a/tools/patman/patman b/tools/patman/patman
index 11a5d8e18a..5a427d1942 12
--- a/tools/patman/patman
+++ b/tools/patman/patman
@@ -1 +1 @@
-main.py
\ No newline at end of file
+__main__.py
\ No newline at end of file
-- 
2.38.1



[PATCH v2 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'

2022-12-19 Thread Maxim Cournoyer
This resolves 10 out of 11 test failures seen when running './patman
test' from the 'tools/patman' subdirectory. This was caused by the
.checkpatch.conf configuration file at the root of the project not
being picked up. Make the test suite of patman independant from it by
always invoking the checkpatch.pl script with the minimally required
arguments for the test suite to pass.

Signed-off-by: Maxim Cournoyer 
---

Changes in v2:
- Reword the commit message with a better explanation of the problem
- Add the '--strict' argument to script invocation

 tools/patman/checkpatch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d1b902dd96..012c0d895c 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -211,7 +211,7 @@ def check_patch(fname, verbose=False, show_types=False, 
use_tree=False):
 stdout: Full output of checkpatch
 """
 chk = find_check_patch()
-args = [chk]
+args = [chk, '--u-boot', '--strict']
 if not use_tree:
 args.append('--no-tree')
 if show_types:
-- 
2.38.1



[PATCH v2 2/8] patman: locate test data files via __file__ and pathlib

2022-12-19 Thread Maxim Cournoyer
Previously it would rely on the executing script location, which could
break for example when running the tests via 'pytest'.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/func_test.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7b92bc67be..7fa4a00786 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -7,6 +7,7 @@
 """Functional tests for checking that patman behaves correctly"""
 
 import os
+import pathlib
 import re
 import shutil
 import sys
@@ -28,6 +29,10 @@ from patman.test_util import capture_sys_output
 import pygit2
 from patman import status
 
+
+TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+
 class TestFunctional(unittest.TestCase):
 """Functional tests for checking that patman behaves correctly"""
 leb = (b'Lord Edmund Blackadd\xc3\xabr '.
@@ -57,8 +62,7 @@ class TestFunctional(unittest.TestCase):
 Returns:
 str: Full path to file in the test directory
 """
-return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-'test', fname)
+return TEST_DATA_DIR / fname
 
 @classmethod
 def _get_text(cls, fname):
-- 
2.38.1



[PATCH v2 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module.

2022-12-19 Thread Maxim Cournoyer
This patch fixes all the PEP 8 warnings reported by Pyflake for the
gitutil module.

Signed-off-by: Maxim Cournoyer 
---

(no changes since v1)

 tools/patman/gitutil.py | 106 
 1 file changed, 65 insertions(+), 41 deletions(-)

diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index ceaf2ce150..74c6e94494 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -2,21 +2,19 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 #
 
-import re
 import os
-import subprocess
 import sys
 
 from patman import command
 from patman import settings
 from patman import terminal
-from patman import tools
 
 # True to use --no-decorate - we check this in setup()
 use_no_decorate = True
 
+
 def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
-   count=None):
+count=None):
 """Create a command to perform a 'git log'
 
 Args:
@@ -49,6 +47,7 @@ def log_cmd(commit_range, git_dir=None, oneline=False, 
reverse=False,
 cmd.append('--')
 return cmd
 
+
 def count_commits_to_branch(branch):
 """Returns number of commits between HEAD and the tracking branch.
 
@@ -68,13 +67,14 @@ def count_commits_to_branch(branch):
 rev_range = '@{upstream}..'
 pipe = [log_cmd(rev_range, oneline=True)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- oneline=True, raise_on_error=False)
+  oneline=True, raise_on_error=False)
 if result.return_code:
 raise ValueError('Failed to determine upstream: %s' %
  result.stderr.strip())
 patch_count = len(result.stdout.splitlines())
 return patch_count
 
+
 def name_revision(commit_hash):
 """Gets the revision name for a commit
 
@@ -91,6 +91,7 @@ def name_revision(commit_hash):
 name = stdout.split(' ')[1].strip()
 return name
 
+
 def guess_upstream(git_dir, branch):
 """Tries to guess the upstream for a branch
 
@@ -109,7 +110,7 @@ def guess_upstream(git_dir, branch):
 """
 pipe = [log_cmd(branch, git_dir=git_dir, oneline=True, count=100)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+  raise_on_error=False)
 if result.return_code:
 return None, "Branch '%s' not found" % branch
 for line in result.stdout.splitlines()[1:]:
@@ -121,6 +122,7 @@ def guess_upstream(git_dir, branch):
 return name, "Guessing upstream as '%s'" % name
 return None, "Cannot find a suitable upstream for branch '%s'" % branch
 
+
 def get_upstream(git_dir, branch):
 """Returns the name of the upstream for a branch
 
@@ -135,10 +137,10 @@ def get_upstream(git_dir, branch):
 """
 try:
 remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
-   'branch.%s.remote' % branch)
+ 'branch.%s.remote' % branch)
 merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
-  'branch.%s.merge' % branch)
-except:
+'branch.%s.merge' % branch)
+except Exception:
 upstream, msg = guess_upstream(git_dir, branch)
 return upstream, msg
 
@@ -149,7 +151,8 @@ def get_upstream(git_dir, branch):
 return '%s/%s' % (remote, leaf), None
 else:
 raise ValueError("Cannot determine upstream branch for branch "
-"'%s' remote='%s', merge='%s'" % (branch, remote, merge))
+ "'%s' remote='%s', merge='%s'"
+ % (branch, remote, merge))
 
 
 def get_range_in_branch(git_dir, branch, include_upstream=False):
@@ -168,6 +171,7 @@ def get_range_in_branch(git_dir, branch, 
include_upstream=False):
 rstr = '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
 return rstr, msg
 
+
 def count_commits_in_range(git_dir, range_expr):
 """Returns the number of commits in the given range.
 
@@ -180,12 +184,13 @@ def count_commits_in_range(git_dir, range_expr):
 """
 pipe = [log_cmd(range_expr, git_dir=git_dir, oneline=True)]
 result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+  raise_on_error=False)
 if result.return_code:
 return None, "Range '%s' not found or is invalid" % range_expr
 patch_count = len(result.stdout.splitlines())
 return patch_count, None
 
+
 def count_commits_in_branch(git_dir, branch, include_upstream=False):
 """Returns the number of commits in the given branch.
 
@@ -201,6 +206,7 @@ def count_commits_in_branch(git_dir, branch, 
include_upstream=False):
 return None, msg
 return count_commits_in_range(git_dir, range_expr)
 
+
 def count_commits(commit_range):
 """R

  1   2   >