Patches/fixes for 2.6.35
v4 cover Patches/fixes for 2.6.35
Updates from version 3 of these series:
- noMMU warning patch changed by moving the CONSISTENT_* definitions to the CONFIG_MMU section
- .phys_io alignment patch replaced by two patches that enforce the alignment in the machine_desc structures for VExpress and RealView
- commit log added to the T2 module relocations patch
Catalin Marinas (8):
ARM: Avoid the CONSISTENT_DMA_SIZE warning on noMMU builds
ARM: The v6_dma_inv_range() function must preserve data on SMP
ARM: Add a config option for the ARM11MPCore DMA cache maintenance workaround
ARM: Add support for the MOVW/MOVT relocations in Thumb-2
ARM: Remove dummy loads from the original relocation address
ARM: Do not compile the Thumb-2 module relocations on an ARM kernel
ARM: VExpress: Align the machine_desc.phys_io to 1MB section
ARM: RealView: Align the machine_desc.phys_io to 1MB section
arch/arm/include/asm/elf.h | 2 ++ arch/arm/kernel/module.c | 34 ++++++++++++++++++++++++++++++ arch/arm/mach-realview/realview_eb.c | 3 ++- arch/arm/mach-realview/realview_pb1176.c | 3 ++- arch/arm/mach-realview/realview_pb11mp.c | 3 ++- arch/arm/mach-realview/realview_pba8.c | 3 ++- arch/arm/mach-realview/realview_pbx.c | 3 ++- arch/arm/mach-vexpress/ct-ca9x4.c | 3 ++- arch/arm/mm/Kconfig | 19 +++++++++++++++++ arch/arm/mm/cache-v6.S | 18 ++++++++++++---- arch/arm/mm/dma-mapping.c | 18 ++++++++-------- 11 files changed, 90 insertions(+), 19 deletions(-)
Signature · 1 line
Catalin
PATCH v4 1/8 ARM: Avoid the CONSISTENT_DMA_SIZE warning on noMMU builds
This macro is not defined when !CONFIG_MMU so this patch moves the CONSISTENT_* definitions to the CONFIG_MMU section.
--- arch/arm/mm/dma-mapping.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
arch/arm/mm/dma-mapping.c +9 -9
@@ -24,15 +24,6 @@#include <asm/tlbflush.h> #include <asm/sizes.h> -/* Sanity check size */ -#if (CONSISTENT_DMA_SIZE %SZ_2M ) -#error "CONSISTENT_DMA_SIZE must be multiple of 2MiB" -#endif - -#define CONSISTENT_OFFSET (x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) -#define CONSISTENT_PTE_INDEX (x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT) -#define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT) -static u64 get_coherent_dma_mask (struct device *dev) {u64 mask =ISA_DMA_THRESHOLD ;
@@ -123,6 +114,15 @@ static void __dma_free_buffer(struct page *page, size_t size) }#ifdef CONFIG_MMU +/* Sanity check size */ +#if (CONSISTENT_DMA_SIZE %SZ_2M ) +#error "CONSISTENT_DMA_SIZE must be multiple of 2MiB" +#endif + +#define CONSISTENT_OFFSET (x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) +#define CONSISTENT_PTE_INDEX (x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT) +#define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT) +/* * These are the page tables (2MB each) covering uncached, DMA consistent allocations */
PATCH v4 2/8 ARM: The v6_dma_inv_range() function must preserve data on SMP
In reply to Catalin MarinasA recent patch for DMA cache maintenance on ARM11MPCore added a write for ownership trick to the v6_dma_inv_range() function. Such operation destroys data already present in the buffer. However, this function is used with with dma_sync_single_for_device() which is supposed to preserve the existing data transfered into the buffer. This patch adds a combination of read/write for ownership to preserve the original data.
--- arch/arm/mm/cache-v6.S | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/mm/cache-v6.S +2 -1
@@ -212,7 +212,8 @@ v6_dma_inv_range: #endif 1: #ifdef CONFIG_SMP - str r0, [r0] @ write for ownership + ldr r2, [r0] @ read for ownership + str r2, [r0] @ write for ownership #endif #ifdef HARVARD_CACHE mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
PATCH v4 3/8 ARM: Add a config option for the ARM11MPCore DMA cache maintenance workaround
In reply to Catalin MarinasCommit f4d6477f introduced a workaround for the lack of hardware broadcasting of the cache maintenance operations on ARM11MPCore. However, the workaround is only valid on CPUs that do not do speculative loads into the D-cache.
This patch adds a Kconfig option with the corresponding help to make the above clear. When the DMA_CACHE_RWFO option is disabled, the kernel behaviour is that prior to the f4d6477f commit. This also allows ARMv6 UP processors with speculative loads to work correctly.
For other processors, a different workaround may be needed.
--- arch/arm/mm/Kconfig | 19 +++++++++++++++++++ arch/arm/mm/cache-v6.S | 15 ++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/mm/Kconfig +19 -0
@@ -735,6 +735,25 @@ config NEEDS_SYSCALL_FOR_CMPXCHG Forget about fast user space cmpxchg support. It is just not possible. +config DMA_CACHE_RWFO + bool "Enable read/write for ownership DMA cache maintenance" + depends on CPU_V6 && SMP + default y + help + The Snoop Control Unit on ARM11MPCore does not detect the + cache maintenance operations and the dma_{map,unmap}_area() + functions may leave stale cache entries on other CPUs. By + enabling this option, Read or Write For Ownership in the ARMv6 + DMA cache maintenance functions is performed. These LDR/STR + instructions change the cache line state to shared or modified + so that the cache operation has the desired effect. + + Note that the workaround is only valid on processors that do + not perform speculative loads into the D-cache. For such + processors, if cache maintenance operations are not broadcast + in hardware, other workarounds are needed (e.g. cache + maintenance broadcasting in software via FIQ). + config OUTER_CACHE bool
arch/arm/mm/cache-v6.S +12 -3
@@ -211,7 +211,7 @@ v6_dma_inv_range: mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line #endif 1: -#ifdef CONFIG_SMP +#ifdef CONFIG_DMA_CACHE_RWFO ldr r2, [r0] @ read for ownership str r2, [r0] @ write for ownership #endif
@@ -235,7 +235,7 @@ v6_dma_inv_range: v6_dma_clean_range: bic r0, r0, #D_CACHE_LINE_SIZE - 1 1: -#ifdef CONFIG_SMP +#ifdef CONFIG_DMA_CACHE_RWFO ldr r2, [r0] @ read for ownership #endif #ifdef HARVARD_CACHE
@@ -258,7 +258,7 @@ v6_dma_clean_range: ENTRY(v6_dma_flush_range) bic r0, r0, #D_CACHE_LINE_SIZE - 1 1: -#ifdef CONFIG_SMP +#ifdef CONFIG_DMA_CACHE_RWFO ldr r2, [r0] @ read for ownership str r2, [r0] @ write for ownership #endif
@@ -284,9 +284,13 @@ ENTRY(v6_dma_map_area) add r1, r1, r0 teq r2, #DMA_FROM_DEVICE beq v6_dma_inv_range +#ifndef CONFIG_DMA_CACHE_RWFO + b v6_dma_clean_range +#else teq r2, #DMA_TO_DEVICE beq v6_dma_clean_range b v6_dma_flush_range +#endif ENDPROC(v6_dma_map_area) /*
@@ -296,6 +300,11 @@ ENDPROC(v6_dma_map_area) * - dir - DMA direction */ ENTRY(v6_dma_unmap_area) +#ifndef CONFIG_DMA_CACHE_RWFO + add r1, r1, r0 + teq r2, #DMA_TO_DEVICE + bne v6_dma_inv_range +#endif mov pc, lr ENDPROC(v6_dma_unmap_area)
PATCH v4 4/8 ARM: Add support for the MOVW/MOVT relocations in Thumb-2
In reply to Catalin MarinasThe patch adds handling case for the R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS relocations in arch/arm/kernel/module.c. Such relocations may appear in Thumb-2 compiled kernel modules.
--- arch/arm/include/asm/elf.h | 2 ++ arch/arm/kernel/module.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
arch/arm/include/asm/elf.h +2 -0
@@ -59,6 +59,8 @@ typedef struct user_fp elf_fpregset_t;#define R_ARM_THM_CALL 10#define R_ARM_THM_JUMP24 30 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48/* * These are used to set parameters in the core dumps.
arch/arm/kernel/module.c +32 -0
@@ -237,6 +237,38 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, lower = *(u16 *)(loc +2 );break ; +case R_ARM_THM_MOVW_ABS_NC : +case R_ARM_THM_MOVT_ABS : + upper = *(u16 *)loc; + lower = *(u16 *)(loc +2 ); + +/* +* MOVT/MOVW instructions encoding in Thumb-2: +* +* i = upper[10] +* imm4 = upper[3:0] +* imm3 = lower[14:12] +* imm8 = lower[7:0] +* +* imm16 = imm4:i:imm3:imm8 +*/ + offset = ((upper &0x000f ) <<12 ) | + ((upper &0x0400 ) <<1 ) | + ((lower &0x7000 ) >>4 ) | (lower &0x00ff ); + offset = (offset ^0x8000 ) -0x8000 ; + offset += sym->st_value; + +if (ELF32_R_TYPE (rel->r_info) ==R_ARM_THM_MOVT_ABS ) + offset >>=16 ; + + *(u16 *)loc = (u16)((upper &0xfbf0 ) | + ((offset &0xf000 ) >>12 ) | + ((offset &0x0800 ) >>1 )); + *(u16 *)(loc +2 ) = (u16)((lower &0x8f00 ) | + ((offset &0x0700 ) <<4 ) | + (offset &0x00ff )); +break ; +default :printk (KERN_ERR "%s: unknown relocation: %u\n" , module->name,ELF32_R_TYPE (rel->r_info));
PATCH v4 5/8 ARM: Remove dummy loads from the original relocation address
In reply to Catalin MarinasReading back the upper and lower values in the R_ARM_THM_CALL and R_ARM_THM_JUMP24 case was introduced by a previous commit but they are not needed.
--- arch/arm/kernel/module.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
arch/arm/kernel/module.c +0 -2
@@ -233,8 +233,6 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, *(u16 *)(loc +2 ) = (u16)((lower &0xd000 ) | (j1 <<13 ) | (j2 <<11 ) | ((offset >>1 ) &0x07ff )); - upper = *(u16 *)loc; - lower = *(u16 *)(loc +2 );break ;case R_ARM_THM_MOVW_ABS_NC :
PATCH v4 6/8 ARM: Do not compile the Thumb-2 module relocations on an ARM kernel
In reply to Catalin MarinasKernels compiled to ARM do not need to handle Thumb-2 module relocations as interworking is not allowed. This patch #ifdef's out the handling of such relocations.
--- arch/arm/kernel/module.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/kernel/module.c +4 -0
@@ -102,7 +102,9 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,unsigned long loc;Elf32_Sym *sym;s32 offset; +#ifdef CONFIG_THUMB2_KERNEL u32 upper, lower, sign, j1, j2; +#endif offset =ELF32_R_SYM (rel->r_info);if (offset <0 || offset > (symsec->sh_size /sizeof (Elf32_Sym))) {
@@ -185,6 +187,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, (offset &0x0fff );break ; +#ifdef CONFIG_THUMB2_KERNEL case R_ARM_THM_CALL :case R_ARM_THM_JUMP24 : upper = *(u16 *)loc;
@@ -266,6 +269,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, ((offset &0x0700 ) <<4 ) | (offset & 0x00ff));break ; +#endif default : printk(KERN_ERR "%s: unknown relocation: %u\n",
PATCH v4 7/8 ARM: VExpress: Align the machine_desc.phys_io to 1MB section
In reply to Catalin MarinasWhen not aligned, random bits could be written in the initial page table by the __create_page_tables() function.
--- arch/arm/mach-vexpress/ct-ca9x4.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/mach-vexpress/ct-ca9x4.c +2 -1
@@ -9,6 +9,7 @@#include <linux/amba/clcd.h> #include <asm/clkdev.h> +#include <asm/pgtable.h> #include <asm/hardware/arm_timer.h> #include <asm/hardware/cache-l2x0.h> #include <asm/hardware/gic.h>
@@ -235,7 +236,7 @@ static void ct_ca9x4_init(void) }MACHINE_START (VEXPRESS ,"ARM-Versatile Express CA9x4" ) - .phys_io = V2M_UART0, + .phys_io = V2M_UART0 & SECTION_MASK, .io_pg_offst = (__MMIO_P2V(V2M_UART0) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .map_io = ct_ca9x4_map_io,
PATCH v4 8/8 ARM: RealView: Align the machine_desc.phys_io to 1MB section
In reply to Catalin MarinasWhen not aligned, random bits could be written in the initial page table by the __create_page_tables() function.
--- arch/arm/mach-realview/realview_eb.c | 3 ++- arch/arm/mach-realview/realview_pb1176.c | 3 ++- arch/arm/mach-realview/realview_pb11mp.c | 3 ++- arch/arm/mach-realview/realview_pba8.c | 3 ++- arch/arm/mach-realview/realview_pbx.c | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-realview/realview_eb.c +2 -1
@@ -32,6 +32,7 @@#include <asm/leds.h> #include <asm/mach-types.h> #include <asm/pmu.h> +#include <asm/pgtable.h> #include <asm/hardware/gic.h> #include <asm/hardware/cache-l2x0.h> #include <asm/localtimer.h>
@@ -457,7 +458,7 @@ static void __init realview_eb_init(void)MACHINE_START (REALVIEW_EB ,"ARM-RealView EB" )/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ - .phys_io = REALVIEW_EB_UART0_BASE, + .phys_io = REALVIEW_EB_UART0_BASE & SECTION_MASK, .io_pg_offst = (IO_ADDRESS(REALVIEW_EB_UART0_BASE) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .fixup = realview_fixup,
arch/arm/mach-realview/realview_pb1176.c +2 -1
@@ -32,6 +32,7 @@#include <asm/leds.h> #include <asm/mach-types.h> #include <asm/pmu.h> +#include <asm/pgtable.h> #include <asm/hardware/gic.h> #include <asm/hardware/cache-l2x0.h>
@@ -351,7 +352,7 @@ static void __init realview_pb1176_init(void)MACHINE_START (REALVIEW_PB1176 ,"ARM-RealView PB1176" )/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ - .phys_io = REALVIEW_PB1176_UART0_BASE, + .phys_io = REALVIEW_PB1176_UART0_BASE & SECTION_MASK, .io_pg_offst = (IO_ADDRESS(REALVIEW_PB1176_UART0_BASE) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .fixup = realview_pb1176_fixup,
arch/arm/mach-realview/realview_pb11mp.c +2 -1
@@ -32,6 +32,7 @@#include <asm/leds.h> #include <asm/mach-types.h> #include <asm/pmu.h> +#include <asm/pgtable.h> #include <asm/hardware/gic.h> #include <asm/hardware/cache-l2x0.h> #include <asm/localtimer.h>
@@ -373,7 +374,7 @@ static void __init realview_pb11mp_init(void)MACHINE_START (REALVIEW_PB11MP ,"ARM-RealView PB11MPCore" )/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ - .phys_io = REALVIEW_PB11MP_UART0_BASE, + .phys_io = REALVIEW_PB11MP_UART0_BASE & SECTION_MASK, .io_pg_offst = (IO_ADDRESS(REALVIEW_PB11MP_UART0_BASE) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .fixup = realview_fixup,
arch/arm/mach-realview/realview_pba8.c +2 -1
@@ -31,6 +31,7 @@#include <asm/leds.h> #include <asm/mach-types.h> #include <asm/pmu.h> +#include <asm/pgtable.h> #include <asm/hardware/gic.h> #include <asm/mach/arch.h>
@@ -323,7 +324,7 @@ static void __init realview_pba8_init(void)MACHINE_START (REALVIEW_PBA8 ,"ARM-RealView PB-A8" )/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ - .phys_io = REALVIEW_PBA8_UART0_BASE, + .phys_io = REALVIEW_PBA8_UART0_BASE & SECTION_MASK, .io_pg_offst = (IO_ADDRESS(REALVIEW_PBA8_UART0_BASE) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .fixup = realview_fixup,
arch/arm/mach-realview/realview_pbx.c +2 -1
@@ -31,6 +31,7 @@#include <asm/mach-types.h> #include <asm/pmu.h> #include <asm/smp_twd.h> +#include <asm/pgtable.h> #include <asm/hardware/gic.h> #include <asm/hardware/cache-l2x0.h>
@@ -409,7 +410,7 @@ static void __init realview_pbx_init(void)MACHINE_START (REALVIEW_PBX ,"ARM-RealView PBX" )/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ - .phys_io = REALVIEW_PBX_UART0_BASE, + .phys_io = REALVIEW_PBX_UART0_BASE & SECTION_MASK, .io_pg_offst = (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x00000100, .fixup = realview_pbx_fixup,
v4 cover Patches/fixes for 2.6.35
In reply to Catalin MarinasQuoted 7 lines · Catalin Marinas
Updates from version 3 of these series:
- noMMU warning patch changed by moving the CONSISTENT_* definitions to the
CONFIG_MMUsection
- .phys_io alignment patch replaced by two patches that enforce the alignment in themachine_descstructures for VExpress and RealView
- commit log added to the T2 module relocations patch
Ok.