Move the ARCH_DMA_MINALIGN definition to asm/cache.h
Subsystems (3)
cover Move the ARCH_DMA_MINALIGN definition to asm/cache.h
Hi,
The ARCH_KMALLOC_MINALIGN reduction series defines a generic ARCH_DMA_MINALIGN in linux/cache.h:
https://lore.kernel.org/r/[email protected]/
Unfortunately, this causes a duplicate definition warning for microblaze, powerpc (32-bit only) and sh as these architectures define ARCH_DMA_MINALIGN in a different file than asm/cache.h. Move the macro to asm/cache.h to avoid this issue and also bring them in line with the other architectures.
Andrew, if the arch maintainers cc'ed are fine with such change, could you please take these three patches together with the ARCH_KMALLOC_MINALIGN series?
Thank you.
Catalin Marinas (3):
powerpc: Move the ARCH_DMA_MINALIGN definition to asm/cache.h
microblaze: Move the ARCH_{DMA,SLAB}_MINALIGN definitions to
asm/cache.h
sh: Move the ARCH_DMA_MINALIGN definition to asm/cache.h
arch/microblaze/include/asm/cache.h | 5 +++++ arch/microblaze/include/asm/page.h | 5 ----- arch/powerpc/include/asm/cache.h | 4 ++++ arch/powerpc/include/asm/page_32.h | 4 ---- arch/sh/include/asm/cache.h | 6 ++++++ arch/sh/include/asm/page.h | 6 ------ 6 files changed, 15 insertions(+), 15 deletions(-)
PATCH 1/3 powerpc: Move the ARCH_DMA_MINALIGN definition to asm/cache.h
The powerpc architecture defines ARCH_DMA_MINALIGN in asm/page_32.h and only if CONFIG_NOT_COHERENT_CACHE is enabled (32-bit platforms only). Move this macro to asm/cache.h to allow a generic ARCH_DMA_MINALIGN definition in linux/cache.h without redefine errors/warnings.
--- arch/powerpc/include/asm/cache.h | 4 ++++ arch/powerpc/include/asm/page_32.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/cache.h +4 -0
@@ -33,6 +33,10 @@#define IFETCH_ALIGN_BYTES (1 << IFETCH_ALIGN_SHIFT) +#ifdef CONFIG_NOT_COHERENT_CACHE +#define ARCH_DMA_MINALIGN L1_CACHE_BYTES +#endif +#if !defined(__ASSEMBLY__)#ifdef CONFIG_PPC64
arch/powerpc/include/asm/page_32.h +0 -4
@@ -12,10 +12,6 @@#define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32 -#ifdef CONFIG_NOT_COHERENT_CACHE -#define ARCH_DMA_MINALIGN L1_CACHE_BYTES -#endif -#if defined(CONFIG_PPC_256K_PAGES ) || \ (defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES ))#define PTE_SHIFT (PAGE_SHIFT - PTE_T_LOG2 - 2)/* 1/4 of a page */
PATCH 2/3 microblaze: Move the ARCH_{DMA,SLAB}_MINALIGN definitions to asm/cache.h
In reply to Catalin MarinasThe microblaze architecture defines ARCH_DMA_MINALIGN in asm/page.h. Move it to asm/cache.h to allow a generic ARCH_DMA_MINALIGN definition in linux/cache.h without redefine errors/warnings.
While at it, also move ARCH_SLAB_MINALIGN to asm/cache.h for consistency.
--- arch/microblaze/include/asm/cache.h | 5 +++++ arch/microblaze/include/asm/page.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/microblaze/include/asm/cache.h +5 -0
@@ -18,4 +18,9 @@#define SMP_CACHE_BYTES L1_CACHE_BYTES +/* MS be sure that SLAB allocates aligned objects */ +#define ARCH_DMA_MINALIGN L1_CACHE_BYTES + +#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES +#endif /* _ASM_MICROBLAZE_CACHE_H */
arch/microblaze/include/asm/page.h +0 -5
@@ -30,11 +30,6 @@#ifndef __ASSEMBLY__ -/* MS be sure that SLAB allocates aligned objects */ -#define ARCH_DMA_MINALIGN L1_CACHE_BYTES - -#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES -/* * PAGE_OFFSET -- the first address of the first page of memory. With MMU * it is set to the kernel start address (aligned on a page boundary).
PATCH 3/3 sh: Move the ARCH_DMA_MINALIGN definition to asm/cache.h
In reply to Catalin MarinasThe sh architecture defines ARCH_DMA_MINALIGN in asm/page.h. Move it to asm/cache.h to allow a generic ARCH_DMA_MINALIGN definition in linux/cache.h without redefine errors/warnings.
--- arch/sh/include/asm/cache.h | 6 ++++++ arch/sh/include/asm/page.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)
arch/sh/include/asm/cache.h +6 -0
@@ -14,6 +14,12 @@#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) +/* +* Some drivers need to perform DMA into kmalloc'ed buffers +* and so we have to increase the kmalloc minalign for this. +*/ +#define ARCH_DMA_MINALIGN L1_CACHE_BYTES +#define __read_mostly __section(".data..read_mostly")#ifndef __ASSEMBLY__
arch/sh/include/asm/page.h +0 -6
@@ -174,10 +174,4 @@ typedef struct page *pgtable_t;#include <asm-generic/memory_model.h> #include <asm-generic/getorder.h> -/* -* Some drivers need to perform DMA into kmalloc'ed buffers -* and so we have to increase the kmalloc minalign for this. -*/ -#define ARCH_DMA_MINALIGN L1_CACHE_BYTES -#endif /* __ASM_SH_PAGE_H */
Le 13/06/2023 à 17:52, Catalin Marinas a écrit :
Quoted 5 lines
Hi,
The
ARCH_KMALLOC_MINALIGNreduction series defines a genericARCH_DMA_MINALIGNinlinux/cache.h:
Quoted 7 lines
https://lore.kernel.org/r/[email protected]/
Unfortunately, this causes a duplicate definition warning for microblaze, powerpc (32-bit only) and sh as these architectures define
ARCH_DMA_MINALIGNin a different file thanasm/cache.h. Move the macro toasm/cache.hto avoid this issue and also bring them in line with the other architectures.
What about mips ?
arch/mips/include/asm/mach-generic/kmalloc.h:#define ARCH_DMA_MINALIGN 128
arch/mips/include/asm/mach-ip32/kmalloc.h:#define ARCH_DMA_MINALIGN 32
arch/mips/include/asm/mach-ip32/kmalloc.h:#define ARCH_DMA_MINALIGN 128
arch/mips/include/asm/mach-n64/kmalloc.h:#define ARCH_DMA_MINALIGN L1_CACHE_BYTES arch/mips/include/asm/mach-tx49xx/kmalloc.h:#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
Quoted 21 lines
Andrew, if the arch maintainers cc'ed are fine with such change, could you please take these three patches together with the
ARCH_KMALLOC_MINALIGNseries?Thank you.
Catalin Marinas (3):
powerpc: Move theARCH_DMA_MINALIGNdefinition toasm/cache.h
microblaze: Move the ARCH_{DMA,SLAB}_MINALIGN definitions to
asm/cache.h
sh: Move theARCH_DMA_MINALIGNdefinition toasm/cache.harch/microblaze/include/asm/cache.h | 5 +++++ arch/microblaze/include/asm/page.h | 5 ----- arch/powerpc/include/asm/cache.h | 4 ++++ arch/powerpc/include/asm/page_32.h | 4 ---- arch/sh/include/asm/cache.h | 6 ++++++ arch/sh/include/asm/page.h | 6 ------ 6 files changed, 15 insertions(+), 15 deletions(-)
Quoted 16 lines · Christophe Leroy
Le 13/06/2023 à 17:52, Catalin Marinas a écrit :
Quoted 5 lines
Hi,
The
ARCH_KMALLOC_MINALIGNreduction series defines a genericARCH_DMA_MINALIGNinlinux/cache.h:Quoted 7 lines
https://lore.kernel.org/r/[email protected]/
Unfortunately, this causes a duplicate definition warning for microblaze, powerpc (32-bit only) and sh as these architectures define
ARCH_DMA_MINALIGNin a different file thanasm/cache.h. Move the macro toasm/cache.hto avoid this issue and also bring them in line with the other architectures.
Quoted 7 lines
What about mips ?
arch/mips/include/asm/mach-generic/kmalloc.h:#define
ARCH_DMA_MINALIGN128
arch/mips/include/asm/mach-ip32/kmalloc.h:#defineARCH_DMA_MINALIGN32
arch/mips/include/asm/mach-ip32/kmalloc.h:#defineARCH_DMA_MINALIGN128
arch/mips/include/asm/mach-n64/kmalloc.h:#defineARCH_DMA_MINALIGNL1_CACHE_BYTES
arch/mips/include/asm/mach-tx49xx/kmalloc.h:#defineARCH_DMA_MINALIGNL1_CACHE_BYTES
Sorry, I should have mentioned it in the cover letter (discussed here -
https://lore.kernel.org/r/ZIhPaixb%[email protected]/). These kmalloc.h files are included in asm/cache.h, based on which machine is enabled, so there's no problem for mips. It makes more sense to keep them in those mach-*/kmalloc.h files instead of having lots of #ifdefs in cache.h.
Signature · 1 line
Catalin