Move malloc_cache_aligned() to its own header
Subsystems (18)
PATCH v2 1/2 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.
---
Changes in v2: None
common/cmd_ubi.c | 2 +- drivers/mtd/nand/nand_util.c | 1 + fs/ubifs/super.c | 3 +++ fs/ubifs/ubifs.c | 2 ++ include/common.h | 9 --------- include/memalign.h | 25 +++++++++++++++++++++++++ lib/gzip.c | 1 + lib/zlib/zutil.c | 4 +++- 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 include/memalign.h
common/cmd_ubi.c +1 -1
@@ -14,7 +14,7 @@#include <common.h> #include <command.h> #include <exports.h> - +#include <memalign.h> #include <nand.h> #include <onenand_uboot.h> #include <linux/mtd/mtd.h>
drivers/mtd/nand/nand_util.c +1 -0
@@ -23,6 +23,7 @@#include <command.h> #include <watchdog.h> #include <malloc.h> +#include <memalign.h> #include <div64.h> #include <asm/errno.h>
fs/ubifs/super.c +3 -0
@@ -28,6 +28,9 @@#include <linux/writeback.h> #else +#include <common.h> +#include <malloc.h> +#include <memalign.h> #include <linux/compat.h> #include <linux/stat.h> #include <linux/err.h>
fs/ubifs/ubifs.c +2 -0
@@ -23,6 +23,8 @@* Adrian Hunter */ +#include <common.h> +#include <memalign.h> #include "ubifs.h" #include <u-boot/zlib.h>
include/common.h +0 -9
@@ -1060,15 +1060,6 @@ int cpu_release(int nr, int argc, char * const argv[]);#define DEFINE_CACHE_ALIGN_BUFFER (type, name, size) \ DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN) -#ifndef __ASSEMBLY__ -#include <malloc.h> - -static inline void *malloc_cache_aligned (size_t size) -{ -return memalign (ARCH_DMA_MINALIGN ,ALIGN (size,ARCH_DMA_MINALIGN )); -} -#endif -/* * check_member() - Check the offset of a structure member *
include/memalign.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __ALIGNMEM_H +#define __ALIGNMEM_H + +/* +* ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It +* is used to align DMA buffers. +*/ +#ifndef __ASSEMBLY__ +#include <asm/cache.h> + +#include <malloc.h> + +static inline void *malloc_cache_aligned (size_t size) +{ +return memalign (ARCH_DMA_MINALIGN ,ALIGN (size,ARCH_DMA_MINALIGN )); +} +#endif + +#endif /* __ALIGNMEM_H */
lib/gzip.c +1 -0
@@ -10,6 +10,7 @@#include <command.h> #include <image.h> #include <malloc.h> +#include <memalign.h> #include <u-boot/zlib.h> #include "zlib/zutil.h"
lib/zlib/zutil.c +3 -1
@@ -43,7 +43,9 @@ void z_error (m)*/ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ -#ifndef __UBOOT__ +#ifdef __UBOOT__ +#include <malloc.h> +#else #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size));
Signature · 1 line
2.5.0.457.gab17608
PATCH v2 2/2 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.
---
Changes in v2:
- Add a new patch to move ALLOC_CACHE_ALIGN_BUFFER() to the new header
board/raspberrypi/rpi/rpi.c | 1 + board/samsung/common/misc.c | 1 + common/cmd_usb.c | 1 + common/env_fat.c | 1 + common/env_mmc.c | 1 + common/env_nand.c | 1 + common/env_ubi.c | 1 + common/usb.c | 1 + common/usb_hub.c | 1 + common/usb_kbd.c | 1 + common/usb_storage.c | 1 + disk/part_dos.c | 1 + disk/part_efi.c | 1 + disk/part_mac.c | 1 + drivers/block/ahci.c | 1 + drivers/mmc/dw_mmc.c | 1 + drivers/mmc/mmc.c | 1 + drivers/mmc/rpmb.c | 1 + drivers/mtd/nand/tegra_nand.c | 1 + drivers/net/e1000.c | 1 + drivers/net/fec_mxc.c | 1 + drivers/net/rtl8169.c | 1 + drivers/spi/mxs_spi.c | 1 + drivers/usb/eth/asix.c | 1 + drivers/usb/eth/asix88179.c | 1 + drivers/usb/eth/mcs7830.c | 1 + drivers/usb/eth/smsc95xx.c | 1 + drivers/usb/gadget/ether.c | 1 + drivers/usb/gadget/f_thor.c | 1 + drivers/usb/host/dwc2.c | 1 + drivers/usb/host/ehci-hcd.c | 1 + drivers/usb/host/ohci-hcd.c | 1 + drivers/usb/host/usb-uclass.c | 1 + drivers/video/bcm2835.c | 1 + fs/ext4/dev.c | 1 + fs/ext4/ext4_common.c | 1 + fs/ext4/ext4_write.c | 1 + fs/fat/fat.c | 1 + include/common.h | 87 ---------------------------------------- include/memalign.h | 93 ++++++++++++++++++++++++++++++++++++++++++- 40 files changed, 130 insertions(+), 88 deletions(-)
board/raspberrypi/rpi/rpi.c +1 -0
@@ -10,6 +10,7 @@#include <fdt_support.h> #include <fdt_simplefb.h> #include <lcd.h> +#include <memalign.h> #include <mmc.h> #include <asm/gpio.h> #include <asm/arch/mbox.h>
board/samsung/common/misc.c +1 -0
@@ -12,6 +12,7 @@#include <errno.h> #include <version.h> #include <malloc.h> +#include <memalign.h> #include <linux/sizes.h> #include <asm/arch/cpu.h> #include <asm/gpio.h>
common/cmd_usb.c +1 -0
@@ -14,6 +14,7 @@#include <common.h> #include <command.h> #include <dm.h> +#include <memalign.h> #include <asm/byteorder.h> #include <asm/unaligned.h> #include <part.h>
common/env_fat.c +1 -0
@@ -13,6 +13,7 @@#include <environment.h> #include <linux/stddef.h> #include <malloc.h> +#include <memalign.h> #include <search.h> #include <errno.h> #include <fat.h>
common/env_mmc.c +1 -0
@@ -12,6 +12,7 @@#include <environment.h> #include <linux/stddef.h> #include <malloc.h> +#include <memalign.h> #include <mmc.h> #include <search.h> #include <errno.h>
common/env_nand.c +1 -0
@@ -19,6 +19,7 @@#include <environment.h> #include <linux/stddef.h> #include <malloc.h> +#include <memalign.h> #include <nand.h> #include <search.h> #include <errno.h>
common/env_ubi.c +1 -0
@@ -11,6 +11,7 @@#include <environment.h> #include <errno.h> #include <malloc.h> +#include <memalign.h> #include <search.h> #include <ubi_uboot.h> #undef crc32
common/usb.c +1 -0
@@ -29,6 +29,7 @@#include <common.h> #include <command.h> #include <dm.h> +#include <memalign.h> #include <asm/processor.h> #include <linux/compiler.h> #include <linux/ctype.h>
common/usb_hub.c +1 -0
@@ -26,6 +26,7 @@#include <command.h> #include <dm.h> #include <errno.h> +#include <memalign.h> #include <asm/processor.h> #include <asm/unaligned.h> #include <linux/ctype.h>
common/usb_kbd.c +1 -0
@@ -11,6 +11,7 @@#include <dm.h> #include <errno.h> #include <malloc.h> +#include <memalign.h> #include <stdio_dev.h> #include <asm/byteorder.h>
common/usb_storage.c +1 -0
@@ -39,6 +39,7 @@#include <errno.h> #include <inttypes.h> #include <mapmem.h> +#include <memalign.h> #include <asm/byteorder.h> #include <asm/processor.h> #include <dm/device-internal.h>
disk/part_dos.c +1 -0
@@ -17,6 +17,7 @@#include <common.h> #include <command.h> #include <ide.h> +#include <memalign.h> #include "part_dos.h" #ifdef HAVE_BLOCK_DEVICE
disk/part_efi.c +1 -0
@@ -16,6 +16,7 @@#include <ide.h> #include <inttypes.h> #include <malloc.h> +#include <memalign.h> #include <part_efi.h> #include <linux/ctype.h>
disk/part_mac.c +1 -0
@@ -15,6 +15,7 @@#include <common.h> #include <command.h> +#include <memalign.h> #include <ide.h> #include "part_mac.h"
drivers/block/ahci.c +1 -0
@@ -15,6 +15,7 @@#include <asm/errno.h> #include <asm/io.h> #include <malloc.h> +#include <memalign.h> #include <scsi.h> #include <libata.h> #include <linux/ctype.h>
drivers/mmc/dw_mmc.c +1 -0
@@ -10,6 +10,7 @@#include <common.h> #include <errno.h> #include <malloc.h> +#include <memalign.h> #include <mmc.h> #include <dwmmc.h> #include <asm-generic/errno.h>
drivers/mmc/mmc.c +1 -0
@@ -14,6 +14,7 @@#include <mmc.h> #include <part.h> #include <malloc.h> +#include <memalign.h> #include <linux/list.h> #include <div64.h> #include "mmc_private.h"
drivers/mmc/rpmb.c +1 -0
@@ -10,6 +10,7 @@#include <config.h> #include <common.h> +#include <memalign.h> #include <mmc.h> #include <u-boot/sha256.h> #include "mmc_private.h"
drivers/mtd/nand/tegra_nand.c +1 -0
@@ -9,6 +9,7 @@#include <common.h> #include <asm/io.h> +#include <memalign.h> #include <nand.h> #include <asm/arch/clock.h> #include <asm/arch/funcmux.h>
drivers/net/e1000.c +1 -0
@@ -32,6 +32,7 @@ tested on both gig copper and gig fiber boards#include <common.h> #include <dm.h> #include <errno.h> +#include <memalign.h> #include <pci.h> #include "e1000.h"
drivers/net/fec_mxc.c +1 -0
@@ -10,6 +10,7 @@#include <common.h> #include <malloc.h> +#include <memalign.h> #include <net.h> #include <netdev.h> #include <miiphy.h>
drivers/net/rtl8169.c +1 -0
@@ -44,6 +44,7 @@#include <dm.h> #include <errno.h> #include <malloc.h> +#include <memalign.h> #include <net.h> #ifndef CONFIG_DM_ETH #include <netdev.h>
drivers/spi/mxs_spi.c +1 -0
@@ -12,6 +12,7 @@#include <common.h> #include <malloc.h> +#include <memalign.h> #include <spi.h> #include <asm/errno.h> #include <asm/io.h>
drivers/usb/eth/asix.c +1 -0
@@ -10,6 +10,7 @@#include <dm.h> #include <usb.h> #include <malloc.h> +#include <memalign.h> #include <linux/mii.h> #include "usb_ether.h"
drivers/usb/eth/asix88179.c +1 -0
@@ -12,6 +12,7 @@#include <linux/mii.h> #include "usb_ether.h" #include <malloc.h> +#include <memalign.h> #include <errno.h> /* ASIX AX88179 based USB 3.0 Ethernet Devices */
drivers/usb/eth/mcs7830.c +1 -0
@@ -14,6 +14,7 @@#include <errno.h> #include <linux/mii.h> #include <malloc.h> +#include <memalign.h> #include <usb.h> #include "usb_ether.h"
drivers/usb/eth/smsc95xx.c +1 -0
@@ -11,6 +11,7 @@#include <dm.h> #include <errno.h> #include <malloc.h> +#include <memalign.h> #include <usb.h> #include <asm/unaligned.h> #include <linux/mii.h>
drivers/usb/gadget/ether.c +1 -0
@@ -17,6 +17,7 @@#include <net.h> #include <usb.h> #include <malloc.h> +#include <memalign.h> #include <linux/ctype.h> #include "gadget_chips.h"
drivers/usb/gadget/f_thor.c +1 -0
@@ -18,6 +18,7 @@#include <errno.h> #include <common.h> #include <malloc.h> +#include <memalign.h> #include <version.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
drivers/usb/host/dwc2.c +1 -0
@@ -10,6 +10,7 @@#include <errno.h> #include <usb.h> #include <malloc.h> +#include <memalign.h> #include <phys2bus.h> #include <usbroothubdes.h> #include <asm/io.h>
drivers/usb/host/ehci-hcd.c +1 -0
@@ -15,6 +15,7 @@#include <usb.h> #include <asm/io.h> #include <malloc.h> +#include <memalign.h> #include <watchdog.h> #include <linux/compiler.h>
drivers/usb/host/ohci-hcd.c +1 -0
@@ -41,6 +41,7 @@#endif #include <malloc.h> +#include <memalign.h> #include <usb.h> #include "ohci.h"
drivers/usb/host/usb-uclass.c +1 -0
@@ -10,6 +10,7 @@#include <common.h> #include <dm.h> #include <errno.h> +#include <memalign.h> #include <usb.h> #include <dm/device-internal.h> #include <dm/lists.h>
drivers/video/bcm2835.c +1 -0
@@ -6,6 +6,7 @@#include <common.h> #include <lcd.h> +#include <memalign.h> #include <asm/arch/mbox.h> #include <asm/global_data.h>
fs/ext4/dev.c +1 -0
@@ -25,6 +25,7 @@#include <common.h> #include <config.h> +#include <memalign.h> #include <ext4fs.h> #include <ext_common.h> #include "ext4_common.h"
fs/ext4/ext4_common.c +1 -0
@@ -24,6 +24,7 @@#include <ext4fs.h> #include <inttypes.h> #include <malloc.h> +#include <memalign.h> #include <stddef.h> #include <linux/stat.h> #include <linux/time.h>
fs/ext4/ext4_write.c +1 -0
@@ -23,6 +23,7 @@#include <common.h> +#include <memalign.h> #include <linux/stat.h> #include <div64.h> #include "ext4_common.h"
fs/fat/fat.c +1 -0
@@ -16,6 +16,7 @@#include <asm/byteorder.h> #include <part.h> #include <malloc.h> +#include <memalign.h> #include <linux/compiler.h> #include <linux/ctype.h>
include/common.h +0 -87
93 lines not on this page · raw message
include/memalign.h +92 -1
101 lines not on this page · raw message
Signature · 1 line
2.5.0.457.gab17608
PATCH v2 2/2 Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h header
Quoted 4 lines · Simon Glass
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 <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/0dfc1318/attachment.sig>
PATCH v2 1/2 Move malloc_cache_aligned() to its own header
In reply to Simon GlassQuoted 19 lines · Simon Glass
At present
malloc.his included everywhere since it recently was added tocommon.hin this commit:4519668 mtd/nand/ubi: assortment of alignment fixes
This seems wasteful and unnecessary. We have been trying to trim down
common.hand 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 asalignmem.hbut it needs to be
included aftercommon.hand people might be confused by this. With the namememalign.hit fits nicely aftermalloc()in most cases.
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>
The series successfully NAND boot tested on Colibri T20 512MB V1.2A therefore
PATCH v2 1/2 Move malloc_cache_aligned() to its own header
In reply to Simon GlassQuoted 9 lines · Simon Glass
At present
malloc.his included everywhere since it recently was added tocommon.hin this commit:4519668 mtd/nand/ubi: assortment of alignment fixes
This seems wasteful and unnecessary. We have been trying to trim down
common.hand put separate functions into separate header files and that change goes in the opposite direction.
Quoted 7 lines
Move
malloc_cache_aligned()to a new header so that this can be avoided. The header would perhaps be better named asalignmem.hbut it needs to be included aftercommon.hand people might be confused by this. With the namememalign.hit fits nicely aftermalloc()in most cases.Signed-off-by Simon Glass <[email protected]>Acked-by Marcel Ziswiler <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/c5191218/attachment.sig>