ARCv2 port to Linux - (B) ISA / Core / platform support
Subsystems (10)
PATCH 5/28 ARCv2: STAR 9000814690: Really Re-enable interrupts to avoid deadlocks
In reply to Vineet GuptaThe issue was, on HS when interrupt is taken, IRQ_ACT is set and that is NOT cleared unless we do RTIE (or manually clear it). Linux interrupt handling has top and bottom halves. Latter lead to softirqs (which can reschedule) AND expect interrupts to be REALLY re-enabled which was NOT happening for us since we only SETI, dont clear IRQ_ACT
So we can have a state when both cores have taken interrupt (IRQ_ACT set), get rescheduled, both send IPI and wait in CSD lock which will never be cleared as cores can't take the pending IPI IRQ due to existing IRQ_ACT set.
So local_irq_enable() now drops the IRQ_ACT.act bit to re-enable IRQs.
--- arch/arc/include/asm/irqflags-arcv2.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arc/include/asm/irqflags-arcv2.h +5 -0
@@ -64,6 +64,11 @@ static inline void arch_local_irq_restore(unsigned long flags)*/ static inline void arch_local_irq_enable (void ) { +unsigned int irqact =read_aux_reg (AUX_IRQ_ACT ); + +if (irqact &0xffff ) +write_aux_reg (AUX_IRQ_ACT , irqact & ~0xffff ); + __asm__ __volatile__(" seti \n" : : :"memory" ); }
Signature · 1 line
1.9.1
PATCH 7/28 ARCv2: MMUv4: cache programming model changes
In reply to Vineet GuptaCaveats about cache flush on ARCv2 based cores
- dcache is PIPT so paddr is sufficient for cache maintenance ops (no need to setup PTAG reg
- icache is still VIPT but only aliasing configs need PTAG setup
So basically this is departure from MMU-v3 which always need vaddr in line ops registers (DC_IVDL, DC_FLDL, IC_IVIL) but paddr in DC_PTAG, IC_PTAG respectively.
--- arch/arc/Kconfig | 2 +- arch/arc/include/asm/arcregs.h | 5 +- arch/arc/include/asm/cache.h | 3 ++ arch/arc/mm/cache.c | 112 +++++++++++++++++++++++++++++++++++------ 4 files changed, 104 insertions(+), 18 deletions(-)
arch/arc/Kconfig +1 -1
@@ -223,7 +223,7 @@ config ARC_CACHE_PAGES config ARC_CACHE_VIPT_ALIASING bool "Support VIPT Aliasing D$" - depends on ARC_HAS_DCACHE + depends on ARC_HAS_DCACHE && ISA_ARCOMPACT default n endif #ARC_CACHE
arch/arc/include/asm/arcregs.h +3 -2
@@ -17,6 +17,7 @@#define ARC_REG_FP_BCR 0x6B/* ARCompact: Single-Precision FPU */ #define ARC_REG_DPFP_BCR 0x6C/* ARCompact: Dbl Precision FPU */ #define ARC_REG_FP_V2_BCR 0xc8/* ARCv2 FPU */ +#define ARC_REG_SLC_BCR 0xce#define ARC_REG_DCCM_BCR 0x74/* DCCM Present + SZ */ #define ARC_REG_TIMERS_BCR 0x75#define ARC_REG_AP_BCR 0x76
@@ -330,7 +331,7 @@ struct cpuinfo_arc_mmu { };struct cpuinfo_arc_cache { -unsigned int sz_k:8 , line_len:8 , assoc:4 , ver:4 , alias:1 , vipt:1 , pad:6 ; +unsigned int sz_k:14 , line_len:8 , assoc:4 , ver:4 , alias:1 , vipt:1 ; };struct cpuinfo_arc_bpu {
@@ -342,7 +343,7 @@ struct cpuinfo_arc_ccm { };struct cpuinfo_arc { -struct cpuinfo_arc_cache icache, dcache; +struct cpuinfo_arc_cache icache, dcache, slc;struct cpuinfo_arc_mmu mmu;struct cpuinfo_arc_bpu bpu;struct bcr_identity core;
arch/arc/include/asm/cache.h +3 -0
@@ -82,4 +82,7 @@ extern void read_decode_cache_bcr(void);#define DC_CTRL_INV_MODE_FLUSH 0x40#define DC_CTRL_FLUSH_STATUS 0x100 +/*System-level cache (L2 cache) related Auxiliary registers */ +#define ARC_REG_SLC_CFG 0x901 +#endif /* _ASM_CACHE_H */
arch/arc/mm/cache.c +97 -15
174 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 14/28 ARCv2: SMP: ARConnect debug/robustness
In reply to Vineet Gupta- Handle possible interrupt coalescing from MCIP
- chk if prev IPI ack before sending new
--- arch/arc/Kconfig | 15 ++++++++++++--- arch/arc/kernel/mcip.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- arch/arc/kernel/smp.c | 20 ++++++++++++++++---- 3 files changed, 72 insertions(+), 11 deletions(-)
arch/arc/Kconfig +12 -3
@@ -448,9 +448,10 @@ menuconfig ARC_DBG bool "ARC debugging" default y +if ARC_DBG + config ARC_DW2_UNWIND bool "Enable DWARF specific kernel stack unwind" - depends on ARC_DBG default y select KALLSYMS help
@@ -464,18 +465,26 @@ config ARC_DW2_UNWIND config ARC_DBG_TLB_PARANOIA bool "Paranoia Checks in Low Level TLB Handlers" - depends on ARC_DBG default n config ARC_DBG_TLB_MISS_COUNT bool "Profile TLB Misses" default n select DEBUG_FS - depends on ARC_DBG help Counts number of I and D TLB Misses and exports them via Debugfs The counters can be cleared via Debugfs as well +if SMP + +config ARC_IPI_DBG + bool "Debug Inter Core interrupts" + default n + +endif + +endif + config ARC_UBOOT_SUPPORT bool "Support uboot arg Handling" default n
arch/arc/kernel/mcip.c +44 -4
71 lines not on this page · raw message
arch/arc/kernel/smp.c +16 -4
@@ -278,8 +278,10 @@ static void ipi_cpu_stop(void)machine_halt (); } -static inline void __do_IPI (unsigned long msg) +static inline int __do_IPI (unsigned long msg) { +int rc =0 ; +switch (msg) {case IPI_RESCHEDULE :scheduler_ipi ();
@@ -294,8 +296,10 @@ static inline void __do_IPI(unsigned long msg)break ;default : -pr_warn ("IPI with unexpected msg %ld\n" , msg); + rc =1 ; } + +return rc; }/*
@@ -305,6 +309,7 @@ static inline void __do_IPI(unsigned long msg)irqreturn_t do_IPI (int irq,void *dev_id) {unsigned long pending; +unsigned long __maybe_unused copy;pr_debug ("IPI [%ld] received on cpu %d\n" , *this_cpu_ptr (&ipi_data),smp_processor_id ());
@@ -316,11 +321,18 @@ irqreturn_t do_IPI(int irq, void *dev_id)* "dequeue" the msg corresponding to this IPI (and possibly other * piggybacked msg from elided IPIs: see ipi_send_msg_one() above) */ - pending =xchg (this_cpu_ptr (&ipi_data),0 ); + copy = pending =xchg (this_cpu_ptr (&ipi_data),0 );do {unsigned long msg =__ffs (pending); -__do_IPI (msg); +int rc; + + rc =__do_IPI (msg); +#ifdef CONFIG_ARC_IPI_DBG +/* IPI received but no valid @msg */ +if (rc) +pr_info ("IPI with bogus msg %ld in %ld\n" , msg, copy); +#endif pending &= ~(1U << msg); }while (pending);
Signature · 1 line
1.9.1
PATCH 18/28 ARC: add smp barriers around atomics per memory-barrriers.txt
In reply to Vineet Gupta--- arch/arc/include/asm/atomic.h | 10 ++++++++++ arch/arc/include/asm/bitops.h | 12 ++++++++++++ arch/arc/include/asm/cmpxchg.h | 10 ++++++++++ arch/arc/include/asm/spinlock.h | 10 ++++++++++ 4 files changed, 42 insertions(+)
arch/arc/include/asm/atomic.h +10 -0
@@ -43,6 +43,8 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ { \unsigned int temp; \ \ +smp_mb (); \ + \ __asm__ __volatile__( \ "1: llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \
@@ -52,6 +54,8 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ : "r"(&v->counter), "ir"(i) \ : "cc"); \ \ +smp_mb (); \ + \return temp; \ }
@@ -142,9 +146,15 @@ ATOMIC_OP(and, &=, and)#define __atomic_add_unless (v, a, u) \ ({ \ int c, old; \ + \ + smp_mb(); \ + \ c = atomic_read(v); \ while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c)\ c = old; \ + \ + smp_mb(); \ + \ c; \ })
arch/arc/include/asm/bitops.h +12 -0
@@ -117,6 +117,8 @@ static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bset %1, %0, %3 \n"
@@ -126,6 +128,8 @@ static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
@@ -139,6 +143,8 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bclr %1, %0, %3 \n"
@@ -148,6 +154,8 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
@@ -161,6 +169,8 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bxor %1, %0, %3 \n"
@@ -170,6 +180,8 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
arch/arc/include/asm/cmpxchg.h +10 -0
@@ -10,6 +10,8 @@#define __ASM_ARC_CMPXCHG_H#include <linux/types.h> + +#include <asm/barrier.h> #include <asm/smp.h> #ifdef CONFIG_ARC_HAS_LLSC
@@ -19,6 +21,8 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new) {unsigned long prev; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%1] \n" " brne %0, %2, 2f \n"
@@ -31,6 +35,8 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new) "r"(new) /* can't be "ir". scond can't take LIMM for "b" */ : "cc", "memory"); /* so that gcc knows memory is being written here */ + smp_mb(); +return prev; }
@@ -78,12 +84,16 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr,switch (size) {case 4 : +smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" :"+r" (val) :"r" (ptr) :"memory" ); +smp_mb (); +return val; }return __xchg_bad_pointer ();
arch/arc/include/asm/spinlock.h +10 -0
@@ -22,24 +22,32 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" " breq %0, %2, 1b \n" :"+&r" (tmp) :"r" (&(lock->slock)),"ir" (__ARCH_SPIN_LOCK_LOCKED__) :"memory" ); + +smp_mb (); }static inline int arch_spin_trylock (arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" :"+r" (tmp) :"r" (&(lock->slock)) :"memory" ); +smp_mb (); +return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__); }
@@ -47,6 +55,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__; +smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" : "+r" (tmp)
Signature · 1 line
1.9.1
PATCH 19/28 arch: conditionally define smp_{mb,rmb,wmb}
In reply to Vineet GuptaThat way arches can define the minimal versions and still #include asm-generic for defaults (vs. defining defaults in arch code)
See new barrier.h in arc for usage !
--- include/asm-generic/barrier.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
include/asm-generic/barrier.h +25 -0
@@ -55,17 +55,42 @@#endif #ifdef CONFIG_SMP + +#ifndef smp_mb#define smp_mb () mb() +#endif + +#ifndef smp_rmb#define smp_rmb () rmb() +#endif + +#ifndef smp_wmb#define smp_wmb () wmb() +#endif + +#ifndef smp_read_barrier_depends#define smp_read_barrier_depends () read_barrier_depends() +#endif +#else +#ifndef smp_mb#define smp_mb () barrier() +#endif + +#ifndef smp_rmb#define smp_rmb () barrier() +#endif + +#ifndef smp_wmb#define smp_wmb () barrier() +#endif + +#ifndef smp_read_barrier_depends#define smp_read_barrier_depends () do { } while (0)#endif +#endif +#ifndef set_mb#define set_mb (var, value) do { (var) = (value); mb(); } while (0)#endif
Signature · 1 line
1.9.1
PATCH 22/28 ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Vineet Gupta--- arch/arc/include/asm/atomic.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arc/include/asm/atomic.h +12 -2
@@ -23,13 +23,21 @@#define atomic_set (v, i) (((v)->counter) = (i)) +#ifdef CONFIG_ISA_ARCV2 +#define PREFETCHW " prefetchw [%1] \n" +#else +#define PREFETCHW +#endif +#define ATOMIC_OP (op, c_op, asm_op) \ static inline void atomic_##op(int i, atomic_t *v) \ { \ unsigned int temp; \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
@@ -46,7 +54,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \smp_mb (); \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
Signature · 1 line
1.9.1
PATCH 23/28 ARCv2: SLC: Handle explcit flush for DMA ops (w/o IO-coherency)
In reply to Vineet GuptaL2 cache on ARCHS processors is called SLC (System Level Cache) For working DMA (in absence of hardware assisted IO Coherency) we need to manage SLC explicitly when buffers transition between cpu and controllers.
--- arch/arc/include/asm/cache.h | 11 ++++++++ arch/arc/mm/cache.c | 64 ++++++++++++++++++++++++++++++++++++++++++-- arch/arc/mm/dma.c | 12 +++++++++ 3 files changed, 85 insertions(+), 2 deletions(-)
arch/arc/include/asm/cache.h +11 -0
@@ -82,5 +82,16 @@ extern void read_decode_cache_bcr(void);/*System-level cache (L2 cache) related Auxiliary registers */ #define ARC_REG_SLC_CFG 0x901 +#define ARC_REG_SLC_CTRL 0x903 +#define ARC_REG_SLC_FLUSH 0x904 +#define ARC_REG_SLC_INVALIDATE 0x905 +#define ARC_REG_SLC_RGN_START 0x914 +#define ARC_REG_SLC_RGN_END 0x916 + +/* Bit val in SLC_CONTROL */ +#define SLC_CTRL_IM 0x040 +#define SLC_CTRL_DISABLE 0x001 +#define SLC_CTRL_BUSY 0x100 +#define SLC_CTRL_RGN_OP_INV 0x200#endif /* _ASM_CACHE_H */
arch/arc/mm/cache.c +62 -2
109 lines not on this page · raw message
arch/arc/mm/dma.c +12 -0
@@ -66,6 +66,18 @@ void *dma_alloc_coherent(struct device *dev, size_t size,/* This is bus address, platform dependent */ *dma_handle = (dma_addr_t )paddr; +/* +* Evict any existing L1 and/or L2 lines for the backing page +* in case it was used earlier as a normal "cached" page. +* Yeah this bit us - STAR 9000898266 +* +* Although core does call flush_cache_vmap(), it gets kvaddr hence +* can't be used to efficiently flush L1 and/or L2 which need paddr +* Currently flush_cache_vmap nukes the L1 cache completely which +* will be optimized as a separate commit +*/ +dma_cache_wback_inv ((unsigned long )paddr, size); +return kvaddr; }EXPORT_SYMBOL (dma_alloc_coherent);
Signature · 1 line
1.9.1
PATCH 25/28 ARCv2: [nsim*hs*] Support simulation platforms for HS38x cores
In reply to Vineet Gupta--- arch/arc/boot/dts/nsim_hs.dts | 53 +++++++++++++++ arch/arc/boot/dts/nsim_hs_idu.dts | 72 ++++++++++++++++++++ arch/arc/boot/dts/nsimosci_hs.dts | 80 +++++++++++++++++++++++ arch/arc/boot/dts/nsimosci_hs_idu.dts | 101 +++++++++++++++++++++++++++++ arch/arc/configs/nsim_hs_defconfig | 64 ++++++++++++++++++ arch/arc/configs/nsim_hs_smp_defconfig | 63 ++++++++++++++++++ arch/arc/configs/nsimosci_hs_defconfig | 73 +++++++++++++++++++++ arch/arc/configs/nsimosci_hs_smp_defconfig | 93 ++++++++++++++++++++++++++ arch/arc/plat-sim/platform.c | 2 + 9 files changed, 601 insertions(+) create mode 100644 arch/arc/boot/dts/nsim_hs.dts create mode 100644 arch/arc/boot/dts/nsim_hs_idu.dts create mode 100644 arch/arc/boot/dts/nsimosci_hs.dts create mode 100644 arch/arc/boot/dts/nsimosci_hs_idu.dts create mode 100644 arch/arc/configs/nsim_hs_defconfig create mode 100644 arch/arc/configs/nsim_hs_smp_defconfig create mode 100644 arch/arc/configs/nsimosci_hs_defconfig create mode 100644 arch/arc/configs/nsimosci_hs_smp_defconfig
arch/arc/boot/dts/nsim_hs.dts new file +53 -0
@@ -0,0 +1,53 @@ +/* + * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/dts-v1/; + +/include/ "skeleton.dtsi" + +/ { + compatible = "snps,nsim_hs"; + interrupt-parent = <&core_intc>; + + chosen { + bootargs = "earlycon=arc_uart,mmio32,0xc0fc1000,115200n8 console=ttyARC0,115200n8"; + }; + + aliases { + serial0 = &arcuart0; + }; + + fpga { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + /* child and parent address space 1:1 mapped */ + ranges; + + core_intc: core-interrupt-controller { + compatible = "snps,archs-intc"; + interrupt-controller; + #interrupt-cells = <1>; + }; + + arcuart0: serial@c0fc1000 { + compatible = "snps,arc-uart"; + reg = <0xc0fc1000 0x100>; + interrupts = <24>; + clock-frequency = <80000000>; + current-speed = <115200>; + status = "okay"; + }; + + arcpct0: pct { + compatible = "snps,archs-pct"; + #interrupt-cells = <1>; + interrupts = <20>; + }; + }; +};
arch/arc/boot/dts/nsim_hs_idu.dts new file +72 -0
72 lines not on this page · raw message
arch/arc/boot/dts/nsimosci_hs.dts new file +80 -0
80 lines not on this page · raw message
arch/arc/boot/dts/nsimosci_hs_idu.dts new file +101 -0
101 lines not on this page · raw message
arch/arc/configs/nsim_hs_defconfig new file +64 -0
64 lines not on this page · raw message
arch/arc/configs/nsim_hs_smp_defconfig new file +63 -0
63 lines not on this page · raw message
arch/arc/configs/nsimosci_hs_defconfig new file +73 -0
73 lines not on this page · raw message
arch/arc/configs/nsimosci_hs_smp_defconfig new file +93 -0
93 lines not on this page · raw message
arch/arc/plat-sim/platform.c +2 -0
@@ -22,7 +22,9 @@static const char *simulation_compat[]__initconst = {"snps,nsim" , +"snps,nsim_hs" ,"snps,nsimosci" , +"snps,nsimosci_hs" ,NULL , };
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 26/28 ARC: [axs101] Prepare for AXS103
In reply to Vineet GuptaFrom: Alexey Brodkin <[email protected]>
To avoid duplicating the MB DTS file, move the MB intc entry into cpu card specific file
--- arch/arc/boot/dts/axc001.dtsi | 21 +++++++++++++++++++++ arch/arc/boot/dts/axs10x_mb.dtsi | 17 ----------------- 2 files changed, 21 insertions(+), 17 deletions(-)
arch/arc/boot/dts/axc001.dtsi +21 -0
@@ -69,6 +69,27 @@ }; }; + /* + * This INTC is actually connected to DW APB GPIO + * which acts as a wire between MB INTC and CPU INTC. + * GPIO INTC is configured in platform init code + * and here we mimic direct connection from MB INTC to + * CPU INTC, thus we set "interrupts = <7>" instead of + * "interrupts = <12>" + * + * This intc actually resides on MB, but we move it here to + * avoid duplicating the MB dtsi file given that IRQ from + * this intc to cpu intc are different for axs101 and axs103 + */ + mb_intc: dw-apb-ictl@0xe0012000 { + #interrupt-cells = <1>; + compatible = "snps,dw-apb-ictl"; + reg = < 0xe0012000 0x200 >; + interrupt-controller; + interrupt-parent = <&cpu_intc>; + interrupts = < 7 >; + }; + memory { #address-cells = <1>; #size-cells = <1>;
arch/arc/boot/dts/axs10x_mb.dtsi +0 -17
@@ -36,23 +36,6 @@ }; }; - /* - * This INTC is actually connected to DW APB GPIO - * which acts as a wire between MB INTC and CPU INTC. - * GPIO INTC is configured in platform init code - * and here we mimic direct connection from MB INTC to - * CPU INTC, thus we set "interrupts = <7>" instead of - * "interrupts = <12>" - */ - mb_intc: dw-apb-ictl@0x12000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0x12000 0x200 >; - interrupt-controller; - interrupt-parent = <&cpu_intc>; - interrupts = < 7 >; - }; - ethernet@0x18000 { #interrupt-cells = <1>; compatible = "snps,dwmac";
Signature · 1 line
1.9.1
PATCH 27/28 ARCv2: [axs103] Support ARC SDP FPGA platform for HS38x cores
In reply to Vineet Gupta--- Documentation/devicetree/bindings/arc/axs103.txt | 8 + arch/arc/boot/dts/axc003.dtsi | 102 ++++++++++++ arch/arc/boot/dts/axc003_idu.dtsi | 126 +++++++++++++++ arch/arc/boot/dts/axs103.dts | 24 +++ arch/arc/boot/dts/axs103_idu.dts | 24 +++ arch/arc/configs/axs103_defconfig | 117 ++++++++++++++ arch/arc/configs/axs103_smp_defconfig | 118 ++++++++++++++ arch/arc/kernel/devtree.c | 2 +- arch/arc/plat-axs10x/Kconfig | 13 +- arch/arc/plat-axs10x/axs10x.c | 198 +++++++++++++++++++++-- 10 files changed, 720 insertions(+), 12 deletions(-) create mode 100644 Documentation/devicetree/bindings/arc/axs103.txt create mode 100644 arch/arc/boot/dts/axc003.dtsi create mode 100644 arch/arc/boot/dts/axc003_idu.dtsi create mode 100644 arch/arc/boot/dts/axs103.dts create mode 100644 arch/arc/boot/dts/axs103_idu.dts create mode 100644 arch/arc/configs/axs103_defconfig create mode 100644 arch/arc/configs/axs103_smp_defconfig
Documentation/devicetree/bindings/arc/axs103.txt new file +8 -0
@@ -0,0 +1,8 @@ +Synopsys DesignWare ARC Software Development Platforms Device Tree Bindings +--------------------------------------------------------------------------- + +SDP Main Board with an AXC003 FPGA Card which can contain various flavours of +HS38x cores. + +Required root node properties: + - compatible = "snps,axs103", "snps,arc-sdp";
arch/arc/boot/dts/axc003.dtsi new file +102 -0
102 lines not on this page · raw message
arch/arc/boot/dts/axc003_idu.dtsi new file +126 -0
126 lines not on this page · raw message
arch/arc/boot/dts/axs103.dts new file +24 -0
@@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * Device Tree for AXS103 SDP with AXS10X Main Board and + * AXC003 FPGA Card (with UP bitfile) + */ +/dts-v1/; + +/include/ "axc003.dtsi" +/include/ "axs10x_mb.dtsi" + +/ { + compatible = "snps,axs103", "snps,arc-sdp"; + + chosen { + bootargs = "earlycon=uart8250,mmio32,0xe0022000,115200n8 console=ttyS3,115200n8 debug print-fatal-signals=1"; + }; +};
arch/arc/boot/dts/axs103_idu.dts new file +24 -0
@@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * Device Tree for AXS103 SDP with AXS10X Main Board and + * AXC003 FPGA Card (with SMP bitfile) + */ +/dts-v1/; + +/include/ "axc003_idu.dtsi" +/include/ "axs10x_mb.dtsi" + +/ { + compatible = "snps,axs103", "snps,arc-sdp"; + + chosen { + bootargs = "earlycon=uart8250,mmio32,0xe0022000,115200n8 console=ttyS3,115200n8 debug print-fatal-signals=1"; + }; +};
arch/arc/configs/axs103_defconfig new file +117 -0
117 lines not on this page · raw message
arch/arc/configs/axs103_smp_defconfig new file +118 -0
118 lines not on this page · raw message
arch/arc/kernel/devtree.c +1 -1
@@ -33,7 +33,7 @@ static void __init arc_set_early_base_baud(unsigned long dt_root)if (of_flat_dt_is_compatible (dt_root,"abilis,arc-tb10x" )) arc_base_baud = core_clk/3 ;else if (of_flat_dt_is_compatible (dt_root,"snps,arc-sdp" )) - arc_base_baud =33333333 ;/* Fixed 33MHz clk */ + arc_base_baud =33333333 ;/* Fixed 33MHz clk (AXS10x) */ else arc_base_baud = core_clk; }
arch/arc/plat-axs10x/Kconfig +12 -1
@@ -6,7 +6,7 @@ # published by the Free Software Foundation. # -config ARC_PLAT_AXS10X +menuconfig ARC_PLAT_AXS10X bool "Synopsys ARC AXS10x Software Development Platforms" select DW_APB_ICTL select GPIO_DWAPB
@@ -23,6 +23,7 @@ config ARC_PLAT_AXS10X if ARC_PLAT_AXS10X config AXS101 + depends on ISA_ARCOMPACT bool "AXS101 with AXC001 CPU Card (ARC 770D/EM6/AS221)" help This adds support for the 770D/EM6/AS221 CPU Card. Only the ARC
@@ -32,4 +33,14 @@ config AXS101 this daughtercard. Please use the axs101.dts device tree with this configuration. +config AXS103 + bool "AXS103 with AXC003 CPU Card (ARC HS38x)" + depends on ISA_ARCV2 + help + This adds support for the HS38x CPU Card. + + The AXS103 Platform consists of an AXS10x mainboard with + this daughtercard. Please use the axs103.dts device tree + with this configuration. + endif
arch/arc/plat-axs10x/axs10x.c +188 -10
236 lines not on this page · raw message
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 28/28 ARCv2: [vdk] dts files and defconfig for HS38 VDK
In reply to Vineet GuptaFrom: Ruud Derwig <[email protected]>
- CONFIG_ARC_UBOOT_SUPPORT to handle arguments passed in r0, r1, r2
- CONFIG_DEVTMPFS_MOUNT for mouting rootfs since it uses external cpio for rootfs
--- arch/arc/boot/dts/vdk_axc003.dtsi | 61 +++++++++++++++++++ arch/arc/boot/dts/vdk_axc003_idu.dtsi | 76 +++++++++++++++++++++++ arch/arc/boot/dts/vdk_axs10x_mb.dtsi | 93 ++++++++++++++++++++++++++++ arch/arc/boot/dts/vdk_hs38.dts | 21 +++++++ arch/arc/boot/dts/vdk_hs38_smp.dts | 21 +++++++ arch/arc/configs/vdk_hs38_defconfig | 102 +++++++++++++++++++++++++++++++ arch/arc/configs/vdk_hs38_smp_defconfig | 104 ++++++++++++++++++++++++++++++++ arch/arc/kernel/asm-offsets.c | 2 + arch/arc/mm/tlbex.S | 2 + arch/arc/plat-axs10x/axs10x.c | 8 +++ 10 files changed, 490 insertions(+) create mode 100644 arch/arc/boot/dts/vdk_axc003.dtsi create mode 100644 arch/arc/boot/dts/vdk_axc003_idu.dtsi create mode 100644 arch/arc/boot/dts/vdk_axs10x_mb.dtsi create mode 100644 arch/arc/boot/dts/vdk_hs38.dts create mode 100644 arch/arc/boot/dts/vdk_hs38_smp.dts create mode 100644 arch/arc/configs/vdk_hs38_defconfig create mode 100644 arch/arc/configs/vdk_hs38_smp_defconfig
arch/arc/boot/dts/vdk_axc003.dtsi new file +61 -0
@@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013, 2014 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * Device tree for AXC003 CPU card: HS38x UP configuration (VDK version) + */ + +/ { + compatible = "snps,arc"; + clock-frequency = <50000000>; + #address-cells = <1>; + #size-cells = <1>; + + cpu_card { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + ranges = <0x00000000 0xf0000000 0x10000000>; + + cpu_intc: archs-intc@cpu { + compatible = "snps,archs-intc"; + interrupt-controller; + #interrupt-cells = <1>; + }; + + debug_uart: dw-apb-uart@0x5000 { + compatible = "snps,dw-apb-uart"; + reg = <0x5000 0x100>; + clock-frequency = <2403200>; + interrupt-parent = <&cpu_intc>; + interrupts = <19>; + baud = <115200>; + reg-shift = <2>; + reg-io-width = <4>; + }; + + }; + + mb_intc: dw-apb-ictl@0xe0012000 { + #interrupt-cells = <1>; + compatible = "snps,dw-apb-ictl"; + reg = < 0xe0012000 0x200 >; + interrupt-controller; + interrupt-parent = <&cpu_intc>; + interrupts = < 18 >; + }; + + memory { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x80000000 0x40000000>; + device_type = "memory"; + reg = <0x00000000 0x20000000>; /* 512MiB */ + }; +};
arch/arc/boot/dts/vdk_axc003_idu.dtsi new file +76 -0
76 lines not on this page · raw message
arch/arc/boot/dts/vdk_axs10x_mb.dtsi new file +93 -0
93 lines not on this page · raw message
arch/arc/boot/dts/vdk_hs38.dts new file +21 -0
@@ -0,0 +1,21 @@ +/* + * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com) + * + * ARC HS38 Virtual Development Kit (VDK) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/dts-v1/; + +/include/ "vdk_axc003.dtsi" +/include/ "vdk_axs10x_mb.dtsi" + +/ { + compatible = "snps,axs103"; + + chosen { + bootargs = "earlycon=uart8250,mmio32,0xe0022000,115200n8 console=tty0 console=ttyS3,115200n8 consoleblank=0"; + }; +};
arch/arc/boot/dts/vdk_hs38_smp.dts new file +21 -0
@@ -0,0 +1,21 @@ +/* + * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com) + * + * ARC HS38 Virtual Development Kit, SMP version (VDK) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/dts-v1/; + +/include/ "vdk_axc003_idu.dtsi" +/include/ "vdk_axs10x_mb.dtsi" + +/ { + compatible = "snps,axs103"; + + chosen { + bootargs = "earlycon=uart8250,mmio32,0xe0022000,115200n8 console=tty0 console=ttyS3,115200n8 consoleblank=0"; + }; +};
arch/arc/configs/vdk_hs38_defconfig new file +102 -0
102 lines not on this page · raw message
arch/arc/configs/vdk_hs38_smp_defconfig new file +104 -0
104 lines not on this page · raw message
arch/arc/kernel/asm-offsets.c +2 -0
@@ -37,6 +37,8 @@ int main(void)DEFINE (TASK_ACT_MM , offsetof(struct task_struct , active_mm));DEFINE (TASK_TGID , offsetof(struct task_struct , tgid)); +DEFINE (TASK_PID , offsetof(struct task_struct , pid)); +DEFINE (TASK_COMM , offsetof(struct task_struct , comm));DEFINE (MM_CTXT , offsetof(struct mm_struct , context));DEFINE (MM_PGD , offsetof(struct mm_struct , pgd));
arch/arc/mm/tlbex.S +2 -0
@@ -313,6 +313,7 @@ ENTRY(EV_TLBMissI) CONV_PTE_TO_TLB COMMIT_ENTRY_TO_MMU TLBMISS_RESTORE_REGS +EV_TLBMissI_fast_ret: ; additional label for VDK OS-kit instrumentation rtie END(EV_TLBMissI)
@@ -378,6 +379,7 @@ ENTRY(EV_TLBMissD) COMMIT_ENTRY_TO_MMU TLBMISS_RESTORE_REGS +EV_TLBMissD_fast_ret: ; additional label for VDK OS-kit instrumentation rtie ;-------- Common routine to call Linux Page Fault Handler -----------
arch/arc/plat-axs10x/axs10x.c +8 -0
@@ -15,6 +15,8 @@*/ #include <linux/of_platform.h> + +#include <asm/asm-offsets.h> #include <asm/clk.h> #include <asm/io.h> #include <asm/mach_desc.h>
@@ -473,4 +475,10 @@ MACHINE_START(AXS103, "axs103")#endif MACHINE_END +/* +* For the VDK OS-kit, to get the offset to pid and command fields +*/ +char coware_swa_pid_offset[TASK_PID]; +char coware_swa_comm_offset[TASK_COMM ]; +#endif /* CONFIG_AXS103 */
Signature · 1 line
1.9.1
cover ARCv2 port to Linux - (B) ISA / Core / platform support
Hi,
ARCv2 is the next generation ISA from Synopsys and basis for the HS3{4,6,8} families of processors which retain the traditional ARC mantra of low power and configurability and are now more performant and feature rich.
Linux has been ported to HS38x series, a 10 stage pipeline core which supports MMU (with huge pages) and SMP (upto 4 cores) among other features.
- www.synopsys.com/dw/ipdir.php?ds=arc-hs38-processor
- http://news.synopsys.com/2014-10-14-New-DesignWare-ARC-HS38-Processor-Doubles-Performance-for-Embedded-Linux-Applications
- http://www.embedded.com/electronics-news/4435975/Synopsys-ARC-HS38-core-gives-2X-boost-to-Linux-based-apps
This sub-series builds upon the preparatory patches posted previously [1] and implements the actual ARC HS38x core support.
Please review !
Thx,
-Vineet
[1] https://lkml.org/lkml/2015/6/7/25
Alexey Brodkin (1):
ARC: [axs101] Prepare for AXS103
Claudiu Zissulescu (1):
ARCv2: optimised string/mem lib routines
Ruud Derwig (1):
ARCv2: [vdk] dts files and defconfig for HS38 VDK
Vineet Gupta (25):
ARCv2: [intc] HS38 core interrupt controller
ARCv2: Support for ARCv2 ISA and HS38x cores
ARCv2: STAR 9000793984: Handle return from intr to Delay Slot
ARCv2: STAR 9000808988: signals involving Delay Slot
ARCv2: STAR 9000814690: Really Re-enable interrupts to avoid deadlocks
ARCv2: MMUv4: TLB programming Model changes
ARCv2: MMUv4: cache programming model changes
ARCv2: MMUv4: support aliasing icache config
ARCv2: Adhere to Zero Delay loop restriction
ARCv2: extable: Enable sorting at build time
ARCv2: clocksource: Introduce 64bit local RTC counter
ARC: make plat_smp_ops weak to allow over-rides
ARCv2: SMP: ARConnect debug/robustness
ARCv2: SMP: clocksource: Enable Global Real Time counter
ARCv2: SMP: intc: IDU 2nd level intc for dynamic IRQ distribution
ARC: add compiler barrier to LLSC based cmpxchg
ARC: add smp barriers around atomics per memory-barrriers.txt
arch: conditionally define smp_{mb,rmb,wmb}
ARCv2: barriers
ARC: Reduce bitops lines of code using macros
ARCv2: STAR 9000837815 workaround hardware exclusive transactions
livelock
ARCv2: SLC: Handle explcit flush for DMA ops (w/o IO-coherency)
ARCv2: All bits in place, allow ARCv2 builds
ARCv2: [nsim*hs*] Support simulation platforms for HS38x cores
ARCv2: [axs103] Support ARC SDP FPGA platform for HS38x cores
.../devicetree/bindings/arc/archs-idu-intc.txt | 46 ++ .../devicetree/bindings/arc/archs-intc.txt | 22 + Documentation/devicetree/bindings/arc/axs103.txt | 8 + arch/arc/Kconfig | 130 ++++- arch/arc/Makefile | 8 +- arch/arc/boot/dts/axc001.dtsi | 21 + arch/arc/boot/dts/axc003.dtsi | 102 ++++ arch/arc/boot/dts/axc003_idu.dtsi | 126 +++++ arch/arc/boot/dts/axs103.dts | 24 + arch/arc/boot/dts/axs103_idu.dts | 24 + arch/arc/boot/dts/axs10x_mb.dtsi | 17 - arch/arc/boot/dts/nsim_hs.dts | 53 +++ arch/arc/boot/dts/nsim_hs_idu.dts | 72 +++ arch/arc/boot/dts/nsimosci_hs.dts | 80 ++++ arch/arc/boot/dts/nsimosci_hs_idu.dts | 101 ++++ arch/arc/boot/dts/vdk_axc003.dtsi | 61 +++ arch/arc/boot/dts/vdk_axc003_idu.dtsi | 76 +++ arch/arc/boot/dts/vdk_axs10x_mb.dtsi | 93 ++++ arch/arc/boot/dts/vdk_hs38.dts | 21 + arch/arc/boot/dts/vdk_hs38_smp.dts | 21 + arch/arc/configs/axs103_defconfig | 117 +++++ arch/arc/configs/axs103_smp_defconfig | 118 +++++ arch/arc/configs/nsim_hs_defconfig | 64 +++ arch/arc/configs/nsim_hs_smp_defconfig | 63 +++ arch/arc/configs/nsimosci_hs_defconfig | 73 +++ arch/arc/configs/nsimosci_hs_smp_defconfig | 93 ++++ arch/arc/configs/vdk_hs38_defconfig | 102 ++++ arch/arc/configs/vdk_hs38_smp_defconfig | 104 ++++ arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/arcregs.h | 60 ++- arch/arc/include/asm/atomic.h | 24 +- arch/arc/include/asm/barrier.h | 48 ++ arch/arc/include/asm/bitops.h | 522 ++++++++------------- arch/arc/include/asm/cache.h | 18 +- arch/arc/include/asm/cmpxchg.h | 19 +- arch/arc/include/asm/delay.h | 9 +- arch/arc/include/asm/elf.h | 5 + arch/arc/include/asm/entry-arcv2.h | 190 ++++++++ arch/arc/include/asm/entry.h | 21 +- arch/arc/include/asm/irq.h | 6 + arch/arc/include/asm/irqflags-arcv2.h | 124 +++++ arch/arc/include/asm/irqflags-compact.h | 2 + arch/arc/include/asm/irqflags.h | 4 + arch/arc/include/asm/mcip.h | 94 ++++ arch/arc/include/asm/mmu.h | 24 +- arch/arc/include/asm/pgtable.h | 10 + arch/arc/include/asm/ptrace.h | 43 ++ arch/arc/include/asm/spinlock.h | 10 + arch/arc/include/asm/thread_info.h | 1 + arch/arc/include/asm/uaccess.h | 17 +- arch/arc/kernel/Makefile | 4 +- arch/arc/kernel/asm-offsets.c | 5 + arch/arc/kernel/devtree.c | 2 +- arch/arc/kernel/entry-arcv2.S | 239 ++++++++++ arch/arc/kernel/head.S | 2 - arch/arc/kernel/intc-arcv2.c | 126 +++++ arch/arc/kernel/mcip.c | 341 ++++++++++++++ arch/arc/kernel/process.c | 12 +- arch/arc/kernel/ptrace.c | 2 +- arch/arc/kernel/setup.c | 56 ++- arch/arc/kernel/signal.c | 6 +- arch/arc/kernel/smp.c | 22 +- arch/arc/kernel/time.c | 95 ++++ arch/arc/kernel/troubleshoot.c | 33 +- arch/arc/lib/Makefile | 6 +- arch/arc/lib/memcmp.S | 30 +- arch/arc/lib/memcpy-archs.S | 236 ++++++++++ arch/arc/lib/memset-archs.S | 93 ++++ arch/arc/lib/strcmp-archs.S | 78 +++ arch/arc/mm/cache.c | 188 +++++++- arch/arc/mm/dma.c | 12 + arch/arc/mm/tlb.c | 54 ++- arch/arc/mm/tlbex.S | 28 +- arch/arc/plat-axs10x/Kconfig | 13 +- arch/arc/plat-axs10x/axs10x.c | 206 +++++++- arch/arc/plat-sim/platform.c | 7 + include/asm-generic/barrier.h | 25 + scripts/sortextable.c | 5 + 78 files changed, 4567 insertions(+), 451 deletions(-) create mode 100644 Documentation/devicetree/bindings/arc/archs-idu-intc.txt create mode 100644 Documentation/devicetree/bindings/arc/archs-intc.txt create mode 100644 Documentation/devicetree/bindings/arc/axs103.txt create mode 100644 arch/arc/boot/dts/axc003.dtsi create mode 100644 arch/arc/boot/dts/axc003_idu.dtsi create mode 100644 arch/arc/boot/dts/axs103.dts create mode 100644 arch/arc/boot/dts/axs103_idu.dts create mode 100644 arch/arc/boot/dts/nsim_hs.dts create mode 100644 arch/arc/boot/dts/nsim_hs_idu.dts create mode 100644 arch/arc/boot/dts/nsimosci_hs.dts create mode 100644 arch/arc/boot/dts/nsimosci_hs_idu.dts create mode 100644 arch/arc/boot/dts/vdk_axc003.dtsi create mode 100644 arch/arc/boot/dts/vdk_axc003_idu.dtsi create mode 100644 arch/arc/boot/dts/vdk_axs10x_mb.dtsi create mode 100644 arch/arc/boot/dts/vdk_hs38.dts create mode 100644 arch/arc/boot/dts/vdk_hs38_smp.dts create mode 100644 arch/arc/configs/axs103_defconfig create mode 100644 arch/arc/configs/axs103_smp_defconfig create mode 100644 arch/arc/configs/nsim_hs_defconfig create mode 100644 arch/arc/configs/nsim_hs_smp_defconfig create mode 100644 arch/arc/configs/nsimosci_hs_defconfig create mode 100644 arch/arc/configs/nsimosci_hs_smp_defconfig create mode 100644 arch/arc/configs/vdk_hs38_defconfig create mode 100644 arch/arc/configs/vdk_hs38_smp_defconfig create mode 100644 arch/arc/include/asm/barrier.h create mode 100644 arch/arc/include/asm/entry-arcv2.h create mode 100644 arch/arc/include/asm/irqflags-arcv2.h create mode 100644 arch/arc/include/asm/mcip.h create mode 100644 arch/arc/kernel/entry-arcv2.S create mode 100644 arch/arc/kernel/intc-arcv2.c create mode 100644 arch/arc/kernel/mcip.c create mode 100644 arch/arc/lib/memcpy-archs.S create mode 100644 arch/arc/lib/memset-archs.S create mode 100644 arch/arc/lib/strcmp-archs.S
Signature · 1 line
1.9.1
PATCH 6/28 ARCv2: MMUv4: TLB programming Model changes
--- arch/arc/Kconfig | 5 ++++ arch/arc/include/asm/arcregs.h | 2 +- arch/arc/include/asm/mmu.h | 24 ++++++++++++++++++- arch/arc/include/asm/pgtable.h | 10 ++++++++ arch/arc/mm/tlb.c | 54 +++++++++++++++++++++++++++++++++++++++--- arch/arc/mm/tlbex.S | 24 +++++++++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-)
arch/arc/Kconfig +5 -0
@@ -267,6 +267,7 @@ choice prompt "MMU Version" default ARC_MMU_V3 if ARC_CPU_770 default ARC_MMU_V2 if ARC_CPU_750D + default ARC_MMU_V4 if ARC_CPU_HS config ARC_MMU_V1 bool "MMU v1"
@@ -287,6 +288,10 @@ config ARC_MMU_V3 Variable Page size (1k-16k), var JTLB size 128 x (2 or 4) Shared Address Spaces (SASID) +config ARC_MMU_V4 + bool "MMU v4" + depends on ISA_ARCV2 + endchoice
arch/arc/include/asm/arcregs.h +1 -1
@@ -325,7 +325,7 @@ struct bcr_generic {*/ struct cpuinfo_arc_mmu { -unsigned int ver:4 , pg_sz_k:8 , pad:8 , u_dtlb:6 , u_itlb:6 ; +unsigned int ver:4 , pg_sz_k:8 , s_pg_sz_m:8 , u_dtlb:6 , u_itlb:6 ;unsigned int num_tlb:16 , sets:12 , ways:4 ; };
arch/arc/include/asm/mmu.h +23 -1
@@ -15,24 +15,41 @@#define CONFIG_ARC_MMU_VER 2#elif defined(CONFIG_ARC_MMU_V3 )#define CONFIG_ARC_MMU_VER 3 +#elif defined(CONFIG_ARC_MMU_V4 ) +#define CONFIG_ARC_MMU_VER 4#endif /* MMU Management regs */ #define ARC_REG_MMU_BCR 0x06f +#if (CONFIG_ARC_MMU_VER <4 )#define ARC_REG_TLBPD0 0x405#define ARC_REG_TLBPD1 0x406#define ARC_REG_TLBINDEX 0x407#define ARC_REG_TLBCOMMAND 0x408#define ARC_REG_PID 0x409#define ARC_REG_SCRATCH_DATA0 0x418 +#else +#define ARC_REG_TLBPD0 0x460 +#define ARC_REG_TLBPD1 0x461 +#define ARC_REG_TLBINDEX 0x464 +#define ARC_REG_TLBCOMMAND 0x465 +#define ARC_REG_PID 0x468 +#define ARC_REG_SCRATCH_DATA0 0x46c +#endif /* Bits in MMU PID register */ -#define MMU_ENABLE (1 << 31)/* Enable MMU for process */ +#define __TLB_ENABLE (1 << 31) +#define __PROG_ENABLE (1 << 30) +#define MMU_ENABLE (__TLB_ENABLE | __PROG_ENABLE)/* Error code if probe fails */ #define TLB_LKUP_ERR 0x80000000 +#if (CONFIG_ARC_MMU_VER <4 )#define TLB_DUP_ERR (TLB_LKUP_ERR | 0x00000001) +#else +#define TLB_DUP_ERR (TLB_LKUP_ERR | 0x40000000) +#endif /* TLB Commands */ #define TLBWrite 0x1
@@ -45,6 +62,11 @@#define TLBIVUTLB 0x6/* explicitly inv uTLBs */ #endif +#if (CONFIG_ARC_MMU_VER >=4 ) +#define TLBInsertEntry 0x7 +#define TLBDeleteEntry 0x8 +#endif + #ifndef __ASSEMBLY__ typedef struct {
arch/arc/include/asm/pgtable.h +10 -0
@@ -72,8 +72,18 @@#define _PAGE_READ (1<<3)/* Page has user read perm (H) */ #define _PAGE_ACCESSED (1<<4)/* Page is accessed (S) */ #define _PAGE_MODIFIED (1<<5)/* Page modified (dirty) (S) */ + +#if (CONFIG_ARC_MMU_VER >=4 ) +#define _PAGE_WTHRU (1<<7)/* Page cache mode write-thru (H) */ +#endif +#define _PAGE_GLOBAL (1<<8)/* Page is global (H) */ #define _PAGE_PRESENT (1<<9)/* TLB entry is valid (H) */ + +#if (CONFIG_ARC_MMU_VER >=4 ) +#define _PAGE_SZ (1<<10)/* Page Size indicator (H) */ +#endif +#define _PAGE_SHARED_CODE (1<<11)/* Shared Code page with cmn vaddr usable for shared TLB entries (H) */ #endif
arch/arc/mm/tlb.c +51 -3
92 lines not on this page · raw message
arch/arc/mm/tlbex.S +24 -0
@@ -44,6 +44,7 @@ #include <asm/processor.h> #include <asm/tlb-mmu1.h> +#ifdef CONFIG_ISA_ARCOMPACT ;----------------------------------------------------------------- ; ARC700 Exception Handling doesn't auto-switch stack and it only provides ; ONE scratch AUX reg "ARC_REG_SCRATCH_DATA0"
@@ -121,6 +122,24 @@ ex_saved_reg1: #endif .endm +#else /* ARCv2 */ + +.macro TLBMISS_FREEUP_REGS + PUSH r0 + PUSH r1 + PUSH r2 + PUSH r3 +.endm + +.macro TLBMISS_RESTORE_REGS + POP r3 + POP r2 + POP r1 + POP r0 +.endm + +#endif + ;============================================================================ ; Troubleshooting Stuff ;============================================================================
@@ -239,6 +258,7 @@ ex_saved_reg1: ; Commit the TLB entry into MMU .macro COMMIT_ENTRY_TO_MMU +#if (CONFIG_ARC_MMU_VER < 4) /* Get free TLB slot: Set = computed from vaddr, way = random */ sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
@@ -249,6 +269,10 @@ ex_saved_reg1: #else sr TLBWrite, [ARC_REG_TLBCOMMAND] #endif + +#else + sr TLBInsertEntry, [ARC_REG_TLBCOMMAND] +#endif .endm
Signature · 1 line
1.9.1
PATCH 8/28 ARCv2: MMUv4: support aliasing icache config
In reply to Vineet GuptaThis is also default for AXS103 release
--- arch/arc/include/asm/cache.h | 4 +--- arch/arc/mm/cache.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)
arch/arc/include/asm/cache.h +1 -3
@@ -60,7 +60,7 @@ extern void read_decode_cache_bcr(void);#define ARC_REG_IC_IVIC 0x10#define ARC_REG_IC_CTRL 0x11#define ARC_REG_IC_IVIL 0x19 -#if defined(CONFIG_ARC_MMU_V3 ) +#if defined(CONFIG_ARC_MMU_V3 ) || defined(CONFIG_ARC_MMU_V4 )#define ARC_REG_IC_PTAG 0x1E#endif
@@ -74,9 +74,7 @@ extern void read_decode_cache_bcr(void);#define ARC_REG_DC_IVDL 0x4A#define ARC_REG_DC_FLSH 0x4B#define ARC_REG_DC_FLDL 0x4C -#if defined(CONFIG_ARC_MMU_V3 )#define ARC_REG_DC_PTAG 0x5C -#endif /* Bit val in DC_CTRL */ #define DC_CTRL_INV_MODE_FLUSH 0x40
arch/arc/mm/cache.c +13 -1
@@ -21,6 +21,9 @@#include <asm/cachectl.h> #include <asm/setup.h> +void (*_cache_line_loop_ic_fn)(unsigned long paddr,unsigned long vaddr, +unsigned long sz,const int cacheop); +char *arc_cache_mumbojumbo (int c,char *buf,int len) {int n =0 ;
@@ -414,7 +417,7 @@ __ic_line_inv_vaddr_local(unsigned long paddr, unsigned long vaddr,unsigned long flags;local_irq_save (flags); -__cache_line_loop (paddr, vaddr, sz,OP_INV_IC ); + (*_cache_line_loop_ic_fn)(paddr, vaddr, sz,OP_INV_IC );local_irq_restore (flags); }
@@ -746,6 +749,15 @@ void arc_cache_init(void)if (ic->ver !=CONFIG_ARC_MMU_VER )panic ("Cache ver [%d] doesn't match MMU ver [%d]\n" , ic->ver,CONFIG_ARC_MMU_VER ); + +/* +* In MMU v4 (HS38x) the alising icache config uses IVIL/PTAG +* pair to provide vaddr/paddr respectively, just as in MMU v3 +*/ +if (is_isa_arcv2 () && ic->alias) + _cache_line_loop_ic_fn = __cache_line_loop_v3; +else + _cache_line_loop_ic_fn = __cache_line_loop; }if (IS_ENABLED (CONFIG_ARC_HAS_DCACHE )) {
Signature · 1 line
1.9.1
PATCH 11/28 ARCv2: extable: Enable sorting at build time
In reply to Vineet Gupta--- scripts/sortextable.c | 5 +++++ 1 file changed, 5 insertions(+)
scripts/sortextable.c +5 -0
@@ -47,6 +47,10 @@#define EM_MICROBLAZE 189#endif +#ifndef EM_ARCV2 +#define EM_ARCV2 195 +#endif +static int fd_map;/* File descriptor for file being modified. */ static int mmap_failed;/* Boolean flag. */ static void *ehdr_curr;/* current ElfXX_Ehdr * for resource cleanup */
@@ -281,6 +285,7 @@ do_file(char const *const fname) custom_sort = sort_relative_table;break ;case EM_ARCOMPACT : +case EM_ARCV2 :case EM_ARM :case EM_AARCH64 :case EM_MICROBLAZE :
Signature · 1 line
1.9.1
PATCH 4/28 ARCv2: STAR 9000808988: signals involving Delay Slot
In reply to Vineet GuptaReported by Anton as LTP:munmap01 failing with Illegal Instruction Exception.
--------------------->8-------------------------------------- mmap2(NULL, 24576, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x200d2000
munmap(0x200d2000, 24576) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x200d2000}
---
potentially unexpected fatal signal 4.
Path: /munmap01
CPU: 0 PID: 61 Comm: munmap01 Not tainted 3.13.0-g5d5c46d9a556 #8 task: 9f1a8000 ti: 9f154000 task.ti: 9f154000
[ECR ]: 0x00020100 => Illegal Insn
[EFA ]: 0x0001354c
[BLINK ]: 0x200515d4
[ERET ]: 0x1354c
@off 0x1354c in [/munmap01]
VMA: 0x00010000 to 0x00018000 [STAT32]: 0x800802c0
...
--------------------->8--------------------------------------
The issue was
1. munmap01 accessed unmapped memory (on purpose) with signal handler installed for SIGSEGV
2. The faulting instruction happened to be in Delay Slot 00011864 <main>:
11908: bl.d 13284 <tst_resm>
1190c: stb r16,[r2]3. kernel sets up the reg file for signal handler and correctly clears the DE bit in pt_regs->status32 placeholder
4. However RESTORE_CALLEE_SAVED_USER macro is not adjusted for ARCv2, and it over-writes the above with orig/stale value of status32
5. After RTIE, userspace signal handler executes a non branch instruction with DE bit set, triggering Illegal Instruction Exception.
--- arch/arc/include/asm/entry.h | 17 ++++++++++------- arch/arc/kernel/asm-offsets.c | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-)
arch/arc/include/asm/entry.h +10 -7
@@ -125,8 +125,6 @@ POP r13 .endm -#define OFF_USER_R25_FROM_R24 (SZ_CALLEE_REGS + SZ_PT_REGS - 8)/4 -/*-------------------------------------------------------------- * Collect User Mode callee regs as struct callee_regs - needed by * fork/do_signal/unaligned-access-emulation.
@@ -139,12 +137,13 @@*-------------------------------------------------------------*/ .macro SAVE_CALLEE_SAVED_USER + mov r12, sp ; save SP as ref to pt_regs SAVE_R13_TO_R24#ifdef CONFIG_ARC_CURR_IN_REG - ; Retrieve orig r25 and save it on stack - ld.as r12, [sp, OFF_USER_R25_FROM_R24] - st.a r12, [sp, -4] + ; Retrieve orig r25 and save it with rest of callee_regs + ld.as r12, [r12, PT_user_r25] + PUSH r12#else PUSH r25#endif
@@ -191,12 +190,16 @@ .macro RESTORE_CALLEE_SAVED_USER#ifdef CONFIG_ARC_CURR_IN_REG - ld.ab r12, [sp, 4] - st.as r12, [sp, OFF_USER_R25_FROM_R24] + POP r12#else POP r25#endif RESTORE_R24_TO_R13 + + ; SP is back to start of pt_regs +#ifdef CONFIG_ARC_CURR_IN_REG + st.as r12, [sp, PT_user_r25] +#endif .endm/*--------------------------------------------------------------
arch/arc/kernel/asm-offsets.c +2 -0
@@ -60,5 +60,7 @@ int main(void)DEFINE (SZ_CALLEE_REGS ,sizeof (struct callee_regs ));DEFINE (SZ_PT_REGS ,sizeof (struct pt_regs )); +DEFINE (PT_user_r25, offsetof(struct pt_regs , user_r25)); +return 0 ; }
Signature · 1 line
1.9.1
PATCH 10/28 ARCv2: Adhere to Zero Delay loop restriction
In reply to Vineet GuptaBranch insn can't be scheduled as last insn of Zero Overhead loop
--- arch/arc/include/asm/delay.h | 9 ++++----- arch/arc/include/asm/uaccess.h | 17 ++++++++--------- arch/arc/lib/memcmp.S | 30 +++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 15 deletions(-)
arch/arc/include/asm/delay.h +4 -5
@@ -22,11 +22,10 @@static inline void __delay (unsigned long loops) { __asm__ __volatile__( -"1: sub.f %0, %0, 1 \n" -" jpnz 1b \n" - :"+r" (loops) - : - :"cc" ); +" lp 1f \n" +" nop \n" +"1: \n" + :"+l" (loops)); }extern void __bad_udelay (void );
arch/arc/include/asm/uaccess.h +8 -9
@@ -659,31 +659,30 @@ static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)static inline long __arc_strncpy_from_user (char *dst,const char __user *src,long count) { -long res = count; +long res =0 ;char val; -unsigned int hw_count;if (count ==0 )return 0 ; __asm__ __volatile__( -" lp 2f \n" +" lp 3f \n" "1: ldb.ab %3, [%2, 1] \n" -" breq.d %3, 0, 2f \n" +" breq.d %3, 0, 3f \n" " stb.ab %3, [%1, 1] \n" -"2: sub %0, %6, %4 \n" -"3: ;nop \n" +" add %0, %0, 1 # Num of NON NULL bytes copied \n" +"3: \n" " .section .fixup, \"ax\" \n" " .align 4 \n" -"4: mov %0, %5 \n" +"4: mov %0, %4 # sets @res as -EFAULT \n" " j 3b \n" " .previous \n" " .section __ex_table, \"a\" \n" " .align 4 \n" " .word 1b, 4b \n" " .previous \n" - :"=r" (res),"+r" (dst),"+r" (src),"=&r" (val),"=l" (hw_count) - :"g" (-EFAULT ),"ir" (count),"4" (count)/* this "4" seeds lp_count */ + :"+r" (res),"+r" (dst),"+r" (src),"=r" (val) + :"g" (-EFAULT ),"l" (count) :"memory" );return res;
arch/arc/lib/memcmp.S +29 -1
@@ -24,14 +24,32 @@ ENTRY(memcmp) ld r4,[r0,0] ld r5,[r1,0] lsr.f lp_count,r3,3 +#ifdef CONFIG_ISA_ARCV2 + /* In ARCv2 a branch can't be the last instruction in a zero overhead + * loop. + * So we move the branch to the start of the loop, duplicate it + * after the end, and set up r12 so that the branch isn't taken + * initially. + */ + mov_s r12,WORD2 + lpne .Loop_end + brne WORD2,r12,.Lodd + ld WORD2,[r0,4] +#else lpne .Loop_end ld_s WORD2,[r0,4] +#endif ld_s r12,[r1,4] brne r4,r5,.Leven ld.a r4,[r0,8] ld.a r5,[r1,8] +#ifdef CONFIG_ISA_ARCV2 +.Loop_end: + brne WORD2,r12,.Lodd +#else brne WORD2,r12,.Lodd .Loop_end: +#endif asl_s SHIFT,SHIFT,3 bhs_s .Last_cmp brne r4,r5,.Leven
@@ -89,7 +107,6 @@ ENTRY(memcmp) bset.cs r0,r0,31 .Lodd: cmp_s WORD2,r12 - mov_s r0,1 j_s.d [blink] bset.cs r0,r0,31
@@ -100,14 +117,25 @@ ENTRY(memcmp) ldb r4,[r0,0] ldb r5,[r1,0] lsr.f lp_count,r3 +#ifdef CONFIG_ISA_ARCV2 + mov r12,r3 lpne .Lbyte_end + brne r3,r12,.Lbyte_odd +#else + lpne .Lbyte_end +#endif ldb_s r3,[r0,1] ldb r12,[r1,1] brne r4,r5,.Lbyte_even ldb.a r4,[r0,2] ldb.a r5,[r1,2] +#ifdef CONFIG_ISA_ARCV2 +.Lbyte_end: + brne r3,r12,.Lbyte_odd +#else brne r3,r12,.Lbyte_odd .Lbyte_end: +#endif bcc .Lbyte_even brne r4,r5,.Lbyte_even ldb_s r3,[r0,1]
Signature · 1 line
1.9.1
PATCH 12/28 ARCv2: clocksource: Introduce 64bit local RTC counter
In reply to Vineet Gupta--- arch/arc/Kconfig | 5 +++++ arch/arc/kernel/setup.c | 9 +++++++-- arch/arc/kernel/time.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-)
arch/arc/Kconfig +5 -0
@@ -372,6 +372,11 @@ config ARC_HAS_LL64 dest operands with 2 possible source operands. default y +config ARC_HAS_RTC + bool "Local 64-bit r/o cycle counter" + default n + depends on !SMP + config ARC_NUMBER_OF_INTERRUPTS int "Number of interrupts" range 8 240
arch/arc/kernel/setup.c +7 -2
@@ -200,9 +200,11 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len) (unsigned int )(arc_get_core_freq () /1000000 ), (unsigned int)(arc_get_core_freq() / 10000) % 100); - n +=scnprintf (buf + n, len - n,"Timers\t\t: %s%s\nISA Extn\t: " , + n +=scnprintf (buf + n, len - n,"Timers\t\t: %s%s%s%s\nISA Extn\t: " ,IS_AVAIL1 (cpu->timers.t0,"Timer0 " ), -IS_AVAIL1 (cpu->timers.t1,"Timer1 " )); +IS_AVAIL1 (cpu->timers.t1,"Timer1 " ), +IS_AVAIL2 (cpu->timers.rtc,"64-bit RTC " , +CONFIG_ARC_HAS_RTC )); n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s", IS_AVAIL2(atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
@@ -290,6 +292,9 @@ static void arc_chk_core_config(void)if (!cpu->timers.t1)panic ("Timer1 is not present!\n" ); +if (IS_ENABLED (CONFIG_ARC_HAS_RTC ) && !cpu->timers.rtc) +panic ("RTC is not present\n" ); +#ifdef CONFIG_ARC_HAS_DCCM /* * DCCM can be arbit placed in hardware.
arch/arc/kernel/time.c +50 -0
62 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 13/28 ARC: make plat_smp_ops weak to allow over-rides
In reply to Vineet GuptaThis allows platforms to provide their own cpu wakeup routines as well as IPI send / clear backends, while allowing a SMP kernel w/o any such backend to build/boot
--- arch/arc/Kconfig | 21 +++++--- arch/arc/include/asm/irq.h | 1 + arch/arc/include/asm/mcip.h | 91 +++++++++++++++++++++++++++++++++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/intc-arcv2.c | 2 +- arch/arc/kernel/mcip.c | 117 +++++++++++++++++++++++++++++++++++++++++++ arch/arc/kernel/smp.c | 2 +- arch/arc/plat-sim/platform.c | 5 ++ 8 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 arch/arc/include/asm/mcip.h create mode 100644 arch/arc/kernel/mcip.c
arch/arc/Kconfig +14 -7
@@ -160,12 +160,12 @@ config CPU_BIG_ENDIAN Build kernel for Big Endian Mode of ARC CPU config SMP - bool "Symmetric Multi-Processing (Incomplete)" + bool "Symmetric Multi-Processing" default n + select ARC_HAS_COH_CACHES if ISA_ARCV2 + select ARC_MCIP if ISA_ARCV2 help - This enables support for systems with more than one CPU. If you have - a system with only one CPU, say N. If you have a system with more - than one CPU, say Y. + This enables support for systems with more than one CPU. if SMP
@@ -175,13 +175,20 @@ config ARC_HAS_COH_CACHES config ARC_HAS_REENTRANT_IRQ_LV2 def_bool n -endif #SMP +config ARC_MCIP + bool "ARConnect Multicore IP (MCIP) Support " + depends on ISA_ARCV2 + help + This IP block enables SMP in ARC-HS38 cores. + It provides for cross-core interrupts, multi-core debug + hardware semaphores, shared memory,.... config NR_CPUS int "Maximum number of CPUs (2-4096)" range 2 4096 - depends on SMP - default "2" + default "4" + +endif #SMP menuconfig ARC_CACHE bool "Enable Cache Support"
arch/arc/include/asm/irq.h +1 -0
@@ -19,6 +19,7 @@#else #define TIMER0_IRQ 16#define TIMER1_IRQ 17 +#define IPI_IRQ 19#endif #include <linux/interrupt.h>
arch/arc/include/asm/mcip.h new file +91 -0
91 lines not on this page · raw message
arch/arc/kernel/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o +obj-$(CONFIG_ARC_MCIP) += mcip.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_EMUL_UNALIGNED) += unaligned.o
arch/arc/kernel/intc-arcv2.c +1 -1
@@ -90,7 +90,7 @@ static struct irq_chip arcv2_irq_chip = {static int arcv2_irq_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw) { -if (irq ==TIMER0_IRQ ) +if (irq ==TIMER0_IRQ || irq ==IPI_IRQ )irq_set_chip_and_handler (irq, &arcv2_irq_chip, handle_percpu_irq);else irq_set_chip_and_handler (irq, &arcv2_irq_chip, handle_level_irq);
arch/arc/kernel/mcip.c new file +117 -0
117 lines not on this page · raw message
arch/arc/kernel/smp.c +1 -1
@@ -31,7 +31,7 @@ arch_spinlock_t smp_atomic_ops_lock = __ARCH_SPIN_LOCK_UNLOCKED;arch_spinlock_t smp_bitops_lock = __ARCH_SPIN_LOCK_UNLOCKED;#endif -struct plat_smp_ops plat_smp_ops; +struct plat_smp_ops __weak plat_smp_ops;/* XXX: per cpu ? Only needed once in early seconday boot */ struct task_struct *secondary_idle_tsk;
arch/arc/plat-sim/platform.c +5 -0
@@ -10,6 +10,7 @@#include <linux/init.h> #include <asm/mach_desc.h> +#include <asm/mcip.h> /*----------------------- Machine Descriptions ------------------------------ *
@@ -27,4 +28,8 @@ static const char *simulation_compat[] __initconst = {MACHINE_START (SIMULATION ,"simulation" ) .dt_compat = simulation_compat, +#ifdef CONFIG_ARC_MCIP + .init_early = mcip_init_early_smp, + .init_smp = mcip_init_smp, +#endifMACHINE_END
Signature · 1 line
1.9.1
PATCH 15/28 ARCv2: SMP: clocksource: Enable Global Real Time counter
In reply to Vineet Gupta--- arch/arc/Kconfig | 5 +++++ arch/arc/include/asm/mcip.h | 3 +++ arch/arc/kernel/mcip.c | 3 +++ arch/arc/kernel/time.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+)
arch/arc/Kconfig +5 -0
@@ -384,6 +384,11 @@ config ARC_HAS_RTC default n depends on !SMP +config ARC_HAS_GRTC + bool "SMP synchronized 64-bit cycle counter" + default y + depends on SMP + config ARC_NUMBER_OF_INTERRUPTS int "Number of interrupts" range 8 240
arch/arc/include/asm/mcip.h +3 -0
@@ -39,6 +39,9 @@ struct mcip_cmd {#define CMD_DEBUG_SET_MASK 0x34#define CMD_DEBUG_SET_SELECT 0x36 +#define CMD_GRTC_READ_LO 0x42 +#define CMD_GRTC_READ_HI 0x43 +#define CMD_IDU_ENABLE 0x71#define CMD_IDU_DISABLE 0x72#define CMD_IDU_SET_MODE 0x74
arch/arc/kernel/mcip.c +3 -0
@@ -154,4 +154,7 @@ void mcip_init_early_smp(void)__mcip_cmd_data (CMD_DEBUG_SET_SELECT ,0 ,0xf );__mcip_cmd_data (CMD_DEBUG_SET_MASK ,0xf ,0xf ); } + +if (IS_ENABLED (CONFIG_ARC_HAS_GRTC ) && !mp.grtc) +panic ("kernel trying to use non-existent GRTC\n" ); }
arch/arc/kernel/time.c +45 -0
63 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 17/28 ARC: add compiler barrier to LLSC based cmpxchg
In reply to Vineet GuptaWhen auditing cmpxchg call sites, Chuck noted that gcc was optimizing away some of the desired LDs.
| do {
| new = old = *ipi_data_ptr;
| new |= 1U << msg;
| } while (cmpxchg(ipi_data_ptr, old, new) != old);was generating to below
| 8015cef8: ld r2,[r4,0] <-- First LD | 8015cefc: bset r1,r2,r1 | | 8015cf00: llock r3,[r4] <-- atomic op | 8015cf04: brne r3,r2,8015cf10 | 8015cf08: scond r1,[r4] | 8015cf0c: bnz 8015cf00 | | 8015cf10: brne r3,r2,8015cf00 <-- Branch doesn't go to orig LD
Although this was fixed by adding a ACCESS_ONCE in this call site, it seems safer (for now at least) to add compiler barrier to LLSC based cmpxchg
--- arch/arc/include/asm/cmpxchg.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arc/include/asm/cmpxchg.h +5 -4
@@ -25,10 +25,11 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)" scond %3, [%1] \n" " bnz 1b \n" "2: \n" - : "=&r"(prev) - : "r"(ptr), "ir"(expected), -" r"(new) /* can't be " ir". scond can't take limm for " b" */ - : "cc"); + : "=&r"(prev) /* Early clobber, to prevent reg reuse */ + : "r"(ptr), /* Not "m": llock only supports reg direct addr mode */ +" ir"(expected), +" r"(new) /* can't be " ir". scond can't take LIMM for " b" */ + : "cc", "memory"); /* so that gcc knows memory is being written here */ return prev; }
Signature · 1 line
1.9.1
PATCH 21/28 ARC: Reduce bitops lines of code using macros
In reply to Vineet GuptaNo semantical changes !
--- arch/arc/include/asm/bitops.h | 463 +++++++++++++----------------------------- 1 file changed, 137 insertions(+), 326 deletions(-)
arch/arc/include/asm/bitops.h +137 -326
@@ -18,83 +18,50 @@#include <linux/types.h> #include <linux/compiler.h> #include <asm/barrier.h> +#ifndef CONFIG_ARC_HAS_LLSC +#include <asm/smp.h> +#endif -/* -* Hardware assisted read-modify-write using ARC700 LLOCK/SCOND insns. -* The Kconfig glue ensures that in SMP, this is only set if the container -* SoC/platform has cross-core coherent LLOCK/SCOND -*/ #if defined(CONFIG_ARC_HAS_LLSC ) -static inline void set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -/* -* ARC ISA micro-optimization: -* -* Instructions dealing with bitpos only consider lower 5 bits (0-31) -* e.g (x << 33) is handled like (x << 1) by ASL instruction -* (mem pointer still needs adjustment to point to next word) -* -* Hence the masking to clamp @nr arg can be elided in general. -* -* However if @nr is a constant (above assumed it in a register), -* and greater than 31, gcc can optimize away (x << 33) to 0, -* as overflow, given the 32-bit ISA. Thus masking needs to be done -* for constant @nr, but no code is generated due to const prop. -*/ -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bset %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); -} - -static inline void clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bclr %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); -} - -static inline void change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; +/* +* Hardware assisted Atomic-R-M-W +*/ - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bxor %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); +#define BIT_OP (op, c_op, asm_op) \ +static inline void op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned int temp; \ + \ + m += nr >> 5; \ + \ +/* \ +* ARC ISA micro-optimization: \ +* \ +* Instructions dealing with bitpos only consider lower 5 bits \ +* e.g (x << 33) is handled like (x << 1) by ASL instruction \ +* (mem pointer still needs adjustment to point to next word) \ +* \ +* Hence the masking to clamp @nr arg can be elided in general. \ +* \ +* However if @nr is a constant (above assumed in a register), \ +* and greater than 31, gcc can optimize away (x << 33) to 0, \ +* as overflow, given the 32-bit ISA. Thus masking needs to be \ +* done for const @nr, but no code is generated due to gcc \ +* const prop. \ +*/ \ +if (__builtin_constant_p (nr)) \ + nr &=0x1f ; \ + \ + __asm__ __volatile__( \ +"1: llock %0, [%1] \n" \ + " " #asm_op " %0, %0, %2 \n" \ +" scond %0, [%1] \n" \ +" bnz 1b \n" \ + :"=&r" (temp)/* Early clobber, to prevent reg reuse */ \ + :"r" (m),/* Not "m": llock only supports reg direct addr mode */ \ +"ir" (nr) \ + : "cc"); \ }/*
@@ -108,87 +75,34 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *m)* Since ARC lacks a equivalent h/w primitive, the bit is set unconditionally * and the old value of bit is returned */ -static inline int test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bset %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bclr %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bxor %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; +#define TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old, temp; \ + \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + smp_mb(); \ + \ + __asm__ __volatile__( \ + "1: llock %0, [%2] \n" \ + " " #asm_op " %1, %0, %3 \n" \ + " scond %1, [%2] \n" \ + " bnz 1b \n" \ + : "=&r"(old), "=&r"(temp) \ + : "r"(m), "ir"(nr) \ + : "cc"); \ + \ + smp_mb(); \ + \ + return (old & (1 << nr)) != 0; \ }#else /* !CONFIG_ARC_HAS_LLSC */ -#include <asm/smp.h> -/* * Non hardware assisted Atomic-R-M-W * Locking would change to irq-disabling only (UP) and spinlocks (SMP)
@@ -205,108 +119,40 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)* at compile time) */ -static inline void set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp | (1UL << nr); - -bitops_unlock (flags); -} - -static inline void clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp & ~(1UL << nr); - -bitops_unlock (flags); -} - -static inline void change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp ^ (1UL << nr); - -bitops_unlock (flags); +#define BIT_OP (op, c_op, asm_op) \ +static inline void op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long temp, flags; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + bitops_lock(flags); \ + \ + temp = *m; \ + *m = temp c_op (1UL << nr); \ + \ + bitops_unlock(flags); \ } -static inline int test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - old = *m; - *m = old | (1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - old = *m; - *m = old & ~(1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - old = *m; - *m = old ^ (1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; +#define TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old, flags; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + bitops_lock(flags); \ + \ + old = *m; \ + *m = old c_op (1 << nr); \ + \ + bitops_unlock(flags); \ + \ + return (old & (1 << nr)) != 0; \ }#endif /* CONFIG_ARC_HAS_LLSC */
@@ -315,86 +161,51 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)* Non atomic variants **************************************/ -static inline void __set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp | (1UL << nr); -} - -static inline void __clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp & ~(1UL << nr); -} - -static inline void __change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp ^ (1UL << nr); -} - -static inline int -__test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old | (1 << nr); - -return (old & (1 << nr)) !=0 ; +#define __BIT_OP (op, c_op, asm_op) \ +static inline void __##op##_bit(unsigned long nr, volatile unsigned long *m) \ +{ \ + unsigned long temp; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + temp = *m; \ + *m = temp c_op (1UL << nr); \ } -static inline int -__test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old & ~(1 << nr); - -return (old & (1 << nr)) !=0 ; +#define __TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int __test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + old = *m; \ + *m = old c_op (1 << nr); \ + \ + return (old & (1 << nr)) != 0; \ } -static inline int -__test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old ^ (1 << nr); - -return (old & (1 << nr)) !=0 ; -} +#define BIT_OPS (op, c_op, asm_op) \ + \ +/* set_bit(), clear_bit(), change_bit() */ \ + BIT_OP(op, c_op, asm_op) \ + \ +/* test_and_set_bit(), test_and_clear_bit(), test_and_change_bit() */ \ +TEST_N_BIT_OP (op, c_op, asm_op) \ + \ + /* __set_bit(), __clear_bit(), __change_bit() */ \ +__BIT_OP (op, c_op, asm_op) \ + \ + /* __test_and_set_bit(), __test_and_clear_bit(), __test_and_change_bit() */\ + __TEST_N_BIT_OP(op, c_op, asm_op) + +BIT_OPS(set, |, bset) +BIT_OPS(clear, & ~, bclr) +BIT_OPS(change, ^, bxor)/* * This routine doesn't need to be atomic.
Signature · 1 line
1.9.1
PATCH 24/28 ARCv2: All bits in place, allow ARCv2 builds
In reply to Vineet Gupta--- arch/arc/Kconfig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/arc/Kconfig +4 -5
@@ -97,11 +97,10 @@ config ISA_ARCOMPACT help The original ARC ISA of ARC600/700 cores -### For bisectability, disable ARCv2 support until we have all the bits in place -#config ISA_ARCV2 -# bool "ARC ISA v2" -# help -# ISA for the Next Generation ARC-HS cores +config ISA_ARCV2 + bool "ARC ISA v2" + help + ISA for the Next Generation ARC-HS cores endchoice
Signature · 1 line
1.9.1
PATCH 1/28 ARCv2: [intc] HS38 core interrupt controller
In reply to Vineet Gupta--- .../devicetree/bindings/arc/archs-intc.txt | 22 ++++ arch/arc/include/asm/irqflags-arcv2.h | 116 +++++++++++++++++++ arch/arc/kernel/intc-arcv2.c | 126 +++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 Documentation/devicetree/bindings/arc/archs-intc.txt create mode 100644 arch/arc/include/asm/irqflags-arcv2.h create mode 100644 arch/arc/kernel/intc-arcv2.c
Documentation/devicetree/bindings/arc/archs-intc.txt new file +22 -0
@@ -0,0 +1,22 @@ +* ARC-HS incore Interrupt Controller (Provided by cores implementing ARCv2 ISA) + +Properties: + +- compatible: "snps,archs-intc" +- interrupt-controller: This is an interrupt controller. +- #interrupt-cells: Must be <1>. + + Single Cell "interrupts" property of a device specifies the IRQ number + between 16 to 256 + + intc accessed via the special ARC AUX register interface, hence "reg" property + is not specified. + +Example: + + intc: interrupt-controller { + compatible = "snps,archs-intc"; + interrupt-controller; + #interrupt-cells = <1>; + interrupts = <16 17 18 19 20 21 22 23 24 25>; + };
arch/arc/include/asm/irqflags-arcv2.h new file +116 -0
116 lines not on this page · raw message
arch/arc/kernel/intc-arcv2.c new file +126 -0
126 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 2/28 ARCv2: Support for ARCv2 ISA and HS38x cores
In reply to Vineet GuptaThe notable features are:
- SMP configurations of upto 4 cores with coherency
- Optional L2 Cache and IO-Coherency
- Revised Interrupt Architecture (multiple priorites, reg banks, auto stack switch, auto regfile save/restore)
- MMUv4 (PIPT dcache, Huge Pages)
- Instructions for
* 64bit load/store: LDD, STD
* Hardware assisted divide/remainder: DIV, REM
* Function prologue/epilogue: ENTER_S, LEAVE_S
* IRQ enable/disable: CLRI, SETI
* pop count: FFS, FLS
* SETcc, BMSKN, XBFU...
--- arch/arc/Kconfig | 80 +++++++++++++- arch/arc/Makefile | 8 +- arch/arc/include/asm/arcregs.h | 53 ++++++++- arch/arc/include/asm/bitops.h | 71 ++++++++++++ arch/arc/include/asm/elf.h | 5 + arch/arc/include/asm/entry-arcv2.h | 190 ++++++++++++++++++++++++++++++++ arch/arc/include/asm/entry.h | 4 + arch/arc/include/asm/irq.h | 5 + arch/arc/include/asm/irqflags-arcv2.h | 3 + arch/arc/include/asm/irqflags-compact.h | 2 + arch/arc/include/asm/irqflags.h | 4 + arch/arc/include/asm/ptrace.h | 43 ++++++++ arch/arc/include/asm/thread_info.h | 1 + arch/arc/kernel/Makefile | 3 +- arch/arc/kernel/entry-arcv2.S | 189 +++++++++++++++++++++++++++++++ arch/arc/kernel/head.S | 2 - arch/arc/kernel/process.c | 12 +- arch/arc/kernel/ptrace.c | 2 +- arch/arc/kernel/setup.c | 45 +++++++- arch/arc/kernel/signal.c | 6 +- arch/arc/kernel/troubleshoot.c | 33 +++++- arch/arc/mm/tlbex.S | 2 - 22 files changed, 730 insertions(+), 33 deletions(-) create mode 100644 arch/arc/include/asm/entry-arcv2.h create mode 100644 arch/arc/kernel/entry-arcv2.S
arch/arc/Kconfig +75 -5
@@ -88,11 +88,31 @@ source "arch/arc/plat-axs10x/Kconfig" endmenu +choice + prompt "ARC Instruction Set" + default ISA_ARCOMPACT + +config ISA_ARCOMPACT + bool "ARCompact ISA" + help + The original ARC ISA of ARC600/700 cores + +### For bisectability, disable ARCv2 support until we have all the bits in place +#config ISA_ARCV2 +# bool "ARC ISA v2" +# help +# ISA for the Next Generation ARC-HS cores + +endchoice + menu "ARC CPU Configuration" choice prompt "ARC Core" - default ARC_CPU_770 + default ARC_CPU_770 if ISA_ARCOMPACT + default ARC_CPU_HS if ISA_ARCV2 + +if ISA_ARCOMPACT config ARC_CPU_750D bool "ARC750D"
@@ -110,6 +130,27 @@ config ARC_CPU_770 -Caches: New Prog Model, Region Flush -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr +endif #ISA_ARCOMPACT + +config ARC_CPU_HS + bool "ARC-HS" + depends on ISA_ARCV2 + help + Support for ARC HS38x Cores based on ARCv2 ISA + The notable features are: + - SMP configurations of upto 4 core with coherency + - Optional L2 Cache and IO-Coherency + - Revised Interrupt Architecture (multiple priorites, reg banks, + auto stack switch, auto regfile save/restore) + - MMUv4 (PIPT dcache, Huge Pages) + - Instructions for + * 64bit load/store: LDD, STD + * Hardware assisted divide/remainder: DIV, REM + * Function prologue/epilogue: ENTER_S, LEAVE_S + * IRQ enable/disable: CLRI, SETI + * pop count: FFS, FLS + * SETcc, BMSKN, XBFU... + endchoice config CPU_BIG_ENDIAN
@@ -134,7 +175,7 @@ config ARC_HAS_COH_CACHES config ARC_HAS_REENTRANT_IRQ_LV2 def_bool n -endif +endif #SMP config NR_CPUS int "Maximum number of CPUs (2-4096)"
@@ -223,7 +264,7 @@ config ARC_HAS_HW_MPY Multipler. Otherwise software multipy lib is used choice - prompt "ARC700 MMU Version" + prompt "MMU Version" default ARC_MMU_V3 if ARC_CPU_770 default ARC_MMU_V2 if ARC_CPU_750D
@@ -268,6 +309,8 @@ config ARC_PAGE_SIZE_4K endchoice +if ISA_ARCOMPACT + config ARC_COMPACT_IRQ_LEVELS bool "ARCompact IRQ Priorities: High(2)/Low(1)" default n
@@ -287,7 +330,7 @@ config ARC_IRQ5_LV2 config ARC_IRQ6_LV2 bool -endif +endif #ARC_COMPACT_IRQ_LEVELS config ARC_FPU_SAVE_RESTORE bool "Enable FPU state persistence across context switch"
@@ -300,18 +343,43 @@ config ARC_FPU_SAVE_RESTORE based on actual usage of FPU by a task. Thus our implemn does this for all tasks in system. +endif #ISA_ARCOMPACT + config ARC_CANT_LLSC def_bool n config ARC_HAS_LLSC bool "Insn: LLOCK/SCOND (efficient atomic ops)" default y - depends on ARC_CPU_770 && !ARC_CANT_LLSC + depends on !ARC_CPU_750D && !ARC_CANT_LLSC config ARC_HAS_SWAPE bool "Insn: SWAPE (endian-swap)" default y +if ISA_ARCV2 + +config ARC_HAS_LL64 + bool "Insn: 64bit LDD/STD" + help + Enable gcc to generate 64-bit load/store instructions + ISA mandates even/odd registers to allow encoding of two + dest operands with 2 possible source operands. + default y + +config ARC_NUMBER_OF_INTERRUPTS + int "Number of interrupts" + range 8 240 + default 32 + help + This defines the number of interrupts on the ARCv2HS core. + It affects the size of vector table. + The initial 8 IRQs are fixed (Timer, ICI etc) and although configurable + in hardware, it keep things simple for Linux to assume they are always + present. + +endif # ISA_ARCV2 + endmenu # "ARC CPU Configuration" config LINUX_LINK_BASE
@@ -337,8 +405,10 @@ config ARC_CURR_IN_REG config ARC_EMUL_UNALIGNED bool "Emulate unaligned memory access (userspace only)" + default N select SYSCTL_ARCH_UNALIGN_NO_WARN select SYSCTL_ARCH_UNALIGN_ALLOW + depends on ISA_ARCOMPACT help This enables misaligned 16 & 32 bit memory access from user space. Use ONLY-IF-ABS-NECESSARY as it will be very slow and also can hide
arch/arc/Makefile +7 -1
@@ -14,7 +14,9 @@ endif KBUILD_DEFCONFIG := nsim_700_defconfig -cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__ +cflags-y += -fno-common -pipe -fno-builtin -D__linux__ +cflags-${CONFIG_ISA_ARCOMPACT} += -mA7 +cflags-${CONFIG_ISA_ARCV2} += -mcpu=archs ifdef CONFIG_ARC_CURR_IN_REG # For a global register defintion, make sure it gets passed to every file
@@ -34,6 +36,10 @@ cflags-$(atleast_gcc44) += -fsection-anchors cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape +ifndef CONFIG_ARC_HAS_LL64 +cflags-y += -mno-ll64 +endif + cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables # By default gcc 4.8 generates dwarf4 which kernel unwinder can't grok
arch/arc/include/asm/arcregs.h +49 -4
99 lines not on this page · raw message
arch/arc/include/asm/bitops.h +71 -0
83 lines not on this page · raw message
arch/arc/include/asm/elf.h +5 -0
@@ -15,6 +15,11 @@/* These ELF defines belong to uapi but libc elf.h already defines them */ #define EM_ARCOMPACT 93 +#define EM_ARCV2 195/* ARCv2 Cores */ + +#define EM_ARC_INUSE (IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \ + EM_ARCOMPACT : EM_ARCV2) +/* ARC Relocations (kernel Modules only) */ #define R_ARC_32 0x4#define R_ARC_32_ME 0x1B
arch/arc/include/asm/entry-arcv2.h new file +190 -0
190 lines not on this page · raw message
arch/arc/include/asm/entry.h +4 -0
@@ -16,7 +16,11 @@#include <asm/processor.h> /* For VMALLOC_START */ #include <asm/mmu.h> +#ifdef CONFIG_ISA_ARCOMPACT #include <asm/entry-compact.h> /* ISA specific bits */ +#else +#include <asm/entry-arcv2.h> +#endif /* Note on the LD/ST addr modes with addr reg wback *
arch/arc/include/asm/irq.h +5 -0
@@ -13,8 +13,13 @@#define NR_IRQS 128/* allow some CPU external IRQ handling */ /* Platform Independent IRQs */ +#ifdef CONFIG_ISA_ARCOMPACT #define TIMER0_IRQ 3#define TIMER1_IRQ 4 +#else +#define TIMER0_IRQ 16 +#define TIMER1_IRQ 17 +#endif #include <linux/interrupt.h> #include <asm-generic/irq.h>
arch/arc/include/asm/irqflags-arcv2.h +3 -0
@@ -27,6 +27,9 @@#define AUX_IRQ_SELECT 0x40b#define AUX_IRQ_ENABLE 0x40c +/* Was Intr taken in User Mode */ +#define AUX_IRQ_ACT_BIT_U 31 +/* 0 is highest level, but taken by FIRQs, if present in design */ #define ARCV2_IRQ_DEF_PRIO 0
arch/arc/include/asm/irqflags-compact.h +2 -0
@@ -39,6 +39,8 @@#define AUX_ITRIGGER 0x40d#define AUX_IPULSE 0x415 +#define ISA_INIT_STATUS_BITS STATUS_IE_MASK +#ifndef __ASSEMBLY__/******************************************************************
arch/arc/include/asm/irqflags.h +4 -0
@@ -10,6 +10,10 @@#ifndef __ASM_ARC_IRQFLAGS_H#define __ASM_ARC_IRQFLAGS_H +#ifdef CONFIG_ISA_ARCOMPACT #include <asm/irqflags-compact.h> +#else +#include <asm/irqflags-arcv2.h> +#endif #endif
arch/arc/include/asm/ptrace.h +43 -0
55 lines not on this page · raw message
arch/arc/include/asm/thread_info.h +1 -0
@@ -25,6 +25,7 @@#endif #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) +#define THREAD_SHIFT (PAGE_SHIFT << THREAD_SIZE_ORDER)#ifndef __ASSEMBLY__
arch/arc/kernel/Makefile +2 -1
@@ -10,7 +10,8 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o process.o devtree.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o -obj-y += entry-compact.o intc-compact.o +obj-$(CONFIG_ISA_ARCOMPACT) += entry-compact.o intc-compact.o +obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o
arch/arc/kernel/entry-arcv2.S new file +189 -0
189 lines not on this page · raw message
arch/arc/kernel/head.S +0 -2
@@ -49,8 +49,6 @@ 1: .endm - .cpu A7 - .section .init.text, "ax",@progbits .type stext, @function .globl stext
arch/arc/kernel/process.c +9 -3
@@ -44,7 +44,10 @@ SYSCALL_DEFINE0(arc_gettls)void arch_cpu_idle (void ) {/* sleep, but enable all interrupts before committing */ - __asm__("sleep 0x3" ); +if (is_isa_arcompact ()) + __asm__("sleep 0x3" ); +else + __asm__("sleep 0x10" ); } asmlinkage void ret_from_fork(void);
@@ -166,7 +169,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long usp)* [L] ZOL loop inhibited to begin with - cleared by a LP insn * Interrupts enabled */ - regs->status32 =STATUS_U_MASK |STATUS_L_MASK |STATUS_IE_MASK ; + regs->status32 =STATUS_U_MASK |STATUS_L_MASK |ISA_INIT_STATUS_BITS ;/* bogus seed values for debugging */ regs->lp_start =0x10 ;
@@ -196,8 +199,11 @@ int elf_check_arch(const struct elf32_hdr *x) {unsigned int eflags; -if (x->e_machine !=EM_ARCOMPACT ) +if (x->e_machine !=EM_ARC_INUSE ) { +pr_err ("ELF not built for %s ISA\n" , +is_isa_arcompact () ?"ARCompact" :"ARCv2" );return 0 ; + } eflags = x->e_flags;if ((eflags &EF_ARC_OSABI_MSK ) <EF_ARC_OSABI_CURRENT ) {
arch/arc/kernel/ptrace.c +1 -1
@@ -200,7 +200,7 @@ static const struct user_regset arc_regsets[] = {static const struct user_regset_view user_arc_view = { .name =UTS_MACHINE , - .e_machine =EM_ARCOMPACT , + .e_machine =EM_ARC_INUSE , .regsets = arc_regsets, .n =ARRAY_SIZE (arc_regsets) };
arch/arc/kernel/setup.c +40 -5
86 lines not on this page · raw message
arch/arc/kernel/signal.c +3 -3
@@ -336,7 +336,7 @@ static void arc_restart_syscall(struct k_sigaction *ka, struct pt_regs *regs)* their orig user space value when we ret from kernel */ regs->r0 = regs->orig_r0; - regs->ret -=4 ; + regs->ret -=is_isa_arcv2 () ?2 :4 ;break ; } }
@@ -377,10 +377,10 @@ void do_signal(struct pt_regs *regs)if (regs->r0 == -ERESTARTNOHAND || regs->r0 == -ERESTARTSYS || regs->r0 == -ERESTARTNOINTR ) { regs->r0 = regs->orig_r0; - regs->ret -=4 ; + regs->ret -=is_isa_arcv2 () ?2 :4 ; }else if (regs->r0 == -ERESTART_RESTARTBLOCK ) { regs->r8 = __NR_restart_syscall; - regs->ret -=4 ; + regs->ret -=is_isa_arcv2 () ?2 :4 ; }syscall_wont_restart (regs);/* No more restarts */ }
arch/arc/kernel/troubleshoot.c +27 -6
@@ -14,6 +14,7 @@#include <linux/proc_fs.h> #include <linux/file.h> #include <asm/arcregs.h> +#include <asm/irqflags.h> /* * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25)
@@ -34,7 +35,10 @@ static noinline void print_reg_file(long *reg_rev, int start_num) n +=scnprintf (buf + n, len - n,"\n" );/* because pt_regs has regs reversed: r12..r0, r25..r13 */ - reg_rev--; +if (is_isa_arcv2 () && start_num ==0 ) + reg_rev++; +else + reg_rev--; }if (start_num !=0 )
@@ -152,6 +156,15 @@ static void show_ecr_verbose(struct pt_regs *regs) ((cause_code == 0x02) ? "Write" : "EX")); }else if (vec ==ECR_V_INSN_ERR ) {pr_cont ("Illegal Insn\n" ); +#ifdef CONFIG_ISA_ARCV2 + }else if (vec ==ECR_V_MEM_ERR ) { +if (cause_code ==0x00 ) +pr_cont ("Bus Error from Insn Mem\n" ); +else if (cause_code ==0x10 ) +pr_cont ("Bus Error from Data Mem\n" ); +else +pr_cont ("Bus Error, check PRM\n" ); +#endif }else {pr_cont ("Check Programmer's Manual\n" ); }
@@ -185,12 +198,20 @@ void show_regs(struct pt_regs *regs)pr_info ("[STAT32]: 0x%08lx" , regs->status32); -#define STS_BIT (r, bit) r->status32 & STATUS_##bit##_MASK ? #bit : "" -if (!user_mode (regs)) -pr_cont (" : %2s %2s %2s %2s %2s\n" , -STS_BIT (regs,AE ),STS_BIT (regs,A2 ),STS_BIT (regs,A1 ), -STS_BIT (regs,E2 ),STS_BIT (regs,E1 )); +#define STS_BIT (r, bit) r->status32 & STATUS_##bit##_MASK ? #bit" " : "" +#ifdef CONFIG_ISA_ARCOMPACT +pr_cont (" : %2s%2s%2s%2s%2s%2s%2s\n" , + (regs->status32 &STATUS_U_MASK ) ?"U " :"K " , +STS_BIT (regs,DE ),STS_BIT (regs,AE ), +STS_BIT (regs,A2 ),STS_BIT (regs,A1 ), +STS_BIT (regs,E2 ),STS_BIT (regs,E1 )); +#else +pr_cont (" : %2s%2s%2s%2s\n" , +STS_BIT (regs,IE ), + (regs->status32 &STATUS_U_MASK ) ?"U " :"K " , +STS_BIT (regs,DE ),STS_BIT (regs,AE )); +#endif pr_info ("BTA: 0x%08lx\t SP: 0x%08lx\t FP: 0x%08lx\n" , regs->bta, regs->sp, regs->fp); pr_info("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
arch/arc/mm/tlbex.S +0 -2
@@ -35,8 +35,6 @@ * Rahul Trivedi, Amit Bhor: Codito Technologies 2004 */ - .cpu A7 - #include <linux/linkage.h> #include <asm/entry.h> #include <asm/mmu.h>
Signature · 1 line
1.9.1
PATCH 3/28 ARCv2: STAR 9000793984: Handle return from intr to Delay Slot
In reply to Vineet Gupta--- arch/arc/kernel/asm-offsets.c | 1 + arch/arc/kernel/entry-arcv2.S | 50 +++++++++++++++++++++++++++++++++++++++++++ arch/arc/kernel/setup.c | 2 ++ 3 files changed, 53 insertions(+)
arch/arc/kernel/asm-offsets.c +1 -0
@@ -56,6 +56,7 @@ int main(void)DEFINE (PT_r5, offsetof(struct pt_regs , r5));DEFINE (PT_r6, offsetof(struct pt_regs , r6));DEFINE (PT_r7, offsetof(struct pt_regs , r7)); +DEFINE (PT_ret, offsetof(struct pt_regs , ret));DEFINE (SZ_CALLEE_REGS ,sizeof (struct callee_regs ));DEFINE (SZ_PT_REGS ,sizeof (struct pt_regs ));
arch/arc/kernel/entry-arcv2.S +50 -0
60 lines not on this page · raw message
arch/arc/kernel/setup.c +2 -0
@@ -30,6 +30,8 @@#define FIX_PTR (x) __asm__ __volatile__(";" : "+r"(x)) +unsigned int intr_to_DE_cnt; +/* Part of U-boot ABI: see head.S */ int __initdata uboot_tag;char __initdata *uboot_arg;
Signature · 1 line
1.9.1
PATCH 9/28 ARCv2: optimised string/mem lib routines
In reply to Vineet GuptaFrom: Claudiu Zissulescu <[email protected]>
--- arch/arc/lib/Makefile | 6 +- arch/arc/lib/memcpy-archs.S | 236 ++++++++++++++++++++++++++++++++++++++++++++ arch/arc/lib/memset-archs.S | 93 +++++++++++++++++ arch/arc/lib/strcmp-archs.S | 78 +++++++++++++++ 4 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 arch/arc/lib/memcpy-archs.S create mode 100644 arch/arc/lib/memset-archs.S create mode 100644 arch/arc/lib/strcmp-archs.S
arch/arc/lib/Makefile +4 -2
@@ -5,5 +5,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -lib-y := strchr-700.o strcmp.o strcpy-700.o strlen.o -lib-y += memcmp.o memcpy-700.o memset.o +lib-y := strchr-700.o strcpy-700.o strlen.o memcmp.o + +lib-$(CONFIG_ISA_ARCOMPACT) += memcpy-700.o memset.o strcmp.o +lib-$(CONFIG_ISA_ARCV2) += memcpy-archs.o memset-archs.o strcmp-archs.o
arch/arc/lib/memcpy-archs.S new file +236 -0
236 lines not on this page · raw message
arch/arc/lib/memset-archs.S new file +93 -0
93 lines not on this page · raw message
arch/arc/lib/strcmp-archs.S new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 20/28 ARCv2: barriers
In reply to Vineet Gupta--- arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/barrier.h | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 arch/arc/include/asm/barrier.h
arch/arc/include/asm/Kbuild +0 -1
@@ -1,5 +1,4 @@ generic-y += auxvec.h -generic-y += barrier.h generic-y += bitsperlong.h generic-y += bugs.h generic-y += clkdev.h
arch/arc/include/asm/barrier.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 16/28 ARCv2: SMP: intc: IDU 2nd level intc for dynamic IRQ distribution
In reply to Vineet Gupta--- .../devicetree/bindings/arc/archs-idu-intc.txt | 46 ++++++ arch/arc/kernel/mcip.c | 183 ++++++++++++++++++++- 2 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/arc/archs-idu-intc.txt
Documentation/devicetree/bindings/arc/archs-idu-intc.txt new file +46 -0
@@ -0,0 +1,46 @@ +* ARC-HS Interrupt Distribution Unit + + This optional 2nd level interrupt controller can be used in SMP configurations for + dynamic IRQ routing, load balancing of common/external IRQs towards core intc. + +Properties: + +- compatible: "snps,archs-idu-intc" +- interrupt-controller: This is an interrupt controller. +- interrupt-parent: <reference to parent core intc> +- #interrupt-cells: Must be <2>. +- interrupts: <...> specifies the upstream core irqs + + First cell specifies the "common" IRQ from peripheral to IDU + Second cell specifies the irq distribution mode to cores + 0=Round Robin; 1=cpu0, 2=cpu1, 4=cpu2, 8=cpu3 + + intc accessed via the special ARC AUX register interface, hence "reg" property + is not specified. + +Example: + core_intc: core-interrupt-controller { + compatible = "snps,archs-intc"; + interrupt-controller; + #interrupt-cells = <1>; + }; + + idu_intc: idu-interrupt-controller { + compatible = "snps,archs-idu-intc"; + interrupt-controller; + interrupt-parent = <&core_intc>; + + /* + * <hwirq distribution> + * distribution: 0=RR; 1=cpu0, 2=cpu1, 4=cpu2, 8=cpu3 + */ + #interrupt-cells = <2>; + + /* upstream core irqs: downstream these are "COMMON" irq 0,1.. */ + interrupts = <24 25 26 27 28 29 30 31>; + }; + + some_device: serial@c0fc1000 { + interrupt-parent = <&idu_intc>; + interrupts = <0 0>; /* upstream idu IRQ #24, Round Robin */ + };
arch/arc/kernel/mcip.c +182 -1
201 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 17/28] ARC: add compiler barrier to LLSC based cmpxchg
In reply to Vineet GuptaQuoted 20 lines · Vineet Gupta
When auditing cmpxchg call sites, Chuck noted that gcc was optimizing away some of the desired LDs.
| do { | new = old = *ipi_data_ptr; | new |= 1U << msg; | } while (cmpxchg(ipi_data_ptr, old, new) != old);was generating to below
| 8015cef8: ld r2,[r4,0] <-- First LD | 8015cefc: bset r1,r2,r1 | | 8015cf00: llock r3,[r4] <-- atomic op | 8015cf04: brne r3,r2,8015cf10 | 8015cf08: scond r1,[r4] | 8015cf0c: bnz 8015cf00 | | 8015cf10: brne r3,r2,8015cf00 <-- Branch doesn't go to orig LD
Quoted 3 lines
Although this was fixed by adding a
ACCESS_ONCEin this call site, it seems safer (for now at least) to add compiler barrier to LLSC based cmpxchg
This is required even. cmpxchg() should include a full memory barrier _before_ and _after_ the op. Both imply a compiler barrier.
Peter Zijlstra
maintainerRe: [PATCH 18/28] ARC: add smp barriers around atomics per memory-barrriers.txt
In reply to Vineet GuptaOn Tue, Jun 09, 2015 at 05:18:18PM +0530, Vineet Gupta wrote:
Please try and provide at least _some_ Changelog body.
<snip all atomic ops that return values>
Quoted 27 lines
arch/arc/include/asm/spinlock.h +6
-0@@ -22,24 +22,32 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" " breq %0, %2, 1b \n" :"+&r" (tmp) :"r" (&(lock->slock)),"ir" (__ARCH_SPIN_LOCK_LOCKED__) :"memory" ); + +smp_mb (); }static inline int arch_spin_trylock (arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__(
arch/arc/include/asm/spinlock.h static inline void arch_spin_lock(arch_spinlock_t *lock) · line 53
Quoted 10 lines
arch/arc/include/asm/spinlock.h +2
-0"1: ex %0, [%1] \n" : "+r" (tmp) : "r"(&(lock->slock)) : "memory"); + smp_mb(); +return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__); }
Both these are only required to provide an ACQUIRE barrier, if all you have is smp_mb(), the second is sufficient.
Also note that a failed trylock is not required to provide _any_ barrier at all.
arch/arc/include/asm/spinlock.h static inline void arch_spin_unlock(arch_spinlock_t *lock) · line 62
Quoted 9 lines
arch/arc/include/asm/spinlock.h +2
-0@@ -47,6 +55,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__; +smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" : "+r" (tmp)
This requires a RELEASE barrier, again, if all you have is smp_mb(), this is indeed correct.
Describing some of this would make for a fine Changelog body :-)
Re: [PATCH 19/28] arch: conditionally define smp_{mb,rmb,wmb}
In reply to Vineet GuptaQuoted 5 lines · Vineet Gupta
That way arches can define the minimal versions and still #include asm-generic for defaults (vs. defining defaults in arch code)
See new
barrier.hin arc for usage !
Fair enough,
Peter Zijlstra
maintainerRe: [PATCH 22/28] ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Vineet GuptaOn Tue, Jun 09, 2015 at 05:18:22PM +0530, Vineet Gupta wrote:
This really really wants a Changelog describing the actual hardware fail and why this workaround is sufficient.
Peter Zijlstra
maintainerRe: [PATCH 20/28] ARCv2: barriers
In reply to Vineet GuptaOn Tue, Jun 09, 2015 at 05:18:20PM +0530, Vineet Gupta wrote:
A description of how your hardware works; or a reference to the platform documentation would not go amiss.
Quoted 24 lines
+++
b/arch/arc/include/asm/barrier.harch/arc/include/asm/barrier.h new file +22
-0@@ -0,0 +1,48 @@ +/* +* Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __ASM_BARRIER_H +#define __ASM_BARRIER_H + +#ifdef CONFIG_SMP + +#ifdef CONFIG_ISA_ARCV2 + +/* +* DMB: +* - Ensures that selected memory operation issued before it will complete +* before any subsequent memory operation of same type +*/ +#define smp_mb () asm volatile("dmb 3\n" : : : "memory") +#define smp_rmb () asm volatile("dmb 1\n" : : : "memory")
arch/arc/include/asm/barrier.h line 32
Quoted 10 lines
arch/arc/include/asm/barrier.h new file +10
-0+#define smp_wmb () asm volatile("dmb 2\n" : : : "memory") + +/* +* DSYNC: +* - Waits for completion of all outstanding memory operations before any new +* operations can begin +* - Includes implicit memory operations such as cache/TLB/BPU maintenance ops +* - Lighter version of SYNC as it doesn't wait for non-memory operations +*/ +#define mb () asm volatile("dsync\n" : : : "memory")
So mb() is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.
Quoted 9 lines
arch/arc/include/asm/barrier.h new file +9
-0+#else /* CONFIG_ISA_ARCOMPACT */ + +/* SYNC: +* - Waits for completion of all outstanding memory transactions AND all +* previous instructions to reture +*/ +#define mb () asm volatile("sync\n" : : : "memory") + +#endif /* CONFIG_ISA_ARCV2 */
Re: [PATCH 18/28] ARC: add smp barriers around atomics per memory-barrriers.txt
In reply to Peter ZijlstraQuoted 5 lines · Peter Zijlstra
On Tue, Jun 09, 2015 at 05:18:18PM +0530, Vineet Gupta wrote:
Please try and provide at least _some_ Changelog body.
<snip all atomic ops that return values>
Will do as comments in source as well as commit log in v2.
Quoted 32 lines
Quoted 32 lines
arch/arc/include/asm/spinlock.h +6
-0@@ -22,24 +22,32 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" " breq %0, %2, 1b \n" :"+&r" (tmp) :"r" (&(lock->slock)),"ir" (__ARCH_SPIN_LOCK_LOCKED__) :"memory" ); + +smp_mb (); }static inline int arch_spin_trylock (arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" :"+r" (tmp) :"r" (&(lock->slock)) :"memory" );
Quoted 7 lines
arch/arc/include/asm/spinlock.h static inline void arch_spin_lock(arch_spinlock_t *lock) · line 53
Quoted 5 lines
arch/arc/include/asm/spinlock.h +2
-0+smp_mb (); +return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__); }Both these are only required to provide an ACQUIRE barrier, if all you have is
smp_mb(), the second is sufficient.
Essentially ARCv2 is weakly ordered with explicit ordering provided by DMB instructions with semantics load/load, store/store, all/all.
I wanted to clarify a couple of things
(1) ACQUIRE barrier implies store/{store,load} while RELEASE implies {load,store}/store and given what DMB provides for ARCv2, smp_mb() is the only fit ?
(2) Do we need smp_mb() on both sides of spin lock/unlock - doesn't ACQUIRE imply we have a smp_mb() after lock but before any subsequent critical section - so the top hunk is not necessarily needed. Similarly RELEASE requires a smp_mb() before the memory operation for lock, but not after.
Quoted 2 lines
Also note that a failed trylock is not required to provide _any_ barrier at all.
But that means wrapping the barrier in a branch etc, I'd rather keep them uniform for now - unless we see performance hits due to that. I suppose all of that is more relevant for heavy metal 4k cpu stuff ?
Quoted 5 lines
Quoted 5 lines
arch/arc/include/asm/spinlock.h +0
-0@@ -47,6 +55,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__;
Quoted 7 lines
arch/arc/include/asm/spinlock.h static inline void arch_spin_unlock(arch_spinlock_t *lock) · line 62
Quoted 5 lines
arch/arc/include/asm/spinlock.h +2
-0+smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" : "+r" (tmp)This requires a RELEASE barrier, again, if all you have is
smp_mb(), this is indeed correct.
Ok, actually we already had a smp_mb() in the end of this function - but depending on what ur reply is to #2 above we can remove that (as a seperate commit)
Quoted 2 lines
Describing some of this would make for a fine Changelog body :-)
I will spin a v2 after your response, with more informative changelog.
Thx for the review.
-Vineet
Re: [PATCH 20/28] ARCv2: barriers
In reply to Peter ZijlstraQuoted 4 lines · Peter Zijlstra
On Tue, Jun 09, 2015 at 05:18:20PM +0530, Vineet Gupta wrote:
A description of how your hardware works; or a reference to the platform documentation would not go amiss.
Honestly the docs group is working on a publicly sharable version of PRM (Programmer's Reference Manual) but it might take some more time. I'm sure kernel developers including you don't like to sign an NDA.... The information I have in comments is pretty much what we have in there w.r.t. the barrier instructions. But I will capture the the weak memory ordering and other details as part of changelog here too.
Quoted 12 lines
Quoted 12 lines
[snip ....]
arch/arc/include/asm/barrier.h new file +11
-0+/* +* DMB: +* - Ensures that selected memory operation issued before it will complete +* before any subsequent memory operation of same type +*/ +#define smp_mb () asm volatile("dmb 3\n" : : : "memory") +#define smp_rmb () asm volatile("dmb 1\n" : : : "memory") +#define smp_wmb () asm volatile("dmb 2\n" : : : "memory") + +/* +* DSYNC:
Quoted 8 lines
Quoted 6 lines
+ * - Waits for completion of all outstanding memory operations before any new
+ * operations can begin
+ * - Includes implicit memory operations such as cache/TLB/BPU maintenance ops
+ * - Lighter version of SYNC as it doesn't wait for non-memory operations
+ */
+#definemb()asmvolatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how mb() can possibly order with DMA per se (unless there's some advanced form of IO-coherency)
-Vineet
Quoted 12 lines
Quoted 10 lines
arch/arc/include/asm/barrier.h new file +9
-0+#else /* CONFIG_ISA_ARCOMPACT */ + +/* SYNC: +* - Waits for completion of all outstanding memory transactions AND all +* previous instructions to reture +*/ +#define mb () asm volatile("sync\n" : : : "memory") + +#endif /* CONFIG_ISA_ARCV2 */
Re: [PATCH 22/28] ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Peter ZijlstraOn Tuesday 09 June 2015 06:05 PM, Peter Zijlstra wrote:
On Tue, Jun 09, 2015 at 05:18:22PM +0530, Vineet Gupta wrote:
This really really wants a Changelog describing the actual hardware fail and why this workaround is sufficient.
OK - I need some more time to rehash the exact details with our hardware folks. But AFAIKR, this was hardware livelock in llock/scond when 2 cores were doing r-m-w to two different words in the same cache line - adding prefetchw (prefetch with a write intent) would get the line in exclusive state and break the livelock.
The test itself was one from EEMBC Multibench but I'll have to look it up.
Wasn't there something similar in ARM world too - they have some sort of snoop-delayed exclusive handling in hardware to mitigate something similar although as Will later remarked it involved llock/scond with vanilla ld/st to same line/word ?
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/254142.html
Thx,
-Vineet
Peter Zijlstra
maintainerRe: [PATCH 18/28] ARC: add smp barriers around atomics per memory-barrriers.txt
In reply to Vineet GuptaQuoted 21 lines · Vineet Gupta
Quoted 6 lines
Quoted 6 lines
arch/arc/include/asm/spinlock.h +0
-0@@ -22,24 +22,32 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__;Quoted 14 lines
arch/arc/include/asm/spinlock.h static inline void arch_spin_lock(arch_spinlock_t *lock) · line 35
Quoted 11 lines
arch/arc/include/asm/spinlock.h +4
-0+smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" " breq %0, %2, 1b \n" :"+&r" (tmp) :"r" (&(lock->slock)),"ir" (__ARCH_SPIN_LOCK_LOCKED__) :"memory" ); + +smp_mb (); }Both these are only required to provide an ACQUIRE barrier, if all you have is
smp_mb(), the second is sufficient.
Quoted 6 lines
Essentially ARCv2 is weakly ordered with explicit ordering provided by DMB instructions with semantics load/load, store/store, all/all.
I wanted to clarify a couple of things
(1) ACQUIRE barrier implies store/{store,load} while RELEASE implies {load,store}/store and given what DMB provides for ARCv2,smp_mb()is the only fit ?
Please see Documentation/memory-barriers.txt, but a quick recap:
- ACQUIRE: both loads and stores before to the barrier are allowed to be observed after it. Neither loads nor stores after the barrier are allowed to be observed before it.
- RELEASE: both loads and stores before it must be observed before the barrier. However, any load or store after it may be observed before it.
Therefore:
X = Y = 0;
[S] X = 1 ACQUIRE RELEASE [S] Y = 1
is in fact fully unordered, because both stores are allowed to cross in, and could cross one another on the inside, like:
ACQUIRE [S] Y = 1 [S] X = 1 RELEASE
Quoted 4 lines
(2) Do we need
smp_mb()on both sides of spin lock/unlock - doesn't ACQUIRE imply we have asmp_mb()after lock but before any subsequent critical section - so the top hunk is not necessarily needed. Similarly RELEASE requires asmp_mb()before the memory operation for lock, but not after.
You do not need an smp_mb() on both sides, as you say, after lock and before unlock is sufficient. The main point being that things can not escape out of the critical section. Its fine for them to leak in.
Peter Zijlstra
maintainerRe: [PATCH 20/28] ARCv2: barriers
In reply to Vineet GuptaQuoted 8 lines · Vineet Gupta
Quoted 4 lines · Peter Zijlstra
On Tue, Jun 09, 2015 at 05:18:20PM +0530, Vineet Gupta wrote:
A description of how your hardware works; or a reference to the platform documentation would not go amiss.
Honestly the docs group is working on a publicly sharable version of PRM (Programmer's Reference Manual) but it might take some more time.
Good news that. I appreciate these things can take some time.
Quoted 2 lines
I'm sure kernel
developers including you don't like to sign an NDA....
It might also be a question on your company vs my company. But yes, I generally prefer not to do NDAs.
Quoted 4 lines
The information I have in
comments is pretty much what we have in there w.r.t. the barrier instructions. But I will capture the the weak memory ordering and other details as part of changelog here too.
Right, so I think we all understand weak (ARM, PPC etc..) and we all understand load/load, store/store and load-store/load-store barriers.
Although explicitly mentioning it never hurt anybody ;-)
I think the most interesting part is the device side.
Quoted 11 lines
Quoted 10 lines
arch/arc/include/asm/barrier.h line 32
Quoted 8 lines
arch/arc/include/asm/barrier.h new file +8
-0+/* +* DSYNC: +* - Waits for completion of all outstanding memory operations before any new +* operations can begin +* - Includes implicit memory operations such as cache/TLB/BPU maintenance ops +* - Lighter version of SYNC as it doesn't wait for non-memory operations +*/ +#define mb () asm volatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.
Quoted 5 lines
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how
mb()can possibly order with DMA per se (unless there's some advanced form of IO-coherency)
I'm afraid I might not be the best of sources here, I tend to stay away from actual device stuff like that. I've Cc'ed Will Deacon who might be able to shed a bit more light on this aspect.
Peter Zijlstra
maintainerRe: [PATCH 22/28] ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Vineet GuptaQuoted 9 lines · Vineet Gupta
OK - I need some more time to rehash the exact details with our hardware folks. But AFAIKR, this was hardware livelock in llock/scond when 2 cores were doing r-m-w to two different words in the same cache line - adding prefetchw (prefetch with a write intent) would get the line in exclusive state and break the livelock.
The test itself was one from EEMBC Multibench but I'll have to look it up.
Quoted 6 lines
Wasn't there something similar in ARM world too - they have some sort of snoop-delayed exclusive handling in hardware to mitigate something similar although as Will later remarked it involved llock/scond with vanilla ld/st to same line/word ?
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/254142.html
Cute, I was not aware of that.
Sounds reasonable (unfortunate but understandable). Speaking as someone who at times does full arch sweeps on code like this it really helps understanding if such things are explained a wee bit better than not at all :-)
Re: [PATCH 20/28] ARCv2: barriers
In reply to Peter ZijlstraQuoted 21 lines · Peter Zijlstra
Quoted 1 line · Vineet Gupta
On Tuesday 09 June 2015 06:10 PM, Peter Zijlstra wrote:
I think the most interesting part is the device side.
Quoted 11 lines
Quoted 10 lines
arch/arc/include/asm/barrier.h line 32
Quoted 8 lines
arch/arc/include/asm/barrier.h new file +8
-0+/* +* DSYNC: +* - Waits for completion of all outstanding memory operations before any new +* operations can begin +* - Includes implicit memory operations such as cache/TLB/BPU maintenance ops +* - Lighter version of SYNC as it doesn't wait for non-memory operations +*/ +#define mb () asm volatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.Quoted 5 lines
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how
mb()can possibly order with DMA per se (unless there's some advanced form of IO-coherency)
Quoted 3 lines
I'm afraid I might not be the best of sources here, I tend to stay away from actual device stuff like that. I've Cc'ed Will Deacon who might be able to shed a bit more light on this aspect.
I'd definitely expect mb() to order arbitrary memory accesses against each other (i.e. regardless of whether or not they're to RAM or MMIO devices). Some drivers use it to "flush the writebuffer" but I don't think that makes a whole lot of sense. Certainly, on ARM, if we want to know that something reached an MMIO endpoint then we'll need a read-back as well as the barrier for the general case.
You also need that guarantee in your readl/writel family of macros. It's extremely heavy and rarely needed, which is why I added the _relaxed versions to all architectures.
The "ordering against DMA" is something like reading an MMIO register to determine whether the DMA has completed, then going off to read the contents out of the DMA buffer. The comment you have about DSYNC makes it sound like it's not sufficient for this case.
Will
Re: [PATCH 20/28] ARCv2: barriers
Quoted 30 lines · Will Deacon
Quoted 14 lines · Peter Zijlstra
Quoted 1 line · Vineet Gupta
On Tuesday 09 June 2015 06:10 PM, Peter Zijlstra wrote:
I think the most interesting part is the device side.
Quoted 10 lines
Quoted 10 lines
arch/arc/include/asm/barrier.h line 32
Quoted 8 lines
arch/arc/include/asm/barrier.h new file +8
-0+/* +* DSYNC: +* - Waits for completion of all outstanding memory operations before any new +* operations can begin +* - Includes implicit memory operations such as cache/TLB/BPU maintenance ops +* - Lighter version of SYNC as it doesn't wait for non-memory operations +*/ +#define mb () asm volatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.Quoted 8 lines
Quoted 5 lines
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how
mb()can possibly order with DMA per se (unless there's some advanced form of IO-coherency)I'm afraid I might not be the best of sources here, I tend to stay away from actual device stuff like that. I've Cc'ed Will Deacon who might be able to shed a bit more light on this aspect.
I'd definitely expect
mb()to order arbitrary memory accesses against each other (i.e. regardless of whether or not they're to RAM or MMIO devices). Some drivers use it to "flush the writebuffer" but I don't think that makes a whole lot of sense. Certainly, on ARM, if we want to know that something reached an MMIO endpoint then we'll need a read-back as well as the barrier for the general case.
Quoted 3 lines
You also need that guarantee in your readl/writel family of macros. It's extremely heavy and rarely needed, which is why I added the
_relaxedversions to all architectures.
Wow - adding that to these accessors will really be heavy - given that a whole bunch of drivers still use the stock API (or perhaps don't know / care whether they need the readl or the relaxed api. And it is practically impossible to switch them over - after if ain't broken how can u fix it. So far we've been testing this implementation (readl/writel - w/o any explicit barrier) on slower FPGA builds and this includes a whole bunch of designware IP - mmc, eth, gpio.... and don't see any ill effects - do you reckon we still need to add it.
Quoted 4 lines
The "ordering against DMA" is something like reading an MMIO register to determine whether the DMA has completed, then going off to read the contents out of the DMA buffer. The comment you have about DSYNC makes it sound like it's not sufficient for this case.
IMHO this use case is slightly pedantic - since DMA completion will typically follow up with an interrupt (I understand it's still possible to poll a dma status reg). at any rate when it comes to dwaring a line between memory accesses - regular or mmio, DSYNC is all we got in the ISA so ARCV2 mb() has to use it - there's no better option.
-Vineet
Quoted 2 lines
Will
Re: [PATCH 18/28] ARC: add smp barriers around atomics per memory-barrriers.txt
In reply to Peter ZijlstraQuoted 24 lines · Peter Zijlstra
Quoted 3 lines · Vineet Gupta
I wanted to clarify a couple of things
(1) ACQUIRE barrier implies store/{store,load} while RELEASE implies {load,store}/store and given what DMB provides for ARCv2,smp_mb()is the only fit ?Please see
Documentation/memory-barriers.txt, but a quick recap:- ACQUIRE: both loads and stores before to the barrier are allowed to be observed after it. Neither loads nor stores after the barrier are allowed to be observed before it.
- RELEASE: both loads and stores before it must be observed before the barrier. However, any load or store after it may be observed before it.
Therefore:
X = Y = 0;
[S] X = 1 ACQUIRE RELEASE [S] Y = 1
Quoted 7 lines
is in fact fully unordered, because both stores are allowed to cross in, and could cross one another on the inside, like:
ACQUIRE [S] Y = 1 [S] X = 1 RELEASE
Thx for that. I think I was mixing smp_load_acquire() / store_release() with the spin lock ACQUIRE/RELEASE. As Paul put it on a lwn article, after re-reading memory-barrier.txt I've indeed felt a hit on my already meager brain power :-)
Quoted 7 lines
Quoted 4 lines
(2) Do we need
smp_mb()on both sides of spin lock/unlock - doesn't ACQUIRE imply we have asmp_mb()after lock but before any subsequent critical section - so the top hunk is not necessarily needed. Similarly RELEASE requires asmp_mb()before the memory operation for lock, but not after.You do not need an
smp_mb()on both sides, as you say, after lock and before unlock is sufficient. The main point being that things can not escape out of the critical section. Its fine for them to leak in.
Ok - neverthless I will probably keep the extraneous barriers around for now since I see some weird hackbench regression on a dual core SMP build by removing the those 3 barriers (and/or replacing them with a nop so as to keep the icache / bpu micro-arch profile exactly same as before).
-Vineet
Re: [PATCH 20/28] ARCv2: barriers
In reply to Vineet GuptaQuoted 35 lines · Vineet Gupta
Quoted 30 lines · Will Deacon
Quoted 14 lines · Peter Zijlstra
Quoted 1 line · Vineet Gupta
On Tuesday 09 June 2015 06:10 PM, Peter Zijlstra wrote:
I think the most interesting part is the device side.
Quoted 10 lines
Quoted 10 lines
arch/arc/include/asm/barrier.h line 32
Quoted 8 lines
arch/arc/include/asm/barrier.h new file +8
-0+/* +* DSYNC: +* - Waits for completion of all outstanding memory operations before any new +* operations can begin +* - Includes implicit memory operations such as cache/TLB/BPU maintenance ops +* - Lighter version of SYNC as it doesn't wait for non-memory operations +*/ +#define mb () asm volatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.Quoted 8 lines
Quoted 5 lines
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how
mb()can possibly order with DMA per se (unless there's some advanced form of IO-coherency)I'm afraid I might not be the best of sources here, I tend to stay away from actual device stuff like that. I've Cc'ed Will Deacon who might be able to shed a bit more light on this aspect.
I'd definitely expect
mb()to order arbitrary memory accesses against each other (i.e. regardless of whether or not they're to RAM or MMIO devices). Some drivers use it to "flush the writebuffer" but I don't think that makes a whole lot of sense. Certainly, on ARM, if we want to know that something reached an MMIO endpoint then we'll need a read-back as well as the barrier for the general case.Quoted 3 lines
You also need that guarantee in your readl/writel family of macros. It's extremely heavy and rarely needed, which is why I added the
_relaxedversions to all architectures.
Quoted 7 lines
Wow - adding that to these accessors will really be heavy - given that a whole bunch of drivers still use the stock API (or perhaps don't know / care whether they need the readl or the relaxed api. And it is practically impossible to switch them over - after if ain't broken how can u fix it. So far we've been testing this implementation (readl/writel - w/o any explicit barrier) on slower FPGA builds and this includes a whole bunch of designware IP - mmc, eth, gpio.... and don't see any ill effects - do you reckon we still need to add it.
Unfortunately, yes, as that's effectively what the kernel requires:
http://marc.info/?l=linux-kernel&m=121192394430581&w=2
http://thread.gmane.org/gmane.linux.ide/46414
The conclusion is that x86 *does* provide this ordering in its accessors and drivers are written to assume that, so either you go round fixing all the drivers by adding the missing barriers or you implement it in your accessors (like we have done on ARM). Subtle I/O ordering issues are no fun to debug.
That's also the reason I added the _relaxed versions, so you can port drivers one-by-one to the weaker semantics whilst having the potentially broken drivers continue to work.
Quoted 10 lines
Quoted 4 lines
The "ordering against DMA" is something like reading an MMIO register to determine whether the DMA has completed, then going off to read the contents out of the DMA buffer. The comment you have about DSYNC makes it sound like it's not sufficient for this case.
IMHO this use case is slightly pedantic - since DMA completion will typically follow up with an interrupt (I understand it's still possible to poll a dma status reg). at any rate when it comes to dwaring a line between memory accesses - regular or mmio, DSYNC is all we got in the ISA so ARCV2
mb()has to use it - there's no better option.
Does taking an interrupt ensure visibility of the data on your architecture? Most non-pci device architectures allow that to race, so you end up relying on the readX in the irq handler to order the buffer access.
If you don't have an instruction for this, then I don't understand how you can perform DMA to/from regions of memory that are mapped as weakly ordered by the CPU (e.g. how would you write a data buffer then tell the device to go read from it?).
Will
PATCH v2 1/1 ARC: add smp barriers around atomics per Documentation/atomic_ops.txt
In reply to Vineet Gupta- arch_spin_lock/unlock were lacking the ACQUIRE/RELEASE barriers Since ARCv2 only provides load/load, store/store and all/all, we need the full barrier
- LLOCK/SCOND based atomics, bitops, cmpxchg, which return modified values were lacking the explicit smp barriers.
- Non LLOCK/SCOND varaints don't need the explicit barriers since that is implicity provided by the spin locks used to implement the critical section (the spin lock barriers in turn are also fixed in this commit as explained above
--- arch/arc/include/asm/atomic.h | 21 +++++++++++++++++++++ arch/arc/include/asm/bitops.h | 19 +++++++++++++++++++ arch/arc/include/asm/cmpxchg.h | 17 +++++++++++++++++ arch/arc/include/asm/spinlock.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+)
arch/arc/include/asm/atomic.h +21 -0
@@ -43,6 +43,12 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ { \unsigned int temp; \ \ +/* \ +* Explicit full memory barrier needed before/after as \ +* LLOCK/SCOND thmeselves don't provide any such semantics \ +*/ \ +smp_mb (); \ + \ __asm__ __volatile__( \ "1: llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \
@@ -52,6 +58,8 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ : "r"(&v->counter), "ir"(i) \ : "cc"); \ \ +smp_mb (); \ + \return temp; \ }
@@ -105,6 +113,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \unsigned long flags; \unsigned long temp; \ \ +/* \ +* spin lock/unlock provides the needed smp_mb() before/after \ +*/ \atomic_ops_lock (flags); \ temp = v->counter; \ temp c_op i; \
@@ -142,9 +153,19 @@ ATOMIC_OP(and, &=, and)#define __atomic_add_unless (v, a, u) \ ({ \ int c, old; \ + \ +/* \ +* Explicit full memory barrier needed before/after as \ +* LLOCK/SCOND thmeselves don't provide any such semantics \ +*/ \ +smp_mb (); \ + \ c =atomic_read (v); \while (c != (u ) && (old =atomic_cmpxchg ((v), c, c + (a))) != c)\ c = old; \ + \ +smp_mb (); \ + \ c; \ })
arch/arc/include/asm/bitops.h +19 -0
@@ -117,6 +117,12 @@ static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +/* +* Explicit full memory barrier needed before/after as +* LLOCK/SCOND themselves don't provide any such semantics +*/ +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bset %1, %0, %3 \n"
@@ -126,6 +132,8 @@ static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
@@ -139,6 +147,8 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bclr %1, %0, %3 \n"
@@ -148,6 +158,8 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
@@ -161,6 +173,8 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +smp_mb (); + __asm__ __volatile__("1: llock %0, [%2] \n" " bxor %1, %0, %3 \n"
@@ -170,6 +184,8 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m) : "r"(m), "ir"(nr) : "cc"); +smp_mb (); +return (old & (1 << nr)) !=0 ; }
@@ -249,6 +265,9 @@ static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *m)if (__builtin_constant_p (nr)) nr &=0x1f ; +/* +* spin lock/unlock provide the needed smp_mb() before/after +*/ bitops_lock (flags); old = *m;
arch/arc/include/asm/cmpxchg.h +17 -0
@@ -10,6 +10,8 @@#define __ASM_ARC_CMPXCHG_H#include <linux/types.h> + +#include <asm/barrier.h> #include <asm/smp.h> #ifdef CONFIG_ARC_HAS_LLSC
@@ -19,6 +21,12 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new) {unsigned long prev; +/* +* Explicit full memory barrier needed before/after as +* LLOCK/SCOND thmeselves don't provide any such semantics +*/ +smp_mb (); + __asm__ __volatile__("1: llock %0, [%1] \n" " brne %0, %2, 2f \n"
@@ -31,6 +39,8 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new) "r"(new) /* can't be "ir". scond can't take LIMM for "b" */ : "cc", "memory"); /* so that gcc knows memory is being written here */ + smp_mb(); +return prev; }
@@ -43,6 +53,9 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)int prev;volatile unsigned long *p = ptr; +/* +* spin lock/unlock provide the needed smp_mb() before/after +*/ atomic_ops_lock (flags); prev = *p;if (prev == expected)
@@ -78,12 +91,16 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr,switch (size) {case 4 : +smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" :"+r" (val) :"r" (ptr) :"memory" ); +smp_mb (); +return val; }return __xchg_bad_pointer ();
arch/arc/include/asm/spinlock.h +32 -0
@@ -22,24 +22,46 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +/* +* This smp_mb() is technically superfluous, we only need the one +* after the lock for providing the ACQUIRE semantics. +* However doing the "right" thing was regressing hackbench +* so keeping this, pending further investigation +*/ +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" " breq %0, %2, 1b \n" :"+&r" (tmp) :"r" (&(lock->slock)),"ir" (__ARCH_SPIN_LOCK_LOCKED__) :"memory" ); + +/* +* ACQUIRE barrier to ensure load/store after taking the lock +* don't "bleed-up" out of the critical section (leak-in is allowed) +* http://www.spinics.net/lists/kernel/msg2010409.html +* +* ARCv2 only has load-load, store-store and all-all barrier +* thus need the full all-all barrier +*/ +smp_mb (); }static inline int arch_spin_trylock (arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; +smp_mb (); + __asm__ __volatile__("1: ex %0, [%1] \n" :"+r" (tmp) :"r" (&(lock->slock)) :"memory" ); +smp_mb (); +return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__); }
@@ -47,12 +69,22 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) {unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__; +/* +* RELEASE barrier: given the instructions avail on ARCv2, full barrier +* is the only option +*/ +smp_mb (); + __asm__ __volatile__(" ex %0, [%1] \n" :"+r" (tmp) :"r" (&(lock->slock)) :"memory" ); +/* +* superfluous, but keeping for now - see pairing version in +* arch_spin_lock above +*/ smp_mb (); }
Signature · 1 line
1.9.1
PATCH v2 1/1 ARC: Reduce bitops lines of code using macros
In reply to Vineet GuptaNo semantical changes !
--- arch/arc/include/asm/bitops.h | 477 +++++++++++++----------------------------- 1 file changed, 144 insertions(+), 333 deletions(-)
arch/arc/include/asm/bitops.h +144 -333
@@ -18,83 +18,50 @@#include <linux/types.h> #include <linux/compiler.h> #include <asm/barrier.h> +#ifndef CONFIG_ARC_HAS_LLSC +#include <asm/smp.h> +#endif -/* -* Hardware assisted read-modify-write using ARC700 LLOCK/SCOND insns. -* The Kconfig glue ensures that in SMP, this is only set if the container -* SoC/platform has cross-core coherent LLOCK/SCOND -*/ #if defined(CONFIG_ARC_HAS_LLSC ) -static inline void set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -/* -* ARC ISA micro-optimization: -* -* Instructions dealing with bitpos only consider lower 5 bits (0-31) -* e.g (x << 33) is handled like (x << 1) by ASL instruction -* (mem pointer still needs adjustment to point to next word) -* -* Hence the masking to clamp @nr arg can be elided in general. -* -* However if @nr is a constant (above assumed it in a register), -* and greater than 31, gcc can optimize away (x << 33) to 0, -* as overflow, given the 32-bit ISA. Thus masking needs to be done -* for constant @nr, but no code is generated due to const prop. -*/ -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bset %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); -} - -static inline void clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bclr %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); -} - -static inline void change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; +/* +* Hardware assisted Atomic-R-M-W +*/ - __asm__ __volatile__( -"1: llock %0, [%1] \n" -" bxor %0, %0, %2 \n" -" scond %0, [%1] \n" -" bnz 1b \n" - :"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); +#define BIT_OP (op, c_op, asm_op) \ +static inline void op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned int temp; \ + \ + m += nr >> 5; \ + \ +/* \ +* ARC ISA micro-optimization: \ +* \ +* Instructions dealing with bitpos only consider lower 5 bits \ +* e.g (x << 33) is handled like (x << 1) by ASL instruction \ +* (mem pointer still needs adjustment to point to next word) \ +* \ +* Hence the masking to clamp @nr arg can be elided in general. \ +* \ +* However if @nr is a constant (above assumed in a register), \ +* and greater than 31, gcc can optimize away (x << 33) to 0, \ +* as overflow, given the 32-bit ISA. Thus masking needs to be \ +* done for const @nr, but no code is generated due to gcc \ +* const prop. \ +*/ \ +if (__builtin_constant_p (nr)) \ + nr &=0x1f ; \ + \ + __asm__ __volatile__( \ +"1: llock %0, [%1] \n" \ + " " #asm_op " %0, %0, %2 \n" \ +" scond %0, [%1] \n" \ +" bnz 1b \n" \ + :"=&r" (temp)/* Early clobber, to prevent reg reuse */ \ + :"r" (m),/* Not "m": llock only supports reg direct addr mode */ \ +"ir" (nr) \ + : "cc"); \ }/*
@@ -108,91 +75,38 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *m)* Since ARC lacks a equivalent h/w primitive, the bit is set unconditionally * and the old value of bit is returned */ -static inline int test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -/* -* Explicit full memory barrier needed before/after as -* LLOCK/SCOND themselves don't provide any such semantics -*/ -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bset %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bclr %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned int old, temp; - - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -smp_mb (); - - __asm__ __volatile__( -"1: llock %0, [%2] \n" -" bxor %1, %0, %3 \n" -" scond %1, [%2] \n" -" bnz 1b \n" - :"=&r" (old),"=&r" (temp) - :"r" (m),"ir" (nr) - :"cc" ); - -smp_mb (); - -return (old & (1 << nr)) !=0 ; +#define TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old, temp; \ + \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ +/* \ +* Explicit full memory barrier needed before/after as \ +* LLOCK/SCOND themselves don't provide any such smenatic \ +*/ \ +smp_mb (); \ + \ + __asm__ __volatile__( \ + "1: llock %0, [%2] \n" \ + " " #asm_op " %1, %0, %3 \n" \ + " scond %1, [%2] \n" \ + " bnz 1b \n" \ + : "=&r"(old), "=&r"(temp) \ + : "r"(m), "ir"(nr) \ + : "cc"); \ + \ + smp_mb(); \ + \ + return (old & (1 << nr)) != 0; \ }#else /* !CONFIG_ARC_HAS_LLSC */ -#include <asm/smp.h> -/* * Non hardware assisted Atomic-R-M-W * Locking would change to irq-disabling only (UP) and spinlocks (SMP)
@@ -209,111 +123,43 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)* at compile time) */ -static inline void set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp | (1UL << nr); - -bitops_unlock (flags); -} - -static inline void clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp & ~(1UL << nr); - -bitops_unlock (flags); -} - -static inline void change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - temp = *m; - *m = temp ^ (1UL << nr); - -bitops_unlock (flags); +#define BIT_OP (op, c_op, asm_op) \ +static inline void op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long temp, flags; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ +/* \ +* spin lock/unlock provide the needed smp_mb() before/after \ +*/ \ +bitops_lock (flags); \ + \ + temp = *m; \ + *m = temp c_op (1UL << nr); \ + \ +bitops_unlock (flags); \ } -static inline int test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -/* -* spin lock/unlock provide the needed smp_mb() before/after -*/ -bitops_lock (flags); - - old = *m; - *m = old | (1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - old = *m; - *m = old & ~(1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; -} - -static inline int -test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old, flags; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - -bitops_lock (flags); - - old = *m; - *m = old ^ (1 << nr); - -bitops_unlock (flags); - -return (old & (1 << nr)) !=0 ; +#define TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old, flags; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + bitops_lock(flags); \ + \ + old = *m; \ + *m = old c_op (1 << nr); \ + \ + bitops_unlock(flags); \ + \ + return (old & (1 << nr)) != 0; \ }#endif /* CONFIG_ARC_HAS_LLSC */
@@ -322,86 +168,51 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *m)* Non atomic variants **************************************/ -static inline void __set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp | (1UL << nr); -} - -static inline void __clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp & ~(1UL << nr); -} - -static inline void __change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long temp; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - temp = *m; - *m = temp ^ (1UL << nr); -} - -static inline int -__test_and_set_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old | (1 << nr); - -return (old & (1 << nr)) !=0 ; +#define __BIT_OP (op, c_op, asm_op) \ +static inline void __##op##_bit(unsigned long nr, volatile unsigned long *m) \ +{ \ + unsigned long temp; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + temp = *m; \ + *m = temp c_op (1UL << nr); \ } -static inline int -__test_and_clear_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old & ~(1 << nr); - -return (old & (1 << nr)) !=0 ; +#define __TEST_N_BIT_OP (op, c_op, asm_op) \ +static inline int __test_and_##op##_bit(unsigned long nr, volatile unsigned long *m)\ +{ \ + unsigned long old; \ + m += nr >> 5; \ + \ + if (__builtin_constant_p(nr)) \ + nr &= 0x1f; \ + \ + old = *m; \ + *m = old c_op (1 << nr); \ + \ + return (old & (1 << nr)) != 0; \ } -static inline int -__test_and_change_bit (unsigned long nr,volatile unsigned long *m) -{ -unsigned long old; - m += nr >>5 ; - -if (__builtin_constant_p (nr)) - nr &=0x1f ; - - old = *m; - *m = old ^ (1 << nr); - -return (old & (1 << nr)) !=0 ; -} +#define BIT_OPS (op, c_op, asm_op) \ + \ +/* set_bit(), clear_bit(), change_bit() */ \ + BIT_OP(op, c_op, asm_op) \ + \ +/* test_and_set_bit(), test_and_clear_bit(), test_and_change_bit() */ \ +TEST_N_BIT_OP (op, c_op, asm_op) \ + \ + /* __set_bit(), __clear_bit(), __change_bit() */ \ +__BIT_OP (op, c_op, asm_op) \ + \ + /* __test_and_set_bit(), __test_and_clear_bit(), __test_and_change_bit() */\ + __TEST_N_BIT_OP(op, c_op, asm_op) + +BIT_OPS(set, |, bset) +BIT_OPS(clear, & ~, bclr) +BIT_OPS(change, ^, bxor)/* * This routine doesn't need to be atomic.
Signature · 1 line
1.9.1
Re: [PATCH v2] ARC: add smp barriers around atomics per Documentation/atomic_ops.txt
In reply to Vineet GuptaQuoted 11 lines · Vineet Gupta
- arch_spin_lock/unlock were lacking the ACQUIRE/RELEASE barriers Since ARCv2 only provides load/load, store/store and all/all, we need the full barrier
- LLOCK/SCOND based atomics, bitops, cmpxchg, which return modified values were lacking the explicit smp barriers.
- Non LLOCK/SCOND varaints don't need the explicit barriers since that is implicity provided by the spin locks used to implement the critical section (the spin lock barriers in turn are also fixed in this commit as explained above
And iirc you're relying on asm-generic/barrier.h to issue smp_mb__{before,after}_atomic() as smp_mb(), right?
Although I'd love to know why you need those extra barriers in your spinlocks...
Peter Zijlstra
maintainerRe: [PATCH v2] ARC: Reduce bitops lines of code using macros
In reply to Vineet GuptaQuoted 1 line · Vineet Gupta
No semantical changes !
Acked-by Peter Zijlstra (Intel) <[email protected]>
Vineet Gupta
Acked-by Peter Zijlstra (Intel)Re: [PATCH v2] ARC: add smp barriers around atomics per Documentation/atomic_ops.txt
In reply to Peter ZijlstraOn Friday 12 June 2015 06:35 PM, Peter Zijlstra wrote:
Quoted 11 lines · Vineet Gupta
- arch_spin_lock/unlock were lacking the ACQUIRE/RELEASE barriers Since ARCv2 only provides load/load, store/store and all/all, we need the full barrier
- LLOCK/SCOND based atomics, bitops, cmpxchg, which return modified values were lacking the explicit smp barriers.
- Non LLOCK/SCOND varaints don't need the explicit barriers since that is implicity provided by the spin locks used to implement the critical section (the spin lock barriers in turn are also fixed in this commit as explained above
And iirc you're relying on asm-generic/barrier.h to issue smp_mb__{before,after}_atomic() as smp_mb(), right?
Yep !
Thx !
Although I'd love to know why you need those extra barriers in your spinlocks...
I'll keep you posted as I'd like to get rid of them too. But there's bunch of stuff going on ATM so can't really jump into investigating that. Will need some wrestling with perf... which makes me think that I'd posted a bunch of perf patches for ARC/ARCv2 as well - can u please take alook at them sometime soon !
Thx,
-Vineet
PATCH v2 22/28 ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Peter ZijlstraA quad core SMP build could get into hardware livelock with concurrent LLOCK/SCOND. Workaround that by adding a PREFETCHW which is serialized by SCU (System Coherency Unit). It brings the cache line in Exclusive state and makes others invalidate their lines. This gives enough time for winner to complete the LLOCK/SCOND, before others can get the line back.
--- arch/arc/include/asm/atomic.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arc/include/asm/atomic.h +12 -2
@@ -23,13 +23,21 @@#define atomic_set (v, i) (((v)->counter) = (i)) +#ifdef CONFIG_ISA_ARCV2 +#define PREFETCHW " prefetchw [%1] \n" +#else +#define PREFETCHW +#endif +#define ATOMIC_OP (op, c_op, asm_op) \ static inline void atomic_##op(int i, atomic_t *v) \ { \ unsigned int temp; \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
@@ -50,7 +58,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \smp_mb (); \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
Signature · 1 line
1.9.1
Re: [PATCH v2 22/28] ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
Quoted 29 lines · Vineet Gupta
A quad core SMP build could get into hardware livelock with concurrent LLOCK/SCOND. Workaround that by adding a PREFETCHW which is serialized by SCU (System Coherency Unit). It brings the cache line in Exclusive state and makes others invalidate their lines. This gives enough time for winner to complete the LLOCK/SCOND, before others can get the line back.
Cc Peter Zijlstra (Intel) <[email protected]>Signed-off-by Vineet Gupta <[email protected]>--- arch/arc/include/asm/atomic.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)arch/arc/include/asm/atomic.h +6
-0@@ -23,13 +23,21 @@#define atomic_set (v, i) (((v)->counter) = (i)) +#ifdef CONFIG_ISA_ARCV2 +#define PREFETCHW " prefetchw [%1] \n" +#else +#define PREFETCHW +#endif +#define ATOMIC_OP (op, c_op, asm_op) \ static inline void atomic_##op(int i, atomic_t *v) \ { \
arch/arc/include/asm/atomic.h line 43
Quoted 10 lines
arch/arc/include/asm/atomic.h +3
-1unsigned int temp; \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
Curious, but are you *sure* the prefetch should be *inside* the loop? On most ll/sc architectures, that's a livelock waiting to happen because you ping-pong the cache-line around in exclusive state.
Will
Re: [PATCH v2 22/28] ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
Quoted 35 lines · Will Deacon
Quoted 34 lines · Vineet Gupta
Quoted 34 lines
A quad core SMP build could get into hardware livelock with concurrent LLOCK/SCOND. Workaround that by adding a PREFETCHW which is serialized by SCU (System Coherency Unit). It brings the cache line in Exclusive state and makes others invalidate their lines. This gives enough time for winner to complete the LLOCK/SCOND, before others can get the line back.
Cc Peter Zijlstra (Intel) <[email protected]>Signed-off-by Vineet Gupta <[email protected]>--- arch/arc/include/asm/atomic.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)arch/arc/include/asm/atomic.h +7
-1@@ -23,13 +23,21 @@#define atomic_set (v, i) (((v)->counter) = (i)) +#ifdef CONFIG_ISA_ARCV2 +#define PREFETCHW " prefetchw [%1] \n" +#else +#define PREFETCHW +#endif +#define ATOMIC_OP (op, c_op, asm_op) \ static inline void atomic_##op(int i, atomic_t *v) \ { \ unsigned int temp; \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \
Quoted 8 lines
Quoted 5 lines
arch/arc/include/asm/atomic.h line 43
Quoted 5 lines
arch/arc/include/asm/atomic.h +2
-0+PREFETCHW \ +" llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \" scond %0, [%1] \n" \" bnz 1b \n" \Curious, but are you *sure* the prefetch should be *inside* the loop? On most ll/sc architectures, that's a livelock waiting to happen because you ping-pong the cache-line around in exclusive state.
Indeed, the prefetchw inside the loop seems dubious, but this is what broke the h/w livelock when we were playing with multibench last year and what i was told to do by h/w folks. Let me go check once again !
-Vineet
Re: [PATCH 20/28] ARCv2: barriers
In reply to Will DeaconQuoted 44 lines · Will Deacon
Quoted 35 lines · Vineet Gupta
Quoted 30 lines · Will Deacon
Quoted 14 lines · Peter Zijlstra
Quoted 1 line · Vineet Gupta
On Tuesday 09 June 2015 06:10 PM, Peter Zijlstra wrote:
I think the most interesting part is the device side.
Quoted 10 lines
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+/* + * DSYNC: + * - Waits for completion of all outstanding memory operations before any new + * operations can begin + * - Includes implicit memory operations such as cache/TLB/BPU maintenance ops + * - Lighter version of SYNC as it doesn't wait for non-memory operations + */ +#define mb() asm volatile("dsync\n" : : : "memory")So
mb()is supposed to order against things like DMA memory ops, is DMA part of point 1 or 3, if 3, this is not a suitable instruction.Quoted 8 lines
Quoted 5 lines
Can u please explain the DMA case a bit more ? From what I understood and used in say ethernet driver, it is more of a line drawn between say cpu updating a shared buffer descriptor and kicking a MMIO register (which in turn could initiate a DMA) but I'm not sure how
mb()can possibly order with DMA per se (unless there's some advanced form of IO-coherency)I'm afraid I might not be the best of sources here, I tend to stay away from actual device stuff like that. I've Cc'ed Will Deacon who might be able to shed a bit more light on this aspect.
I'd definitely expect
mb()to order arbitrary memory accesses against each other (i.e. regardless of whether or not they're to RAM or MMIO devices). Some drivers use it to "flush the writebuffer" but I don't think that makes a whole lot of sense. Certainly, on ARM, if we want to know that something reached an MMIO endpoint then we'll need a read-back as well as the barrier for the general case.Quoted 3 lines
You also need that guarantee in your readl/writel family of macros. It's extremely heavy and rarely needed, which is why I added the
_relaxedversions to all architectures.Quoted 7 lines
Wow - adding that to these accessors will really be heavy - given that a whole bunch of drivers still use the stock API (or perhaps don't know / care whether they need the readl or the relaxed api. And it is practically impossible to switch them over - after if ain't broken how can u fix it. So far we've been testing this implementation (readl/writel - w/o any explicit barrier) on slower FPGA builds and this includes a whole bunch of designware IP - mmc, eth, gpio.... and don't see any ill effects - do you reckon we still need to add it.
Quoted 4 lines
Unfortunately, yes, as that's effectively what the kernel requires:
http://marc.info/?l=linux-kernel&m=121192394430581&w=2
http://thread.gmane.org/gmane.linux.ide/46414
Oh great - thx for those !
Quoted 10 lines
The conclusion is that x86 *does* provide this ordering in its accessors and drivers are written to assume that, so either you go round fixing all the drivers by adding the missing barriers or you implement it in your accessors (like we have done on ARM). Subtle I/O ordering issues are no fun to debug.
That's also the reason I added the
_relaxedversions, so you can port drivers one-by-one to the weaker semantics whilst having the potentially broken drivers continue to work.
OK, so given that regular/mmio is also weakly ordered, it would seem that we need full mb() *before* and *after* the IO access in the non relaxed API. ARM code seems to put a rmb() after the readl and wmb() before the writel. Is that based on how h/w provides for some ?
In one of the links you posted above, Catalin posed the same question, but I didn't see response to that.
| If we are to make the writel/readl on ARM fully ordered with both IO | (enforced by hardware) and uncached memory, do we add barriers on each | side of the writel/readl etc.? The common cases would require a barrier | before writel (write buffer flushing) and a barrier after readl (in case | of polling for a "DMA complete" state). | | So if io_wmb() just orders to IO writes (writel_relaxed), does it mean | that we still need a mighty wmb() that orders any type of accesses (i.e. | uncached memory vs IO)? Can drivers not use the strict writel() and no | longer rely on wmb() (wondering whether we could simplify it on ARM with | fully ordered IO accessors)?
Further readl/writel would be no different than ioread32/iowrite32 ?
FWIW, h/w folks tell me that DMB guarentess local barrier semantics so we don't need to use DSYNC. Latter only provides full r+w+TLB/BPU stuff while DMB allows finer grained r/w/r+w. But if we need full mb then using one vs. other becomes a moot point.
-Vineet
Quoted 23 lines
Quoted 10 lines
Quoted 4 lines
The "ordering against DMA" is something like reading an MMIO register to determine whether the DMA has completed, then going off to read the contents out of the DMA buffer. The comment you have about DSYNC makes it sound like it's not sufficient for this case.
IMHO this use case is slightly pedantic - since DMA completion will typically follow up with an interrupt (I understand it's still possible to poll a dma status reg). at any rate when it comes to dwaring a line between memory accesses - regular or mmio, DSYNC is all we got in the ISA so ARCV2
mb()has to use it - there's no better option.Does taking an interrupt ensure visibility of the data on your architecture? Most non-pci device architectures allow that to race, so you end up relying on the readX in the irq handler to order the buffer access.
If you don't have an instruction for this, then I don't understand how you can perform DMA to/from regions of memory that are mapped as weakly ordered by the CPU (e.g. how would you write a data buffer then tell the device to go read from it?).
Will
Re: [PATCH 20/28] ARCv2: barriers
Quoted 33 lines · Vineet Gupta
Quoted 14 lines · Will Deacon
Quoted 5 lines · Vineet Gupta
Quoted 3 lines · Will Deacon
You also need that guarantee in your readl/writel family of macros. It's extremely heavy and rarely needed, which is why I added the
_relaxedversions to all architectures.Quoted 7 lines
Wow - adding that to these accessors will really be heavy - given that a whole bunch of drivers still use the stock API (or perhaps don't know / care whether they need the readl or the relaxed api. And it is practically impossible to switch them over - after if ain't broken how can u fix it. So far we've been testing this implementation (readl/writel - w/o any explicit barrier) on slower FPGA builds and this includes a whole bunch of designware IP - mmc, eth, gpio.... and don't see any ill effects - do you reckon we still need to add it.
Quoted 4 lines
Unfortunately, yes, as that's effectively what the kernel requires:
http://marc.info/?l=linux-kernel&m=121192394430581&w=2
http://thread.gmane.org/gmane.linux.ide/46414Oh great - thx for those !
Quoted 10 lines
The conclusion is that x86 *does* provide this ordering in its accessors and drivers are written to assume that, so either you go round fixing all the drivers by adding the missing barriers or you implement it in your accessors (like we have done on ARM). Subtle I/O ordering issues are no fun to debug.
That's also the reason I added the
_relaxedversions, so you can port drivers one-by-one to the weaker semantics whilst having the potentially broken drivers continue to work.
Quoted 4 lines
OK, so given that regular/mmio is also weakly ordered, it would seem that we need full
mb()*before* and *after* the IO access in the non relaxed API. ARM code seems to put armb()after the readl andwmb()before the writel. Is that based on how h/w provides for some ?
We figured that you'd likely be doing something like:
<writel_relaxed DMA buffer>
<writel MMIO "go" reg>
or:
<readl MMIO "status" reg>
<readl_relaxed DMA buffer>
so ended up with writel doing {wmb(); writel_relaxed} and readl doing {readl_relaxed; rmb()}.
Quoted 15 lines
In one of the links you posted above, Catalin posed the same question, but I didn't see response to that.
| If we are to make the writel/readl on ARM fully ordered with both IO | (enforced by hardware) and uncached memory, do we add barriers on each | side of the writel/readl etc.? The common cases would require a barrier | before writel (write buffer flushing) and a barrier after readl (in case | of polling for a "DMA complete" state). | | So if io_wmb() just orders to IO writes (writel_relaxed), does it mean | that we still need a mighty wmb() that orders any type of accesses (i.e. | uncached memory vs IO)? Can drivers not use the strict writel() and no | longer rely on wmb() (wondering whether we could simplify it on ARM with | fully ordered IO accessors)?
Quoted 1 line
Further readl/writel would be no different than ioread32/iowrite32 ?
ioread32/iowrite32 can be used with port addresses and dispatch to the relevant accessors depending on that. The memory ordering semantics should be the same as readl/writel.
Quoted 4 lines
FWIW, h/w folks tell me that DMB guarentess local barrier semantics so we don't need to use DSYNC. Latter only provides full r+w+TLB/BPU stuff while DMB allows finer grained r/w/r+w. But if we need full mb then using one vs. other becomes a moot point.
I'd say go with what we do on ARM/arm64, then at least we have consistency in the use of barriers.
Will
PATCH v2 20/28 ARCv2: barriers
ARCv2 based HS38 cores are weakly ordered and thus explicit barriers for kernel proper.
SMP barrier is provided by DMB instruction which also guarantees local barrier hence used as backend of smp_*mb() as well as *mb() APIs
Also hookup barriers into MMIO accessors to avoid ordering issues in IO
---
Changes since v1
* Better changelog and comments
* local/mandatory barriers to NOT use DSYNC, but DMB
* define DMB based mandatory barriers even for !SMP
---
--- arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/barrier.h | 48 ++++++++++++++++++++++++++++++++++++++++++ arch/arc/include/asm/io.h | 42 +++++++++++++++++++++++++++++++++--- 3 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 arch/arc/include/asm/barrier.h
arch/arc/include/asm/Kbuild +0 -1
@@ -1,5 +1,4 @@ generic-y += auxvec.h -generic-y += barrier.h generic-y += bitsperlong.h generic-y += bugs.h generic-y += clkdev.h
arch/arc/include/asm/barrier.h new file +48 -0
48 lines not on this page · raw message
arch/arc/include/asm/io.h +39 -3
48 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 22/28 ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock
In reply to Will DeaconA quad core SMP build could get into hardware livelock with concurrent LLOCK/SCOND. Workaround that by adding a PREFETCHW which is serialized by SCU (System Coherency Unit). It brings the cache line in Exclusive state and makes others invalidate their lines. This gives enough time for winner to complete the LLOCK/SCOND, before others can get the line back.
The prefetchw in the ll/sc loop is not nice but this is the only software workaround for current version of RTL.
--- arch/arc/include/asm/atomic.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arc/include/asm/atomic.h +12 -2
@@ -23,13 +23,21 @@#define atomic_set (v, i) (((v)->counter) = (i)) +#ifdef CONFIG_ISA_ARCV2 +#define PREFETCHW " prefetchw [%1] \n" +#else +#define PREFETCHW +#endif +#define ATOMIC_OP (op, c_op, asm_op) \ static inline void atomic_##op(int i, atomic_t *v) \ { \ unsigned int temp; \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
@@ -50,7 +58,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \smp_mb (); \ \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: \n" \ + PREFETCHW \ + " llock %0, [%1] \n" \ " " #asm_op " %0, %0, %2 \n" \ " scond %0, [%1] \n" \ " bnz 1b \n" \
Signature · 1 line
1.9.1
Re: [PATCH 20/28] ARCv2: barriers
In reply to Will DeaconQuoted 37 lines · Will Deacon
Quoted 4 lines
OK, so given that regular/mmio is also weakly ordered, it would seem that we need
Quoted 3 lines
full
mb()*before* and *after* the IO access in the non relaxed API. ARM code seems to put armb()after the readl andwmb()before the writel. Is that based on how h/w provides for some ?We figured that you'd likely be doing something like:
<
writel_relaxedDMA buffer>
<writel MMIO "go" reg>or:
<readl MMIO "status" reg>
<readl_relaxedDMA buffer>so ended up with writel doing {
wmb();writel_relaxed} and readl doing {readl_relaxed;rmb()}.Quoted 15 lines
Quoted 15 lines
In one of the links you posted above, Catalin posed the same question, but I didn't see response to that.
| If we are to make the writel/readl on ARM fully ordered with both IO | (enforced by hardware) and uncached memory, do we add barriers on each | side of the writel/readl etc.? The common cases would require a barrier | before writel (write buffer flushing) and a barrier after readl (in case | of polling for a "DMA complete" state). | | So if io_wmb() just orders to IO writes (writel_relaxed), does it mean | that we still need a mighty wmb() that orders any type of accesses (i.e. | uncached memory vs IO)? Can drivers not use the strict writel() and no | longer rely on wmb() (wondering whether we could simplify it on ARM with | fully ordered IO accessors)?Quoted 1 line
Quoted 1 line
Further readl/writel would be no different than ioread32/iowrite32 ?
ioread32/iowrite32 can be used with port addresses and dispatch to the relevant accessors depending on that. The memory ordering semantics should be the same as readl/writel.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
FWIW, h/w folks tell me that DMB guarentess local barrier semantics so we don't need to use DSYNC. Latter only provides full r+w+TLB/BPU stuff while DMB allows finer grained r/w/r+w. But if we need full mb then using one vs. other becomes a moot point.
I'd say go with what we do on ARM/arm64, then at least we have consistency in the use of barriers.
Thx for very helpful review/feedback Will. I've posted a v2 !
-Vineet
Re: [PATCH v2 20/28] ARCv2: barriers
In reply to Vineet GuptaHi Vineet,
Quoted 11 lines · Vineet Gupta
ARCv2 based HS38 cores are weakly ordered and thus explicit barriers for kernel proper.
SMP barrier is provided by DMB instruction which also guarantees local barrier hence used as backend of smp_*mb() as well as
*mb()APIsAlso hookup barriers into MMIO accessors to avoid ordering issues in IO
Cc Peter Zijlstra (Intel) <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Vineet Gupta <[email protected]>
Quoted 6 lines
---
Changes since v1
* Better changelog and comments
* local/mandatory barriers to NOT use DSYNC, but DMB
* define DMB based mandatory barriers even for !SMP
---
Functionally, all looks good to me. However, my comment is completely misleading ;)
Quoted 9 lines
+/*
+ * MMIO can also get buffered/optimized in micro-arch, so barriers needed
+ * Based on ARM model for the typical use case
+ *
+ * <writel_relaxedDMA buffer>
+ * <writel MMIO "go" reg>+ * or: + * <readl MMIO "status" reg> + * <readl_relaxed DMA buffer>
The writel_relaxed/readl_relaxed parts here would actually just be bog-standard loads and stores to an in-memory buffer. I was trying too hard to show the barrier semantics and accidentally turned the DMA buffers into __iomem regions.
If you fix the comment:
Sorry for messing you about.
Will
Re: [PATCH v2 20/28] ARCv2: barriers
Hi Will,
Quoted 9 lines · Will Deacon
Quoted 9 lines
+/*
Quoted 8 lines
+ * MMIO can also get buffered/optimized in micro-arch, so barriers needed
+ * Based on ARM model for the typical use case
+ *
+ * <writel_relaxedDMA buffer>
+ * <writel MMIO "go" reg>+ * or: + * <readl MMIO "status" reg> + * <readl_relaxed DMA buffer>
Quoted 4 lines
The writel_relaxed/readl_relaxed parts here would actually just be bog-standard loads and stores to an in-memory buffer. I was trying too hard to show the barrier semantics and accidentally turned the DMA buffers into
__iomemregions.
Not sure if I follow you completely :-)
IMHO, It doesn't matter if we are dealing with a typical DMA buffer (cached) or a buffer descriptor (typically uncached unless there's hardware IO-coh or some such). Both the cases assume a vanilla ld/st to buffer (using relaxed API) with a surrounding MMIO access.
Quoted 2 lines
If you fix the comment:
Does this look better ?
- * <writel_relaxed DMA buffer>
+ * <writel_relaxed DMA buffer (cached or uncached)>
Quoted 4 lines
Reviewed-by Will Deacon <[email protected]>Sorry for messing you about.
NP.
-Vineet
Peter Zijlstra
maintainerRe: [PATCH v2 20/28] ARCv2: barriers
In reply to Vineet GuptaQuoted 11 lines · Vineet Gupta
+/*
+ * MMIO can also get buffered/optimized in micro-arch, so barriers needed
+ * Based on ARM model for the typical use case
+ *
+ * <writel_relaxedDMA buffer>
+ * <writel MMIO "go" reg>+ * or: + * <readl MMIO "status" reg> + * <readl_relaxed DMA buffer>
http://lkml.kernel.org/r/[email protected]
Might I suggest you use the above link. Since we control kernel.org we have redirect that URL to a archive of our choosing. This keeps the links working even if spinics.net or marc.info were to go belly up.
Re: [PATCH v2 20/28] ARCv2: barriers
In reply to Vineet GuptaQuoted 10 lines · Vineet Gupta
Quoted 9 lines · Will Deacon
Quoted 9 lines
+/*
Quoted 8 lines
+ * MMIO can also get buffered/optimized in micro-arch, so barriers needed
+ * Based on ARM model for the typical use case
+ *
+ * <writel_relaxedDMA buffer>
+ * <writel MMIO "go" reg>+ * or: + * <readl MMIO "status" reg> + * <readl_relaxed DMA buffer>
Quoted 6 lines
Quoted 4 lines
The writel_relaxed/readl_relaxed parts here would actually just be bog-standard loads and stores to an in-memory buffer. I was trying too hard to show the barrier semantics and accidentally turned the DMA buffers into
__iomemregions.Not sure if I follow you completely :-)
D'oh, sorry.
Quoted 4 lines
IMHO, It doesn't matter if we are dealing with a typical DMA buffer (cached) or a buffer descriptor (typically uncached unless there's hardware IO-coh or some such). Both the cases assume a vanilla ld/st to buffer (using relaxed API) with a surrounding MMIO access.
It's more that you should only pass __iomem pointers (i.e. stuff you got back from something like ioremap) to readl_relaxed/writel_relaxed and that's not typically how you would allocate your DMA buffer.
Quoted 6 lines
Quoted 1 line
If you fix the comment:
Does this look better ?
- * <
writel_relaxedDMA buffer>
+ * <writel_relaxedDMA buffer (cached or uncached)>
I'd just replace 'writel_relaxed' with whatever your store instruction is (ST)?
Will
PATCH v3 22/28 ARCv2: barriers
ARCv2 based HS38 cores are weakly ordered and thus explicit barriers for kernel proper.
SMP barrier is provided by DMB instruction which also guarantees local barrier hence used as backend of smp_*mb() as well as *mb() APIs
Also hookup barriers into MMIO accessors to avoid ordering issues in IO
---
Changes since v2
* lkml discussion link points to lkml redirector (PeterZ)
* Updated comment about IO ordering to use standard LD/ST (Will Deacon)
Changes since v1
* Better changelog and comments
* local/mandatory barriers to NOT use DSYNC, but DMB
* define DMB based mandatory barriers even for !SMP
---
--- arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/barrier.h | 48 ++++++++++++++++++++++++++++++++++++++++++ arch/arc/include/asm/io.h | 44 +++++++++++++++++++++++++++++++++++--- 3 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 arch/arc/include/asm/barrier.h
arch/arc/include/asm/Kbuild +0 -1
@@ -1,5 +1,4 @@ generic-y += auxvec.h -generic-y += barrier.h generic-y += bitsperlong.h generic-y += bugs.h generic-y += clkdev.h
arch/arc/include/asm/barrier.h new file +48 -0
48 lines not on this page · raw message
arch/arc/include/asm/io.h +41 -3
50 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 22/28] ARCv2: barriers
Quoted 21 lines · Vineet Gupta
ARCv2 based HS38 cores are weakly ordered and thus explicit barriers for kernel proper.
SMP barrier is provided by DMB instruction which also guarantees local barrier hence used as backend of smp_*mb() as well as
*mb()APIsAlso hookup barriers into MMIO accessors to avoid ordering issues in IO
Cc Peter Zijlstra (Intel) <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Vineet Gupta <[email protected]>---
Changes since v2
* lkml discussion link points to lkml redirector (PeterZ)
* Updated comment about IO ordering to use standard LD/ST (Will Deacon)Changes since v1
* Better changelog and comments
* local/mandatory barriers to NOT use DSYNC, but DMB
* define DMB based mandatory barriers even for !SMP
---
[...]
Quoted 6 lines
+/*
+ * MMIO can also get buffered/optimized in micro-arch, so barriers needed
+ * Based on ARM model for the typical use case
+ *
+ * <ST [DMA buffer]>
+ *wmb()
Quoted 8 lines
+ * <writel MMIO "go" reg>
+ * or:
+ * <readl MMIO "status" reg>
+ *rmb()
+ * <LD [DMA buffer]>
+ *
+ * http://lkml.kernel.org/r/[email protected]
+ */
If that makes sense to you, then fine, but I find the wmb() and rmb() a bit odd since they're implied by the writel/readl macros.
Regardless, you can keep my reviewed-by from last time.
Will
Re: [PATCH 11/28] ARCv2: extable: Enable sorting at build time
In reply to Vineet GuptaHi David,
Quoted 22 lines · Vineet Gupta
Signed-off-by Vineet Gupta <[email protected]>--- scripts/sortextable.c | 5 +++++ 1 file changed, 5 insertions(+)scripts/sortextable.c +4
-0@@ -47,6 +47,10 @@#define EM_MICROBLAZE 189#endif +#ifndef EM_ARCV2 +#define EM_ARCV2 195 +#endif +static int fd_map;/* File descriptor for file being modified. */ static int mmap_failed;/* Boolean flag. */ static void *ehdr_curr;/* current ElfXX_Ehdr * for resource cleanup */
scripts/sortextable.c do_file(char const *const fname) · line 291
Quoted 7 lines
scripts/sortextable.c +1
-0@@ -281,6 +285,7 @@ do_file(char const *const fname) custom_sort = sort_relative_table;break ;case EM_ARCOMPACT : +case EM_ARCV2 :case EM_ARM :case EM_AARCH64 :case EM_MICROBLAZE :
Sorry for missing you in the CC in orig post of this patch. Can I get your Ack on this one !
-Vineet
David Daney
Acked-byRe: [PATCH 11/28] ARCv2: extable: Enable sorting at build time
Quoted 27 lines · Vineet Gupta
Hi David,
Quoted 24 lines · Vineet Gupta
Signed-off-by Vineet Gupta <[email protected]>--- scripts/sortextable.c | 5 +++++ 1 file changed, 5 insertions(+)scripts/sortextable.c +4
-0@@ -47,6 +47,10 @@#define EM_MICROBLAZE 189#endif +#ifndef EM_ARCV2 +#define EM_ARCV2 195 +#endif +static int fd_map;/* File descriptor for file being modified. */ static int mmap_failed;/* Boolean flag. */ static void *ehdr_curr;/* current ElfXX_Ehdr * for resource cleanup */ @@ -281,6 +285,7 @@ do_file(char const *const fname) custom_sort = sort_relative_table;break ;case EM_ARCOMPACT :
Quoted 9 lines
scripts/sortextable.c do_file(char const *const fname) · line 291
Quoted 5 lines
scripts/sortextable.c +1
-0+case EM_ARCV2 :case EM_ARM :case EM_AARCH64 :case EM_MICROBLAZE :Sorry for missing you in the CC in orig post of this patch. Can I get your Ack on this one !
OK:
Really this is obvious, and only effects ARCv2, so the corresponding maintainers shouldn't need my Ack.
David Daney
Quoted 2 lines
-Vineet
Re: [PATCH 11/28] ARCv2: extable: Enable sorting at build time
Quoted 8 lines · David Daney
Quoted 4 lines
Sorry for missing you in the CC in orig post of this patch. Can I get your Ack on this one !
OK:
Acked-by David Daney <[email protected]>
Thx David. Although I had put the patch as it is in the end as I need to send a pull request to Linus soon for hat stuff.
Quoted 2 lines
Really this is obvious, and only effects ARCv2, so the corresponding maintainers shouldn't need my Ack.
Indeed it was obvious, but last few commits in that file had ACK's from you so I thought of retaining the tradition so to speak :-)
-Vineet