ioremap and dma cleanups and fixes for superh (resend)
Subsystems (6)
Hi Yoshinori and Rich,
can you take a look and possibly pick up the series below that untangles and sorts out minor issues with the sh ioremap and dma code?
PATCH 1/10 sh: remove -Werror from Makefiles
The sh build is full of warnings when building with gcc 9.2.1. While fixing those would be great, at least avoid failing the build.
--- arch/sh/kernel/Makefile | 2 -- arch/sh/lib/Makefile | 2 -- arch/sh/mm/Makefile | 2 -- 3 files changed, 6 deletions(-)
arch/sh/kernel/Makefile +0 -2
@@ -47,5 +47,3 @@ obj-$(CONFIG_DWARF_UNWINDER) += dwarf.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_callchain.o obj-$(CONFIG_DMA_NONCOHERENT) += dma-coherent.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o - -ccflags-y := -Werror
arch/sh/lib/Makefile +0 -2
@@ -30,5 +30,3 @@ memset-$(CONFIG_CPU_SH4) := memset-sh4.o lib-$(CONFIG_MMU) += copy_page.o __clear_user.o lib-$(CONFIG_MCOUNT) += mcount.o lib-y += $(memcpy-y) $(memset-y) $(udivsi3-y) - -ccflags-y := -Werror
arch/sh/mm/Makefile +0 -2
@@ -43,5 +43,3 @@ obj-$(CONFIG_UNCACHED_MAPPING) += uncached.o obj-$(CONFIG_HAVE_SRAM_POOL) += sram.o GCOV_PROFILE_pmb.o := n - -ccflags-y := -Werror
Signature · 1 line
2.26.2
PATCH 2/10 sh: sort the selects for SUPERH alphabetically
In reply to Christoph HellwigEnsure there is an order for the selects. Also remove a duplicate one.
--- arch/sh/Kconfig | 95 ++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 48 deletions(-)
arch/sh/Kconfig +47 -48
@@ -1,75 +1,74 @@ # SPDX-License-Identifier: GPL-2.0 config SUPERH def_bool y + select ARCH_32BIT_OFF_T + select ARCH_HAVE_CUSTOM_GPIO_H + select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) select ARCH_HAS_BINFMT_FLAT if !MMU + select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST + select ARCH_HIBERNATION_POSSIBLE if MMU select ARCH_MIGHT_HAVE_PC_PARPORT - select HAVE_PATA_PLATFORM + select ARCH_WANT_IPC_PARSE_VERSION select CLKDEV_LOOKUP + select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT - select HAVE_IDE if HAS_IOPORT_MAP - select HAVE_OPROFILE + select GENERIC_ATOMIC64 + select GENERIC_CLOCKEVENTS + select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST + select GENERIC_IDLE_POLL_SETUP + select GENERIC_IRQ_SHOW + select GENERIC_PCI_IOMAP if PCI + select GENERIC_SCHED_CLOCK + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER + select GENERIC_SMP_IDLE_THREAD + select GUP_GET_PTE_LOW_HIGH if X2TLB + select HAVE_ARCH_AUDITSYSCALL + select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK - select HAVE_PERF_EVENTS select HAVE_DEBUG_BUGVERBOSE - select HAVE_FAST_GUP if MMU - select ARCH_HAVE_CUSTOM_GPIO_H - select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) - select ARCH_HAS_GCOV_PROFILE_ALL - select PERF_USE_VMALLOC select HAVE_DEBUG_KMEMLEAK - select HAVE_KERNEL_GZIP - select CPU_NO_EFFICIENT_FFS + select HAVE_DYNAMIC_FTRACE + select HAVE_FAST_GUP if MMU + select HAVE_FUNCTION_GRAPH_TRACER + select HAVE_FUNCTION_TRACER + select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_FTRACE_MCOUNT_RECORD + select HAVE_HW_BREAKPOINT + select HAVE_IDE if HAS_IOPORT_MAP + select HAVE_IOREMAP_PROT if MMU && !X2TLB select HAVE_KERNEL_BZIP2 + select HAVE_KERNEL_GZIP select HAVE_KERNEL_LZMA - select HAVE_KERNEL_XZ select HAVE_KERNEL_LZO + select HAVE_KERNEL_XZ + select HAVE_KPROBES + select HAVE_KRETPROBES + select HAVE_MIXED_BREAKPOINTS_REGS + select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER + select HAVE_NMI + select HAVE_OPROFILE + select HAVE_PATA_PLATFORM + select HAVE_PERF_EVENTS + select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_UID16 - select ARCH_WANT_IPC_PARSE_VERSION + select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS - select HAVE_REGS_AND_STACK_ACCESS_API - select MAY_HAVE_SPARSE_IRQ select IRQ_FORCED_THREADING - select RTC_LIB - select GENERIC_ATOMIC64 - select GENERIC_IRQ_SHOW - select GENERIC_SMP_IDLE_THREAD - select GENERIC_IDLE_POLL_SETUP - select GENERIC_CLOCKEVENTS - select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST - select GENERIC_PCI_IOMAP if PCI - select GENERIC_SCHED_CLOCK - select GENERIC_STRNCPY_FROM_USER - select GENERIC_STRNLEN_USER - select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER + select MAY_HAVE_SPARSE_IRQ select MODULES_USE_ELF_RELA + select NEED_SG_DMA_LENGTH select NO_GENERIC_PCI_IOPORT_MAP if PCI - select OLD_SIGSUSPEND select OLD_SIGACTION + select OLD_SIGSUSPEND select PCI_DOMAINS if PCI - select HAVE_ARCH_AUDITSYSCALL - select HAVE_FUTEX_CMPXCHG if FUTEX - select HAVE_NMI - select NEED_SG_DMA_LENGTH - select ARCH_HAS_GIGANTIC_PAGE - select ARCH_32BIT_OFF_T - select GUP_GET_PTE_LOW_HIGH if X2TLB - select HAVE_KPROBES - select HAVE_KRETPROBES - select HAVE_IOREMAP_PROT if MMU && !X2TLB - select HAVE_FUNCTION_TRACER - select HAVE_FTRACE_MCOUNT_RECORD - select HAVE_DYNAMIC_FTRACE - select ARCH_WANT_IPC_PARSE_VERSION - select HAVE_FUNCTION_GRAPH_TRACER - select HAVE_ARCH_KGDB - select HAVE_HW_BREAKPOINT - select HAVE_MIXED_BREAKPOINTS_REGS select PERF_EVENTS - select ARCH_HIBERNATION_POSSIBLE if MMU + select PERF_USE_VMALLOC + select RTC_LIB select SPARSE_IRQ - select HAVE_STACKPROTECTOR help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast
Signature · 1 line
2.26.2
PATCH 3/10 sh: remove __KERNEL__ ifdefs from non-UAPI headers
In reply to Christoph HellwigThere is no point in having __KERNEL__ ifdefs in headers not exported to userspace.
--- arch/sh/include/asm/adc.h | 2 -- arch/sh/include/asm/addrspace.h | 3 --- arch/sh/include/asm/bitops.h | 4 ---- arch/sh/include/asm/cache.h | 2 -- arch/sh/include/asm/cacheflush.h | 3 --- arch/sh/include/asm/dma.h | 2 -- arch/sh/include/asm/elf.h | 2 -- arch/sh/include/asm/freq.h | 2 -- arch/sh/include/asm/futex.h | 3 --- arch/sh/include/asm/io.h | 3 --- arch/sh/include/asm/mmu_context.h | 2 -- arch/sh/include/asm/mmzone.h | 3 --- arch/sh/include/asm/pci.h | 4 ---- arch/sh/include/asm/processor_32.h | 2 -- arch/sh/include/asm/sparsemem.h | 3 --- arch/sh/include/asm/string_32.h | 4 ---- arch/sh/include/asm/syscalls_32.h | 3 --- arch/sh/include/asm/thread_info.h | 5 ----- arch/sh/include/asm/watchdog.h | 2 -- 19 files changed, 54 deletions(-)
arch/sh/include/asm/adc.h +0 -2
@@ -1,7 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __ASM_ADC_H#define __ASM_ADC_H -#ifdef __KERNEL__/* * Copyright (C) 2004 Andriy Skulysh */
@@ -10,5 +9,4 @@int adc_single (unsigned int channel); -#endif /* __KERNEL__ */ #endif /* __ASM_ADC_H */
arch/sh/include/asm/addrspace.h +0 -3
@@ -7,8 +7,6 @@#ifndef __ASM_SH_ADDRSPACE_H#define __ASM_SH_ADDRSPACE_H -#ifdef __KERNEL__ -#include <cpu/addrspace.h> /* If this CPU supports segmentation, hook up the helpers */
@@ -62,5 +60,4 @@#define P3_ADDR_MAX P4SEG#endif -#endif /* __KERNEL__ */ #endif /* __ASM_SH_ADDRSPACE_H */
arch/sh/include/asm/bitops.h +0 -4
@@ -2,8 +2,6 @@#ifndef __ASM_SH_BITOPS_H#define __ASM_SH_BITOPS_H -#ifdef __KERNEL__ -#ifndef _LINUX_BITOPS_H#error only <linux/bitops.h> can be included directly#endif
@@ -71,6 +69,4 @@ static inline unsigned long __ffs(unsigned long word)#include <asm-generic/bitops/__fls.h> #include <asm-generic/bitops/fls64.h> -#endif /* __KERNEL__ */ -#endif /* __ASM_SH_BITOPS_H */
arch/sh/include/asm/cache.h +0 -2
@@ -8,7 +8,6 @@*/ #ifndef __ASM_SH_CACHE_H#define __ASM_SH_CACHE_H -#ifdef __KERNEL__#include <linux/init.h> #include <cpu/cache.h>
@@ -44,5 +43,4 @@ struct cache_info {unsigned long flags; };#endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ #endif /* __ASM_SH_CACHE_H */
arch/sh/include/asm/cacheflush.h +0 -3
@@ -2,8 +2,6 @@#ifndef __ASM_SH_CACHEFLUSH_H#define __ASM_SH_CACHEFLUSH_H -#ifdef __KERNEL__ -#include <linux/mm.h> /*
@@ -109,5 +107,4 @@ static inline void *sh_cacheop_vaddr(void *vaddr) return vaddr; } -#endif /* __KERNEL__ */ #endif /* __ASM_SH_CACHEFLUSH_H */
arch/sh/include/asm/dma.h +0 -2
@@ -6,7 +6,6 @@*/ #ifndef __ASM_SH_DMA_H#define __ASM_SH_DMA_H -#ifdef __KERNEL__#include <linux/spinlock.h> #include <linux/wait.h>
@@ -144,5 +143,4 @@ extern int isa_dma_bridge_buggy;#define isa_dma_bridge_buggy (0)#endif -#endif /* __KERNEL__ */ #endif /* __ASM_SH_DMA_H */
arch/sh/include/asm/elf.h +0 -2
@@ -90,7 +90,6 @@ typedef struct user_fpu_struct elf_fpregset_t;#endif #define ELF_ARCH EM_SH -#ifdef __KERNEL__/* * This is used to ensure we don't load something for the wrong architecture. */
@@ -209,5 +208,4 @@ do { \NEW_AUX_ENT (AT_L2_CACHESHAPE , l2_cache_shape); \ } while (0) -#endif /* __KERNEL__ */ #endif /* __ASM_SH_ELF_H */
arch/sh/include/asm/freq.h +0 -2
@@ -6,9 +6,7 @@*/ #ifndef __ASM_SH_FREQ_H#define __ASM_SH_FREQ_H -#ifdef __KERNEL__#include <cpu/freq.h> -#endif /* __KERNEL__ */ #endif /* __ASM_SH_FREQ_H */
arch/sh/include/asm/futex.h +0 -3
@@ -2,8 +2,6 @@#ifndef __ASM_SH_FUTEX_H#define __ASM_SH_FUTEX_H -#ifdef __KERNEL__ -#include <linux/futex.h> #include <linux/uaccess.h> #include <asm/errno.h>
@@ -71,5 +69,4 @@ static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, return ret; } -#endif /* __KERNEL__ */ #endif /* __ASM_SH_FUTEX_H */
arch/sh/include/asm/io.h +0 -3
@@ -20,7 +20,6 @@#include <linux/pgtable.h> #include <asm-generic/iomap.h> -#ifdef __KERNEL__#define __IO_PREFIX generic#include <asm/io_generic.h> #include <asm/io_trapped.h>
@@ -380,6 +379,4 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }int valid_phys_addr_range (phys_addr_t addr,size_t size);int valid_mmap_phys_addr_range (unsigned long pfn,size_t size); -#endif /* __KERNEL__ */ -#endif /* __ASM_SH_IO_H */
arch/sh/include/asm/mmu_context.h +0 -2
@@ -8,7 +8,6 @@#ifndef __ASM_SH_MMU_CONTEXT_H#define __ASM_SH_MMU_CONTEXT_H -#ifdef __KERNEL__#include <cpu/mmu_context.h> #include <asm/tlbflush.h> #include <linux/uaccess.h>
@@ -177,5 +176,4 @@ static inline void disable_mmu(void)#define disable_mmu () do { } while (0)#endif -#endif /* __KERNEL__ */ #endif /* __ASM_SH_MMU_CONTEXT_H */
arch/sh/include/asm/mmzone.h +0 -3
@@ -2,8 +2,6 @@#ifndef __ASM_SH_MMZONE_H#define __ASM_SH_MMZONE_H -#ifdef __KERNEL__ -#ifdef CONFIG_NEED_MULTIPLE_NODES #include <linux/numa.h>
@@ -44,5 +42,4 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,/* arch/sh/mm/init.c */ void __init allocate_pgdat (unsigned int nid); -#endif /* __KERNEL__ */ #endif /* __ASM_SH_MMZONE_H */
arch/sh/include/asm/pci.h +0 -4
@@ -2,8 +2,6 @@#ifndef __ASM_SH_PCI_H#define __ASM_SH_PCI_H -#ifdef __KERNEL__ -/* Can be used to override the logic in pci_scan_bus for skipping already-configured bus numbers - to be used for buggy BIOSes or architectures with incomplete PCI setup by the loader */
@@ -96,6 +94,4 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) return channel ? 15 : 14; } -#endif /* __KERNEL__ */ #endif /* __ASM_SH_PCI_H */ -
arch/sh/include/asm/processor_32.h +0 -2
@@ -8,7 +8,6 @@#ifndef __ASM_SH_PROCESSOR_32_H#define __ASM_SH_PROCESSOR_32_H -#ifdef __KERNEL__#include <linux/compiler.h> #include <linux/linkage.h>
@@ -203,5 +202,4 @@ static inline void prefetchw(const void *x) }#endif -#endif /* __KERNEL__ */ #endif /* __ASM_SH_PROCESSOR_32_H */
arch/sh/include/asm/sparsemem.h +0 -3
@@ -2,7 +2,6 @@#ifndef __ASM_SH_SPARSEMEM_H#define __ASM_SH_SPARSEMEM_H -#ifdef __KERNEL__/* * SECTION_SIZE_BITS 2^N: how big each section will be * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
@@ -12,6 +11,4 @@#define MAX_PHYSADDR_BITS 32#define MAX_PHYSMEM_BITS 32 -#endif -#endif /* __ASM_SH_SPARSEMEM_H */
arch/sh/include/asm/string_32.h +0 -4
@@ -2,8 +2,6 @@#ifndef __ASM_SH_STRING_H#define __ASM_SH_STRING_H -#ifdef __KERNEL__ -/* * Copyright (C) 1999 Niibe Yutaka * But consider these trivial functions to be public domain.
@@ -127,6 +125,4 @@ extern void *memchr(const void *__s, int __c, size_t __n);#define __HAVE_ARCH_STRLENextern size_t strlen (const char *); -#endif /* __KERNEL__ */ -#endif /* __ASM_SH_STRING_H */
arch/sh/include/asm/syscalls_32.h +0 -3
@@ -2,8 +2,6 @@#ifndef __ASM_SH_SYSCALLS_32_H#define __ASM_SH_SYSCALLS_32_H -#ifdef __KERNEL__ -#include <linux/compiler.h> #include <linux/linkage.h> #include <linux/types.h>
@@ -26,5 +24,4 @@ asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,unsigned long thread_info_flags); -#endif /* __KERNEL__ */ #endif /* __ASM_SH_SYSCALLS_32_H */
arch/sh/include/asm/thread_info.h +0 -5
@@ -10,8 +10,6 @@* Copyright (C) 2002 David Howells ([email protected]) * - Incorporating suggestions made by Linus Torvalds and Dave Miller */ -#ifdef __KERNEL__ -#include <asm/page.h> /*
@@ -170,7 +168,4 @@ static inline unsigned int get_thread_fault_code(void) }#endif /* !__ASSEMBLY__ */ - -#endif /* __KERNEL__ */ -#endif /* __ASM_SH_THREAD_INFO_H */
arch/sh/include/asm/watchdog.h +0 -2
@@ -8,7 +8,6 @@*/ #ifndef __ASM_SH_WATCHDOG_H#define __ASM_SH_WATCHDOG_H -#ifdef __KERNEL__#include <linux/types.h> #include <linux/io.h>
@@ -157,5 +156,4 @@ static inline void sh_wdt_write_csr(__u8 val)__raw_writew ((WTCSR_HIGH <<8 ) | (__u16 )val,WTCSR ); }#endif /* CONFIG_CPU_SUBTYPE_SH7785 || CONFIG_CPU_SUBTYPE_SH7780 */ -#endif /* __KERNEL__ */ #endif /* __ASM_SH_WATCHDOG_H */
Signature · 1 line
2.26.2
PATCH 4/10 sh: move ioremap_fixed details out of <asm/io.h>
In reply to Christoph Hellwigioremap_fixed is an internal implementation detail and should not be exposed to drivers.
--- arch/sh/include/asm/io.h | 16 ---------------- arch/sh/mm/init.c | 1 + arch/sh/mm/ioremap.c | 1 + arch/sh/mm/ioremap.h | 23 +++++++++++++++++++++++ arch/sh/mm/ioremap_fixed.c | 1 + 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 arch/sh/mm/ioremap.h
arch/sh/include/asm/io.h +0 -16
@@ -346,22 +346,6 @@ ioremap_prot(phys_addr_t offset, unsigned long size, unsigned long flags) }#endif -#ifdef CONFIG_IOREMAP_FIXED -extern void __iomem *ioremap_fixed (phys_addr_t ,unsigned long ,pgprot_t ); -extern int iounmap_fixed (void __iomem *); -extern void ioremap_fixed_init (void ); -#else -static inline void __iomem * -ioremap_fixed (phys_addr_t phys_addr,unsigned long size,pgprot_t prot) -{ -BUG (); -return NULL ; -} - -static inline void ioremap_fixed_init (void ) { } -static inline int iounmap_fixed (void __iomem *addr) {return -EINVAL ; } -#endif -#define ioremap_uc ioremap/*
arch/sh/mm/init.c +1 -0
@@ -28,6 +28,7 @@#include <asm/setup.h> #include <asm/cache.h> #include <linux/sizes.h> +#include "ioremap.h" pgd_t swapper_pg_dir[PTRS_PER_PGD ];
arch/sh/mm/ioremap.c +1 -0
@@ -24,6 +24,7 @@#include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <asm/mmu.h> +#include "ioremap.h" /* * Remap an arbitrary physical address space into the kernel virtual
arch/sh/mm/ioremap.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _SH_MM_IORMEMAP_H +#define _SH_MM_IORMEMAP_H 1 + +#ifdef CONFIG_IOREMAP_FIXED +void __iomem *ioremap_fixed (phys_addr_t ,unsigned long ,pgprot_t ); +int iounmap_fixed (void __iomem *); +void ioremap_fixed_init (void ); +#else +static inline void __iomem * +ioremap_fixed (phys_addr_t phys_addr,unsigned long size,pgprot_t prot) +{ +BUG (); +return NULL ; +} +static inline void ioremap_fixed_init (void ) +{ +} +static inline int iounmap_fixed (void __iomem *addr) +{ +return -EINVAL ; +} +#endif /* CONFIG_IOREMAP_FIXED */ +#endif /* _SH_MM_IORMEMAP_H */
arch/sh/mm/ioremap_fixed.c +1 -0
@@ -24,6 +24,7 @@#include <asm/tlbflush.h> #include <asm/mmu.h> #include <asm/mmu_context.h> +#include "ioremap.h" struct ioremap_map {void __iomem *addr;
Signature · 1 line
2.26.2
PATCH 5/10 sh: move the ioremap implementation out of line
In reply to Christoph HellwigMove the internal implementation details of ioremap out of line, no need to expose any of this to drivers for a slow path API.
--- arch/sh/include/asm/io.h | 101 ++++++--------------------------------- arch/sh/mm/ioremap.c | 53 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 86 deletions(-)
arch/sh/include/asm/io.h +15 -86
@@ -242,109 +242,38 @@ unsigned long long poke_real_address_q(unsigned long long addr,#define phys_to_virt (address) (__va(address))#endif -/* -* On 32-bit SH, we traditionally have the whole physical address space -* mapped at all times (as MIPS does), so "ioremap()" and "iounmap()" do -* not need to do anything but place the address in the proper segment. -* This is true for P1 and P2 addresses, as well as some P3 ones. -* However, most of the P3 addresses and newer cores using extended -* addressing need to map through page tables, so the ioremap() -* implementation becomes a bit more complicated. -* -* See arch/sh/mm/ioremap.c for additional notes on this. -* -* We cheat a bit and always return uncachable areas until we've fixed -* the drivers to handle caching properly. -* -* On the SH-5 the concept of segmentation in the 1:1 PXSEG sense simply -* doesn't exist, so everything must go through page tables. -*/ #ifdef CONFIG_MMU +void iounmap (void __iomem *addr);void __iomem *__ioremap_caller (phys_addr_t offset,unsigned long size,pgprot_t prot,void *caller); -void iounmap (void __iomem *addr); - -static inline void __iomem * -__ioremap (phys_addr_t offset,unsigned long size,pgprot_t prot) -{ -return __ioremap_caller (offset, size, prot,__builtin_return_address (0 )); -} - -static inline void __iomem * -__ioremap_29bit (phys_addr_t offset,unsigned long size,pgprot_t prot) -{ -#ifdef CONFIG_29BIT -phys_addr_t last_addr = offset + size -1 ; - -/* -* For P1 and P2 space this is trivial, as everything is already -* mapped. Uncached access for P1 addresses are done through P2. -* In the P3 case or for addresses outside of the 29-bit space, -* mapping must be done by the PMB or by using page tables. -*/ -if (likely (PXSEG (offset) <P3SEG &&PXSEG (last_addr) <P3SEG )) { -u64 flags =pgprot_val (prot); - -/* -* Anything using the legacy PTEA space attributes needs -* to be kicked down to page table mappings. -*/ -if (unlikely (flags & _PAGE_PCC_MASK)) -return NULL ; -if (unlikely (flags & _PAGE_CACHABLE)) -return (void __iomem *)P1SEGADDR (offset); - -return (void __iomem *)P2SEGADDR (offset); - } - -/* P4 above the store queues are always mapped. */ -if (unlikely (offset >=P3_ADDR_MAX )) -return (void __iomem *)P4SEGADDR (offset); -#endif - -return NULL ; -} - -static inline void __iomem * -__ioremap_mode (phys_addr_t offset,unsigned long size,pgprot_t prot) -{ -void __iomem *ret; - - ret =__ioremap_trapped (offset, size); -if (ret) -return ret; - - ret =__ioremap_29bit (offset, size, prot); -if (ret) -return ret; - -return __ioremap (offset, size, prot); -} -#else -#define __ioremap (offset, size, prot) ((void __iomem *)(offset)) -#define __ioremap_mode (offset, size, prot) ((void __iomem *)(offset)) -static inline void iounmap (void __iomem *addr) {} -#endif /* CONFIG_MMU */ static inline void __iomem *ioremap (phys_addr_t offset,unsigned long size) { -return __ioremap_mode (offset, size,PAGE_KERNEL_NOCACHE ); +return __ioremap_caller (offset, size,PAGE_KERNEL_NOCACHE , +__builtin_return_address (0 )); }static inline void __iomem *ioremap_cache (phys_addr_t offset,unsigned long size) { -return __ioremap_mode (offset, size,PAGE_KERNEL ); +return __ioremap_caller (offset, size,PAGE_KERNEL , +__builtin_return_address (0 )); }#define ioremap_cache ioremap_cache#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem * -ioremap_prot (phys_addr_t offset,unsigned long size,unsigned long flags) +static inline void __iomem *ioremap_prot (phys_addr_t offset,unsigned long size, +unsigned long flags) { -return __ioremap_mode (offset, size,__pgprot (flags)); +return __ioremap_caller (offset, size,__pgprot (flags), +__builtin_return_address (0 )); } -#endif +#endif /* CONFIG_HAVE_IOREMAP_PROT */ + +#else /* CONFIG_MMU */ +#define iounmap (addr) do { } while (0) +#define ioremap (offset, size) ((void __iomem *)(unsigned long)(offset)) +#endif /* CONFIG_MMU */ #define ioremap_uc ioremap
arch/sh/mm/ioremap.c +53 -0
65 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 6/10 sh: don't include <asm/io_trapped.h> in <asm/io.h>
In reply to Christoph HellwigNo need to expose the details of trapped I/O to drivers.
--- arch/sh/include/asm/io.h | 1 - arch/sh/kernel/ioport.c | 1 + arch/sh/mm/ioremap.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-)
arch/sh/include/asm/io.h +0 -1
@@ -22,7 +22,6 @@#define __IO_PREFIX generic#include <asm/io_generic.h> -#include <asm/io_trapped.h> #include <asm-generic/pci_iomap.h> #include <mach/mangle-port.h>
arch/sh/kernel/ioport.c +1 -0
@@ -7,6 +7,7 @@*/ #include <linux/module.h> #include <linux/io.h> +#include <asm/io_trapped.h> unsigned long sh_io_port_base__read_mostly =-1 ;EXPORT_SYMBOL (sh_io_port_base);
arch/sh/mm/ioremap.c +1 -0
@@ -18,6 +18,7 @@#include <linux/mm.h> #include <linux/pci.h> #include <linux/io.h> +#include <asm/io_trapped.h> #include <asm/page.h> #include <asm/pgalloc.h> #include <asm/addrspace.h>
Signature · 1 line
2.26.2
PATCH 7/10 sh: unexport register_trapped_io and match_trapped_io_handler
In reply to Christoph HellwigBoth functions are only used by compiled in core code.
--- arch/sh/kernel/io_trapped.c | 2 -- 1 file changed, 2 deletions(-)
arch/sh/kernel/io_trapped.c +0 -2
@@ -102,7 +102,6 @@ int register_trapped_io(struct trapped_io *tiop)pr_warn ("unable to install trapped io filter\n" );return -1 ; } -EXPORT_SYMBOL_GPL (register_trapped_io); void __iomem *match_trapped_io_handler(struct list_head *list, unsigned long offset,
@@ -131,7 +130,6 @@ void __iomem *match_trapped_io_handler(struct list_head *list,spin_unlock_irqrestore (&trapped_lock, flags);return NULL ; } -EXPORT_SYMBOL_GPL (match_trapped_io_handler);static struct trapped_io *lookup_tiop (unsigned long address) {
Signature · 1 line
2.26.2
PATCH 8/10 dma-mapping: consolidate the NO_DMA definition in kernel/dma/Kconfig
In reply to Christoph HellwigHave a single definition that architetures can select.
--- arch/m68k/Kconfig | 4 +--- arch/m68k/Kconfig.machine | 1 + arch/um/Kconfig | 4 +--- kernel/dma/Kconfig | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-)
arch/m68k/Kconfig +1 -3
@@ -17,6 +17,7 @@ config M68K select HAVE_COPY_THREAD_TLS select GENERIC_IRQ_SHOW select GENERIC_ATOMIC64 + select NO_DMA if !MMU && !COLDFIRE select HAVE_UID16 select VIRT_TO_BUS select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
@@ -60,9 +61,6 @@ config TIME_LOW_RES config NO_IOPORT_MAP def_bool y -config NO_DMA - def_bool (MMU && SUN3) || (!MMU && !COLDFIRE) - config ZONE_DMA bool default y
arch/m68k/Kconfig.machine +1 -0
@@ -126,6 +126,7 @@ config SUN3 depends on MMU depends on !MMU_MOTOROLA select MMU_SUN3 if MMU + select NO_DMA select M68020 help This option enables support for the Sun 3 series of workstations
arch/um/Kconfig +1 -3
@@ -15,6 +15,7 @@ config UML select HAVE_DEBUG_KMEMLEAK select HAVE_DEBUG_BUGVERBOSE select HAVE_COPY_THREAD_TLS + select NO_DMA select GENERIC_IRQ_SHOW select GENERIC_CPU_DEVICES select GENERIC_CLOCKEVENTS
@@ -168,9 +169,6 @@ config MMAPPER This driver allows a host file to be used as emulated IO memory inside UML. -config NO_DMA - def_bool y - config PGTABLE_LEVELS int default 3 if 3_LEVEL_PGTABLES
kernel/dma/Kconfig +3 -0
@@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only +config NO_DMA + bool + config HAS_DMA bool depends on !NO_DMA
Signature · 1 line
2.26.2
PATCH 9/10 sh: don't allow non-coherent DMA for NOMMU
In reply to Christoph HellwigThe code handling non-coherent DMA depends on being able to remap code as non-cached. But that can't be done without an MMU, so using this option on NOMMU builds is broken.
--- arch/sh/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sh/Kconfig +2 -1
@@ -61,6 +61,7 @@ config SUPERH select MAY_HAVE_SPARSE_IRQ select MODULES_USE_ELF_RELA select NEED_SG_DMA_LENGTH + select NO_DMA if !MMU && !DMA_COHERENT select NO_GENERIC_PCI_IOPORT_MAP if PCI select OLD_SIGACTION select OLD_SIGSUSPEND
@@ -135,7 +136,7 @@ config DMA_COHERENT bool config DMA_NONCOHERENT - def_bool !DMA_COHERENT + def_bool !NO_DMA && !DMA_COHERENT select ARCH_HAS_SYNC_DMA_FOR_DEVICE config PGTABLE_LEVELS
Signature · 1 line
2.26.2
Re: [PATCH 09/10] sh: don't allow non-coherent DMA for NOMMU
Quoted 3 lines · Christoph Hellwig
The code handling non-coherent DMA depends on being able to remap code as non-cached. But that can't be done without an MMU, so using this option on NOMMU builds is broken.
I'm working on a nommu j-core board that's doing DMA behind the OS's back at the moment, which I have a todo item to teach the kernel about. The DMA does not go through the cache, there's currently a cache flush before looking at the result instead.
How should this be wired up after your patch?
Rob
Re: [PATCH 09/10] sh: don't allow non-coherent DMA for NOMMU
Quoted 11 lines · Rob Landley
Quoted 3 lines · Christoph Hellwig
The code handling non-coherent DMA depends on being able to remap code as non-cached. But that can't be done without an MMU, so using this option on NOMMU builds is broken.
I'm working on a nommu j-core board that's doing DMA behind the OS's back at the moment, which I have a todo item to teach the kernel about. The DMA does not go through the cache, there's currently a cache flush before looking at the result instead.
How should this be wired up after your patch?
The problem with nommu and non-coherent dma is the dma_alloc_coherent calls. Most platforms with an mmu set a nocache bit through the page tables (including sh), but that option obviously doesn't exist for nommu. Some hardware has an uncached window where access is uncached automatically if access through specific kernel virtual addresses, for that the architecture needs to impement the arch_dma_set_uncached helper and select CONFIG_ARCH_HAS_DMA_SET_UNCACHED. If that also doesn't exist you'll need some sort of pool of always uncached memory (set by the firmware or early startup code). That currently doesn't exist in generic code, but we have a bunch of architectures implementing that in arch_dma_alloc. I plan to have a common implementation of the pool soon hopefully.
Streaming DMA just works if you reuse the existing arch_sync_dma_for_device implementation.
PATCH 10/10 sh: use the generic dma coherent remap allocator
In reply to Christoph HellwigThis switches to using common code for the DMA allocations, including potential use of the CMA allocator if configured.
Switching to the generic code enables DMA allocations from atomic context, which is required by the DMA API documentation, and also adds various other minor features drivers start relying upon. It also makes sure we have on tested code base for all architectures that require uncached pte bits for coherent DMA allocations.
--- arch/sh/Kconfig | 2 ++ arch/sh/kernel/dma-coherent.c | 51 ++--------------------------------- 2 files changed, 4 insertions(+), 49 deletions(-)
arch/sh/Kconfig +2 -0
@@ -137,7 +137,9 @@ config DMA_COHERENT config DMA_NONCOHERENT def_bool !NO_DMA && !DMA_COHERENT + select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select DMA_DIRECT_REMAP config PGTABLE_LEVELS default 3 if X2TLB
arch/sh/kernel/dma-coherent.c +2 -49
62 lines not on this page · raw message
Signature · 1 line
2.26.2