[PATCH] Add support for Davicom DM96xx based USB 10/100 ethernet devices

2020-09-12 Thread hyyoxhk
Ported from Linux driver - drivers/net/usb9601.c

Signed-off-by: hyyoxhk 
---
 drivers/usb/eth/Kconfig  | 8 
 drivers/usb/eth/Makefile | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/eth/Kconfig b/drivers/usb/eth/Kconfig
index 2f6bfa8e71..8a47ca0ec4 100644
--- a/drivers/usb/eth/Kconfig
+++ b/drivers/usb/eth/Kconfig
@@ -62,4 +62,12 @@ config USB_ETHER_SMSC95XX
  Say Y here if you would like to support SMSC LAN95xx based USB 2.0
  Ethernet Devices.
 
+config USB_ETHER_DM9601
+   bool "Davicom DM96xx based USB 10/100 ethernet devices"
+   depends on USB_HOST_ETHER
+   depends on DM_ETH
+   ---help---
+ This option adds support for Davicom DM9601/DM9620/DM9621A
+ based USB 10/100 Ethernet adapters.
+
 endif
diff --git a/drivers/usb/eth/Makefile b/drivers/usb/eth/Makefile
index 2e5d0782e8..044b12f028 100644
--- a/drivers/usb/eth/Makefile
+++ b/drivers/usb/eth/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_ETHER_ASIX) += asix.o
 obj-$(CONFIG_USB_ETHER_ASIX88179) += asix88179.o
 obj-$(CONFIG_USB_ETHER_MCS7830) += mcs7830.o
 obj-$(CONFIG_USB_ETHER_SMSC95XX) += smsc95xx.o
+obj-$(CONFIG_USB_ETHER_DM9601) += dm9601.o
 obj-$(CONFIG_USB_ETHER_LAN75XX) += lan7x.o lan75xx.o
 obj-$(CONFIG_USB_ETHER_LAN78XX) += lan7x.o lan78xx.o
 obj-$(CONFIG_USB_ETHER_RTL8152) += r8152.o r8152_fw.o
-- 
2.17.1




[PATCH] lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

2020-09-12 Thread Marek Vasut
Repair incorrectly negated condition in the original patch which broke
DT memory node parsing on everything which has more than one DT memory
node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original
patch would complete parsing cycle for the first memory node, then move
on to the next one, identify it as a valid, and end the parsing. The fix
is to invert the condition, to make the code behave as it did before the
livetree conversion, so it would continue parsing the subsequent memory
nodes as well.

Fixes: c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Signed-off-by: Marek Vasut 
Cc: Michal Simek 
Cc: Simon Glass 
Cc: Tom Rini 
---
 lib/fdtdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d3b22ec323..5f41f58a63 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
if (ret < 0) {
reg = 0;
mem = get_next_memory_node(mem);
-   if (ofnode_valid(mem))
+   if (!ofnode_valid(mem))
break;
 
ret = ofnode_read_resource(mem, reg++, );
@@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
if (ret < 0) {
reg = 0;
mem = get_next_memory_node(mem);
-   if (ofnode_valid(mem))
+   if (!ofnode_valid(mem))
break;
 
ret = ofnode_read_resource(mem, reg++, );
-- 
2.28.0



Re: [PATCH 1/1] cmd/button: return button status

2020-09-12 Thread Tom Rini
On Wed, Sep 02, 2020 at 10:08:26PM +0200, Heinrich Schuchardt wrote:

> To make the button command useful in a shell script it should return the
> status of the button:
> 
> * 0 (true) - pressed, on
> * 1 (false) - not pressed, off
> 
> The button command takes only one argument. Correct maxargs.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Philippe Reynes 
> ---
>  cmd/button.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --
> 2.28.0
> 
> diff --git a/cmd/button.c b/cmd/button.c
> index 84ad1653c7..64c5a8fa04 100644
> --- a/cmd/button.c
> +++ b/cmd/button.c
> @@ -75,11 +75,11 @@ int do_button(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
> 
>   ret = show_button_state(dev);
> 
> - return 0;
> + return !ret;
>  }
> 
>  U_BOOT_CMD(
> - button, 4, 1, do_button,
> + button, 2, 1, do_button,
>   "manage buttons",
>   " \tGet button state\n"
>   "button list\t\tShow a list of buttons"

This in turn breaks the current button test, which I believe needs to be
updated to match.  Thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 0/3] binman: Further updates for FIT support

2020-09-12 Thread Samuel Holland
On 9/7/20 3:44 AM, Michal Simek wrote:
> Hi Simon,
> 
> On 06. 09. 20 18:39, Simon Glass wrote:
>> This series adds support for help messages when binary blobs are missing,
>> as well as selecting the default FIT configuration.
>>
>> It includes the v3 patches from the earlier series that were not applied.
>>
>> Note: This series is available at u-boot-dm/binman-working and is based
>> on u-boot-dm/next
>>
>> Changes in v4:
>> - Add more documentation for DEFAULT-SEQ
>> - Drop patches previous applied to u-boot-dm/next
>>
>> Changes in v3:
>> - Add a way to show help messages for missing blobs
>> - Rebase on top of earlier binman series
>>
>> Changes in v2:
>> - Add new patch to allow selecting default FIT configuration
>>
>> Simon Glass (3):
>>   binman: Allow selecting default FIT configuration
>>   binman: Support help messages for missing blobs
>>   binman: sunxi: Add help message for missing sunxi ATF BL31
>>
>>  Makefile  |  2 +
>>  arch/arm/dts/sunxi-u-boot.dtsi|  1 +
>>  tools/binman/README   |  6 ++
>>  tools/binman/README.entries   |  4 ++
>>  tools/binman/control.py   | 69 ++-
>>  tools/binman/entry.py |  9 +++
>>  tools/binman/etype/fit.py | 26 +++
>>  tools/binman/ftest.py | 59 ++--
>>  tools/binman/missing-blob-help| 15 
>>  tools/binman/test/168_fit_missing_blob.dts|  9 ++-
>>  .../test/{170_fit_fdt.dts => 172_fit_fdt.dts} |  2 +-
>>  11 files changed, 195 insertions(+), 7 deletions(-)
>>  create mode 100644 tools/binman/missing-blob-help
>>  rename tools/binman/test/{170_fit_fdt.dts => 172_fit_fdt.dts} (95%)
>>
> 
> I just spot one thing and will be good to clearify it.
> 
> In sunxi this description is used.
> + firmware = "uboot";
> + loadables = "atf";
> 
> But is this right way how this should be described?

No, this is backwards. I have sent a patch to fix this along with the script it
was copied from:

https://patchwork.ozlabs.org/project/uboot/patch/20200906032615.40448-8-sam...@sholland.org/

Cheers,
Samuel

> I personally use firmware which points to ATF and loadables which points
> to uboot. Not sure what sunxi is doing but also in spl_fit.c there is a
> comment about it.
>   /*
>* Find the U-Boot image using the following search order:
>*   - start at 'firmware' (e.g. an ARM Trusted Firmware)
>*   - fall back 'kernel' (e.g. a Falcon-mode OS boot
>*   - fall back to using the first 'loadables' entry
>*/
> 
> Thanks,
> Michal
> 
> 
> 



[PATCH 0/3] log: Fix segfault in sandbox when LOG_LEVEL_DEFAULT >= LOGL_DEBUG

2020-09-12 Thread Sean Anderson
Since the syslog feature has been introduced, sandbox no longer boots when
LOG_LEVEL_DEFAULT prints cdebug messages. This is because it tries to call
net_init before initf_dm.


Sean Anderson (3):
  dev: Disambiguate errors in uclass_find
  net: Expose some errors generated in net_init
  log: syslog: Handle errors in net_init

 common/log_syslog.c   |  4 +++-
 drivers/core/uclass.c | 16 +++-
 include/net.h |  2 +-
 net/eth-uclass.c  |  3 +++
 net/net.c | 15 +++
 test/dm/core.c|  2 +-
 test/dm/test-main.c   |  2 +-
 7 files changed, 35 insertions(+), 9 deletions(-)

-- 
2.28.0



[PATCH 2/3] net: Expose some errors generated in net_init

2020-09-12 Thread Sean Anderson
net_init does not always succeed, and there is no existing mechanism to
discover errors. This patch allows callers of net_init (such as net_init)
to handle errors. The root issue is that eth_get_dev can fail, but
net_init_loop doesn't expose that. The ideal way to fix eth_get_dev would
be to return an error with ERR_PTR, but there are a lot of callers, and all
of them just check if it's NULL. Another approach would be to change the
signature to something like

int eth_get_dev(struct udevice **pdev)

but that would require rewriting all of the many callers.

Signed-off-by: Sean Anderson 
---

 include/net.h|  2 +-
 net/eth-uclass.c |  3 +++
 net/net.c| 15 +++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/net.h b/include/net.h
index 1bf9867f8c..b80b13ae7c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -593,7 +593,7 @@ extern int net_ntp_time_offset; /* 
offset time from UTC */
 #endif
 
 /* Initialize the network adapter */
-void net_init(void);
+int net_init(void);
 int net_loop(enum proto_t);
 
 /* Load failed. Start again. */
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 0d9b75a9a2..1f59d24f54 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -75,6 +75,9 @@ struct udevice *eth_get_dev(void)
struct eth_uclass_priv *uc_priv;
 
uc_priv = eth_get_uclass_priv();
+   if (!uc_priv)
+   return NULL;
+
if (!uc_priv->current)
eth_errno = uclass_first_device(UCLASS_ETH,
_priv->current);
diff --git a/net/net.c b/net/net.c
index 28d9eebf9d..3afd0d6fb0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -353,12 +353,19 @@ void net_auto_load(void)
tftp_start(TFTPGET);
 }
 
-static void net_init_loop(void)
+static int net_init_loop(void)
 {
if (eth_get_dev())
memcpy(net_ethaddr, eth_get_ethaddr(), 6);
+   else
+   /*
+* Not ideal, but there's no way to get the actual error, and I
+* don't feel like fixing all the users of eth_get_dev to deal
+* with errors.
+*/
+   return -ENONET;
 
-   return;
+   return 0;
 }
 
 static void net_clear_handlers(void)
@@ -373,7 +380,7 @@ static void net_cleanup_loop(void)
net_clear_handlers();
 }
 
-void net_init(void)
+int net_init(void)
 {
static int first_call = 1;
 
@@ -396,7 +403,7 @@ void net_init(void)
first_call = 0;
}
 
-   net_init_loop();
+   return net_init_loop();
 }
 
 /**/
-- 
2.28.0



[PATCH 3/3] log: syslog: Handle errors in net_init

2020-09-12 Thread Sean Anderson
Since the previous patch, net_init now exposes some errors, so check for
them.

Signed-off-by: Sean Anderson 
---

 common/log_syslog.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/log_syslog.c b/common/log_syslog.c
index 149ff5af31..aaa0fcfa48 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -46,7 +46,9 @@ static int log_syslog_emit(struct log_device *ldev, struct 
log_rec *rec)
processing_msg = 1;
 
/* Setup packet buffers */
-   net_init();
+   ret = net_init();
+   if (ret)
+   return ret;
/* Disable hardware and put it into the reset state */
eth_halt();
/* Set current device according to environment variables */
-- 
2.28.0



[PATCH v4 7/9] sunxi: binman: Update FIT component descriptions

