Stephen Warren [Sat, 5 Sep 2015 04:03:46 +0000 (22:03 -0600)]
dfu: don't keep freeing/reallocating
DFU currently allocates buffer memory at the start of each data transfer
operation and frees it at the end. Especially since memalign() is used to
allocate the buffer, and various other allocations happen during the
transfer, this can expose the code to heap fragmentation, which prevents
the allocation from succeeding on subsequent transfers.
Fix the code to allocate the buffer once when DFU mode is initialized,
and free the buffer once when DFU mode is exited, to reduce the exposure
to heap fragmentation.
The failure mode is:
// Internally to memalign(), this allocates a lot more than s to guarantee
// that alignment can occur, then returns chunks of memory at the start/
// end of the allocated buffer to the heap.
p = memalign(a, s);
// Various other malloc()s occur here, some of which allocate the RAM
// immediately before/after "p".
//
// DFU transfer is complete, so buffer is released.
free(p);
// By chance, no other malloc()/free() here, in DFU at least.
//
// A new DFU transfer starts, so the buffer is allocated again.
// In theory this should succeed since we just free()d a buffer of the
// same size. However, this fails because memalign() internally attempts
// to allocate much more than "s", yet free(p) above only free()d a
// little more than "s".
p = memalign(a, s);
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Stephen Warren [Sat, 5 Sep 2015 04:03:45 +0000 (22:03 -0600)]
ext4: fix leak in check_filename()
root_first_block_buffer should be free()d in all cases, not just when an
error occurs. Fix the success exit path of the function to do this.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Stephen Warren [Sat, 5 Sep 2015 04:03:44 +0000 (22:03 -0600)]
ext4: free allocations by parse_path()
parse_path() malloc()s the entries in the array it's passed. Those
allocations must be free()d by the caller, ext4fs_get_parent_inode_num().
Add code to do this.
For this to work, all the array entries must be dynamically allocated,
rather than a mix of dynamic and static allocations. Fix parse_path() not
to over-write arr[0] with a pointer to statically allocated data.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Stephen Warren [Sat, 5 Sep 2015 04:03:43 +0000 (22:03 -0600)]
ext4: avoid calling ext4fs_mount() twice, which leaks
ext4_write_file() is only called from the "fs" layer, which calls both
ext4fs_mount() and ext4fs_close() before/after calling ext4_write_file().
Fix ext4_write_file() not to call ext4fs_mount() again, since the mount
operation malloc()s some RAM which is leaked when a second mount call
over-writes the pointer to that data, if no intervening close call is
made.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Stephen Warren [Sat, 5 Sep 2015 04:03:42 +0000 (22:03 -0600)]
usb: gadget: don't leak configs when unbinding
By the time g_dnl_unbind() is run, cdev->config has been set to NULL,
so the free() there does nothing, and the config struct is leaked.
Equally, struct usb_gadget contains a linked list of config structs, so
the code should iterate over them all and free each one, rather than
freeing one particular config struct.
composite_unbind() already iterates over the list of config structs, and
unlinks each from the linked list. Fix this loop to free() each struct as
it's unlinked and otherwise forgotten.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Łukasz Majewski [Thu, 3 Sep 2015 12:21:39 +0000 (14:21 +0200)]
FIX: fat: Provide correct return code from disk_{read|write} to upper layers
It is very common that FAT code is using following pattern:
if (disk_{read|write}() < 0)
return -1;
Up till now the above code was dead, since disk_{read|write) could only
return value >= 0.
As a result some errors from medium layer (i.e. eMMC/SD) were not caught.
The above behavior was caused by block_{read|write|erase} declared at
struct block_dev_desc (@part.h). It returns unsigned long, where 0
indicates error and > 0 indicates that medium operation was correct.
This patch as error regards 0 returned from block_{read|write|erase}
when nr_blocks is grater than zero. Read/Write operation with nr_blocks=0
should return 0 and hence is not considered as an error.
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid XU3 - Exynos 5433
Kishon Vijay Abraham I [Thu, 3 Sep 2015 09:57:52 +0000 (15:27 +0530)]
include: configs: Enable DWC3 and DFU in OMAP5 uEVM
Enable dwc3, dwc3-omap and PHY to get DWC3 functional in OMAP5
uEVM. Also enable support for DFU.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Simon Glass [Wed, 2 Sep 2015 23:24:58 +0000 (17:24 -0600)]
Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h header
Now that we have a new header file for cache-aligned allocation, we should
move the stack-based allocation macro there also.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Wed, 2 Sep 2015 23:24:57 +0000 (17:24 -0600)]
Move malloc_cache_aligned() to its own header
At present malloc.h is included everywhere since it recently was added to
common.h in this commit:
4519668 mtd/nand/ubi: assortment of alignment fixes
This seems wasteful and unnecessary. We have been trying to trim down
common.h and put separate functions into separate header files and that
change goes in the opposite direction.
Move malloc_cache_aligned() to a new header so that this can be avoided.
The header would perhaps be better named as alignmem.h but it needs to be
included after common.h and people might be confused by this. With the name
memalign.h it fits nicely after malloc() in most cases.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Stefan Roese [Wed, 2 Sep 2015 09:11:00 +0000 (11:11 +0200)]
arm: spear: Enable THUMB mode on x600 board
To reduce the size of the U-Boot image on the x600 board, lets enable
the THUMB mode. This reduces the overall size to less than 0x6000
bytes. Fitting it again in the onboard NOR flash.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Stefan Roese [Wed, 2 Sep 2015 09:10:59 +0000 (11:10 +0200)]
arm: spear: Add BCH4 SW support to SPEAr600 x600 board
This board is equipped with a Micron NAND chip (MT29F1G08ABADAH4) that
needs 4-bit ECC. But the SPEAr600 only supports 1-bit HW ECC internally.
This patch enables the SW 4-bit BCH support for this board.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Stefan Roese [Wed, 2 Sep 2015 09:10:58 +0000 (11:10 +0200)]
arm: spear: Add command to switch between 1-bit HW ECC and SW BCH4
This patch adds the "nandecc" command to switch between the SPEAr600 internal
1-bit HW ECC and the 4-bit SW BCH4 ECC. This can be needed to support NAND
chips with a stronger ECC than 1-bit, as on the x600. And to dynamically
switch between both ECC schemes for backwards compatibility.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Stefan Roese [Wed, 2 Sep 2015 12:29:12 +0000 (14:29 +0200)]
mtd: nand: fsmc: Add BCH4 SW ECC support for SPEAr600
This patch adds support for 4-bit ECC BCH4 for the SPEAr600 SoC. This can
be used by boards equipped with a NAND chip that requires 4-bit ECC strength.
The SPEAr600 HW ECC only supports 1-bit ECC strength.
To enable SW BCH4, you need to specify this in your config header:
#define CONFIG_NAND_ECC_BCH
#define CONFIG_BCH
And use the command "nandecc bch4" to select this ECC scheme upon runtime.
Tested on SPEAr600 x600 board.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Scott Wood <scottwood@freescale.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Simon Glass [Mon, 31 Aug 2015 01:19:39 +0000 (19:19 -0600)]
arm: Remove tx25 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:36 +0000 (19:19 -0600)]
arm: Remove palmtreo680 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:34 +0000 (19:19 -0600)]
arm: Remove xaeniax board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:33 +0000 (19:19 -0600)]
arm: Remove vpac270_nor_128 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:32 +0000 (19:19 -0600)]
arm: Remove vl_ma2sc board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:31 +0000 (19:19 -0600)]
arm: Remove vision2 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Stefano Babic <sbabic@denx.de>
Simon Glass [Mon, 31 Aug 2015 01:19:30 +0000 (19:19 -0600)]
arm: Remove versatileab board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:29 +0000 (19:19 -0600)]
arm: Remove tt01 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:28 +0000 (19:19 -0600)]
arm: Remove tk71 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:27 +0000 (19:19 -0600)]
arm: Remove scb9328 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:26 +0000 (19:19 -0600)]
arm: Remove rd6281a board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:25 +0000 (19:19 -0600)]
arm: Remove qong board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:24 +0000 (19:19 -0600)]
arm: Remove pxa255_idp, zipitz2 boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:23 +0000 (19:19 -0600)]
arm: Remove portuxg20, stamp9g20 boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:22 +0000 (19:19 -0600)]
arm: Remove polaris and trizepsiv boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Stefano Babic <sbabic@denx.de>
Simon Glass [Mon, 31 Aug 2015 01:19:21 +0000 (19:19 -0600)]
arm: Remove palmtc board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:20 +0000 (19:19 -0600)]
arm: Remove palmld board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:19 +0000 (19:19 -0600)]
arm: Remove otc570 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:18 +0000 (19:19 -0600)]
arm: Remove openrd boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:17 +0000 (19:19 -0600)]
arm: Remove omap3_sdp3430 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:16 +0000 (19:19 -0600)]
arm: Remove omap3_mvblx board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:14 +0000 (19:19 -0600)]
arm: Remove nhk8815 boards and nomadik arch
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:13 +0000 (19:19 -0600)]
arm: Remove mx51_efikamx, mx51_efikasb boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:12 +0000 (19:19 -0600)]
arm: Remove mv88f6281gtw_ge board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:10 +0000 (19:19 -0600)]
arm: Remove lp8x4x board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:09 +0000 (19:19 -0600)]
arm: Remove jornada board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:08 +0000 (19:19 -0600)]
arm: Remove inetspace_v2_cmc board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:07 +0000 (19:19 -0600)]
arm: Remove mx31_litekit board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:06 +0000 (19:19 -0600)]
arm: Remove imx27lite, imx27_litekit and magnesium boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:05 +0000 (19:19 -0600)]
arm: Remove ima3-mx53 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:04 +0000 (19:19 -0600)]
arm: Remove enbw_cmc board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:02 +0000 (19:19 -0600)]
arm: Remove eb_cpu9k2 and eb_cpu9k2_ram boards
These board have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:01 +0000 (19:19 -0600)]
arm: Remove dig297 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:19:00 +0000 (19:19 -0600)]
arm: Remove d2net_v2 defconfig file
This file appears to be an orphan with no board files. Drop it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:18:59 +0000 (19:18 -0600)]
arm: Remove unmaintained davinci boards
These boards have not been converted to generic board by the deadline.
Remove dm355evm, dm355leopard, dm365evm, dm6467evm, dvevm, ea20, schmoogie,
sffsdr, sonata.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:18:58 +0000 (19:18 -0600)]
arm: Remove snowball and u8500_href boards
These boards have not been converted to generic board by the deadline.
Remove them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:18:56 +0000 (19:18 -0600)]
arm: Remove eukrea boards
These boards have not been converted to generic board by the deadline.
Remove all cpu9260 and cpuat91 boards.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 31 Aug 2015 01:18:55 +0000 (19:18 -0600)]
arm: Remove balloon3 board
This board has not been converted to generic board by the deadline.
Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Lokesh Vutla [Fri, 28 Aug 2015 08:05:08 +0000 (13:35 +0530)]
ti_armv7_common: env: Use partuuid for detecting mmc root fs
Linux kernel can enumerate mmc sd as either mmcblk0 or mmcblk1.
But u-boot default environment assumes that sd always populates
as mmcblk0. With this the root fs is not being mounted when
mmc sd is enumerated as mmcblk1.
So use partuuid to update root= option in default environment.
Reported-by: Yan Liu <yan-liu@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Lokesh Vutla [Fri, 28 Aug 2015 08:05:07 +0000 (13:35 +0530)]
ti_armv7_common: env: Consolidate MMC args
Define default mmc args in ti_armv7_common.h so that all
TI platforms can reuse.
Reported-by: Yan Liu <yan-liu@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Lokesh Vutla [Fri, 28 Aug 2015 08:05:06 +0000 (13:35 +0530)]
ti_omap4_common: use ext4 fs as default.
All TI SoCs expect filesystem to be ext4, omap4_common is the only one
with ext3. move omap4 to ext4 so that we can start consolidating MMC
arguments.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Lokesh Vutla [Fri, 28 Aug 2015 06:58:25 +0000 (12:28 +0530)]
ARM: DRA7: emif: Fix disabling/enabling of refreshes
clrsetbits_le32/clrbits_le32 takes mask of the bits as input that
are needed to be set/clear. But emif driver passes the shift of the bits.
Fixing it here.
Reported-by: Mark Mckeown <m-mckeown@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Vladimir Zapolskiy [Thu, 27 Aug 2015 00:16:48 +0000 (03:16 +0300)]
lpc32xx: remove duplicated DMA_CLK_ENABLE bit definition
Because there is an originally defined CLK_DMA_ENABLE macro in clk.h,
no reason to add another DMA_CLK_ENABLE macro with the same value.
Remove DMA_CLK_ENABLE, since it does not follow naming convention from
the code, this implies renaming of DMA_CLK_ENABLE to CLK_DMA_ENABLE in
lpc32xx/devices.c file.
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Tested-by: Sylvain Lemieux <slemieux@tycoint.com>
Peng Fan [Wed, 26 Aug 2015 07:41:33 +0000 (15:41 +0800)]
driver: misc: correct Kconfig entry
Should use FSL_SEC_MON, not CONFIG_FSL_SEC_MON as Kconfig entry.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: York Sun <yorksun@freescale.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>
Hannes Petermaier [Tue, 25 Aug 2015 11:55:41 +0000 (13:55 +0200)]
board/BuR: simplify default IP-setup on B&R boards.
To simplify and having a common default IP-setup on all B&R boards we
introduce an environment variable "brdefaultip" which does following.
Test if ${ipaddr} is empty, if yes it set's up some defaults:
- ipaddr : 192.168.60.1
- netmask : 255.255.255.0
- gatewayip: 192.168.60.254
- serverip : 192.168.60.254
This environment is ran from CONFIG_PREBOOT.
All other "tricks" are dropped.
Signed-off-by: Hannes Schmelzer <oe5hpm@oevsv.at>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Stephen Warren [Wed, 29 Jul 2015 03:55:03 +0000 (21:55 -0600)]
fat: handle paths that include ../
The FAT code contains a special case to parse the root directory. This
is needed since the root directory location/layout on disk is special
cased for FAT12/16. In particular, the location and size of the FAT12/16
root directory is hard-coded and contiguous, whereas all FAT12/16 non-root
directories, and all FAT32 directories, are stored in a non-contiguous
fashion, with the layout represented by a linked-list of clusters in the
FAT.
If a file path contains ../ (for example /extlinux/../bcm2835-rpi-cm.dtb),
it is possible to need to parse the root directory for the first element
in the path (requiring application of the special case), then a sub-
directory (in the general way), then re-parse the root directory (again
requiring the special case). However, the current code in U-Boot only
applies the special case for the very first path element, and never for
any later path element. When reparsing the root directory without
applying the special case, any file in a sector (or cluster?) other than
the first sector/cluster of the root directory will not be found.
This change modifies the non-root-dir-parsing loop of do_fat_read_at()
to detect if it's walked back to the root directory, and if so, jumps
back to the special case code that handles parsing of the root directory.
This change was tested using sandbox by executing:
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/../"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/..backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../backup/../bcm2835-rpi-cm.dtb"
(/extlinux and /backup are in different sectors so trigger some different
cases, and bcm2835-rpi-cm.dtb is in a sector of the root directory other
than the first).
In all honesty, this change is a bit of a hack, using goto and all.
However, as demonstrated above it appears to work well in practice, is
quite minimal, likely doesn't introduce any risk of regressions, and
hopefully doesn't introduce any maintenance issues.
The correct fix would be to collapse the root and non-root loops in
do_fat_read_at() and get_dentfromdir() into a single loop that has a
small special-case when moving from one sector to the next, to handle
the layout difference of root/non-root directories. AFAIK all other
aspects of directory parsing are identical. However, that's a much
larger change which needs significantly more thought before it's
implemented.
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Masahiro Yamada [Mon, 11 May 2015 10:44:01 +0000 (19:44 +0900)]
git-mailrc: add Alexey as ARC maintainer
It's easier to Cc him on ARC-releated patches.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tom Rini [Fri, 11 Sep 2015 17:05:05 +0000 (13:05 -0400)]
Merge branch 'master' of git.denx.de/u-boot-sunxi
Heiko Schocher [Tue, 8 Sep 2015 09:52:52 +0000 (11:52 +0200)]
at91, taurus, smartweb: add dfu support
[root@pollux dfu-util]# ./src/dfu-util -l
dfu-util 0.8
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Found DFU: [0908:02d2] ver=0212, devnum=119, cfg=1, intf=0, alt=0, name="Linux", serial="UNKNOWN"
[root@pollux dfu-util]#
Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Heiko Schocher [Tue, 8 Sep 2015 09:52:51 +0000 (11:52 +0200)]
usb: gadget: at91_udc: add at91_udc into U-Boot
add U-Boot specific changes to the at91_udc linux driver,
so it works with U-Boot.
Signed-off-by: Heiko Schocher <hs@denx.de>
Heiko Schocher [Tue, 8 Sep 2015 09:52:50 +0000 (11:52 +0200)]
usb: gadget: at91_udc: port linux driver at91_udc
port at91_udc driver from linux:
original commit Message:
commit
c94e289f195e0e13cf34d27f9338d28221a85751
Author: Arnd Bergmann <arnd@arndb.de>
Date: Sat Apr 11 00:14:21 2015 +0200
usb: gadget: remove incorrect __init/__exit annotations
A recent change introduced a link error for the composite
printer gadget driver:
`printer_unbind' referenced in section `.ref.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
Evidently the unbind function should not be marked __exit here,
because it is called through a callback pointer that is not necessarily
discarded, __composite_unbind() is indeed called from the error path of
composite_bind(), which can never work for a built-in driver.
Looking at the surrounding code, I found the same problem in all other
composite gadget drivers in both the bind and unbind functions, as
well as the udc platform driver 'remove' functions. Those will break
if anyone uses the 'unbind' sysfs attribute to detach a device from a
built-in driver.
This patch removes the incorrect annotations from all the gadget
drivers.
Signed-off-by: Heiko Schocher <hs@denx.de>
Bo Shen [Wed, 2 Sep 2015 10:00:06 +0000 (18:00 +0800)]
ARM: atmel: boards: use default CONFIG_SYS_PBSIZE
Entering the maximum number of characters defined by CONFIG_SYS_CBSIZE
into the console and hitting enter afterwards, causes a hang in the
system because CONFIG_SYS_PBSIZE is not capable of storing the extra
characters of the error message:
"Unknown command '' - try 'help'".
Use the default CONFIG_SYS_PBSIZE definition from config_fallbacks.h
to solve this problem.
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Daniel Gorsulowski [Mon, 31 Aug 2015 05:32:25 +0000 (07:32 +0200)]
arm: at91: convert meesc board to generic board
Signed-off-by: Daniel Gorsulowski <daniel.gorsulowski@esd.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
[fix corrupt line wraps in patch]
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Heiko Schocher [Fri, 21 Aug 2015 16:55:07 +0000 (18:55 +0200)]
taurus: board updates
taurus changes:
- rename at91_spl_board_init to spl_board_init
fixes problems with recovery button and nand erase sector 0
- adapt CONFIG_SPL_MAX_SIZE and CONFIG_SPL_BSS_MAX_SIZE
- add CONFIG_AT91_HW_WDT_TIMEOUT 15
- CONFIG_SF_DEFAULT_MODE SPI_MODE_3 not mode 0
Signed-off-by: Heiko Schocher <hs@denx.de>
Heiko Schocher [Fri, 21 Aug 2015 16:53:46 +0000 (18:53 +0200)]
arm, at91: add axm extensions
add extensions for the axm board:
- power on LED on power up
- press both recovery buttons on power up to enter
recovery mode
- detect 64 MiB and 128 MiB ramsize
- PHY rest at reboot because of ATMEL bug
- use siemens update concept
- add axm default environment
- set CONFIG_SPL_MAX_SIZE to 15k
Signed-off-by: Heiko Schocher <hs@denx.de>
Heiko Schocher [Fri, 21 Aug 2015 09:28:20 +0000 (11:28 +0200)]
corvus, dfu: add dfu support
add support for DFU on the corvus board.
Signed-off-by: Heiko Schocher <hs@denx.de>
Heiko Schocher [Fri, 21 Aug 2015 09:28:19 +0000 (11:28 +0200)]
at91: corvus: board updates
- rename at91_spl_board_init into spl_board_init
- use SZ_1X defines for sizes
Signed-off-by: Heiko Schocher <hs@denx.de>
Stefan Roese [Fri, 4 Sep 2015 12:43:00 +0000 (14:43 +0200)]
sunxi_nand_spl: Add config parameter for 4KiB page sized NAND devices
This patch adds support for NAND chips with 4KiB page size and 24/1024
ECC strength. Like the Micron MT29F32G08CBACAWP which is used on the
ICnova-A20 SoM.
Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Siarhei Siamashka [Wed, 2 Sep 2015 23:36:39 +0000 (02:36 +0300)]
sunxi: Ensure that 'mksunxiboot' tool produces deterministic output
Currently some uninitialized padding bytes are written to the output
file, as can be confirmed with valgrind:
$ valgrind tools/mksunxiboot spl/u-boot-spl.bin spl/sunxi-spl.bin
==5581== Syscall param write(buf) points to uninitialised byte(s)
==5581== at 0x4F0F940: __write_nocancel (in /lib64/libc-2.20.so)
==5581== by 0x400839: main (in /tmp/u-boot/tools/mksunxiboot)
==5581== Address 0xffeff5d3c is on thread 1's stack
==5581== in frame #1, created by main (???)
This patch fixes the problem by clearing the whole structure instead
of just a portion of it.
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Siarhei Siamashka [Tue, 8 Sep 2015 14:49:08 +0000 (17:49 +0300)]
sunxi: Fix wrong serial console setup in Forfun Q88DB tablet
The Forfun Q88DB tablet was unbootable since commit
b6006baf9c2553543e3384983d23d95efbf24fa6 ("sunxi: Move all
boards to the driver-model"). Appears that this is caused
by the wrong serial console setup in the SPL. The serial
console should use PG3/PG4 pins according to the FEX file.
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Jelle van der Waa [Mon, 7 Sep 2015 20:43:57 +0000 (22:43 +0200)]
sun5i: Add A10s-Wobo-i5 defconfig and dts
The Wobo i5 top set box is a somewhat curious A10s based top set box,
it uses an AXP209 rather then the AXP152 usually used in combination
with the A10s. It has an ethernet phy connected to PORTD rather then
PORTA, and its built-in usb wifi is connected via the otg controller.
The dts file changes are identical to the changes submitted to the
upstream kernel.
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Sat, 5 Sep 2015 15:01:31 +0000 (17:01 +0200)]
sun5i: Add q8_a13_tablet defconfig and dts
This commits adds a generic support for q8 formfactor a13 based tablets.
These tablets ship in many variants, with the difference mainly being the
touchscreen controller / accelerometer / wifi chip used.
The wifi is USB based, and thus not listed in devicetree.
ATM the kernel does not support the touchscreen / accelerometer on these
devices. In the future we may need multiple configs with different
CONFIG_DEFAULT_DEVICE_TREE settings, this depends on how we solve the
hw differences on the kernel side.
For now this will suffice.
The dts files are identical to the dts files submitted to the upstream
kernel for these tablets.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Hans de Goede [Wed, 9 Sep 2015 07:46:30 +0000 (09:46 +0200)]
sun4i: Add dts and defconfig for iNet-1 based tablets
The iNet-tek iNet-1 PCB is a PCB found in various generic 10.1" 1024x600
A10 based tablets such as the Point of View Protab2 XXL and the
Cherry M1007.
This patch has been tested on both rev2 and rev5 of this board / these
tablets.
These tablets feature the usual connectors: headphone, mini hdmi,
power-barrel, mini-usb and a micro-sd slot.
The dts is identical to the dts submitted to the upstream kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Hans de Goede [Tue, 8 Sep 2015 20:28:30 +0000 (22:28 +0200)]
sun4i: Add defconfig and dts for inet9f-rev03 based tablets
The inet9f-rev03 pcb is specially designed for gaming tablets, such as
the qware tb-g100 tablet.
These 7" tablets feature a dpad, firebuttons and 2 joysticks on the sides
of the screen.
Besides this they have the usual connectors: power-barrel, mini usb,
mini hdmi, headphone and micro-sd slot.
The dts is identical to the dts submitted to the upstream kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Hans de Goede [Sat, 5 Sep 2015 08:50:56 +0000 (10:50 +0200)]
sun4i: Add defconfig and dts for the pov protab2-ips9 tablet
The Point of View protab2-ips9 is a tablet with a 9" ips 1024x768 lcd
screen, microsd slot, headphones, mini hdmi, mini usb b and power barrel
connectors.
The dts file is identical to the one submitted to the upstream kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Bin Meng [Thu, 3 Sep 2015 12:37:29 +0000 (05:37 -0700)]
net: designware: Fix build warnings
When building dm version of designware eth driver on a platform
with 64-bit phys_addr_t, it reports the following warnings:
drivers/net/designware.c: In function 'designware_eth_probe':
drivers/net/designware.c:599:2:
warning: format '%lx' expects argument of type 'long unsigned int',
but argument 3 has type 'phys_addr_t' [-Wformat]
drivers/net/designware.c:600:21:
warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/net/designware.c:601:21:
warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
This commit fixes the build warnings.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:28 +0000 (05:37 -0700)]
x86: galileo: Convert to use CONFIG_DM_USB
Move to driver model for USB on Intel Galileo.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:27 +0000 (05:37 -0700)]
x86: quark: Add USB PHY initialization support
USB PHY needs to be properly initialized per Quark firmware writer
guide, otherwise the EHCI controller on Quark SoC won't work.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:26 +0000 (05:37 -0700)]
x86: Convert to use driver model pci on quark/galileo
Move to driver model pci for Intel quark/galileo.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:25 +0000 (05:37 -0700)]
x86: Enable PCIe controller on quark/galileo
Quark SoC holds the PCIe controller in reset following a power on.
U-Boot needs to release the PCIe controller from reset. The PCIe
controller (D23:F0/F1) will not be visible in PCI configuration
space and any access to its PCI configuration registers will cause
system hang while it is held in reset.
Enable PCIe controller per Quark firmware writer guide.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:24 +0000 (05:37 -0700)]
x86: quark: Avoid chicken and egg problem
If we convert to use driver model pci on quark, we will encounter
some chicken and egg problems like below:
- To enable PCIe root ports, we need program some registers on the
message bus via pci bus. With driver model, the first time to
access pci bus, the pci enumeration process will be triggered.
But without first enabling PCIe root ports, pci enumeration
just hangs when scanning PCIe root ports.
- Similar situation happens when trying to access GPIO from the
PCIe enabling codes, as GPIO requires its block base address
to be assigned via a pci configuration register in the bridge.
To avoid such dilemma, replace all pci calls in the quark codes
to use the local version which does not go through driver model.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Thu, 3 Sep 2015 12:37:23 +0000 (05:37 -0700)]
x86: quark: Optimize MRC execution time
Intel Quark SoC has a low end x86 processor with only 400MHz
frequency. Currently it takes about 15 seconds for U-Boot to
boot to shell and the most time consuming part is with MRC,
which is about 12 seconds. MRC programs lots of registers on
the SoC internal message bus indirectly accessed via pci bus.
To speed up the boot, create an optimized version of pci config
read/write dword routines which directly operate on PCI I/O ports.
These two routines are inlined to provide better performance too.
Now it only takes about 3 seconds to finish MRC, which is really
fast (4 times faster than before).
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass [Tue, 1 Sep 2015 00:55:35 +0000 (18:55 -0600)]
dm: pci: Allow a PCI bus to be found without an alias
At present, until a PCI bus is probed, it cannot be found by its sequence
number unless it has an alias. This is the same with any device.
However with PCI this is more annoying than usual, since bus 0 is always the
same device.
Add a function that tries a little harder to locate PCI bus 0. This means
that PCI enumeration will happen automatically on the first access.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass [Wed, 26 Aug 2015 03:52:14 +0000 (21:52 -0600)]
buildman: Improve the config comparison feature
At present buildman can compare configurations between commits but the
feature is less useful than it could be. There is no summary by architecture
and changes are not reported on a per-board basis.
Correct these deficiencies so that it is possible to see exactly what is
changing for any number of boards.
Note that 'buildman -b <branch> -C' is recommended for any build where you
will be comparing configuration. Without -C the correct configuration will
not be reported since changes will often not be picked up.
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Sun, 30 Aug 2015 16:23:32 +0000 (01:23 +0900)]
Revert "patman: use -D option for git format-patch"
This reverts commit
19b4a3369876f9215e2b861f211e8df1a75e26ca.
Since that commit, patman generates useless patches for file removal;
"git format -D" prints only the header but not the diff when deleting
files, and "git am" always refuses such patches.
The following is the quotation from "man git-format-patch":
-D, --irreversible-delete
Omit the preimage for deletes, i.e. print only the header but
not the diff between the preimage and /dev/null. The resulting
patch is not meant to be applied with patch nor git apply; this
is solely for people who want to just concentrate on reviewing
the text after the change. In addition, the output obviously
lack enough information to apply such a patch in reverse, even
manually, hence the name of the option.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 09:22:39 +0000 (02:22 -0700)]
x86: bayleybay: Convert to use more dm drivers
Move to driver model for USB and ETH on Intel Bayley Bay.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 09:22:38 +0000 (02:22 -0700)]
x86: coreboot: Convert to use more dm drivers
Move to driver model for RTC, USB and ETH on coreboot.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 05:25:59 +0000 (22:25 -0700)]
x86: crownbay: Enable CONFIG_PCH_GBE
Now that we have converted the pch_gbe driver to driver moel,
enable it on Intel Crown Bay board.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 05:25:58 +0000 (22:25 -0700)]
net: pch_gbe: Add Kconfig option
Add Kconfig option in preparation for moving board to use Kconfig.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng [Fri, 28 Aug 2015 05:25:57 +0000 (22:25 -0700)]
net: pch_gbe: Convert to driver model
This commit converts pch_gbe ethernet driver to driver model.
Since this driver is only used by Intel Crown Bay board, the
conversion does not keep the non-dm version.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 05:25:56 +0000 (22:25 -0700)]
x86: crownbay: Convert to use CONFIG_DM_ETH for E1000
Since E1000 driver has been converted to driver model, enable it
on Intel Crown Bay. But the Intel Topcliff GbE driver has not been
converted to driver model yet, disable it for now.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Bin Meng [Fri, 28 Aug 2015 05:25:55 +0000 (22:25 -0700)]
x86: crownbay: Convert to use CONFIG_DM_USB
Move to driver model for USB on Intel Crown Bay.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng [Fri, 28 Aug 2015 05:25:54 +0000 (22:25 -0700)]
dm: eth: Correctly detect alias in eth_get_dev_by_name()
When given a device name string, we should test to see if it is
really an alias like "eth#".
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Bin Meng [Fri, 28 Aug 2015 05:25:53 +0000 (22:25 -0700)]
dm: test: Add a new test case for dm_test_eth_rotate
Add one more ethernet device node in the sandbox test device tree,
with name 'sbe5'. This is to support a new test case for testing
network device rotation.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Bin Meng [Fri, 28 Aug 2015 05:25:52 +0000 (22:25 -0700)]
dm: eth: Do not print misleading "Net Initialization Skipped"
With driver model, board_eth_init() or cpu_eth_init() is not a must.
Thus we don't need print a misleading "Net Initialization Skipped".
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Bin Meng [Fri, 28 Aug 2015 05:25:51 +0000 (22:25 -0700)]
net: Revert "tftp: adjust settings to be suitable for 100Mbit ethernet"
Commit
620776d "tftp: adjust settings to be suitable for 100Mbit ethernet"
causes the following error message when trying to load a file using 'tftp'
command via a tftp server.
TFTP error: 'Unsupported option(s) requested' (8)
This is due to with commit
620776d changes, the tftp option 'timeout'
value is now set to zero which is an invalid value as per RFC2349 [1].
Valid values range between "1" and "255" seconds, inclusive. With some
tftp servers that strictly implement the RFC requirement, it reports
such an error message.
Revert commit
620776d for RFC compliance.
[1] https://www.ietf.org/rfc/rfc2349.txt
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Simon Glass [Fri, 28 Aug 2015 01:54:48 +0000 (19:54 -0600)]
x86: panther: Add PCI and video configuration
Add a PCI node to the device tree. This allows SPI flash and SATA to work
correctly. Also configure the video to come up correctly even though there
is no keyboard.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>