[PATCH 00/12] Various minor patches

This series contains a number of minor patches collected while completing the ACPI updates for U-Boot.
Simon Glass (12): log: Add missing category names x86: zimage: Add a little more logging x86: zimage: Sanity-check the kernel version before printing it x86: zimage: Quieten down the zimage boot process syscon: Drop the logging in syscon_get_by_driver_data() bloblist: Place on a 4KB boundary binman: Add a way to read the ROM offset binman: Support multiple images in the library log: Fix the comment for struct log_driver() board: Show memory for frame buffers i2c: designware: Use log_debug() for debugging tpm: cr50: Correct logging statements
arch/x86/lib/zimage.c | 26 +++++++++++++++++++++----- common/board_f.c | 6 +++++- common/log.c | 6 ++++++ drivers/core/syscon-uclass.c | 2 +- drivers/i2c/designware_i2c.c | 4 ++-- drivers/tpm/cr50_i2c.c | 10 +++++----- include/binman.h | 7 +++++++ include/log.h | 6 +++++- lib/binman.c | 14 +++++++++++++- 9 files changed, 65 insertions(+), 16 deletions(-)

Add some category names that were missed in recent changes. Update the comment as a reminder.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/log.c | 5 +++++ include/log.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/common/log.c b/common/log.c index 9a5f100da34..38336d84e3c 100644 --- a/common/log.c +++ b/common/log.c @@ -21,6 +21,11 @@ static const char *log_cat_name[LOGC_COUNT - LOGC_NONE] = { "driver-model", "device-tree", "efi", + "alloc", + "sandbox", + "bloblist", + "devres", + "acpi", };
static const char *log_level_name[LOGL_COUNT] = { diff --git a/include/log.h b/include/log.h index 2859ce1f2e7..00885004a36 100644 --- a/include/log.h +++ b/include/log.h @@ -39,7 +39,9 @@ enum log_level_t {
/** * Log categories supported. Most of these correspond to uclasses (i.e. - * enum uclass_id) but there are also some more generic categories + * enum uclass_id) but there are also some more generic categories. + * + * Remember to update log_cat_name[] after adding a new category. */ enum log_category_t { LOGC_FIRST = 0, /* First part mirrors UCLASS_... */

Am 28. September 2020 02:46:13 MESZ schrieb Simon Glass sjg@chromium.org:
Add some category names that were missed in recent changes. Update the comment as a reminder.
Signed-off-by: Simon Glass sjg@chromium.org
common/log.c | 5 +++++ include/log.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/common/log.c b/common/log.c index 9a5f100da34..38336d84e3c 100644 --- a/common/log.c +++ b/common/log.c @@ -21,6 +21,11 @@ static const char *log_cat_name[LOGC_COUNT - LOGC_NONE] = { "driver-model", "device-tree", "efi",
- "alloc",
- "sandbox",
- "bloblist",
- "devres",
- "acpi",
};
Should we add a compile time check that the array size matches the number of non-uclass categories?
Best regards
Heinrich
static const char *log_level_name[LOGL_COUNT] = { diff --git a/include/log.h b/include/log.h index 2859ce1f2e7..00885004a36 100644 --- a/include/log.h +++ b/include/log.h @@ -39,7 +39,9 @@ enum log_level_t {
/**
- Log categories supported. Most of these correspond to uclasses (i.e.
- enum uclass_id) but there are also some more generic categories
- enum uclass_id) but there are also some more generic categories.
- Remember to update log_cat_name[] after adding a new category.
*/ enum log_category_t { LOGC_FIRST = 0, /* First part mirrors UCLASS_... */

On Sun, Sep 27, 2020 at 06:46:13PM -0600, Simon Glass wrote:
Add some category names that were missed in recent changes. Update the comment as a reminder.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Add logging for each part of the boot process, using a new
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/lib/zimage.c | 6 ++++++ common/log.c | 1 + include/log.h | 1 + 3 files changed, 8 insertions(+)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index a00964cc8d9..7418c9a5fed 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -12,10 +12,13 @@ * linux/Documentation/i386/boot.txt */
+#define LOG_CATEGORY LOGC_BOOT + #include <common.h> #include <command.h> #include <env.h> #include <irq_func.h> +#include <log.h> #include <malloc.h> #include <acpi/acpi_table.h> #include <asm/io.h> @@ -292,6 +295,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, struct setup_header *hdr = &setup_base->hdr; int bootproto = get_boot_protocol(hdr, false);
+ log_debug("Setup E820 entries\n"); setup_base->e820_entries = install_e820_map( ARRAY_SIZE(setup_base->e820_map), setup_base->e820_map);
@@ -317,6 +321,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, }
if (cmd_line) { + log_debug("Setup cmdline\n"); if (bootproto >= 0x0202) { hdr->cmd_line_ptr = (uintptr_t)cmd_line; } else if (bootproto >= 0x0200) { @@ -340,6 +345,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) setup_base->acpi_rsdp_addr = acpi_get_rsdp_addr();
+ log_debug("Setup devicetree\n"); setup_device_tree(hdr, (const void *)env_get_hex("fdtaddr", 0)); setup_video(&setup_base->screen_info);
diff --git a/common/log.c b/common/log.c index 38336d84e3c..9c65688ba6d 100644 --- a/common/log.c +++ b/common/log.c @@ -26,6 +26,7 @@ static const char *log_cat_name[LOGC_COUNT - LOGC_NONE] = { "bloblist", "devres", "acpi", + "boot", };
static const char *log_level_name[LOGL_COUNT] = { diff --git a/include/log.h b/include/log.h index 00885004a36..dc1b6b5e4c6 100644 --- a/include/log.h +++ b/include/log.h @@ -59,6 +59,7 @@ enum log_category_t { LOGC_DEVRES, /* Device resources (devres_... functions) */ /* Advanced Configuration and Power Interface (ACPI) */ LOGC_ACPI, + LOGC_BOOT, /* Related to boot process / boot image processing */
LOGC_COUNT, /* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */

Hi Simon,
On Mon, Sep 28, 2020 at 8:46 AM Simon Glass sjg@chromium.org wrote:
Add logging for each part of the boot process, using a new
using a new category?
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/lib/zimage.c | 6 ++++++ common/log.c | 1 + include/log.h | 1 + 3 files changed, 8 insertions(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
Regards, Bin

Hi Simon,
On Fri, Oct 16, 2020 at 1:57 PM Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Mon, Sep 28, 2020 at 8:46 AM Simon Glass sjg@chromium.org wrote:
Add logging for each part of the boot process, using a new
using a new category?
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/lib/zimage.c | 6 ++++++ common/log.c | 1 + include/log.h | 1 + 3 files changed, 8 insertions(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
Could you please rebase this series?
Applying: x86: zimage: Add a little more logging error: patch failed: common/log.c:26 error: common/log.c: patch does not apply Patch failed at 0001 x86: zimage: Add a little more logging The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Regards, Bin

With Chrome OS the kernel setup block is stored in a separate place from the kernel, so it is not possible to access the kernel version string. At present, garbage is printed.
Add a sanity check to avoid this.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/lib/zimage.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 7418c9a5fed..d425ded596d 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -31,6 +31,7 @@ #include <asm/arch/timestamp.h> #endif #include <linux/compiler.h> +#include <linux/ctype.h> #include <linux/libfdt.h>
/* @@ -175,11 +176,19 @@ static const char *get_kernel_version(struct boot_params *params, { struct setup_header *hdr = ¶ms->hdr; int bootproto; + const char *s, *end;
bootproto = get_boot_protocol(hdr, false); if (bootproto < 0x0200 || hdr->setup_sects < 15) return NULL;
+ /* sanity-check the kernel version in case it is missing */ + for (s = kernel_base + hdr->kernel_version + 0x200, end = s + 0x100; *s; + s++) { + if (!isprint(*s)) + return NULL; + } + return kernel_base + hdr->kernel_version + 0x200; }

On Mon, Sep 28, 2020 at 8:46 AM Simon Glass sjg@chromium.org wrote:
With Chrome OS the kernel setup block is stored in a separate place from the kernel, so it is not possible to access the kernel version string. At present, garbage is printed.
Add a sanity check to avoid this.
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/lib/zimage.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

Much of the output is not very useful. The bootm command is quite a bit quieter. Convert some output to use log_debug().
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/lib/zimage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index d425ded596d..50fb16d2dac 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -212,13 +212,13 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
/* determine size of setup */ if (0 == hdr->setup_sects) { - printf("Setup Sectors = 0 (defaulting to 4)\n"); + log_warning("Setup Sectors = 0 (defaulting to 4)\n"); setup_size = 5 * 512; } else { setup_size = (hdr->setup_sects + 1) * 512; }
- printf("Setup Size = 0x%8.8lx\n", (ulong)setup_size); + log_debug("Setup Size = 0x%8.8lx\n", (ulong)setup_size);
if (setup_size > SETUP_MAX_SIZE) printf("Error: Setup is too large (%d bytes)\n", setup_size); @@ -226,8 +226,8 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, /* determine boot protocol version */ bootproto = get_boot_protocol(hdr, true);
- printf("Using boot protocol version %x.%02x\n", - (bootproto & 0xff00) >> 8, bootproto & 0xff); + log_debug("Using boot protocol version %x.%02x\n", + (bootproto & 0xff00) >> 8, bootproto & 0xff);
version = get_kernel_version(params, image); if (version) @@ -420,7 +420,8 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc, struct boot_params *from = (struct boot_params *)state.base_ptr;
base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE; - printf("Building boot_params at 0x%8.8lx\n", (ulong)base_ptr); + log_debug("Building boot_params at 0x%8.8lx\n", + (ulong)base_ptr); memset(base_ptr, '\0', sizeof(*base_ptr)); base_ptr->hdr = from->hdr; } else {

On Mon, Sep 28, 2020 at 8:46 AM Simon Glass sjg@chromium.org wrote:
Much of the output is not very useful. The bootm command is quite a bit quieter. Convert some output to use log_debug().
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/lib/zimage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

This function can be called when it is not known whether it will find anything. This results in confusing log messages if the device is not found. It is better for the caller to log the failure, if necessary.
Drop the logging from this function.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/core/syscon-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index 9cbda4ebdae..66ac579e465 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -140,7 +140,7 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp)
ret = uclass_first_device_drvdata(UCLASS_SYSCON, driver_data, devp); if (ret) - return log_msg_ret("find", ret); + return ret;
return 0; }

On Sun, Sep 27, 2020 at 06:46:17PM -0600, Simon Glass wrote:
This function can be called when it is not known whether it will find anything. This results in confusing log messages if the device is not found. It is better for the caller to log the failure, if necessary.
Drop the logging from this function.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

It is much easier to read the bloblist addresses if it starts on a 4KB boundary. Update it to align it accordingly.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_f.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/board_f.c b/common/board_f.c index 62473abf793..e99277d7e88 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -573,7 +573,9 @@ static int reserve_stacks(void) static int reserve_bloblist(void) { #ifdef CONFIG_BLOBLIST - gd->start_addr_sp = reserve_stack_aligned(CONFIG_BLOBLIST_SIZE); + /* Align to a 4KB boundary for easier reading of addresses */ + gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - CONFIG_BLOBLIST_SIZE, + 0x1000); gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE); #endif

On Sun, Sep 27, 2020 at 06:46:18PM -0600, Simon Glass wrote:
It is much easier to read the bloblist addresses if it starts on a 4KB boundary. Update it to align it accordingly.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Provide a function to read the ROM offset so that we can store the value in one place and clients don't need to store it themselves after calling binman_set_rom_offset().
Signed-off-by: Simon Glass sjg@chromium.org ---
include/binman.h | 7 +++++++ lib/binman.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/binman.h b/include/binman.h index e0b92075e27..8b89a9666d5 100644 --- a/include/binman.h +++ b/include/binman.h @@ -42,6 +42,13 @@ int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep); */ void binman_set_rom_offset(int rom_offset);
+/** + * binman_get_rom_offset() - Get the ROM memory-map offset + * + * @returns offset from an image_pos to the memory-mapped address + */ +int binman_get_rom_offset(void); + /** * binman_entry_find() - Find a binman symbol * diff --git a/lib/binman.c b/lib/binman.c index 7a8ad62c4a8..79e497fc8de 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -43,7 +43,7 @@ static int binman_entry_find_internal(ofnode node, const char *name,
ret = ofnode_read_u32(node, "image-pos", &entry->image_pos); if (ret) - return log_msg_ret("import-pos", ret); + return log_msg_ret("image-pos", ret); ret = ofnode_read_u32(node, "size", &entry->size); if (ret) return log_msg_ret("size", ret); @@ -83,6 +83,11 @@ void binman_set_rom_offset(int rom_offset) binman->rom_offset = rom_offset; }
+int binman_get_rom_offset(void) +{ + return binman->rom_offset; +} + int binman_init(void) { binman = malloc(sizeof(struct binman_info));

Provide a function to read the ROM offset so that we can store the value in one place and clients don't need to store it themselves after calling binman_set_rom_offset().
Signed-off-by: Simon Glass sjg@chromium.org ---
include/binman.h | 7 +++++++ lib/binman.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!

Add support for multiple images, since these are used on x86 now. Select the first image for now, since that is generally the correct one. At some point we can add a way to determine which image is currently running.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/binman.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lib/binman.c b/lib/binman.c index 79e497fc8de..e71c1b9e992 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -96,6 +96,13 @@ int binman_init(void) binman->image = ofnode_path("/binman"); if (!ofnode_valid(binman->image)) return log_msg_ret("binman node", -EINVAL); + if (ofnode_read_bool(binman->image, "multiple-images")) { + ofnode node = ofnode_first_subnode(binman->image); + + if (!ofnode_valid(node)) + return log_msg_ret("first image", -ENOENT); + binman->image = node; + } binman->rom_offset = ROM_OFFSET_NONE;
return 0;

Add support for multiple images, since these are used on x86 now. Select the first image for now, since that is generally the correct one. At some point we can add a way to determine which image is currently running.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/binman.c | 7 +++++++ 1 file changed, 7 insertions(+)
Applied to u-boot-dm, thanks!

This is missing a comment for the 'emit' member. Add it.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/log.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/log.h b/include/log.h index dc1b6b5e4c6..b49f5c99859 100644 --- a/include/log.h +++ b/include/log.h @@ -304,6 +304,7 @@ struct log_device; * 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 */ struct log_driver { const char *name;

Am 28. September 2020 02:46:21 MESZ schrieb Simon Glass sjg@chromium.org:
This is missing a comment for the 'emit' member. Add it.
Signed-off-by: Simon Glass sjg@chromium.org
include/log.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/log.h b/include/log.h index dc1b6b5e4c6..b49f5c99859 100644 --- a/include/log.h +++ b/include/log.h @@ -304,6 +304,7 @@ struct log_device;
- 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
*/ struct log_driver { const char *name;
log.h seems to be missing in the generated HTML documentation. Cf https://u-boot.readthedocs.io/en/latest/api/index.html
If we add it, make htmldocs will warn us of similar glitches.
Best regards
Heinrich

When debugging is enabled, show the memory allocated to video frame buffers.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_f.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/common/board_f.c b/common/board_f.c index e99277d7e88..9f441c44f17 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -392,6 +392,8 @@ static int reserve_video(void) ret = video_reserve(&addr); if (ret) return ret; + debug("Reserving %luk for video at: %08lx\n", + (unsigned long)gd->relocaddr - addr, addr); gd->relocaddr = addr; #elif defined(CONFIG_LCD) # ifdef CONFIG_FB_ADDR

On Sun, Sep 27, 2020 at 06:46:22PM -0600, Simon Glass wrote:
When debugging is enabled, show the memory allocated to video frame buffers.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

We don't want the debug output to be visible in a normal boot. Silence it.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/i2c/designware_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 569a5d39b49..791f32e971c 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -807,8 +807,8 @@ int designware_i2c_probe(struct udevice *bus) return -ENXIO; }
- log_info("I2C bus %s version %#x\n", bus->name, - readl(&priv->regs->comp_version)); + log_debug("I2C bus %s version %#x\n", bus->name, + readl(&priv->regs->comp_version));
return __dw_i2c_init(priv->regs, 0, 0); }

Hello Simon,
Am 28.09.2020 um 02:46 schrieb Simon Glass:
We don't want the debug output to be visible in a normal boot. Silence it.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/i2c/designware_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Heiko Schocherhs@denx.de
bye, Heiko

On Sun, Sep 27, 2020 at 06:46:23PM -0600, Simon Glass wrote:
We don't want the debug output to be visible in a normal boot. Silence it.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Heiko Schocherhs@denx.de
Applied to u-boot/master, thanks!

Fix up some logging statements in this file. Most of them should use log_debug(), apart from one error.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/tpm/cr50_i2c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index 64831a42232..a761e3d52f1 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -494,13 +494,13 @@ static int process_reset(struct udevice *dev) continue; }
- log_warning("TPM ready after %ld ms\n", get_timer(start)); + log_debug("TPM ready after %ld ms\n", get_timer(start));
return 0; } while (get_timer(start) < TIMEOUT_INIT_MS);
- log_warning("TPM failed to reset after %ld ms, status: %#x\n", - get_timer(start), access); + log_err("TPM failed to reset after %ld ms, status: %#x\n", + get_timer(start), access);
return -EPERM; } @@ -539,7 +539,7 @@ static int claim_locality(struct udevice *dev, int loc) log_err("Failed to claim locality\n"); return -EPERM; } - log_info("Claimed locality %d\n", loc); + log_debug("Claimed locality %d\n", loc); priv->locality = loc;
return 0; @@ -577,7 +577,7 @@ static int cr50_i2c_cleanup(struct udevice *dev) { struct cr50_priv *priv = dev_get_priv(dev);
- printf("%s: cleanup %d\n", __func__, priv->locality); + log_debug("cleanup %d\n", priv->locality); if (priv->locality != -1) release_locality(dev, 1);

On Sun, Sep 27, 2020 at 06:46:24PM -0600, Simon Glass wrote:
Fix up some logging statements in this file. Most of them should use log_debug(), apart from one error.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (5)
-
Bin Meng
-
Heiko Schocher
-
Heinrich Schuchardt
-
Simon Glass
-
Tom Rini