2020-09-12 Thread Samuel Holland
Since commit d879616e9e64 ("spl: fit: simplify logic for FDT loading for
non-OS boots"), the SPL looks at the "os" properties of FIT images to
determine where to append the FDT.

The "os" property of the "firmware" image also determines how to execute
the next stage of the boot process, as in 1d3790905d9c ("spl: atf:
introduce spl_invoke_atf and make bl31_entry private"). For this reason,
the next stage must be specified in "firmware", not in "loadables".

To support this additional functionality, and to properly model the boot
process, where ATF runs before U-Boot, add the "os" properties and swap
the firmware/loadable images in the FIT image.

Since this description was copied as an example in commit 70248d6a2916
("binman: Support generating FITs with multiple dtbs"), update those
examples as well for correctness and consistency.

Acked-by: Patrick Wildt 
Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 6 --
 tools/binman/README.entries| 4 ++--
 tools/binman/etype/fit.py  | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 4d599720382..ff3fff599f4 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -35,6 +35,7 @@
uboot {
description = "U-Boot (64-bit)";
type = "standalone";
+   os = "u-boot";
arch = "arm64";
compression = "none";
load = <0x4a00>;
@@ -46,6 +47,7 @@
atf {
description = "ARM Trusted Firmware";
type = "firmware";
+   os = "arm-trusted-firmware";
arch = "arm64";
compression = "none";
load = ;
@@ -68,8 +70,8 @@
 
@config-SEQ {
description = "NAME";
-   firmware = "uboot";
-   loadables = "atf";
+   firmware = "atf";
+   loadables = "uboot";
fdt = "fdt-SEQ";
};
};
diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index d2628dffd5d..c45aed0a681 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -385,8 +385,8 @@ You can create config nodes in a similar way:
 default = "@config-DEFAULT-SEQ";
 @config-SEQ {
 description = "NAME";
-firmware = "uboot";
-loadables = "atf";
+firmware = "atf";
+loadables = "uboot";
 fdt = "fdt-SEQ";
 };
 };
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 01fa51367e6..73793ecda31 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -73,8 +73,8 @@ class Entry_fit(Entry):
 default = "@config-DEFAULT-SEQ";
 @config-SEQ {
 description = "NAME";
-firmware = "uboot";
-loadables = "atf";
+firmware = "atf";
+loadables = "uboot";
 fdt = "fdt-SEQ";
 };
 };
-- 
2.26.2



[PATCH v4 3/9] spl: fit: Minimally parse OS properties with FIT_IMAGE_TINY

2020-09-12 Thread Samuel Holland
Some boards, specifically 64-bit Allwinner boards (sun50i), are
extremely limited on SPL size. One strategy that was used to make space
was to remove the FIT "os" property parsing code, because it uses a
rather large lookup table.

However, this forces the legacy FIT parsing code path, which requires
the "firmware" entry in the FIT to reference the U-Boot binary, even if
U-Boot is not the next binary in the boot sequence (for example, on
sun50i boards, ATF is run first).

This prevents the same FIT image from being used with a SPL with
CONFIG_SPL_FIT_IMAGE_TINY=n and CONFIG_SPL_ATF=y, because the boot
method selection code looks at `spl_image.os`, which is only set from
the "firmware" entry's "os" property.

To be able to use CONFIG_SPL_ATF=y, the "firmware" entry in the FIT
must be ATF, and U-Boot must be a loadable. For this to work, we need to
parse the "os" property just enough to tell U-Boot from other images, so
we can find it in the loadables list to append the FDT, and so we don't
try to append the FDT to ATF (which could clobber adjacent firmware).

So add the minimal code necessary to distinguish U-Boot/non-U-Boot
loadables with CONFIG_SPL_FIT_IMAGE_TINY=y. This adds about 300 bytes,
much less than the 7400 bytes added by CONFIG_SPL_FIT_IMAGE_TINY=n.

Acked-by: Patrick Wildt 
Signed-off-by: Samuel Holland 
---
 common/spl/Kconfig   |  4 +---
 common/spl/spl_fit.c | 17 -
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index af8255a8d6a..041b47244bd 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -465,9 +465,7 @@ config SPL_FIT_IMAGE_TINY
  Enable this to reduce the size of the FIT image loading code
  in SPL, if space for the SPL binary is very tight.
 
- This removes the detection of image types (which forces the
- first image to be treated as having a U-Boot style calling
- convention) and skips the recording of each loaded payload
+ This skips the recording of each loaded payload
  (i.e. loadable) into the FDT (modifying the loaded FDT to
  ensure this information is available to the next image
  invoked).
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 365104fe028..a31ab6c5992 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -466,7 +466,22 @@ static int spl_fit_record_loadable(const void *fit, int 
images, int index,
 static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
 {
 #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT)
-   return -ENOTSUPP;
+   const char *name = fdt_getprop(fit, noffset, FIT_OS_PROP, NULL);
+
+   if (!name)
+   return -ENOENT;
+
+   /*
+* We don't care what the type of the image actually is,
+* only whether or not it is U-Boot. This saves some
+* space by omitting the large table of OS types.
+*/
+   if (!strcmp(name, "u-boot"))
+   *os = IH_OS_U_BOOT;
+   else
+   *os = IH_OS_INVALID;
+
+   return 0;
 #else
return fit_image_get_os(fit, noffset, os);
 #endif
-- 
2.26.2



[PATCH v4 8/9] binman: Add support for SCP firmware

2020-09-12 Thread Samuel Holland
Add an entry type for a firmware blob for a Sytem Control Processor,
given by an entry arg. This firmware is a raw binary blob.

Signed-off-by: Samuel Holland 
---
 Makefile  |  2 +-
 tools/binman/etype/scp.py | 19 +++
 tools/binman/ftest.py |  7 +++
 tools/binman/test/172_scp.dts | 16 
 4 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/etype/scp.py
 create mode 100644 tools/binman/test/172_scp.dts

diff --git a/Makefile b/Makefile
index d5aa8605c0a..5a6681f129e 100644
--- a/Makefile
+++ b/Makefile
@@ -1328,7 +1328,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
$(BINMAN_DEBUG),-D) \
build -u -d u-boot.dtb -O . -m --allow-missing \
-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
-I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \
-   -a atf-bl31-path=${BL31} \
+   -a atf-bl31-path=${BL31} -a scp-path=${SCP} \
$(BINMAN_$(@F))
 
 OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
diff --git a/tools/binman/etype/scp.py b/tools/binman/etype/scp.py
new file mode 100644
index 000..93f8787d2d7
--- /dev/null
+++ b/tools/binman/etype/scp.py
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2020 Samuel Holland 
+#
+# Entry-type module for System Control Processor (SCP) firmware blob
+#
+
+from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg
+
+class Entry_scp(Entry_blob_named_by_arg):
+"""Entry containing a System Control Processor (SCP) firmware blob
+
+Properties / Entry arguments:
+- scp-path: Filename of file to read into the entry, typically scp.bin
+
+This entry holds firmware for an external platform-specific coprocessor.
+"""
+def __init__(self, section, etype, node):
+super().__init__(section, etype, node, 'scp')
+self.external = True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 78d0e9c2b93..72e738913eb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -75,6 +75,7 @@ FSP_M_DATA= b'fsp_m'
 FSP_S_DATA= b'fsp_s'
 FSP_T_DATA= b'fsp_t'
 ATF_BL31_DATA = b'bl31'
+SCP_DATA  = b'scp'
 TEST_FDT1_DATA= b'fdt1'
 TEST_FDT2_DATA= b'test-fdt2'
 
@@ -174,6 +175,7 @@ class TestFunctional(unittest.TestCase):
 
 TestFunctional._MakeInputFile('compress', COMPRESS_DATA)
 TestFunctional._MakeInputFile('bl31.bin', ATF_BL31_DATA)
+TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
 
 # Add a few .dtb files for testing
 TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR,
@@ -3575,6 +3577,11 @@ class TestFunctional(unittest.TestCase):
 data = self._DoReadFile('169_atf_bl31.dts')
 self.assertEqual(ATF_BL31_DATA, data[:len(ATF_BL31_DATA)])
 
+def testPackScp(self):
+"""Test that an image with an SCP binary can be created"""
+data = self._DoReadFile('172_scp.dts')
+self.assertEqual(SCP_DATA, data[:len(SCP_DATA)])
+
 def testFitFdt(self):
 """Test an image with an FIT with multiple FDT images"""
 def _CheckFdt(seq, expected_data):
diff --git a/tools/binman/test/172_scp.dts b/tools/binman/test/172_scp.dts
new file mode 100644
index 000..354e4ef17df
--- /dev/null
+++ b/tools/binman/test/172_scp.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   size = <16>;
+
+   scp {
+   filename = "scp.bin";
+   };
+   };
+};
-- 
2.26.2



[PATCH v4 2/9] binman: Only write FDT once per node

2020-09-12 Thread Samuel Holland
Due to an extra level of indentation, the "data" property containing the
FDT was being written repeatedly after every other property in the node.
Move the block up one level, so the property is added exactly once.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 tools/binman/etype/fit.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index c291eb26bad..01fa51367e6 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -179,10 +179,10 @@ class Entry_fit(Entry):
 b'SEQ', tools.ToBytes(str(seq + 1)))
 fsw.property(pname, val)
 
-# Add data for 'fdt' nodes (but not 
'config')
-if depth == 1 and in_images:
-fsw.property('data',
- tools.ReadFile(fname))
+# Add data for 'fdt' nodes (but not 'config')
+if depth == 1 and in_images:
+fsw.property('data',
+ tools.ReadFile(fname))
 else:
 if self._fdts is None:
 if self._fit_list_prop:
-- 
2.26.2



[PATCH v4 6/9] sunxi: binman: Use a macro for the BL31 load address

2020-09-12 Thread Samuel Holland
This consolidates the SoC-specific part at the top of the file to avoid
cluttering it up with preprocessor conditions.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 6ab0c783ba5..4d599720382 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -1,5 +1,11 @@
 #include 
 
+#ifdef CONFIG_MACH_SUN50I_H6
+#define BL31_ADDR 0x104000
+#else
+#define BL31_ADDR  0x44000
+#endif
+
 / {
aliases {
mmc1 = 
@@ -42,14 +48,8 @@
type = "firmware";
arch = "arm64";
compression = "none";
-/* TODO: Do this with an overwrite in this board's dtb? */
-#ifdef CONFIG_MACH_SUN50I_H6
-   load = <0x104000>;
-   entry = <0x104000>;
-#else
-   load = <0x44000>;
-   entry = <0x44000>;
-#endif
+   load = ;
+   entry = ;
 
atf-bl31 {
filename = "bl31.bin";
-- 
2.26.2



Re: [PATCH 4/4] log: Disable the syslog driver by default

2020-09-12 Thread Heinrich Schuchardt
Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass :
>This driver interferes with other sandbox tests since it causes log
>output
>to be interspersed with "No ethernet found." messages. Disable this
>driver
>by default.
>
>Enable it for the syslog tests so that they still pass.
>
>Signed-off-by: Simon Glass 
>---
>
> common/log_syslog.c   |  1 -
> test/log/syslog_test.c| 24 
> test/log/syslog_test.h| 16 
> test/log/syslog_test_ndebug.c |  2 ++
> 4 files changed, 42 insertions(+), 1 deletion(-)
>
>diff --git a/common/log_syslog.c b/common/log_syslog.c
>index cf0dbba9bf5..149ff5af310 100644
>--- a/common/log_syslog.c
>+++ b/common/log_syslog.c
>@@ -115,5 +115,4 @@ out:
> LOG_DRIVER(syslog) = {
>   .name   = "syslog",
>   .emit   = log_syslog_emit,
>-  .flags  = LOGDF_ENABLE,

What does the flag removal change outside Python testing?

Best regards

Heinrich

> };
>diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c
>index abcb9ffd28b..febaca68e8d 100644
>--- a/test/log/syslog_test.c
>+++ b/test/log/syslog_test.c
>@@ -56,6 +56,20 @@ int sb_log_tx_handler(struct udevice *dev, void
>*packet, unsigned int len)
>   return 0;
> }
> 
>+int syslog_test_setup(struct unit_test_state *uts)
>+{
>+  ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), true));
>+
>+  return 0;
>+}
>+
>+int syslog_test_finish(struct unit_test_state *uts)
>+{
>+  ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), false));
>+
>+  return 0;
>+}
>+
> /**
>  * log_test_syslog_err() - test log_err() function
>  *
>@@ -67,6 +81,7 @@ static int log_test_syslog_err(struct unit_test_state
>*uts)
>   int old_log_level = gd->default_log_level;
>   struct sb_log_env env;
> 
>+  ut_assertok(syslog_test_setup(uts));
>   gd->log_fmt = LOGF_TEST;
>   gd->default_log_level = LOGL_INFO;
>   env_set("ethact", "eth@10002000");
>@@ -82,6 +97,7 @@ static int log_test_syslog_err(struct unit_test_state
>*uts)
>   sandbox_eth_set_tx_handler(0, NULL);
>   gd->default_log_level = old_log_level;
>   gd->log_fmt = log_get_default_format();
>+  ut_assertok(syslog_test_finish(uts));
> 
>   return 0;
> }
>@@ -98,6 +114,7 @@ static int log_test_syslog_warning(struct
>unit_test_state *uts)
>   int old_log_level = gd->default_log_level;
>   struct sb_log_env env;
> 
>+  ut_assertok(syslog_test_setup(uts));
>   gd->log_fmt = LOGF_TEST;
>   gd->default_log_level = LOGL_INFO;
>   env_set("ethact", "eth@10002000");
>@@ -114,6 +131,7 @@ static int log_test_syslog_warning(struct
>unit_test_state *uts)
>   ut_assertnull(env.expected);
>   gd->default_log_level = old_log_level;
>   gd->log_fmt = log_get_default_format();
>+  ut_assertok(syslog_test_finish(uts));
> 
>   return 0;
> }
>@@ -130,6 +148,7 @@ static int log_test_syslog_notice(struct
>unit_test_state *uts)
>   int old_log_level = gd->default_log_level;
>   struct sb_log_env env;
> 
>+  ut_assertok(syslog_test_setup(uts));
>   gd->log_fmt = LOGF_TEST;
>   gd->default_log_level = LOGL_INFO;
>   env_set("ethact", "eth@10002000");
>@@ -146,6 +165,7 @@ static int log_test_syslog_notice(struct
>unit_test_state *uts)
>   ut_assertnull(env.expected);
>   gd->default_log_level = old_log_level;
>   gd->log_fmt = log_get_default_format();
>+  ut_assertok(syslog_test_finish(uts));
> 
>   return 0;
> }
>@@ -162,6 +182,7 @@ static int log_test_syslog_info(struct
>unit_test_state *uts)
>   int old_log_level = gd->default_log_level;
>   struct sb_log_env env;
> 
>+  ut_assertok(syslog_test_setup(uts));
>   gd->log_fmt = LOGF_TEST;
>   gd->default_log_level = LOGL_INFO;
>   env_set("ethact", "eth@10002000");
>@@ -178,6 +199,7 @@ static int log_test_syslog_info(struct
>unit_test_state *uts)
>   ut_assertnull(env.expected);
>   gd->default_log_level = old_log_level;
>   gd->log_fmt = log_get_default_format();
>+  ut_assertok(syslog_test_finish(uts));
> 
>   return 0;
> }
>@@ -194,6 +216,7 @@ static int log_test_syslog_debug(struct
>unit_test_state *uts)
>   int old_log_level = gd->default_log_level;
>   struct sb_log_env env;
> 
>+  ut_assertok(syslog_test_setup(uts));
>   gd->log_fmt = LOGF_TEST;
>   gd->default_log_level = LOGL_DEBUG;
>   env_set("ethact", "eth@10002000");
>@@ -210,6 +233,7 @@ static int log_test_syslog_debug(struct
>unit_test_state *uts)
>   ut_assertnull(env.expected);
>   gd->default_log_level = old_log_level;
>   gd->log_fmt = log_get_default_format();
>+  ut_assertok(syslog_test_finish(uts));
> 
>   return 0;
> }
>diff --git a/test/log/syslog_test.h b/test/log/syslog_test.h
>index 75900f3aad3..1310257bfe1 100644
>--- a/test/log/syslog_test.h
>+++ b/test/log/syslog_test.h
>@@ -47,4 +47,20 @@ struct sb_log_env {
>  */
>int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned 

