summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeLines
* ext4: Fix memory leak in case of failureStefan Brüns2016-09-23-2/+2
| | | | | | | | temp_ptr should always be freed, even if the function is left via goto fail. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Avoid out-of-bounds access of block bitmapStefan Brüns2016-09-23-22/+12
| | | | | | | | | | | | If the blocksize is 1024, count is initialized with 1. Incrementing count by 8 will never match (count == fs->blksz * 8), and ptr may be incremented beyond the buffer end if the bitmap is filled. Add the startblock offset after the loop. Remove the second loop, as only the first iteration will be done. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: After completely filled group, scan next group from the beginningStefan Brüns2016-09-23-3/+5
| | | | | | | | | | | | | | | | | | | | The last free block of a block group may be in its middle. After it has been allocated, the next block group should be scanned from its beginning. The following command triggers the bad behaviour (on a blocksize 1024 fs): ./sandbox/u-boot -c 'i=0; host bind 0 ./disk.raw ; while test $i -lt 260 ; do echo $i; setexpr i $i + 1; ext4write host 0:2 0 /X${i} 0x1450; done ; ext4write host 0:2 0 /X240 0x2000 ; ' When 'X240' is extended from 5200 byte to 8192 byte, the new blocks should start from the first free block (8811), but it uses the blocks 8098-8103 and 16296-16297 -- 8103 + 1 + 8192 = 16296. This can be shown with debugfs, commands 'ffb' and 'stat X240'. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Do not clear zalloc'ed buffers a second timeStefan Brüns2016-09-23-3/+0
| | | | | | | | | zero_buffer is never written, thus clearing it is pointless. journal_buffer is completely initialized by ext4fs_devread (or in case of failure, not used). Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Only update number of of unused inodes if GDT_CSUM feature is setStefan Brüns2016-09-23-7/+7
| | | | | | | | | | e2fsck warns about "Group descriptor 0 marked uninitialized without feature set." The bg_itable_unused field is only defined if FEATURE_RO_COMPAT_GDT_CSUM is set, and should be set (kept) zero otherwise. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Scan all directory blocks when looking up an entryStefan Brüns2016-09-23-44/+40
| | | | | | | | | Scanning only the direct blocks of the directory file may falsely report an existing file as nonexisting, and worse can also lead to creation of a duplicate entry on file creation. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Avoid corruption of directories with hash tree indexesStefan Brüns2016-09-23-0/+6
| | | | | | | | | While directories can be read using the old linear scan method, adding a new file would require updating the index tree (alternatively, the whole tree could be removed). Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Scan all directory blocks for space when inserting a new entryStefan Brüns2016-09-23-44/+30
| | | | | | | | | | | Previously, only the last directory block was scanned for available space. Instead, scan all blocks back to front, and if no sufficient space is found, eventually append a new block. Blocks are only appended if the directory does not use extents or the new block would require insertion of indirect blocks, as the old code does. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: Do not crash when trying to grow a directory using extentsStefan Brüns2016-09-23-1/+6
| | | | | | | | | | | | | The following command crashes u-boot: ./sandbox/u-boot -c 'i=0; host bind 0 ./sandbox/test/fs/3GB.ext4.img ; while test $i -lt 200 ; do echo $i; setexpr i $i + 1; ext4write host 0 0 /foobar${i} 0; done' Previously, the code updated the direct_block even for extents, and fortunately crashed before pushing garbage to the disk. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: propagate error if creation of directory entry failsStefan Brüns2016-09-23-8/+10
| | | | | | | | In case the dir entry creation failed, ext4fs_write would later overwrite a random inode, as inodeno was never initialized. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: fix possible crash on directory traversal, ignore deleted entriesStefan Brüns2016-09-23-39/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | The following command triggers a segfault in search_dir: ./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ; ext4write host 0 0 /./foo 0x10' The following command triggers a segfault in check_filename: ./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ; ext4write host 0 0 /. 0x10' "." is the first entry in the directory, thus previous_dir is NULL. The whole previous_dir block in search_dir seems to be a bad copy from check_filename(...). As the changed data is not written to disk, the statement is mostly harmless, save the possible NULL-ptr reference. Typically a file is unlinked by extending the direntlen of the previous entry. If the entry is the first entry in the directory block, it is invalidated by setting inode=0. The inode==0 case is hard to trigger without crafted filesystems. It only hits if the first entry in a directory block is deleted and later a lookup for the entry (by name) is done. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: fix wrong usage of le32_to_cpu()Michael Walle2016-09-23-1/+1
| | | | | | | le32_to_cpu() must only convert the revision_level and not the boolean result. Signed-off-by: Michael Walle <michael@walle.cc>
* ext4: fix endianess problems in ext4 write supportMichael Walle2016-09-23-250/+311
| | | | | | | | All fields were accessed directly instead of using the proper byte swap functions. Thus, ext4 write support was only usable on little-endian architectures. Fix this. Signed-off-by: Michael Walle <michael@walle.cc>
* ext4: use kernel names for byte swapsMichael Walle2016-09-23-55/+55
| | | | | | Instead of __{be,le}{16,32}_to_cpu use {be,le}{16,32}_to_cpu. Signed-off-by: Michael Walle <michael@walle.cc>
* ext4: change structure fields to __le/__be typesMichael Walle2016-09-23-88/+88
| | | | | | | | Change all the types of ext2/4 fields to little endian types and all the JBD fields to big endian types. Now we can use sparse (make C=1) to check for statements where we need byteswaps. Signed-off-by: Michael Walle <michael@walle.cc>
* test/fs: Check writes using "." (same dir) relative pathStefan Brüns2016-09-23-1/+28
| | | | | | <path>/<fname> and <path>/./<fname> should reference the same file. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* test/fs: Check ext4 behaviour if dirent is first entry in directory blockStefan Brüns2016-09-23-0/+10
| | | | | | | | | | This is a regression test for a crash happening if the first dirent in the block matches. Code tried to access a predecessor entry which does not exist. The crash happened for any block, but "." is always the first entry in the first directory block and thus easy to check for. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* test/fs: strip noise from filesystem code prior to checking resultsStefan Brüns2016-09-23-11/+15
| | | | | | | | ext4 and fat code emit some diagnostic messages during command execution. These additional lines force a match window size which strictly is not necessary. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* test/fs: remove use of undefined WRITE_FILE variableStefan Brüns2016-09-23-6/+4
| | | | | | | The write file is created from $SMALL_FILE by appending ".w" on all other occurences in the code. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* test/fs: Restructure file path specification to allow some flexibilityStefan Brüns2016-09-23-36/+22
| | | | | | | | Instead of providing the full path, specify directory and filename separately. This allows to specify intermediate directories, required for some additional tests. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* cmd/fat: Do not crash on write when <bytes> is not specifiedStefan Brüns2016-09-23-2/+2
| | | | | | | | argc is checked, but is off by one. In case <bytes> is not specified, create an empty file, which is identical to the ext4write behaviour. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* fs/fat: Correct description of determine_fatent functionStefan Brüns2016-09-23-1/+3
| | | | | | | Current description does not match the function behaviour. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
* fs/fat: Do not write unmodified fat entries to diskStefan Brüns2016-09-23-12/+21
| | | | | | | | | | | | The code caches 6 sectors of the FAT. On FAT traversal, the old contents needs to be flushed to disk, but only if any FAT entries had been modified. Explicitly flag the buffer on modification. Currently, creating a new file traverses the whole FAT up to the first free cluster and rewrites the on-disk blocks. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
* fs/fat: Remove two statements without effectStefan Brüns2016-09-23-4/+1
| | | | | | | | | | fatlength is a local variable which is no more used after the assignment. s_name is not used in the function, save the strncpy. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
* Merge git://git.denx.de/u-boot-rockchipTom Rini2016-09-22-26/+1391
|\
| * clk: rk3288: add PWM clock get rateKever Yang2016-09-22-0/+2
| | | | | | | | | | | | | | This patch add clk_get_rate for PWM device. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * clk: rk3399: add pmucru controller supportKever Yang2016-09-22-4/+173
| | | | | | | | | | | | | | | | pmucru is a module like cru which is a clock controller manage some PLL and module clocks. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rk3399: add a empty "sys_proto.h" header fileKever Yang2016-09-22-0/+10
| | | | | | | | | | | | | | | | driver/usb/dwc3/gadget.c need a "sys_proto.h" header file, add a empty one to make compile success. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rockchip: rk3288: skip lowlevel_init processXu Ziyuan2016-09-22-8/+1
| | | | | | | | | | | | | | | | lowlevel_init() is never needed for rk3288, so drop it. Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
| * board: evb-rk3399: enable usb 2.0 host vbus power on board_initKever Yang2016-09-22-1/+14
| | | | | | | | | | | | | | | | rk3399 using one gpio control signal for two usb 2.0 host port, it's better to enable the power in board file instead of in usb driver. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * config: evb-rk3399: enable fixed regulatorKever Yang2016-09-22-0/+2
| | | | | | | | | | | | | | This patch enable fixed regulator driver for rk3399 evb. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * dts: rk3399-evb: add regulator-fixed for usb host vbusKever Yang2016-09-22-0/+6
| | | | | | | | | | | | | | | | rk3399 evb using one gpio to enable 5V output for both USB 2.0 host port, let's use fixed regulator for them. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * dts: rk3399: add dwc3_typec node for rk3399MengDongyang2016-09-22-0/+53
| | | | | | | | | | | | | | | | | | rk3399 has two dwc3 controller for type-C port, add the dts node and enable them. Signed-off-by: MengDongyang <daniel.meng@rock-chips.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * config: rk3399: add usb related configsMengDongyang2016-09-22-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch to enable configs for usb module - xhci - ehci - usb storage - usb net Signed-off-by: MengDongyang <daniel.meng@rock-chips.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Squashed in patch to move to Kconfig: https://patchwork.ozlabs.org/patch/672543/ Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
| * usb: host: add Kconfig for USB_XHCI_ROCKCHIPKever Yang2016-09-22-0/+7
| | | | | | | | | | | | | | Add a Kconfig for Rockchip xhci controller. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Marek Vasut <marex@denx.de>
| * rockchip: select DM_USB for rockchip SoCMengDongyang2016-09-22-0/+1
| | | | | | | | | | | | | | | | Select DM_USB to compatible with USB DM driver model. Signed-off-by: MengDongyang <daniel.meng@rock-chips.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * usb: xhci-rockchip: add rockchip dwc3 controller driverMengDongyang2016-09-22-0/+226
| | | | | | | | | | | | | | | | | | | | | | | | This patch add support for rockchip dwc3 controller, which corresponding to the two type-C port on rk3399 evb. Only support usb2.0 currently for we have not enable the usb3.0 phy driver and PD(fusb302) driver. Signed-off-by: MengDongyang <daniel.meng@rock-chips.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * rk3288: add arch_cpu_init for rk3288Kever Yang2016-09-22-0/+20
| | | | | | | | | | | | | | | | We do some SoC level one time setting initialization in arch_cpu_init. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rk_pwm: remove grf setting code from driverKever Yang2016-09-22-11/+0
| | | | | | | | | | | | | | | | | | We consider the grf setting for pwm controller select as the system operation instead of driver operation, move it to soc init, let's remove it from pwm driver first. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rk_pwm: use clock framework API to get module clockKever Yang2016-09-22-3/+14
| | | | | | | | | | | | | | | | | | This patch use clock API instead of hardcode for get pwm clock. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Fix printf() to debug() nit: Signed-off-by: Simon Glass <sjg@chromium.org>
| * rockchip: use dummy byte only enable OF_PLATDATAXu Ziyuan2016-09-22-0/+4
| | | | | | | | | | | | | | | | | | Add a condition to determine the rk3288_sdram_channel size. This patch fixes read sdram_channel property failed from DT on rk3288 boards, which not enable OF_PLATDATA. Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
| * dts: rk3399: add pinctrl for sdmmcKever Yang2016-09-22-0/+37
| | | | | | | | | | | | | | | | This patch add pinctrl for sdcard which may not be initialized before uboot. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rk3399: enable the pwm2/3 pinctrl in board initKever Yang2016-09-22-1/+30
| | | | | | | | | | | | | | | | | | There is no interrupt line for each PWM which used by pinctrl to get the periph_id, so it's not able to enable the default pinctrl setting by pinctrl framework, let's enable it at board_init(). Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * config: evb-rk3399: enable pinctrl driverKever Yang2016-09-22-0/+2
| | | | | | | | | | | | | | | | This patch enable rk3399 pinctrl driver and gpio driver which is sub-node of pinctrl. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * pinctrl: add driver for rk3399Kever Yang2016-09-22-0/+770
| | | | | | | | | | | | | | This patch add pinctrl driver for rk3399. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
| * rk3399: syscon: add support for pmugrfKever Yang2016-09-22-0/+2
| | | | | | | | | | | | | | | | pmugrf is a module like grf which contain some of the iomux registers and other registers. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
* | ns16650: Make sure we have CONFIG_CLK set before using infrastructureTom Rini2016-09-22-15/+17
| | | | | | | | | | | | | | We cannot call on the CONFIG_CLK based clk_get_rate function unless CONFIG_CLK is set. Signed-off-by: Tom Rini <trini@konsulko.com>
* | Merge branch 'master' of git://git.denx.de/u-boot-uniphierTom Rini2016-09-22-285/+469
|\ \
| * | ARM: dts: uniphier: sync clock/reset controller nodes with LinuxMasahiro Yamada2016-09-23-181/+301
| | | | | | | | | | | | | | | | | | Sync device trees with Linux for easier DT life. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
| * | clk: uniphier: allow to have clock node under syscon nodeMasahiro Yamada2016-09-23-9/+9
| | | | | | | | | | | | | | | | | | | | | To sync the DT binding with Linux, the register base must be taken from the parent syscon node. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>