Skip to content

Commit 9e28bf8

Browse files
author
Christoph Hellwig
committed
m68k: use the coherent DMA code for coldfire without data cache
Coldfire cores configured without a data cache are DMA coherent and should thus simply use the simple coherent version of dma-direct. Introduce a new COLDFIRE_COHERENT_DMA Kconfig symbol as a convenient short hand for such configurations, and a M68K_NONCOHERENT_DMA symbol for all cases where we need to build non-coherent DMA infrastructure to simplify the Kconfig and code conditionals. Not building the non-coherent DMA code slightly reduces the code size for such configurations. Numers for m5249evb_defconfig below: text data bss dec hex filename 2896158 401052 65392 3362602 334f2a vmlinux.before 2895166 400988 65392 3361546 334b0a vmlinux.after Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Ungerer <gerg@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Tested-by: Greg Ungerer <gerg@linux-m68k.org>
1 parent 63f067e commit 9e28bf8

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

arch/m68k/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ config M68K
66
select ARCH_HAS_BINFMT_FLAT
77
select ARCH_HAS_CPU_FINALIZE_INIT if MMU
88
select ARCH_HAS_CURRENT_STACK_POINTER
9-
select ARCH_HAS_DMA_ALLOC if !MMU || COLDFIRE
10-
select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE
11-
select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
9+
select ARCH_HAS_DMA_ALLOC if M68K_NONCOHERENT_DMA && COLDFIRE
10+
select ARCH_HAS_DMA_PREP_COHERENT if M68K_NONCOHERENT_DMA && !COLDFIRE
11+
select ARCH_HAS_SYNC_DMA_FOR_DEVICE if M68K_NONCOHERENT_DMA
1212
select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
1313
select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
1414
select ARCH_NO_PREEMPT if !COLDFIRE
1515
select ARCH_USE_MEMTEST if MMU_MOTOROLA
1616
select ARCH_WANT_IPC_PARSE_VERSION
1717
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
18-
select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE
18+
select DMA_DIRECT_REMAP if M68K_NONCOHERENT_DMA && !COLDFIRE
1919
select GENERIC_ATOMIC64
2020
select GENERIC_CPU_DEVICES
2121
select GENERIC_IOMAP

arch/m68k/Kconfig.cpu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,15 @@ config CACHE_COPYBACK
535535
The ColdFire CPU cache is set into Copy-back mode.
536536
endchoice
537537
endif # HAVE_CACHE_CB
538+
539+
# Coldfire cores that do not have a data cache configured can do coherent DMA.
540+
config COLDFIRE_COHERENT_DMA
541+
bool
542+
default y
543+
depends on COLDFIRE
544+
depends on !HAVE_CACHE_CB && !CACHE_D && !CACHE_BOTH
545+
546+
config M68K_NONCOHERENT_DMA
547+
bool
548+
default y
549+
depends on HAS_DMA && !COLDFIRE_COHERENT_DMA

arch/m68k/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
2323
obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
2424
obj-$(CONFIG_PCI) += pcibios.o
2525

26-
obj-$(CONFIG_HAS_DMA) += dma.o
26+
obj-$(CONFIG_M68K_NONCOHERENT_DMA) += dma.o
2727

2828
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
2929
obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o

arch/m68k/kernel/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <asm/cacheflush.h>
1919

20-
#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
20+
#ifndef CONFIG_COLDFIRE
2121
void arch_dma_prep_coherent(struct page *page, size_t size)
2222
{
2323
cache_push(page_to_phys(page), size);

0 commit comments

Comments
 (0)