[PATCH v4 9/9] sunxi: binman: Add support for including SCP firmware

2020-09-12 Thread Samuel Holland
Allwinner sun50i SoCs contain an OpenRISC 1000 CPU that functions as a
System Control Processor, or SCP. ARM Trusted Firmware (ATF)
communicates with the SCP over SCPI to implement the PSCI system
suspend, shutdown and reset functionality. Currently, SCP firmware is
optional; the system will boot and run without it, but system suspend
will be unavailable.

Since all communication with the SCP is mediated by ATF, the only thing
U-Boot needs to do is load the firmware into SRAM. The SCP firmware
occupies the last 16KiB of SRAM A2, immediately following ATF.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 16 -
 board/sunxi/README.sunxi64 | 43 --
 2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index ff3fff599f4..5ab7c6c23b7 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -2,8 +2,10 @@
 
 #ifdef CONFIG_MACH_SUN50I_H6
 #define BL31_ADDR 0x104000
+#define  SCP_ADDR 0x114000
 #else
 #define BL31_ADDR  0x44000
+#define  SCP_ADDR  0x5
 #endif
 
 / {
@@ -58,6 +60,18 @@
};
};
 
+   scp {
+   description = "SCP firmware";
+   type = "firmware";
+   arch = "or1k";
+   compression = "none";
+   load = ;
+
+   scp {
+   filename = "scp.bin";
+   };
+   };
+
@fdt-SEQ {
description = "NAME";
type = "flat_dt";
@@ -71,7 +85,7 @@
@config-SEQ {
description = "NAME";
firmware = "atf";
-   loadables = "uboot";
+   loadables = "scp", "uboot";
fdt = "fdt-SEQ";
};
};
diff --git a/board/sunxi/README.sunxi64 b/board/sunxi/README.sunxi64
index 258921af22d..9a67e5301eb 100644
--- a/board/sunxi/README.sunxi64
+++ b/board/sunxi/README.sunxi64
@@ -14,8 +14,12 @@ Quick Start / Overview
 - Build the ARM Trusted Firmware binary (see "ARM Trusted Firmware (ATF)" 
below)
   $ cd /src/arm-trusted-firmware
   $ make PLAT=sun50i_a64 DEBUG=1 bl31
+- Build the SCP firmware binary (see "SCP firmware (Crust)" below)
+  $ cd /src/crust
+  $ make pine64_plus_defconfig && make -j5 scp
 - Build U-Boot (see "SPL/U-Boot" below)
   $ export BL31=/path/to/bl31.bin
+  $ export SCP=/src/crust/build/scp/scp.bin
   $ make pine64_plus_defconfig && make -j5
 - Transfer to an uSD card (see "microSD card" below)
   $ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdx bs=8k seek=1
@@ -24,13 +28,17 @@ Quick Start / Overview
 Building the firmware
 =
 
-The Allwinner A64/H5 firmware consists of three parts: U-Boot's SPL, an
-ARM Trusted Firmware (ATF) build and the U-Boot proper.
-The SPL will load both ATF and U-Boot proper along with the right device
-tree blob (.dtb) and will pass execution to ATF (in EL3), which in turn will
-drop into the U-Boot proper (in EL2).
-As the ATF binary will become part of the U-Boot image file, you will need
-to build it first.
+The Allwinner A64/H5/H6 firmware consists of several parts: U-Boot's SPL,
+ARM Trusted Firmware (ATF), optional System Control Processor (SCP) firmware
+(e.g. Crust), and the U-Boot proper.
+
+The SPL will load all of the other firmware binaries into RAM, along with the
+right device tree blob (.dtb), and will pass execution to ATF (in EL3). If SCP
+firmware was loaded, ATF will power on the SCP and wait for it to boot.
+ATF will then drop into U-Boot proper (in EL2).
+
+As the ATF binary and SCP firmware will become part of the U-Boot image file,
+you will need to build them first.
 
  ARM Trusted Firmware (ATF)
 
@@ -53,6 +61,27 @@ As sometimes the ATF build process is a bit picky about the 
toolchain used,
 or if you can't be bothered with building ATF, there are known working
 binaries in the firmware repository[3], purely for convenience reasons.
 
+ SCP firmware (Crust)
+--
+SCP firmware is responsible for implementing system suspend/resume, and (on
+boards without a PMIC) soft poweroff/on. ATF contains fallback code for CPU
+power control, so SCP firmware is optional if you don't need either of these
+features. It runs on the AR100, with is an or1k CPU, not ARM, so it needs a
+different cross toolchain.
+
+There is one SCP firmware 

[PATCH v4 1/9] Makefile: Only define u-boot.itb rule when applicable

2020-09-12 Thread Samuel Holland
If neither CONFIG_SPL_FIT_SOURCE nor CONFIG_USE_SPL_FIT_GENERATOR is
enabled, U_BOOT_ITS will be undefined, and attempting to make u-boot.itb
will pass invalid arguments to mkimage, causing it to print its help
message.

Remove the rule in that case, so it is more obvious that u-boot.itb is
not something that can be made. This will reduce confusion as platforms
move away from CONFIG_USE_SPL_FIT_GENERATOR, as u-boot.itb was
previously a valid goal for those platforms.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index 65024c74089..d5aa8605c0a 100644
--- a/Makefile
+++ b/Makefile
@@ -1438,11 +1438,13 @@ else
 MKIMAGEFLAGS_u-boot.itb = -E
 endif
 
+ifdef U_BOOT_ITS
 u-boot.itb: u-boot-nodtb.bin \
$(if 
$(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \
$(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)
+endif
 
 u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
-- 
2.26.2



[PATCH v4 5/9] sunxi: binman: Provide a default BL31 filename

2020-09-12 Thread Samuel Holland
Prior to commit 7f7f8aca8257 ("sunxi: Convert 64-bit boards to use
binman"), if the BL31 environment variable was not defined, the firmware
would be loaded from a file "bl31.bin" in the current directory. Restore
that behavior by providing that as the default filename in case no entry
arg is provided, which will be the case if the environment variable is
unset.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 82b97a9503f..6ab0c783ba5 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -52,6 +52,7 @@
 #endif
 
atf-bl31 {
+   filename = "bl31.bin";
};
};
 
-- 
2.26.2



[PATCH v4 0/9] sunxi: binman fixes and SCP firmware support

2020-09-12 Thread Samuel Holland
This is a rework of my previous patch series adding SCP firmware support
for system suspend, on top of the binman rewrite of mksunxi_fit_atf.sh.

This patch series is based on u-boot-dm/next.

- The first two patches apply to binman FIT support generally.
- The third patch is unchanged from previous versions.
- Patches 4-6 fix small issues in the new sunxi binman description.
- Patches 7-9 implement the same functionality as previous versions
  of this series, but using binman instead of a shell script.

Changes v3->v4:
- Added a test for the SCP firmware entry type.

Samuel Holland (9):
  Makefile: Only define u-boot.itb rule when applicable
  binman: Only write FDT once per node
  spl: fit: Minimally parse OS properties with FIT_IMAGE_TINY
  sunxi: binman: Fix spacing between nodes
  sunxi: binman: Provide a default BL31 filename
  sunxi: binman: Use a macro for the BL31 load address
  sunxi: binman: Update FIT component descriptions
  binman: Add support for SCP firmware
  sunxi: binman: Add support for including SCP firmware

 Makefile   |  4 +++-
 arch/arm/dts/sunxi-u-boot.dtsi | 42 +
 board/sunxi/README.sunxi64 | 43 --
 common/spl/Kconfig |  4 +---
 common/spl/spl_fit.c   | 17 +-
 tools/binman/README.entries|  4 ++--
 tools/binman/etype/fit.py  | 12 +-
 tools/binman/etype/scp.py  | 19 +++
 tools/binman/ftest.py  |  7 ++
 tools/binman/test/172_scp.dts  | 16 +
 10 files changed, 138 insertions(+), 30 deletions(-)
 create mode 100644 tools/binman/etype/scp.py
 create mode 100644 tools/binman/test/172_scp.dts

-- 
2.26.2



[PATCH v4 4/9] sunxi: binman: Fix spacing between nodes

2020-09-12 Thread Samuel Holland
Nodes should have a blank line separating them from sibling nodes and
properties. Add the necessary lines.

Reviewed-by: Simon Glass 
Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 1d1c3691099..82b97a9503f 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -14,9 +14,11 @@
u-boot-sunxi-with-spl {
filename = "u-boot-sunxi-with-spl.bin";
pad-byte = <0xff>;
+
blob {
filename = "spl/sunxi-spl.bin";
};
+
 #ifdef CONFIG_ARM64
fit {
description = "Configuration to load ATF before U-Boot";
@@ -34,6 +36,7 @@
u-boot-nodtb {
};
};
+
atf {
description = "ARM Trusted Firmware";
type = "firmware";
@@ -47,6 +50,7 @@
load = <0x44000>;
entry = <0x44000>;
 #endif
+
atf-bl31 {
};
};
@@ -60,6 +64,7 @@
 
configurations {
default = "config-1";
+
@config-SEQ {
description = "NAME";
firmware = "uboot";
-- 
2.26.2



[PATCH 1/3] dev: Disambiguate errors in uclass_find

2020-09-12 Thread Sean Anderson
There are two cases where uclass_find can return an error. The second is
when the uclass has not yet been init'd. The first is when the driver model
has not been init'd (or has been only partially init'd) and there is no
root uclass driver.

If LOG_SYSLOG is enabled and LOG_DEFAULT_LEVEL is set to LOGL_DEBUG or
higher, log_syslog_emit will try to call net_init before initf_dm has been
called. This in turn (eventually) calls uclass_get for UCLASS_ETH.

If the second error occurs, uclass_get should call uclass_add to create the
uclass. If the first error occurs, then uclass_get should not call
uclass_add (because the uclass list has not been initialized). However, the
first error is expected when calling uclass_get for UCLASS_ROOT, so we add
an exception.

There are several alternative approaches to this patch. One option would be
to duplicate the check against gd->dm_root in uclass_get and not change the
behavior of uclass_find. I did not choose this approach because I think it
it is less clear than the patch as-is. However, that is certainly
subjective, and there is no other technical reason to do it this way.

Another approach would have been to change log_syslog_emit to abort if it
is called too early. I did not choose this approach because the check in
uclass_find to see if gd->dm_root exists implies that functions in its
file are allowed to be called at any time. There is an argument to be made
that callers should ensure that they don't call certain functions too
early. I think it is better to code defensively in these circumstances to
make it easier to discover such errors.

Signed-off-by: Sean Anderson 
---

 drivers/core/uclass.c | 16 +++-
 test/dm/core.c|  2 +-
 test/dm/test-main.c   |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index c3f1b73cd6..2e098034c9 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -27,7 +28,7 @@ struct uclass *uclass_find(enum uclass_id key)
struct uclass *uc;
 
if (!gd->dm_root)
-   return NULL;
+   return ERR_PTR(-EAGAIN);
/*
 * TODO(s...@chromium.org): Optimise this, perhaps moving the found
 * node to the start of the list, or creating a linear array mapping
@@ -144,6 +145,19 @@ int uclass_get(enum uclass_id id, struct uclass **ucp)
 
*ucp = NULL;
uc = uclass_find(id);
+   if (IS_ERR(uc)) {
+   /*
+* If we're getting the root uclass, then uclass_find will fail
+* with -EAGAIN (since it thinks there's no uclass list to
+* search), but we need to add it anyway (since otherwise it
+* would never be created).
+*/
+   if (PTR_ERR(uc) == -EAGAIN && id == UCLASS_ROOT)
+   uc = NULL;
+   else
+   return PTR_ERR(uc);
+   }
+
if (!uc)
return uclass_add(id, ucp);
*ucp = uc;
diff --git a/test/dm/core.c b/test/dm/core.c
index 8ed5bf7370..a4e0ac06f9 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -733,7 +733,7 @@ static int dm_test_uclass_before_ready(struct 
unit_test_state *uts)
gd->dm_root_f = NULL;
memset(>uclass_root, '\0', sizeof(gd->uclass_root));
 
-   ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
+   ut_asserteq_ptr(ERR_PTR(-EAGAIN), uclass_find(UCLASS_TEST));
 
return 0;
 }
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 38b7b1481a..6ff07a5d32 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -70,7 +70,7 @@ static int dm_test_destroy(struct unit_test_state *uts)
 * check that here before we call uclass_find_device().
 */
uc = uclass_find(id);
-   if (!uc)
+   if (IS_ERR_OR_NULL(uc))
continue;
ut_assertok(uclass_destroy(uc));
}
-- 
2.28.0



Re: Intermittent failure with test_efi_selftest_text_input

2020-09-12 Thread Heinrich Schuchardt
Am 12. September 2020 18:40:17 MESZ schrieb Simon Glass :
>Hi Heinrich,
>
>I am seeing a failure in gitlab every now and then. Here is an example
>of a build that failed and then succeeded on retry:
>
>https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/jobs/149201
>
>Here's the failing trace:
>
>https://pastebin.com/bdu6jmVy
>
>Do you have any ideas?
>
>Regards,
>Simon

I see no error in the EFI test itself.

There seems to be some bug in QEMU:

CPU: QEMU Virtual CPU version 2.5+ 
DRAM: 128 MiB 
unable to find cpus device 
Warning: MP init failure

I have no access to a computer this weekend. Please put the log into a mail as 
I think Pastebin does not keep pastes for long.

Regards

Heinrich



Re: [PATCH 4/4] log: Disable the syslog driver by default

2020-09-12 Thread Heinrich Schuchardt
Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass :
>Hi Heinrich,
>
>On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt 
>wrote:
>>
>> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
>:
>> >This driver interferes with other sandbox tests since it causes log
>> >output
>> >to be interspersed with "No ethernet found." messages. Disable this
>> >driver
>> >by default.
>> >
>> >Enable it for the syslog tests so that they still pass.
>> >
>> >Signed-off-by: Simon Glass 
>> >---
>> >
>> > common/log_syslog.c   |  1 -
>> > test/log/syslog_test.c| 24 
>> > test/log/syslog_test.h| 16 
>> > test/log/syslog_test_ndebug.c |  2 ++
>> > 4 files changed, 42 insertions(+), 1 deletion(-)
>> >
>> >diff --git a/common/log_syslog.c b/common/log_syslog.c
>> >index cf0dbba9bf5..149ff5af310 100644
>> >--- a/common/log_syslog.c
>> >+++ b/common/log_syslog.c
>> >@@ -115,5 +115,4 @@ out:
>> > LOG_DRIVER(syslog) = {
>> >   .name   = "syslog",
>> >   .emit   = log_syslog_emit,
>> >-  .flags  = LOGDF_ENABLE,
>>
>> What does the flag removal change outside Python testing?
>
>If this driver is to be used on a board, you must call
>log_device_set_enable().

This would pervert the nice log driver system that you have provided. I 
definitively want syslog with vanilla code just by customizing.

If you want to mute the network stack, then move it to use log and filter on 
the network uclass.

Or simply adjust the test that has hickups.

Best regards

Heinrich

>
>Regards,
>Simon



RE: [PATCH] lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

2020-09-12 Thread Biju Das
Hi Marek,

Thanks for the patch.

> -Original Message-
> From: U-Boot  On Behalf Of Marek Vasut
> Sent: 12 September 2020 11:43
> To: u-boot@lists.denx.de
> Cc: Marek Vasut ; Michal Simek
> ; Simon Glass ; Tom Rini
> 
> Subject: [PATCH] lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree
> API
>
> Repair incorrectly negated condition in the original patch which broke DT
> memory node parsing on everything which has more than one DT memory
> node, e.g. R-Car3.
>
> In case multiple valid memory nodes are present in the DT, the original patch
> would complete parsing cycle for the first memory node, then move on to
> the next one, identify it as a valid, and end the parsing. The fix is to 
> invert the
> condition, to make the code behave as it did before the livetree conversion,
> so it would continue parsing the subsequent memory nodes as well.
>
> Fixes: c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
> Signed-off-by: Marek Vasut 
> Cc: Michal Simek 
> Cc: Simon Glass 
> Cc: Tom Rini 

Tested this patch on following RZ/G2 Boards and it reports correct DRAM size 
with 2020.10 uboot master branch.

1) RZ/G2H (a.k.a r8a774e1)
2) RZ/G2M (a.k.a r8a774a1)
3) RZ/G2N (a.k.a r8a774b1)

