| 4f144a41 | 25-Jan-2016 |
Stephen Warren <swarren@nvidia.com> |
malloc: work around some memalign fragmentation issues
Use of memalign can trigger fragmentation issues such as:
// Internally, this needs to find a free block quite bit larger than s. // Once the
malloc: work around some memalign fragmentation issues
Use of memalign can trigger fragmentation issues such as:
// Internally, this needs to find a free block quite bit larger than s. // Once the free region is found, any unaligned "padding" immediately // before and after the block is marked free, so that the allocation // takes only s bytes (plus malloc header overhead). p = memalign(a, s); // If there's little fragmentation so far, this allocation is likely // located immediately after p. p2 = malloc(x); free(p); // In theory, this should return the same value for p. However, the hole // left by the free() call is only s in size (plus malloc header overhead) // whereas memalign searches for a larger block in order to guarantee it // can adjust the returned pointer to the alignment requirements. Hence, // the pointer returned, if any, won't be p. If there's little or no space // left after p2, this allocation will fail. p = memalign(a, s);
In practice, this issue occurs when running the "dfu" command repeatedly on NVIDIA Tegra boards, since DFU allocates a large 32M data buffer, and then initializes the USB controller. If this is the first time USB has been used in the U-Boot session, this causes a probe of the USB driver, which causes various allocations, including a strdup() of a GPIO name when requesting the VBUS GPIO. When DFU is torn down, the USB driver is left probed, and hence its memory is left allocated. If "dfu" is executed again, allocation of the 32M data buffer fails as described above.
In practice, there is a memory hole exactly large enough to hold the 32M data buffer than DFU needs. However, memalign() can't know that in a general way. Given that, it's particularly annoying that the allocation fails!
The issue is that memalign() tries to allocate something larger to guarantee the ability to align the returned pointer. This patch modifies memalign() so that if the "general case" over-sized allocation fails, another allocation is attempted, of the exact size the user desired. If that allocation just happens to be aligned in the way the user wants, (and in the case described above, it will be, since the free memory region is located where a previous identical allocation was located), the pointer can be returned.
This patch is somewhat related to 806bd245b1ab "dfu: don't keep freeing/reallocating". That patch worked around the issue by removing repeated free/memalign within a single execution of "dfu". However, the same technique can't be applied across multiple invocations, since there's no reason to keep the DFU buffer allocated while DFU isn't running. This patch addresses the root-cause a bit more directly.
This problem highlights some of the disadvantages of dynamic allocation and deferred probing of devices.
This patch isn't checkpatch-clean, since it conforms to the existing coding style in dlmalloc.c, which is different to the rest of U-Boot.
Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
show more ...
|
| 3da52409 | 21-Jan-2016 |
Tom Rini <trini@konsulko.com> |
common/console.c: Remove unused inline functions
clang-3.8 reports that these functions are unused, remove them. As this is the last part of CONFIG_MODEM_SUPPORT_DEBUG, drop that from README.
Revi
common/console.c: Remove unused inline functions
clang-3.8 reports that these functions are unused, remove them. As this is the last part of CONFIG_MODEM_SUPPORT_DEBUG, drop that from README.
Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com>
show more ...
|
| e92029c0 | 20-Jan-2016 |
Clemens Gruber <clemens.gruber@pqgruber.com> |
env_mmc: support overriding mmc dev from board code
This enables boards to choose where to/from the environment should be saved/loaded. They can then for example support using the same device (dynam
env_mmc: support overriding mmc dev from board code
This enables boards to choose where to/from the environment should be saved/loaded. They can then for example support using the same device (dynamically) from which the bootloader was launched to load and save env data and do not have to define CONFIG_SYS_MMC_ENV_DEV statically.
In my use case, the environment needs to be on the same device I booted from. It can be the eMMC or an optional SD card. I therefore would override mmc_get_env_dev in the board code, read the CPU registers to determine where we booted from and return the corresponding device index.
Cc: Tom Rini <trini@konsulko.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Tim Harvey <tharvey@gateworks.com> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
show more ...
|
| 66280e82 | 22-Jan-2016 |
Simon Glass <sjg@chromium.org> |
gpio: Warn about invalid GPIOs used with the 'gpio' command
At present there is no indication that an invalid GPIO is used except that the GPIO status is not displayed. Make the error more explicit
gpio: Warn about invalid GPIOs used with the 'gpio' command
At present there is no indication that an invalid GPIO is used except that the GPIO status is not displayed. Make the error more explicit to avoid confusion.
Signed-off-by: Simon Glass <sjg@chromium.org>
show more ...
|
| e3b81c1c | 19-Jan-2016 |
Simon Glass <sjg@chromium.org> |
dm: stdio: video: Plumb the video uclass into stdio
Register video drivers with stdio so that they can be used for text output. This needs to be done explicitly for now. At some point we should be a
dm: stdio: video: Plumb the video uclass into stdio
Register video drivers with stdio so that they can be used for text output. This needs to be done explicitly for now. At some point we should be able to convert stdio itself to driver model and avoid this step.
Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de>
show more ...
|
| 5a541945 | 19-Jan-2016 |
Simon Glass <sjg@chromium.org> |
dm: common: Add memory reservation for the video uclass
Before relocation we need to reserve memory for the video driver frame buffers so that they can use this memory when they start up (after relo
dm: common: Add memory reservation for the video uclass
Before relocation we need to reserve memory for the video driver frame buffers so that they can use this memory when they start up (after relocation). Add a call to the uclass to permit this.
The current top and bottom of the region is stored in global_data so that it can be checked post-relocation to ensure enough memory is available. No video device should be probed before relocation.
Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de>
show more ...
|