25 Jan, 2016

1 commit

  • BUILD_BUG_* macros have been defined in several headers. It would
    be nice to collect them in include/linux/bug.h like Linux.

    This commit is cherry-picking useful macros from include/linux/bug.h
    of Linux 4.4.

    I did not import BUILD_BUG_ON_MSG() because it would not work if it
    is used with include/common.h in U-Boot. I'd like to postpone it
    until the root cause (the "error()" macro in include/common.h causes
    the name conflict with "__attribute__((error()))") is fixed.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Tom Rini

    Masahiro Yamada
     

19 Jan, 2016

1 commit

  • In a number of places we had wordings of the GPL (or LGPL in a few
    cases) license text that were split in such a way that it wasn't caught
    previously. Convert all of these to the correct SPDX-License-Identifier
    tag.

    Signed-off-by: Tom Rini

    Tom Rini
     

14 Jan, 2016

2 commits

  • As noted by Coverity, when we have an error in
    alloc_triple_indirect_block we will leak ti_pbuff_start_addr as it's not
    being freed. Further inspection here shows that we could also leak
    ti_cbuff_start_addr in one corner case so free that as well.

    Reported-by: Coverity (CID 131205, 131206)
    Signed-off-by: Tom Rini

    Tom Rini
     
  • This will allow the implementation to make use of data in the block_dev
    structure beyond the base device number. This will be useful so that eMMC
    block devices can encompass the HW partition ID rather than treating this
    out-of-band. Equally, the existence of the priv field is crying out for
    this patch to exist.

    Signed-off-by: Stephen Warren
    Reviewed-by: Tom Rini

    Stephen Warren
     

08 Jan, 2016

1 commit


24 Nov, 2015

1 commit

  • If the ext3 journal gets out of sync with what is written on disk, for
    example because of an unexpected power cut, ext4fs_read_file can
    return an all-zero directory entry. In that case, ext4fs_iterate_dir
    would infinite loop.

    This patch detects when a directory entry's direntlen member is 0 and
    returns a failure status, which breaks out of the infinite loop. As a
    result, U-Boot will not find files that may subsequently be recovered
    when the journal is replayed.

    This is better behaviour than hanging in an infinite loop, but as a
    further improvement maybe U-Boot could interpret the ext3 journal and
    actually find the unsynced entries.

    Signed-off-by: Thomas Fitzsimmons
    Reviewed-by: Stefan Roese

    Thomas Fitzsimmons
     

10 Nov, 2015

1 commit

  • After consulting with some of the SPDX team, the conclusion is that
    Makefiles are worth adding SPDX-License-Identifier tags too, and most of
    ours have one. This adds tags to ones that lack them and converts a few
    that had full (or in one case, very partial) license blobs into the
    equivalent tag.

    Cc: Kate Stewart
    Signed-off-by: Tom Rini

    Tom Rini
     

06 Nov, 2015

1 commit


26 Oct, 2015

1 commit

  • sync with linux v4.2

    commit 64291f7db5bd8150a74ad2036f1037e6a0428df2
    Author: Linus Torvalds
    Date: Sun Aug 30 11:34:09 2015 -0700

    Linux 4.2

    This update is needed, as it turned out, that fastmap
    was in experimental/broken state in kernel v3.15, which
    was the last base for U-Boot.

    Signed-off-by: Heiko Schocher
    Tested-by: Ezequiel Garcia

    Heiko Schocher
     

25 Oct, 2015

3 commits


12 Oct, 2015

5 commits

  • Overwriting an empty file not created by U-Boot did not work, and it
    could even corrupt the FAT. Moreover, creating empty files or emptying
    existing files allocated a cluster, which is not standard.

    Fix this by always keeping empty files clusterless as specified by
    Microsoft (the start cluster must be set to 0 in the directory entry in
    that case), and by supporting overwriting such files.

    Signed-off-by: Benoît Thébaudeau

    Benoît Thébaudeau
     
  • Signed-off-by: Benoît Thébaudeau

    Benoît Thébaudeau
     
  • curclust was used instead of newclust in the debug() calls and in one
    CHECK_CLUST() call, which could skip a failure case.

    Signed-off-by: Benoît Thébaudeau

    Benoît Thébaudeau
     
  • set_contents() had uselessly split calls to set_cluster(). Merge these
    calls, which removes some cases of set_cluster() being called with a
    size of zero.

    Signed-off-by: Benoît Thébaudeau

    Benoît Thébaudeau
     
  • set_cluster() was using a temporary buffer without enforcing its
    alignment for DMA and cache. Moreover, it did not check the alignment of
    the passed buffer, which can come directly from applicative code or from
    the user.

    This could cause random data corruption, which has been observed on
    i.MX25 writing to an SD card.

    Fix this by only passing ARCH_DMA_MINALIGN-aligned buffers to
    disk_write(), which requires the introduction of a buffer bouncing
    mechanism for the misaligned buffers passed to set_cluster().

    By the way, improve the handling of the corresponding return values from
    disk_write():
    - print them with debug() in case of error,
    - consider that there is an error is disk_write() returns a smaller
    block count than the requested one, not only if its return value is
    negative.

    After this change, set_cluster() and get_cluster() are almost
    symmetrical.

    Signed-off-by: Benoît Thébaudeau

    Benoît Thébaudeau
     

12 Sep, 2015