Tested-by: Biju Das 

Cheers,
Biju

> ---
>  lib/fdtdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d3b22ec323..5f41f58a63 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
>  if (ret < 0) {
>  reg = 0;
>  mem = get_next_memory_node(mem);
> -if (ofnode_valid(mem))
> +if (!ofnode_valid(mem))
>  break;
>
>  ret = ofnode_read_resource(mem, reg++, );
> @@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
>  if (ret < 0) {
>  reg = 0;
>  mem = get_next_memory_node(mem);
> -if (ofnode_valid(mem))
> +if (!ofnode_valid(mem))
>  break;
>
>  ret = ofnode_read_resource(mem, reg++, );
> --
> 2.28.0



Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, 
Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 
Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 
3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. 
no.: DE 14978647


[PATCH] Add support for Davicom DM96xx based USB 10/100 ethernet devices

2020-09-12 Thread hyyoxhk
Ported from Linux driver - drivers/net/usb9601.c

Signed-off-by: hyyoxhk 
---
 drivers/usb/eth/Kconfig  |   8 +
 drivers/usb/eth/Makefile |   1 +
 drivers/usb/eth/dm9601.c | 521 +++
 3 files changed, 530 insertions(+)
 create mode 100644 drivers/usb/eth/dm9601.c

diff --git a/drivers/usb/eth/Kconfig b/drivers/usb/eth/Kconfig
index 2f6bfa8e71..8a47ca0ec4 100644
--- a/drivers/usb/eth/Kconfig
+++ b/drivers/usb/eth/Kconfig
@@ -62,4 +62,12 @@ config USB_ETHER_SMSC95XX
  Say Y here if you would like to support SMSC LAN95xx based USB 2.0
  Ethernet Devices.
 
+config USB_ETHER_DM9601
+   bool "Davicom DM96xx based USB 10/100 ethernet devices"
+   depends on USB_HOST_ETHER
+   depends on DM_ETH
+   ---help---
+ This option adds support for Davicom DM9601/DM9620/DM9621A
+ based USB 10/100 Ethernet adapters.
+
 endif
diff --git a/drivers/usb/eth/Makefile b/drivers/usb/eth/Makefile
index 2e5d0782e8..044b12f028 100644
--- a/drivers/usb/eth/Makefile
+++ b/drivers/usb/eth/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_ETHER_ASIX) += asix.o
 obj-$(CONFIG_USB_ETHER_ASIX88179) += asix88179.o
 obj-$(CONFIG_USB_ETHER_MCS7830) += mcs7830.o
 obj-$(CONFIG_USB_ETHER_SMSC95XX) += smsc95xx.o
+obj-$(CONFIG_USB_ETHER_DM9601) += dm9601.o
 obj-$(CONFIG_USB_ETHER_LAN75XX) += lan7x.o lan75xx.o
 obj-$(CONFIG_USB_ETHER_LAN78XX) += lan7x.o lan78xx.o
 obj-$(CONFIG_USB_ETHER_RTL8152) += r8152.o r8152_fw.o
diff --git a/drivers/usb/eth/dm9601.c b/drivers/usb/eth/dm9601.c
new file mode 100644
index 00..f5956c7c73
--- /dev/null
+++ b/drivers/usb/eth/dm9601.c
@@ -0,0 +1,521 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Davicom DM96xx USB 10/100Mbps ethernet devices
+ *
+ * Ported from Linux driver - drivers/net/usb9601.c
+ *
+ * Copyright (C) 2020 hey 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "usb_ether.h"
+
+/* control requests */
+#define DM_READ_REGS   0x00
+#define DM_WRITE_REGS  0x01
+#define DM_READ_MEMS   0x02
+#define DM_WRITE_REG   0x03
+#define DM_WRITE_MEMS  0x05
+#define DM_WRITE_MEM   0x07
+
+/* registers */
+#define DM_NET_CTRL0x00
+#define DM_RX_CTRL 0x05
+#define DM_SHARED_CTRL 0x0b
+#define DM_SHARED_ADDR 0x0c
+#define DM_SHARED_DATA 0x0d/* low + high */
+#define DM_PHY_ADDR0x10/* 6 bytes */
+#define DM_MCAST_ADDR  0x16/* 8 bytes */
+#define DM_GPR_CTRL0x1e
+#define DM_GPR_DATA0x1f
+#define DM_CHIP_ID 0x2c
+#define DM_MODE_CTRL   0x91/* only on dm9620 */
+
+/* chip id values */
+#define ID_DM9601  0
+#define ID_DM9620  1
+
+#define DM_MAX_MCAST   64
+#define DM_MCAST_SIZE  8
+#define DM_EEPROM_LEN  256
+#define DM_TX_OVERHEAD 2   /* 2 byte header */
+#define DM_RX_OVERHEAD 7   /* 3 byte header + 4 byte crc tail */
+#define DM_TIMEOUT 1000
+
+#define USB_CTRL_SET_TIMEOUT 5000
+#define PHY_CONNECT_TIMEOUT 5000
+#define USB_BULK_SEND_TIMEOUT 5000
+#define USB_BULK_RECV_TIMEOUT 5000
+#define RX_URB_SIZE 2048
+
+/* driver private */
+struct dm9601_private {
+   struct ueth_data ueth;
+};
+
+static int dm_read(struct usb_device *udev, u8 reg, u16 length, void *data)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(u8, v, length);
+   int err;
+
+   err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ DM_READ_REGS,
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ 0, reg, v, length,
+ USB_CTRL_SET_TIMEOUT);
+
+   memcpy(data, v, length);
+
+   if (err != length && err >= 0)
+   err = -EINVAL;
+
+   return err;
+}
+
+static int dm_read_reg(struct usb_device *udev, u8 reg, u8 *value)
+{
+   return dm_read(udev, reg, 1, value);
+}
+
+static int dm_write(struct usb_device *udev, u8 reg, u16 length, void *data)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(u8, v, length);
+   int err;
+
+   memcpy(v, data, length);
+
+   err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ DM_WRITE_REGS,
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ 0, reg, v, length,
+ USB_CTRL_SET_TIMEOUT);
+   if (err >= 0 && err < length)
+   err = -EINVAL;
+
+   return err;
+}
+
+static int dm_write_reg(struct usb_device *udev, u8 reg, u8 value)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(u8, v, 1);
+   v[0] = value;
+
+   return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+   DM_WRITE_REG,
+   USB_DIR_OUT | USB_TYPE_VENDOR | 
USB_RECIP_DEVICE,
+   v[0], reg, NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+}
+
+static int dm_read_shared_word(struct usb_device *udev, int phy, u8 reg, 
__le16 *value)
+{
+   int ret, i;
+
+   dm_write_reg(udev, DM_SHARED_ADDR, phy ? (reg | 

Intermittent failure with test_efi_selftest_text_input

2020-09-12 Thread Simon Glass
Hi Heinrich,

I am seeing a failure in gitlab every now and then. Here is an example
of a build that failed and then succeeded on retry:

https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/jobs/149201

Here's the failing trace:

https://pastebin.com/bdu6jmVy

Do you have any ideas?

Regards,
Simon


[PATCH v2 1/2] log: Allow LOG_DEBUG to always enable log output

2020-09-12 Thread Simon Glass
At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file
(before log.h inclusion) causes _log() to be executed for every log()
call, regardless of the build- or run-time logging level.

However there is no guarantee that the log record will actually be
displayed. If the current log level is lower than LOGL_DEBUG then it will
not be.

Add a way to signal that the log record should always be displayed and
update log_passes_filters() to handle this.

With the new behaviour, log_debug() will always log if LOG_DEBUG is
enabled.

Move log_test_syslog_nodebug() into its own file since it cannot be made
to work where it is, with LOG_DEBUG defined.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Move log_test_syslog_nodebug() into its own file
- Add casts for the enum to keep clang happy

 common/log.c  |  6 ++-
 doc/README.log|  7 +---
 include/log.h | 18 +++--
 test/log/Makefile |  1 +
 test/log/syslog_test.c| 76 +--
 test/log/syslog_test.h| 50 +++
 test/log/syslog_test_ndebug.c | 55 +
 7 files changed, 129 insertions(+), 84 deletions(-)
 create mode 100644 test/log/syslog_test.h
 create mode 100644 test/log/syslog_test_ndebug.c

diff --git a/common/log.c b/common/log.c
index 734d26de4af..f44f15743ff 100644
--- a/common/log.c
+++ b/common/log.c
@@ -157,6 +157,9 @@ static bool log_passes_filters(struct log_device *ldev, 
struct log_rec *rec)
 {
struct log_filter *filt;
 
+   if (rec->force_debug)
+   return true;
+
/* If there are no filters, filter on the default log level */
if (list_empty(>filter_head)) {
if (rec->level > gd->default_log_level)
@@ -208,7 +211,8 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
va_list args;
 
rec.cat = cat;
-   rec.level = level;
+   rec.level = level & LOGL_LEVEL_MASK;
+   rec.force_debug = level & LOGL_FORCE_DEBUG;
rec.file = file;
rec.line = line;
rec.func = func;
diff --git a/doc/README.log b/doc/README.log
index ba838824a99..a313399fc93 100644
--- a/doc/README.log
+++ b/doc/README.log
@@ -78,11 +78,8 @@ Sometimes it is useful to turn on logging just in one file. 
You can use this:
#define LOG_DEBUG
 
 to enable building in of all logging statements in a single file. Put it at
-the top of the file, before any #includes.
-
-To actually get U-Boot to output this you need to also set the default logging
-level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (LOGL_DEBUG) or more. Otherwise
-debug output is suppressed and will not be generated.
+the top of the file, before any #includes. This overrides any log-level setting
+in U-Boot, including CONFIG_LOG_DEFAULT_LEVEL, but just for that file.
 
 
 Convenience functions
diff --git a/include/log.h b/include/log.h
index 2859ce1f2e7..86c8d7be09d 100644
--- a/include/log.h
+++ b/include/log.h
@@ -33,6 +33,9 @@ enum log_level_t {
LOGL_COUNT,
LOGL_NONE,
 
+   LOGL_LEVEL_MASK = 0xf,  /* Mask for valid log levels */
+   LOGL_FORCE_DEBUG = 0x10, /* Mask to force output due to LOG_DEBUG */
+
LOGL_FIRST = LOGL_EMERG,
LOGL_MAX = LOGL_DEBUG_IO,
 };
@@ -133,7 +136,7 @@ static inline int _log_nop(enum log_category_t cat, enum 
log_level_t level,
 
 #if CONFIG_IS_ENABLED(LOG)
 #ifdef LOG_DEBUG
-#define _LOG_DEBUG 1
+#define _LOG_DEBUG LOGL_FORCE_DEBUG
 #else
 #define _LOG_DEBUG 0
 #endif
@@ -141,9 +144,11 @@ static inline int _log_nop(enum log_category_t cat, enum 
log_level_t level,
 /* Emit a log record if the level is less that the maximum */
 #define log(_cat, _level, _fmt, _args...) ({ \
int _l = _level; \
-   if (CONFIG_IS_ENABLED(LOG) && (_l <= _LOG_MAX_LEVEL || _LOG_DEBUG)) \
-   _log((enum log_category_t)(_cat), _l, __FILE__, __LINE__, \
- __func__, \
+   if (CONFIG_IS_ENABLED(LOG) && \
+   (_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
+   _log((enum log_category_t)(_cat), \
+(enum log_level_t)(_l | _LOG_DEBUG), __FILE__, \
+__LINE__, __func__, \
  pr_fmt(_fmt), ##_args); \
})
 #else
@@ -279,8 +284,12 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
  * Memebers marked as 'allocated' are allocated (e.g. via strdup()) by the log
  * system.
  *
+ * TODO(s...@chromium.org): Compress this struct down a bit to reduce space, 
e.g.
+ * a single u32 for cat, level, line and force_debug
+ *
  * @cat: Category, representing a uclass or part of U-Boot
  * @level: Severity level, less severe is higher
+ * @force_debug: Force output of debug
  * @file: Name of file where the log record was generated (not allocated)
  * @line: Line number where the log record was generated
  * @func: Function where the log record was 

[PATCH v2 2/2] lib: Allow hexdump to be used in SPL

2020-09-12 Thread Simon Glass
It is sometimes useful to output hex dumps in SPL. Add a config option to
allow this.

Signed-off-by: Simon Glass 
Reviewed-by: Stefan Roese 
---

Changes in v2:
- Leave the Makefile alone as the logic is in the C file

 lib/Kconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index 8efb154f734..37aae73a266 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -542,6 +542,14 @@ config HEXDUMP
help
  This enables functions for printing dumps of binary data.
 
+config SPL_HEXDUMP
+   bool "Enable hexdump in SPL"
+   depends on HEXDUMP
+   default y
+   help
+ This enables functions for printing dumps of binary data in
+ SPL.
+
 config OF_LIBFDT
bool "Enable the FDT library"
default y if OF_CONTROL
-- 
2.28.0.618.gf4bc123cb7-goog



[PATCH 0/4] log: Fix the syslog spam when running tests

2020-09-12 Thread Simon Glass
At present running some sandbox tests produces unwanted ethernet errors
from the syslog driver, e.g.:

$ ./u-boot -c "ut bloblist"

Running 5 bloblist tests
Test: bloblist_test_bad_blob
Test: bloblist_test_blob
Test: bloblist_test_blob_ensure
Failed to allocate e0 bytes size=100, need size=130
No ethernet found.
bloblist add: returning err=-28
No ethernet found.
Test: bloblist_test_checksum
Checksum f3129fae != 338fbdc
No ethernet found.
Bad checksum: returning err=-5
No ethernet found.
...

This series fixes this by making the syslog driver disabled by default. It
can be enabled with a function call.


Simon Glass (4):
  log: Add a flag to enable log drivers
  log: Drop #ifdef in log_test
  log: Add a way to enable/disable a log device
  log: Disable the syslog driver by default

 common/log.c  | 42 ++-
 common/log_console.c  |  1 +
 include/log.h | 28 ++-
 test/log/log_test.c   |  9 ++--
 test/log/syslog_test.c| 24 
 test/log/syslog_test.h| 16 +
 test/log/syslog_test_ndebug.c |  2 ++
 test/py/tests/test_log.py |  8 +++
 8 files changed, 126 insertions(+), 4 deletions(-)

-- 
2.28.0.618.gf4bc123cb7-goog



Re: Intermittent failure with test_efi_selftest_text_input

2020-09-12 Thread Simon Glass
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:11, Heinrich Schuchardt  wrote:
>
> Am 12. September 2020 18:40:17 MESZ schrieb Simon Glass :
>>
>> Hi Heinrich,
>>
>> I am seeing a failure in gitlab every now and then. Here is an example
>> of a build that failed and then succeeded on retry:
>>
>> https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/jobs/149201
>>
>> Here's the failing trace:
>>
>> https://pastebin.com/bdu6jmVy
>>
>> Do you have any ideas?
>>
>> Regards,
>> Simon
>
>
> I see no error in the EFI test itself.
>
> There seems to be some bug in QEMU:
>
> CPU: QEMU Virtual CPU version 2.5+
> DRAM: 128 MiB
> unable to find cpus device
> Warning: MP init failure

+Bin Meng have you seen this before? Is it OK to do mp_init on qemu?


>
> I have no access to a computer this weekend. Please put the log into a mail 
> as I think Pastebin does not keep pastes for long.

 [0KRunning with gitlab-runner 12.0.1 (0e5417a3)
 [0;m [0K  on konsulko-bootbake G37FKVsV
 [0;msection_start:1599927871:prepare_executor
 [0K [0KUsing Docker executor with image
trini/u-boot-gitlab-ci-runner:bionic-20200807-02Sep2020 ...
 [0;m [0KPulling docker image
trini/u-boot-gitlab-ci-runner:bionic-20200807-02Sep2020 ...
 [0;m [0KUsing docker image
sha256:2ce90130337e549a4fabf73a19832d1c66fef9de08a806c638a44074dc691e0a
for trini/u-boot-gitlab-ci-runner:bionic-20200807-02Sep2020 ...
 [0;msection_end:1599927873:prepare_executor
 [0Ksection_start:1599927873:prepare_script
 [0KRunning on runner-G37FKVsV-project-552-concurrent-0 via bootbake...
section_end:1599927875:prepare_script
 [0Ksection_start:1599927875:get_sources
 [0K [32;1mFetching changes... [0;m
Reinitialized existing Git repository in
/builds/u-boot/custodians/u-boot-dm/.git/
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
 [32;1mChecking out 96edab25 as log-working... [0;m
Removing test/py/.pytest_cache/
Removing test/py/__pycache__/
Removing test/py/tests/__pycache__/
Removing test/py/tests/test_android/__pycache__/
Removing test/py/tests/test_efi_secboot/__pycache__/
Removing test/py/tests/test_fs/__pycache__/
Removing test/py/tests/test_fs/test_squashfs/__pycache__/
Removing tools/buildman/__pycache__/
Removing tools/patman/__pycache__/

 [32;1mSkipping Git submodules setup [0;m
section_end:1599927879:get_sources
 [0Ksection_start:1599927879:restore_cache
 [0Ksection_end:1599927881:restore_cache
 [0Ksection_start:1599927881:download_artifacts
 [0Ksection_end:1599927883:download_artifacts
 [0Ksection_start:1599927883:build_script
 [0K [32;1m$ git clone --depth=1
git://github.com/swarren/uboot-test-hooks.git
/tmp/uboot-test-hooks [0;m
Cloning into '/tmp/uboot-test-hooks'...
 [32;1m$ ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname` [0;m
 [32;1m$ ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname` [0;m
 [32;1m$ grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal
 echo lsefimmap lsefi lsefisystab efinet tftp minicmd [0;m
 [32;1m$ grub-mkimage --prefix="" -o ~/grub_x64.efi -O x86_64-efi
normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd [0;m
 [32;1m$ if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then wget -O
- 
https://github.com/riscv/opensbi/releases/download/v0.8/opensbi-0.8-rv-bin.tar.xz
| tar -C /tmp -xJ; export
OPENSBI=/tmp/opensbi-0.8-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin;
fi [0;m
 [32;1m$ if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then wget -O
- 
https://github.com/riscv/opensbi/releases/download/v0.8/opensbi-0.8-rv-bin.tar.xz
| tar -C /tmp -xJ; export
OPENSBI=/tmp/opensbi-0.8-rv-bin/share/opensbi/lp64/generic/firmware/fw_dynamic.bin;
fi [0;m
 [32;1m$ export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD} [0;m
 [32;1m$ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W
-e --board ${TEST_PY_BD} ${OVERRIDE} [0;m
Building current source for 1 boards (1 thread, 24 jobs per thread)

Starting build...


000 /1   -1  (starting)


100 /1  qemu-x86
Completed: 1 total built, duration 0:00:12, rate 0.08
 [32;1m$ cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/ [0;m
 [32;1m$ cp ~/grub_x64.efi $UBOOT_TRAVIS_BUILD_DIR/ [0;m
 [32;1m$ cp /opt/grub/grubriscv64.efi
$UBOOT_TRAVIS_BUILD_DIR/grub_riscv64.efi [0;m
 [32;1m$ cp /opt/grub/grubriscv32.efi
$UBOOT_TRAVIS_BUILD_DIR/grub_riscv32.efi [0;m
 [32;1m$ cp /opt/grub/grubaa64.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi [0;m
 [32;1m$ cp /opt/grub/grubarm.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi [0;m
 [32;1m$ virtualenv -p /usr/bin/python3 /tmp/venv [0;m
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/venv/bin/python3
Also creating executable in /tmp/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
 [32;1m$ . /tmp/venv/bin/activate [0;m
 [32;1m$ pip install -r test/py/requirements.txt [0;m
Collecting atomicwrites==1.3.0
  Downloading atomicwrites-1.3.0-py2.py3-none-any.whl (5.9 kB)
Collecting attrs==19.3.0
  Downloading 

Re: [PATCH 3/4] log: Add a way to enable/disable a log device

2020-09-12 Thread Heinrich Schuchardt
Am 12. September 2020 20:28:49 MESZ schrieb Simon Glass :
>At present all log devices are enabled by default. Add a function to
>allow
>devices to be disabled or enabled at runtime.

Should this capability be added to the log command?

Regards

Heinrich

>
>Signed-off-by: Simon Glass 
>---
>
> common/log.c  | 38 ++
> include/log.h | 17 +
> test/log/log_test.c   |  7 +++
> test/py/tests/test_log.py |  8 
> 4 files changed, 70 insertions(+)
>
>diff --git a/common/log.c b/common/log.c
>index ce528fe4535..a9aacfaf354 100644
>--- a/common/log.c
>+++ b/common/log.c
>@@ -297,6 +297,44 @@ int log_remove_filter(const char *drv_name, int
>filter_num)
>   return -ENOENT;
> }
> 
>+/**
>+ * log_find_device_by_drv() - Find a device by its driver
>+ *
>+ * @drv: Log driver
>+ * @return Device associated with that driver, or NULL if not found
>+ */
>+static struct log_device *log_find_device_by_drv(struct log_driver
>*drv)
>+{
>+  struct log_device *ldev;
>+
>+  list_for_each_entry(ldev, >log_head, sibling_node) {
>+  if (ldev->drv == drv)
>+  return ldev;
>+  }
>+  /*
>+   * It is quite hard to pass an invalid driver since passing an
>unknown
>+   * LOG_GET_DRIVER(xxx) would normally produce a compilation error.
>But
>+   * it is possible to pass NULL, for example, so this
>+   */
>+
>+  return NULL;
>+}
>+
>+int log_device_set_enable(struct log_driver *drv, bool enable)
>+{
>+  struct log_device *ldev;
>+
>+  ldev = log_find_device_by_drv(drv);
>+  if (!ldev)
>+  return -ENOENT;
>+  if (enable)
>+  ldev->flags |= LOGDF_ENABLE;
>+  else
>+  ldev->flags &= ~LOGDF_ENABLE;
>+
>+  return 0;
>+}
>+
> int log_init(void)
> {
>   struct log_driver *drv = ll_entry_start(struct log_driver,
>log_driver);
>diff --git a/include/log.h b/include/log.h
>index d28bc1ef0e4..4acc087b2e9 100644
>--- a/include/log.h
>+++ b/include/log.h
>@@ -388,6 +388,10 @@ struct log_filter {
> #define LOG_DRIVER(_name) \
>   ll_entry_declare(struct log_driver, _name, log_driver)
> 
>+/* Get a pointer to a given driver */
>+#define LOG_GET_DRIVER(__name)
>\
>+  ll_entry_get(struct log_driver, __name, log_driver)
>+
> /**
>  * log_get_cat_name() - Get the name of a category
>  *
>@@ -465,6 +469,19 @@ int log_add_filter(const char *drv_name, enum
>log_category_t cat_list[],
>  */
> int log_remove_filter(const char *drv_name, int filter_num);
> 
>+/**
>+ * log_device_set_enable() - Enable or disable a log device
>+ *
>+ * Devices are referenced by their driver, so use LOG_GET_DRIVER(name)
>to pass
>+ * the driver to this function. For example if the driver is declared
>with
>+ * LOG_DRIVER(wibble) then pass LOG_GET_DRIVER(wibble) here.
>+ *
>+ * @drv: Driver of device to enable
>+ * @enable: true to enable, false to disable
>+ * @return 0 if OK, -ENOENT if the driver was not found
>+ */
>+int log_device_set_enable(struct log_driver *drv, bool enable);
>+
> #if CONFIG_IS_ENABLED(LOG)
> /**
>  * log_init() - Set up the log system ready for use
>diff --git a/test/log/log_test.c b/test/log/log_test.c
>index fdee5e6757f..6a60ff6be3c 100644
>--- a/test/log/log_test.c
>+++ b/test/log/log_test.c
>@@ -196,6 +196,13 @@ static int log_test(int testnum)
>   log_io("level %d\n", LOGL_DEBUG_IO);
>   break;
>   }
>+  case 11:
>+  log_err("default\n");
>+  ret = log_device_set_enable(LOG_GET_DRIVER(console), false);
>+  log_err("disabled\n");
>+  ret = log_device_set_enable(LOG_GET_DRIVER(console), true);
>+  log_err("enabled\n");
>+  break;
>   }
> 
>   return 0;
>diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py
>index ddc28f19ee8..275f9382d2f 100644
>--- a/test/py/tests/test_log.py
>+++ b/test/py/tests/test_log.py
>@@ -92,6 +92,13 @@ def test_log(u_boot_console):
> for i in range(7):
> assert 'log_test() level %d' % i == next(lines)
> 
>+def test11():
>+"""Test use of log_device_set_enable()"""
>+lines = run_test(11)
>+assert 'log_test() default'
>+# disabled should not be displayed
>+assert 'log_test() enabled'
>+
>  # TODO(s...@chromium.org): Consider structuring this as separate tests
> cons = u_boot_console
> test0()
>@@ -105,6 +112,7 @@ def test_log(u_boot_console):
> test8()
> test9()
> test10()
>+test11()
> 
> @pytest.mark.buildconfigspec('cmd_log')
> def test_log_format(u_boot_console):



Re: [PATCH 4/4] log: Disable the syslog driver by default

2020-09-12 Thread Simon Glass
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt  wrote:
>
> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass :
> >This driver interferes with other sandbox tests since it causes log
> >output
> >to be interspersed with "No ethernet found." messages. Disable this
> >driver
> >by default.
> >
> >Enable it for the syslog tests so that they still pass.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > common/log_syslog.c   |  1 -
> > test/log/syslog_test.c| 24 
> > test/log/syslog_test.h| 16 
> > test/log/syslog_test_ndebug.c |  2 ++
> > 4 files changed, 42 insertions(+), 1 deletion(-)
> >
> >diff --git a/common/log_syslog.c b/common/log_syslog.c
> >index cf0dbba9bf5..149ff5af310 100644
> >--- a/common/log_syslog.c
> >+++ b/common/log_syslog.c
> >@@ -115,5 +115,4 @@ out:
> > LOG_DRIVER(syslog) = {
> >   .name   = "syslog",
> >   .emit   = log_syslog_emit,
> >-  .flags  = LOGDF_ENABLE,
>
> What does the flag removal change outside Python testing?

If this driver is to be used on a board, you must call log_device_set_enable().

Regards,
Simon


Re: [PATCH] RFC: tegra: xhci: Allocate from non-cached memory

2020-09-12 Thread Marek Vasut
On 9/11/20 9:43 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
> 
> This fixes the XHCI driver on T210 boards (TX1, Nano). I was seeing
> that Set_Address wasn't completing, returning with a Context Parameter
> error. Examining the slot context, etc. showed that the correct info was
> there in RAM. Once I set 'dcache off' globally, it started working.
> This patch was created to force the TRB, etc. allocation to be in
> non-cached memory, which resulted in XHCI working on Nano/TX1 w/o the
> need for a global dcache disable. Thierry Reding pointed to a similar
> fix he'd done for the rtl6189 driver.
> 
> Sending this to the list for comment, as this should have affected other
> XHCI implementations on other SoCs. Note that Tegra X1 (T210) has a
> 64-byte cache line size (64-bit ARMv8), and I do see the
> flush_cache/inval_cache ARM code being called via
> xhci_cache_flash/xhci_inval_cache.

Is cache management on tegra210 broken ? I've seen the same non-cached
workaround in the DWMAC ethernet driver.


[PATCH 4/4] log: Disable the syslog driver by default

2020-09-12 Thread Simon Glass
This driver interferes with other sandbox tests since it causes log output
to be interspersed with "No ethernet found." messages. Disable this driver
by default.

Enable it for the syslog tests so that they still pass.

Signed-off-by: Simon Glass 
---

 common/log_syslog.c   |  1 -
 test/log/syslog_test.c| 24 
 test/log/syslog_test.h| 16 
 test/log/syslog_test_ndebug.c |  2 ++
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/common/log_syslog.c b/common/log_syslog.c
index cf0dbba9bf5..149ff5af310 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -115,5 +115,4 @@ out:
 LOG_DRIVER(syslog) = {
.name   = "syslog",
.emit   = log_syslog_emit,
-   .flags  = LOGDF_ENABLE,
 };
diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c
index abcb9ffd28b..febaca68e8d 100644
--- a/test/log/syslog_test.c
+++ b/test/log/syslog_test.c
@@ -56,6 +56,20 @@ int sb_log_tx_handler(struct udevice *dev, void *packet, 
unsigned int len)
return 0;
 }
 
+int syslog_test_setup(struct unit_test_state *uts)
+{
+   ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), true));
+
+   return 0;
+}
+
+int syslog_test_finish(struct unit_test_state *uts)
+{
+   ut_assertok(log_device_set_enable(LOG_GET_DRIVER(syslog), false));
+
+   return 0;
+}
+
 /**
  * log_test_syslog_err() - test log_err() function
  *
@@ -67,6 +81,7 @@ static int log_test_syslog_err(struct unit_test_state *uts)
int old_log_level = gd->default_log_level;
struct sb_log_env env;
 
+   ut_assertok(syslog_test_setup(uts));
gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
@@ -82,6 +97,7 @@ static int log_test_syslog_err(struct unit_test_state *uts)
sandbox_eth_set_tx_handler(0, NULL);
gd->default_log_level = old_log_level;
gd->log_fmt = log_get_default_format();
+   ut_assertok(syslog_test_finish(uts));
 
return 0;
 }
@@ -98,6 +114,7 @@ static int log_test_syslog_warning(struct unit_test_state 
*uts)
int old_log_level = gd->default_log_level;
struct sb_log_env env;
 
+   ut_assertok(syslog_test_setup(uts));
gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
@@ -114,6 +131,7 @@ static int log_test_syslog_warning(struct unit_test_state 
*uts)
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
gd->log_fmt = log_get_default_format();
+   ut_assertok(syslog_test_finish(uts));
 
return 0;
 }
@@ -130,6 +148,7 @@ static int log_test_syslog_notice(struct unit_test_state 
*uts)
int old_log_level = gd->default_log_level;
struct sb_log_env env;
 
+   ut_assertok(syslog_test_setup(uts));
gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
@@ -146,6 +165,7 @@ static int log_test_syslog_notice(struct unit_test_state 
*uts)
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
gd->log_fmt = log_get_default_format();
+   ut_assertok(syslog_test_finish(uts));
 
return 0;
 }
@@ -162,6 +182,7 @@ static int log_test_syslog_info(struct unit_test_state *uts)
int old_log_level = gd->default_log_level;
struct sb_log_env env;
 
+   ut_assertok(syslog_test_setup(uts));
gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
@@ -178,6 +199,7 @@ static int log_test_syslog_info(struct unit_test_state *uts)
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
gd->log_fmt = log_get_default_format();
+   ut_assertok(syslog_test_finish(uts));
 
return 0;
 }
@@ -194,6 +216,7 @@ static int log_test_syslog_debug(struct unit_test_state 
*uts)
int old_log_level = gd->default_log_level;
struct sb_log_env env;
 
+   ut_assertok(syslog_test_setup(uts));
gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_DEBUG;
env_set("ethact", "eth@10002000");
@@ -210,6 +233,7 @@ static int log_test_syslog_debug(struct unit_test_state 
*uts)
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
gd->log_fmt = log_get_default_format();
+   ut_assertok(syslog_test_finish(uts));
 
return 0;
 }
diff --git a/test/log/syslog_test.h b/test/log/syslog_test.h
index 75900f3aad3..1310257bfe1 100644
--- a/test/log/syslog_test.h
+++ b/test/log/syslog_test.h
@@ -47,4 +47,20 @@ struct sb_log_env {
  */
 int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len);
 
+/**
+ * syslog_test_setup() - Enable syslog logging ready for tests
+ *
+ * @uts: Test state
+ * @return 0 if OK, -ENOENT if the syslog log driver is not found
+ */
+int syslog_test_setup(struct 

[PATCH 1/4] log: Add a flag to enable log drivers

2020-09-12 Thread Simon Glass
At present there is no way to disable a log driver. But the syslog driver
causes (attempted) network traffic in sandbox every time a log message
is printed, which is often.

Add a flag to enable a log driver. Adjust struct log_device to use a short
for next_filter_num so that no more memory is used for devices. Also fix
a missing line in the struct log_driver comment while here.

To maintain compatibility, enable it for all drivers for now.

Signed-off-by: Simon Glass 
---

 common/log.c |  4 +++-
 common/log_console.c |  1 +
 common/log_syslog.c  |  1 +
 include/log.h| 11 ++-
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/common/log.c b/common/log.c
index f44f15743ff..ce528fe4535 100644
--- a/common/log.c
+++ b/common/log.c
@@ -196,7 +196,8 @@ static int log_dispatch(struct log_rec *rec)
struct log_device *ldev;
 
list_for_each_entry(ldev, >log_head, sibling_node) {
-   if (log_passes_filters(ldev, rec))
+   if ((ldev->flags & LOGDF_ENABLE) &&
+   log_passes_filters(ldev, rec))
ldev->drv->emit(ldev, rec);
}
 
@@ -318,6 +319,7 @@ int log_init(void)
}
INIT_LIST_HEAD(>filter_head);
ldev->drv = drv;
+   ldev->flags = drv->flags;
list_add_tail(>sibling_node,
  (struct list_head *)>log_head);
drv++;
diff --git a/common/log_console.c b/common/log_console.c
index bb3f8464b98..8776fd47039 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -44,4 +44,5 @@ static int log_console_emit(struct log_device *ldev, struct 
log_rec *rec)
 LOG_DRIVER(console) = {
.name   = "console",
.emit   = log_console_emit,
+   .flags  = LOGDF_ENABLE,
 };
diff --git a/common/log_syslog.c b/common/log_syslog.c
index 149ff5af310..cf0dbba9bf5 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -115,4 +115,5 @@ out:
 LOG_DRIVER(syslog) = {
.name   = "syslog",
.emit   = log_syslog_emit,
+   .flags  = LOGDF_ENABLE,
 };
diff --git a/include/log.h b/include/log.h
index 86c8d7be09d..d28bc1ef0e4 100644
--- a/include/log.h
+++ b/include/log.h
@@ -307,10 +307,16 @@ struct log_rec {
 
 struct log_device;
 
+enum log_device_flags {
+   LOGDF_ENABLE= BIT(0),   /* Device is enabled */
+};
+
 /**
  * struct log_driver - a driver which accepts and processes log records
  *
  * @name: Name of driver
+ * @emit: Method to call to emit a log record via this device
+ * @flags: Initial value for flags (use LOGDF_ENABLE to enable on start-up)
  */
 struct log_driver {
const char *name;
@@ -321,6 +327,7 @@ struct log_driver {
 * for processing. The filter is checked before calling this function.
 */
int (*emit)(struct log_device *ldev, struct log_rec *rec);
+   unsigned short flags;
 };
 
 /**
@@ -333,12 +340,14 @@ struct log_driver {
  * @next_filter_num: Seqence number of next filter filter added (0=no filters
  * yet). This increments with each new filter on the device, but never
  * decrements
+ * @flags: Flags for this filter (enum log_device_flags)
  * @drv: Pointer to driver for this device
  * @filter_head: List of filters for this device
  * @sibling_node: Next device in the list of all devices
  */
 struct log_device {
-   int next_filter_num;
+   unsigned short next_filter_num;
+   unsigned short flags;
struct log_driver *drv;
struct list_head filter_head;
struct list_head sibling_node;
-- 
2.28.0.618.gf4bc123cb7-goog



[PATCH 3/4] log: Add a way to enable/disable a log device

2020-09-12 Thread Simon Glass
At present all log devices are enabled by default. Add a function to allow
devices to be disabled or enabled at runtime.

Signed-off-by: Simon Glass 
---

 common/log.c  | 38 ++
 include/log.h | 17 +
 test/log/log_test.c   |  7 +++
 test/py/tests/test_log.py |  8 
 4 files changed, 70 insertions(+)

diff --git a/common/log.c b/common/log.c
index ce528fe4535..a9aacfaf354 100644
--- a/common/log.c
+++ b/common/log.c
@@ -297,6 +297,44 @@ int log_remove_filter(const char *drv_name, int filter_num)
return -ENOENT;
 }
 
+/**
+ * log_find_device_by_drv() - Find a device by its driver
+ *
+ * @drv: Log driver
+ * @return Device associated with that driver, or NULL if not found
+ */
+static struct log_device *log_find_device_by_drv(struct log_driver *drv)
+{
+   struct log_device *ldev;
+
+   list_for_each_entry(ldev, >log_head, sibling_node) {
+   if (ldev->drv == drv)
+   return ldev;
+   }
+   /*
+* It is quite hard to pass an invalid driver since passing an unknown
+* LOG_GET_DRIVER(xxx) would normally produce a compilation error. But
+* it is possible to pass NULL, for example, so this
+*/
+
+   return NULL;
+}
+
+int log_device_set_enable(struct log_driver *drv, bool enable)
+{
+   struct log_device *ldev;
+
+   ldev = log_find_device_by_drv(drv);
+   if (!ldev)
+   return -ENOENT;
+   if (enable)
+   ldev->flags |= LOGDF_ENABLE;
+   else
+   ldev->flags &= ~LOGDF_ENABLE;
+
+   return 0;
+}
+
 int log_init(void)
 {
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
diff --git a/include/log.h b/include/log.h
index d28bc1ef0e4..4acc087b2e9 100644
--- a/include/log.h
+++ b/include/log.h
@@ -388,6 +388,10 @@ struct log_filter {
 #define LOG_DRIVER(_name) \
ll_entry_declare(struct log_driver, _name, log_driver)
 
+/* Get a pointer to a given driver */
+#define LOG_GET_DRIVER(__name) \
+   ll_entry_get(struct log_driver, __name, log_driver)
+
 /**
  * log_get_cat_name() - Get the name of a category
  *
@@ -465,6 +469,19 @@ int log_add_filter(const char *drv_name, enum 
log_category_t cat_list[],
  */
 int log_remove_filter(const char *drv_name, int filter_num);
 
+/**
+ * log_device_set_enable() - Enable or disable a log device
+ *
+ * Devices are referenced by their driver, so use LOG_GET_DRIVER(name) to pass
+ * the driver to this function. For example if the driver is declared with
+ * LOG_DRIVER(wibble) then pass LOG_GET_DRIVER(wibble) here.
+ *
+ * @drv: Driver of device to enable
+ * @enable: true to enable, false to disable
+ * @return 0 if OK, -ENOENT if the driver was not found
+ */
+int log_device_set_enable(struct log_driver *drv, bool enable);
+
 #if CONFIG_IS_ENABLED(LOG)
 /**
  * log_init() - Set up the log system ready for use
diff --git a/test/log/log_test.c b/test/log/log_test.c
index fdee5e6757f..6a60ff6be3c 100644
--- a/test/log/log_test.c
+++ b/test/log/log_test.c
@@ -196,6 +196,13 @@ static int log_test(int testnum)
log_io("level %d\n", LOGL_DEBUG_IO);
break;
}
+   case 11:
+   log_err("default\n");
+   ret = log_device_set_enable(LOG_GET_DRIVER(console), false);
+   log_err("disabled\n");
+   ret = log_device_set_enable(LOG_GET_DRIVER(console), true);
+   log_err("enabled\n");
+   break;
}
 
return 0;
diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py
index ddc28f19ee8..275f9382d2f 100644
--- a/test/py/tests/test_log.py
+++ b/test/py/tests/test_log.py
@@ -92,6 +92,13 @@ def test_log(u_boot_console):
 for i in range(7):
 assert 'log_test() level %d' % i == next(lines)
 
+def test11():
+"""Test use of log_device_set_enable()"""
+lines = run_test(11)
+assert 'log_test() default'
+# disabled should not be displayed
+assert 'log_test() enabled'
+
 # TODO(s...@chromium.org): Consider structuring this as separate tests
 cons = u_boot_console
 test0()
@@ -105,6 +112,7 @@ def test_log(u_boot_console):
 test8()
 test9()
 test10()
+test11()
 
 @pytest.mark.buildconfigspec('cmd_log')
 def test_log_format(u_boot_console):
-- 
2.28.0.618.gf4bc123cb7-goog



[PATCH 2/4] log: Drop #ifdef in log_test

2020-09-12 Thread Simon Glass
This is not needed as the Makefile only builds the file if CONFIG_LOG_TEST
is enabled. Drop it.

Signed-off-by: Simon Glass 
---

 test/log/log_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/test/log/log_test.c b/test/log/log_test.c
index 4245372d65f..fdee5e6757f 100644
--- a/test/log/log_test.c
+++ b/test/log/log_test.c
@@ -201,7 +201,6 @@ static int log_test(int testnum)
return 0;
 }
 
-#ifdef CONFIG_LOG_TEST
 int do_log_test(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
int testnum = 0;
@@ -216,4 +215,3 @@ int do_log_test(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 
return ret ? CMD_RET_FAILURE : 0;
 }
-#endif
-- 
2.28.0.618.gf4bc123cb7-goog



[PATCH 4/4] dm: Print device name in dev_xxx() like Linux

2020-09-12 Thread Sean Anderson
This adorns messages generated by dev_xxx() with the device and driver
names. It also redirects dev_xxx() to log() when it is available. The names
of these functions very roughly take inspiration from Linux, but there is
no deeper correlation.

Signed-off-by: Sean Anderson 
---

 include/dm/device_compat.h | 58 ++
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/include/dm/device_compat.h b/include/dm/device_compat.h
index 7c14aa464d..5d18eb68fa 100644
--- a/include/dm/device_compat.h
+++ b/include/dm/device_compat.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
+ * Copyright (C) 2020 Sean Anderson 
  * Copyright (c) 2013 Google, Inc
  *
  * (C) Copyright 2012
@@ -33,19 +34,33 @@
 #undef dev_warn
 #endif
 
-/*
- * REVISIT:
- * print device name like Linux
- */
-#define dev_printk(dev, fmt, ...)  \
-({ \
-   printk(fmt, ##__VA_ARGS__); \
+#ifdef VERBOSE_DEBUG
+#define _VERBOSE_DEBUG 1
+#else
+#define _VERBOSE_DEBUG 0
+#endif
+
+#define dev_printk_emit(cat, level, fmt, ...) \
+({ \
+   if ((_DEBUG && level == LOGL_DEBUG) || \
+   (_VERBOSE_DEBUG && level == LOGL_DEBUG_CONTENT)) \
+   printf(fmt, ##__VA_ARGS__); \
+   else if (CONFIG_IS_ENABLED(LOG)) \
+   log(cat, level, fmt, ##__VA_ARGS__); \
+   else if (level < CONFIG_VAL(LOGLEVEL)) \
+   printf(fmt, ##__VA_ARGS__); \
 })
 
-#define __dev_printk(level, dev, fmt, ...) \
-({ \
-   if (level < CONFIG_VAL(LOGLEVEL))   \
-   dev_printk(dev, fmt, ##__VA_ARGS__);\
+#define __dev_printk(level, dev, fmt, ...) \
+({ \
+   struct udevice *__dev = dev; \
+   if (__dev) \
+   dev_printk_emit(__dev->driver->id, level, "%s %s: " fmt, \
+   __dev->name, __dev->driver->name, \
+   ##__VA_ARGS__); \
+   else \
+   dev_printk_emit(LOG_CATEGORY, level, \
+   "(NULL udevice *): " fmt, ##__VA_ARGS__); \
 })
 
 #define dev_emerg(dev, fmt, ...) \
@@ -62,26 +77,9 @@
__dev_printk(LOGL_NOTICE, dev, fmt, ##__VA_ARGS__)
 #define dev_info(dev, fmt, ...) \
__dev_printk(LOGL_INFO, dev, fmt, ##__VA_ARGS__)
-
-#ifdef DEBUG
 #define dev_dbg(dev, fmt, ...) \
__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__)
-#else
-#define dev_dbg(dev, fmt, ...) \
-({ \
-   if (0)  \
-   __dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);  \
-})
-#endif
-
-#ifdef VERBOSE_DEBUG
-#define dev_vdbg   dev_dbg
-#else
-#define dev_vdbg(dev, fmt, ...)\
-({ \
-   if (0)  \
-   __dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);  \
-})
-#endif
+#define dev_vdbg(dev, fmt, ...) \
+   __dev_printk(LOGL_DEBUG_CONTENT, dev, fmt, ##__VA_ARGS__)
 
 #endif
-- 
2.28.0



[PATCH 2/4] net: mdio: Supply appropriate devices for dev_dgb calls

2020-09-12 Thread Sean Anderson
The name of the device we are working on is `ethdev` and not just `dev`.

Signed-off-by: Sean Anderson 
---

 net/mdio-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 66ee2e1976..b5e8e46512 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -145,7 +145,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct 
udevice *ethdev,
break;
 
if (!ofnode_valid(phandle.node)) {
-   dev_dbg(dev, "can't find PHY node\n");
+   dev_dbg(ethdev, "can't find PHY node\n");
return NULL;
}
 
@@ -161,7 +161,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct 
udevice *ethdev,
if (uclass_get_device_by_ofnode(UCLASS_MDIO,
ofnode_get_parent(phandle.node),
)) {
-   dev_dbg(dev, "can't find MDIO bus for node %s\n",
+   dev_dbg(ethdev, "can't find MDIO bus for node %s\n",
ofnode_get_name(ofnode_get_parent(phandle.node)));
return NULL;
}
-- 
2.28.0



[PATCH 3/4] dm: Use symbolic constants for log levels in dev_xxx()

2020-09-12 Thread Sean Anderson
This substitutes literal log levels with their symbolic constants.

Signed-off-by: Sean Anderson 
---

 include/dm/device_compat.h | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/dm/device_compat.h b/include/dm/device_compat.h
index 3d8cd09f4c..7c14aa464d 100644
--- a/include/dm/device_compat.h
+++ b/include/dm/device_compat.h
@@ -10,6 +10,7 @@
 #ifndef _DM_DEVICE_COMPAT_H
 #define _DM_DEVICE_COMPAT_H
 
+#include 
 #include 
 
 /*
@@ -48,28 +49,28 @@
 })
 
 #define dev_emerg(dev, fmt, ...) \
-   __dev_printk(0, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_EMERG, dev, fmt, ##__VA_ARGS__)
 #define dev_alert(dev, fmt, ...) \
-   __dev_printk(1, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_ALERT, dev, fmt, ##__VA_ARGS__)
 #define dev_crit(dev, fmt, ...) \
-   __dev_printk(2, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_CRIT, dev, fmt, ##__VA_ARGS__)
 #define dev_err(dev, fmt, ...) \
-   __dev_printk(3, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_ERR, dev, fmt, ##__VA_ARGS__)
 #define dev_warn(dev, fmt, ...) \
-   __dev_printk(4, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_WARNING, dev, fmt, ##__VA_ARGS__)
 #define dev_notice(dev, fmt, ...) \
-   __dev_printk(5, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_NOTICE, dev, fmt, ##__VA_ARGS__)
 #define dev_info(dev, fmt, ...) \
-   __dev_printk(6, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_INFO, dev, fmt, ##__VA_ARGS__)
 
 #ifdef DEBUG
 #define dev_dbg(dev, fmt, ...) \
-   __dev_printk(7, dev, fmt, ##__VA_ARGS__)
+   __dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__)
 #else
 #define dev_dbg(dev, fmt, ...) \
 ({ \
if (0)  \
-   __dev_printk(7, dev, fmt, ##__VA_ARGS__);   \
+   __dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);  \
 })
 #endif
 
@@ -79,7 +80,7 @@
 #define dev_vdbg(dev, fmt, ...)\
 ({ \
if (0)  \
-   __dev_printk(7, dev, fmt, ##__VA_ARGS__);   \
+   __dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);  \
 })
 #endif
 
-- 
2.28.0



[PATCH 0/4] dm: Print device name in dev_xxx() like Linux

2020-09-12 Thread Sean Anderson
This series adds some additional information to dev_dbg. With this series, and
the following options applied in addition to sandbox_defconfig

CONFIG_LOGLEVEL=8
CONFIG_LOG=n
CONFIG_CMD_LOG=n
CONFIG_CMD_TPM=n

the output of U-Boot is

U-Boot 2020.10-rc4-6-g19b641-dirty (Sep 12 2020 - 18:15:00 -0400)

Model: sandbox
DRAM:  128 MiB
pinctrl-gpio sandbox_pinctrl_gpio: set_state_simple op missing
leds gpio_led: set_state_simple op missing
default_on gpio_led: set_state_simple op missing
base-gpios sandbox_gpio: set_state_simple op missing
default_off gpio_led: set_state_simple op missing
wdt@0 wdt_sandbox: set_state_simple op missing
WDT:   Started with servicing (60s timeout)
MMC:   mmc0 mmc_sandbox: set_state_simple op missing
mmc1 mmc_sandbox: set_state_simple op missing
mmc2 mmc_sandbox: set_state_simple op missing
mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD)
lcd sandbox_lcd_sdl: set_state_simple op missing
In:serial
Out:   vidconsole
Err:   vidconsole
Model: sandbox
hog_input_active_low gpio_hog: set_state_simple op missing
hog_input_active_high gpio_hog: set_state_simple op missing
hog_output_low gpio_hog: set_state_simple op missing
hog_output_high gpio_hog: set_state_simple op missing
cros-ec google_cros_ec_sandbox: set_state_simple op missing
SCSI:
pci_ep pci_ep_sandbox: set_state_simple op missing
Net:   eth@10002000 eth_sandbox: set_state_simple op missing
eth0: eth@10002000eth@10003000 eth_sandbox: set_state_simple op missing
, eth5: eth@10003000sbe5 eth_sandbox: set_state_simple op missing
, eth3: sbe5eth@10004000 eth_sandbox: set_state_simple op missing
, eth6: eth@10004000
bootcount@0 bootcount-rtc: set_state_simple op missing
i2c@0 i2c_sandbox: set_state_simple op missing
rtc@61 rtc-sandbox: set_state_simple op missing
emul i2c_emul_parent_drv: set_state_simple op missing
emull sandbox_i2c_rtc_emul: set_state_simple op missing
Hit any key to stop autoboot:

When using CONFIG_LOG the output of U-Boot is too verbose to fit in this email.
Note that there is a soft dependency on [1] if you would like to test this patch
with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=201343


Sean Anderson (4):
  remoteproc: Remove unused function rproc_elf_sanity_check
  net: mdio: Supply appropriate devices for dev_dgb calls
  dm: Use symbolic constants for log levels in dev_xxx()
  dm: Print device name in dev_xxx() like Linux

 drivers/remoteproc/rproc-elf-loader.c | 16 --
 include/dm/device_compat.h| 75 +--
 include/remoteproc.h  | 13 -
 net/mdio-uclass.c |  4 +-
 4 files changed, 39 insertions(+), 69 deletions(-)

-- 
2.28.0



[PATCH 1/4] remoteproc: Remove unused function rproc_elf_sanity_check

2020-09-12 Thread Sean Anderson
This function is never used anywhere, and it also tries to log with a
nonexistant device.

Signed-off-by: Sean Anderson 
---

 drivers/remoteproc/rproc-elf-loader.c | 16 
 include/remoteproc.h  | 13 -
 2 files changed, 29 deletions(-)

diff --git a/drivers/remoteproc/rproc-elf-loader.c 
b/drivers/remoteproc/rproc-elf-loader.c
index c464ecebb7..b185a6cafb 100644
--- a/drivers/remoteproc/rproc-elf-loader.c
+++ b/drivers/remoteproc/rproc-elf-loader.c
@@ -158,22 +158,6 @@ int rproc_elf64_sanity_check(ulong addr, ulong size)
return 0;
 }
 
-/* Basic function to verify ELF image format */
-int rproc_elf_sanity_check(ulong addr, ulong size)
-{
-   Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr;
-
-   if (!addr) {
-   dev_err(dev, "Invalid firmware address\n");
-   return -EFAULT;
-   }
-
-   if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
-   return rproc_elf64_sanity_check(addr, size);
-   else
-   return rproc_elf32_sanity_check(addr, size);
-}
-
 int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size)
 {
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
diff --git a/include/remoteproc.h b/include/remoteproc.h
index a903acb9b2..74d01723f6 100644
--- a/include/remoteproc.h
+++ b/include/remoteproc.h
@@ -226,19 +226,6 @@ int rproc_elf32_sanity_check(ulong addr, ulong size);
  */
 int rproc_elf64_sanity_check(ulong addr, ulong size);
 
-/**
- * rproc_elf_sanity_check() - Verify if an image is a valid ELF one
- *
- * Check if a valid ELF image exists at the given memory location. Auto
- * detects ELF32/ELF64 and verifies basic ELF64/ELF32 format requirements
- * like magic number and sections size.
- *
- * @addr:  address of the image to verify
- * @size:  size of the image
- * @return 0 if the image looks good, else appropriate error value.
- */
-int rproc_elf_sanity_check(ulong addr, ulong size);
-
 /**
  * rproc_elf32_load_image() - load an ELF32 image
  * @dev:   device loading the ELF32 image
-- 
2.28.0



Re: [PATCH 0/4] dm: Print device name in dev_xxx() like Linux

2020-09-12 Thread Sean Anderson


On 9/12/20 8:28 PM, Sean Anderson wrote:
> This series adds some additional information to dev_dbg. With this series, and
> the following options applied in addition to sandbox_defconfig
> 
> CONFIG_LOGLEVEL=8
> CONFIG_LOG=n
> CONFIG_CMD_LOG=n
> CONFIG_CMD_TPM=n
> 
> the output of U-Boot is
> 
> U-Boot 2020.10-rc4-6-g19b641-dirty (Sep 12 2020 - 18:15:00 -0400)
> 
> Model: sandbox
> DRAM:  128 MiB
> pinctrl-gpio sandbox_pinctrl_gpio: set_state_simple op missing
> leds gpio_led: set_state_simple op missing
> default_on gpio_led: set_state_simple op missing
> base-gpios sandbox_gpio: set_state_simple op missing
> default_off gpio_led: set_state_simple op missing
> wdt@0 wdt_sandbox: set_state_simple op missing
> WDT:   Started with servicing (60s timeout)
> MMC:   mmc0 mmc_sandbox: set_state_simple op missing
> mmc1 mmc_sandbox: set_state_simple op missing
> mmc2 mmc_sandbox: set_state_simple op missing
> mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD)
> lcd sandbox_lcd_sdl: set_state_simple op missing
> In:serial
> Out:   vidconsole
> Err:   vidconsole
> Model: sandbox
> hog_input_active_low gpio_hog: set_state_simple op missing
> hog_input_active_high gpio_hog: set_state_simple op missing
> hog_output_low gpio_hog: set_state_simple op missing
> hog_output_high gpio_hog: set_state_simple op missing
> cros-ec google_cros_ec_sandbox: set_state_simple op missing
> SCSI:
> pci_ep pci_ep_sandbox: set_state_simple op missing
> Net:   eth@10002000 eth_sandbox: set_state_simple op missing
> eth0: eth@10002000eth@10003000 eth_sandbox: set_state_simple op missing
> , eth5: eth@10003000sbe5 eth_sandbox: set_state_simple op missing
> , eth3: sbe5eth@10004000 eth_sandbox: set_state_simple op missing
> , eth6: eth@10004000
> bootcount@0 bootcount-rtc: set_state_simple op missing
> i2c@0 i2c_sandbox: set_state_simple op missing
> rtc@61 rtc-sandbox: set_state_simple op missing
> emul i2c_emul_parent_drv: set_state_simple op missing
> emull sandbox_i2c_rtc_emul: set_state_simple op missing
> Hit any key to stop autoboot:
> 
> When using CONFIG_LOG the output of U-Boot is too verbose to fit in this 
> email.
> Note that there is a soft dependency on [1] if you would like to test this 
> patch
> with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.
> 
> [1] https://patchwork.ozlabs.org/project/uboot/list/?series=201343
> 
> 
> Sean Anderson (4):
>   remoteproc: Remove unused function rproc_elf_sanity_check
>   net: mdio: Supply appropriate devices for dev_dgb calls
>   dm: Use symbolic constants for log levels in dev_xxx()
>   dm: Print device name in dev_xxx() like Linux
> 
>  drivers/remoteproc/rproc-elf-loader.c | 16 --
>  include/dm/device_compat.h| 75 +--
>  include/remoteproc.h  | 13 -
>  net/mdio-uclass.c |  4 +-
>  4 files changed, 39 insertions(+), 69 deletions(-)
> 

In my haste I may have forgotten to run CI and make many more patches
like the first two to fix drivers calling a dev_ log function without an
actual device. So this series breaks a lot of things at the moment [1].
Consider it an RFC I guess for after I fix all those build failures.

--Sean

[1] 
https://dev.azure.com/seanga2/u-boot/_build/results?buildId=30=logs=7f2f73d6-a009-5260-5fdd-7738e0f76a89=97bcf3f1-e64d-5752-c0e9-95a663c62e27


[PATCH] ARM: mx6: ddr: Add support for iMX6UL/ULL/SL/SDL

2020-09-12 Thread Marek Vasut
This patch adds support for iMX6UL/ULL/SL/SDL MMDC into the DDR calibration
code. The difference between MX6DQ and MX6UL/ULL/SL is that the later SoCs
have 2 SDQS registers, just like MX6SX, while the MX6DQ/MX6SDL has 8.

Fixes: 4f4c128c65 ("ARM: mx6: ddr: Add support for iMX6SX")
Signed-off-by: Marek Vasut 
Cc: Eric Nelson 
Cc: Fabio Estevam 
Cc: Stefano Babic 
---
 arch/arm/mach-imx/mx6/ddr.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/mach-imx/mx6/ddr.c b/arch/arm/mach-imx/mx6/ddr.c
index 16df71083d..f872bfdab3 100644
--- a/arch/arm/mach-imx/mx6/ddr.c
+++ b/arch/arm/mach-imx/mx6/ddr.c
@@ -250,16 +250,31 @@ int mmdc_do_write_level_calibration(struct 
mx6_ddr_sysinfo const *sysinfo)
 
 static void mmdc_set_sdqs(bool set)
 {
+   struct mx6sdl_iomux_ddr_regs *mx6sdl_ddr_iomux =
+   (struct mx6sdl_iomux_ddr_regs *)MX6SDL_IOM_DDR_BASE;
struct mx6dq_iomux_ddr_regs *mx6dq_ddr_iomux =
(struct mx6dq_iomux_ddr_regs *)MX6DQ_IOM_DDR_BASE;
struct mx6sx_iomux_ddr_regs *mx6sx_ddr_iomux =
(struct mx6sx_iomux_ddr_regs *)MX6SX_IOM_DDR_BASE;
+   struct mx6sl_iomux_ddr_regs *mx6sl_ddr_iomux =
+   (struct mx6sl_iomux_ddr_regs *)MX6SL_IOM_DDR_BASE;
+   struct mx6ul_iomux_ddr_regs *mx6ul_ddr_iomux =
+   (struct mx6ul_iomux_ddr_regs *)MX6UL_IOM_DDR_BASE;
int i, sdqs_cnt;
u32 sdqs;
 
if (is_mx6sx()) {
sdqs = (u32)(_ddr_iomux->dram_sdqs0);
sdqs_cnt = 2;
+   } else if (is_mx6sl()) {
+   sdqs = (u32)(_ddr_iomux->dram_sdqs0);
+   sdqs_cnt = 2;
+   } else if (is_mx6ul() || is_mx6ull()) {
+   sdqs = (u32)(_ddr_iomux->dram_sdqs0);
+   sdqs_cnt = 2;
+   } else if (is_mx6sdl()) {
+   sdqs = (u32)(_ddr_iomux->dram_sdqs0);
+   sdqs_cnt = 8;
} else {/* MX6DQ */
sdqs = (u32)(_ddr_iomux->dram_sdqs0);
sdqs_cnt = 8;
-- 
2.28.0



Re: [PATCH 3/4] log: Add a way to enable/disable a log device

2020-09-12 Thread Simon Glass
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:25, Heinrich Schuchardt  wrote:
>
> Am 12. September 2020 20:28:49 MESZ schrieb Simon Glass :
> >At present all log devices are enabled by default. Add a function to
> >allow
> >devices to be disabled or enabled at runtime.
>
> Should this capability be added to the log command?

It's probably not a bad idea. I'll take a look.

Regards,
Simon


Re: [PATCH 4/4] log: Disable the syslog driver by default

2020-09-12 Thread Simon Glass
Hi Heinrich,

On Sat, 12 Sep 2020 at 14:34, Heinrich Schuchardt  wrote:
>
> Am 12. September 2020 22:24:24 MESZ schrieb Simon Glass :
> >Hi Heinrich,
> >
> >On Sat, 12 Sep 2020 at 14:16, Heinrich Schuchardt 
> >wrote:
> >>
> >> Am 12. September 2020 20:28:50 MESZ schrieb Simon Glass
> >:
> >> >This driver interferes with other sandbox tests since it causes log
> >> >output
> >> >to be interspersed with "No ethernet found." messages. Disable this
> >> >driver
> >> >by default.
> >> >
> >> >Enable it for the syslog tests so that they still pass.
> >> >
> >> >Signed-off-by: Simon Glass 
> >> >---
> >> >
> >> > common/log_syslog.c   |  1 -
> >> > test/log/syslog_test.c| 24 
> >> > test/log/syslog_test.h| 16 
> >> > test/log/syslog_test_ndebug.c |  2 ++
> >> > 4 files changed, 42 insertions(+), 1 deletion(-)
> >> >
> >> >diff --git a/common/log_syslog.c b/common/log_syslog.c
> >> >index cf0dbba9bf5..149ff5af310 100644
> >> >--- a/common/log_syslog.c
> >> >+++ b/common/log_syslog.c
> >> >@@ -115,5 +115,4 @@ out:
> >> > LOG_DRIVER(syslog) = {
> >> >   .name   = "syslog",
> >> >   .emit   = log_syslog_emit,
> >> >-  .flags  = LOGDF_ENABLE,
> >>
> >> What does the flag removal change outside Python testing?
> >
> >If this driver is to be used on a board, you must call
> >log_device_set_enable().
>
> This would pervert the nice log driver system that you have provided. I 
> definitively want syslog with vanilla code just by customizing.
>
> If you want to mute the network stack, then move it to use log and filter on 
> the network uclass.

Well sandbox has a network but it fails to send syslog messages, which
is probably a good thing, at least without someone saying they want it
to happen.

>
> Or simply adjust the test that has hickups.

I don't like that idea because any test can produce log output.

Another option would be to only disable the device with sandbox, e.g.

#ifndef CONFIG_SANDBOX
   .flags  = LOGDF_ENABLE,
#endif

Regards,
Simon