From 3800b318c5303633f056bc6ab387ef01906cee57 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Sat, 7 May 2022 21:23:05 +0800 Subject: [PATCH 01/25] boot: image-pre-load: drop unused CONFIG_SYS_BOOTM_LEN CONFIG_SYS_BOOTM_LEN is not used in this file, drop it. Signed-off-by: Peng Fan Reviewed-by: Tom Rini --- boot/image-pre-load.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c index 78d89069a98..5ab9ae18746 100644 --- a/boot/image-pre-load.c +++ b/boot/image-pre-load.c @@ -23,11 +23,6 @@ DECLARE_GLOBAL_DATA_PTR; #define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key" #define IMAGE_PRE_LOAD_PROP_MANDATORY "mandatory" -#ifndef CONFIG_SYS_BOOTM_LEN -/* use 8MByte as default max gunzip size */ -#define CONFIG_SYS_BOOTM_LEN 0x800000 -#endif - /* * Information in the device-tree about the signature in the header */ From c5ef2025579e91f132cd3cead8ebe8b4cd5dd2b6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 7 May 2022 22:39:01 +0200 Subject: [PATCH 02/25] dm: fix DM_EVENT dependencies CONFIG_DM_EVENT without CONFIG_EVENT is non-functional. Let CONFIG_DM_EVENT depend on CONFIG_EVENT. Remove superfluous stub in include/event.h. Fixes: 5b896ed5856f ("event: Add events for device probe/remove") Reported-by: Jan Kiszka Signed-off-by: Heinrich Schuchardt --- drivers/core/Kconfig | 3 +-- include/event.h | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 27d6578772a..9b9a7148a1a 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -89,8 +89,7 @@ config DM_DEVICE_REMOVE config DM_EVENT bool "Support events with driver model" - depends on DM - imply EVENT + depends on DM && EVENT default y if SANDBOX help This enables support for generating events related to driver model diff --git a/include/event.h b/include/event.h index 62e72a7bd31..7765f072503 100644 --- a/include/event.h +++ b/include/event.h @@ -144,7 +144,6 @@ int event_register(const char *id, enum event_t type, event_handler_t func, /** event_show_spy_list( - Show a list of event spies */ void event_show_spy_list(void); -#if CONFIG_IS_ENABLED(EVENT) /** * event_notify() - notify spies about an event * @@ -159,6 +158,7 @@ void event_show_spy_list(void); */ int event_notify(enum event_t type, void *data, int size); +#if CONFIG_IS_ENABLED(EVENT) /** * event_notify_null() - notify spies about an event * @@ -169,11 +169,6 @@ int event_notify(enum event_t type, void *data, int size); */ int event_notify_null(enum event_t type); #else -static inline int event_notify(enum event_t type, void *data, int size) -{ - return 0; -} - static inline int event_notify_null(enum event_t type) { return 0; From 7f0836a1105de86ef1b4ffdd608ebfe21504cb44 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 8 May 2022 13:01:42 +0300 Subject: [PATCH 03/25] cmd: dm: migrate dm command to use U_BOOT_CMD_WITH_SUBCMDS() Migrate dm command to use U_BOOT_CMD_WITH_SUBCMDS() helper macro, to reduce duplicated code. We can also drop the CONFIG_NEEDS_MANUAL_RELOC exception, as the command list is updated post relocation in board_r.c initcall initr_manual_reloc_cmdtable(). Signed-off-by: Ovidiu Panait --- cmd/dm.c | 64 +++++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 52 deletions(-) diff --git a/cmd/dm.c b/cmd/dm.c index 1dd19fe45b5..ca609224f55 100644 --- a/cmd/dm.c +++ b/cmd/dm.c @@ -8,12 +8,6 @@ #include #include -#include -#include -#include -#include -#include -#include #include static int do_dm_dump_all(struct cmd_tbl *cmdtp, int flag, int argc, @@ -64,55 +58,21 @@ static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, int ar return 0; } -static struct cmd_tbl test_commands[] = { - U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), - U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), - U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""), - U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""), - U_BOOT_CMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat, "", ""), - U_BOOT_CMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info, "", ""), -}; - -static __maybe_unused void dm_reloc(void) -{ - static int relocated; - - if (!relocated) { - fixup_cmdtable(test_commands, ARRAY_SIZE(test_commands)); - relocated = 1; - } -} - -static int do_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct cmd_tbl *test_cmd; - int ret; - -#ifdef CONFIG_NEEDS_MANUAL_RELOC - dm_reloc(); -#endif - - if (argc < 2) - return CMD_RET_USAGE; - test_cmd = find_cmd_tbl(argv[1], test_commands, - ARRAY_SIZE(test_commands)); - argc -= 2; - argv += 2; - if (!test_cmd || argc > test_cmd->maxargs) - return CMD_RET_USAGE; - - ret = test_cmd->cmd(test_cmd, flag, argc, argv); - - return cmd_process_error(test_cmd, ret); -} - -U_BOOT_CMD( - dm, 3, 1, do_dm, - "Driver model low level access", +#if CONFIG_IS_ENABLED(SYS_LONGHELP) +static char dm_help_text[] = "tree Dump driver model tree ('*' = activated)\n" "dm uclass Dump list of instances for each uclass\n" "dm devres Dump list of device resources for each device\n" "dm drivers Dump list of drivers with uclass and instances\n" "dm compat Dump list of drivers with compatibility strings\n" "dm static Dump list of drivers with static platform data" -); + ; +#endif + +U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text, + U_BOOT_SUBCMD_MKENT(tree, 1, 1, do_dm_dump_all), + U_BOOT_SUBCMD_MKENT(uclass, 1, 1, do_dm_dump_uclass), + U_BOOT_SUBCMD_MKENT(devres, 1, 1, do_dm_dump_devres), + U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers), + U_BOOT_SUBCMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat), + U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info)); From 92c1df98b3f71a142e99e31846f697dd2a544782 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Tue, 10 May 2022 09:58:28 +1200 Subject: [PATCH 04/25] doc: regulator: Add regulator-force-boot-off binding The actual support was added in commit fec8c900c8b2 ("power: regulator: Add support for regulator-force-boot-off"), update the docs to include this. Signed-off-by: Chris Packham --- doc/device-tree-bindings/regulator/regulator.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/device-tree-bindings/regulator/regulator.txt b/doc/device-tree-bindings/regulator/regulator.txt index 6c9a02120fd..ddb02b7a3c4 100644 --- a/doc/device-tree-bindings/regulator/regulator.txt +++ b/doc/device-tree-bindings/regulator/regulator.txt @@ -36,6 +36,7 @@ Optional properties: - regulator-always-on: regulator should never be disabled - regulator-boot-on: enabled by bootloader/firmware - regulator-ramp-delay: ramp delay for regulator (in uV/us) +- regulator-force-boot-off: disabled during the boot stage - regulator-init-microvolt: a init allowed Voltage value - regulator-state-(standby|mem|disk) type: object From 8a1ab5e81126c6ccedaa76376e7206f5c8583aa3 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 10 May 2022 12:51:47 -0400 Subject: [PATCH 05/25] misc: Correct Kconfig dependencies for a number of options We have many cases of SPL (or TPL or VPL) drivers that don't depend on SPL_MISC (and so on) but rather just MISC. Cc: Sean Anderson Signed-off-by: Tom Rini Reviewed-by: Sean Anderson --- drivers/misc/Kconfig | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 85ae7f62e91..419ddd31c0b 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -125,7 +125,7 @@ config CROS_EC config SPL_CROS_EC bool "Enable Chrome OS EC in SPL" - depends on SPL + depends on SPL_MISC help Enable access to the Chrome OS EC in SPL. This is a separate microcontroller typically available on a SPI bus on Chromebooks. It @@ -135,7 +135,7 @@ config SPL_CROS_EC config TPL_CROS_EC bool "Enable Chrome OS EC in TPL" - depends on TPL + depends on TPL_MISC help Enable access to the Chrome OS EC in TPL. This is a separate microcontroller typically available on a SPI bus on Chromebooks. It @@ -145,7 +145,7 @@ config TPL_CROS_EC config VPL_CROS_EC bool "Enable Chrome OS EC in VPL" - depends on VPL + depends on VPL_MISC help Enable access to the Chrome OS EC in VPL. This is a separate microcontroller typically available on a SPI bus on Chromebooks. It @@ -173,7 +173,7 @@ config CROS_EC_LPC config SPL_CROS_EC_LPC bool "Enable Chrome OS EC LPC driver in SPL" - depends on CROS_EC + depends on CROS_EC && SPL_MISC help Enable I2C access to the Chrome OS EC. This is used on x86 Chromebooks such as link and falco. The keyboard is provided @@ -182,7 +182,7 @@ config SPL_CROS_EC_LPC config TPL_CROS_EC_LPC bool "Enable Chrome OS EC LPC driver in TPL" - depends on CROS_EC + depends on CROS_EC && TPL_MISC help Enable I2C access to the Chrome OS EC. This is used on x86 Chromebooks such as link and falco. The keyboard is provided @@ -191,7 +191,7 @@ config TPL_CROS_EC_LPC config VPL_CROS_EC_LPC bool "Enable Chrome OS EC LPC driver in VPL" - depends on CROS_EC + depends on CROS_EC && VPL_MISC help Enable I2C access to the Chrome OS EC. This is used on x86 Chromebooks such as link and falco. The keyboard is provided @@ -284,7 +284,7 @@ config MXC_OCOTP config SPL_MXC_OCOTP bool "Enable MXC OCOTP driver in SPL" - depends on SPL && (ARCH_IMX8M || ARCH_MX6 || ARCH_MX7 || ARCH_MX7ULP || ARCH_VF610) + depends on SPL_MISC && (ARCH_IMX8M || ARCH_MX6 || ARCH_MX7 || ARCH_MX7ULP || ARCH_VF610) default y help If you say Y here, you will get support for the One Time @@ -314,7 +314,7 @@ config P2SB config SPL_P2SB bool "Intel Primary to Sideband Bridge in SPL" - depends on SPL && (X86 || SANDBOX) + depends on SPL_MISC && (X86 || SANDBOX) help The Primary to Sideband Bridge is used to access various peripherals through memory-mapped I/O in a large chunk of PCI space. The space is @@ -324,7 +324,7 @@ config SPL_P2SB config TPL_P2SB bool "Intel Primary to Sideband Bridge in TPL" - depends on TPL && (X86 || SANDBOX) + depends on TPL_MISC && (X86 || SANDBOX) help The Primary to Sideband Bridge is used to access various peripherals through memory-mapped I/O in a large chunk of PCI space. The space is @@ -343,7 +343,7 @@ config PWRSEQ config SPL_PWRSEQ bool "Enable power-sequencing drivers for SPL" - depends on PWRSEQ + depends on SPL_MISC && PWRSEQ help Power-sequencing drivers provide support for controlling power for devices. They are typically referenced by a phandle from another @@ -451,7 +451,7 @@ config I2C_EEPROM config SPL_I2C_EEPROM bool "Enable driver for generic I2C-attached EEPROMs for SPL" - depends on MISC && SPL && SPL_DM + depends on SPL_MISC help This option is an SPL-variant of the I2C_EEPROM option. See the help of I2C_EEPROM for details. @@ -504,6 +504,7 @@ config FS_LOADER config SPL_FS_LOADER bool "Enable loader driver for file system" + depends on SPL help This is file system generic loader which can be used to load the file image from the storage into target such as memory. From 2e2e784de0605081af7c5c9d04a014af69888c2c Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 10 May 2022 14:36:59 -0400 Subject: [PATCH 06/25] zlib: Port fix for CVE-2018-25032 to U-Boot While our copy of zlib is missing upstream commit 263b1a05b04e ("Allow deflatePrime() to insert bits in the middle of a stream.") we do have Z_FIXED support, and so the majority of the code changes in 5c44459c3b28 ("Fix a bug that can crash deflate on some input when using Z_FIXED.") apply here directly and cleanly. As this has been assigned a CVE, lets go and apply these changes. Link: https://github.com/madler/zlib/commit/5c44459c3b28a9bd3283aaceab7c615f8020c531 Reported-by: "Gan, Yau Wai" Signed-off-by: Tom Rini --- lib/zlib/deflate.c | 64 +++++++++++++++++++++++++++++++++++----------- lib/zlib/deflate.h | 25 ++++++++---------- lib/zlib/trees.c | 50 ++++++++++-------------------------- 3 files changed, 74 insertions(+), 65 deletions(-) diff --git a/lib/zlib/deflate.c b/lib/zlib/deflate.c index 63473359e45..4549f4dc12a 100644 --- a/lib/zlib/deflate.c +++ b/lib/zlib/deflate.c @@ -223,11 +223,6 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, int wrap = 1; static const char my_version[] = ZLIB_VERSION; - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { return Z_VERSION_ERROR; @@ -287,9 +282,47 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + /* We overlay pending_buf and sym_buf. This works since the average size + * for length/distance pairs over any compressed block is assured to be 31 + * bits or less. + * + * Analysis: The longest fixed codes are a length code of 8 bits plus 5 + * extra bits, for lengths 131 to 257. The longest fixed distance codes are + * 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest + * possible fixed-codes length/distance pair is then 31 bits total. + * + * sym_buf starts one-fourth of the way into pending_buf. So there are + * three bytes in sym_buf for every four bytes in pending_buf. Each symbol + * in sym_buf is three bytes -- two for the distance and one for the + * literal/length. As each symbol is consumed, the pointer to the next + * sym_buf value to read moves forward three bytes. From that symbol, up to + * 31 bits are written to pending_buf. The closest the written pending_buf + * bits gets to the next sym_buf symbol to read is just before the last + * code is written. At that time, 31*(n-2) bits have been written, just + * after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at + * 8*n bits into pending_buf. (Note that the symbol buffer fills when n-1 + * symbols are written.) The closest the writing gets to what is unread is + * then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and + * can range from 128 to 32768. + * + * Therefore, at a minimum, there are 142 bits of space between what is + * written and what is read in the overlain buffers, so the symbols cannot + * be overwritten by the compressed data. That space is actually 139 bits, + * due to the three-bit fixed-code block header. + * + * That covers the case where either Z_FIXED is specified, forcing fixed + * codes, or when the use of fixed codes is chosen, because that choice + * results in a smaller compressed block than dynamic codes. That latter + * condition then assures that the above analysis also covers all dynamic + * blocks. A dynamic-code block will only be chosen to be emitted if it has + * fewer bits than a fixed-code block would for the same set of symbols. + * Therefore its average symbol length is assured to be less than 31. So + * the compressed data for a dynamic block also cannot overwrite the + * symbols from which it is being constructed. + */ + + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); + s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { @@ -298,8 +331,12 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, deflateEnd (strm); return Z_MEM_ERROR; } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + s->sym_buf = s->pending_buf + s->lit_bufsize; + s->sym_end = (s->lit_bufsize - 1) * 3; + /* We avoid equality with lit_bufsize*3 because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ s->level = level; s->strategy = strategy; @@ -935,7 +972,6 @@ int ZEXPORT deflateCopy (dest, source) #else deflate_state *ds; deflate_state *ss; - ushf *overlay; if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { @@ -955,8 +991,7 @@ int ZEXPORT deflateCopy (dest, source) ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { @@ -970,8 +1005,7 @@ int ZEXPORT deflateCopy (dest, source) zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + ds->sym_buf = ds->pending_buf + ds->lit_bufsize; ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; diff --git a/lib/zlib/deflate.h b/lib/zlib/deflate.h index cbf0d1ea5d9..4c53b94af0b 100644 --- a/lib/zlib/deflate.h +++ b/lib/zlib/deflate.h @@ -211,7 +211,7 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ - uchf *l_buf; /* buffer for literals or lengths */ + uchf *sym_buf; /* buffer for distances and literals/lengths */ uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -233,13 +233,8 @@ typedef struct internal_state { * - I can't count above 4 */ - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ + uInt sym_next; /* running index in sym_buf */ + uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ @@ -318,20 +313,22 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = cc; \ s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ + flush = (s->sym_next == s->sym_end); \ } # define _tr_tally_dist(s, distance, length, flush) \ { uch len = (length); \ ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ + s->sym_buf[s->sym_next++] = dist; \ + s->sym_buf[s->sym_next++] = dist >> 8; \ + s->sym_buf[s->sym_next++] = len; \ dist--; \ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ + flush = (s->sym_next == s->sym_end); \ } #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) diff --git a/lib/zlib/trees.c b/lib/zlib/trees.c index 700c62f6d7b..970bc5dbc64 100644 --- a/lib/zlib/trees.c +++ b/lib/zlib/trees.c @@ -425,7 +425,7 @@ local void init_block(s) s->dyn_ltree[END_BLOCK].Freq = 1; s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; + s->sym_next = s->matches = 0; } #define SMALLEST 1 @@ -962,7 +962,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); + s->sym_next / 3)); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; @@ -1029,8 +1029,9 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) unsigned dist; /* distance of matched string */ unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ { - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; + s->sym_buf[s->sym_next++] = dist; + s->sym_buf[s->sym_next++] = dist >> 8; + s->sym_buf[s->sym_next++] = lc; if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; @@ -1045,30 +1046,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ + return (s->sym_next == s->sym_end); } /* =========================================================================== @@ -1081,13 +1059,14 @@ local void compress_block(s, ltree, dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ + unsigned sx = 0; /* running index in sym_buf */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; + if (s->sym_next != 0) do { + dist = s->sym_buf[sx++] & 0xff; + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; + lc = s->sym_buf[sx++]; if (dist == 0) { send_code(s, lc, ltree); /* send a literal byte */ Tracecv(isgraph(lc), (stderr," '%c' ", lc)); @@ -1112,11 +1091,10 @@ local void compress_block(s, ltree, dtree) } } /* literal or match pair ? */ - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); + /* Check that the overlay between pending_buf and sym_buf is ok: */ + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); - } while (lx < s->last_lit); + } while (sx < s->sym_next); send_code(s, END_BLOCK, ltree); s->last_eob_len = ltree[END_BLOCK].Len; From 89ab1e28173b7b23504ecd39e618fc73bbfd0371 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 10 May 2022 21:43:38 +0200 Subject: [PATCH 07/25] btrfs: simplify lookup_data_extent() After returning if ret <= 0 we know that ret > 0. No need to check it. Signed-off-by: Heinrich Schuchardt Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- fs/btrfs/inode.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d00b5153336..0173d30cd8a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -546,15 +546,12 @@ static int lookup_data_extent(struct btrfs_root *root, struct btrfs_path *path, /* Error or we're already at the file extent */ if (ret <= 0) return ret; - if (ret > 0) { - /* Check previous file extent */ - ret = btrfs_previous_item(root, path, ino, - BTRFS_EXTENT_DATA_KEY); - if (ret < 0) - return ret; - if (ret > 0) - goto check_next; - } + /* Check previous file extent */ + ret = btrfs_previous_item(root, path, ino, BTRFS_EXTENT_DATA_KEY); + if (ret < 0) + return ret; + if (ret > 0) + goto check_next; /* Now the key.offset must be smaller than @file_offset */ btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); if (key.objectid != ino || From 84378d5c86d1b8e7afd2132e2c8d79d8e7e1f7d9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 10 May 2022 21:53:25 +0200 Subject: [PATCH 08/25] fs/squashfs: fix sqfs_read_sblk() Setting sblk = NULL has no effect on the caller. We want to set *sblk = NULL if an error occurrs to avoid usage after free. Signed-off-by: Heinrich Schuchardt --- fs/squashfs/sqfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 547d2fd4b30..90bf32ca0ae 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -49,7 +49,7 @@ static int sqfs_read_sblk(struct squashfs_super_block **sblk) if (sqfs_disk_read(0, 1, *sblk) != 1) { free(*sblk); - sblk = NULL; + *sblk = NULL; return -EINVAL; } From b6c2b25f648102019f81ba22738879889ecc02c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Wed, 11 May 2022 10:36:07 +0100 Subject: [PATCH 09/25] scripts: Introduce {quiet_,}cmd_bin2c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a make command to compile binary files as C data through bin2c with $(call,bin2c,) Note that this requires BUILD_BIN2C=y. Cc: Simon Glass Signed-off-by: Pierre-Clément Tosi --- scripts/Makefile.lib | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3db2550085a..c0a5bb9addc 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -567,6 +567,11 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ # Additional commands for U-Boot # +# bin2c +# --------------------------------------------------------------------------- +quiet_cmd_bin2c = BIN2C $@ + cmd_bin2c = $(objtree)/scripts/bin2c $2 < $< > $@ + # mkimage # --------------------------------------------------------------------------- MKIMAGEOUTPUT ?= /dev/null From b4d3b338df14d3d793bcbd0c55ec3d4398596c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 13 May 2022 22:24:51 +0200 Subject: [PATCH 10/25] mtd: mtdpart: Change size type from fdt_addr_t to fdt_size_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set correct type for 3rd argument of ofnode_get_addr_size_index_notrans() function. It expects fdt_size_t * and not fdt_addr_t *. When these two types do not have same size then U-Boot throw compile warning: drivers/mtd/mtdpart.c: In function ‘add_mtd_partitions_of’: drivers/mtd/mtdpart.c:906:57: warning: passing argument 3 of ‘ofnode_get_addr_size_index_notrans’ from incompatible pointer type [-Wincompatible-pointer-types] offset = ofnode_get_addr_size_index_notrans(child, 0, &size); ^~~~~ In file included from include/dm/device.h:13, from include/linux/mtd/mtd.h:26, from include/ubi_uboot.h:28, from drivers/mtd/mtdpart.c:27: include/dm/ofnode.h:530:25: note: expected ‘fdt_size_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘fdt_addr_t *’ {aka ‘long unsigned int *’} fdt_size_t *size); ~~~~~~~~~~~~^~~~ Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/mtd/mtdpart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index d077897e4a7..56aa58b58bb 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -902,7 +902,8 @@ int add_mtd_partitions_of(struct mtd_info *master) ofnode_for_each_subnode(child, parts) { struct mtd_partition part = { 0 }; struct mtd_info *slave; - fdt_addr_t offset, size; + fdt_addr_t offset; + fdt_size_t size; if (!ofnode_is_available(child)) continue; From 12c90955a7e82687acaed3cb53d096bc669e82ca Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 15 May 2022 21:40:28 +0300 Subject: [PATCH 11/25] event: remove CONFIG_EVENT_DYNAMIC check in event_register() The whole event_register() function is wrapped in EVENT_DYNAMIC #ifdef checks, so the inner check is not needed: #if CONFIG_IS_ENABLED(EVENT_DYNAMIC) ... int event_register(...) { ... if (!CONFIG_IS_ENABLED(EVENT_DYNAMIC)) return -ENOSYS; } #endif Signed-off-by: Ovidiu Panait --- common/event.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/event.c b/common/event.c index 9d67a060a02..063647447d5 100644 --- a/common/event.c +++ b/common/event.c @@ -159,8 +159,6 @@ int event_register(const char *id, enum event_t type, event_handler_t func, void struct event_state *state = gd_event_state(); struct event_spy *spy; - if (!CONFIG_IS_ENABLED(EVENT_DYNAMIC)) - return -ENOSYS; spy = malloc(sizeof(*spy)); if (!spy) return log_msg_ret("alloc", -ENOMEM); From cebc8161708e357758c407eaa79a8cd66ee68fde Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 15 May 2022 21:40:29 +0300 Subject: [PATCH 12/25] event: fix static events for CONFIG_NEEDS_MANUAL_RELOC Static events do not currently work post-relocation for boards that enable CONFIG_NEEDS_MANUAL_RELOC. Relocate event handler pointers for all event spies to fix this. Tested on Microblaze. Signed-off-by: Ovidiu Panait --- common/board_r.c | 3 +++ common/event.c | 15 +++++++++++++++ include/event.h | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 22b5deaa8c2..4e3cf1f4ecc 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -612,6 +612,9 @@ static init_fnc_t init_sequence_r[] = { */ #endif initr_reloc_global_data, +#if CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC) && CONFIG_IS_ENABLED(EVENT) + event_manual_reloc, +#endif #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) initr_unlock_ram_in_cache, #endif diff --git a/common/event.c b/common/event.c index 063647447d5..af1ed4121d8 100644 --- a/common/event.c +++ b/common/event.c @@ -17,6 +17,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -148,6 +149,20 @@ void event_show_spy_list(void) } } +#if CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC) +int event_manual_reloc(void) +{ + struct evspy_info *spy, *end; + + spy = ll_entry_start(struct evspy_info, evspy_info); + end = ll_entry_end(struct evspy_info, evspy_info); + for (; spy < end; spy++) + MANUAL_RELOC(spy->func); + + return 0; +} +#endif + #if CONFIG_IS_ENABLED(EVENT_DYNAMIC) static void spy_free(struct event_spy *spy) { diff --git a/include/event.h b/include/event.h index 7765f072503..c00c4fb68dc 100644 --- a/include/event.h +++ b/include/event.h @@ -144,6 +144,16 @@ int event_register(const char *id, enum event_t type, event_handler_t func, /** event_show_spy_list( - Show a list of event spies */ void event_show_spy_list(void); +/** + * event_manual_reloc() - Relocate event handler pointers + * + * Relocate event handler pointers for all static event spies. It is called + * during the generic board init sequence, after relocation. + * + * Return: 0 if OK + */ +int event_manual_reloc(void); + /** * event_notify() - notify spies about an event * From 5920e5c838d1b6647878e51c0b9b8c9e4eaf1928 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 16 May 2022 16:11:07 -0400 Subject: [PATCH 13/25] mkimage: Document more misc options Document -G and the secondary image types which can be used with -R. Also reword the documentation of -s for clarity. Signed-off-by: Sean Anderson --- doc/mkimage.1 | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index c92e1337326..878db904757 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -99,6 +99,30 @@ Set image name to 'image name'. .BI "\-R [" "secondary image name" "]" Some image types support a second image for additional data. For these types, use \-R to specify this second image. +.TS +allbox; +lb lbx +l l. +Image Type Secondary Image Description +pblimage Additional RCW-style header, typically used for PBI commands. +zynqimage, zynqmpimage T{ +Initialization parameters, one per line. Each parameter has the form +.sp +.ti 4 +.I address data +.sp +where +.I address +and +.I data +are hexadecimal integers. The boot ROM will write each +.I data +to +.I address +when loading the image. At most 256 parameters may be specified in this +manner. +T} +.TE .TP .BI "\-d [" "image data file" "]" @@ -110,8 +134,8 @@ Set XIP (execute in place) flag. .TP .BI "\-s" -Create an image with no data. The header will be created, but the image itself -will not contain data (such as U-Boot or any specified kernel). +Don't copy in the image data. Depending on the image type, this may create +just the header, everything but the image data, or nothing at all. .TP .BI "\-v" @@ -176,6 +200,11 @@ Specifies the directory containing keys to use for signing. This directory should contain a private key file .key for use with signing and a certificate .crt (containing the public key) for use with verification. +.TP +.BI "\-G [" "key_file" "]" +Specifies the private key file to use when signing. This option may be used +instead of \-k. + .TP .BI "\-K [" "key_destination" "]" Specifies a compiled device tree binary file (typically .dtb) to write From 87b0af9317cb4105f3f29cb0a4c28c7cd87ea65f Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 16 May 2022 16:11:08 -0400 Subject: [PATCH 14/25] mkimage: Support signing 'auto' FITs This adds support for signing images in auto-generated FITs. To do this, we need to add a signature node. The algorithm name property already has its own option, but we need one for the key name hint. We could have gone the -G route and added an explicit name for the public key (like what is done for the private key). However, many places assume the public key can be constructed from the key dir and hint, and I don't want to do the refactoring necessary. As a consequence of this, it is now easier to add public keys to an existing image without signing something. This could be done all along, but now you don't have to create an its just to do it. Ideally, we wouldn't create a FIT at the end. This could be done by calling fit_image_setup_sig/info.crypto->add_verify_data directly. Signed-off-by: Sean Anderson --- doc/mkimage.1 | 24 ++++++++++++++++++++++++ tools/fit_image.c | 41 ++++++++++++++++++++++++++++++++++------- tools/imagetool.h | 1 + tools/mkimage.c | 5 ++++- 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index 878db904757..759dc2d12f5 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -218,6 +218,13 @@ CONFIG_OF_CONTROL in U-Boot. Specifies the private key file to use when signing. This option may be used instead of \-k. +.TP +.BI "\-g [" "key_name_hint" "]" +Sets the key-name-hint property when used with \-f auto. This is the +part of the key. The directory part is set by \-k. This option also indicates +that the images included in the FIT should be signed. If this option is +specified, \-o must be specified as well. + .TP .BI "\-o [" "signing algorithm" "]" Specifies the algorithm to be used for signing a FIT image. The default is @@ -278,6 +285,15 @@ skipping those for which keys cannot be found. Also add a comment. .B -c """Kernel 3.8 image for production devices""" kernel.itb .fi +.P +Add public keys to u-boot.dtb without needing a FIT to sign. This will also +create a FIT containing an images node with no data named unused.itb. +.nf +.B mkimage -f auto -d /dev/null -k /public/signing-keys -g dev \\\\ +.br +.B -o sha256,rsa2048 -K u-boot.dtb unused.itb +.fi + .P Update an existing FIT image, signing it with additional keys. Add corresponding public keys into u-boot.dtb. This will resign all images @@ -306,6 +322,14 @@ automatic mode. No .its file is required. .B -c """Kernel 4.4 image for production devices""" -d vmlinuz \\\\ .B -b /path/to/rk3288-firefly.dtb -b /path/to/rk3288-jerry.dtb kernel.itb .fi +.P +Create a FIT image containing a signed kernel, using automatic mode. No .its +file is required. +.nf +.B mkimage -f auto -A arm -O linux -T kernel -C none -a 43e00000 -e 0 \\\\ +.br +.B -d vmlinuz -k /secret/signing-keys -g dev -o sha256,rsa2048 kernel.itb +.fi .SH HOMEPAGE http://www.denx.de/wiki/U-Boot/WebHome diff --git a/tools/fit_image.c b/tools/fit_image.c index 1884a2eb0b9..979f2411ee0 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -199,15 +199,36 @@ static void get_basename(char *str, int size, const char *fname) } /** - * add_crc_node() - Add a hash node to request a CRC checksum for an image + * add_hash_node() - Add a hash or signature node * + * @params: Image parameters * @fdt: Device tree to add to (in sequential-write mode) + * + * If there is a key name hint, try to sign the images. Otherwise, just add a + * CRC. + * + * Return: 0 on success, or -1 on failure */ -static void add_crc_node(void *fdt) +static int add_hash_node(struct image_tool_params *params, void *fdt) { - fdt_begin_node(fdt, "hash-1"); - fdt_property_string(fdt, FIT_ALGO_PROP, "crc32"); + if (params->keyname) { + if (!params->algo_name) { + fprintf(stderr, + "%s: Algorithm name must be specified\n", + params->cmdname); + return -1; + } + + fdt_begin_node(fdt, "signature-1"); + fdt_property_string(fdt, FIT_ALGO_PROP, params->algo_name); + fdt_property_string(fdt, FIT_KEY_HINT, params->keyname); + } else { + fdt_begin_node(fdt, "hash-1"); + fdt_property_string(fdt, FIT_ALGO_PROP, "crc32"); + } + fdt_end_node(fdt); + return 0; } /** @@ -248,7 +269,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile); if (ret) return ret; - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); /* Now the device tree files if available */ @@ -271,7 +294,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) genimg_get_arch_short_name(params->arch)); fdt_property_string(fdt, FIT_COMP_PROP, genimg_get_comp_short_name(IH_COMP_NONE)); - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); } @@ -289,7 +314,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) params->fit_ramdisk); if (ret) return ret; - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); } diff --git a/tools/imagetool.h b/tools/imagetool.h index 05dd94d1084..ca7c2e48ba9 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -71,6 +71,7 @@ struct image_tool_params { const char *keydir; /* Directory holding private keys */ const char *keydest; /* Destination .dtb for public key */ const char *keyfile; /* Filename of private or public key */ + const char *keyname; /* Key name "hint" */ const char *comment; /* Comment to add to signature node */ /* Algorithm name to use for hashing/signing or NULL to use the one * specified in the its */ diff --git a/tools/mkimage.c b/tools/mkimage.c index 5c6a60e8513..0e1198b4113 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -119,6 +119,7 @@ static void usage(const char *msg) "Signing / verified boot options: [-k keydir] [-K dtb] [ -c ] [-p addr] [-r] [-N engine]\n" " -k => set directory containing private keys\n" " -K => write public keys to this .dtb file\n" + " -g => set key name hint\n" " -G => use this signing key (in lieu of -k)\n" " -c => add comment in signature node\n" " -F => re-sign existing FIT image\n" @@ -163,7 +164,7 @@ static void process_args(int argc, char **argv) int opt; while ((opt = getopt(argc, argv, - "a:A:b:B:c:C:d:D:e:Ef:FG:k:i:K:ln:N:p:o:O:rR:qstT:vVx")) != -1) { + "a:A:b:B:c:C:d:D:e:Ef:Fg:G:k:i:K:ln:N:p:o:O:rR:qstT:vVx")) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); @@ -239,6 +240,8 @@ static void process_args(int argc, char **argv) params.type = IH_TYPE_FLATDT; params.fflag = 1; break; + case 'g': + params.keyname = optarg; case 'G': params.keyfile = optarg; break; From bc8e09811e248287d1964ec6bba60c56235a23f2 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Tue, 17 May 2022 14:37:05 +0200 Subject: [PATCH 15/25] dm: core: convert of_machine_is_compatible to livetree Replace in the function of_machine_is_compatible(), the used API fdt_node_check_compatible() by ofnode_device_is_compatible() to support a live tree. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- drivers/core/device.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 3ab2583df38..3199d6a1b73 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -1125,9 +1125,7 @@ bool device_is_compatible(const struct udevice *dev, const char *compat) bool of_machine_is_compatible(const char *compat) { - const void *fdt = gd->fdt_blob; - - return !fdt_node_check_compatible(fdt, 0, compat); + return ofnode_device_is_compatible(ofnode_root(), compat); } int dev_disable_by_path(const char *path) From fb84517d52aa24b5b8bad6abc228459a146b6ba5 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Tue, 17 May 2022 13:55:07 -0400 Subject: [PATCH 16/25] serial: smh: Fake tstc ARM semihosting provides no provisions for determining if there is pending input. The only way to determine if there is console input is to do a read (and block until the user types something). For this reason, we always return true for tstc (since you will always get input if you try). However, this behavior can cause problems for code which expects tstc to eventually be empty. In query_console_serial, there is the following construct: /* empty input buffer */ while (tstc()) getchar(); with the current implementation, this effectively turns into an infinite loop. To avoid this, fake tstc by returning false half of the time. This is generally OK because the other common construct looks like do { if (tstc()) process(getchar()); } while (!timeout()); so it's fine if we only read a new character every other loop. This will break things like CYGACC_COMM_IF_GETC_TIMEOUT, but that could be reworked to test on the timeout instead of calling tstc again (and ymodem over semihosted serial is not that useful in the first place). Signed-off-by: Sean Anderson --- drivers/serial/serial_semihosting.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c index 2561414e40f..cfa1ec3148c 100644 --- a/drivers/serial/serial_semihosting.c +++ b/drivers/serial/serial_semihosting.c @@ -13,10 +13,12 @@ * struct smh_serial_priv - Semihosting serial private data * @infd: stdin file descriptor (or error) * @outfd: stdout file descriptor (or error) + * @counter: Counter used to fake pending every other call */ struct smh_serial_priv { int infd; int outfd; + unsigned counter; }; #if CONFIG_IS_ENABLED(DM_SERIAL) @@ -68,10 +70,20 @@ static ssize_t smh_serial_puts(struct udevice *dev, const char *s, size_t len) return ret; } +static int smh_serial_pending(struct udevice *dev, bool input) +{ + struct smh_serial_priv *priv = dev_get_priv(dev); + + if (input) + return priv->counter++ & 1; + return false; +} + static const struct dm_serial_ops smh_serial_ops = { .putc = smh_serial_putc, .puts = smh_serial_puts, .getc = smh_serial_getc, + .pending = smh_serial_pending, }; static int smh_serial_bind(struct udevice *dev) @@ -106,6 +118,7 @@ U_BOOT_DRVINFO(smh_serial) = { #else /* DM_SERIAL */ static int infd = -ENODEV; static int outfd = -ENODEV; +static unsigned counter = 1; static int smh_serial_start(void) { @@ -138,7 +151,7 @@ static int smh_serial_getc(void) static int smh_serial_tstc(void) { - return 1; + return counter++ & 1; } static void smh_serial_puts(const char *s) From 05947cb1d8d651b6b4e5f5dcbcef8e58d5ec4b44 Mon Sep 17 00:00:00 2001 From: Judy Wang Date: Tue, 3 May 2022 14:04:40 +0800 Subject: [PATCH 17/25] drivers:optee:rpmb: initialize drivers of mmc devices in UCLASS_BLK for rpmb access CONFIG_MMC only initializes drivers for devices in UCLASS_MMC, we need to initialize drivers for devices of type IF_TYPE_MMC in UCLASS_BLK as well because they are the child devices of devices in UCLASS_MMC. This is required for feature RPMB since it will access eMMC in optee-os. Signed-off-by: Judy Wang [trini: Add my SoB line and adjust Judy's name in git, having emailed off-list] Signed-off-by: Tom Rini --- drivers/tee/optee/rpmb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c index 0804fc963cf..cf5e0a08e61 100644 --- a/drivers/tee/optee/rpmb.c +++ b/drivers/tee/optee/rpmb.c @@ -72,6 +72,10 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id) debug("Cannot find RPMB device\n"); return NULL; } + if (mmc_init(mmc)) { + log(LOGC_BOARD, LOGL_ERR, "%s:MMC device %d init failed\n", __func__, dev_id); + return NULL; + } if (!(mmc->version & MMC_VERSION_MMC)) { debug("Device id %d is not an eMMC device\n", dev_id); return NULL; @@ -104,6 +108,11 @@ static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info) if (!mmc) return TEE_ERROR_ITEM_NOT_FOUND; + if (mmc_init(mmc)) { + log(LOGC_BOARD, LOGL_ERR, "%s:MMC device %d init failed\n", __func__, dev_id); + return TEE_ERROR_NOT_SUPPORTED; + } + if (!mmc->ext_csd) return TEE_ERROR_GENERIC; From 26f981f295d00351b6f0c69b5317b254b2361cc0 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 19 May 2022 11:10:43 +0200 Subject: [PATCH 18/25] fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQ Asking if the alias we found actually points at the device tree node we passed in (in the guise of its offset from blob) can be done simply by asking if the fdt_path_offset() of the alias' path is identical to offset. In fact, the current method suffers from the possibility of false negatives: dtc does not necessarily emit a phandle property for a node just because it is referenced in /aliases; it only emits a phandle property for a node if it is referenced in somewhere. So if both the node we passed in and the alias node we're considering don't have phandles, fdt_get_phandle() returns 0 for both. Since the proper check is so simple, there's no reason to hide that behind a config option (and if one really wanted that, it should be called something else because there's no need to involve phandle in the check). Signed-off-by: Rasmus Villemoes Acked-by: Aswath Govindraju --- configs/am65x_evm_a53_defconfig | 1 - configs/evb-ast2600_defconfig | 1 - configs/sama7g5ek_mmc1_defconfig | 1 - configs/sama7g5ek_mmc_defconfig | 1 - lib/Kconfig | 7 ------- lib/fdtdec.c | 7 ++----- 6 files changed, 2 insertions(+), 16 deletions(-) diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index 9c088e1d02e..65e41e5b6af 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -180,4 +180,3 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0451 CONFIG_USB_GADGET_PRODUCT_NUM=0x6162 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_OF_LIBFDT_OVERLAY=y -CONFIG_PHANDLE_CHECK_SEQ=y diff --git a/configs/evb-ast2600_defconfig b/configs/evb-ast2600_defconfig index 38d78d51924..bfd0a5f2b10 100644 --- a/configs/evb-ast2600_defconfig +++ b/configs/evb-ast2600_defconfig @@ -86,4 +86,3 @@ CONFIG_WDT=y CONFIG_SHA384=y CONFIG_HEXDUMP=y # CONFIG_EFI_LOADER is not set -CONFIG_PHANDLE_CHECK_SEQ=y diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig index 367cc48bba6..36343354945 100644 --- a/configs/sama7g5ek_mmc1_defconfig +++ b/configs/sama7g5ek_mmc1_defconfig @@ -80,4 +80,3 @@ CONFIG_TIMER=y CONFIG_MCHP_PIT64B_TIMER=y CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER_HII is not set -CONFIG_PHANDLE_CHECK_SEQ=y diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig index 1de21b74a46..e12bf285845 100644 --- a/configs/sama7g5ek_mmc_defconfig +++ b/configs/sama7g5ek_mmc_defconfig @@ -80,4 +80,3 @@ CONFIG_TIMER=y CONFIG_MCHP_PIT64B_TIMER=y CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER_HII is not set -CONFIG_PHANDLE_CHECK_SEQ=y diff --git a/lib/Kconfig b/lib/Kconfig index acc0ac081a4..884569f9b15 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -958,11 +958,4 @@ config LMB_RESERVED_REGIONS Define the number of supported reserved regions in the library logical memory blocks. -config PHANDLE_CHECK_SEQ - bool "Enable phandle check while getting sequence number" - help - When there are multiple device tree nodes with same name, - enable this config option to distinguish them using - phandles in fdtdec_get_alias_seq() function. - endmenu diff --git a/lib/fdtdec.c b/lib/fdtdec.c index e20f6aad9c2..ffa78f97ca0 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -516,11 +516,8 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset, * Adding an extra check to distinguish DT nodes with * same name */ - if (IS_ENABLED(CONFIG_PHANDLE_CHECK_SEQ)) { - if (fdt_get_phandle(blob, offset) != - fdt_get_phandle(blob, fdt_path_offset(blob, prop))) - continue; - } + if (offset != fdt_path_offset(blob, prop)) + continue; val = trailing_strtol(name); if (val != -1) { From f2ebaaa9f38dddddefaf2e616a9fc489fe8b4021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Thu, 19 May 2022 17:48:30 +0100 Subject: [PATCH 19/25] pci: Handle failed calloc in decode_regions() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check for calloc() failing to allocate the requested memory. Make decode_regions() return an error code. Cc: Bin Meng Cc: Simon Glass Cc: Stefan Roese Signed-off-by: Pierre-Clément Tosi Reviewed-by: Stefan Roese --- drivers/pci/pci-uclass.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 970ee1adf1b..2c85e78a136 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -954,7 +954,7 @@ int pci_bind_bus_devices(struct udevice *bus) return 0; } -static void decode_regions(struct pci_controller *hose, ofnode parent_node, +static int decode_regions(struct pci_controller *hose, ofnode parent_node, ofnode node) { int pci_addr_cells, addr_cells, size_cells; @@ -968,7 +968,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, prop = ofnode_get_property(node, "ranges", &len); if (!prop) { debug("%s: Cannot decode regions\n", __func__); - return; + return -EINVAL; } pci_addr_cells = ofnode_read_simple_addr_cells(node); @@ -986,6 +986,8 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, max_regions = len / cells_per_record + CONFIG_NR_DRAM_BANKS; hose->regions = (struct pci_region *) calloc(1, max_regions * sizeof(struct pci_region)); + if (!hose->regions) + return -ENOMEM; for (i = 0; i < max_regions; i++, len -= cells_per_record) { u64 pci_addr, addr, size; @@ -1053,7 +1055,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, /* Add a region for our local memory */ bd = gd->bd; if (!bd) - return; + return 0; for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { if (bd->bi_dram[i].size) { @@ -1068,7 +1070,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, } } - return; + return 0; } static int pci_uclass_pre_probe(struct udevice *bus) @@ -1097,7 +1099,10 @@ static int pci_uclass_pre_probe(struct udevice *bus) /* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus(bus)) { hose->ctlr = bus; - decode_regions(hose, dev_ofnode(bus->parent), dev_ofnode(bus)); + ret = decode_regions(hose, dev_ofnode(bus->parent), + dev_ofnode(bus)); + if (ret) + return ret; } else { struct pci_controller *parent_hose; From ba9aa40bb387385b8ef8b6594661a97ddcb8d04c Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Thu, 19 May 2022 18:26:05 -0400 Subject: [PATCH 20/25] bootm: Fix Linux silent console on newer kernels Linux determines its console based on several sources: 1. the console command line parameter 2. device tree (e.g. /chosen/stdout-path) 3. various other board- and arch-specific sources If the console parameter specifies a real console (e.g. ttyS0) then that is used as /dev/console. However, if it does not specify a real console (e.g. ttyDoesntExist) then *nothing* will be used as /dev/console. Reading/writing it will return ENODEV. Additionally, no other source will be used as a console source. Linux commit ab4af56ae250 ("printk/console: Allow to disable console output by using console="" or console=null") recently changed the semantics of the parameter. Previously, specifying console="" would be treated like specifying some other bad console. This commit changed things so that it added /dev/ttynull as a console (if available). However, it also allows for other console sources. If the device tree specifies a console (such as if U-Boot and Linux share a device tree), then it will be used in addition to /dev/ttynull. This can result in a non-silent console. To avoid this, explicitly set ttynull as the console. This will disable other console sources. If CONFIG_NULL_TTY is disabled, then this will have the same behavior as in the past (no output, and writing /dev/console returns ENODEV). [1] and [2] have additional background on this kernel change. [1] https://lore.kernel.org/all/20201006025935.GA597@jagdpanzerIV.localdomain/ [2] https://lore.kernel.org/all/20201111135450.11214-1-pmladek@suse.com/ Signed-off-by: Sean Anderson --- boot/bootm.c | 16 +++++++++------- test/bootm.c | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 714406ab668..dfa65f125e5 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -498,7 +498,8 @@ ulong bootm_disable_interrupts(void) } #define CONSOLE_ARG "console=" -#define CONSOLE_ARG_SIZE sizeof(CONSOLE_ARG) +#define NULL_CONSOLE (CONSOLE_ARG "ttynull") +#define CONSOLE_ARG_SIZE sizeof(NULL_CONSOLE) /** * fixup_silent_linux() - Handle silencing the linux boot if required @@ -550,21 +551,22 @@ static int fixup_silent_linux(char *buf, int maxlen) char *end = strchr(start, ' '); int start_bytes; - start_bytes = start - cmdline + CONSOLE_ARG_SIZE - 1; + start_bytes = start - cmdline; strncpy(buf, cmdline, start_bytes); + strncpy(buf + start_bytes, NULL_CONSOLE, CONSOLE_ARG_SIZE); if (end) - strcpy(buf + start_bytes, end); + strcpy(buf + start_bytes + CONSOLE_ARG_SIZE - 1, end); else - buf[start_bytes] = '\0'; + buf[start_bytes + CONSOLE_ARG_SIZE] = '\0'; } else { - sprintf(buf, "%s %s", cmdline, CONSOLE_ARG); + sprintf(buf, "%s %s", cmdline, NULL_CONSOLE); } if (buf + strlen(buf) >= cmdline) return -ENOSPC; } else { - if (maxlen < sizeof(CONSOLE_ARG)) + if (maxlen < CONSOLE_ARG_SIZE) return -ENOSPC; - strcpy(buf, CONSOLE_ARG); + strcpy(buf, NULL_CONSOLE); } debug("after silent fix-up: %s\n", buf); diff --git a/test/bootm.c b/test/bootm.c index 8528982ae11..7d03e1e0c68 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -83,12 +83,12 @@ static int bootm_test_silent(struct unit_test_state *uts) ut_assertok(env_set("silent_linux", "yes")); ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); - ut_asserteq_str("console=", buf); + ut_asserteq_str("console=ttynull", buf); /* Empty buffer should still add the string */ *buf = '\0'; ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); - ut_asserteq_str("console=", buf); + ut_asserteq_str("console=ttynull", buf); /* Check nothing happens when do_silent is false */ *buf = '\0'; @@ -97,21 +97,21 @@ static int bootm_test_silent(struct unit_test_state *uts) /* Not enough space */ *buf = '\0'; - ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 8, BOOTM_CL_SILENT)); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 15, BOOTM_CL_SILENT)); /* Just enough space */ *buf = '\0'; - ut_assertok(bootm_process_cmdline(buf, 9, BOOTM_CL_SILENT)); + ut_assertok(bootm_process_cmdline(buf, 16, BOOTM_CL_SILENT)); /* add at end */ strcpy(buf, "something"); ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); - ut_asserteq_str("something console=", buf); + ut_asserteq_str("something console=ttynull", buf); /* change at start */ strcpy(buf, CONSOLE_STR " something"); ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); - ut_asserteq_str("console= something", buf); + ut_asserteq_str("console=ttynull something", buf); return 0; } @@ -210,12 +210,12 @@ static int bootm_test_subst_var(struct unit_test_state *uts) { env_set("bootargs", NULL); ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); - ut_asserteq_str("console=", env_get("bootargs")); + ut_asserteq_str("console=ttynull", env_get("bootargs")); ut_assertok(env_set("var", "abc")); ut_assertok(env_set("bootargs", "some${var}thing")); ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); - ut_asserteq_str("some${var}thing console=", env_get("bootargs")); + ut_asserteq_str("some${var}thing console=ttynull", env_get("bootargs")); return 0; } @@ -227,12 +227,12 @@ static int bootm_test_subst_both(struct unit_test_state *uts) ut_assertok(env_set("silent_linux", "yes")); env_set("bootargs", NULL); ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL)); - ut_asserteq_str("console=", env_get("bootargs")); + ut_asserteq_str("console=ttynull", env_get("bootargs")); ut_assertok(env_set("bootargs", "some${var}thing " CONSOLE_STR)); ut_assertok(env_set("var", "1234567890")); ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL)); - ut_asserteq_str("some1234567890thing console=", env_get("bootargs")); + ut_asserteq_str("some1234567890thing console=ttynull", env_get("bootargs")); return 0; } From e5e04eaa2f1cb4dc37a12551018a00a18cab19de Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 20 May 2022 13:19:08 +0200 Subject: [PATCH 21/25] common/board_r.c: drop legacy and unused bi_enetaddr The bi_enetaddr field in struct bd_info is write-only; nothing ever reads back the value. Moreover, the value we write is more or less random, and certainly not something one can rely on: If the board has a writable environment and the mac address has been stored there, we fetch that value. But if the board doesn't, this code runs before initr_net() -> eth_initialize(), and thus before the code in eth-uclass which fetches MAC addresses from eeprom, fuses or whatnot and populates the (run-time) environment with those values. Signed-off-by: Rasmus Villemoes Reviewed-by: Tom Rini --- common/board_r.c | 15 --------------- include/asm-generic/u-boot.h | 1 - 2 files changed, 16 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 4e3cf1f4ecc..ed29069d2de 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -469,18 +469,6 @@ static int initr_malloc_bootparams(void) } #endif -#ifdef CONFIG_CMD_NET -static int initr_ethaddr(void) -{ - struct bd_info *bd = gd->bd; - - /* kept around for legacy kernels only ... ignore the next section */ - eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr); - - return 0; -} -#endif /* CONFIG_CMD_NET */ - #if defined(CONFIG_LED_STATUS) static int initr_status_led(void) { @@ -759,9 +747,6 @@ static init_fnc_t init_sequence_r[] = { initr_status_led, #endif /* PPC has a udelay(20) here dating from 2002. Why? */ -#ifdef CONFIG_CMD_NET - initr_ethaddr, -#endif #if defined(CONFIG_GPIO_HOG) gpio_hog_probe_all, #endif diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h index 1becc669aee..70303acd558 100644 --- a/include/asm-generic/u-boot.h +++ b/include/asm-generic/u-boot.h @@ -48,7 +48,6 @@ struct bd_info { #endif unsigned long bi_bootflags; /* boot / reboot flag (Unused) */ unsigned long bi_ip_addr; /* IP Address */ - unsigned char bi_enetaddr[6]; /* OLD: see README.enetaddr */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_busfreq; /* Bus Freq, in MHz */ From 98303ce73d7a14b8019824e7c7912a223e4a6207 Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Sun, 22 May 2022 15:22:08 +0200 Subject: [PATCH 22/25] include/configs: Remove rootwait=1 to all the affected boards rootwait=1 is not a valid kernel boot parameters. According to the documenation is only rootwait rootwait [KNL] Wait (indefinitely) for root device to show up. Useful for devices that are detected asynchronously (e.g. USB and MMC devices). Fix: Unknown kernel command line parameters "rootwait=1", will be passed to user space. Signed-off-by: Michael Trimarchi Reviewed-by: Heiko Schocher --- include/configs/am335x_evm.h | 2 +- include/configs/am43xx_evm.h | 2 +- include/configs/baltos.h | 2 +- include/configs/chiliboard.h | 2 +- include/configs/etamin.h | 2 +- include/configs/imx8mn_bsh_smm_s2.h | 2 +- include/configs/siemens-am33x-common.h | 4 ++-- include/configs/ti_armv7_keystone2.h | 2 +- include/environment/ti/nand.h | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 3e98e5c6653..13d11084cd4 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -34,7 +34,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "nand read ${fdtaddr} NAND.u-boot-spl-os; " \ diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h index 665ace5b01b..e0138fe1db8 100644 --- a/include/configs/am43xx_evm.h +++ b/include/configs/am43xx_evm.h @@ -159,7 +159,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,4096\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "nand read ${fdtaddr} NAND.u-boot-spl-os; " \ diff --git a/include/configs/baltos.h b/include/configs/baltos.h index b881d8c03fd..7b43741fde7 100644 --- a/include/configs/baltos.h +++ b/include/configs/baltos.h @@ -37,7 +37,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:rootfs rw ubi.mtd=5\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "setenv loadaddr 0x84000000; " \ diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h index 82acda595f0..8bad0f9ac4b 100644 --- a/include/configs/chiliboard.h +++ b/include/configs/chiliboard.h @@ -20,7 +20,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "nand read ${fdt_addr} NAND.u-boot-spl-os; " \ diff --git a/include/configs/etamin.h b/include/configs/etamin.h index 383beee17ae..654faedf33e 100644 --- a/include/configs/etamin.h +++ b/include/configs/etamin.h @@ -107,7 +107,7 @@ "nand_active_ubi_vol=rootfs_a\0" \ "rootfs_name=rootfs\0" \ "kernel_name=uImage\0"\ - "nand_root_fs_type=ubifs rootwait=1\0" \ + "nand_root_fs_type=ubifs rootwait\0" \ "nand_args=run bootargs_defaults;" \ "mtdparts default;" \ "setenv ${partitionset_active} true;" \ diff --git a/include/configs/imx8mn_bsh_smm_s2.h b/include/configs/imx8mn_bsh_smm_s2.h index 098f23b206d..f7529783692 100644 --- a/include/configs/imx8mn_bsh_smm_s2.h +++ b/include/configs/imx8mn_bsh_smm_s2.h @@ -21,7 +21,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:root rw ubi.mtd=nandrootfs\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "nand read ${fdt_addr_r} nanddtb; " \ diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h index 5dc09fa91cc..941e02c5c68 100644 --- a/include/configs/siemens-am33x-common.h +++ b/include/configs/siemens-am33x-common.h @@ -218,7 +218,7 @@ "nand_active_ubi_vol=rootfs_a\0" \ "nand_active_ubi_vol_A=rootfs_a\0" \ "nand_active_ubi_vol_B=rootfs_b\0" \ - "nand_root_fs_type=ubifs rootwait=1\0" \ + "nand_root_fs_type=ubifs rootwait\0" \ "nand_src_addr=0x280000\0" \ "nand_src_addr_A=0x280000\0" \ "nand_src_addr_B=0x780000\0" \ @@ -295,7 +295,7 @@ "nand_active_ubi_vol=rootfs_a\0" \ "rootfs_name=rootfs\0" \ "kernel_name=uImage\0"\ - "nand_root_fs_type=ubifs rootwait=1\0" \ + "nand_root_fs_type=ubifs rootwait\0" \ "nand_args=run bootargs_defaults;" \ "mtdparts default;" \ "setenv ${partitionset_active} true;" \ diff --git a/include/configs/ti_armv7_keystone2.h b/include/configs/ti_armv7_keystone2.h index 7fd79953dc1..6952cc63719 100644 --- a/include/configs/ti_armv7_keystone2.h +++ b/include/configs/ti_armv7_keystone2.h @@ -165,7 +165,7 @@ "sf write ${loadaddr} 0 ${filesize}\0" \ "burn_uboot_nand=nand erase 0 0x100000; " \ "nand write ${loadaddr} 0 ${filesize}\0" \ - "args_all=setenv bootargs console=ttyS0,115200n8 rootwait=1 " \ + "args_all=setenv bootargs console=ttyS0,115200n8 rootwait " \ KERNEL_MTD_PARTS \ "args_net=setenv bootargs ${bootargs} rootfstype=nfs " \ "root=/dev/nfs rw nfsroot=${serverip}:${nfs_root}," \ diff --git a/include/environment/ti/nand.h b/include/environment/ti/nand.h index 11dcefcc41c..7d00afa2b10 100644 --- a/include/environment/ti/nand.h +++ b/include/environment/ti/nand.h @@ -14,7 +14,7 @@ "root=${nandroot} " \ "rootfstype=${nandrootfstype}\0" \ "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \ - "nandrootfstype=ubifs rootwait=1\0" \ + "nandrootfstype=ubifs rootwait\0" \ "nandboot=echo Booting from nand ...; " \ "run nandargs; " \ "nand read ${fdtaddr} NAND.u-boot-spl-os; " \ From b257c4e9064dc4c2b86d30cec5ece368ca981225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Mon, 23 May 2022 22:50:36 +0200 Subject: [PATCH 23/25] ubifs: Add missing dependency on GZIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GZIP option can be manually de-selected when UBIFS is enabled. This cause following compile error because ubifs calls gzip functions. /tmp/ccxVrh2c.ltrans1.ltrans.o: in function `gzip_decompress.lto_priv.566': :(.text+0x768): undefined reference to `zunzip' collect2: error: ld returned 1 exit status make: *** [Makefile:1813: u-boot] Error 1 So add missing dependency on GZIP. Signed-off-by: Pali Rohár --- cmd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 06ec81007ad..9a0b7203112 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2569,6 +2569,7 @@ config CMD_UBIFS depends on CMD_UBI default y if CMD_UBI select LZO + select GZIP help UBIFS is a file system for flash devices which works on top of UBI. From 24272ffd505be0597703032dbdd8ffdd7ef7a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Wed, 25 May 2022 14:38:55 +0100 Subject: [PATCH 24/25] qfw: Don't fail if setup data size is 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip missing setup data (which is valid) rather than failing with an error. Cc: Bin Meng Cc: Simon Glass Reported-by: Andrew Walbran Signed-off-by: Pierre-Clément Tosi --- cmd/qfw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/qfw.c b/cmd/qfw.c index d58615040c6..ccbc967ca9f 100644 --- a/cmd/qfw.c +++ b/cmd/qfw.c @@ -25,15 +25,17 @@ static int qemu_fwcfg_cmd_setup_kernel(void *load_addr, void *initrd_addr) qfw_read_entry(qfw_dev, FW_CFG_SETUP_SIZE, 4, &setup_size); qfw_read_entry(qfw_dev, FW_CFG_KERNEL_SIZE, 4, &kernel_size); - if (setup_size == 0 || kernel_size == 0) { + if (kernel_size == 0) { printf("warning: no kernel available\n"); return -1; } data_addr = load_addr; - qfw_read_entry(qfw_dev, FW_CFG_SETUP_DATA, - le32_to_cpu(setup_size), data_addr); - data_addr += le32_to_cpu(setup_size); + if (setup_size != 0) { + qfw_read_entry(qfw_dev, FW_CFG_SETUP_DATA, + le32_to_cpu(setup_size), data_addr); + data_addr += le32_to_cpu(setup_size); + } qfw_read_entry(qfw_dev, FW_CFG_KERNEL_DATA, le32_to_cpu(kernel_size), data_addr); From b62450cf229c50ad2ce819dd02a09726909cc89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 27 May 2022 22:15:24 +0200 Subject: [PATCH 25/25] serial: Replace CONFIG_DEBUG_UART_BASE by CONFIG_VAL(DEBUG_UART_BASE) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CONFIG_VAL(DEBUG_UART_BASE) expands to CONFIG_DEBUG_UART_BASE or CONFIG_SPL_DEBUG_UART_BASE or CONFIG_TPL_DEBUG_UART_BASE and allows boards to set different values for SPL, TPL and U-Boot Proper. For ns16550 driver this support is there since commit d293759d55cc ("serial: ns16550: Add support for SPL_DEBUG_UART_BASE"). Signed-off-by: Pali Rohár --- arch/arm/mach-uniphier/debug-uart/debug-uart.c | 4 ++-- arch/x86/cpu/apollolake/cpu_common.c | 2 +- board/eets/pdu001/board.c | 2 +- drivers/serial/altera_jtag_uart.c | 2 +- drivers/serial/altera_uart.c | 4 ++-- drivers/serial/atmel_usart.c | 4 ++-- drivers/serial/serial_ar933x.c | 4 ++-- drivers/serial/serial_arc.c | 4 ++-- drivers/serial/serial_bcm6345.c | 4 ++-- drivers/serial/serial_linflexuart.c | 4 ++-- drivers/serial/serial_meson.c | 2 +- drivers/serial/serial_msm_geni.c | 6 +++--- drivers/serial/serial_mt7620.c | 4 ++-- drivers/serial/serial_mtk.c | 4 ++-- drivers/serial/serial_mvebu_a3700.c | 4 ++-- drivers/serial/serial_mxc.c | 4 ++-- drivers/serial/serial_omap.c | 4 ++-- drivers/serial/serial_pic32.c | 4 ++-- drivers/serial/serial_pl01x.c | 4 ++-- drivers/serial/serial_s5p.c | 4 ++-- drivers/serial/serial_sifive.c | 4 ++-- drivers/serial/serial_stm32.c | 4 ++-- drivers/serial/serial_xuartlite.c | 4 ++-- drivers/serial/serial_zynq.c | 4 ++-- 24 files changed, 45 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-uniphier/debug-uart/debug-uart.c b/arch/arm/mach-uniphier/debug-uart/debug-uart.c index d116d46812d..1ba012ca45d 100644 --- a/arch/arm/mach-uniphier/debug-uart/debug-uart.c +++ b/arch/arm/mach-uniphier/debug-uart/debug-uart.c @@ -18,7 +18,7 @@ static void _debug_uart_putc(int c) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); while (!(readl(base + UNIPHIER_UART_LSR) & UART_LSR_THRE)) ; @@ -57,7 +57,7 @@ void sg_set_iectrl(unsigned int pin) void _debug_uart_init(void) { #ifdef CONFIG_SPL_BUILD - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); unsigned int divisor; switch (uniphier_get_soc_id()) { diff --git a/arch/x86/cpu/apollolake/cpu_common.c b/arch/x86/cpu/apollolake/cpu_common.c index 5d7d26b140f..9a5502617bf 100644 --- a/arch/x86/cpu/apollolake/cpu_common.c +++ b/arch/x86/cpu/apollolake/cpu_common.c @@ -72,7 +72,7 @@ static void pch_uart_init(void) } #ifdef CONFIG_DEBUG_UART - apl_uart_init(PCH_DEV_UART, CONFIG_DEBUG_UART_BASE); + apl_uart_init(PCH_DEV_UART, CONFIG_VAL(DEBUG_UART_BASE)); #endif } diff --git a/board/eets/pdu001/board.c b/board/eets/pdu001/board.c index 2b483dab8e1..1054837d434 100644 --- a/board/eets/pdu001/board.c +++ b/board/eets/pdu001/board.c @@ -273,7 +273,7 @@ void board_debug_uart_init(void) setup_early_clocks(); /* done by pin controller driver if not debugging */ - enable_uart_pin_mux(CONFIG_DEBUG_UART_BASE); + enable_uart_pin_mux(CONFIG_VAL(DEBUG_UART_BASE)); } #endif diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c index 4435fcf56b9..9e39da7dd24 100644 --- a/drivers/serial/altera_jtag_uart.c +++ b/drivers/serial/altera_jtag_uart.c @@ -134,7 +134,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct altera_jtaguart_regs *regs = (void *)CONFIG_DEBUG_UART_BASE; + struct altera_jtaguart_regs *regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); while (1) { u32 st = readl(®s->control); diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c index b18be6e2454..35920480841 100644 --- a/drivers/serial/altera_uart.c +++ b/drivers/serial/altera_uart.c @@ -123,7 +123,7 @@ U_BOOT_DRIVER(altera_uart) = { static inline void _debug_uart_init(void) { - struct altera_uart_regs *regs = (void *)CONFIG_DEBUG_UART_BASE; + struct altera_uart_regs *regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); u32 div; div = (CONFIG_DEBUG_UART_CLOCK / CONFIG_BAUDRATE) - 1; @@ -132,7 +132,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct altera_uart_regs *regs = (void *)CONFIG_DEBUG_UART_BASE; + struct altera_uart_regs *regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); while (1) { u32 st = readl(®s->status); diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c index bd14f3e7819..1fb9ee5cc94 100644 --- a/drivers/serial/atmel_usart.c +++ b/drivers/serial/atmel_usart.c @@ -319,14 +319,14 @@ U_BOOT_DRIVER(serial_atmel) = { #ifdef CONFIG_DEBUG_UART_ATMEL static inline void _debug_uart_init(void) { - atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_VAL(DEBUG_UART_BASE); _atmel_serial_init(usart, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); } static inline void _debug_uart_putc(int ch) { - atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_VAL(DEBUG_UART_BASE); while (!(readl(&usart->csr) & USART3_BIT(TXRDY))) ; diff --git a/drivers/serial/serial_ar933x.c b/drivers/serial/serial_ar933x.c index da06bef97c7..4f916349762 100644 --- a/drivers/serial/serial_ar933x.c +++ b/drivers/serial/serial_ar933x.c @@ -199,7 +199,7 @@ U_BOOT_DRIVER(serial_ar933x) = { static inline void _debug_uart_init(void) { - void __iomem *regs = (void *)CONFIG_DEBUG_UART_BASE; + void __iomem *regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); u32 val, scale, step; /* @@ -227,7 +227,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int c) { - void __iomem *regs = (void *)CONFIG_DEBUG_UART_BASE; + void __iomem *regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); u32 data; do { diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 8f3e4dd44f1..b2d95bdbe18 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -137,7 +137,7 @@ U_BOOT_DRIVER(serial_arc) = { static inline void _debug_uart_init(void) { - struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_DEBUG_UART_BASE; + struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_VAL(DEBUG_UART_BASE); int arc_console_baud = CONFIG_DEBUG_UART_CLOCK / (CONFIG_BAUDRATE * 4) - 1; writeb(arc_console_baud & 0xff, ®s->baudl); @@ -146,7 +146,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int c) { - struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_DEBUG_UART_BASE; + struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_VAL(DEBUG_UART_BASE); while (!(readb(®s->status) & UART_TXEMPTY)) ; diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c index f08e91ff3ba..2359656a239 100644 --- a/drivers/serial/serial_bcm6345.c +++ b/drivers/serial/serial_bcm6345.c @@ -269,7 +269,7 @@ U_BOOT_DRIVER(bcm6345_serial) = { #ifdef CONFIG_DEBUG_UART_BCM6345 static inline void _debug_uart_init(void) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); bcm6345_serial_init(base, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); } @@ -285,7 +285,7 @@ static inline void wait_xfered(void __iomem *base) static inline void _debug_uart_putc(int ch) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); wait_xfered(base); writel(ch, base + UART_FIFO_REG); diff --git a/drivers/serial/serial_linflexuart.c b/drivers/serial/serial_linflexuart.c index 876a4baa9fc..b449e55a650 100644 --- a/drivers/serial/serial_linflexuart.c +++ b/drivers/serial/serial_linflexuart.c @@ -201,14 +201,14 @@ U_BOOT_DRIVER(serial_linflex) = { static inline void _debug_uart_init(void) { - struct linflex_fsl *base = (struct linflex_fsl *)CONFIG_DEBUG_UART_BASE; + struct linflex_fsl *base = (struct linflex_fsl *)CONFIG_VAL(DEBUG_UART_BASE); linflex_serial_init_internal(base); } static inline void _debug_uart_putc(int ch) { - struct linflex_fsl *base = (struct linflex_fsl *)CONFIG_DEBUG_UART_BASE; + struct linflex_fsl *base = (struct linflex_fsl *)CONFIG_VAL(DEBUG_UART_BASE); /* XXX: Is this OK? Should this use the non-DM version? */ _linflex_serial_putc(base, ch); diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c index d69ec221e45..c5ed3ede45e 100644 --- a/drivers/serial/serial_meson.c +++ b/drivers/serial/serial_meson.c @@ -182,7 +182,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct meson_uart *regs = (struct meson_uart *)CONFIG_DEBUG_UART_BASE; + struct meson_uart *regs = (struct meson_uart *)CONFIG_VAL(DEBUG_UART_BASE); while (readl(®s->status) & AML_UART_TX_FULL) ; diff --git a/drivers/serial/serial_msm_geni.c b/drivers/serial/serial_msm_geni.c index 3e255a99dcc..3943ca43e49 100644 --- a/drivers/serial/serial_msm_geni.c +++ b/drivers/serial/serial_msm_geni.c @@ -569,7 +569,7 @@ U_BOOT_DRIVER(serial_msm_geni) = { #ifdef CONFIG_DEBUG_UART_MSM_GENI static struct msm_serial_data init_serial_data = { - .base = CONFIG_DEBUG_UART_BASE + .base = CONFIG_VAL(DEBUG_UART_BASE) }; /* Serial dumb device, to reuse driver code */ @@ -587,7 +587,7 @@ static struct udevice init_dev = { static inline void _debug_uart_init(void) { - phys_addr_t base = CONFIG_DEBUG_UART_BASE; + phys_addr_t base = CONFIG_VAL(DEBUG_UART_BASE); geni_serial_init(&init_dev); geni_serial_baud(base, CLK_DIV, CONFIG_BAUDRATE); @@ -596,7 +596,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - phys_addr_t base = CONFIG_DEBUG_UART_BASE; + phys_addr_t base = CONFIG_VAL(DEBUG_UART_BASE); writel(DEF_TX_WM, base + SE_GENI_TX_WATERMARK_REG); qcom_geni_serial_setup_tx(base, 1); diff --git a/drivers/serial/serial_mt7620.c b/drivers/serial/serial_mt7620.c index 76ecc2b38ce..5c5264bc962 100644 --- a/drivers/serial/serial_mt7620.c +++ b/drivers/serial/serial_mt7620.c @@ -220,7 +220,7 @@ static inline void _debug_uart_init(void) { struct mt7620_serial_plat plat; - plat.regs = (void *)CONFIG_DEBUG_UART_BASE; + plat.regs = (void *)CONFIG_VAL(DEBUG_UART_BASE); plat.clock = CONFIG_DEBUG_UART_CLOCK; writel(0, &plat.regs->ier); @@ -233,7 +233,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { struct mt7620_serial_regs __iomem *regs = - (void *)CONFIG_DEBUG_UART_BASE; + (void *)CONFIG_VAL(DEBUG_UART_BASE); while (!(readl(®s->lsr) & UART_LSR_THRE)) ; diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c index 4145d9fdb3d..a84f39b3fa2 100644 --- a/drivers/serial/serial_mtk.c +++ b/drivers/serial/serial_mtk.c @@ -426,7 +426,7 @@ static inline void _debug_uart_init(void) { struct mtk_serial_priv priv; - priv.regs = (void *) CONFIG_DEBUG_UART_BASE; + priv.regs = (void *) CONFIG_VAL(DEBUG_UART_BASE); priv.clock = CONFIG_DEBUG_UART_CLOCK; writel(0, &priv.regs->ier); @@ -439,7 +439,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { struct mtk_serial_regs __iomem *regs = - (void *) CONFIG_DEBUG_UART_BASE; + (void *) CONFIG_VAL(DEBUG_UART_BASE); while (!(readl(®s->lsr) & UART_LSR_THRE)) ; diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c index 3e673bde57b..0fcd7e88ace 100644 --- a/drivers/serial/serial_mvebu_a3700.c +++ b/drivers/serial/serial_mvebu_a3700.c @@ -321,7 +321,7 @@ U_BOOT_DRIVER(serial_mvebu) = { static inline void _debug_uart_init(void) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); u32 parent_rate, divider; /* reset FIFOs */ @@ -349,7 +349,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); while (readl(base + UART_STATUS_REG) & UART_STATUS_TXFIFO_FULL) ; diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index e4970a169bd..70a0e5e9197 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -372,7 +372,7 @@ U_BOOT_DRIVER(serial_mxc) = { static inline void _debug_uart_init(void) { - struct mxc_uart *base = (struct mxc_uart *)CONFIG_DEBUG_UART_BASE; + struct mxc_uart *base = (struct mxc_uart *)CONFIG_VAL(DEBUG_UART_BASE); _mxc_serial_init(base, false); _mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK, @@ -381,7 +381,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct mxc_uart *base = (struct mxc_uart *)CONFIG_DEBUG_UART_BASE; + struct mxc_uart *base = (struct mxc_uart *)CONFIG_VAL(DEBUG_UART_BASE); while (!(readl(&base->ts) & UTS_TXEMPTY)) WATCHDOG_RESET(); diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c index ee938f67632..e9ff61a0bac 100644 --- a/drivers/serial/serial_omap.c +++ b/drivers/serial/serial_omap.c @@ -66,7 +66,7 @@ static inline int serial_in_shift(void *addr, int shift) static inline void _debug_uart_init(void) { - struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_VAL(DEBUG_UART_BASE); int baud_divisor; baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, @@ -85,7 +85,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_VAL(DEBUG_UART_BASE); while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) ; diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c index ccdda9f0334..3c5d37ce0ab 100644 --- a/drivers/serial/serial_pic32.c +++ b/drivers/serial/serial_pic32.c @@ -187,14 +187,14 @@ U_BOOT_DRIVER(pic32_serial) = { static inline void _debug_uart_init(void) { - void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; + void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE); pic32_serial_init(base, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); } static inline void _debug_uart_putc(int ch) { - writel(ch, CONFIG_DEBUG_UART_BASE + U_TXR); + writel(ch, CONFIG_VAL(DEBUG_UART_BASE) + U_TXR); } DEBUG_UART_FUNCS diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 67caa063c9a..9b0d16f1645 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -403,7 +403,7 @@ U_BOOT_DRIVER(serial_pl01x) = { static void _debug_uart_init(void) { #ifndef CONFIG_DEBUG_UART_SKIP_INIT - struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE; + struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_VAL(DEBUG_UART_BASE); enum pl01x_type type; if (IS_ENABLED(CONFIG_DEBUG_UART_PL011)) @@ -419,7 +419,7 @@ static void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE; + struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_VAL(DEBUG_UART_BASE); while (pl01x_putc(regs, ch) == -EAGAIN) ; diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index de420d2d945..4b3947e7f6b 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -276,7 +276,7 @@ static inline void _debug_uart_init(void) if (IS_ENABLED(CONFIG_DEBUG_UART_SKIP_INIT)) return; - struct s5p_uart *uart = (struct s5p_uart *)CONFIG_DEBUG_UART_BASE; + struct s5p_uart *uart = (struct s5p_uart *)CONFIG_VAL(DEBUG_UART_BASE); s5p_serial_init(uart); #if CONFIG_IS_ENABLED(ARCH_APPLE) @@ -288,7 +288,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct s5p_uart *uart = (struct s5p_uart *)CONFIG_DEBUG_UART_BASE; + struct s5p_uart *uart = (struct s5p_uart *)CONFIG_VAL(DEBUG_UART_BASE); #if CONFIG_IS_ENABLED(ARCH_APPLE) while (readl(&uart->ufstat) & S5L_TX_FIFO_FULL); diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c index 794f9c924bc..4af1ff5060a 100644 --- a/drivers/serial/serial_sifive.c +++ b/drivers/serial/serial_sifive.c @@ -212,7 +212,7 @@ U_BOOT_DRIVER(serial_sifive) = { static inline void _debug_uart_init(void) { struct uart_sifive *regs = - (struct uart_sifive *)CONFIG_DEBUG_UART_BASE; + (struct uart_sifive *)CONFIG_VAL(DEBUG_UART_BASE); _sifive_serial_setbrg(regs, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); @@ -222,7 +222,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { struct uart_sifive *regs = - (struct uart_sifive *)CONFIG_DEBUG_UART_BASE; + (struct uart_sifive *)CONFIG_VAL(DEBUG_UART_BASE); while (_sifive_serial_putc(regs, ch) == -EAGAIN) WATCHDOG_RESET(); diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c index f6cb708c370..2ba92bf9c48 100644 --- a/drivers/serial/serial_stm32.c +++ b/drivers/serial/serial_stm32.c @@ -270,7 +270,7 @@ static inline struct stm32_uart_info *_debug_uart_info(void) static inline void _debug_uart_init(void) { - fdt_addr_t base = CONFIG_DEBUG_UART_BASE; + fdt_addr_t base = CONFIG_VAL(DEBUG_UART_BASE); struct stm32_uart_info *uart_info = _debug_uart_info(); _stm32_serial_init(base, uart_info); @@ -281,7 +281,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int c) { - fdt_addr_t base = CONFIG_DEBUG_UART_BASE; + fdt_addr_t base = CONFIG_VAL(DEBUG_UART_BASE); struct stm32_uart_info *uart_info = _debug_uart_info(); while (_stm32_serial_putc(base, uart_info, c) == -EAGAIN) diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c index 9780a44d09e..b6197da97cc 100644 --- a/drivers/serial/serial_xuartlite.c +++ b/drivers/serial/serial_xuartlite.c @@ -143,7 +143,7 @@ U_BOOT_DRIVER(serial_uartlite) = { static inline void _debug_uart_init(void) { - struct uartlite *regs = (struct uartlite *)CONFIG_DEBUG_UART_BASE; + struct uartlite *regs = (struct uartlite *)CONFIG_VAL(DEBUG_UART_BASE); int ret; uart_out32(®s->control, 0); @@ -159,7 +159,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct uartlite *regs = (struct uartlite *)CONFIG_DEBUG_UART_BASE; + struct uartlite *regs = (struct uartlite *)CONFIG_VAL(DEBUG_UART_BASE); while (uart_in32(®s->status) & SR_TX_FIFO_FULL) ; diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c index 6bb003dc155..83adfb5fb98 100644 --- a/drivers/serial/serial_zynq.c +++ b/drivers/serial/serial_zynq.c @@ -295,7 +295,7 @@ U_BOOT_DRIVER(serial_zynq) = { #ifdef CONFIG_DEBUG_UART_ZYNQ static inline void _debug_uart_init(void) { - struct uart_zynq *regs = (struct uart_zynq *)CONFIG_DEBUG_UART_BASE; + struct uart_zynq *regs = (struct uart_zynq *)CONFIG_VAL(DEBUG_UART_BASE); _uart_zynq_serial_init(regs); _uart_zynq_serial_setbrg(regs, CONFIG_DEBUG_UART_CLOCK, @@ -304,7 +304,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct uart_zynq *regs = (struct uart_zynq *)CONFIG_DEBUG_UART_BASE; + struct uart_zynq *regs = (struct uart_zynq *)CONFIG_VAL(DEBUG_UART_BASE); while (_uart_zynq_serial_putc(regs, ch) == -EAGAIN) WATCHDOG_RESET();