8 commits

  • Since last API changes for files >2GB, the read of symlink is broken as
    ext4fs_read_file now returns 0 instead of the length of the actual read.

    Signed-off-by: Gary Bisson

    Gary Bisson
     
  • 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
    Acked-by: Lukasz Majewski
    Tested-by: Lukasz Majewski

    Stephen Warren
     
  • 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
    Acked-by: Lukasz Majewski
    Tested-by: Lukasz Majewski

    Stephen Warren
     
  • 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
    Acked-by: Lukasz Majewski
    Tested-by: Lukasz Majewski

    Stephen Warren
     
  • 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

    Test HW: Odroid XU3 - Exynos 5433

    Łukasz Majewski
     
  • 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

    Simon Glass
     
  • 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
    Acked-by: Marcel Ziswiler

    Simon Glass
     
  • 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

    Stephen Warren
     

29 Aug, 2015

1 commit

  • Various U-Boot adoptions/extensions to MTD/NAND/UBI did not take buffer
    alignment into account which led to failures of the following form:

    ERROR: v7_dcache_inval_range - start address is not aligned - 0x1f7f0108
    ERROR: v7_dcache_inval_range - stop address is not aligned - 0x1f7f1108

    Signed-off-by: Marcel Ziswiler
    Reviewed-by: Simon Glass
    Acked-by: Scott Wood
    [trini: Add __UBOOT__ hunk to lib/zlib/zutil.c due to malloc.h in common.h]
    Signed-off-by: Tom Rini

    Marcel Ziswiler
     

13 Aug, 2015

9 commits

  • http://lists.denx.de/pipermail/u-boot/2012-September/134347.html
    allows for reading files in chunks from the shell.

    When this feature is used to read past the end of a file an error
    was returned instead of returning the bytes read up to the end of
    file. Thus the following fails in the shell:

    offset = 0
    len = chunksize
    do
    read file, offset, len
    write data
    until bytes_read < len

    The patch changes the behaviour to printing an informational
    message and returning the actual read number of bytes aka read(2)
    behaviour for convenient use in U-Boot scripts.

    Signed-off-by: Max Krummenacher
    Signed-off-by: Marcel Ziswiler
    Acked-by: Marek Vasut
    Signed-off-by: Stefan Agner
    Signed-off-by: Marcel Ziswiler

    Max Krummenacher
     
  • When building the file system the existing code does an insertion into
    a linked list. It attempts to speed this up by keeping a pointer to
    where the last entry was inserted but it's still slow.

    Now the nodes are just inserted into the list without searching
    through for the correct place. This unsorted list is then sorted once
    using mergesort after all the entries have been added to the list.
    This speeds up the scanning of the flash file system considerably.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • If a sector has a CLEANMARKER at the beginning, it indicates that the
    entire sector has been erased. Therefore, if this is found, we can skip the
    entire block. This was not being done before this patch.

    The code now does the same as the kernel does when encountering a
    CLEANMARKER. It still checks that the next few words are FFFFFFFF, and if
    so, the block is assumed to be empty, and so is skipped.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • The scan code is similar to the linux kernel, but the kernel defines a much
    smaller size to scan through before deciding a sector is blank. Assuming
    that what is in the kernel is OK, make these two match.

    On its own, this change makes no difference to scanning of any sectors
    which have a clean marker at the beginning, since the entire sector is not
    blank.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • If the flash is slow, reading less from the flash into buffers makes
    the process faster.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • jffs2_1pass_read_inode() would read the entire data for each node
    in the filesystem, regardless of whether it was part of the file
    to be loaded or not. By only reading the header data for an inode,
    and then reading the data only when it is found to be part of the
    file to be loaded, much copying of data is saved.

    jffs2_1pass_list_inodes() read each inode for every file in the
    directory into a buffer. By using NULL as a buffer pointer, NOR
    flash simply returns a pointer, and therefore avoids a memory copy.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • If multiple versions of a file exist, only the most recent version
    should be used. The scheme to write 0 for the inode in older versions
    did not work, since this would have required writing to flash.

    The only time this caused an issue was listing a directory, where older
    versions of the file would still be seen. Since the directory entries
    are sorted, just look at the next entry in the list, and if it's the same
    move to that entry instead.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • Copying complete nodes from flash can be slow if the flash is slow
    to read. By only reading the data needed, the sorting operation can
    be made much faster.

    The directory entry comparison function also had a two bugs. First, it
    did not ensure the name was copied, so the name comparison may have
    been faulty (although it would have worked with NOR flash). Second,
    setting the ino to zero to ignore the entry did not work, since this
    was either writing to a temporary buffer, or (for NOR flash) directly
    to flash. Either way, the change was not remembered.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     
  • If a destination is not provided, jffs2_1pass_read_inode() only
    returns the length of the file. In this case, avoid reading all
    the data nodes, and return as soon as the length of the file is
    known.

    Signed-off-by: Mark Tomlinson

    Mark Tomlinson
     

20 Apr, 2015

1 commit

  • Only do sandbox filesystem access when using the hostfs device
    interface, rather then falling back to it in all cases. This prevents
    confusion situations due to the fallback being taken rather then an
    unsupported error being raised.

    Signed-off-by: Sjoerd Simons
    Reviewed-by: Simon Glass
    Acked-by: Simon Glass

    Sjoerd Simons
     

19 Apr, 2015

1 commit


06 Mar, 2015

1 commit

  • After rework of the file system API, the size of ext4
    write was missed. This causes printing unreliable write
    size at the end of the file system write operation.

    Signed-off-by: Przemyslaw Marczak
    Cc: Sjoerd Simons
    Cc: Lukasz Majewski
    Cc: Simon Glass
    Tested-by: Stephen Warren

    Przemyslaw Marczak
     

05 Feb, 2015

1 commit


30 Jan, 2015

1 commit