From 9814430128cecf316b3e53f766d351bb1680d041 Mon Sep 17 00:00:00 2001 From: Christian GMEINER Date: Tue, 4 Dec 2018 20:35:24 +0100 Subject: [PATCH 01/20] sandbox: add memset_io(..), memcpy_fromio(..) and memcpy_toio(..) These functions could be used by drivers. Signed-off-by: Christian GMEINER Reviewed-by: Simon Glass --- arch/sandbox/include/asm/io.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 81b7750628..2a350a826c 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -173,6 +173,18 @@ static inline void _outsw(volatile u16 *port, const void *buf, int ns) { } +static inline void memset_io(volatile void *addr, unsigned char val, int count) +{ +} + +static inline void memcpy_fromio(void *dst, const volatile void *src, int count) +{ +} + +static inline void memcpy_toio(volatile void *dst, const void *src, int count) +{ +} + #define insw(port, buf, ns) _insw((u16 *)port, buf, ns) #define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns) From 90a29fcc1f36fb5c05a1eaedb16793c320e00d39 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Dec 2018 05:35:26 -0700 Subject: [PATCH 02/20] buildman: Drop comment about Ctrl-C problem This bug is now fixed, so drop this comment. Signed-off-by: Simon Glass --- tools/buildman/README | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/buildman/README b/tools/buildman/README index 5a709c6ff9..d688b7cf00 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1169,8 +1169,6 @@ access to log files. Also it would be nice if buildman could 'hunt' for problems, perhaps by building a few boards for each arch, or checking commits for changed files and building only boards which use those files. -A specific problem to fix is that Ctrl-C does not exit buildman cleanly when -multiple builder threads are active. Credits ======= From 54d2cfe6ee11dc5bcce55d41b91d92f9a53e6485 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Dec 2018 18:42:52 -0700 Subject: [PATCH 03/20] dm: Tidy up 'dm tree' output when there are many devices At present the 'Index' column assumes there is only one digit. But on some devices (e.g. snow) there are a lot of regulators and GPIO banks. Adjust the output to allow for two digits without messing up the display. Also capatalise the heading to match. Fixes: 5197dafc42 (dm: core: Widen the dump tree to show more of the driver's name.) Signed-off-by: Simon Glass Reviewed-by: Liviu Dudau --- drivers/core/dump.c | 4 ++-- test/py/tests/test_bind.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/core/dump.c b/drivers/core/dump.c index 04217cbde8..8fbfd93fb5 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -16,7 +16,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag) struct udevice *child; /* print the first 20 characters to not break the tree-format. */ - printf(" %-10.10s %d [ %c ] %-20.20s ", dev->uclass->uc_drv->name, + printf(" %-10.10s %2d [ %c ] %-20.20s ", dev->uclass->uc_drv->name, dev_get_uclass_index(dev, NULL), dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name); @@ -49,7 +49,7 @@ void dm_dump_all(void) root = dm_root(); if (root) { - printf(" Class index Probed Driver Name\n"); + printf(" Class Index Probed Driver Name\n"); printf("-----------------------------------------------------------\n"); show_devices(root, -1, 0); } diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index dee3fee566..917839f628 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -13,7 +13,8 @@ def in_tree(response, name, uclass, drv, depth, last_child): else: leaf = leaf + '`' leaf = leaf + '-- ' + name - line = ' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$'.format(uclass, drv, leaf) + line = (' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$' + .format(uclass, drv, leaf)) prog = re.compile(line) for l in lines: if prog.match(l): From d8e9cf4d473fc223c272301351becb29bd18ed2a Mon Sep 17 00:00:00 2001 From: Sekhar Nori Date: Thu, 6 Dec 2018 15:20:47 +0530 Subject: [PATCH 04/20] common: fdt_support: print hexadecimal numbers in debug We usually deal with hexadecimal addresses and sizes in device-tree. Its much easier if debug logs print hexadecimal values too. Reviewed-by: Simon Glass Signed-off-by: Sekhar Nori Reviewed-by: Lokesh Vutla Reviewed-by: Tom Rini --- common/fdt_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 3440e42a25..42583e3ed8 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1025,7 +1025,7 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range, s = fdt_read_number(range + na + pna, ns); da = fdt_read_number(addr, na); - debug("OF: default map, cp=%llu, s=%llu, da=%llu\n", cp, s, da); + debug("OF: default map, cp=%llx, s=%llx, da=%llx\n", cp, s, da); if (da < cp || da >= (cp + s)) return OF_BAD_ADDR; @@ -1080,7 +1080,7 @@ static u64 of_bus_isa_map(fdt32_t *addr, const fdt32_t *range, s = fdt_read_number(range + na + pna, ns); da = fdt_read_number(addr + 1, na - 1); - debug("OF: ISA map, cp=%llu, s=%llu, da=%llu\n", cp, s, da); + debug("OF: ISA map, cp=%llx, s=%llx, da=%llx\n", cp, s, da); if (da < cp || da >= (cp + s)) return OF_BAD_ADDR; From df9cf1cc08d73af765f0f434909295ac6fed2c4b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Dec 2018 17:11:10 -0700 Subject: [PATCH 05/20] test: dm: regmap: Fix the long test delay At present one of the regmap tests takes 5 seconds to run since it waits for a timeout. This should be handled using sandbox_timer_add_offset() which advances time for test purposes. This requires a little change to make the regmap_read_poll_timeout() testable. Update the macro and the test. Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test") Signed-off-by: Simon Glass --- include/regmap.h | 14 +++++++++++++- test/dm/regmap.c | 7 ++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/regmap.h b/include/regmap.h index a3afb72df5..8359c511d2 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, * @cond: Break condition (usually involving @val) * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). * @timeout_ms: Timeout in ms, 0 means never timeout + * @test_add_time: Used for sandbox testing - amount of time to add after + * starting the loop (0 if not testing) * * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read * error return value in case of a error read. In the two former cases, @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, * * This is modelled after the regmap_read_poll_timeout macros in linux but * with millisecond timeout. + * + * The _test version is for sandbox testing only. Do not use this in normal + * code as it advances the timer. */ -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \ +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \ + timeout_ms, test_add_time) \ ({ \ unsigned long __start = get_timer(0); \ int __ret; \ @@ -267,6 +273,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, break; \ if (cond) \ break; \ + if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \ + sandbox_timer_add_offset(test_add_time); \ if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \ __ret = regmap_read((map), (addr), &(val)); \ break; \ @@ -277,6 +285,10 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ }) +#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \ + regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \ + timeout_ms, 0) \ + /** * regmap_update_bits() - Perform a read/modify/write using a mask * diff --git a/test/dm/regmap.c b/test/dm/regmap.c index 9a70c159dd..82de295cb8 100644 --- a/test/dm/regmap.c +++ b/test/dm/regmap.c @@ -160,9 +160,10 @@ static int dm_test_regmap_poll(struct unit_test_state *uts) start = get_timer(0); ut_asserteq(-ETIMEDOUT, - regmap_read_poll_timeout(map, 0, reg, - (reg == 0xcacafafa), - 1, 5 * CONFIG_SYS_HZ)); + regmap_read_poll_timeout_test(map, 0, reg, + (reg == 0xcacafafa), + 1, 5 * CONFIG_SYS_HZ, + 5 * CONFIG_SYS_HZ)); ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ)); From e74429bb17533c454b804e523ff5724344711ad2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 10 Dec 2018 09:05:23 -0700 Subject: [PATCH 06/20] buildman: Deal nicely with invalid build-status file The 'done' files created by buildman may end up being empty if buildman runs out of disk space while writing them. This error is then persistent, since even if disk space is reclaimed and the build retries, the empty file causes an exception in the builder thread. Deal with this silently by doing a rebuild. Signed-off-by: Simon Glass --- tools/buildman/builderthread.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index c84ba6acf1..b91634f3ab 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -156,7 +156,12 @@ class BuilderThread(threading.Thread): if result.already_done: # Get the return code from that build and use it with open(done_file, 'r') as fd: - result.return_code = int(fd.readline()) + try: + result.return_code = int(fd.readline()) + except ValueError: + # The file may be empty due to running out of disk space. + # Try a rebuild + result.return_code = RETURN_CODE_RETRY # Check the signal that the build needs to be retried if result.return_code == RETURN_CODE_RETRY: From 398ae02669d1300ab2cdcbbdfe1c5c264d47b718 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 17 Dec 2018 09:12:16 -0700 Subject: [PATCH 07/20] sandbox: Correct SDL build flags The check for CONFIG_SANDBOX_SDL in config.mk does not work since the build config is not available by the time that file is included. Remove it so that we always call sdl-config except when NO_SDL is used. Signed-off-by: Simon Glass --- arch/sandbox/config.mk | 2 -- arch/sandbox/cpu/sdl.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 7226b7be42..31a12db103 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -11,11 +11,9 @@ PLATFORM_LIBS += -lrt ifneq ($(NO_SDL),) PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL else -ifdef CONFIG_SANDBOX_SDL PLATFORM_LIBS += $(shell sdl-config --libs) PLATFORM_CPPFLAGS += $(shell sdl-config --cflags) endif -endif cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ -Wl,--start-group $(u-boot-main) -Wl,--end-group \ diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index f668f5379a..080c7c8d74 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include /** From 0c89a318dc9abbdb74a9b57c5e7e4441d892b51a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:18 -0700 Subject: [PATCH 08/20] efi_loader: Add a wchar_t cast in efi_file_open() The printf() string here is not actually correct. Add a cast to avoid a warning when checking is enabled. Signed-off-by: Simon Glass --- lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 128cb0a627..8a4f3a9f40 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -221,8 +221,8 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, struct file_handle *fh = to_fh(file); efi_status_t ret; - EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name, - open_mode, attributes); + EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, + (wchar_t *)file_name, open_mode, attributes); /* Check parameters */ if (!file || !new_handle || !file_name) { From ed4e933d13c7242c643e4a535edf4d75c5322f94 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:19 -0700 Subject: [PATCH 09/20] log: Check printf() arguments At present logging does not check printf() arguments. Now that all users have been corrected, enable this to prevent further problems. Signed-off-by: Simon Glass --- include/log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/log.h b/include/log.h index 0f2bc19477..d7f6471006 100644 --- a/include/log.h +++ b/include/log.h @@ -73,7 +73,8 @@ static inline int log_uc_cat(enum uclass_id id) * @return 0 if log record was emitted, -ve on error */ int _log(enum log_category_t cat, enum log_level_t level, const char *file, - int line, const char *func, const char *fmt, ...); + int line, const char *func, const char *fmt, ...) + __attribute__ ((format (__printf__, 6, 7))); /* Define this at the top of a file to add a prefix to debug messages */ #ifndef pr_fmt From 00beb2485f71ab23114b37ef47d136e269ef69f7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:20 -0700 Subject: [PATCH 10/20] buildman: Add support for building with clang Add a -O option which allows building with clang. Signed-off-by: Simon Glass --- tools/buildman/README | 10 +++++++++ tools/buildman/builderthread.py | 1 + tools/buildman/cmdline.py | 2 ++ tools/buildman/control.py | 2 +- tools/buildman/toolchain.py | 38 +++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/tools/buildman/README b/tools/buildman/README index d688b7cf00..56a99c70a2 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1046,6 +1046,16 @@ value for 'altbootcmd', but lost one for ' altbootcmd'. The -U option uses the u-boot.env files which are produced by a build. + +Building with clang +=================== + +To build with clang (sandbox only), use the -O option to override the +toolchain. For example: + + buildman -O clang-7 --board sandbox + + Other options ============= diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index b91634f3ab..6b156f152d 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -229,6 +229,7 @@ class BuilderThread(threading.Thread): config_args = ['%s_defconfig' % brd.target] config_out = '' args.extend(self.builder.toolchains.GetMakeArguments(brd)) + args.extend(self.toolchain.MakeArgs()) # If we need to reconfigure, do that now if do_config: diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 93d09ca08d..832a5145d2 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -74,6 +74,8 @@ def ParseArgs(): parser.add_option('-o', '--output-dir', type='string', dest='output_dir', default='..', help='Directory where all builds happen and buildman has its workspace (default is ../)') + parser.add_option('-O', '--override-toolchain', type='string', + help="Override host toochain to use for sandbox (e.g. 'clang-7')") parser.add_option('-Q', '--quick', action='store_true', default=False, help='Do a rough build, with limited warning resolution') parser.add_option('-p', '--full-path', action='store_true', diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c900211510..27916d3c35 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -141,7 +141,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, no_toolchains = toolchains is None if no_toolchains: - toolchains = toolchain.Toolchains() + toolchains = toolchain.Toolchains(options.override_toolchain) if options.fetch_arch: if options.fetch_arch == 'list': diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index c62ce136fa..b3c61827f3 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -54,9 +54,11 @@ class Toolchain: arch: Architecture of toolchain as determined from the first component of the filename. E.g. arm-linux-gcc becomes arm priority: Toolchain priority (0=highest, 20=lowest) + override_toolchain: Toolchain to use for sandbox, overriding the normal + one """ def __init__(self, fname, test, verbose=False, priority=PRIORITY_CALC, - arch=None): + arch=None, override_toolchain=None): """Create a new toolchain object. Args: @@ -68,6 +70,7 @@ class Toolchain: """ self.gcc = fname self.path = os.path.dirname(fname) + self.override_toolchain = override_toolchain # Find the CROSS_COMPILE prefix to use for U-Boot. For example, # 'arm-linux-gnueabihf-gcc' turns into 'arm-linux-gnueabihf-'. @@ -81,6 +84,8 @@ class Toolchain: self.arch = arch else: self.arch = self.cross[:pos] if pos != -1 else 'sandbox' + if self.arch == 'sandbox' and override_toolchain: + self.gcc = override_toolchain env = self.MakeEnvironment(False) @@ -150,11 +155,18 @@ class Toolchain: Args: full_path: Return the full path in CROSS_COMPILE and don't set PATH + Returns: + Dict containing the environemnt to use. This is based on the current + environment, with changes as needed to CROSS_COMPILE, PATH and + LC_ALL. """ env = dict(os.environ) wrapper = self.GetWrapper() - if full_path: + if self.override_toolchain: + # We'll use MakeArgs() to provide this + pass + elif full_path: env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross) else: env['CROSS_COMPILE'] = wrapper + self.cross @@ -164,6 +176,22 @@ class Toolchain: return env + def MakeArgs(self): + """Create the 'make' arguments for a toolchain + + This is only used when the toolchain is being overridden. Since the + U-Boot Makefile sets CC and HOSTCC explicitly we cannot rely on the + environment (and MakeEnvironment()) to override these values. This + function returns the arguments to accomplish this. + + Returns: + List of arguments to pass to 'make' + """ + if self.override_toolchain: + return ['HOSTCC=%s' % self.override_toolchain, + 'CC=%s' % self.override_toolchain] + return [] + class Toolchains: """Manage a list of toolchains for building U-Boot @@ -180,10 +208,11 @@ class Toolchains: paths: List of paths to check for toolchains (may contain wildcards) """ - def __init__(self): + def __init__(self, override_toolchain=None): self.toolchains = {} self.prefixes = {} self.paths = [] + self.override_toolchain = override_toolchain self._make_flags = dict(bsettings.GetItems('make-flags')) def GetPathList(self, show_warning=True): @@ -234,7 +263,8 @@ class Toolchains: priority: Priority to use for this toolchain arch: Toolchain architecture, or None if not known """ - toolchain = Toolchain(fname, test, verbose, priority, arch) + toolchain = Toolchain(fname, test, verbose, priority, arch, + self.override_toolchain) add_it = toolchain.ok if toolchain.arch in self.toolchains: add_it = (toolchain.priority < From e9500f49ea350b14973bdacd9948f9c2177ff2a8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:21 -0700 Subject: [PATCH 11/20] travis: Use buildman for building with clang Now that buildman supports clang, use it. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- .travis.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 321fd793a7..fc4d5a1d5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,16 +109,9 @@ script: # # From buildman, exit code 129 means warnings only. If we've been asked to # use clang only do one configuration. - - if [[ "${TOOLCHAIN}" == "clang" ]]; then + - if [[ "${BUILDMAN}" != "" ]]; then ret=0; - make O=../.bm-work/${TEST_PY_BD} HOSTCC=clang-7 CC=clang-7 -j$(nproc) - KCFLAGS=-Werror sandbox_config all || ret=$?; - if [[ $ret -ne 0 ]]; then - exit $ret; - fi; - elif [[ "${BUILDMAN}" != "" ]]; then - ret=0; - tools/buildman/buildman -P -E ${BUILDMAN} || ret=$?; + tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then tools/buildman/buildman -sdeP ${BUILDMAN}; exit $ret; @@ -351,7 +344,7 @@ matrix: env: - TEST_PY_BD="sandbox" BUILDMAN="^sandbox$" - TOOLCHAIN="clang" + OVERRIDE="clang-7" - name: "test/py sandbox_spl" env: - TEST_PY_BD="sandbox_spl" From 8405452e6abab07cf445ba307b3ca58d39a097ba Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:22 -0700 Subject: [PATCH 12/20] net: Fix error handling in sb_eth_raw_ofdata_to_platdata() At present this stores the error number in an unsigned int so an error is never detected. Use the existing signed variable instead. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- drivers/net/sandbox-raw.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index 09cc678ebd..7e6625d020 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -152,7 +152,6 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); const char *ifname; - u32 local; int ret; pdata->iobase = dev_read_addr(dev); @@ -173,10 +172,10 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) priv->host_ifindex, priv->host_ifname); } - local = sandbox_eth_raw_os_is_local(priv->host_ifname); - if (local < 0) - return local; - priv->local = local; + ret = sandbox_eth_raw_os_is_local(priv->host_ifname); + if (ret < 0) + return ret; + priv->local = ret; return 0; } From ccd2979a8d59636ca0cf288db03e1298dc120123 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 7 Jan 2019 16:44:24 -0700 Subject: [PATCH 13/20] buildman: Fix tabs in GetWrapper() This function has tabs instead of spaces. Fix it. Signed-off-by: Simon Glass --- tools/buildman/toolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index b3c61827f3..a65737fdf8 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -135,8 +135,8 @@ class Toolchain: def GetWrapper(self, show_warning=True): """Get toolchain wrapper from the setting file. """ - value = '' - for name, value in bsettings.GetItems('toolchain-wrapper'): + value = '' + for name, value in bsettings.GetItems('toolchain-wrapper'): if not value: print "Warning: Wrapper not found" if value: From 0171f432047e86305593bb1eb1cc86f853e55029 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 28 Dec 2018 14:23:07 -0700 Subject: [PATCH 14/20] serial: Move new functions to serial.h We should not be adding new functions to common.h. Move these recently added functions to serial.h. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/common.h | 5 ----- include/serial.h | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/common.h b/include/common.h index 657cc404cf..028a735a5c 100644 --- a/include/common.h +++ b/include/common.h @@ -350,8 +350,6 @@ void smp_set_core_boot_addr(unsigned long addr, int corenr); void smp_kick_all_cpus(void); /* $(CPU)/serial.c */ -struct serial_device_info; - int serial_init (void); void serial_setbrg (void); void serial_putc (const char); @@ -359,9 +357,6 @@ void serial_putc_raw(const char); void serial_puts (const char *); int serial_getc (void); int serial_tstc (void); -int serial_getconfig(uint *config); -int serial_setconfig(uint config); -int serial_getinfo(struct serial_device_info *info); /* $(CPU)/speed.c */ int get_clocks (void); diff --git a/include/serial.h b/include/serial.h index c1a9fee250..fa7e0130bd 100644 --- a/include/serial.h +++ b/include/serial.h @@ -281,6 +281,10 @@ struct serial_dev_priv { /* Access the serial operations for a device */ #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops) +int serial_getconfig(uint *config); +int serial_setconfig(uint config); +int serial_getinfo(struct serial_device_info *info); + void atmel_serial_initialize(void); void mcf_serial_initialize(void); void mpc85xx_serial_initialize(void); From 67d1b0513079049baa3e0e38603eb33a3857af5d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 28 Dec 2018 14:23:08 -0700 Subject: [PATCH 15/20] dm: serial: Adjust serial_getconfig() to use proper API All driver-model functions should have a device as the first parameter. Update this function accordingly. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- arch/x86/lib/acpi_table.c | 5 ++++- drivers/serial/serial-uclass.c | 9 +++------ include/serial.h | 2 +- test/dm/serial.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 79bc2000bd..bfcf2adbf1 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -342,6 +342,7 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) struct acpi_table_header *header = &(spcr->header); struct serial_device_info serial_info = {0}; ulong serial_address, serial_offset; + struct udevice *dev; uint serial_config; uint serial_width; int access_size; @@ -431,7 +432,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) break; } - ret = serial_getconfig(&serial_config); + ret = uclass_first_device_err(UCLASS_SERIAL, &dev); + if (!ret) + ret = serial_getconfig(dev, &serial_config); if (ret) serial_config = SERIAL_DEFAULT_CONFIG; diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index ffcd6d15af..81f1067f42 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -294,16 +294,13 @@ void serial_setbrg(void) ops->setbrg(gd->cur_serial_dev, gd->baudrate); } -int serial_getconfig(uint *config) +int serial_getconfig(struct udevice *dev, uint *config) { struct dm_serial_ops *ops; - if (!gd->cur_serial_dev) - return 0; - - ops = serial_get_ops(gd->cur_serial_dev); + ops = serial_get_ops(dev); if (ops->getconfig) - return ops->getconfig(gd->cur_serial_dev, config); + return ops->getconfig(dev, config); return 0; } diff --git a/include/serial.h b/include/serial.h index fa7e0130bd..5ba031ab53 100644 --- a/include/serial.h +++ b/include/serial.h @@ -281,7 +281,7 @@ struct serial_dev_priv { /* Access the serial operations for a device */ #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops) -int serial_getconfig(uint *config); +int serial_getconfig(struct udevice *dev, uint *config); int serial_setconfig(uint config); int serial_getinfo(struct serial_device_info *info); diff --git a/test/dm/serial.c b/test/dm/serial.c index 19a15d5d95..972755face 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -24,7 +24,7 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver */ ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); - ut_assertok(serial_getconfig(&value_serial)); + ut_assertok(serial_getconfig(dev_serial, &value_serial)); ut_assert(value_serial == SERIAL_DEFAULT_CONFIG); ut_assertok(serial_getinfo(&info_serial)); ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN); @@ -32,7 +32,7 @@ static int dm_test_serial(struct unit_test_state *uts) /* * test with a parameter which is NULL pointer */ - ut_asserteq(-EINVAL, serial_getconfig(NULL)); + ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL)); ut_asserteq(-EINVAL, serial_getinfo(NULL)); /* * test with a serial config which is not supported by From 3de04e771c4b230ad08c7b22871dedf5f69032b9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 28 Dec 2018 14:23:09 -0700 Subject: [PATCH 16/20] dm: serial: Adjust serial_setconfig() to use proper API All driver-model functions should have a device as the first parameter. Update this function accordingly. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- drivers/serial/serial-uclass.c | 9 +++------ include/serial.h | 2 +- test/dm/serial.c | 11 +++++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 81f1067f42..669c82f379 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -305,16 +305,13 @@ int serial_getconfig(struct udevice *dev, uint *config) return 0; } -int serial_setconfig(uint config) +int serial_setconfig(struct udevice *dev, uint config) { struct dm_serial_ops *ops; - if (!gd->cur_serial_dev) - return 0; - - ops = serial_get_ops(gd->cur_serial_dev); + ops = serial_get_ops(dev); if (ops->setconfig) - return ops->setconfig(gd->cur_serial_dev, config); + return ops->setconfig(dev, config); return 0; } diff --git a/include/serial.h b/include/serial.h index 5ba031ab53..8a05a09089 100644 --- a/include/serial.h +++ b/include/serial.h @@ -282,7 +282,7 @@ struct serial_dev_priv { #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops) int serial_getconfig(struct udevice *dev, uint *config); -int serial_setconfig(uint config); +int serial_setconfig(struct udevice *dev, uint config); int serial_getinfo(struct serial_device_info *info); void atmel_serial_initialize(void); diff --git a/test/dm/serial.c b/test/dm/serial.c index 972755face..f82b4a19e8 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -23,7 +23,7 @@ static int dm_test_serial(struct unit_test_state *uts) * test with default config which is the only one supported by * sandbox_serial driver */ - ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); + ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG)); ut_assertok(serial_getconfig(dev_serial, &value_serial)); ut_assert(value_serial == SERIAL_DEFAULT_CONFIG); ut_assertok(serial_getinfo(&info_serial)); @@ -39,7 +39,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong parity */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_ODD, SERIAL_8_BITS, SERIAL_ONE_STOP))); /* @@ -47,7 +48,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_6_BITS, SERIAL_ONE_STOP))); @@ -56,7 +58,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong stop bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_8_BITS, SERIAL_TWO_STOP))); From a61cbad78e67963944e7d719f0aee27b8aef6c02 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 28 Dec 2018 14:23:10 -0700 Subject: [PATCH 17/20] dm: serial: Adjust serial_getinfo() to use proper API All driver-model functions should have a device as the first parameter. Update this function accordingly. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- arch/x86/lib/acpi_table.c | 11 ++++++----- drivers/serial/serial-uclass.c | 9 +++------ include/serial.h | 2 +- test/dm/serial.c | 4 ++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index bfcf2adbf1..04058a60d7 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -354,7 +354,10 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) header->length = sizeof(struct acpi_spcr); header->revision = 2; - ret = serial_getinfo(&serial_info); + /* Read the device once, here. It is reused below */ + ret = uclass_first_device_err(UCLASS_SERIAL, &dev); + if (!ret) + ret = serial_getinfo(dev, &serial_info); if (ret) serial_info.type = SERIAL_CHIP_UNKNOWN; @@ -432,11 +435,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) break; } - ret = uclass_first_device_err(UCLASS_SERIAL, &dev); - if (!ret) + serial_config = SERIAL_DEFAULT_CONFIG; + if (dev) ret = serial_getconfig(dev, &serial_config); - if (ret) - serial_config = SERIAL_DEFAULT_CONFIG; spcr->parity = SERIAL_GET_PARITY(serial_config); spcr->stop_bits = SERIAL_GET_STOP(serial_config); diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 669c82f379..d4488a2cc2 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -316,21 +316,18 @@ int serial_setconfig(struct udevice *dev, uint config) return 0; } -int serial_getinfo(struct serial_device_info *info) +int serial_getinfo(struct udevice *dev, struct serial_device_info *info) { struct dm_serial_ops *ops; - if (!gd->cur_serial_dev) - return -ENODEV; - if (!info) return -EINVAL; info->baudrate = gd->baudrate; - ops = serial_get_ops(gd->cur_serial_dev); + ops = serial_get_ops(dev); if (ops->getinfo) - return ops->getinfo(gd->cur_serial_dev, info); + return ops->getinfo(dev, info); return -EINVAL; } diff --git a/include/serial.h b/include/serial.h index 8a05a09089..8a790ccaaf 100644 --- a/include/serial.h +++ b/include/serial.h @@ -283,7 +283,7 @@ struct serial_dev_priv { int serial_getconfig(struct udevice *dev, uint *config); int serial_setconfig(struct udevice *dev, uint config); -int serial_getinfo(struct serial_device_info *info); +int serial_getinfo(struct udevice *dev, struct serial_device_info *info); void atmel_serial_initialize(void); void mcf_serial_initialize(void); diff --git a/test/dm/serial.c b/test/dm/serial.c index f82b4a19e8..3d741a8c36 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -26,14 +26,14 @@ static int dm_test_serial(struct unit_test_state *uts) ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG)); ut_assertok(serial_getconfig(dev_serial, &value_serial)); ut_assert(value_serial == SERIAL_DEFAULT_CONFIG); - ut_assertok(serial_getinfo(&info_serial)); + ut_assertok(serial_getinfo(dev_serial, &info_serial)); ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN); ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS); /* * test with a parameter which is NULL pointer */ ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL)); - ut_asserteq(-EINVAL, serial_getinfo(NULL)); + ut_asserteq(-EINVAL, serial_getinfo(dev_serial, NULL)); /* * test with a serial config which is not supported by * sandbox_serial driver: test with wrong parity From eab647d5e745c7b5b5a6962b0511bd18bb22365d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 28 Dec 2018 14:23:11 -0700 Subject: [PATCH 18/20] dm: serial: Tidy up header file comments The getconfig() comment is out of date. Fix this and add comments for recently added functions. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/serial.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/include/serial.h b/include/serial.h index 8a790ccaaf..c1368c68b6 100644 --- a/include/serial.h +++ b/include/serial.h @@ -235,9 +235,7 @@ struct dm_serial_ops { * Get a current config for this device. * * @dev: Device pointer - * @parity: parity to use - * @bits: bits number to use - * @stop: stop bits number to use + * @serial_config: Returns config information (see SERIAL_... above) * @return 0 if OK, -ve on error */ int (*getconfig)(struct udevice *dev, uint *serial_config); @@ -257,6 +255,7 @@ struct dm_serial_ops { * * @dev: Device pointer * @info: struct serial_device_info to fill + * @return 0 if OK, -ve on error */ int (*getinfo)(struct udevice *dev, struct serial_device_info *info); }; @@ -281,8 +280,37 @@ struct serial_dev_priv { /* Access the serial operations for a device */ #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops) +/** + * serial_getconfig() - Get the uart configuration + * (parity, 5/6/7/8 bits word length, stop bits) + * + * Get a current config for this device. + * + * @dev: Device pointer + * @serial_config: Returns config information (see SERIAL_... above) + * @return 0 if OK, -ve on error + */ int serial_getconfig(struct udevice *dev, uint *config); + +/** + * serial_setconfig() - Set up the uart configuration + * (parity, 5/6/7/8 bits word length, stop bits) + * + * Set up a new config for this device. + * + * @dev: Device pointer + * @serial_config: number of bits, parity and number of stopbits to use + * @return 0 if OK, -ve on error + */ int serial_setconfig(struct udevice *dev, uint config); + +/** + * serial_getinfo() - Get serial device information + * + * @dev: Device pointer + * @info: struct serial_device_info to fill + * @return 0 if OK, -ve on error + */ int serial_getinfo(struct udevice *dev, struct serial_device_info *info); void atmel_serial_initialize(void); From d0a30a8ae2228baa8714a6a0028b944defccb352 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 5 Jan 2019 22:30:07 +0100 Subject: [PATCH 19/20] sandbox: i2c_emul_find() No emulators for device 'rtc@43' when running the date command on sandbox_defconfig an error occurs: ./u-boot -D u-boot.dtb => date i2c_emul_find() No emulators for device 'rtc@43' ## Get date failed Correct the references to the emulator devices in the sandbox device trees using test.dts as a reference. Fixes: 031a650e1309 ("dm: sandbox: i2c: Use new emulator parent uclass") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Dropped unnecessary #address/size-cells property in i2c_emul: Signed-off-by: Simon Glass --- arch/sandbox/dts/sandbox.dts | 10 ++++------ arch/sandbox/dts/sandbox64.dts | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index ae3189ec8c..a41b5f052d 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -100,11 +100,13 @@ eeprom@2c { reg = <0x2c>; compatible = "i2c-eeprom"; + sandbox,emul = <&emul_eeprom>; }; rtc_0: rtc@43 { reg = <0x43>; compatible = "sandbox-rtc"; + sandbox,emul = <&emul0>; }; sandbox_pmic: sandbox_pmic { reg = <0x40>; @@ -115,18 +117,14 @@ }; i2c_emul: emul { - #address-cells = <1>; - #size-cells = <0>; reg = <0xff>; compatible = "sandbox,i2c-emul-parent"; - emul-eeprom { - reg = <0x2c>; + emul_eeprom: emul-eeprom { compatible = "sandbox,i2c-eeprom"; sandbox,filename = "i2c.bin"; sandbox,size = <256>; }; - emul0 { - reg = <0x43>; + emul0: emul0 { compatible = "sandbox,i2c-rtc"; }; }; diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts index d30fd62a2a..a3c95f2cdb 100644 --- a/arch/sandbox/dts/sandbox64.dts +++ b/arch/sandbox/dts/sandbox64.dts @@ -90,11 +90,13 @@ eeprom@2c { reg = <0x2c>; compatible = "i2c-eeprom"; + sandbox,emul = <&emul_eeprom>; }; rtc_0: rtc@43 { reg = <0x43>; compatible = "sandbox-rtc"; + sandbox,emul = <&emul0>; }; sandbox_pmic: sandbox_pmic { reg = <0x40>; @@ -107,12 +109,12 @@ i2c_emul: emul { reg = <0xff>; compatible = "sandbox,i2c-emul-parent"; - emul-eeprom { + emul_eeprom: emul-eeprom { compatible = "sandbox,i2c-eeprom"; sandbox,filename = "i2c.bin"; sandbox,size = <256>; }; - emul0 { + emul0: emul0 { compatible = "sandbox,i2c-rtc"; }; }; From f51f6715a5013f37620c38f0430e21d4736e235a Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 21 Dec 2018 21:54:30 +0530 Subject: [PATCH 20/20] lib: fdtdec: fdtdec_get_addr_size_fixed remove checks With 8 bytes addressing even on 32 bit machines these checks are no longer valid. Remove them. Signed-off-by: Keerthy Reviewed-by: Simon Glass --- lib/fdtdec.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 6f8ec0dbed..18663ce6bd 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -95,16 +95,6 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, debug("%s: %s: ", __func__, prop_name); - if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) { - debug("(na too large for fdt_addr_t type)\n"); - return FDT_ADDR_T_NONE; - } - - if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) { - debug("(ns too large for fdt_size_t type)\n"); - return FDT_ADDR_T_NONE; - } - prop = fdt_getprop(blob, node, prop_name, &len); if (!prop) { debug("(not found)\n");