Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm into next

Pull ARM updates from Russell King:

- Major clean-up of the L2 cache support code. The existing mess was
becoming rather unmaintainable through all the additions that others
have done over time. This turns it into a much nicer structure, and
implements a few performance improvements as well.

- Clean up some of the CP15 control register tweaks for alignment
support, moving some code and data into alignment.c

- DMA properties for ARM, from Santosh and reviewed by DT people. This
adds DT properties to specify bus translations we can't discover
automatically, and to indicate whether devices are coherent.

- Hibernation support for ARM

- Make ftrace work with read-only text in modules

- add suspend support for PJ4B CPUs

- rework interrupt masking for undefined instruction handling, which
allows us to enable interrupts earlier in the handling of these
exceptions.

- support for big endian page tables

- fix stacktrace support to exclude stacktrace functions from the
trace, and add save_stack_trace_regs() implementation so that kprobes
can record stack traces.

- Add support for the Cortex-A17 CPU.

- Remove last vestiges of ARM710 support.

- Removal of ARM "meminfo" structure, finally converting us solely to
memblock to handle the early memory initialisation.

* 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: (142 commits)
ARM: ensure C page table setup code follows assembly code (part II)
ARM: ensure C page table setup code follows assembly code
ARM: consolidate last remaining open-coded alignment trap enable
ARM: remove global cr_no_alignment
ARM: remove CPU_CP15 conditional from alignment.c
ARM: remove unused adjust_cr() function
ARM: move "noalign" command line option to alignment.c
ARM: provide common method to clear bits in CPU control register
ARM: 8025/1: Get rid of meminfo
ARM: 8060/1: mm: allow sub-architectures to override PCI I/O memory type
ARM: 8066/1: correction for ARM patch 8031/2
ARM: 8049/1: ftrace/add save_stack_trace_regs() implementation
ARM: 8065/1: remove last use of CONFIG_CPU_ARM710
ARM: 8062/1: Modify ldrt fixup handler to re-execute the userspace instruction
ARM: 8047/1: rwsem: use asm-generic rwsem implementation
ARM: l2c: trial at enabling some Cortex-A9 optimisations
ARM: l2c: add warnings for stuff modifying aux_ctrl register values
ARM: l2c: print a warning with L2C-310 caches if the cache size is modified
ARM: l2c: remove old .set_debug method
ARM: l2c: kill L2X0_AUX_CTRL_MASK before anyone else makes use of this
...

+2483 -1633
+1 -8
Documentation/arm/memory.txt
··· 41 41 fffe0000 fffe7fff ITCM mapping area for platforms with 42 42 ITCM mounted inside the CPU. 43 43 44 - fff00000 fffdffff Fixmap mapping region. Addresses provided 44 + ffc00000 ffdfffff Fixmap mapping region. Addresses provided 45 45 by fix_to_virt() will be located here. 46 - 47 - ffc00000 ffefffff DMA memory mapping region. Memory returned 48 - by the dma_alloc_xxx functions will be 49 - dynamically mapped here. 50 - 51 - ff000000 ffbfffff Reserved for future expansion of DMA 52 - mapping region. 53 46 54 47 fee00000 feffffff Mapping of PCI I/O space. This is a static 55 48 mapping within the vmalloc space.
+1
Documentation/devicetree/bindings/arm/pmu.txt
··· 8 8 9 9 - compatible : should be one of 10 10 "arm,armv8-pmuv3" 11 + "arm,cortex-a17-pmu" 11 12 "arm,cortex-a15-pmu" 12 13 "arm,cortex-a12-pmu" 13 14 "arm,cortex-a9-pmu"
+6 -60
arch/arm/Kconfig
··· 165 165 bool 166 166 default y 167 167 168 - config RWSEM_GENERIC_SPINLOCK 169 - bool 170 - default y 171 - 172 168 config RWSEM_XCHGADD_ALGORITHM 173 169 bool 170 + default y 174 171 175 172 config ARCH_HAS_ILOG2_U32 176 173 bool ··· 1086 1089 1087 1090 source arch/arm/mm/Kconfig 1088 1091 1089 - config ARM_NR_BANKS 1090 - int 1091 - default 16 if ARCH_EP93XX 1092 - default 8 1093 - 1094 1092 config IWMMXT 1095 1093 bool "Enable iWMMXt support" 1096 1094 depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 || CPU_PJ4B ··· 1206 1214 register of the Cortex-A9 which reduces the linefill issuing 1207 1215 capabilities of the processor. 1208 1216 1209 - config PL310_ERRATA_588369 1210 - bool "PL310 errata: Clean & Invalidate maintenance operations do not invalidate clean lines" 1211 - depends on CACHE_L2X0 1212 - help 1213 - The PL310 L2 cache controller implements three types of Clean & 1214 - Invalidate maintenance operations: by Physical Address 1215 - (offset 0x7F0), by Index/Way (0x7F8) and by Way (0x7FC). 1216 - They are architecturally defined to behave as the execution of a 1217 - clean operation followed immediately by an invalidate operation, 1218 - both performing to the same memory location. This functionality 1219 - is not correctly implemented in PL310 as clean lines are not 1220 - invalidated as a result of these operations. 1221 - 1222 1217 config ARM_ERRATA_643719 1223 1218 bool "ARM errata: LoUIS bit field in CLIDR register is incorrect" 1224 1219 depends on CPU_V7 && SMP ··· 1227 1248 invalidated are not, resulting in an incoherency in the system page 1228 1249 tables. The workaround changes the TLB flushing routines to invalidate 1229 1250 entries regardless of the ASID. 1230 - 1231 - config PL310_ERRATA_727915 1232 - bool "PL310 errata: Background Clean & Invalidate by Way operation can cause data corruption" 1233 - depends on CACHE_L2X0 1234 - help 1235 - PL310 implements the Clean & Invalidate by Way L2 cache maintenance 1236 - operation (offset 0x7FC). This operation runs in background so that 1237 - PL310 can handle normal accesses while it is in progress. Under very 1238 - rare circumstances, due to this erratum, write data can be lost when 1239 - PL310 treats a cacheable write transaction during a Clean & 1240 - Invalidate by Way operation. 1241 1251 1242 1252 config ARM_ERRATA_743622 1243 1253 bool "ARM errata: Faulty hazard checking in the Store Buffer may lead to data corruption" ··· 1252 1284 completion of a following broadcasted operation if the second 1253 1285 operation is received by a CPU before the ICIALLUIS has completed, 1254 1286 potentially leading to corrupted entries in the cache or TLB. 1255 - 1256 - config PL310_ERRATA_753970 1257 - bool "PL310 errata: cache sync operation may be faulty" 1258 - depends on CACHE_PL310 1259 - help 1260 - This option enables the workaround for the 753970 PL310 (r3p0) erratum. 1261 - 1262 - Under some condition the effect of cache sync operation on 1263 - the store buffer still remains when the operation completes. 1264 - This means that the store buffer is always asked to drain and 1265 - this prevents it from merging any further writes. The workaround 1266 - is to replace the normal offset of cache sync operation (0x730) 1267 - by another offset targeting an unmapped PL310 register 0x740. 1268 - This has the same effect as the cache sync operation: store buffer 1269 - drain and waiting for all buffers empty. 1270 1287 1271 1288 config ARM_ERRATA_754322 1272 1289 bool "ARM errata: possible faulty MMU translations following an ASID switch" ··· 1300 1347 system. This workaround adds a DSB instruction before the 1301 1348 relevant cache maintenance functions and sets a specific bit 1302 1349 in the diagnostic control register of the SCU. 1303 - 1304 - config PL310_ERRATA_769419 1305 - bool "PL310 errata: no automatic Store Buffer drain" 1306 - depends on CACHE_L2X0 1307 - help 1308 - On revisions of the PL310 prior to r3p2, the Store Buffer does 1309 - not automatically drain. This can cause normal, non-cacheable 1310 - writes to be retained when the memory system is idle, leading 1311 - to suboptimal I/O performance for drivers using coherent DMA. 1312 - This option adds a write barrier to the cpu_idle loop so that, 1313 - on systems with an outer cache, the store buffer is drained 1314 - explicitly. 1315 1350 1316 1351 config ARM_ERRATA_775420 1317 1352 bool "ARM errata: A data cache maintenance operation which aborts, might lead to deadlock" ··· 2219 2278 2220 2279 config ARM_CPU_SUSPEND 2221 2280 def_bool PM_SLEEP 2281 + 2282 + config ARCH_HIBERNATION_POSSIBLE 2283 + bool 2284 + depends on MMU 2285 + default y if ARCH_SUSPEND_POSSIBLE 2222 2286 2223 2287 endmenu 2224 2288
+2
arch/arm/boot/compressed/atags_to_fdt.c
··· 7 7 #define do_extend_cmdline 0 8 8 #endif 9 9 10 + #define NR_BANKS 16 11 + 10 12 static int node_offset(void *fdt, const char *node_path) 11 13 { 12 14 int offset = fdt_path_offset(fdt, node_path);
+1 -1
arch/arm/boot/dts/marco.dtsi
··· 36 36 ranges = <0x40000000 0x40000000 0xa0000000>; 37 37 38 38 l2-cache-controller@c0030000 { 39 - compatible = "sirf,marco-pl310-cache", "arm,pl310-cache"; 39 + compatible = "arm,pl310-cache"; 40 40 reg = <0xc0030000 0x1000>; 41 41 interrupts = <0 59 0>; 42 42 arm,tag-latency = <1 1 1>;
+1 -1
arch/arm/boot/dts/prima2.dtsi
··· 48 48 ranges = <0x40000000 0x40000000 0x80000000>; 49 49 50 50 l2-cache-controller@80040000 { 51 - compatible = "arm,pl310-cache", "sirf,prima2-pl310-cache"; 51 + compatible = "arm,pl310-cache"; 52 52 reg = <0x80040000 0x1000>; 53 53 interrupts = <59>; 54 54 arm,tag-latency = <1 1 1>;
+3 -3
arch/arm/common/mcpm_entry.c
··· 106 106 BUG(); 107 107 } 108 108 109 - int mcpm_cpu_power_down_finish(unsigned int cpu, unsigned int cluster) 109 + int mcpm_wait_for_cpu_powerdown(unsigned int cpu, unsigned int cluster) 110 110 { 111 111 int ret; 112 112 113 - if (WARN_ON_ONCE(!platform_ops || !platform_ops->power_down_finish)) 113 + if (WARN_ON_ONCE(!platform_ops || !platform_ops->wait_for_powerdown)) 114 114 return -EUNATCH; 115 115 116 - ret = platform_ops->power_down_finish(cpu, cluster); 116 + ret = platform_ops->wait_for_powerdown(cpu, cluster); 117 117 if (ret) 118 118 pr_warn("%s: cpu %u, cluster %u failed to power down (%d)\n", 119 119 __func__, cpu, cluster, ret);
+1 -1
arch/arm/common/mcpm_platsmp.c
··· 62 62 63 63 cpu_to_pcpu(cpu, &pcpu, &pcluster); 64 64 65 - return !mcpm_cpu_power_down_finish(pcpu, pcluster); 65 + return !mcpm_wait_for_cpu_powerdown(pcpu, pcluster); 66 66 } 67 67 68 68 static int mcpm_cpu_disable(unsigned int cpu)
+1
arch/arm/include/asm/Kbuild
··· 21 21 generic-y += poll.h 22 22 generic-y += preempt.h 23 23 generic-y += resource.h 24 + generic-y += rwsem.h 24 25 generic-y += sections.h 25 26 generic-y += segment.h 26 27 generic-y += sembuf.h
+1 -1
arch/arm/include/asm/assembler.h
··· 312 312 * you cannot return to the original mode. 313 313 */ 314 314 .macro safe_svcmode_maskall reg:req 315 - #if __LINUX_ARM_ARCH__ >= 6 315 + #if __LINUX_ARM_ARCH__ >= 6 && !defined(CONFIG_CPU_V7M) 316 316 mrs \reg , cpsr 317 317 eor \reg, \reg, #HYP_MODE 318 318 tst \reg, #MODE_MASK
+3 -1
arch/arm/include/asm/cacheflush.h
··· 212 212 static inline void __flush_icache_all(void) 213 213 { 214 214 __flush_icache_preferred(); 215 - dsb(); 215 + dsb(ishst); 216 216 } 217 217 218 218 /* ··· 487 487 int set_memory_x(unsigned long addr, int numpages); 488 488 int set_memory_nx(unsigned long addr, int numpages); 489 489 490 + void flush_uprobe_xol_access(struct page *page, unsigned long uaddr, 491 + void *kaddr, unsigned long len); 490 492 #endif
+12 -13
arch/arm/include/asm/cp15.h
··· 42 42 #ifndef __ASSEMBLY__ 43 43 44 44 #if __LINUX_ARM_ARCH__ >= 4 45 - #define vectors_high() (cr_alignment & CR_V) 45 + #define vectors_high() (get_cr() & CR_V) 46 46 #else 47 47 #define vectors_high() (0) 48 48 #endif 49 49 50 50 #ifdef CONFIG_CPU_CP15 51 51 52 - extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ 53 52 extern unsigned long cr_alignment; /* defined in entry-armv.S */ 54 53 55 - static inline unsigned int get_cr(void) 54 + static inline unsigned long get_cr(void) 56 55 { 57 - unsigned int val; 56 + unsigned long val; 58 57 asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc"); 59 58 return val; 60 59 } 61 60 62 - static inline void set_cr(unsigned int val) 61 + static inline void set_cr(unsigned long val) 63 62 { 64 63 asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR" 65 64 : : "r" (val) : "cc"); ··· 78 79 : : "r" (val)); 79 80 isb(); 80 81 } 81 - 82 - #ifndef CONFIG_SMP 83 - extern void adjust_cr(unsigned long mask, unsigned long set); 84 - #endif 85 82 86 83 #define CPACC_FULL(n) (3 << (n * 2)) 87 84 #define CPACC_SVC(n) (1 << (n * 2)) ··· 101 106 #else /* ifdef CONFIG_CPU_CP15 */ 102 107 103 108 /* 104 - * cr_alignment and cr_no_alignment are tightly coupled to cp15 (at least in the 105 - * minds of the developers). Yielding 0 for machines without a cp15 (and making 106 - * it read-only) is fine for most cases and saves quite some #ifdeffery. 109 + * cr_alignment is tightly coupled to cp15 (at least in the minds of the 110 + * developers). Yielding 0 for machines without a cp15 (and making it 111 + * read-only) is fine for most cases and saves quite some #ifdeffery. 107 112 */ 108 - #define cr_no_alignment UL(0) 109 113 #define cr_alignment UL(0) 114 + 115 + static inline unsigned long get_cr(void) 116 + { 117 + return 0; 118 + } 110 119 111 120 #endif /* ifdef CONFIG_CPU_CP15 / else */ 112 121
+1
arch/arm/include/asm/cputype.h
··· 72 72 #define ARM_CPU_PART_CORTEX_A15 0xC0F0 73 73 #define ARM_CPU_PART_CORTEX_A7 0xC070 74 74 #define ARM_CPU_PART_CORTEX_A12 0xC0D0 75 + #define ARM_CPU_PART_CORTEX_A17 0xC0E0 75 76 76 77 #define ARM_CPU_XSCALE_ARCH_MASK 0xe000 77 78 #define ARM_CPU_XSCALE_ARCH_V1 0x2000
+24 -1
arch/arm/include/asm/dma-mapping.h
··· 58 58 #ifndef __arch_pfn_to_dma 59 59 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) 60 60 { 61 + if (dev) 62 + pfn -= dev->dma_pfn_offset; 61 63 return (dma_addr_t)__pfn_to_bus(pfn); 62 64 } 63 65 64 66 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) 65 67 { 66 - return __bus_to_pfn(addr); 68 + unsigned long pfn = __bus_to_pfn(addr); 69 + 70 + if (dev) 71 + pfn += dev->dma_pfn_offset; 72 + 73 + return pfn; 67 74 } 68 75 69 76 static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) 70 77 { 78 + if (dev) { 79 + unsigned long pfn = dma_to_pfn(dev, addr); 80 + 81 + return phys_to_virt(__pfn_to_phys(pfn)); 82 + } 83 + 71 84 return (void *)__bus_to_virt((unsigned long)addr); 72 85 } 73 86 74 87 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) 75 88 { 89 + if (dev) 90 + return pfn_to_dma(dev, virt_to_pfn(addr)); 91 + 76 92 return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); 77 93 } 78 94 ··· 120 104 return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask); 121 105 } 122 106 #define dma_max_pfn(dev) dma_max_pfn(dev) 107 + 108 + static inline int set_arch_dma_coherent_ops(struct device *dev) 109 + { 110 + set_dma_ops(dev, &arm_coherent_dma_ops); 111 + return 0; 112 + } 113 + #define set_arch_dma_coherent_ops(dev) set_arch_dma_coherent_ops(dev) 123 114 124 115 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 125 116 {
+4 -17
arch/arm/include/asm/fixmap.h
··· 1 1 #ifndef _ASM_FIXMAP_H 2 2 #define _ASM_FIXMAP_H 3 3 4 - /* 5 - * Nothing too fancy for now. 6 - * 7 - * On ARM we already have well known fixed virtual addresses imposed by 8 - * the architecture such as the vector page which is located at 0xffff0000, 9 - * therefore a second level page table is already allocated covering 10 - * 0xfff00000 upwards. 11 - * 12 - * The cache flushing code in proc-xscale.S uses the virtual area between 13 - * 0xfffe0000 and 0xfffeffff. 14 - */ 15 - 16 - #define FIXADDR_START 0xfff00000UL 17 - #define FIXADDR_TOP 0xfffe0000UL 4 + #define FIXADDR_START 0xffc00000UL 5 + #define FIXADDR_TOP 0xffe00000UL 18 6 #define FIXADDR_SIZE (FIXADDR_TOP - FIXADDR_START) 19 7 20 - #define FIX_KMAP_BEGIN 0 21 - #define FIX_KMAP_END (FIXADDR_SIZE >> PAGE_SHIFT) 8 + #define FIX_KMAP_NR_PTES (FIXADDR_SIZE >> PAGE_SHIFT) 22 9 23 10 #define __fix_to_virt(x) (FIXADDR_START + ((x) << PAGE_SHIFT)) 24 11 #define __virt_to_fix(x) (((x) - FIXADDR_START) >> PAGE_SHIFT) ··· 14 27 15 28 static inline unsigned long fix_to_virt(const unsigned int idx) 16 29 { 17 - if (idx >= FIX_KMAP_END) 30 + if (idx >= FIX_KMAP_NR_PTES) 18 31 __this_fixmap_does_not_exist(); 19 32 return __fix_to_virt(idx); 20 33 }
-8
arch/arm/include/asm/glue-df.h
··· 31 31 #undef CPU_DABORT_HANDLER 32 32 #undef MULTI_DABORT 33 33 34 - #if defined(CONFIG_CPU_ARM710) 35 - # ifdef CPU_DABORT_HANDLER 36 - # define MULTI_DABORT 1 37 - # else 38 - # define CPU_DABORT_HANDLER cpu_arm7_data_abort 39 - # endif 40 - #endif 41 - 42 34 #ifdef CONFIG_CPU_ABRT_EV4 43 35 # ifdef CPU_DABORT_HANDLER 44 36 # define MULTI_DABORT 1
+72 -32
arch/arm/include/asm/hardware/cache-l2x0.h
··· 26 26 #define L2X0_CACHE_TYPE 0x004 27 27 #define L2X0_CTRL 0x100 28 28 #define L2X0_AUX_CTRL 0x104 29 - #define L2X0_TAG_LATENCY_CTRL 0x108 30 - #define L2X0_DATA_LATENCY_CTRL 0x10C 29 + #define L310_TAG_LATENCY_CTRL 0x108 30 + #define L310_DATA_LATENCY_CTRL 0x10C 31 31 #define L2X0_EVENT_CNT_CTRL 0x200 32 32 #define L2X0_EVENT_CNT1_CFG 0x204 33 33 #define L2X0_EVENT_CNT0_CFG 0x208 ··· 54 54 #define L2X0_LOCKDOWN_WAY_D_BASE 0x900 55 55 #define L2X0_LOCKDOWN_WAY_I_BASE 0x904 56 56 #define L2X0_LOCKDOWN_STRIDE 0x08 57 - #define L2X0_ADDR_FILTER_START 0xC00 58 - #define L2X0_ADDR_FILTER_END 0xC04 57 + #define L310_ADDR_FILTER_START 0xC00 58 + #define L310_ADDR_FILTER_END 0xC04 59 59 #define L2X0_TEST_OPERATION 0xF00 60 60 #define L2X0_LINE_DATA 0xF10 61 61 #define L2X0_LINE_TAG 0xF30 62 62 #define L2X0_DEBUG_CTRL 0xF40 63 - #define L2X0_PREFETCH_CTRL 0xF60 64 - #define L2X0_POWER_CTRL 0xF80 65 - #define L2X0_DYNAMIC_CLK_GATING_EN (1 << 1) 66 - #define L2X0_STNDBY_MODE_EN (1 << 0) 63 + #define L310_PREFETCH_CTRL 0xF60 64 + #define L310_POWER_CTRL 0xF80 65 + #define L310_DYNAMIC_CLK_GATING_EN (1 << 1) 66 + #define L310_STNDBY_MODE_EN (1 << 0) 67 67 68 68 /* Registers shifts and masks */ 69 69 #define L2X0_CACHE_ID_PART_MASK (0xf << 6) 70 70 #define L2X0_CACHE_ID_PART_L210 (1 << 6) 71 + #define L2X0_CACHE_ID_PART_L220 (2 << 6) 71 72 #define L2X0_CACHE_ID_PART_L310 (3 << 6) 72 73 #define L2X0_CACHE_ID_RTL_MASK 0x3f 73 - #define L2X0_CACHE_ID_RTL_R0P0 0x0 74 - #define L2X0_CACHE_ID_RTL_R1P0 0x2 75 - #define L2X0_CACHE_ID_RTL_R2P0 0x4 76 - #define L2X0_CACHE_ID_RTL_R3P0 0x5 77 - #define L2X0_CACHE_ID_RTL_R3P1 0x6 78 - #define L2X0_CACHE_ID_RTL_R3P2 0x8 74 + #define L210_CACHE_ID_RTL_R0P2_02 0x00 75 + #define L210_CACHE_ID_RTL_R0P1 0x01 76 + #define L210_CACHE_ID_RTL_R0P2_01 0x02 77 + #define L210_CACHE_ID_RTL_R0P3 0x03 78 + #define L210_CACHE_ID_RTL_R0P4 0x0b 79 + #define L210_CACHE_ID_RTL_R0P5 0x0f 80 + #define L220_CACHE_ID_RTL_R1P7_01REL0 0x06 81 + #define L310_CACHE_ID_RTL_R0P0 0x00 82 + #define L310_CACHE_ID_RTL_R1P0 0x02 83 + #define L310_CACHE_ID_RTL_R2P0 0x04 84 + #define L310_CACHE_ID_RTL_R3P0 0x05 85 + #define L310_CACHE_ID_RTL_R3P1 0x06 86 + #define L310_CACHE_ID_RTL_R3P1_50REL0 0x07 87 + #define L310_CACHE_ID_RTL_R3P2 0x08 88 + #define L310_CACHE_ID_RTL_R3P3 0x09 79 89 80 - #define L2X0_AUX_CTRL_MASK 0xc0000fff 90 + /* L2C auxiliary control register - bits common to L2C-210/220/310 */ 91 + #define L2C_AUX_CTRL_WAY_SIZE_SHIFT 17 92 + #define L2C_AUX_CTRL_WAY_SIZE_MASK (7 << 17) 93 + #define L2C_AUX_CTRL_WAY_SIZE(n) ((n) << 17) 94 + #define L2C_AUX_CTRL_EVTMON_ENABLE BIT(20) 95 + #define L2C_AUX_CTRL_PARITY_ENABLE BIT(21) 96 + #define L2C_AUX_CTRL_SHARED_OVERRIDE BIT(22) 97 + /* L2C-210/220 common bits */ 81 98 #define L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT 0 82 - #define L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK 0x7 99 + #define L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK (7 << 0) 83 100 #define L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT 3 84 - #define L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK (0x7 << 3) 101 + #define L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK (7 << 3) 85 102 #define L2X0_AUX_CTRL_TAG_LATENCY_SHIFT 6 86 - #define L2X0_AUX_CTRL_TAG_LATENCY_MASK (0x7 << 6) 103 + #define L2X0_AUX_CTRL_TAG_LATENCY_MASK (7 << 6) 87 104 #define L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT 9 88 - #define L2X0_AUX_CTRL_DIRTY_LATENCY_MASK (0x7 << 9) 89 - #define L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT 16 90 - #define L2X0_AUX_CTRL_WAY_SIZE_SHIFT 17 91 - #define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x7 << 17) 92 - #define L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT 22 93 - #define L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT 26 94 - #define L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT 27 95 - #define L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT 28 96 - #define L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT 29 97 - #define L2X0_AUX_CTRL_EARLY_BRESP_SHIFT 30 105 + #define L2X0_AUX_CTRL_DIRTY_LATENCY_MASK (7 << 9) 106 + #define L2X0_AUX_CTRL_ASSOC_SHIFT 13 107 + #define L2X0_AUX_CTRL_ASSOC_MASK (15 << 13) 108 + /* L2C-210 specific bits */ 109 + #define L210_AUX_CTRL_WRAP_DISABLE BIT(12) 110 + #define L210_AUX_CTRL_WA_OVERRIDE BIT(23) 111 + #define L210_AUX_CTRL_EXCLUSIVE_ABORT BIT(24) 112 + /* L2C-220 specific bits */ 113 + #define L220_AUX_CTRL_EXCLUSIVE_CACHE BIT(12) 114 + #define L220_AUX_CTRL_FWA_SHIFT 23 115 + #define L220_AUX_CTRL_FWA_MASK (3 << 23) 116 + #define L220_AUX_CTRL_NS_LOCKDOWN BIT(26) 117 + #define L220_AUX_CTRL_NS_INT_CTRL BIT(27) 118 + /* L2C-310 specific bits */ 119 + #define L310_AUX_CTRL_FULL_LINE_ZERO BIT(0) /* R2P0+ */ 120 + #define L310_AUX_CTRL_HIGHPRIO_SO_DEV BIT(10) /* R2P0+ */ 121 + #define L310_AUX_CTRL_STORE_LIMITATION BIT(11) /* R2P0+ */ 122 + #define L310_AUX_CTRL_EXCLUSIVE_CACHE BIT(12) 123 + #define L310_AUX_CTRL_ASSOCIATIVITY_16 BIT(16) 124 + #define L310_AUX_CTRL_CACHE_REPLACE_RR BIT(25) /* R2P0+ */ 125 + #define L310_AUX_CTRL_NS_LOCKDOWN BIT(26) 126 + #define L310_AUX_CTRL_NS_INT_CTRL BIT(27) 127 + #define L310_AUX_CTRL_DATA_PREFETCH BIT(28) 128 + #define L310_AUX_CTRL_INSTR_PREFETCH BIT(29) 129 + #define L310_AUX_CTRL_EARLY_BRESP BIT(30) /* R2P0+ */ 98 130 99 - #define L2X0_LATENCY_CTRL_SETUP_SHIFT 0 100 - #define L2X0_LATENCY_CTRL_RD_SHIFT 4 101 - #define L2X0_LATENCY_CTRL_WR_SHIFT 8 131 + #define L310_LATENCY_CTRL_SETUP(n) ((n) << 0) 132 + #define L310_LATENCY_CTRL_RD(n) ((n) << 4) 133 + #define L310_LATENCY_CTRL_WR(n) ((n) << 8) 102 134 103 - #define L2X0_ADDR_FILTER_EN 1 135 + #define L310_ADDR_FILTER_EN 1 136 + 137 + #define L310_PREFETCH_CTRL_OFFSET_MASK 0x1f 138 + #define L310_PREFETCH_CTRL_DBL_LINEFILL_INCR BIT(23) 139 + #define L310_PREFETCH_CTRL_PREFETCH_DROP BIT(24) 140 + #define L310_PREFETCH_CTRL_DBL_LINEFILL_WRAP BIT(27) 141 + #define L310_PREFETCH_CTRL_DATA_PREFETCH BIT(28) 142 + #define L310_PREFETCH_CTRL_INSTR_PREFETCH BIT(29) 143 + #define L310_PREFETCH_CTRL_DBL_LINEFILL BIT(30) 104 144 105 145 #define L2X0_CTRL_EN 1 106 146
+1
arch/arm/include/asm/highmem.h
··· 18 18 } while (0) 19 19 20 20 extern pte_t *pkmap_page_table; 21 + extern pte_t *fixmap_page_table; 21 22 22 23 extern void *kmap_high(struct page *page); 23 24 extern void kunmap_high(struct page *page);
+6
arch/arm/include/asm/io.h
··· 179 179 /* PCI fixed i/o mapping */ 180 180 #define PCI_IO_VIRT_BASE 0xfee00000 181 181 182 + #if defined(CONFIG_PCI) 183 + void pci_ioremap_set_mem_type(int mem_type); 184 + #else 185 + static inline void pci_ioremap_set_mem_type(int mem_type) {} 186 + #endif 187 + 182 188 extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr); 183 189 184 190 /*
+4 -3
arch/arm/include/asm/mach/arch.h
··· 14 14 #include <linux/reboot.h> 15 15 16 16 struct tag; 17 - struct meminfo; 18 17 struct pt_regs; 19 18 struct smp_operations; 20 19 #ifdef CONFIG_SMP ··· 44 45 unsigned char reserve_lp1 :1; /* never has lp1 */ 45 46 unsigned char reserve_lp2 :1; /* never has lp2 */ 46 47 enum reboot_mode reboot_mode; /* default restart mode */ 48 + unsigned l2c_aux_val; /* L2 cache aux value */ 49 + unsigned l2c_aux_mask; /* L2 cache aux mask */ 50 + void (*l2c_write_sec)(unsigned long, unsigned); 47 51 struct smp_operations *smp; /* SMP operations */ 48 52 bool (*smp_init)(void); 49 - void (*fixup)(struct tag *, char **, 50 - struct meminfo *); 53 + void (*fixup)(struct tag *, char **); 51 54 void (*init_meminfo)(void); 52 55 void (*reserve)(void);/* reserve mem blocks */ 53 56 void (*map_io)(void);/* IO mapping function */
+4 -4
arch/arm/include/asm/mcpm.h
··· 98 98 * previously in which case the caller should take appropriate action. 99 99 * 100 100 * On success, the CPU is not guaranteed to be truly halted until 101 - * mcpm_cpu_power_down_finish() subsequently returns non-zero for the 101 + * mcpm_wait_for_cpu_powerdown() subsequently returns non-zero for the 102 102 * specified cpu. Until then, other CPUs should make sure they do not 103 103 * trash memory the target CPU might be executing/accessing. 104 104 */ 105 105 void mcpm_cpu_power_down(void); 106 106 107 107 /** 108 - * mcpm_cpu_power_down_finish - wait for a specified CPU to halt, and 108 + * mcpm_wait_for_cpu_powerdown - wait for a specified CPU to halt, and 109 109 * make sure it is powered off 110 110 * 111 111 * @cpu: CPU number within given cluster ··· 127 127 * - zero if the CPU is in a safely parked state 128 128 * - nonzero otherwise (e.g., timeout) 129 129 */ 130 - int mcpm_cpu_power_down_finish(unsigned int cpu, unsigned int cluster); 130 + int mcpm_wait_for_cpu_powerdown(unsigned int cpu, unsigned int cluster); 131 131 132 132 /** 133 133 * mcpm_cpu_suspend - bring the calling CPU in a suspended state ··· 171 171 struct mcpm_platform_ops { 172 172 int (*power_up)(unsigned int cpu, unsigned int cluster); 173 173 void (*power_down)(void); 174 - int (*power_down_finish)(unsigned int cpu, unsigned int cluster); 174 + int (*wait_for_powerdown)(unsigned int cpu, unsigned int cluster); 175 175 void (*suspend)(u64); 176 176 void (*powered_up)(void); 177 177 };
+1 -2
arch/arm/include/asm/memblock.h
··· 1 1 #ifndef _ASM_ARM_MEMBLOCK_H 2 2 #define _ASM_ARM_MEMBLOCK_H 3 3 4 - struct meminfo; 5 4 struct machine_desc; 6 5 7 - void arm_memblock_init(struct meminfo *, const struct machine_desc *); 6 + void arm_memblock_init(const struct machine_desc *); 8 7 phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align); 9 8 10 9 #endif
-2
arch/arm/include/asm/memory.h
··· 83 83 */ 84 84 #define IOREMAP_MAX_ORDER 24 85 85 86 - #define CONSISTENT_END (0xffe00000UL) 87 - 88 86 #else /* CONFIG_MMU */ 89 87 90 88 /*
+51 -15
arch/arm/include/asm/outercache.h
··· 28 28 void (*clean_range)(unsigned long, unsigned long); 29 29 void (*flush_range)(unsigned long, unsigned long); 30 30 void (*flush_all)(void); 31 - void (*inv_all)(void); 32 31 void (*disable)(void); 33 32 #ifdef CONFIG_OUTER_CACHE_SYNC 34 33 void (*sync)(void); 35 34 #endif 36 - void (*set_debug)(unsigned long); 37 35 void (*resume)(void); 36 + 37 + /* This is an ARM L2C thing */ 38 + void (*write_sec)(unsigned long, unsigned); 38 39 }; 39 40 40 41 extern struct outer_cache_fns outer_cache; 41 42 42 43 #ifdef CONFIG_OUTER_CACHE 43 - 44 + /** 45 + * outer_inv_range - invalidate range of outer cache lines 46 + * @start: starting physical address, inclusive 47 + * @end: end physical address, exclusive 48 + */ 44 49 static inline void outer_inv_range(phys_addr_t start, phys_addr_t end) 45 50 { 46 51 if (outer_cache.inv_range) 47 52 outer_cache.inv_range(start, end); 48 53 } 54 + 55 + /** 56 + * outer_clean_range - clean dirty outer cache lines 57 + * @start: starting physical address, inclusive 58 + * @end: end physical address, exclusive 59 + */ 49 60 static inline void outer_clean_range(phys_addr_t start, phys_addr_t end) 50 61 { 51 62 if (outer_cache.clean_range) 52 63 outer_cache.clean_range(start, end); 53 64 } 65 + 66 + /** 67 + * outer_flush_range - clean and invalidate outer cache lines 68 + * @start: starting physical address, inclusive 69 + * @end: end physical address, exclusive 70 + */ 54 71 static inline void outer_flush_range(phys_addr_t start, phys_addr_t end) 55 72 { 56 73 if (outer_cache.flush_range) 57 74 outer_cache.flush_range(start, end); 58 75 } 59 76 77 + /** 78 + * outer_flush_all - clean and invalidate all cache lines in the outer cache 79 + * 80 + * Note: depending on implementation, this may not be atomic - it must 81 + * only be called with interrupts disabled and no other active outer 82 + * cache masters. 83 + * 84 + * It is intended that this function is only used by implementations 85 + * needing to override the outer_cache.disable() method due to security. 86 + * (Some implementations perform this as a clean followed by an invalidate.) 87 + */ 60 88 static inline void outer_flush_all(void) 61 89 { 62 90 if (outer_cache.flush_all) 63 91 outer_cache.flush_all(); 64 92 } 65 93 66 - static inline void outer_inv_all(void) 67 - { 68 - if (outer_cache.inv_all) 69 - outer_cache.inv_all(); 70 - } 94 + /** 95 + * outer_disable - clean, invalidate and disable the outer cache 96 + * 97 + * Disable the outer cache, ensuring that any data contained in the outer 98 + * cache is pushed out to lower levels of system memory. The note and 99 + * conditions above concerning outer_flush_all() applies here. 100 + */ 101 + extern void outer_disable(void); 71 102 72 - static inline void outer_disable(void) 73 - { 74 - if (outer_cache.disable) 75 - outer_cache.disable(); 76 - } 77 - 103 + /** 104 + * outer_resume - restore the cache configuration and re-enable outer cache 105 + * 106 + * Restore any configuration that the cache had when previously enabled, 107 + * and re-enable the outer cache. 108 + */ 78 109 static inline void outer_resume(void) 79 110 { 80 111 if (outer_cache.resume) ··· 121 90 static inline void outer_flush_range(phys_addr_t start, phys_addr_t end) 122 91 { } 123 92 static inline void outer_flush_all(void) { } 124 - static inline void outer_inv_all(void) { } 125 93 static inline void outer_disable(void) { } 126 94 static inline void outer_resume(void) { } 127 95 128 96 #endif 129 97 130 98 #ifdef CONFIG_OUTER_CACHE_SYNC 99 + /** 100 + * outer_sync - perform a sync point for outer cache 101 + * 102 + * Ensure that all outer cache operations are complete and any store 103 + * buffers are drained. 104 + */ 131 105 static inline void outer_sync(void) 132 106 { 133 107 if (outer_cache.sync)
-28
arch/arm/include/asm/setup.h
··· 21 21 #define __tagtable(tag, fn) \ 22 22 static const struct tagtable __tagtable_##fn __tag = { tag, fn } 23 23 24 - /* 25 - * Memory map description 26 - */ 27 - #define NR_BANKS CONFIG_ARM_NR_BANKS 28 - 29 - struct membank { 30 - phys_addr_t start; 31 - phys_addr_t size; 32 - unsigned int highmem; 33 - }; 34 - 35 - struct meminfo { 36 - int nr_banks; 37 - struct membank bank[NR_BANKS]; 38 - }; 39 - 40 - extern struct meminfo meminfo; 41 - 42 - #define for_each_bank(iter,mi) \ 43 - for (iter = 0; iter < (mi)->nr_banks; iter++) 44 - 45 - #define bank_pfn_start(bank) __phys_to_pfn((bank)->start) 46 - #define bank_pfn_end(bank) __phys_to_pfn((bank)->start + (bank)->size) 47 - #define bank_pfn_size(bank) ((bank)->size >> PAGE_SHIFT) 48 - #define bank_phys_start(bank) (bank)->start 49 - #define bank_phys_end(bank) ((bank)->start + (bank)->size) 50 - #define bank_phys_size(bank) (bank)->size 51 - 52 24 extern int arm_add_memory(u64 start, u64 size); 53 25 extern void early_print(const char *str, ...); 54 26 extern void dump_machine_table(void);
+1
arch/arm/kernel/Makefile
··· 39 39 obj-$(CONFIG_ISA_DMA) += dma-isa.o 40 40 obj-$(CONFIG_PCI) += bios32.o isa.o 41 41 obj-$(CONFIG_ARM_CPU_SUSPEND) += sleep.o suspend.o 42 + obj-$(CONFIG_HIBERNATION) += hibernate.o 42 43 obj-$(CONFIG_SMP) += smp.o 43 44 ifdef CONFIG_MMU 44 45 obj-$(CONFIG_SMP) += smp_tlb.o
+3 -2
arch/arm/kernel/atags_parse.c
··· 22 22 #include <linux/fs.h> 23 23 #include <linux/root_dev.h> 24 24 #include <linux/screen_info.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/setup.h> 27 28 #include <asm/system_info.h> ··· 223 222 } 224 223 225 224 if (mdesc->fixup) 226 - mdesc->fixup(tags, &from, &meminfo); 225 + mdesc->fixup(tags, &from); 227 226 228 227 if (tags->hdr.tag == ATAG_CORE) { 229 - if (meminfo.nr_banks != 0) 228 + if (memblock_phys_mem_size()) 230 229 squash_mem_tags(tags); 231 230 save_atags(tags); 232 231 parse_tags(tags);
-4
arch/arm/kernel/devtree.c
··· 27 27 #include <asm/mach/arch.h> 28 28 #include <asm/mach-types.h> 29 29 30 - void __init early_init_dt_add_memory_arch(u64 base, u64 size) 31 - { 32 - arm_add_memory(base, size); 33 - } 34 30 35 31 #ifdef CONFIG_SMP 36 32 extern struct of_cpu_method __cpu_method_of_table[];
+10 -9
arch/arm/kernel/entry-armv.S
··· 344 344 @ 345 345 @ Enable the alignment trap while in kernel mode 346 346 @ 347 - alignment_trap r0 347 + alignment_trap r0, .LCcralign 348 348 349 349 @ 350 350 @ Clear FP to mark the first stack frame ··· 412 412 @ this as a real undefined instruction 413 413 @ 414 414 adr r9, BSYM(ret_from_exception) 415 + 416 + @ IRQs must be enabled before attempting to read the instruction from 417 + @ user space since that could cause a page/translation fault if the 418 + @ page table was modified by another CPU. 419 + enable_irq 415 420 416 421 tst r3, #PSR_T_BIT @ Thumb mode? 417 422 bne __und_usr_thumb ··· 489 484 */ 490 485 .pushsection .fixup, "ax" 491 486 .align 2 492 - 4: mov pc, r9 487 + 4: str r4, [sp, #S_PC] @ retry current instruction 488 + mov pc, r9 493 489 .popsection 494 490 .pushsection __ex_table,"a" 495 491 .long 1b, 4b ··· 523 517 * r9 = normal "successful" return address 524 518 * r10 = this threads thread_info structure 525 519 * lr = unrecognised instruction return address 526 - * IRQs disabled, FIQs enabled. 520 + * IRQs enabled, FIQs enabled. 527 521 */ 528 522 @ 529 523 @ Fall-through from Thumb-2 __und_usr ··· 630 624 #endif 631 625 632 626 do_fpe: 633 - enable_irq 634 627 ldr r4, .LCfp 635 628 add r10, r10, #TI_FPSTATE @ r10 = workspace 636 629 ldr pc, [r4] @ Call FP module USR entry point ··· 657 652 b 1f 658 653 __und_usr_fault_16: 659 654 mov r1, #2 660 - 1: enable_irq 661 - mov r0, sp 655 + 1: mov r0, sp 662 656 adr lr, BSYM(ret_from_exception) 663 657 b __und_fault 664 658 ENDPROC(__und_usr_fault_32) ··· 1147 1143 .data 1148 1144 1149 1145 .globl cr_alignment 1150 - .globl cr_no_alignment 1151 1146 cr_alignment: 1152 - .space 4 1153 - cr_no_alignment: 1154 1147 .space 4 1155 1148 1156 1149 #ifdef CONFIG_MULTI_IRQ_HANDLER
+1 -7
arch/arm/kernel/entry-common.S
··· 365 365 str r0, [sp, #S_OLD_R0] @ Save OLD_R0 366 366 #endif 367 367 zero_fp 368 - 369 - #ifdef CONFIG_ALIGNMENT_TRAP 370 - ldr ip, __cr_alignment 371 - ldr ip, [ip] 372 - mcr p15, 0, ip, c1, c0 @ update control register 373 - #endif 374 - 368 + alignment_trap ip, __cr_alignment 375 369 enable_irq 376 370 ct_user_exit 377 371 get_thread_info tsk
+2 -2
arch/arm/kernel/entry-header.S
··· 37 37 #endif 38 38 .endm 39 39 40 - .macro alignment_trap, rtemp 40 + .macro alignment_trap, rtemp, label 41 41 #ifdef CONFIG_ALIGNMENT_TRAP 42 - ldr \rtemp, .LCcralign 42 + ldr \rtemp, \label 43 43 ldr \rtemp, [\rtemp] 44 44 mcr p15, 0, \rtemp, c1, c0 45 45 #endif
+13
arch/arm/kernel/ftrace.c
··· 14 14 15 15 #include <linux/ftrace.h> 16 16 #include <linux/uaccess.h> 17 + #include <linux/module.h> 17 18 18 19 #include <asm/cacheflush.h> 19 20 #include <asm/opcodes.h> ··· 63 62 return addr; 64 63 } 65 64 #endif 65 + 66 + int ftrace_arch_code_modify_prepare(void) 67 + { 68 + set_all_modules_text_rw(); 69 + return 0; 70 + } 71 + 72 + int ftrace_arch_code_modify_post_process(void) 73 + { 74 + set_all_modules_text_ro(); 75 + return 0; 76 + } 66 77 67 78 static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) 68 79 {
+1 -2
arch/arm/kernel/head-common.S
··· 99 99 str r1, [r5] @ Save machine type 100 100 str r2, [r6] @ Save atags pointer 101 101 cmp r7, #0 102 - bicne r4, r0, #CR_A @ Clear 'A' bit 103 - stmneia r7, {r0, r4} @ Save control register values 102 + strne r0, [r7] @ Save control register values 104 103 b start_kernel 105 104 ENDPROC(__mmap_switched) 106 105
+1 -1
arch/arm/kernel/head.S
··· 475 475 476 476 477 477 #ifdef CONFIG_SMP_ON_UP 478 - __INIT 478 + __HEAD 479 479 __fixup_smp: 480 480 and r3, r9, #0x000f0000 @ architecture version 481 481 teq r3, #0x000f0000 @ CPU ID supported?
+107
arch/arm/kernel/hibernate.c
··· 1 + /* 2 + * Hibernation support specific for ARM 3 + * 4 + * Derived from work on ARM hibernation support by: 5 + * 6 + * Ubuntu project, hibernation support for mach-dove 7 + * Copyright (C) 2010 Nokia Corporation (Hiroshi Doyu) 8 + * Copyright (C) 2010 Texas Instruments, Inc. (Teerth Reddy et al.) 9 + * https://lkml.org/lkml/2010/6/18/4 10 + * https://lists.linux-foundation.org/pipermail/linux-pm/2010-June/027422.html 11 + * https://patchwork.kernel.org/patch/96442/ 12 + * 13 + * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> 14 + * 15 + * License terms: GNU General Public License (GPL) version 2 16 + */ 17 + 18 + #include <linux/mm.h> 19 + #include <linux/suspend.h> 20 + #include <asm/system_misc.h> 21 + #include <asm/idmap.h> 22 + #include <asm/suspend.h> 23 + #include <asm/memory.h> 24 + 25 + extern const void __nosave_begin, __nosave_end; 26 + 27 + int pfn_is_nosave(unsigned long pfn) 28 + { 29 + unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin); 30 + unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1); 31 + 32 + return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn); 33 + } 34 + 35 + void notrace save_processor_state(void) 36 + { 37 + WARN_ON(num_online_cpus() != 1); 38 + local_fiq_disable(); 39 + } 40 + 41 + void notrace restore_processor_state(void) 42 + { 43 + local_fiq_enable(); 44 + } 45 + 46 + /* 47 + * Snapshot kernel memory and reset the system. 48 + * 49 + * swsusp_save() is executed in the suspend finisher so that the CPU 50 + * context pointer and memory are part of the saved image, which is 51 + * required by the resume kernel image to restart execution from 52 + * swsusp_arch_suspend(). 53 + * 54 + * soft_restart is not technically needed, but is used to get success 55 + * returned from cpu_suspend. 56 + * 57 + * When soft reboot completes, the hibernation snapshot is written out. 58 + */ 59 + static int notrace arch_save_image(unsigned long unused) 60 + { 61 + int ret; 62 + 63 + ret = swsusp_save(); 64 + if (ret == 0) 65 + soft_restart(virt_to_phys(cpu_resume)); 66 + return ret; 67 + } 68 + 69 + /* 70 + * Save the current CPU state before suspend / poweroff. 71 + */ 72 + int notrace swsusp_arch_suspend(void) 73 + { 74 + return cpu_suspend(0, arch_save_image); 75 + } 76 + 77 + /* 78 + * Restore page contents for physical pages that were in use during loading 79 + * hibernation image. Switch to idmap_pgd so the physical page tables 80 + * are overwritten with the same contents. 81 + */ 82 + static void notrace arch_restore_image(void *unused) 83 + { 84 + struct pbe *pbe; 85 + 86 + cpu_switch_mm(idmap_pgd, &init_mm); 87 + for (pbe = restore_pblist; pbe; pbe = pbe->next) 88 + copy_page(pbe->orig_address, pbe->address); 89 + 90 + soft_restart(virt_to_phys(cpu_resume)); 91 + } 92 + 93 + static u64 resume_stack[PAGE_SIZE/2/sizeof(u64)] __nosavedata; 94 + 95 + /* 96 + * Resume from the hibernation image. 97 + * Due to the kernel heap / data restore, stack contents change underneath 98 + * and that would make function calls impossible; switch to a temporary 99 + * stack within the nosave region to avoid that problem. 100 + */ 101 + int swsusp_arch_resume(void) 102 + { 103 + extern void call_with_stack(void (*fn)(void *), void *arg, void *sp); 104 + call_with_stack(arch_restore_image, 0, 105 + resume_stack + ARRAY_SIZE(resume_stack)); 106 + return 0; 107 + }
+12
arch/arm/kernel/irq.c
··· 37 37 #include <linux/proc_fs.h> 38 38 #include <linux/export.h> 39 39 40 + #include <asm/hardware/cache-l2x0.h> 40 41 #include <asm/exception.h> 41 42 #include <asm/mach/arch.h> 42 43 #include <asm/mach/irq.h> ··· 116 115 117 116 void __init init_IRQ(void) 118 117 { 118 + int ret; 119 + 119 120 if (IS_ENABLED(CONFIG_OF) && !machine_desc->init_irq) 120 121 irqchip_init(); 121 122 else 122 123 machine_desc->init_irq(); 124 + 125 + if (IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_CACHE_L2X0) && 126 + (machine_desc->l2c_aux_mask || machine_desc->l2c_aux_val)) { 127 + outer_cache.write_sec = machine_desc->l2c_write_sec; 128 + ret = l2x0_of_init(machine_desc->l2c_aux_val, 129 + machine_desc->l2c_aux_mask); 130 + if (ret) 131 + pr_err("L2C: failed to init: %d\n", ret); 132 + } 123 133 } 124 134 125 135 #ifdef CONFIG_MULTI_IRQ_HANDLER
+12 -4
arch/arm/kernel/iwmmxt.S
··· 18 18 #include <asm/ptrace.h> 19 19 #include <asm/thread_info.h> 20 20 #include <asm/asm-offsets.h> 21 + #include <asm/assembler.h> 21 22 22 23 #if defined(CONFIG_CPU_PJ4) || defined(CONFIG_CPU_PJ4B) 23 24 #define PJ4(code...) code ··· 66 65 * r9 = ret_from_exception 67 66 * lr = undefined instr exit 68 67 * 69 - * called from prefetch exception handler with interrupts disabled 68 + * called from prefetch exception handler with interrupts enabled 70 69 */ 71 70 72 71 ENTRY(iwmmxt_task_enable) 72 + inc_preempt_count r10, r3 73 73 74 74 XSC(mrc p15, 0, r2, c15, c1, 0) 75 75 PJ4(mrc p15, 0, r2, c1, c0, 2) 76 76 @ CP0 and CP1 accessible? 77 77 XSC(tst r2, #0x3) 78 78 PJ4(tst r2, #0xf) 79 - movne pc, lr @ if so no business here 79 + bne 4f @ if so no business here 80 80 @ enable access to CP0 and CP1 81 81 XSC(orr r2, r2, #0x3) 82 82 XSC(mcr p15, 0, r2, c15, c1, 0) ··· 138 136 wstrd wR15, [r1, #MMX_WR15] 139 137 140 138 2: teq r0, #0 @ anything to load? 141 - moveq pc, lr 139 + beq 3f 142 140 143 141 concan_load: 144 142 ··· 171 169 @ clear CUP/MUP (only if r1 != 0) 172 170 teq r1, #0 173 171 mov r2, #0 174 - moveq pc, lr 172 + beq 3f 175 173 tmcr wCon, r2 174 + 175 + 3: 176 + #ifdef CONFIG_PREEMPT_COUNT 177 + get_thread_info r10 178 + #endif 179 + 4: dec_preempt_count r10, r3 176 180 mov pc, lr 177 181 178 182 /*
+1
arch/arm/kernel/perf_event_cpu.c
··· 221 221 * PMU platform driver and devicetree bindings. 222 222 */ 223 223 static struct of_device_id cpu_pmu_of_device_ids[] = { 224 + {.compatible = "arm,cortex-a17-pmu", .data = armv7_a17_pmu_init}, 224 225 {.compatible = "arm,cortex-a15-pmu", .data = armv7_a15_pmu_init}, 225 226 {.compatible = "arm,cortex-a12-pmu", .data = armv7_a12_pmu_init}, 226 227 {.compatible = "arm,cortex-a9-pmu", .data = armv7_a9_pmu_init},
+12
arch/arm/kernel/perf_event_v7.c
··· 1599 1599 return 0; 1600 1600 } 1601 1601 1602 + static int armv7_a17_pmu_init(struct arm_pmu *cpu_pmu) 1603 + { 1604 + armv7_a12_pmu_init(cpu_pmu); 1605 + cpu_pmu->name = "ARMv7 Cortex-A17"; 1606 + return 0; 1607 + } 1608 + 1602 1609 /* 1603 1610 * Krait Performance Monitor Region Event Selection Register (PMRESRn) 1604 1611 * ··· 2024 2017 } 2025 2018 2026 2019 static inline int armv7_a12_pmu_init(struct arm_pmu *cpu_pmu) 2020 + { 2021 + return -ENODEV; 2022 + } 2023 + 2024 + static inline int armv7_a17_pmu_init(struct arm_pmu *cpu_pmu) 2027 2025 { 2028 2026 return -ENODEV; 2029 2027 }
+13 -24
arch/arm/kernel/setup.c
··· 72 72 __setup("fpe=", fpe_setup); 73 73 #endif 74 74 75 + extern void init_default_cache_policy(unsigned long); 75 76 extern void paging_init(const struct machine_desc *desc); 76 77 extern void early_paging_init(const struct machine_desc *, 77 78 struct proc_info_list *); ··· 591 590 592 591 pr_info("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", 593 592 cpu_name, read_cpuid_id(), read_cpuid_id() & 15, 594 - proc_arch[cpu_architecture()], cr_alignment); 593 + proc_arch[cpu_architecture()], get_cr()); 595 594 596 595 snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c", 597 596 list->arch_name, ENDIANNESS); ··· 604 603 #ifndef CONFIG_ARM_THUMB 605 604 elf_hwcap &= ~(HWCAP_THUMB | HWCAP_IDIVT); 606 605 #endif 607 - 606 + #ifdef CONFIG_MMU 607 + init_default_cache_policy(list->__cpu_mm_mmu_flags); 608 + #endif 608 609 erratum_a15_798181_init(); 609 610 610 611 feat_v6_fixup(); ··· 631 628 632 629 int __init arm_add_memory(u64 start, u64 size) 633 630 { 634 - struct membank *bank = &meminfo.bank[meminfo.nr_banks]; 635 631 u64 aligned_start; 636 - 637 - if (meminfo.nr_banks >= NR_BANKS) { 638 - pr_crit("NR_BANKS too low, ignoring memory at 0x%08llx\n", 639 - (long long)start); 640 - return -EINVAL; 641 - } 642 632 643 633 /* 644 634 * Ensure that start/size are aligned to a page boundary. ··· 673 677 aligned_start = PHYS_OFFSET; 674 678 } 675 679 676 - bank->start = aligned_start; 677 - bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1); 680 + start = aligned_start; 681 + size = size & ~(phys_addr_t)(PAGE_SIZE - 1); 678 682 679 683 /* 680 684 * Check whether this memory region has non-zero size or 681 685 * invalid node number. 682 686 */ 683 - if (bank->size == 0) 687 + if (size == 0) 684 688 return -EINVAL; 685 689 686 - meminfo.nr_banks++; 690 + memblock_add(start, size); 687 691 return 0; 688 692 } 689 693 ··· 691 695 * Pick out the memory size. We look for mem=size@start, 692 696 * where start and size are "size[KkMm]" 693 697 */ 698 + 694 699 static int __init early_mem(char *p) 695 700 { 696 701 static int usermem __initdata = 0; ··· 706 709 */ 707 710 if (usermem == 0) { 708 711 usermem = 1; 709 - meminfo.nr_banks = 0; 712 + memblock_remove(memblock_start_of_DRAM(), 713 + memblock_end_of_DRAM() - memblock_start_of_DRAM()); 710 714 } 711 715 712 716 start = PHYS_OFFSET; ··· 852 854 static inline void reserve_crashkernel(void) {} 853 855 #endif /* CONFIG_KEXEC */ 854 856 855 - static int __init meminfo_cmp(const void *_a, const void *_b) 856 - { 857 - const struct membank *a = _a, *b = _b; 858 - long cmp = bank_pfn_start(a) - bank_pfn_start(b); 859 - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; 860 - } 861 - 862 857 void __init hyp_mode_check(void) 863 858 { 864 859 #ifdef CONFIG_ARM_VIRT_EXT ··· 894 903 895 904 parse_early_param(); 896 905 897 - sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); 898 - 899 906 early_paging_init(mdesc, lookup_processor_type(read_cpuid_id())); 900 907 setup_dma_zone(mdesc); 901 908 sanity_check_meminfo(); 902 - arm_memblock_init(&meminfo, mdesc); 909 + arm_memblock_init(mdesc); 903 910 904 911 paging_init(mdesc); 905 912 request_standard_resources(mdesc);
+4 -1
arch/arm/kernel/sleep.S
··· 127 127 .align 128 128 ENTRY(cpu_resume) 129 129 ARM_BE8(setend be) @ ensure we are in BE mode 130 + #ifdef CONFIG_ARM_VIRT_EXT 131 + bl __hyp_stub_install_secondary 132 + #endif 133 + safe_svcmode_maskall r1 130 134 mov r1, #0 131 135 ALT_SMP(mrc p15, 0, r0, c0, c0, 5) 132 136 ALT_UP_B(1f) ··· 148 144 ldr r0, [r0, #SLEEP_SAVE_SP_PHYS] 149 145 ldr r0, [r0, r1, lsl #2] 150 146 151 - setmode PSR_I_BIT | PSR_F_BIT | SVC_MODE, r1 @ set SVC, irqs off 152 147 @ load phys pgd, stack, resume fn 153 148 ARM( ldmia r0!, {r1, sp, pc} ) 154 149 THUMB( ldmia r0!, {r1, r2, r3} )
+55 -5
arch/arm/kernel/stacktrace.c
··· 3 3 #include <linux/stacktrace.h> 4 4 5 5 #include <asm/stacktrace.h> 6 + #include <asm/traps.h> 6 7 7 8 #if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) 8 9 /* ··· 62 61 #ifdef CONFIG_STACKTRACE 63 62 struct stack_trace_data { 64 63 struct stack_trace *trace; 64 + unsigned long last_pc; 65 65 unsigned int no_sched_functions; 66 66 unsigned int skip; 67 67 }; ··· 71 69 { 72 70 struct stack_trace_data *data = d; 73 71 struct stack_trace *trace = data->trace; 72 + struct pt_regs *regs; 74 73 unsigned long addr = frame->pc; 75 74 76 75 if (data->no_sched_functions && in_sched_functions(addr)) ··· 83 80 84 81 trace->entries[trace->nr_entries++] = addr; 85 82 83 + if (trace->nr_entries >= trace->max_entries) 84 + return 1; 85 + 86 + /* 87 + * in_exception_text() is designed to test if the PC is one of 88 + * the functions which has an exception stack above it, but 89 + * unfortunately what is in frame->pc is the return LR value, 90 + * not the saved PC value. So, we need to track the previous 91 + * frame PC value when doing this. 92 + */ 93 + addr = data->last_pc; 94 + data->last_pc = frame->pc; 95 + if (!in_exception_text(addr)) 96 + return 0; 97 + 98 + regs = (struct pt_regs *)frame->sp; 99 + 100 + trace->entries[trace->nr_entries++] = regs->ARM_pc; 101 + 86 102 return trace->nr_entries >= trace->max_entries; 87 103 } 88 104 89 - void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 105 + /* This must be noinline to so that our skip calculation works correctly */ 106 + static noinline void __save_stack_trace(struct task_struct *tsk, 107 + struct stack_trace *trace, unsigned int nosched) 90 108 { 91 109 struct stack_trace_data data; 92 110 struct stackframe frame; 93 111 94 112 data.trace = trace; 113 + data.last_pc = ULONG_MAX; 95 114 data.skip = trace->skip; 115 + data.no_sched_functions = nosched; 96 116 97 117 if (tsk != current) { 98 118 #ifdef CONFIG_SMP ··· 128 102 trace->entries[trace->nr_entries++] = ULONG_MAX; 129 103 return; 130 104 #else 131 - data.no_sched_functions = 1; 132 105 frame.fp = thread_saved_fp(tsk); 133 106 frame.sp = thread_saved_sp(tsk); 134 107 frame.lr = 0; /* recovered from the stack */ ··· 136 111 } else { 137 112 register unsigned long current_sp asm ("sp"); 138 113 139 - data.no_sched_functions = 0; 114 + /* We don't want this function nor the caller */ 115 + data.skip += 2; 140 116 frame.fp = (unsigned long)__builtin_frame_address(0); 141 117 frame.sp = current_sp; 142 118 frame.lr = (unsigned long)__builtin_return_address(0); 143 - frame.pc = (unsigned long)save_stack_trace_tsk; 119 + frame.pc = (unsigned long)__save_stack_trace; 144 120 } 145 121 146 122 walk_stackframe(&frame, save_trace, &data); ··· 149 123 trace->entries[trace->nr_entries++] = ULONG_MAX; 150 124 } 151 125 126 + void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace) 127 + { 128 + struct stack_trace_data data; 129 + struct stackframe frame; 130 + 131 + data.trace = trace; 132 + data.skip = trace->skip; 133 + data.no_sched_functions = 0; 134 + 135 + frame.fp = regs->ARM_fp; 136 + frame.sp = regs->ARM_sp; 137 + frame.lr = regs->ARM_lr; 138 + frame.pc = regs->ARM_pc; 139 + 140 + walk_stackframe(&frame, save_trace, &data); 141 + if (trace->nr_entries < trace->max_entries) 142 + trace->entries[trace->nr_entries++] = ULONG_MAX; 143 + } 144 + 145 + void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 146 + { 147 + __save_stack_trace(tsk, trace, 1); 148 + } 149 + 152 150 void save_stack_trace(struct stack_trace *trace) 153 151 { 154 - save_stack_trace_tsk(current, trace); 152 + __save_stack_trace(current, trace, 0); 155 153 } 156 154 EXPORT_SYMBOL_GPL(save_stack_trace); 157 155 #endif
+4 -4
arch/arm/kernel/topology.c
··· 91 91 { 92 92 const struct cpu_efficiency *cpu_eff; 93 93 struct device_node *cn = NULL; 94 - unsigned long min_capacity = (unsigned long)(-1); 94 + unsigned long min_capacity = ULONG_MAX; 95 95 unsigned long max_capacity = 0; 96 96 unsigned long capacity = 0; 97 - int alloc_size, cpu = 0; 97 + int cpu = 0; 98 98 99 - alloc_size = nr_cpu_ids * sizeof(*__cpu_capacity); 100 - __cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT); 99 + __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), 100 + GFP_NOWAIT); 101 101 102 102 for_each_possible_cpu(cpu) { 103 103 const u32 *rate;
+20
arch/arm/kernel/uprobes.c
··· 113 113 return 0; 114 114 } 115 115 116 + void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, 117 + void *src, unsigned long len) 118 + { 119 + void *xol_page_kaddr = kmap_atomic(page); 120 + void *dst = xol_page_kaddr + (vaddr & ~PAGE_MASK); 121 + 122 + preempt_disable(); 123 + 124 + /* Initialize the slot */ 125 + memcpy(dst, src, len); 126 + 127 + /* flush caches (dcache/icache) */ 128 + flush_uprobe_xol_access(page, vaddr, dst, len); 129 + 130 + preempt_enable(); 131 + 132 + kunmap_atomic(xol_page_kaddr); 133 + } 134 + 135 + 116 136 int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) 117 137 { 118 138 struct uprobe_task *utask = current->utask;
+2 -7
arch/arm/mach-bcm/bcm_5301x.c
··· 43 43 "imprecise external abort"); 44 44 } 45 45 46 - static void __init bcm5301x_dt_init(void) 47 - { 48 - l2x0_of_init(0, ~0UL); 49 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 50 - } 51 - 52 46 static const char __initconst *bcm5301x_dt_compat[] = { 53 47 "brcm,bcm4708", 54 48 NULL, 55 49 }; 56 50 57 51 DT_MACHINE_START(BCM5301X, "BCM5301X") 52 + .l2c_aux_val = 0, 53 + .l2c_aux_mask = ~0, 58 54 .init_early = bcm5301x_init_early, 59 - .init_machine = bcm5301x_dt_init, 60 55 .dt_compat = bcm5301x_dt_compat, 61 56 MACHINE_END
+6 -11
arch/arm/mach-berlin/berlin.c
··· 18 18 #include <asm/hardware/cache-l2x0.h> 19 19 #include <asm/mach/arch.h> 20 20 21 - static void __init berlin_init_machine(void) 22 - { 23 - /* 24 - * with DT probing for L2CCs, berlin_init_machine can be removed. 25 - * Note: 88DE3005 (Armada 1500-mini) uses pl310 l2cc 26 - */ 27 - l2x0_of_init(0x70c00000, 0xfeffffff); 28 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 29 - } 30 - 31 21 static const char * const berlin_dt_compat[] = { 32 22 "marvell,berlin", 33 23 NULL, ··· 25 35 26 36 DT_MACHINE_START(BERLIN_DT, "Marvell Berlin") 27 37 .dt_compat = berlin_dt_compat, 28 - .init_machine = berlin_init_machine, 38 + /* 39 + * with DT probing for L2CCs, berlin_init_machine can be removed. 40 + * Note: 88DE3005 (Armada 1500-mini) uses pl310 l2cc 41 + */ 42 + .l2c_aux_val = 0x30c00000, 43 + .l2c_aux_mask = 0xfeffffff, 29 44 MACHINE_END
+3 -4
arch/arm/mach-clps711x/board-clep7312.c
··· 18 18 #include <linux/init.h> 19 19 #include <linux/types.h> 20 20 #include <linux/string.h> 21 + #include <linux/memblock.h> 21 22 22 23 #include <asm/setup.h> 23 24 #include <asm/mach-types.h> ··· 27 26 #include "common.h" 28 27 29 28 static void __init 30 - fixup_clep7312(struct tag *tags, char **cmdline, struct meminfo *mi) 29 + fixup_clep7312(struct tag *tags, char **cmdline) 31 30 { 32 - mi->nr_banks=1; 33 - mi->bank[0].start = 0xc0000000; 34 - mi->bank[0].size = 0x01000000; 31 + memblock_add(0xc0000000, 0x01000000); 35 32 } 36 33 37 34 MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")
+4 -6
arch/arm/mach-clps711x/board-edb7211.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/backlight.h> 18 18 #include <linux/platform_device.h> 19 + #include <linux/memblock.h> 19 20 20 21 #include <linux/mtd/physmap.h> 21 22 #include <linux/mtd/partitions.h> ··· 134 133 } 135 134 136 135 static void __init 137 - fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi) 136 + fixup_edb7211(struct tag *tags, char **cmdline) 138 137 { 139 138 /* 140 139 * Bank start addresses are not present in the information ··· 144 143 * Banks sizes _are_ present in the param block, but we're 145 144 * not using that information yet. 146 145 */ 147 - mi->bank[0].start = 0xc0000000; 148 - mi->bank[0].size = SZ_8M; 149 - mi->bank[1].start = 0xc1000000; 150 - mi->bank[1].size = SZ_8M; 151 - mi->nr_banks = 2; 146 + memblock_add(0xc0000000, SZ_8M); 147 + memblock_add(0xc1000000, SZ_8M); 152 148 } 153 149 154 150 static void __init edb7211_init(void)
+1 -1
arch/arm/mach-clps711x/board-p720t.c
··· 295 295 }; 296 296 297 297 static void __init 298 - fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi) 298 + fixup_p720t(struct tag *tag, char **cmdline) 299 299 { 300 300 /* 301 301 * Our bootloader doesn't setup any tags (yet).
+5 -5
arch/arm/mach-cns3xxx/core.c
··· 272 272 * 273 273 * 1 cycle of latency for setup, read and write accesses 274 274 */ 275 - val = readl(base + L2X0_TAG_LATENCY_CTRL); 275 + val = readl(base + L310_TAG_LATENCY_CTRL); 276 276 val &= 0xfffff888; 277 - writel(val, base + L2X0_TAG_LATENCY_CTRL); 277 + writel(val, base + L310_TAG_LATENCY_CTRL); 278 278 279 279 /* 280 280 * Data RAM Control register ··· 285 285 * 286 286 * 1 cycle of latency for setup, read and write accesses 287 287 */ 288 - val = readl(base + L2X0_DATA_LATENCY_CTRL); 288 + val = readl(base + L310_DATA_LATENCY_CTRL); 289 289 val &= 0xfffff888; 290 - writel(val, base + L2X0_DATA_LATENCY_CTRL); 290 + writel(val, base + L310_DATA_LATENCY_CTRL); 291 291 292 292 /* 32 KiB, 8-way, parity disable */ 293 - l2x0_init(base, 0x00540000, 0xfe000fff); 293 + l2x0_init(base, 0x00500000, 0xfe0f0fff); 294 294 } 295 295 296 296 #endif /* CONFIG_CACHE_L2X0 */
+11 -3
arch/arm/mach-ep93xx/crunch-bits.S
··· 16 16 #include <asm/ptrace.h> 17 17 #include <asm/thread_info.h> 18 18 #include <asm/asm-offsets.h> 19 + #include <asm/assembler.h> 19 20 #include <mach/ep93xx-regs.h> 20 21 21 22 /* ··· 63 62 * r9 = ret_from_exception 64 63 * lr = undefined instr exit 65 64 * 66 - * called from prefetch exception handler with interrupts disabled 65 + * called from prefetch exception handler with interrupts enabled 67 66 */ 68 67 ENTRY(crunch_task_enable) 68 + inc_preempt_count r10, r3 69 + 69 70 ldr r8, =(EP93XX_APB_VIRT_BASE + 0x00130000) @ syscon addr 70 71 71 72 ldr r1, [r8, #0x80] 72 73 tst r1, #0x00800000 @ access to crunch enabled? 73 - movne pc, lr @ if so no business here 74 + bne 2f @ if so no business here 74 75 mov r3, #0xaa @ unlock syscon swlock 75 76 str r3, [r8, #0xc0] 76 77 orr r1, r1, #0x00800000 @ enable access to crunch ··· 145 142 146 143 teq r0, #0 @ anything to load? 147 144 cfldr64eq mvdx0, [r1, #CRUNCH_MVDX0] @ mvdx0 was clobbered 148 - moveq pc, lr 145 + beq 1f 149 146 150 147 crunch_load: 151 148 cfldr64 mvdx0, [r0, #CRUNCH_DSPSC] @ load status word ··· 193 190 cfldr64 mvdx14, [r0, #CRUNCH_MVDX14] 194 191 cfldr64 mvdx15, [r0, #CRUNCH_MVDX15] 195 192 193 + 1: 194 + #ifdef CONFIG_PREEMPT_COUNT 195 + get_thread_info r10 196 + #endif 197 + 2: dec_preempt_count r10, r3 196 198 mov pc, lr 197 199 198 200 /*
-1
arch/arm/mach-exynos/common.h
··· 153 153 NUM_SYS_POWERDOWN, 154 154 }; 155 155 156 - extern unsigned long l2x0_regs_phys; 157 156 struct exynos_pmu_conf { 158 157 void __iomem *reg; 159 158 unsigned int val[NUM_SYS_POWERDOWN];
+2 -22
arch/arm/mach-exynos/exynos.c
··· 30 30 #include "mfc.h" 31 31 #include "regs-pmu.h" 32 32 33 - #define L2_AUX_VAL 0x7C470001 34 - #define L2_AUX_MASK 0xC200ffff 35 - 36 33 static struct map_desc exynos4_iodesc[] __initdata = { 37 34 { 38 35 .virtual = (unsigned long)S3C_VA_SYS, ··· 243 246 exynos_map_io(); 244 247 } 245 248 246 - static int __init exynos4_l2x0_cache_init(void) 247 - { 248 - int ret; 249 - 250 - if (!soc_is_exynos4()) 251 - return 0; 252 - 253 - ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK); 254 - if (ret) 255 - return ret; 256 - 257 - if (IS_ENABLED(CONFIG_S5P_SLEEP)) { 258 - l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); 259 - clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); 260 - } 261 - return 0; 262 - } 263 - early_initcall(exynos4_l2x0_cache_init); 264 - 265 249 static void __init exynos_dt_machine_init(void) 266 250 { 267 251 struct device_node *i2c_np; ··· 311 333 DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") 312 334 /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */ 313 335 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 336 + .l2c_aux_val = 0x3c400001, 337 + .l2c_aux_mask = 0xc20fffff, 314 338 .smp = smp_ops(exynos_smp_ops), 315 339 .map_io = exynos_init_io, 316 340 .init_early = exynos_firmware_init,
+1 -29
arch/arm/mach-exynos/sleep.S
··· 16 16 */ 17 17 18 18 #include <linux/linkage.h> 19 - #include <asm/asm-offsets.h> 20 - #include <asm/hardware/cache-l2x0.h> 21 19 22 20 #define CPU_MASK 0xff0ffff0 23 21 #define CPU_CORTEX_A9 0x410fc090 ··· 51 53 and r0, r0, r1 52 54 ldr r1, =CPU_CORTEX_A9 53 55 cmp r0, r1 54 - bne skip_l2_resume 55 - adr r0, l2x0_regs_phys 56 - ldr r0, [r0] 57 - cmp r0, #0 58 - beq skip_l2_resume 59 - ldr r1, [r0, #L2X0_R_PHY_BASE] 60 - ldr r2, [r1, #L2X0_CTRL] 61 - tst r2, #0x1 62 - bne skip_l2_resume 63 - ldr r2, [r0, #L2X0_R_AUX_CTRL] 64 - str r2, [r1, #L2X0_AUX_CTRL] 65 - ldr r2, [r0, #L2X0_R_TAG_LATENCY] 66 - str r2, [r1, #L2X0_TAG_LATENCY_CTRL] 67 - ldr r2, [r0, #L2X0_R_DATA_LATENCY] 68 - str r2, [r1, #L2X0_DATA_LATENCY_CTRL] 69 - ldr r2, [r0, #L2X0_R_PREFETCH_CTRL] 70 - str r2, [r1, #L2X0_PREFETCH_CTRL] 71 - ldr r2, [r0, #L2X0_R_PWR_CTRL] 72 - str r2, [r1, #L2X0_POWER_CTRL] 73 - mov r2, #1 74 - str r2, [r1, #L2X0_CTRL] 75 - skip_l2_resume: 56 + bleq l2c310_early_resume 76 57 #endif 77 58 b cpu_resume 78 59 ENDPROC(exynos_cpu_resume) 79 - #ifdef CONFIG_CACHE_L2X0 80 - .globl l2x0_regs_phys 81 - l2x0_regs_phys: 82 - .long 0 83 - #endif
+1 -1
arch/arm/mach-footbridge/cats-hw.c
··· 76 76 * hard reboots fail on early boards. 77 77 */ 78 78 static void __init 79 - fixup_cats(struct tag *tags, char **cmdline, struct meminfo *mi) 79 + fixup_cats(struct tag *tags, char **cmdline) 80 80 { 81 81 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) 82 82 screen_info.orig_video_lines = 25;
+1 -1
arch/arm/mach-footbridge/netwinder-hw.c
··· 620 620 * the parameter page. 621 621 */ 622 622 static void __init 623 - fixup_netwinder(struct tag *tags, char **cmdline, struct meminfo *mi) 623 + fixup_netwinder(struct tag *tags, char **cmdline) 624 624 { 625 625 #ifdef CONFIG_ISAPNP 626 626 extern int isapnp_disable;
+9 -12
arch/arm/mach-highbank/highbank.c
··· 51 51 } 52 52 53 53 54 - static void highbank_l2x0_disable(void) 54 + static void highbank_l2c310_write_sec(unsigned long val, unsigned reg) 55 55 { 56 - outer_flush_all(); 57 - /* Disable PL310 L2 Cache controller */ 58 - highbank_smc1(0x102, 0x0); 56 + if (reg == L2X0_CTRL) 57 + highbank_smc1(0x102, val); 58 + else 59 + WARN_ONCE(1, "Highbank L2C310: ignoring write to reg 0x%x\n", 60 + reg); 59 61 } 60 62 61 63 static void __init highbank_init_irq(void) ··· 66 64 67 65 if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9")) 68 66 highbank_scu_map_io(); 69 - 70 - /* Enable PL310 L2 Cache controller */ 71 - if (IS_ENABLED(CONFIG_CACHE_L2X0) && 72 - of_find_compatible_node(NULL, NULL, "arm,pl310-cache")) { 73 - highbank_smc1(0x102, 0x1); 74 - l2x0_of_init(0, ~0UL); 75 - outer_cache.disable = highbank_l2x0_disable; 76 - } 77 67 } 78 68 79 69 static void highbank_power_off(void) ··· 179 185 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE) 180 186 .dma_zone_size = (4ULL * SZ_1G), 181 187 #endif 188 + .l2c_aux_val = 0, 189 + .l2c_aux_mask = ~0, 190 + .l2c_write_sec = highbank_l2c310_write_sec, 182 191 .init_irq = highbank_init_irq, 183 192 .init_machine = highbank_init, 184 193 .dt_compat = highbank_match,
+2 -7
arch/arm/mach-imx/mach-vf610.c
··· 20 20 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 21 21 } 22 22 23 - static void __init vf610_init_irq(void) 24 - { 25 - l2x0_of_init(0, ~0UL); 26 - irqchip_init(); 27 - } 28 - 29 23 static const char *vf610_dt_compat[] __initconst = { 30 24 "fsl,vf610", 31 25 NULL, 32 26 }; 33 27 34 28 DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF610 (Device Tree)") 35 - .init_irq = vf610_init_irq, 29 + .l2c_aux_val = 0, 30 + .l2c_aux_mask = ~0, 36 31 .init_machine = vf610_init_machine, 37 32 .dt_compat = vf610_dt_compat, 38 33 .restart = mxc_restart,
+3 -21
arch/arm/mach-imx/suspend-imx6.S
··· 334 334 * turned into relative ones. 335 335 */ 336 336 337 - #ifdef CONFIG_CACHE_L2X0 338 - .macro pl310_resume 339 - adr r0, l2x0_saved_regs_offset 340 - ldr r2, [r0] 341 - add r2, r2, r0 342 - ldr r0, [r2, #L2X0_R_PHY_BASE] @ get physical base of l2x0 343 - ldr r1, [r2, #L2X0_R_AUX_CTRL] @ get aux_ctrl value 344 - str r1, [r0, #L2X0_AUX_CTRL] @ restore aux_ctrl 345 - mov r1, #0x1 346 - str r1, [r0, #L2X0_CTRL] @ re-enable L2 347 - .endm 348 - 349 - l2x0_saved_regs_offset: 350 - .word l2x0_saved_regs - . 351 - 352 - #else 353 - .macro pl310_resume 354 - .endm 355 - #endif 356 - 357 337 ENTRY(v7_cpu_resume) 358 338 bl v7_invalidate_l1 359 - pl310_resume 339 + #ifdef CONFIG_CACHE_L2X0 340 + bl l2c310_early_resume 341 + #endif 360 342 b cpu_resume 361 343 ENDPROC(v7_cpu_resume)
+3 -5
arch/arm/mach-imx/system.c
··· 124 124 } 125 125 126 126 /* Configure the L2 PREFETCH and POWER registers */ 127 - val = readl_relaxed(l2x0_base + L2X0_PREFETCH_CTRL); 127 + val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL); 128 128 val |= 0x70800000; 129 129 /* 130 130 * The L2 cache controller(PL310) version on the i.MX6D/Q is r3p1-50rel0 ··· 137 137 */ 138 138 if (cpu_is_imx6q()) 139 139 val &= ~(1 << 30 | 1 << 23); 140 - writel_relaxed(val, l2x0_base + L2X0_PREFETCH_CTRL); 141 - val = L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN; 142 - writel_relaxed(val, l2x0_base + L2X0_POWER_CTRL); 140 + writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL); 143 141 144 142 iounmap(l2x0_base); 145 143 of_node_put(np); 146 144 147 145 out: 148 - l2x0_of_init(0, ~0UL); 146 + l2x0_of_init(0, ~0); 149 147 } 150 148 #endif
-6
arch/arm/mach-msm/board-halibut.c
··· 83 83 platform_add_devices(devices, ARRAY_SIZE(devices)); 84 84 } 85 85 86 - static void __init halibut_fixup(struct tag *tags, char **cmdline, 87 - struct meminfo *mi) 88 - { 89 - } 90 - 91 86 static void __init halibut_map_io(void) 92 87 { 93 88 msm_map_common_io(); ··· 95 100 96 101 MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)") 97 102 .atag_offset = 0x100, 98 - .fixup = halibut_fixup, 99 103 .map_io = halibut_map_io, 100 104 .init_early = halibut_init_early, 101 105 .init_irq = halibut_init_irq,
+4 -9
arch/arm/mach-msm/board-mahimahi.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/kernel.h> 24 24 #include <linux/platform_device.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/mach-types.h> 27 28 #include <asm/mach/arch.h> ··· 53 52 platform_add_devices(devices, ARRAY_SIZE(devices)); 54 53 } 55 54 56 - static void __init mahimahi_fixup(struct tag *tags, char **cmdline, 57 - struct meminfo *mi) 55 + static void __init mahimahi_fixup(struct tag *tags, char **cmdline) 58 56 { 59 - mi->nr_banks = 2; 60 - mi->bank[0].start = PHYS_OFFSET; 61 - mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET); 62 - mi->bank[0].size = (219*1024*1024); 63 - mi->bank[1].start = MSM_HIGHMEM_BASE; 64 - mi->bank[1].node = PHYS_TO_NID(MSM_HIGHMEM_BASE); 65 - mi->bank[1].size = MSM_HIGHMEM_SIZE; 57 + memblock_add(PHYS_OFFSET, 219*SZ_1M); 58 + memblock_add(MSM_HIGHMEM_BASE, MSM_HIGHMEM_SIZE); 66 59 } 67 60 68 61 static void __init mahimahi_map_io(void)
+1 -2
arch/arm/mach-msm/board-msm7x30.c
··· 40 40 #include "proc_comm.h" 41 41 #include "common.h" 42 42 43 - static void __init msm7x30_fixup(struct tag *tag, char **cmdline, 44 - struct meminfo *mi) 43 + static void __init msm7x30_fixup(struct tag *tag, char **cmdline) 45 44 { 46 45 for (; tag->hdr.size; tag = tag_next(tag)) 47 46 if (tag->hdr.tag == ATAG_MEM && tag->u.mem.start == 0x200000) {
+5 -8
arch/arm/mach-msm/board-sapphire.c
··· 35 35 36 36 #include <linux/mtd/nand.h> 37 37 #include <linux/mtd/partitions.h> 38 + #include <linux/memblock.h> 38 39 39 40 #include "gpio_chip.h" 40 41 #include "board-sapphire.h" ··· 75 74 } 76 75 }; 77 76 78 - static void __init sapphire_fixup(struct tag *tags, char **cmdline, 79 - struct meminfo *mi) 77 + static void __init sapphire_fixup(struct tag *tags, char **cmdline) 80 78 { 81 79 int smi_sz = parse_tag_smi((const struct tag *)tags); 82 80 83 - mi->nr_banks = 1; 84 - mi->bank[0].start = PHYS_OFFSET; 85 - mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET); 86 81 if (smi_sz == 32) { 87 - mi->bank[0].size = (84*1024*1024); 82 + memblock_add(PHYS_OFFSET, 84*SZ_1M); 88 83 } else if (smi_sz == 64) { 89 - mi->bank[0].size = (101*1024*1024); 84 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 90 85 } else { 86 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 91 87 /* Give a default value when not get smi size */ 92 88 smi_sz = 64; 93 - mi->bank[0].size = (101*1024*1024); 94 89 } 95 90 } 96 91
+3 -5
arch/arm/mach-msm/board-trout.c
··· 19 19 #include <linux/init.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/clkdev.h> 22 + #include <linux/memblock.h> 22 23 23 24 #include <asm/system_info.h> 24 25 #include <asm/mach-types.h> ··· 56 55 msm_init_irq(); 57 56 } 58 57 59 - static void __init trout_fixup(struct tag *tags, char **cmdline, 60 - struct meminfo *mi) 58 + static void __init trout_fixup(struct tag *tags, char **cmdline) 61 59 { 62 - mi->nr_banks = 1; 63 - mi->bank[0].start = PHYS_OFFSET; 64 - mi->bank[0].size = (101*1024*1024); 60 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 65 61 } 66 62 67 63 static void __init trout_init(void)
+6
arch/arm/mach-mvebu/board-v7.c
··· 182 182 }; 183 183 184 184 DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)") 185 + .l2c_aux_val = 0, 186 + .l2c_aux_mask = ~0, 185 187 .smp = smp_ops(armada_xp_smp_ops), 186 188 .init_machine = mvebu_dt_init, 187 189 .init_time = mvebu_timer_and_clk_init, ··· 197 195 }; 198 196 199 197 DT_MACHINE_START(ARMADA_375_DT, "Marvell Armada 375 (Device Tree)") 198 + .l2c_aux_val = 0, 199 + .l2c_aux_mask = ~0, 200 200 .init_time = mvebu_timer_and_clk_init, 201 201 .init_machine = mvebu_dt_init, 202 202 .restart = mvebu_restart, ··· 212 208 }; 213 209 214 210 DT_MACHINE_START(ARMADA_38X_DT, "Marvell Armada 380/385 (Device Tree)") 211 + .l2c_aux_val = 0, 212 + .l2c_aux_mask = ~0, 215 213 .init_time = mvebu_timer_and_clk_init, 216 214 .restart = mvebu_restart, 217 215 .dt_compat = armada_38x_dt_compat,
+3 -10
arch/arm/mach-nomadik/cpu-8815.c
··· 143 143 } 144 144 device_initcall(cpu8815_mmcsd_init); 145 145 146 - static void __init cpu8815_init_of(void) 147 - { 148 - #ifdef CONFIG_CACHE_L2X0 149 - /* At full speed latency must be >=2, so 0x249 in low bits */ 150 - l2x0_of_init(0x00730249, 0xfe000fff); 151 - #endif 152 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 153 - } 154 - 155 146 static const char * cpu8815_board_compat[] = { 156 147 "calaosystems,usb-s8815", 157 148 NULL, 158 149 }; 159 150 160 151 DT_MACHINE_START(NOMADIK_DT, "Nomadik STn8815") 152 + /* At full speed latency must be >=2, so 0x249 in low bits */ 153 + .l2c_aux_val = 0x00700249, 154 + .l2c_aux_mask = 0xfe0fefff, 161 155 .map_io = cpu8815_map_io, 162 - .init_machine = cpu8815_init_of, 163 156 .restart = cpu8815_restart, 164 157 .dt_compat = cpu8815_board_compat, 165 158 MACHINE_END
+1
arch/arm/mach-omap2/Kconfig
··· 65 65 select ARCH_HAS_OPP 66 66 select ARM_GIC 67 67 select MACH_OMAP_GENERIC 68 + select MIGHT_HAVE_CACHE_L2X0 68 69 69 70 config SOC_DRA7XX 70 71 bool "TI DRA7XX"
+1
arch/arm/mach-omap2/common.h
··· 91 91 extern void omap3_secure_sync32k_timer_init(void); 92 92 extern void omap3_gptimer_timer_init(void); 93 93 extern void omap4_local_timer_init(void); 94 + int omap_l2_cache_init(void); 94 95 extern void omap5_realtime_timer_init(void); 95 96 96 97 void omap2420_init_early(void);
+2
arch/arm/mach-omap2/io.c
··· 609 609 am43xx_clockdomains_init(); 610 610 am43xx_hwmod_init(); 611 611 omap_hwmod_init_postsetup(); 612 + omap_l2_cache_init(); 612 613 omap_clk_soc_init = am43xx_dt_clk_init; 613 614 } 614 615 ··· 641 640 omap44xx_clockdomains_init(); 642 641 omap44xx_hwmod_init(); 643 642 omap_hwmod_init_postsetup(); 643 + omap_l2_cache_init(); 644 644 omap_clk_soc_init = omap4xxx_dt_clk_init; 645 645 } 646 646
+6 -10
arch/arm/mach-omap2/omap-mpuss-lowpower.c
··· 187 187 * in every restore MPUSS OFF path. 188 188 */ 189 189 #ifdef CONFIG_CACHE_L2X0 190 - static void save_l2x0_context(void) 190 + static void __init save_l2x0_context(void) 191 191 { 192 - u32 val; 193 - void __iomem *l2x0_base = omap4_get_l2cache_base(); 194 - if (l2x0_base) { 195 - val = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 196 - writel_relaxed(val, sar_base + L2X0_AUXCTRL_OFFSET); 197 - val = readl_relaxed(l2x0_base + L2X0_PREFETCH_CTRL); 198 - writel_relaxed(val, sar_base + L2X0_PREFETCH_CTRL_OFFSET); 199 - } 192 + writel_relaxed(l2x0_saved_regs.aux_ctrl, 193 + sar_base + L2X0_AUXCTRL_OFFSET); 194 + writel_relaxed(l2x0_saved_regs.prefetch_ctrl, 195 + sar_base + L2X0_PREFETCH_CTRL_OFFSET); 200 196 } 201 197 #else 202 - static void save_l2x0_context(void) 198 + static void __init save_l2x0_context(void) 203 199 {} 204 200 #endif 205 201
+35 -53
arch/arm/mach-omap2/omap4-common.c
··· 167 167 return l2cache_base; 168 168 } 169 169 170 - static void omap4_l2x0_disable(void) 170 + static void omap4_l2c310_write_sec(unsigned long val, unsigned reg) 171 171 { 172 - outer_flush_all(); 173 - /* Disable PL310 L2 Cache controller */ 174 - omap_smc1(0x102, 0x0); 172 + unsigned smc_op; 173 + 174 + switch (reg) { 175 + case L2X0_CTRL: 176 + smc_op = OMAP4_MON_L2X0_CTRL_INDEX; 177 + break; 178 + 179 + case L2X0_AUX_CTRL: 180 + smc_op = OMAP4_MON_L2X0_AUXCTRL_INDEX; 181 + break; 182 + 183 + case L2X0_DEBUG_CTRL: 184 + smc_op = OMAP4_MON_L2X0_DBG_CTRL_INDEX; 185 + break; 186 + 187 + case L310_PREFETCH_CTRL: 188 + smc_op = OMAP4_MON_L2X0_PREFETCH_INDEX; 189 + break; 190 + 191 + default: 192 + WARN_ONCE(1, "OMAP L2C310: ignoring write to reg 0x%x\n", reg); 193 + return; 194 + } 195 + 196 + omap_smc1(smc_op, val); 175 197 } 176 198 177 - static void omap4_l2x0_set_debug(unsigned long val) 199 + int __init omap_l2_cache_init(void) 178 200 { 179 - /* Program PL310 L2 Cache controller debug register */ 180 - omap_smc1(0x100, val); 181 - } 182 - 183 - static int __init omap_l2_cache_init(void) 184 - { 185 - u32 aux_ctrl = 0; 186 - 187 - /* 188 - * To avoid code running on other OMAPs in 189 - * multi-omap builds 190 - */ 191 - if (!cpu_is_omap44xx()) 192 - return -ENODEV; 201 + u32 aux_ctrl; 193 202 194 203 /* Static mapping, never released */ 195 204 l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K); 196 205 if (WARN_ON(!l2cache_base)) 197 206 return -ENOMEM; 198 207 199 - /* 200 - * 16-way associativity, parity disabled 201 - * Way size - 32KB (es1.0) 202 - * Way size - 64KB (es2.0 +) 203 - */ 204 - aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) | 205 - (0x1 << 25) | 206 - (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) | 207 - (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT)); 208 + /* 16-way associativity, parity disabled, way size - 64KB (es2.0 +) */ 209 + aux_ctrl = L2C_AUX_CTRL_SHARED_OVERRIDE | 210 + L310_AUX_CTRL_DATA_PREFETCH | 211 + L310_AUX_CTRL_INSTR_PREFETCH; 208 212 209 - if (omap_rev() == OMAP4430_REV_ES1_0) { 210 - aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT; 211 - } else { 212 - aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | 213 - (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | 214 - (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) | 215 - (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | 216 - (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT)); 217 - } 218 - if (omap_rev() != OMAP4430_REV_ES1_0) 219 - omap_smc1(0x109, aux_ctrl); 220 - 221 - /* Enable PL310 L2 Cache controller */ 222 - omap_smc1(0x102, 0x1); 223 - 213 + outer_cache.write_sec = omap4_l2c310_write_sec; 224 214 if (of_have_populated_dt()) 225 - l2x0_of_init(aux_ctrl, L2X0_AUX_CTRL_MASK); 215 + l2x0_of_init(aux_ctrl, 0xcf9fffff); 226 216 else 227 - l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK); 228 - 229 - /* 230 - * Override default outer_cache.disable with a OMAP4 231 - * specific one 232 - */ 233 - outer_cache.disable = omap4_l2x0_disable; 234 - outer_cache.set_debug = omap4_l2x0_set_debug; 217 + l2x0_init(l2cache_base, aux_ctrl, 0xcf9fffff); 235 218 236 219 return 0; 237 220 } 238 - omap_early_initcall(omap_l2_cache_init); 239 221 #endif 240 222 241 223 void __iomem *omap4_get_sar_ram_base(void)
+1 -2
arch/arm/mach-orion5x/common.c
··· 365 365 * Many orion-based systems have buggy bootloader implementations. 366 366 * This is a common fixup for bogus memory tags. 367 367 */ 368 - void __init tag_fixup_mem32(struct tag *t, char **from, 369 - struct meminfo *meminfo) 368 + void __init tag_fixup_mem32(struct tag *t, char **from) 370 369 { 371 370 for (; t->hdr.size; t = tag_next(t)) 372 371 if (t->hdr.tag == ATAG_MEM &&
+1 -2
arch/arm/mach-orion5x/common.h
··· 64 64 struct pci_bus *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys); 65 65 int orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin); 66 66 67 - struct meminfo; 68 67 struct tag; 69 - extern void __init tag_fixup_mem32(struct tag *, char **, struct meminfo *); 68 + extern void __init tag_fixup_mem32(struct tag *, char **); 70 69 71 70 #ifdef CONFIG_MACH_MSS2_DT 72 71 extern void mss2_init(void);
-1
arch/arm/mach-prima2/Makefile
··· 2 2 obj-y += common.o 3 3 obj-y += rtciobrg.o 4 4 obj-$(CONFIG_DEBUG_LL) += lluart.o 5 - obj-$(CONFIG_CACHE_L2X0) += l2x0.o 6 5 obj-$(CONFIG_SUSPEND) += pm.o sleep.o 7 6 obj-$(CONFIG_SMP) += platsmp.o headsmp.o 8 7 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
+6
arch/arm/mach-prima2/common.c
··· 34 34 35 35 DT_MACHINE_START(ATLAS6_DT, "Generic ATLAS6 (Flattened Device Tree)") 36 36 /* Maintainer: Barry Song <baohua.song@csr.com> */ 37 + .l2c_aux_val = 0, 38 + .l2c_aux_mask = ~0, 37 39 .map_io = sirfsoc_map_io, 38 40 .init_late = sirfsoc_init_late, 39 41 .dt_compat = atlas6_dt_match, ··· 50 48 51 49 DT_MACHINE_START(PRIMA2_DT, "Generic PRIMA2 (Flattened Device Tree)") 52 50 /* Maintainer: Barry Song <baohua.song@csr.com> */ 51 + .l2c_aux_val = 0, 52 + .l2c_aux_mask = ~0, 53 53 .map_io = sirfsoc_map_io, 54 54 .dma_zone_size = SZ_256M, 55 55 .init_late = sirfsoc_init_late, ··· 67 63 68 64 DT_MACHINE_START(MARCO_DT, "Generic MARCO (Flattened Device Tree)") 69 65 /* Maintainer: Barry Song <baohua.song@csr.com> */ 66 + .l2c_aux_val = 0, 67 + .l2c_aux_mask = ~0, 70 68 .smp = smp_ops(sirfsoc_smp_ops), 71 69 .map_io = sirfsoc_map_io, 72 70 .init_late = sirfsoc_init_late,
-49
arch/arm/mach-prima2/l2x0.c
··· 1 - /* 2 - * l2 cache initialization for CSR SiRFprimaII 3 - * 4 - * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 - * 6 - * Licensed under GPLv2 or later. 7 - */ 8 - 9 - #include <linux/init.h> 10 - #include <linux/kernel.h> 11 - #include <linux/of.h> 12 - #include <asm/hardware/cache-l2x0.h> 13 - 14 - struct l2x0_aux { 15 - u32 val; 16 - u32 mask; 17 - }; 18 - 19 - static const struct l2x0_aux prima2_l2x0_aux __initconst = { 20 - .val = 2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT, 21 - .mask = 0, 22 - }; 23 - 24 - static const struct l2x0_aux marco_l2x0_aux __initconst = { 25 - .val = (2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | 26 - (1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT), 27 - .mask = L2X0_AUX_CTRL_MASK, 28 - }; 29 - 30 - static const struct of_device_id sirf_l2x0_ids[] __initconst = { 31 - { .compatible = "sirf,prima2-pl310-cache", .data = &prima2_l2x0_aux, }, 32 - { .compatible = "sirf,marco-pl310-cache", .data = &marco_l2x0_aux, }, 33 - {}, 34 - }; 35 - 36 - static int __init sirfsoc_l2x0_init(void) 37 - { 38 - struct device_node *np; 39 - const struct l2x0_aux *aux; 40 - 41 - np = of_find_matching_node(NULL, sirf_l2x0_ids); 42 - if (np) { 43 - aux = of_match_node(sirf_l2x0_ids, np)->data; 44 - return l2x0_of_init(aux->val, aux->mask); 45 - } 46 - 47 - return 0; 48 - } 49 - early_initcall(sirfsoc_l2x0_init);
-1
arch/arm/mach-prima2/pm.c
··· 71 71 case PM_SUSPEND_MEM: 72 72 sirfsoc_pre_suspend_power_off(); 73 73 74 - outer_flush_all(); 75 74 outer_disable(); 76 75 /* go zzz */ 77 76 cpu_suspend(0, sirfsoc_finish_suspend);
+1 -2
arch/arm/mach-pxa/cm-x300.c
··· 837 837 cm_x300_init_bl(); 838 838 } 839 839 840 - static void __init cm_x300_fixup(struct tag *tags, char **cmdline, 841 - struct meminfo *mi) 840 + static void __init cm_x300_fixup(struct tag *tags, char **cmdline) 842 841 { 843 842 /* Make sure that mi->bank[0].start = PHYS_ADDR */ 844 843 for (; tags->hdr.size; tags = tag_next(tags))
+4 -6
arch/arm/mach-pxa/corgi.c
··· 34 34 #include <linux/input/matrix_keypad.h> 35 35 #include <linux/gpio_keys.h> 36 36 #include <linux/module.h> 37 + #include <linux/memblock.h> 37 38 #include <video/w100fb.h> 38 39 39 40 #include <asm/setup.h> ··· 754 753 platform_add_devices(devices, ARRAY_SIZE(devices)); 755 754 } 756 755 757 - static void __init fixup_corgi(struct tag *tags, char **cmdline, 758 - struct meminfo *mi) 756 + static void __init fixup_corgi(struct tag *tags, char **cmdline) 759 757 { 760 758 sharpsl_save_param(); 761 - mi->nr_banks=1; 762 - mi->bank[0].start = 0xa0000000; 763 759 if (machine_is_corgi()) 764 - mi->bank[0].size = (32*1024*1024); 760 + memblock_add(0xa0000000, SZ_32M); 765 761 else 766 - mi->bank[0].size = (64*1024*1024); 762 + memblock_add(0xa0000000, SZ_64M); 767 763 } 768 764 769 765 #ifdef CONFIG_MACH_CORGI
+4 -5
arch/arm/mach-pxa/eseries.c
··· 21 21 #include <linux/mtd/nand.h> 22 22 #include <linux/mtd/partitions.h> 23 23 #include <linux/usb/gpio_vbus.h> 24 + #include <linux/memblock.h> 24 25 25 26 #include <video/w100fb.h> 26 27 ··· 42 41 #include "clock.h" 43 42 44 43 /* Only e800 has 128MB RAM */ 45 - void __init eseries_fixup(struct tag *tags, char **cmdline, struct meminfo *mi) 44 + void __init eseries_fixup(struct tag *tags, char **cmdline) 46 45 { 47 - mi->nr_banks=1; 48 - mi->bank[0].start = 0xa0000000; 49 46 if (machine_is_e800()) 50 - mi->bank[0].size = (128*1024*1024); 47 + memblock_add(0xa0000000, SZ_128M); 51 48 else 52 - mi->bank[0].size = (64*1024*1024); 49 + memblock_add(0xa0000000, SZ_64M); 53 50 } 54 51 55 52 struct gpio_vbus_mach_info e7xx_udc_info = {
+3 -5
arch/arm/mach-pxa/poodle.c
··· 29 29 #include <linux/spi/ads7846.h> 30 30 #include <linux/spi/pxa2xx_spi.h> 31 31 #include <linux/mtd/sharpsl.h> 32 + #include <linux/memblock.h> 32 33 33 34 #include <mach/hardware.h> 34 35 #include <asm/mach-types.h> ··· 457 456 poodle_init_spi(); 458 457 } 459 458 460 - static void __init fixup_poodle(struct tag *tags, char **cmdline, 461 - struct meminfo *mi) 459 + static void __init fixup_poodle(struct tag *tags, char **cmdline) 462 460 { 463 461 sharpsl_save_param(); 464 - mi->nr_banks=1; 465 - mi->bank[0].start = 0xa0000000; 466 - mi->bank[0].size = (32*1024*1024); 462 + memblock_add(0xa0000000, SZ_32M); 467 463 } 468 464 469 465 MACHINE_START(POODLE, "SHARP Poodle")
+3 -5
arch/arm/mach-pxa/spitz.c
··· 32 32 #include <linux/io.h> 33 33 #include <linux/module.h> 34 34 #include <linux/reboot.h> 35 + #include <linux/memblock.h> 35 36 36 37 #include <asm/setup.h> 37 38 #include <asm/mach-types.h> ··· 972 971 spitz_i2c_init(); 973 972 } 974 973 975 - static void __init spitz_fixup(struct tag *tags, char **cmdline, 976 - struct meminfo *mi) 974 + static void __init spitz_fixup(struct tag *tags, char **cmdline) 977 975 { 978 976 sharpsl_save_param(); 979 - mi->nr_banks = 1; 980 - mi->bank[0].start = 0xa0000000; 981 - mi->bank[0].size = (64*1024*1024); 977 + memblock_add(0xa0000000, SZ_64M); 982 978 } 983 979 984 980 #ifdef CONFIG_MACH_SPITZ
+3 -5
arch/arm/mach-pxa/tosa.c
··· 37 37 #include <linux/i2c/pxa-i2c.h> 38 38 #include <linux/usb/gpio_vbus.h> 39 39 #include <linux/reboot.h> 40 + #include <linux/memblock.h> 40 41 41 42 #include <asm/setup.h> 42 43 #include <asm/mach-types.h> ··· 961 960 platform_add_devices(devices, ARRAY_SIZE(devices)); 962 961 } 963 962 964 - static void __init fixup_tosa(struct tag *tags, char **cmdline, 965 - struct meminfo *mi) 963 + static void __init fixup_tosa(struct tag *tags, char **cmdline) 966 964 { 967 965 sharpsl_save_param(); 968 - mi->nr_banks=1; 969 - mi->bank[0].start = 0xa0000000; 970 - mi->bank[0].size = (64*1024*1024); 966 + memblock_add(0xa0000000, SZ_64M); 971 967 } 972 968 973 969 MACHINE_START(TOSA, "SHARP Tosa")
+4 -7
arch/arm/mach-realview/core.c
··· 31 31 #include <linux/amba/mmci.h> 32 32 #include <linux/gfp.h> 33 33 #include <linux/mtd/physmap.h> 34 + #include <linux/memblock.h> 34 35 35 36 #include <mach/hardware.h> 36 37 #include <asm/irq.h> ··· 386 385 /* 387 386 * Setup the memory banks. 388 387 */ 389 - void realview_fixup(struct tag *tags, char **from, struct meminfo *meminfo) 388 + void realview_fixup(struct tag *tags, char **from) 390 389 { 391 390 /* 392 391 * Most RealView platforms have 512MB contiguous RAM at 0x70000000. 393 392 * Half of this is mirrored at 0. 394 393 */ 395 394 #ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET 396 - meminfo->bank[0].start = 0x70000000; 397 - meminfo->bank[0].size = SZ_512M; 398 - meminfo->nr_banks = 1; 395 + memblock_add(0x70000000, SZ_512M); 399 396 #else 400 - meminfo->bank[0].start = 0; 401 - meminfo->bank[0].size = SZ_256M; 402 - meminfo->nr_banks = 1; 397 + memblock_add(0, SZ_256M); 403 398 #endif 404 399 }
+1 -2
arch/arm/mach-realview/core.h
··· 52 52 extern int realview_eth_register(const char *name, struct resource *res); 53 53 extern int realview_usb_register(struct resource *res); 54 54 extern void realview_init_early(void); 55 - extern void realview_fixup(struct tag *tags, char **from, 56 - struct meminfo *meminfo); 55 + extern void realview_fixup(struct tag *tags, char **from); 57 56 58 57 extern struct smp_operations realview_smp_ops; 59 58 extern void realview_cpu_die(unsigned int cpu);
+7 -2
arch/arm/mach-realview/realview_eb.c
··· 442 442 realview_eb11mp_fixup(); 443 443 444 444 #ifdef CONFIG_CACHE_L2X0 445 - /* 1MB (128KB/way), 8-way associativity, evmon/parity/share enabled 446 - * Bits: .... ...0 0111 1001 0000 .... .... .... */ 445 + /* 446 + * The PL220 needs to be manually configured as the hardware 447 + * doesn't report the correct sizes. 448 + * 1MB (128KB/way), 8-way associativity, event monitor and 449 + * parity enabled, ignore share bit, no force write allocate 450 + * Bits: .... ...0 0111 1001 0000 .... .... .... 451 + */ 447 452 l2x0_init(__io_address(REALVIEW_EB11MP_L220_BASE), 0x00790000, 0xfe000fff); 448 453 #endif 449 454 platform_device_register(&pmu_device);
+10 -6
arch/arm/mach-realview/realview_pb1176.c
··· 32 32 #include <linux/irqchip/arm-gic.h> 33 33 #include <linux/platform_data/clk-realview.h> 34 34 #include <linux/reboot.h> 35 + #include <linux/memblock.h> 35 36 36 37 #include <mach/hardware.h> 37 38 #include <asm/irq.h> ··· 340 339 dsb(); 341 340 } 342 341 343 - static void realview_pb1176_fixup(struct tag *tags, char **from, 344 - struct meminfo *meminfo) 342 + static void realview_pb1176_fixup(struct tag *tags, char **from) 345 343 { 346 344 /* 347 345 * RealView PB1176 only has 128MB of RAM mapped at 0. 348 346 */ 349 - meminfo->bank[0].start = 0; 350 - meminfo->bank[0].size = SZ_128M; 351 - meminfo->nr_banks = 1; 347 + memblock_add(0, SZ_128M); 352 348 } 353 349 354 350 static void __init realview_pb1176_init(void) ··· 353 355 int i; 354 356 355 357 #ifdef CONFIG_CACHE_L2X0 356 - /* 128Kb (16Kb/way) 8-way associativity. evmon/parity/share enabled. */ 358 + /* 359 + * The PL220 needs to be manually configured as the hardware 360 + * doesn't report the correct sizes. 361 + * 128kB (16kB/way), 8-way associativity, event monitor and 362 + * parity enabled, ignore share bit, no force write allocate 363 + * Bits: .... ...0 0111 0011 0000 .... .... .... 364 + */ 357 365 l2x0_init(__io_address(REALVIEW_PB1176_L220_BASE), 0x00730000, 0xfe000fff); 358 366 #endif 359 367
+7 -2
arch/arm/mach-realview/realview_pb11mp.c
··· 337 337 int i; 338 338 339 339 #ifdef CONFIG_CACHE_L2X0 340 - /* 1MB (128KB/way), 8-way associativity, evmon/parity/share enabled 341 - * Bits: .... ...0 0111 1001 0000 .... .... .... */ 340 + /* 341 + * The PL220 needs to be manually configured as the hardware 342 + * doesn't report the correct sizes. 343 + * 1MB (128KB/way), 8-way associativity, event monitor and 344 + * parity enabled, ignore share bit, no force write allocate 345 + * Bits: .... ...0 0111 1001 0000 .... .... .... 346 + */ 342 347 l2x0_init(__io_address(REALVIEW_TC11MP_L220_BASE), 0x00790000, 0xfe000fff); 343 348 #endif 344 349
+9 -12
arch/arm/mach-realview/realview_pbx.c
··· 29 29 #include <linux/irqchip/arm-gic.h> 30 30 #include <linux/platform_data/clk-realview.h> 31 31 #include <linux/reboot.h> 32 + #include <linux/memblock.h> 32 33 33 34 #include <asm/irq.h> 34 35 #include <asm/mach-types.h> ··· 326 325 realview_pbx_twd_init(); 327 326 } 328 327 329 - static void realview_pbx_fixup(struct tag *tags, char **from, 330 - struct meminfo *meminfo) 328 + static void realview_pbx_fixup(struct tag *tags, char **from) 331 329 { 332 330 #ifdef CONFIG_SPARSEMEM 333 331 /* 334 332 * Memory configuration with SPARSEMEM enabled on RealView PBX (see 335 333 * asm/mach/memory.h for more information). 336 334 */ 337 - meminfo->bank[0].start = 0; 338 - meminfo->bank[0].size = SZ_256M; 339 - meminfo->bank[1].start = 0x20000000; 340 - meminfo->bank[1].size = SZ_512M; 341 - meminfo->bank[2].start = 0x80000000; 342 - meminfo->bank[2].size = SZ_256M; 343 - meminfo->nr_banks = 3; 335 + 336 + memblock_add(0, SZ_256M); 337 + memblock_add(0x20000000, SZ_512M); 338 + memblock_add(0x80000000, SZ_256M); 344 339 #else 345 - realview_fixup(tags, from, meminfo); 340 + realview_fixup(tags, from); 346 341 #endif 347 342 } 348 343 ··· 367 370 __io_address(REALVIEW_PBX_TILE_L220_BASE); 368 371 369 372 /* set RAM latencies to 1 cycle for eASIC */ 370 - writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); 371 - writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL); 373 + writel(0, l2x0_base + L310_TAG_LATENCY_CTRL); 374 + writel(0, l2x0_base + L310_DATA_LATENCY_CTRL); 372 375 373 376 /* 16KB way size, 8-way associativity, parity disabled 374 377 * Bits: .. 0 0 0 0 1 00 1 0 1 001 0 000 0 .... .... .... */
+2 -7
arch/arm/mach-rockchip/rockchip.c
··· 24 24 #include <asm/hardware/cache-l2x0.h> 25 25 #include "core.h" 26 26 27 - static void __init rockchip_dt_init(void) 28 - { 29 - l2x0_of_init(0, ~0UL); 30 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 31 - } 32 - 33 27 static const char * const rockchip_board_dt_compat[] = { 34 28 "rockchip,rk2928", 35 29 "rockchip,rk3066a", ··· 33 39 }; 34 40 35 41 DT_MACHINE_START(ROCKCHIP_DT, "Rockchip Cortex-A9 (Device Tree)") 36 - .init_machine = rockchip_dt_init, 42 + .l2c_aux_val = 0, 43 + .l2c_aux_mask = ~0, 37 44 .dt_compat = rockchip_board_dt_compat, 38 45 MACHINE_END
+3 -5
arch/arm/mach-s3c24xx/mach-smdk2413.c
··· 22 22 #include <linux/serial_s3c.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/io.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/mach/arch.h> 27 28 #include <asm/mach/map.h> ··· 94 93 &s3c2412_device_dma, 95 94 }; 96 95 97 - static void __init smdk2413_fixup(struct tag *tags, char **cmdline, 98 - struct meminfo *mi) 96 + static void __init smdk2413_fixup(struct tag *tags, char **cmdline) 99 97 { 100 98 if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { 101 - mi->nr_banks=1; 102 - mi->bank[0].start = 0x30000000; 103 - mi->bank[0].size = SZ_64M; 99 + memblock_add(0x30000000, SZ_64M); 104 100 } 105 101 } 106 102
+3 -5
arch/arm/mach-s3c24xx/mach-vstms.c
··· 23 23 #include <linux/mtd/nand.h> 24 24 #include <linux/mtd/nand_ecc.h> 25 25 #include <linux/mtd/partitions.h> 26 + #include <linux/memblock.h> 26 27 27 28 #include <asm/mach/arch.h> 28 29 #include <asm/mach/map.h> ··· 130 129 &s3c2412_device_dma, 131 130 }; 132 131 133 - static void __init vstms_fixup(struct tag *tags, char **cmdline, 134 - struct meminfo *mi) 132 + static void __init vstms_fixup(struct tag *tags, char **cmdline) 135 133 { 136 134 if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { 137 - mi->nr_banks=1; 138 - mi->bank[0].start = 0x30000000; 139 - mi->bank[0].size = SZ_64M; 135 + memblock_add(0x30000000, SZ_64M); 140 136 } 141 137 } 142 138
+1 -1
arch/arm/mach-sa1100/assabet.c
··· 531 531 } 532 532 533 533 static void __init 534 - fixup_assabet(struct tag *tags, char **cmdline, struct meminfo *mi) 534 + fixup_assabet(struct tag *tags, char **cmdline) 535 535 { 536 536 /* This must be done before any call to machine_has_neponset() */ 537 537 map_sa1100_gpio_regs();
+2 -2
arch/arm/mach-shmobile/board-armadillo800eva-reference.c
··· 164 164 r8a7740_meram_workaround(); 165 165 166 166 #ifdef CONFIG_CACHE_L2X0 167 - /* Early BRESP enable, Shared attribute override enable, 32K*8way */ 168 - l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff); 167 + /* Shared attribute override enable, 32K*8way */ 168 + l2x0_init(IOMEM(0xf0002000), 0x00400000, 0xc20f0fff); 169 169 #endif 170 170 171 171 r8a7740_add_standard_devices_dt();
+2 -2
arch/arm/mach-shmobile/board-armadillo800eva.c
··· 1271 1271 1272 1272 1273 1273 #ifdef CONFIG_CACHE_L2X0 1274 - /* Early BRESP enable, Shared attribute override enable, 32K*8way */ 1275 - l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff); 1274 + /* Shared attribute override enable, 32K*8way */ 1275 + l2x0_init(IOMEM(0xf0002000), 0x00400000, 0xc20f0fff); 1276 1276 #endif 1277 1277 1278 1278 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
+2 -2
arch/arm/mach-shmobile/board-kzm9g-reference.c
··· 36 36 sh73a0_add_standard_devices_dt(); 37 37 38 38 #ifdef CONFIG_CACHE_L2X0 39 - /* Early BRESP enable, Shared attribute override enable, 64K*8way */ 40 - l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); 39 + /* Shared attribute override enable, 64K*8way */ 40 + l2x0_init(IOMEM(0xf0100000), 0x00400000, 0xc20f0fff); 41 41 #endif 42 42 } 43 43
+2 -2
arch/arm/mach-shmobile/board-kzm9g.c
··· 876 876 gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */ 877 877 878 878 #ifdef CONFIG_CACHE_L2X0 879 - /* Early BRESP enable, Shared attribute override enable, 64K*8way */ 880 - l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); 879 + /* Shared attribute override enable, 64K*8way */ 880 + l2x0_init(IOMEM(0xf0100000), 0x00400000, 0xc20f0fff); 881 881 #endif 882 882 883 883 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
+2 -2
arch/arm/mach-shmobile/setup-r8a7778.c
··· 285 285 void __iomem *base = ioremap_nocache(0xf0100000, 0x1000); 286 286 if (base) { 287 287 /* 288 - * Early BRESP enable, Shared attribute override enable, 64K*16way 288 + * Shared attribute override enable, 64K*16way 289 289 * don't call iounmap(base) 290 290 */ 291 - l2x0_init(base, 0x40470000, 0x82000fff); 291 + l2x0_init(base, 0x00400000, 0xc20f0fff); 292 292 } 293 293 #endif 294 294
+2 -2
arch/arm/mach-shmobile/setup-r8a7779.c
··· 660 660 void __init r8a7779_add_standard_devices(void) 661 661 { 662 662 #ifdef CONFIG_CACHE_L2X0 663 - /* Early BRESP enable, Shared attribute override enable, 64K*16way */ 664 - l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff); 663 + /* Shared attribute override enable, 64K*16way */ 664 + l2x0_init(IOMEM(0xf0100000), 0x00400000, 0xc20f0fff); 665 665 #endif 666 666 r8a7779_pm_init(); 667 667
+2 -7
arch/arm/mach-socfpga/socfpga.c
··· 98 98 writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL); 99 99 } 100 100 101 - static void __init socfpga_cyclone5_init(void) 102 - { 103 - l2x0_of_init(0, ~0UL); 104 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 105 - } 106 - 107 101 static const char *altera_dt_match[] = { 108 102 "altr,socfpga", 109 103 NULL 110 104 }; 111 105 112 106 DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA") 107 + .l2c_aux_val = 0, 108 + .l2c_aux_mask = ~0, 113 109 .smp = smp_ops(socfpga_smp_ops), 114 110 .map_io = socfpga_map_io, 115 111 .init_irq = socfpga_init_irq, 116 - .init_machine = socfpga_cyclone5_init, 117 112 .restart = socfpga_cyclone5_restart, 118 113 .dt_compat = altera_dt_match, 119 114 MACHINE_END
+14 -5
arch/arm/mach-spear/platsmp.c
··· 20 20 #include <mach/spear.h> 21 21 #include "generic.h" 22 22 23 + /* 24 + * Write pen_release in a way that is guaranteed to be visible to all 25 + * observers, irrespective of whether they're taking part in coherency 26 + * or not. This is necessary for the hotplug code to work reliably. 27 + */ 28 + static void write_pen_release(int val) 29 + { 30 + pen_release = val; 31 + smp_wmb(); 32 + sync_cache_w(&pen_release); 33 + } 34 + 23 35 static DEFINE_SPINLOCK(boot_lock); 24 36 25 37 static void __iomem *scu_base = IOMEM(VA_SCU_BASE); ··· 42 30 * let the primary processor know we're out of the 43 31 * pen, then head off into the C entry point 44 32 */ 45 - pen_release = -1; 46 - smp_wmb(); 33 + write_pen_release(-1); 47 34 48 35 /* 49 36 * Synchronise with the boot thread. ··· 69 58 * Note that "pen_release" is the hardware CPU ID, whereas 70 59 * "cpu" is Linux's internal ID. 71 60 */ 72 - pen_release = cpu; 73 - flush_cache_all(); 74 - outer_flush_all(); 61 + write_pen_release(cpu); 75 62 76 63 timeout = jiffies + (1 * HZ); 77 64 while (time_before(jiffies, timeout)) {
+4 -4
arch/arm/mach-spear/spear13xx.c
··· 38 38 if (!IS_ENABLED(CONFIG_CACHE_L2X0)) 39 39 return; 40 40 41 - writel_relaxed(0x06, VA_L2CC_BASE + L2X0_PREFETCH_CTRL); 41 + writel_relaxed(0x06, VA_L2CC_BASE + L310_PREFETCH_CTRL); 42 42 43 43 /* 44 44 * Program following latencies in order to make 45 45 * SPEAr1340 work at 600 MHz 46 46 */ 47 - writel_relaxed(0x221, VA_L2CC_BASE + L2X0_TAG_LATENCY_CTRL); 48 - writel_relaxed(0x441, VA_L2CC_BASE + L2X0_DATA_LATENCY_CTRL); 49 - l2x0_init(VA_L2CC_BASE, 0x70A60001, 0xfe00ffff); 47 + writel_relaxed(0x221, VA_L2CC_BASE + L310_TAG_LATENCY_CTRL); 48 + writel_relaxed(0x441, VA_L2CC_BASE + L310_DATA_LATENCY_CTRL); 49 + l2x0_init(VA_L2CC_BASE, 0x30a00001, 0xfe0fffff); 50 50 } 51 51 52 52 /*
+6 -21
arch/arm/mach-sti/board-dt.c
··· 14 14 15 15 #include "smp.h" 16 16 17 - void __init stih41x_l2x0_init(void) 18 - { 19 - u32 way_size = 0x4; 20 - u32 aux_ctrl; 21 - /* may be this can be encoded in macros like BIT*() */ 22 - aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | 23 - (0x1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) | 24 - (0x1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | 25 - (way_size << L2X0_AUX_CTRL_WAY_SIZE_SHIFT); 26 - 27 - l2x0_of_init(aux_ctrl, L2X0_AUX_CTRL_MASK); 28 - } 29 - 30 - static void __init stih41x_machine_init(void) 31 - { 32 - stih41x_l2x0_init(); 33 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 34 - } 35 - 36 17 static const char *stih41x_dt_match[] __initdata = { 37 18 "st,stih415", 38 19 "st,stih416", ··· 22 41 }; 23 42 24 43 DT_MACHINE_START(STM, "STiH415/416 SoC with Flattened Device Tree") 25 - .init_machine = stih41x_machine_init, 26 - .smp = smp_ops(sti_smp_ops), 27 44 .dt_compat = stih41x_dt_match, 45 + .l2c_aux_val = L2C_AUX_CTRL_SHARED_OVERRIDE | 46 + L310_AUX_CTRL_DATA_PREFETCH | 47 + L310_AUX_CTRL_INSTR_PREFETCH | 48 + L2C_AUX_CTRL_WAY_SIZE(4), 49 + .l2c_aux_mask = 0xc0000fff, 50 + .smp = smp_ops(sti_smp_ops), 28 51 MACHINE_END
-2
arch/arm/mach-tegra/pm.h
··· 35 35 void tegra30_lp1_iram_hook(void); 36 36 void tegra30_sleep_core_init(void); 37 37 38 - extern unsigned long l2x0_saved_regs_addr; 39 - 40 38 void tegra_clear_cpu_in_lp2(void); 41 39 bool tegra_set_cpu_in_lp2(void); 42 40
+3 -8
arch/arm/mach-tegra/reset-handler.S
··· 19 19 20 20 #include <asm/cache.h> 21 21 #include <asm/asm-offsets.h> 22 - #include <asm/hardware/cache-l2x0.h> 23 22 24 23 #include "flowctrl.h" 25 24 #include "fuse.h" ··· 77 78 str r1, [r0] 78 79 #endif 79 80 81 + #ifdef CONFIG_CACHE_L2X0 80 82 /* L2 cache resume & re-enable */ 81 - l2_cache_resume r0, r1, r2, l2x0_saved_regs_addr 83 + bl l2c310_early_resume 84 + #endif 82 85 end_ca9_scu_l2_resume: 83 86 mov32 r9, 0xc0f 84 87 cmp r8, r9 ··· 88 87 89 88 b cpu_resume 90 89 ENDPROC(tegra_resume) 91 - #endif 92 - 93 - #ifdef CONFIG_CACHE_L2X0 94 - .globl l2x0_saved_regs_addr 95 - l2x0_saved_regs_addr: 96 - .long 0 97 90 #endif 98 91 99 92 .align L1_CACHE_SHIFT
-31
arch/arm/mach-tegra/sleep.h
··· 120 120 mov \tmp1, \tmp1, lsr #8 121 121 .endm 122 122 123 - /* Macro to resume & re-enable L2 cache */ 124 - #ifndef L2X0_CTRL_EN 125 - #define L2X0_CTRL_EN 1 126 - #endif 127 - 128 - #ifdef CONFIG_CACHE_L2X0 129 - .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs 130 - W(adr) \tmp1, \phys_l2x0_saved_regs 131 - ldr \tmp1, [\tmp1] 132 - ldr \tmp2, [\tmp1, #L2X0_R_PHY_BASE] 133 - ldr \tmp3, [\tmp2, #L2X0_CTRL] 134 - tst \tmp3, #L2X0_CTRL_EN 135 - bne exit_l2_resume 136 - ldr \tmp3, [\tmp1, #L2X0_R_TAG_LATENCY] 137 - str \tmp3, [\tmp2, #L2X0_TAG_LATENCY_CTRL] 138 - ldr \tmp3, [\tmp1, #L2X0_R_DATA_LATENCY] 139 - str \tmp3, [\tmp2, #L2X0_DATA_LATENCY_CTRL] 140 - ldr \tmp3, [\tmp1, #L2X0_R_PREFETCH_CTRL] 141 - str \tmp3, [\tmp2, #L2X0_PREFETCH_CTRL] 142 - ldr \tmp3, [\tmp1, #L2X0_R_PWR_CTRL] 143 - str \tmp3, [\tmp2, #L2X0_POWER_CTRL] 144 - ldr \tmp3, [\tmp1, #L2X0_R_AUX_CTRL] 145 - str \tmp3, [\tmp2, #L2X0_AUX_CTRL] 146 - mov \tmp3, #L2X0_CTRL_EN 147 - str \tmp3, [\tmp2, #L2X0_CTRL] 148 - exit_l2_resume: 149 - .endm 150 - #else /* CONFIG_CACHE_L2X0 */ 151 - .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs 152 - .endm 153 - #endif /* CONFIG_CACHE_L2X0 */ 154 123 #else 155 124 void tegra_pen_lock(void); 156 125 void tegra_pen_unlock(void);
+3 -29
arch/arm/mach-tegra/tegra.c
··· 70 70 0, 71 71 }; 72 72 73 - static void __init tegra_init_cache(void) 74 - { 75 - #ifdef CONFIG_CACHE_L2X0 76 - static const struct of_device_id pl310_ids[] __initconst = { 77 - { .compatible = "arm,pl310-cache", }, 78 - {} 79 - }; 80 - 81 - struct device_node *np; 82 - int ret; 83 - void __iomem *p = IO_ADDRESS(TEGRA_ARM_PERIF_BASE) + 0x3000; 84 - u32 aux_ctrl, cache_type; 85 - 86 - np = of_find_matching_node(NULL, pl310_ids); 87 - if (!np) 88 - return; 89 - 90 - cache_type = readl(p + L2X0_CACHE_TYPE); 91 - aux_ctrl = (cache_type & 0x700) << (17-8); 92 - aux_ctrl |= 0x7C400001; 93 - 94 - ret = l2x0_of_init(aux_ctrl, 0x8200c3fe); 95 - if (!ret) 96 - l2x0_saved_regs_addr = virt_to_phys(&l2x0_saved_regs); 97 - #endif 98 - } 99 - 100 73 static void __init tegra_init_early(void) 101 74 { 102 75 of_register_trusted_foundations(); 103 76 tegra_apb_io_init(); 104 77 tegra_init_fuse(); 105 78 tegra_cpu_reset_handler_init(); 106 - tegra_init_cache(); 107 79 tegra_powergate_init(); 108 80 tegra_hotplug_init(); 109 81 } ··· 163 191 }; 164 192 165 193 DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") 166 - .map_io = tegra_map_common_io, 194 + .l2c_aux_val = 0x3c400001, 195 + .l2c_aux_mask = 0xc20fc3fe, 167 196 .smp = smp_ops(tegra_smp_ops), 197 + .map_io = tegra_map_common_io, 168 198 .init_early = tegra_init_early, 169 199 .init_irq = tegra_dt_init_irq, 170 200 .init_machine = tegra_dt_init,
+11 -21
arch/arm/mach-ux500/cache-l2x0.c
··· 35 35 return 0; 36 36 } 37 37 38 + static void ux500_l2c310_write_sec(unsigned long val, unsigned reg) 39 + { 40 + /* 41 + * We can't write to secure registers as we are in non-secure 42 + * mode, until we have some SMI service available. 43 + */ 44 + } 45 + 38 46 static int __init ux500_l2x0_init(void) 39 47 { 40 - u32 aux_val = 0x3e000000; 41 - 42 48 if (cpu_is_u8500_family() || cpu_is_ux540_family()) 43 49 l2x0_base = __io_address(U8500_L2CC_BASE); 44 50 else ··· 54 48 /* Unlock before init */ 55 49 ux500_l2x0_unlock(); 56 50 57 - /* DBx540's L2 has 128KB way size */ 58 - if (cpu_is_ux540_family()) 59 - /* 128KB way size */ 60 - aux_val |= (0x4 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT); 61 - else 62 - /* 64KB way size */ 63 - aux_val |= (0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT); 51 + outer_cache.write_sec = ux500_l2c310_write_sec; 64 52 65 - /* 64KB way size, 8 way associativity, force WA */ 66 53 if (of_have_populated_dt()) 67 - l2x0_of_init(aux_val, 0xc0000fff); 54 + l2x0_of_init(0, ~0); 68 55 else 69 - l2x0_init(l2x0_base, aux_val, 0xc0000fff); 70 - 71 - /* 72 - * We can't disable l2 as we are in non secure mode, currently 73 - * this seems be called only during kexec path. So let's 74 - * override outer.disable with nasty assignment until we have 75 - * some SMI service available. 76 - */ 77 - outer_cache.disable = NULL; 78 - outer_cache.set_debug = NULL; 56 + l2x0_init(l2x0_base, 0, ~0); 79 57 80 58 return 0; 81 59 }
+18 -10
arch/arm/mach-vexpress/ct-ca9x4.c
··· 45 45 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc)); 46 46 } 47 47 48 + static void __init ca9x4_l2_init(void) 49 + { 50 + #ifdef CONFIG_CACHE_L2X0 51 + void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K); 52 + 53 + if (l2x0_base) { 54 + /* set RAM latencies to 1 cycle for this core tile. */ 55 + writel(0, l2x0_base + L310_TAG_LATENCY_CTRL); 56 + writel(0, l2x0_base + L310_DATA_LATENCY_CTRL); 57 + 58 + l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff); 59 + } else { 60 + pr_err("L2C: unable to map L2 cache controller\n"); 61 + } 62 + #endif 63 + } 64 + 48 65 #ifdef CONFIG_HAVE_ARM_TWD 49 66 static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER); 50 67 ··· 80 63 gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K), 81 64 ioremap(A9_MPCORE_GIC_CPU, SZ_256)); 82 65 ca9x4_twd_init(); 66 + ca9x4_l2_init(); 83 67 } 84 68 85 69 static int ct_ca9x4_clcd_setup(struct clcd_fb *fb) ··· 163 145 static void __init ct_ca9x4_init(void) 164 146 { 165 147 int i; 166 - 167 - #ifdef CONFIG_CACHE_L2X0 168 - void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K); 169 - 170 - /* set RAM latencies to 1 cycle for this core tile. */ 171 - writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); 172 - writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL); 173 - 174 - l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff); 175 - #endif 176 148 177 149 for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++) 178 150 amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
+2 -2
arch/arm/mach-vexpress/tc2_pm.c
··· 209 209 #define POLL_MSEC 10 210 210 #define TIMEOUT_MSEC 1000 211 211 212 - static int tc2_pm_power_down_finish(unsigned int cpu, unsigned int cluster) 212 + static int tc2_pm_wait_for_powerdown(unsigned int cpu, unsigned int cluster) 213 213 { 214 214 unsigned tries; 215 215 ··· 290 290 static const struct mcpm_platform_ops tc2_pm_power_ops = { 291 291 .power_up = tc2_pm_power_up, 292 292 .power_down = tc2_pm_power_down, 293 - .power_down_finish = tc2_pm_power_down_finish, 293 + .wait_for_powerdown = tc2_pm_wait_for_powerdown, 294 294 .suspend = tc2_pm_suspend, 295 295 .powered_up = tc2_pm_powered_up, 296 296 };
+2 -1
arch/arm/mach-vexpress/v2m.c
··· 372 372 373 373 static void __init v2m_dt_init(void) 374 374 { 375 - l2x0_of_init(0x00400000, 0xfe0fffff); 376 375 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 377 376 } 378 377 ··· 382 383 383 384 DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express") 384 385 .dt_compat = v2m_dt_match, 386 + .l2c_aux_val = 0x00400000, 387 + .l2c_aux_mask = 0xfe0fffff, 385 388 .smp = smp_ops(vexpress_smp_dt_ops), 386 389 .smp_init = smp_init_ops(vexpress_smp_init_ops), 387 390 .init_machine = v2m_dt_init,
+3 -5
arch/arm/mach-zynq/common.c
··· 109 109 struct soc_device *soc_dev; 110 110 struct device *parent = NULL; 111 111 112 - /* 113 - * 64KB way size, 8-way associativity, parity disabled 114 - */ 115 - l2x0_of_init(0x02060000, 0xF0F0FFFF); 116 - 117 112 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); 118 113 if (!soc_dev_attr) 119 114 goto out; ··· 197 202 }; 198 203 199 204 DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform") 205 + /* 64KB way size, 8-way associativity, parity disabled */ 206 + .l2c_aux_val = 0x02000000, 207 + .l2c_aux_mask = 0xf0ffffff, 200 208 .smp = smp_ops(zynq_smp_ops), 201 209 .map_io = zynq_map_io, 202 210 .init_irq = zynq_irq_init,
+51
arch/arm/mm/Kconfig
··· 897 897 This option enables optimisations for the PL310 cache 898 898 controller. 899 899 900 + config PL310_ERRATA_588369 901 + bool "PL310 errata: Clean & Invalidate maintenance operations do not invalidate clean lines" 902 + depends on CACHE_L2X0 903 + help 904 + The PL310 L2 cache controller implements three types of Clean & 905 + Invalidate maintenance operations: by Physical Address 906 + (offset 0x7F0), by Index/Way (0x7F8) and by Way (0x7FC). 907 + They are architecturally defined to behave as the execution of a 908 + clean operation followed immediately by an invalidate operation, 909 + both performing to the same memory location. This functionality 910 + is not correctly implemented in PL310 as clean lines are not 911 + invalidated as a result of these operations. 912 + 913 + config PL310_ERRATA_727915 914 + bool "PL310 errata: Background Clean & Invalidate by Way operation can cause data corruption" 915 + depends on CACHE_L2X0 916 + help 917 + PL310 implements the Clean & Invalidate by Way L2 cache maintenance 918 + operation (offset 0x7FC). This operation runs in background so that 919 + PL310 can handle normal accesses while it is in progress. Under very 920 + rare circumstances, due to this erratum, write data can be lost when 921 + PL310 treats a cacheable write transaction during a Clean & 922 + Invalidate by Way operation. 923 + 924 + config PL310_ERRATA_753970 925 + bool "PL310 errata: cache sync operation may be faulty" 926 + depends on CACHE_PL310 927 + help 928 + This option enables the workaround for the 753970 PL310 (r3p0) erratum. 929 + 930 + Under some condition the effect of cache sync operation on 931 + the store buffer still remains when the operation completes. 932 + This means that the store buffer is always asked to drain and 933 + this prevents it from merging any further writes. The workaround 934 + is to replace the normal offset of cache sync operation (0x730) 935 + by another offset targeting an unmapped PL310 register 0x740. 936 + This has the same effect as the cache sync operation: store buffer 937 + drain and waiting for all buffers empty. 938 + 939 + config PL310_ERRATA_769419 940 + bool "PL310 errata: no automatic Store Buffer drain" 941 + depends on CACHE_L2X0 942 + help 943 + On revisions of the PL310 prior to r3p2, the Store Buffer does 944 + not automatically drain. This can cause normal, non-cacheable 945 + writes to be retained when the memory system is idle, leading 946 + to suboptimal I/O performance for drivers using coherent DMA. 947 + This option adds a write barrier to the cpu_idle loop so that, 948 + on systems with an outer cache, the store buffer is drained 949 + explicitly. 950 + 900 951 config CACHE_TAUROS2 901 952 bool "Enable the Tauros2 L2 cache controller" 902 953 depends on (ARCH_DOVE || ARCH_MMP || CPU_PJ4)
+2 -1
arch/arm/mm/Makefile
··· 95 95 AFLAGS_proc-v6.o :=-Wa,-march=armv6 96 96 AFLAGS_proc-v7.o :=-Wa,-march=armv7-a 97 97 98 + obj-$(CONFIG_OUTER_CACHE) += l2c-common.o 98 99 obj-$(CONFIG_CACHE_FEROCEON_L2) += cache-feroceon-l2.o 99 - obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o 100 + obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o l2c-l2x0-resume.o 100 101 obj-$(CONFIG_CACHE_XSC3L2) += cache-xsc3l2.o 101 102 obj-$(CONFIG_CACHE_TAUROS2) += cache-tauros2.o
+13 -6
arch/arm/mm/alignment.c
··· 28 28 #include <asm/opcodes.h> 29 29 30 30 #include "fault.h" 31 + #include "mm.h" 31 32 32 33 /* 33 34 * 32-bit misaligned trap handler (c) 1998 San Mehat (CCC) -July 1998 ··· 82 81 static unsigned long ai_dword; 83 82 static unsigned long ai_multi; 84 83 static int ai_usermode; 84 + static unsigned long cr_no_alignment; 85 85 86 86 core_param(alignment, ai_usermode, int, 0600); 87 87 ··· 93 91 /* Return true if and only if the ARMv6 unaligned access model is in use. */ 94 92 static bool cpu_is_v6_unaligned(void) 95 93 { 96 - return cpu_architecture() >= CPU_ARCH_ARMv6 && (cr_alignment & CR_U); 94 + return cpu_architecture() >= CPU_ARCH_ARMv6 && get_cr() & CR_U; 97 95 } 98 96 99 97 static int safe_usermode(int new_usermode, bool warn) ··· 951 949 return 0; 952 950 } 953 951 952 + static int __init noalign_setup(char *__unused) 953 + { 954 + set_cr(__clear_cr(CR_A)); 955 + return 1; 956 + } 957 + __setup("noalign", noalign_setup); 958 + 954 959 /* 955 960 * This needs to be done after sysctl_init, otherwise sys/ will be 956 961 * overwritten. Actually, this shouldn't be in sys/ at all since ··· 975 966 return -ENOMEM; 976 967 #endif 977 968 978 - #ifdef CONFIG_CPU_CP15 979 969 if (cpu_is_v6_unaligned()) { 980 - cr_alignment &= ~CR_A; 981 - cr_no_alignment &= ~CR_A; 982 - set_cr(cr_alignment); 970 + set_cr(__clear_cr(CR_A)); 983 971 ai_usermode = safe_usermode(ai_usermode, false); 984 972 } 985 - #endif 973 + 974 + cr_no_alignment = get_cr() & ~CR_A; 986 975 987 976 hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN, 988 977 "alignment exception");
-1
arch/arm/mm/cache-feroceon-l2.c
··· 350 350 outer_cache.inv_range = feroceon_l2_inv_range; 351 351 outer_cache.clean_range = feroceon_l2_clean_range; 352 352 outer_cache.flush_range = feroceon_l2_flush_range; 353 - outer_cache.inv_all = l2_inv_all; 354 353 355 354 enable_l2(); 356 355
+1076 -572
arch/arm/mm/cache-l2x0.c
··· 16 16 * along with this program; if not, write to the Free Software 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 + #include <linux/cpu.h> 19 20 #include <linux/err.h> 20 21 #include <linux/init.h> 22 + #include <linux/smp.h> 21 23 #include <linux/spinlock.h> 22 24 #include <linux/io.h> 23 25 #include <linux/of.h> 24 26 #include <linux/of_address.h> 25 27 26 28 #include <asm/cacheflush.h> 29 + #include <asm/cp15.h> 30 + #include <asm/cputype.h> 27 31 #include <asm/hardware/cache-l2x0.h> 28 32 #include "cache-tauros3.h" 29 33 #include "cache-aurora-l2.h" 34 + 35 + struct l2c_init_data { 36 + const char *type; 37 + unsigned way_size_0; 38 + unsigned num_lock; 39 + void (*of_parse)(const struct device_node *, u32 *, u32 *); 40 + void (*enable)(void __iomem *, u32, unsigned); 41 + void (*fixup)(void __iomem *, u32, struct outer_cache_fns *); 42 + void (*save)(void __iomem *); 43 + struct outer_cache_fns outer_cache; 44 + }; 30 45 31 46 #define CACHE_LINE_SIZE 32 32 47 ··· 51 36 static u32 l2x0_size; 52 37 static unsigned long sync_reg_offset = L2X0_CACHE_SYNC; 53 38 54 - /* Aurora don't have the cache ID register available, so we have to 55 - * pass it though the device tree */ 56 - static u32 cache_id_part_number_from_dt; 57 - 58 39 struct l2x0_regs l2x0_saved_regs; 59 40 60 - struct l2x0_of_data { 61 - void (*setup)(const struct device_node *, u32 *, u32 *); 62 - void (*save)(void); 63 - struct outer_cache_fns outer_cache; 64 - }; 65 - 66 - static bool of_init = false; 67 - 68 - static inline void cache_wait_way(void __iomem *reg, unsigned long mask) 41 + /* 42 + * Common code for all cache controllers. 43 + */ 44 + static inline void l2c_wait_mask(void __iomem *reg, unsigned long mask) 69 45 { 70 46 /* wait for cache operation by line or way to complete */ 71 47 while (readl_relaxed(reg) & mask) 72 48 cpu_relax(); 49 + } 50 + 51 + /* 52 + * By default, we write directly to secure registers. Platforms must 53 + * override this if they are running non-secure. 54 + */ 55 + static void l2c_write_sec(unsigned long val, void __iomem *base, unsigned reg) 56 + { 57 + if (val == readl_relaxed(base + reg)) 58 + return; 59 + if (outer_cache.write_sec) 60 + outer_cache.write_sec(val, reg); 61 + else 62 + writel_relaxed(val, base + reg); 63 + } 64 + 65 + /* 66 + * This should only be called when we have a requirement that the 67 + * register be written due to a work-around, as platforms running 68 + * in non-secure mode may not be able to access this register. 69 + */ 70 + static inline void l2c_set_debug(void __iomem *base, unsigned long val) 71 + { 72 + l2c_write_sec(val, base, L2X0_DEBUG_CTRL); 73 + } 74 + 75 + static void __l2c_op_way(void __iomem *reg) 76 + { 77 + writel_relaxed(l2x0_way_mask, reg); 78 + l2c_wait_mask(reg, l2x0_way_mask); 79 + } 80 + 81 + static inline void l2c_unlock(void __iomem *base, unsigned num) 82 + { 83 + unsigned i; 84 + 85 + for (i = 0; i < num; i++) { 86 + writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_D_BASE + 87 + i * L2X0_LOCKDOWN_STRIDE); 88 + writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_I_BASE + 89 + i * L2X0_LOCKDOWN_STRIDE); 90 + } 91 + } 92 + 93 + /* 94 + * Enable the L2 cache controller. This function must only be 95 + * called when the cache controller is known to be disabled. 96 + */ 97 + static void l2c_enable(void __iomem *base, u32 aux, unsigned num_lock) 98 + { 99 + unsigned long flags; 100 + 101 + l2c_write_sec(aux, base, L2X0_AUX_CTRL); 102 + 103 + l2c_unlock(base, num_lock); 104 + 105 + local_irq_save(flags); 106 + __l2c_op_way(base + L2X0_INV_WAY); 107 + writel_relaxed(0, base + sync_reg_offset); 108 + l2c_wait_mask(base + sync_reg_offset, 1); 109 + local_irq_restore(flags); 110 + 111 + l2c_write_sec(L2X0_CTRL_EN, base, L2X0_CTRL); 112 + } 113 + 114 + static void l2c_disable(void) 115 + { 116 + void __iomem *base = l2x0_base; 117 + 118 + outer_cache.flush_all(); 119 + l2c_write_sec(0, base, L2X0_CTRL); 120 + dsb(st); 73 121 } 74 122 75 123 #ifdef CONFIG_CACHE_PL310 ··· 141 63 /* cache operations by line are atomic on PL310 */ 142 64 } 143 65 #else 144 - #define cache_wait cache_wait_way 66 + #define cache_wait l2c_wait_mask 145 67 #endif 146 68 147 69 static inline void cache_sync(void) ··· 152 74 cache_wait(base + L2X0_CACHE_SYNC, 1); 153 75 } 154 76 155 - static inline void l2x0_clean_line(unsigned long addr) 156 - { 157 - void __iomem *base = l2x0_base; 158 - cache_wait(base + L2X0_CLEAN_LINE_PA, 1); 159 - writel_relaxed(addr, base + L2X0_CLEAN_LINE_PA); 160 - } 161 - 162 - static inline void l2x0_inv_line(unsigned long addr) 163 - { 164 - void __iomem *base = l2x0_base; 165 - cache_wait(base + L2X0_INV_LINE_PA, 1); 166 - writel_relaxed(addr, base + L2X0_INV_LINE_PA); 167 - } 168 - 169 77 #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915) 170 78 static inline void debug_writel(unsigned long val) 171 79 { 172 - if (outer_cache.set_debug) 173 - outer_cache.set_debug(val); 174 - } 175 - 176 - static void pl310_set_debug(unsigned long val) 177 - { 178 - writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL); 80 + l2c_set_debug(l2x0_base, val); 179 81 } 180 82 #else 181 83 /* Optimised out for non-errata case */ 182 84 static inline void debug_writel(unsigned long val) 183 85 { 184 - } 185 - 186 - #define pl310_set_debug NULL 187 - #endif 188 - 189 - #ifdef CONFIG_PL310_ERRATA_588369 190 - static inline void l2x0_flush_line(unsigned long addr) 191 - { 192 - void __iomem *base = l2x0_base; 193 - 194 - /* Clean by PA followed by Invalidate by PA */ 195 - cache_wait(base + L2X0_CLEAN_LINE_PA, 1); 196 - writel_relaxed(addr, base + L2X0_CLEAN_LINE_PA); 197 - cache_wait(base + L2X0_INV_LINE_PA, 1); 198 - writel_relaxed(addr, base + L2X0_INV_LINE_PA); 199 - } 200 - #else 201 - 202 - static inline void l2x0_flush_line(unsigned long addr) 203 - { 204 - void __iomem *base = l2x0_base; 205 - cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); 206 - writel_relaxed(addr, base + L2X0_CLEAN_INV_LINE_PA); 207 86 } 208 87 #endif 209 88 ··· 176 141 static void __l2x0_flush_all(void) 177 142 { 178 143 debug_writel(0x03); 179 - writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY); 180 - cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask); 144 + __l2c_op_way(l2x0_base + L2X0_CLEAN_INV_WAY); 181 145 cache_sync(); 182 146 debug_writel(0x00); 183 147 } ··· 191 157 raw_spin_unlock_irqrestore(&l2x0_lock, flags); 192 158 } 193 159 194 - static void l2x0_clean_all(void) 195 - { 196 - unsigned long flags; 197 - 198 - /* clean all ways */ 199 - raw_spin_lock_irqsave(&l2x0_lock, flags); 200 - writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_WAY); 201 - cache_wait_way(l2x0_base + L2X0_CLEAN_WAY, l2x0_way_mask); 202 - cache_sync(); 203 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 204 - } 205 - 206 - static void l2x0_inv_all(void) 207 - { 208 - unsigned long flags; 209 - 210 - /* invalidate all ways */ 211 - raw_spin_lock_irqsave(&l2x0_lock, flags); 212 - /* Invalidating when L2 is enabled is a nono */ 213 - BUG_ON(readl(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN); 214 - writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY); 215 - cache_wait_way(l2x0_base + L2X0_INV_WAY, l2x0_way_mask); 216 - cache_sync(); 217 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 218 - } 219 - 220 - static void l2x0_inv_range(unsigned long start, unsigned long end) 221 - { 222 - void __iomem *base = l2x0_base; 223 - unsigned long flags; 224 - 225 - raw_spin_lock_irqsave(&l2x0_lock, flags); 226 - if (start & (CACHE_LINE_SIZE - 1)) { 227 - start &= ~(CACHE_LINE_SIZE - 1); 228 - debug_writel(0x03); 229 - l2x0_flush_line(start); 230 - debug_writel(0x00); 231 - start += CACHE_LINE_SIZE; 232 - } 233 - 234 - if (end & (CACHE_LINE_SIZE - 1)) { 235 - end &= ~(CACHE_LINE_SIZE - 1); 236 - debug_writel(0x03); 237 - l2x0_flush_line(end); 238 - debug_writel(0x00); 239 - } 240 - 241 - while (start < end) { 242 - unsigned long blk_end = start + min(end - start, 4096UL); 243 - 244 - while (start < blk_end) { 245 - l2x0_inv_line(start); 246 - start += CACHE_LINE_SIZE; 247 - } 248 - 249 - if (blk_end < end) { 250 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 251 - raw_spin_lock_irqsave(&l2x0_lock, flags); 252 - } 253 - } 254 - cache_wait(base + L2X0_INV_LINE_PA, 1); 255 - cache_sync(); 256 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 257 - } 258 - 259 - static void l2x0_clean_range(unsigned long start, unsigned long end) 260 - { 261 - void __iomem *base = l2x0_base; 262 - unsigned long flags; 263 - 264 - if ((end - start) >= l2x0_size) { 265 - l2x0_clean_all(); 266 - return; 267 - } 268 - 269 - raw_spin_lock_irqsave(&l2x0_lock, flags); 270 - start &= ~(CACHE_LINE_SIZE - 1); 271 - while (start < end) { 272 - unsigned long blk_end = start + min(end - start, 4096UL); 273 - 274 - while (start < blk_end) { 275 - l2x0_clean_line(start); 276 - start += CACHE_LINE_SIZE; 277 - } 278 - 279 - if (blk_end < end) { 280 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 281 - raw_spin_lock_irqsave(&l2x0_lock, flags); 282 - } 283 - } 284 - cache_wait(base + L2X0_CLEAN_LINE_PA, 1); 285 - cache_sync(); 286 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 287 - } 288 - 289 - static void l2x0_flush_range(unsigned long start, unsigned long end) 290 - { 291 - void __iomem *base = l2x0_base; 292 - unsigned long flags; 293 - 294 - if ((end - start) >= l2x0_size) { 295 - l2x0_flush_all(); 296 - return; 297 - } 298 - 299 - raw_spin_lock_irqsave(&l2x0_lock, flags); 300 - start &= ~(CACHE_LINE_SIZE - 1); 301 - while (start < end) { 302 - unsigned long blk_end = start + min(end - start, 4096UL); 303 - 304 - debug_writel(0x03); 305 - while (start < blk_end) { 306 - l2x0_flush_line(start); 307 - start += CACHE_LINE_SIZE; 308 - } 309 - debug_writel(0x00); 310 - 311 - if (blk_end < end) { 312 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 313 - raw_spin_lock_irqsave(&l2x0_lock, flags); 314 - } 315 - } 316 - cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); 317 - cache_sync(); 318 - raw_spin_unlock_irqrestore(&l2x0_lock, flags); 319 - } 320 - 321 160 static void l2x0_disable(void) 322 161 { 323 162 unsigned long flags; 324 163 325 164 raw_spin_lock_irqsave(&l2x0_lock, flags); 326 165 __l2x0_flush_all(); 327 - writel_relaxed(0, l2x0_base + L2X0_CTRL); 166 + l2c_write_sec(0, l2x0_base, L2X0_CTRL); 328 167 dsb(st); 329 168 raw_spin_unlock_irqrestore(&l2x0_lock, flags); 330 169 } 331 170 332 - static void l2x0_unlock(u32 cache_id) 171 + static void l2c_save(void __iomem *base) 333 172 { 334 - int lockregs; 335 - int i; 173 + l2x0_saved_regs.aux_ctrl = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 174 + } 336 175 337 - switch (cache_id & L2X0_CACHE_ID_PART_MASK) { 338 - case L2X0_CACHE_ID_PART_L310: 339 - lockregs = 8; 340 - break; 341 - case AURORA_CACHE_ID: 342 - lockregs = 4; 343 - break; 344 - default: 345 - /* L210 and unknown types */ 346 - lockregs = 1; 347 - break; 348 - } 176 + /* 177 + * L2C-210 specific code. 178 + * 179 + * The L2C-2x0 PA, set/way and sync operations are atomic, but we must 180 + * ensure that no background operation is running. The way operations 181 + * are all background tasks. 182 + * 183 + * While a background operation is in progress, any new operation is 184 + * ignored (unspecified whether this causes an error.) Thankfully, not 185 + * used on SMP. 186 + * 187 + * Never has a different sync register other than L2X0_CACHE_SYNC, but 188 + * we use sync_reg_offset here so we can share some of this with L2C-310. 189 + */ 190 + static void __l2c210_cache_sync(void __iomem *base) 191 + { 192 + writel_relaxed(0, base + sync_reg_offset); 193 + } 349 194 350 - for (i = 0; i < lockregs; i++) { 351 - writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE + 352 - i * L2X0_LOCKDOWN_STRIDE); 353 - writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE + 354 - i * L2X0_LOCKDOWN_STRIDE); 195 + static void __l2c210_op_pa_range(void __iomem *reg, unsigned long start, 196 + unsigned long end) 197 + { 198 + while (start < end) { 199 + writel_relaxed(start, reg); 200 + start += CACHE_LINE_SIZE; 355 201 } 356 202 } 357 203 358 - void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) 204 + static void l2c210_inv_range(unsigned long start, unsigned long end) 359 205 { 360 - u32 aux; 361 - u32 cache_id; 362 - u32 way_size = 0; 363 - int ways; 364 - int way_size_shift = L2X0_WAY_SIZE_SHIFT; 365 - const char *type; 206 + void __iomem *base = l2x0_base; 366 207 367 - l2x0_base = base; 368 - if (cache_id_part_number_from_dt) 369 - cache_id = cache_id_part_number_from_dt; 370 - else 371 - cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID); 372 - aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 208 + if (start & (CACHE_LINE_SIZE - 1)) { 209 + start &= ~(CACHE_LINE_SIZE - 1); 210 + writel_relaxed(start, base + L2X0_CLEAN_INV_LINE_PA); 211 + start += CACHE_LINE_SIZE; 212 + } 373 213 214 + if (end & (CACHE_LINE_SIZE - 1)) { 215 + end &= ~(CACHE_LINE_SIZE - 1); 216 + writel_relaxed(end, base + L2X0_CLEAN_INV_LINE_PA); 217 + } 218 + 219 + __l2c210_op_pa_range(base + L2X0_INV_LINE_PA, start, end); 220 + __l2c210_cache_sync(base); 221 + } 222 + 223 + static void l2c210_clean_range(unsigned long start, unsigned long end) 224 + { 225 + void __iomem *base = l2x0_base; 226 + 227 + start &= ~(CACHE_LINE_SIZE - 1); 228 + __l2c210_op_pa_range(base + L2X0_CLEAN_LINE_PA, start, end); 229 + __l2c210_cache_sync(base); 230 + } 231 + 232 + static void l2c210_flush_range(unsigned long start, unsigned long end) 233 + { 234 + void __iomem *base = l2x0_base; 235 + 236 + start &= ~(CACHE_LINE_SIZE - 1); 237 + __l2c210_op_pa_range(base + L2X0_CLEAN_INV_LINE_PA, start, end); 238 + __l2c210_cache_sync(base); 239 + } 240 + 241 + static void l2c210_flush_all(void) 242 + { 243 + void __iomem *base = l2x0_base; 244 + 245 + BUG_ON(!irqs_disabled()); 246 + 247 + __l2c_op_way(base + L2X0_CLEAN_INV_WAY); 248 + __l2c210_cache_sync(base); 249 + } 250 + 251 + static void l2c210_sync(void) 252 + { 253 + __l2c210_cache_sync(l2x0_base); 254 + } 255 + 256 + static void l2c210_resume(void) 257 + { 258 + void __iomem *base = l2x0_base; 259 + 260 + if (!(readl_relaxed(base + L2X0_CTRL) & L2X0_CTRL_EN)) 261 + l2c_enable(base, l2x0_saved_regs.aux_ctrl, 1); 262 + } 263 + 264 + static const struct l2c_init_data l2c210_data __initconst = { 265 + .type = "L2C-210", 266 + .way_size_0 = SZ_8K, 267 + .num_lock = 1, 268 + .enable = l2c_enable, 269 + .save = l2c_save, 270 + .outer_cache = { 271 + .inv_range = l2c210_inv_range, 272 + .clean_range = l2c210_clean_range, 273 + .flush_range = l2c210_flush_range, 274 + .flush_all = l2c210_flush_all, 275 + .disable = l2c_disable, 276 + .sync = l2c210_sync, 277 + .resume = l2c210_resume, 278 + }, 279 + }; 280 + 281 + /* 282 + * L2C-220 specific code. 283 + * 284 + * All operations are background operations: they have to be waited for. 285 + * Conflicting requests generate a slave error (which will cause an 286 + * imprecise abort.) Never uses sync_reg_offset, so we hard-code the 287 + * sync register here. 288 + * 289 + * However, we can re-use the l2c210_resume call. 290 + */ 291 + static inline void __l2c220_cache_sync(void __iomem *base) 292 + { 293 + writel_relaxed(0, base + L2X0_CACHE_SYNC); 294 + l2c_wait_mask(base + L2X0_CACHE_SYNC, 1); 295 + } 296 + 297 + static void l2c220_op_way(void __iomem *base, unsigned reg) 298 + { 299 + unsigned long flags; 300 + 301 + raw_spin_lock_irqsave(&l2x0_lock, flags); 302 + __l2c_op_way(base + reg); 303 + __l2c220_cache_sync(base); 304 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 305 + } 306 + 307 + static unsigned long l2c220_op_pa_range(void __iomem *reg, unsigned long start, 308 + unsigned long end, unsigned long flags) 309 + { 310 + raw_spinlock_t *lock = &l2x0_lock; 311 + 312 + while (start < end) { 313 + unsigned long blk_end = start + min(end - start, 4096UL); 314 + 315 + while (start < blk_end) { 316 + l2c_wait_mask(reg, 1); 317 + writel_relaxed(start, reg); 318 + start += CACHE_LINE_SIZE; 319 + } 320 + 321 + if (blk_end < end) { 322 + raw_spin_unlock_irqrestore(lock, flags); 323 + raw_spin_lock_irqsave(lock, flags); 324 + } 325 + } 326 + 327 + return flags; 328 + } 329 + 330 + static void l2c220_inv_range(unsigned long start, unsigned long end) 331 + { 332 + void __iomem *base = l2x0_base; 333 + unsigned long flags; 334 + 335 + raw_spin_lock_irqsave(&l2x0_lock, flags); 336 + if ((start | end) & (CACHE_LINE_SIZE - 1)) { 337 + if (start & (CACHE_LINE_SIZE - 1)) { 338 + start &= ~(CACHE_LINE_SIZE - 1); 339 + writel_relaxed(start, base + L2X0_CLEAN_INV_LINE_PA); 340 + start += CACHE_LINE_SIZE; 341 + } 342 + 343 + if (end & (CACHE_LINE_SIZE - 1)) { 344 + end &= ~(CACHE_LINE_SIZE - 1); 345 + l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1); 346 + writel_relaxed(end, base + L2X0_CLEAN_INV_LINE_PA); 347 + } 348 + } 349 + 350 + flags = l2c220_op_pa_range(base + L2X0_INV_LINE_PA, 351 + start, end, flags); 352 + l2c_wait_mask(base + L2X0_INV_LINE_PA, 1); 353 + __l2c220_cache_sync(base); 354 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 355 + } 356 + 357 + static void l2c220_clean_range(unsigned long start, unsigned long end) 358 + { 359 + void __iomem *base = l2x0_base; 360 + unsigned long flags; 361 + 362 + start &= ~(CACHE_LINE_SIZE - 1); 363 + if ((end - start) >= l2x0_size) { 364 + l2c220_op_way(base, L2X0_CLEAN_WAY); 365 + return; 366 + } 367 + 368 + raw_spin_lock_irqsave(&l2x0_lock, flags); 369 + flags = l2c220_op_pa_range(base + L2X0_CLEAN_LINE_PA, 370 + start, end, flags); 371 + l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1); 372 + __l2c220_cache_sync(base); 373 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 374 + } 375 + 376 + static void l2c220_flush_range(unsigned long start, unsigned long end) 377 + { 378 + void __iomem *base = l2x0_base; 379 + unsigned long flags; 380 + 381 + start &= ~(CACHE_LINE_SIZE - 1); 382 + if ((end - start) >= l2x0_size) { 383 + l2c220_op_way(base, L2X0_CLEAN_INV_WAY); 384 + return; 385 + } 386 + 387 + raw_spin_lock_irqsave(&l2x0_lock, flags); 388 + flags = l2c220_op_pa_range(base + L2X0_CLEAN_INV_LINE_PA, 389 + start, end, flags); 390 + l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1); 391 + __l2c220_cache_sync(base); 392 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 393 + } 394 + 395 + static void l2c220_flush_all(void) 396 + { 397 + l2c220_op_way(l2x0_base, L2X0_CLEAN_INV_WAY); 398 + } 399 + 400 + static void l2c220_sync(void) 401 + { 402 + unsigned long flags; 403 + 404 + raw_spin_lock_irqsave(&l2x0_lock, flags); 405 + __l2c220_cache_sync(l2x0_base); 406 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 407 + } 408 + 409 + static void l2c220_enable(void __iomem *base, u32 aux, unsigned num_lock) 410 + { 411 + /* 412 + * Always enable non-secure access to the lockdown registers - 413 + * we write to them as part of the L2C enable sequence so they 414 + * need to be accessible. 415 + */ 416 + aux |= L220_AUX_CTRL_NS_LOCKDOWN; 417 + 418 + l2c_enable(base, aux, num_lock); 419 + } 420 + 421 + static const struct l2c_init_data l2c220_data = { 422 + .type = "L2C-220", 423 + .way_size_0 = SZ_8K, 424 + .num_lock = 1, 425 + .enable = l2c220_enable, 426 + .save = l2c_save, 427 + .outer_cache = { 428 + .inv_range = l2c220_inv_range, 429 + .clean_range = l2c220_clean_range, 430 + .flush_range = l2c220_flush_range, 431 + .flush_all = l2c220_flush_all, 432 + .disable = l2c_disable, 433 + .sync = l2c220_sync, 434 + .resume = l2c210_resume, 435 + }, 436 + }; 437 + 438 + /* 439 + * L2C-310 specific code. 440 + * 441 + * Very similar to L2C-210, the PA, set/way and sync operations are atomic, 442 + * and the way operations are all background tasks. However, issuing an 443 + * operation while a background operation is in progress results in a 444 + * SLVERR response. We can reuse: 445 + * 446 + * __l2c210_cache_sync (using sync_reg_offset) 447 + * l2c210_sync 448 + * l2c210_inv_range (if 588369 is not applicable) 449 + * l2c210_clean_range 450 + * l2c210_flush_range (if 588369 is not applicable) 451 + * l2c210_flush_all (if 727915 is not applicable) 452 + * 453 + * Errata: 454 + * 588369: PL310 R0P0->R1P0, fixed R2P0. 455 + * Affects: all clean+invalidate operations 456 + * clean and invalidate skips the invalidate step, so we need to issue 457 + * separate operations. We also require the above debug workaround 458 + * enclosing this code fragment on affected parts. On unaffected parts, 459 + * we must not use this workaround without the debug register writes 460 + * to avoid exposing a problem similar to 727915. 461 + * 462 + * 727915: PL310 R2P0->R3P0, fixed R3P1. 463 + * Affects: clean+invalidate by way 464 + * clean and invalidate by way runs in the background, and a store can 465 + * hit the line between the clean operation and invalidate operation, 466 + * resulting in the store being lost. 467 + * 468 + * 752271: PL310 R3P0->R3P1-50REL0, fixed R3P2. 469 + * Affects: 8x64-bit (double fill) line fetches 470 + * double fill line fetches can fail to cause dirty data to be evicted 471 + * from the cache before the new data overwrites the second line. 472 + * 473 + * 753970: PL310 R3P0, fixed R3P1. 474 + * Affects: sync 475 + * prevents merging writes after the sync operation, until another L2C 476 + * operation is performed (or a number of other conditions.) 477 + * 478 + * 769419: PL310 R0P0->R3P1, fixed R3P2. 479 + * Affects: store buffer 480 + * store buffer is not automatically drained. 481 + */ 482 + static void l2c310_inv_range_erratum(unsigned long start, unsigned long end) 483 + { 484 + void __iomem *base = l2x0_base; 485 + 486 + if ((start | end) & (CACHE_LINE_SIZE - 1)) { 487 + unsigned long flags; 488 + 489 + /* Erratum 588369 for both clean+invalidate operations */ 490 + raw_spin_lock_irqsave(&l2x0_lock, flags); 491 + l2c_set_debug(base, 0x03); 492 + 493 + if (start & (CACHE_LINE_SIZE - 1)) { 494 + start &= ~(CACHE_LINE_SIZE - 1); 495 + writel_relaxed(start, base + L2X0_CLEAN_LINE_PA); 496 + writel_relaxed(start, base + L2X0_INV_LINE_PA); 497 + start += CACHE_LINE_SIZE; 498 + } 499 + 500 + if (end & (CACHE_LINE_SIZE - 1)) { 501 + end &= ~(CACHE_LINE_SIZE - 1); 502 + writel_relaxed(end, base + L2X0_CLEAN_LINE_PA); 503 + writel_relaxed(end, base + L2X0_INV_LINE_PA); 504 + } 505 + 506 + l2c_set_debug(base, 0x00); 507 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 508 + } 509 + 510 + __l2c210_op_pa_range(base + L2X0_INV_LINE_PA, start, end); 511 + __l2c210_cache_sync(base); 512 + } 513 + 514 + static void l2c310_flush_range_erratum(unsigned long start, unsigned long end) 515 + { 516 + raw_spinlock_t *lock = &l2x0_lock; 517 + unsigned long flags; 518 + void __iomem *base = l2x0_base; 519 + 520 + raw_spin_lock_irqsave(lock, flags); 521 + while (start < end) { 522 + unsigned long blk_end = start + min(end - start, 4096UL); 523 + 524 + l2c_set_debug(base, 0x03); 525 + while (start < blk_end) { 526 + writel_relaxed(start, base + L2X0_CLEAN_LINE_PA); 527 + writel_relaxed(start, base + L2X0_INV_LINE_PA); 528 + start += CACHE_LINE_SIZE; 529 + } 530 + l2c_set_debug(base, 0x00); 531 + 532 + if (blk_end < end) { 533 + raw_spin_unlock_irqrestore(lock, flags); 534 + raw_spin_lock_irqsave(lock, flags); 535 + } 536 + } 537 + raw_spin_unlock_irqrestore(lock, flags); 538 + __l2c210_cache_sync(base); 539 + } 540 + 541 + static void l2c310_flush_all_erratum(void) 542 + { 543 + void __iomem *base = l2x0_base; 544 + unsigned long flags; 545 + 546 + raw_spin_lock_irqsave(&l2x0_lock, flags); 547 + l2c_set_debug(base, 0x03); 548 + __l2c_op_way(base + L2X0_CLEAN_INV_WAY); 549 + l2c_set_debug(base, 0x00); 550 + __l2c210_cache_sync(base); 551 + raw_spin_unlock_irqrestore(&l2x0_lock, flags); 552 + } 553 + 554 + static void __init l2c310_save(void __iomem *base) 555 + { 556 + unsigned revision; 557 + 558 + l2c_save(base); 559 + 560 + l2x0_saved_regs.tag_latency = readl_relaxed(base + 561 + L310_TAG_LATENCY_CTRL); 562 + l2x0_saved_regs.data_latency = readl_relaxed(base + 563 + L310_DATA_LATENCY_CTRL); 564 + l2x0_saved_regs.filter_end = readl_relaxed(base + 565 + L310_ADDR_FILTER_END); 566 + l2x0_saved_regs.filter_start = readl_relaxed(base + 567 + L310_ADDR_FILTER_START); 568 + 569 + revision = readl_relaxed(base + L2X0_CACHE_ID) & 570 + L2X0_CACHE_ID_RTL_MASK; 571 + 572 + /* From r2p0, there is Prefetch offset/control register */ 573 + if (revision >= L310_CACHE_ID_RTL_R2P0) 574 + l2x0_saved_regs.prefetch_ctrl = readl_relaxed(base + 575 + L310_PREFETCH_CTRL); 576 + 577 + /* From r3p0, there is Power control register */ 578 + if (revision >= L310_CACHE_ID_RTL_R3P0) 579 + l2x0_saved_regs.pwr_ctrl = readl_relaxed(base + 580 + L310_POWER_CTRL); 581 + } 582 + 583 + static void l2c310_resume(void) 584 + { 585 + void __iomem *base = l2x0_base; 586 + 587 + if (!(readl_relaxed(base + L2X0_CTRL) & L2X0_CTRL_EN)) { 588 + unsigned revision; 589 + 590 + /* restore pl310 setup */ 591 + writel_relaxed(l2x0_saved_regs.tag_latency, 592 + base + L310_TAG_LATENCY_CTRL); 593 + writel_relaxed(l2x0_saved_regs.data_latency, 594 + base + L310_DATA_LATENCY_CTRL); 595 + writel_relaxed(l2x0_saved_regs.filter_end, 596 + base + L310_ADDR_FILTER_END); 597 + writel_relaxed(l2x0_saved_regs.filter_start, 598 + base + L310_ADDR_FILTER_START); 599 + 600 + revision = readl_relaxed(base + L2X0_CACHE_ID) & 601 + L2X0_CACHE_ID_RTL_MASK; 602 + 603 + if (revision >= L310_CACHE_ID_RTL_R2P0) 604 + l2c_write_sec(l2x0_saved_regs.prefetch_ctrl, base, 605 + L310_PREFETCH_CTRL); 606 + if (revision >= L310_CACHE_ID_RTL_R3P0) 607 + l2c_write_sec(l2x0_saved_regs.pwr_ctrl, base, 608 + L310_POWER_CTRL); 609 + 610 + l2c_enable(base, l2x0_saved_regs.aux_ctrl, 8); 611 + 612 + /* Re-enable full-line-of-zeros for Cortex-A9 */ 613 + if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_FULL_LINE_ZERO) 614 + set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1)); 615 + } 616 + } 617 + 618 + static int l2c310_cpu_enable_flz(struct notifier_block *nb, unsigned long act, void *data) 619 + { 620 + switch (act & ~CPU_TASKS_FROZEN) { 621 + case CPU_STARTING: 622 + set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1)); 623 + break; 624 + case CPU_DYING: 625 + set_auxcr(get_auxcr() & ~(BIT(3) | BIT(2) | BIT(1))); 626 + break; 627 + } 628 + return NOTIFY_OK; 629 + } 630 + 631 + static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock) 632 + { 633 + unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_PART_MASK; 634 + bool cortex_a9 = read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9; 635 + 636 + if (rev >= L310_CACHE_ID_RTL_R2P0) { 637 + if (cortex_a9) { 638 + aux |= L310_AUX_CTRL_EARLY_BRESP; 639 + pr_info("L2C-310 enabling early BRESP for Cortex-A9\n"); 640 + } else if (aux & L310_AUX_CTRL_EARLY_BRESP) { 641 + pr_warn("L2C-310 early BRESP only supported with Cortex-A9\n"); 642 + aux &= ~L310_AUX_CTRL_EARLY_BRESP; 643 + } 644 + } 645 + 646 + if (cortex_a9) { 647 + u32 aux_cur = readl_relaxed(base + L2X0_AUX_CTRL); 648 + u32 acr = get_auxcr(); 649 + 650 + pr_debug("Cortex-A9 ACR=0x%08x\n", acr); 651 + 652 + if (acr & BIT(3) && !(aux_cur & L310_AUX_CTRL_FULL_LINE_ZERO)) 653 + pr_err("L2C-310: full line of zeros enabled in Cortex-A9 but not L2C-310 - invalid\n"); 654 + 655 + if (aux & L310_AUX_CTRL_FULL_LINE_ZERO && !(acr & BIT(3))) 656 + pr_err("L2C-310: enabling full line of zeros but not enabled in Cortex-A9\n"); 657 + 658 + if (!(aux & L310_AUX_CTRL_FULL_LINE_ZERO) && !outer_cache.write_sec) { 659 + aux |= L310_AUX_CTRL_FULL_LINE_ZERO; 660 + pr_info("L2C-310 full line of zeros enabled for Cortex-A9\n"); 661 + } 662 + } else if (aux & (L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP)) { 663 + pr_err("L2C-310: disabling Cortex-A9 specific feature bits\n"); 664 + aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP); 665 + } 666 + 667 + if (aux & (L310_AUX_CTRL_DATA_PREFETCH | L310_AUX_CTRL_INSTR_PREFETCH)) { 668 + u32 prefetch = readl_relaxed(base + L310_PREFETCH_CTRL); 669 + 670 + pr_info("L2C-310 %s%s prefetch enabled, offset %u lines\n", 671 + aux & L310_AUX_CTRL_INSTR_PREFETCH ? "I" : "", 672 + aux & L310_AUX_CTRL_DATA_PREFETCH ? "D" : "", 673 + 1 + (prefetch & L310_PREFETCH_CTRL_OFFSET_MASK)); 674 + } 675 + 676 + /* r3p0 or later has power control register */ 677 + if (rev >= L310_CACHE_ID_RTL_R3P0) { 678 + u32 power_ctrl; 679 + 680 + l2c_write_sec(L310_DYNAMIC_CLK_GATING_EN | L310_STNDBY_MODE_EN, 681 + base, L310_POWER_CTRL); 682 + power_ctrl = readl_relaxed(base + L310_POWER_CTRL); 683 + pr_info("L2C-310 dynamic clock gating %sabled, standby mode %sabled\n", 684 + power_ctrl & L310_DYNAMIC_CLK_GATING_EN ? "en" : "dis", 685 + power_ctrl & L310_STNDBY_MODE_EN ? "en" : "dis"); 686 + } 687 + 688 + /* 689 + * Always enable non-secure access to the lockdown registers - 690 + * we write to them as part of the L2C enable sequence so they 691 + * need to be accessible. 692 + */ 693 + aux |= L310_AUX_CTRL_NS_LOCKDOWN; 694 + 695 + l2c_enable(base, aux, num_lock); 696 + 697 + if (aux & L310_AUX_CTRL_FULL_LINE_ZERO) { 698 + set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1)); 699 + cpu_notifier(l2c310_cpu_enable_flz, 0); 700 + } 701 + } 702 + 703 + static void __init l2c310_fixup(void __iomem *base, u32 cache_id, 704 + struct outer_cache_fns *fns) 705 + { 706 + unsigned revision = cache_id & L2X0_CACHE_ID_RTL_MASK; 707 + const char *errata[8]; 708 + unsigned n = 0; 709 + 710 + if (IS_ENABLED(CONFIG_PL310_ERRATA_588369) && 711 + revision < L310_CACHE_ID_RTL_R2P0 && 712 + /* For bcm compatibility */ 713 + fns->inv_range == l2c210_inv_range) { 714 + fns->inv_range = l2c310_inv_range_erratum; 715 + fns->flush_range = l2c310_flush_range_erratum; 716 + errata[n++] = "588369"; 717 + } 718 + 719 + if (IS_ENABLED(CONFIG_PL310_ERRATA_727915) && 720 + revision >= L310_CACHE_ID_RTL_R2P0 && 721 + revision < L310_CACHE_ID_RTL_R3P1) { 722 + fns->flush_all = l2c310_flush_all_erratum; 723 + errata[n++] = "727915"; 724 + } 725 + 726 + if (revision >= L310_CACHE_ID_RTL_R3P0 && 727 + revision < L310_CACHE_ID_RTL_R3P2) { 728 + u32 val = readl_relaxed(base + L310_PREFETCH_CTRL); 729 + /* I don't think bit23 is required here... but iMX6 does so */ 730 + if (val & (BIT(30) | BIT(23))) { 731 + val &= ~(BIT(30) | BIT(23)); 732 + l2c_write_sec(val, base, L310_PREFETCH_CTRL); 733 + errata[n++] = "752271"; 734 + } 735 + } 736 + 737 + if (IS_ENABLED(CONFIG_PL310_ERRATA_753970) && 738 + revision == L310_CACHE_ID_RTL_R3P0) { 739 + sync_reg_offset = L2X0_DUMMY_REG; 740 + errata[n++] = "753970"; 741 + } 742 + 743 + if (IS_ENABLED(CONFIG_PL310_ERRATA_769419)) 744 + errata[n++] = "769419"; 745 + 746 + if (n) { 747 + unsigned i; 748 + 749 + pr_info("L2C-310 errat%s", n > 1 ? "a" : "um"); 750 + for (i = 0; i < n; i++) 751 + pr_cont(" %s", errata[i]); 752 + pr_cont(" enabled\n"); 753 + } 754 + } 755 + 756 + static void l2c310_disable(void) 757 + { 758 + /* 759 + * If full-line-of-zeros is enabled, we must first disable it in the 760 + * Cortex-A9 auxiliary control register before disabling the L2 cache. 761 + */ 762 + if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_FULL_LINE_ZERO) 763 + set_auxcr(get_auxcr() & ~(BIT(3) | BIT(2) | BIT(1))); 764 + 765 + l2c_disable(); 766 + } 767 + 768 + static const struct l2c_init_data l2c310_init_fns __initconst = { 769 + .type = "L2C-310", 770 + .way_size_0 = SZ_8K, 771 + .num_lock = 8, 772 + .enable = l2c310_enable, 773 + .fixup = l2c310_fixup, 774 + .save = l2c310_save, 775 + .outer_cache = { 776 + .inv_range = l2c210_inv_range, 777 + .clean_range = l2c210_clean_range, 778 + .flush_range = l2c210_flush_range, 779 + .flush_all = l2c210_flush_all, 780 + .disable = l2c310_disable, 781 + .sync = l2c210_sync, 782 + .resume = l2c310_resume, 783 + }, 784 + }; 785 + 786 + static void __init __l2c_init(const struct l2c_init_data *data, 787 + u32 aux_val, u32 aux_mask, u32 cache_id) 788 + { 789 + struct outer_cache_fns fns; 790 + unsigned way_size_bits, ways; 791 + u32 aux, old_aux; 792 + 793 + /* 794 + * Sanity check the aux values. aux_mask is the bits we preserve 795 + * from reading the hardware register, and aux_val is the bits we 796 + * set. 797 + */ 798 + if (aux_val & aux_mask) 799 + pr_alert("L2C: platform provided aux values permit register corruption.\n"); 800 + 801 + old_aux = aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 374 802 aux &= aux_mask; 375 803 aux |= aux_val; 804 + 805 + if (old_aux != aux) 806 + pr_warn("L2C: DT/platform modifies aux control register: 0x%08x -> 0x%08x\n", 807 + old_aux, aux); 376 808 377 809 /* Determine the number of ways */ 378 810 switch (cache_id & L2X0_CACHE_ID_PART_MASK) { 379 811 case L2X0_CACHE_ID_PART_L310: 812 + if ((aux_val | ~aux_mask) & (L2C_AUX_CTRL_WAY_SIZE_MASK | L310_AUX_CTRL_ASSOCIATIVITY_16)) 813 + pr_warn("L2C: DT/platform tries to modify or specify cache size\n"); 380 814 if (aux & (1 << 16)) 381 815 ways = 16; 382 816 else 383 817 ways = 8; 384 - type = "L310"; 385 - #ifdef CONFIG_PL310_ERRATA_753970 386 - /* Unmapped register. */ 387 - sync_reg_offset = L2X0_DUMMY_REG; 388 - #endif 389 - if ((cache_id & L2X0_CACHE_ID_RTL_MASK) <= L2X0_CACHE_ID_RTL_R3P0) 390 - outer_cache.set_debug = pl310_set_debug; 391 818 break; 819 + 392 820 case L2X0_CACHE_ID_PART_L210: 821 + case L2X0_CACHE_ID_PART_L220: 393 822 ways = (aux >> 13) & 0xf; 394 - type = "L210"; 395 823 break; 396 824 397 825 case AURORA_CACHE_ID: 398 - sync_reg_offset = AURORA_SYNC_REG; 399 826 ways = (aux >> 13) & 0xf; 400 827 ways = 2 << ((ways + 1) >> 2); 401 - way_size_shift = AURORA_WAY_SIZE_SHIFT; 402 - type = "Aurora"; 403 828 break; 829 + 404 830 default: 405 831 /* Assume unknown chips have 8 ways */ 406 832 ways = 8; 407 - type = "L2x0 series"; 408 833 break; 409 834 } 410 835 411 836 l2x0_way_mask = (1 << ways) - 1; 412 837 413 838 /* 414 - * L2 cache Size = Way size * Number of ways 839 + * way_size_0 is the size that a way_size value of zero would be 840 + * given the calculation: way_size = way_size_0 << way_size_bits. 841 + * So, if way_size_bits=0 is reserved, but way_size_bits=1 is 16k, 842 + * then way_size_0 would be 8k. 843 + * 844 + * L2 cache size = number of ways * way size. 415 845 */ 416 - way_size = (aux & L2X0_AUX_CTRL_WAY_SIZE_MASK) >> 17; 417 - way_size = 1 << (way_size + way_size_shift); 846 + way_size_bits = (aux & L2C_AUX_CTRL_WAY_SIZE_MASK) >> 847 + L2C_AUX_CTRL_WAY_SIZE_SHIFT; 848 + l2x0_size = ways * (data->way_size_0 << way_size_bits); 418 849 419 - l2x0_size = ways * way_size * SZ_1K; 850 + fns = data->outer_cache; 851 + fns.write_sec = outer_cache.write_sec; 852 + if (data->fixup) 853 + data->fixup(l2x0_base, cache_id, &fns); 420 854 421 855 /* 422 - * Check if l2x0 controller is already enabled. 423 - * If you are booting from non-secure mode 424 - * accessing the below registers will fault. 856 + * Check if l2x0 controller is already enabled. If we are booting 857 + * in non-secure mode accessing the below registers will fault. 425 858 */ 426 - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 427 - /* Make sure that I&D is not locked down when starting */ 428 - l2x0_unlock(cache_id); 859 + if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) 860 + data->enable(l2x0_base, aux, data->num_lock); 429 861 430 - /* l2x0 controller is disabled */ 431 - writel_relaxed(aux, l2x0_base + L2X0_AUX_CTRL); 862 + outer_cache = fns; 432 863 433 - l2x0_inv_all(); 434 - 435 - /* enable L2X0 */ 436 - writel_relaxed(L2X0_CTRL_EN, l2x0_base + L2X0_CTRL); 437 - } 864 + /* 865 + * It is strange to save the register state before initialisation, 866 + * but hey, this is what the DT implementations decided to do. 867 + */ 868 + if (data->save) 869 + data->save(l2x0_base); 438 870 439 871 /* Re-read it in case some bits are reserved. */ 440 872 aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 441 873 442 - /* Save the value for resuming. */ 443 - l2x0_saved_regs.aux_ctrl = aux; 874 + pr_info("%s cache controller enabled, %d ways, %d kB\n", 875 + data->type, ways, l2x0_size >> 10); 876 + pr_info("%s: CACHE_ID 0x%08x, AUX_CTRL 0x%08x\n", 877 + data->type, cache_id, aux); 878 + } 444 879 445 - if (!of_init) { 446 - outer_cache.inv_range = l2x0_inv_range; 447 - outer_cache.clean_range = l2x0_clean_range; 448 - outer_cache.flush_range = l2x0_flush_range; 449 - outer_cache.sync = l2x0_cache_sync; 450 - outer_cache.flush_all = l2x0_flush_all; 451 - outer_cache.inv_all = l2x0_inv_all; 452 - outer_cache.disable = l2x0_disable; 880 + void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) 881 + { 882 + const struct l2c_init_data *data; 883 + u32 cache_id; 884 + 885 + l2x0_base = base; 886 + 887 + cache_id = readl_relaxed(base + L2X0_CACHE_ID); 888 + 889 + switch (cache_id & L2X0_CACHE_ID_PART_MASK) { 890 + default: 891 + case L2X0_CACHE_ID_PART_L210: 892 + data = &l2c210_data; 893 + break; 894 + 895 + case L2X0_CACHE_ID_PART_L220: 896 + data = &l2c220_data; 897 + break; 898 + 899 + case L2X0_CACHE_ID_PART_L310: 900 + data = &l2c310_init_fns; 901 + break; 453 902 } 454 903 455 - pr_info("%s cache controller enabled\n", type); 456 - pr_info("l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d kB\n", 457 - ways, cache_id, aux, l2x0_size >> 10); 904 + __l2c_init(data, aux_val, aux_mask, cache_id); 458 905 } 459 906 460 907 #ifdef CONFIG_OF 461 908 static int l2_wt_override; 909 + 910 + /* Aurora don't have the cache ID register available, so we have to 911 + * pass it though the device tree */ 912 + static u32 cache_id_part_number_from_dt; 913 + 914 + static void __init l2x0_of_parse(const struct device_node *np, 915 + u32 *aux_val, u32 *aux_mask) 916 + { 917 + u32 data[2] = { 0, 0 }; 918 + u32 tag = 0; 919 + u32 dirty = 0; 920 + u32 val = 0, mask = 0; 921 + 922 + of_property_read_u32(np, "arm,tag-latency", &tag); 923 + if (tag) { 924 + mask |= L2X0_AUX_CTRL_TAG_LATENCY_MASK; 925 + val |= (tag - 1) << L2X0_AUX_CTRL_TAG_LATENCY_SHIFT; 926 + } 927 + 928 + of_property_read_u32_array(np, "arm,data-latency", 929 + data, ARRAY_SIZE(data)); 930 + if (data[0] && data[1]) { 931 + mask |= L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK | 932 + L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK; 933 + val |= ((data[0] - 1) << L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT) | 934 + ((data[1] - 1) << L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT); 935 + } 936 + 937 + of_property_read_u32(np, "arm,dirty-latency", &dirty); 938 + if (dirty) { 939 + mask |= L2X0_AUX_CTRL_DIRTY_LATENCY_MASK; 940 + val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT; 941 + } 942 + 943 + *aux_val &= ~mask; 944 + *aux_val |= val; 945 + *aux_mask &= ~mask; 946 + } 947 + 948 + static const struct l2c_init_data of_l2c210_data __initconst = { 949 + .type = "L2C-210", 950 + .way_size_0 = SZ_8K, 951 + .num_lock = 1, 952 + .of_parse = l2x0_of_parse, 953 + .enable = l2c_enable, 954 + .save = l2c_save, 955 + .outer_cache = { 956 + .inv_range = l2c210_inv_range, 957 + .clean_range = l2c210_clean_range, 958 + .flush_range = l2c210_flush_range, 959 + .flush_all = l2c210_flush_all, 960 + .disable = l2c_disable, 961 + .sync = l2c210_sync, 962 + .resume = l2c210_resume, 963 + }, 964 + }; 965 + 966 + static const struct l2c_init_data of_l2c220_data __initconst = { 967 + .type = "L2C-220", 968 + .way_size_0 = SZ_8K, 969 + .num_lock = 1, 970 + .of_parse = l2x0_of_parse, 971 + .enable = l2c220_enable, 972 + .save = l2c_save, 973 + .outer_cache = { 974 + .inv_range = l2c220_inv_range, 975 + .clean_range = l2c220_clean_range, 976 + .flush_range = l2c220_flush_range, 977 + .flush_all = l2c220_flush_all, 978 + .disable = l2c_disable, 979 + .sync = l2c220_sync, 980 + .resume = l2c210_resume, 981 + }, 982 + }; 983 + 984 + static void __init l2c310_of_parse(const struct device_node *np, 985 + u32 *aux_val, u32 *aux_mask) 986 + { 987 + u32 data[3] = { 0, 0, 0 }; 988 + u32 tag[3] = { 0, 0, 0 }; 989 + u32 filter[2] = { 0, 0 }; 990 + 991 + of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag)); 992 + if (tag[0] && tag[1] && tag[2]) 993 + writel_relaxed( 994 + L310_LATENCY_CTRL_RD(tag[0] - 1) | 995 + L310_LATENCY_CTRL_WR(tag[1] - 1) | 996 + L310_LATENCY_CTRL_SETUP(tag[2] - 1), 997 + l2x0_base + L310_TAG_LATENCY_CTRL); 998 + 999 + of_property_read_u32_array(np, "arm,data-latency", 1000 + data, ARRAY_SIZE(data)); 1001 + if (data[0] && data[1] && data[2]) 1002 + writel_relaxed( 1003 + L310_LATENCY_CTRL_RD(data[0] - 1) | 1004 + L310_LATENCY_CTRL_WR(data[1] - 1) | 1005 + L310_LATENCY_CTRL_SETUP(data[2] - 1), 1006 + l2x0_base + L310_DATA_LATENCY_CTRL); 1007 + 1008 + of_property_read_u32_array(np, "arm,filter-ranges", 1009 + filter, ARRAY_SIZE(filter)); 1010 + if (filter[1]) { 1011 + writel_relaxed(ALIGN(filter[0] + filter[1], SZ_1M), 1012 + l2x0_base + L310_ADDR_FILTER_END); 1013 + writel_relaxed((filter[0] & ~(SZ_1M - 1)) | L310_ADDR_FILTER_EN, 1014 + l2x0_base + L310_ADDR_FILTER_START); 1015 + } 1016 + } 1017 + 1018 + static const struct l2c_init_data of_l2c310_data __initconst = { 1019 + .type = "L2C-310", 1020 + .way_size_0 = SZ_8K, 1021 + .num_lock = 8, 1022 + .of_parse = l2c310_of_parse, 1023 + .enable = l2c310_enable, 1024 + .fixup = l2c310_fixup, 1025 + .save = l2c310_save, 1026 + .outer_cache = { 1027 + .inv_range = l2c210_inv_range, 1028 + .clean_range = l2c210_clean_range, 1029 + .flush_range = l2c210_flush_range, 1030 + .flush_all = l2c210_flush_all, 1031 + .disable = l2c310_disable, 1032 + .sync = l2c210_sync, 1033 + .resume = l2c310_resume, 1034 + }, 1035 + }; 462 1036 463 1037 /* 464 1038 * Note that the end addresses passed to Linux primitives are ··· 1166 524 } 1167 525 } 1168 526 527 + static void aurora_save(void __iomem *base) 528 + { 529 + l2x0_saved_regs.ctrl = readl_relaxed(base + L2X0_CTRL); 530 + l2x0_saved_regs.aux_ctrl = readl_relaxed(base + L2X0_AUX_CTRL); 531 + } 532 + 533 + static void aurora_resume(void) 534 + { 535 + void __iomem *base = l2x0_base; 536 + 537 + if (!(readl(base + L2X0_CTRL) & L2X0_CTRL_EN)) { 538 + writel_relaxed(l2x0_saved_regs.aux_ctrl, base + L2X0_AUX_CTRL); 539 + writel_relaxed(l2x0_saved_regs.ctrl, base + L2X0_CTRL); 540 + } 541 + } 542 + 543 + /* 544 + * For Aurora cache in no outer mode, enable via the CP15 coprocessor 545 + * broadcasting of cache commands to L2. 546 + */ 547 + static void __init aurora_enable_no_outer(void __iomem *base, u32 aux, 548 + unsigned num_lock) 549 + { 550 + u32 u; 551 + 552 + asm volatile("mrc p15, 1, %0, c15, c2, 0" : "=r" (u)); 553 + u |= AURORA_CTRL_FW; /* Set the FW bit */ 554 + asm volatile("mcr p15, 1, %0, c15, c2, 0" : : "r" (u)); 555 + 556 + isb(); 557 + 558 + l2c_enable(base, aux, num_lock); 559 + } 560 + 561 + static void __init aurora_fixup(void __iomem *base, u32 cache_id, 562 + struct outer_cache_fns *fns) 563 + { 564 + sync_reg_offset = AURORA_SYNC_REG; 565 + } 566 + 567 + static void __init aurora_of_parse(const struct device_node *np, 568 + u32 *aux_val, u32 *aux_mask) 569 + { 570 + u32 val = AURORA_ACR_REPLACEMENT_TYPE_SEMIPLRU; 571 + u32 mask = AURORA_ACR_REPLACEMENT_MASK; 572 + 573 + of_property_read_u32(np, "cache-id-part", 574 + &cache_id_part_number_from_dt); 575 + 576 + /* Determine and save the write policy */ 577 + l2_wt_override = of_property_read_bool(np, "wt-override"); 578 + 579 + if (l2_wt_override) { 580 + val |= AURORA_ACR_FORCE_WRITE_THRO_POLICY; 581 + mask |= AURORA_ACR_FORCE_WRITE_POLICY_MASK; 582 + } 583 + 584 + *aux_val &= ~mask; 585 + *aux_val |= val; 586 + *aux_mask &= ~mask; 587 + } 588 + 589 + static const struct l2c_init_data of_aurora_with_outer_data __initconst = { 590 + .type = "Aurora", 591 + .way_size_0 = SZ_4K, 592 + .num_lock = 4, 593 + .of_parse = aurora_of_parse, 594 + .enable = l2c_enable, 595 + .fixup = aurora_fixup, 596 + .save = aurora_save, 597 + .outer_cache = { 598 + .inv_range = aurora_inv_range, 599 + .clean_range = aurora_clean_range, 600 + .flush_range = aurora_flush_range, 601 + .flush_all = l2x0_flush_all, 602 + .disable = l2x0_disable, 603 + .sync = l2x0_cache_sync, 604 + .resume = aurora_resume, 605 + }, 606 + }; 607 + 608 + static const struct l2c_init_data of_aurora_no_outer_data __initconst = { 609 + .type = "Aurora", 610 + .way_size_0 = SZ_4K, 611 + .num_lock = 4, 612 + .of_parse = aurora_of_parse, 613 + .enable = aurora_enable_no_outer, 614 + .fixup = aurora_fixup, 615 + .save = aurora_save, 616 + .outer_cache = { 617 + .resume = aurora_resume, 618 + }, 619 + }; 620 + 1169 621 /* 1170 622 * For certain Broadcom SoCs, depending on the address range, different offsets 1171 623 * need to be added to the address before passing it to L2 for ··· 1324 588 1325 589 /* normal case, no cross section between start and end */ 1326 590 if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) { 1327 - l2x0_inv_range(new_start, new_end); 591 + l2c210_inv_range(new_start, new_end); 1328 592 return; 1329 593 } 1330 594 1331 595 /* They cross sections, so it can only be a cross from section 1332 596 * 2 to section 3 1333 597 */ 1334 - l2x0_inv_range(new_start, 598 + l2c210_inv_range(new_start, 1335 599 bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1)); 1336 - l2x0_inv_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 600 + l2c210_inv_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 1337 601 new_end); 1338 602 } 1339 603 ··· 1346 610 if (unlikely(end <= start)) 1347 611 return; 1348 612 1349 - if ((end - start) >= l2x0_size) { 1350 - l2x0_clean_all(); 1351 - return; 1352 - } 1353 - 1354 613 new_start = bcm_l2_phys_addr(start); 1355 614 new_end = bcm_l2_phys_addr(end); 1356 615 1357 616 /* normal case, no cross section between start and end */ 1358 617 if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) { 1359 - l2x0_clean_range(new_start, new_end); 618 + l2c210_clean_range(new_start, new_end); 1360 619 return; 1361 620 } 1362 621 1363 622 /* They cross sections, so it can only be a cross from section 1364 623 * 2 to section 3 1365 624 */ 1366 - l2x0_clean_range(new_start, 625 + l2c210_clean_range(new_start, 1367 626 bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1)); 1368 - l2x0_clean_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 627 + l2c210_clean_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 1369 628 new_end); 1370 629 } 1371 630 ··· 1374 643 return; 1375 644 1376 645 if ((end - start) >= l2x0_size) { 1377 - l2x0_flush_all(); 646 + outer_cache.flush_all(); 1378 647 return; 1379 648 } 1380 649 ··· 1383 652 1384 653 /* normal case, no cross section between start and end */ 1385 654 if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) { 1386 - l2x0_flush_range(new_start, new_end); 655 + l2c210_flush_range(new_start, new_end); 1387 656 return; 1388 657 } 1389 658 1390 659 /* They cross sections, so it can only be a cross from section 1391 660 * 2 to section 3 1392 661 */ 1393 - l2x0_flush_range(new_start, 662 + l2c210_flush_range(new_start, 1394 663 bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1)); 1395 - l2x0_flush_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 664 + l2c210_flush_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR), 1396 665 new_end); 1397 666 } 1398 667 1399 - static void __init l2x0_of_setup(const struct device_node *np, 1400 - u32 *aux_val, u32 *aux_mask) 668 + /* Broadcom L2C-310 start from ARMs R3P2 or later, and require no fixups */ 669 + static const struct l2c_init_data of_bcm_l2x0_data __initconst = { 670 + .type = "BCM-L2C-310", 671 + .way_size_0 = SZ_8K, 672 + .num_lock = 8, 673 + .of_parse = l2c310_of_parse, 674 + .enable = l2c310_enable, 675 + .save = l2c310_save, 676 + .outer_cache = { 677 + .inv_range = bcm_inv_range, 678 + .clean_range = bcm_clean_range, 679 + .flush_range = bcm_flush_range, 680 + .flush_all = l2c210_flush_all, 681 + .disable = l2c310_disable, 682 + .sync = l2c210_sync, 683 + .resume = l2c310_resume, 684 + }, 685 + }; 686 + 687 + static void __init tauros3_save(void __iomem *base) 1401 688 { 1402 - u32 data[2] = { 0, 0 }; 1403 - u32 tag = 0; 1404 - u32 dirty = 0; 1405 - u32 val = 0, mask = 0; 689 + l2c_save(base); 1406 690 1407 - of_property_read_u32(np, "arm,tag-latency", &tag); 1408 - if (tag) { 1409 - mask |= L2X0_AUX_CTRL_TAG_LATENCY_MASK; 1410 - val |= (tag - 1) << L2X0_AUX_CTRL_TAG_LATENCY_SHIFT; 1411 - } 1412 - 1413 - of_property_read_u32_array(np, "arm,data-latency", 1414 - data, ARRAY_SIZE(data)); 1415 - if (data[0] && data[1]) { 1416 - mask |= L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK | 1417 - L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK; 1418 - val |= ((data[0] - 1) << L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT) | 1419 - ((data[1] - 1) << L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT); 1420 - } 1421 - 1422 - of_property_read_u32(np, "arm,dirty-latency", &dirty); 1423 - if (dirty) { 1424 - mask |= L2X0_AUX_CTRL_DIRTY_LATENCY_MASK; 1425 - val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT; 1426 - } 1427 - 1428 - *aux_val &= ~mask; 1429 - *aux_val |= val; 1430 - *aux_mask &= ~mask; 1431 - } 1432 - 1433 - static void __init pl310_of_setup(const struct device_node *np, 1434 - u32 *aux_val, u32 *aux_mask) 1435 - { 1436 - u32 data[3] = { 0, 0, 0 }; 1437 - u32 tag[3] = { 0, 0, 0 }; 1438 - u32 filter[2] = { 0, 0 }; 1439 - 1440 - of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag)); 1441 - if (tag[0] && tag[1] && tag[2]) 1442 - writel_relaxed( 1443 - ((tag[0] - 1) << L2X0_LATENCY_CTRL_RD_SHIFT) | 1444 - ((tag[1] - 1) << L2X0_LATENCY_CTRL_WR_SHIFT) | 1445 - ((tag[2] - 1) << L2X0_LATENCY_CTRL_SETUP_SHIFT), 1446 - l2x0_base + L2X0_TAG_LATENCY_CTRL); 1447 - 1448 - of_property_read_u32_array(np, "arm,data-latency", 1449 - data, ARRAY_SIZE(data)); 1450 - if (data[0] && data[1] && data[2]) 1451 - writel_relaxed( 1452 - ((data[0] - 1) << L2X0_LATENCY_CTRL_RD_SHIFT) | 1453 - ((data[1] - 1) << L2X0_LATENCY_CTRL_WR_SHIFT) | 1454 - ((data[2] - 1) << L2X0_LATENCY_CTRL_SETUP_SHIFT), 1455 - l2x0_base + L2X0_DATA_LATENCY_CTRL); 1456 - 1457 - of_property_read_u32_array(np, "arm,filter-ranges", 1458 - filter, ARRAY_SIZE(filter)); 1459 - if (filter[1]) { 1460 - writel_relaxed(ALIGN(filter[0] + filter[1], SZ_1M), 1461 - l2x0_base + L2X0_ADDR_FILTER_END); 1462 - writel_relaxed((filter[0] & ~(SZ_1M - 1)) | L2X0_ADDR_FILTER_EN, 1463 - l2x0_base + L2X0_ADDR_FILTER_START); 1464 - } 1465 - } 1466 - 1467 - static void __init pl310_save(void) 1468 - { 1469 - u32 l2x0_revision = readl_relaxed(l2x0_base + L2X0_CACHE_ID) & 1470 - L2X0_CACHE_ID_RTL_MASK; 1471 - 1472 - l2x0_saved_regs.tag_latency = readl_relaxed(l2x0_base + 1473 - L2X0_TAG_LATENCY_CTRL); 1474 - l2x0_saved_regs.data_latency = readl_relaxed(l2x0_base + 1475 - L2X0_DATA_LATENCY_CTRL); 1476 - l2x0_saved_regs.filter_end = readl_relaxed(l2x0_base + 1477 - L2X0_ADDR_FILTER_END); 1478 - l2x0_saved_regs.filter_start = readl_relaxed(l2x0_base + 1479 - L2X0_ADDR_FILTER_START); 1480 - 1481 - if (l2x0_revision >= L2X0_CACHE_ID_RTL_R2P0) { 1482 - /* 1483 - * From r2p0, there is Prefetch offset/control register 1484 - */ 1485 - l2x0_saved_regs.prefetch_ctrl = readl_relaxed(l2x0_base + 1486 - L2X0_PREFETCH_CTRL); 1487 - /* 1488 - * From r3p0, there is Power control register 1489 - */ 1490 - if (l2x0_revision >= L2X0_CACHE_ID_RTL_R3P0) 1491 - l2x0_saved_regs.pwr_ctrl = readl_relaxed(l2x0_base + 1492 - L2X0_POWER_CTRL); 1493 - } 1494 - } 1495 - 1496 - static void aurora_save(void) 1497 - { 1498 - l2x0_saved_regs.ctrl = readl_relaxed(l2x0_base + L2X0_CTRL); 1499 - l2x0_saved_regs.aux_ctrl = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 1500 - } 1501 - 1502 - static void __init tauros3_save(void) 1503 - { 1504 691 l2x0_saved_regs.aux2_ctrl = 1505 - readl_relaxed(l2x0_base + TAUROS3_AUX2_CTRL); 692 + readl_relaxed(base + TAUROS3_AUX2_CTRL); 1506 693 l2x0_saved_regs.prefetch_ctrl = 1507 - readl_relaxed(l2x0_base + L2X0_PREFETCH_CTRL); 1508 - } 1509 - 1510 - static void l2x0_resume(void) 1511 - { 1512 - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 1513 - /* restore aux ctrl and enable l2 */ 1514 - l2x0_unlock(readl_relaxed(l2x0_base + L2X0_CACHE_ID)); 1515 - 1516 - writel_relaxed(l2x0_saved_regs.aux_ctrl, l2x0_base + 1517 - L2X0_AUX_CTRL); 1518 - 1519 - l2x0_inv_all(); 1520 - 1521 - writel_relaxed(L2X0_CTRL_EN, l2x0_base + L2X0_CTRL); 1522 - } 1523 - } 1524 - 1525 - static void pl310_resume(void) 1526 - { 1527 - u32 l2x0_revision; 1528 - 1529 - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 1530 - /* restore pl310 setup */ 1531 - writel_relaxed(l2x0_saved_regs.tag_latency, 1532 - l2x0_base + L2X0_TAG_LATENCY_CTRL); 1533 - writel_relaxed(l2x0_saved_regs.data_latency, 1534 - l2x0_base + L2X0_DATA_LATENCY_CTRL); 1535 - writel_relaxed(l2x0_saved_regs.filter_end, 1536 - l2x0_base + L2X0_ADDR_FILTER_END); 1537 - writel_relaxed(l2x0_saved_regs.filter_start, 1538 - l2x0_base + L2X0_ADDR_FILTER_START); 1539 - 1540 - l2x0_revision = readl_relaxed(l2x0_base + L2X0_CACHE_ID) & 1541 - L2X0_CACHE_ID_RTL_MASK; 1542 - 1543 - if (l2x0_revision >= L2X0_CACHE_ID_RTL_R2P0) { 1544 - writel_relaxed(l2x0_saved_regs.prefetch_ctrl, 1545 - l2x0_base + L2X0_PREFETCH_CTRL); 1546 - if (l2x0_revision >= L2X0_CACHE_ID_RTL_R3P0) 1547 - writel_relaxed(l2x0_saved_regs.pwr_ctrl, 1548 - l2x0_base + L2X0_POWER_CTRL); 1549 - } 1550 - } 1551 - 1552 - l2x0_resume(); 1553 - } 1554 - 1555 - static void aurora_resume(void) 1556 - { 1557 - if (!(readl(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 1558 - writel_relaxed(l2x0_saved_regs.aux_ctrl, 1559 - l2x0_base + L2X0_AUX_CTRL); 1560 - writel_relaxed(l2x0_saved_regs.ctrl, l2x0_base + L2X0_CTRL); 1561 - } 694 + readl_relaxed(base + L310_PREFETCH_CTRL); 1562 695 } 1563 696 1564 697 static void tauros3_resume(void) 1565 698 { 1566 - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 699 + void __iomem *base = l2x0_base; 700 + 701 + if (!(readl_relaxed(base + L2X0_CTRL) & L2X0_CTRL_EN)) { 1567 702 writel_relaxed(l2x0_saved_regs.aux2_ctrl, 1568 - l2x0_base + TAUROS3_AUX2_CTRL); 703 + base + TAUROS3_AUX2_CTRL); 1569 704 writel_relaxed(l2x0_saved_regs.prefetch_ctrl, 1570 - l2x0_base + L2X0_PREFETCH_CTRL); 705 + base + L310_PREFETCH_CTRL); 706 + 707 + l2c_enable(base, l2x0_saved_regs.aux_ctrl, 8); 1571 708 } 1572 - 1573 - l2x0_resume(); 1574 709 } 1575 710 1576 - static void __init aurora_broadcast_l2_commands(void) 1577 - { 1578 - __u32 u; 1579 - /* Enable Broadcasting of cache commands to L2*/ 1580 - __asm__ __volatile__("mrc p15, 1, %0, c15, c2, 0" : "=r"(u)); 1581 - u |= AURORA_CTRL_FW; /* Set the FW bit */ 1582 - __asm__ __volatile__("mcr p15, 1, %0, c15, c2, 0\n" : : "r"(u)); 1583 - isb(); 1584 - } 1585 - 1586 - static void __init aurora_of_setup(const struct device_node *np, 1587 - u32 *aux_val, u32 *aux_mask) 1588 - { 1589 - u32 val = AURORA_ACR_REPLACEMENT_TYPE_SEMIPLRU; 1590 - u32 mask = AURORA_ACR_REPLACEMENT_MASK; 1591 - 1592 - of_property_read_u32(np, "cache-id-part", 1593 - &cache_id_part_number_from_dt); 1594 - 1595 - /* Determine and save the write policy */ 1596 - l2_wt_override = of_property_read_bool(np, "wt-override"); 1597 - 1598 - if (l2_wt_override) { 1599 - val |= AURORA_ACR_FORCE_WRITE_THRO_POLICY; 1600 - mask |= AURORA_ACR_FORCE_WRITE_POLICY_MASK; 1601 - } 1602 - 1603 - *aux_val &= ~mask; 1604 - *aux_val |= val; 1605 - *aux_mask &= ~mask; 1606 - } 1607 - 1608 - static const struct l2x0_of_data pl310_data = { 1609 - .setup = pl310_of_setup, 1610 - .save = pl310_save, 1611 - .outer_cache = { 1612 - .resume = pl310_resume, 1613 - .inv_range = l2x0_inv_range, 1614 - .clean_range = l2x0_clean_range, 1615 - .flush_range = l2x0_flush_range, 1616 - .sync = l2x0_cache_sync, 1617 - .flush_all = l2x0_flush_all, 1618 - .inv_all = l2x0_inv_all, 1619 - .disable = l2x0_disable, 1620 - }, 1621 - }; 1622 - 1623 - static const struct l2x0_of_data l2x0_data = { 1624 - .setup = l2x0_of_setup, 1625 - .save = NULL, 1626 - .outer_cache = { 1627 - .resume = l2x0_resume, 1628 - .inv_range = l2x0_inv_range, 1629 - .clean_range = l2x0_clean_range, 1630 - .flush_range = l2x0_flush_range, 1631 - .sync = l2x0_cache_sync, 1632 - .flush_all = l2x0_flush_all, 1633 - .inv_all = l2x0_inv_all, 1634 - .disable = l2x0_disable, 1635 - }, 1636 - }; 1637 - 1638 - static const struct l2x0_of_data aurora_with_outer_data = { 1639 - .setup = aurora_of_setup, 1640 - .save = aurora_save, 1641 - .outer_cache = { 1642 - .resume = aurora_resume, 1643 - .inv_range = aurora_inv_range, 1644 - .clean_range = aurora_clean_range, 1645 - .flush_range = aurora_flush_range, 1646 - .sync = l2x0_cache_sync, 1647 - .flush_all = l2x0_flush_all, 1648 - .inv_all = l2x0_inv_all, 1649 - .disable = l2x0_disable, 1650 - }, 1651 - }; 1652 - 1653 - static const struct l2x0_of_data aurora_no_outer_data = { 1654 - .setup = aurora_of_setup, 1655 - .save = aurora_save, 1656 - .outer_cache = { 1657 - .resume = aurora_resume, 1658 - }, 1659 - }; 1660 - 1661 - static const struct l2x0_of_data tauros3_data = { 1662 - .setup = NULL, 711 + static const struct l2c_init_data of_tauros3_data __initconst = { 712 + .type = "Tauros3", 713 + .way_size_0 = SZ_8K, 714 + .num_lock = 8, 715 + .enable = l2c_enable, 1663 716 .save = tauros3_save, 1664 717 /* Tauros3 broadcasts L1 cache operations to L2 */ 1665 718 .outer_cache = { ··· 1451 936 }, 1452 937 }; 1453 938 1454 - static const struct l2x0_of_data bcm_l2x0_data = { 1455 - .setup = pl310_of_setup, 1456 - .save = pl310_save, 1457 - .outer_cache = { 1458 - .resume = pl310_resume, 1459 - .inv_range = bcm_inv_range, 1460 - .clean_range = bcm_clean_range, 1461 - .flush_range = bcm_flush_range, 1462 - .sync = l2x0_cache_sync, 1463 - .flush_all = l2x0_flush_all, 1464 - .inv_all = l2x0_inv_all, 1465 - .disable = l2x0_disable, 1466 - }, 1467 - }; 1468 - 939 + #define L2C_ID(name, fns) { .compatible = name, .data = (void *)&fns } 1469 940 static const struct of_device_id l2x0_ids[] __initconst = { 1470 - { .compatible = "arm,l210-cache", .data = (void *)&l2x0_data }, 1471 - { .compatible = "arm,l220-cache", .data = (void *)&l2x0_data }, 1472 - { .compatible = "arm,pl310-cache", .data = (void *)&pl310_data }, 1473 - { .compatible = "bcm,bcm11351-a2-pl310-cache", /* deprecated name */ 1474 - .data = (void *)&bcm_l2x0_data}, 1475 - { .compatible = "brcm,bcm11351-a2-pl310-cache", 1476 - .data = (void *)&bcm_l2x0_data}, 1477 - { .compatible = "marvell,aurora-outer-cache", 1478 - .data = (void *)&aurora_with_outer_data}, 1479 - { .compatible = "marvell,aurora-system-cache", 1480 - .data = (void *)&aurora_no_outer_data}, 1481 - { .compatible = "marvell,tauros3-cache", 1482 - .data = (void *)&tauros3_data }, 941 + L2C_ID("arm,l210-cache", of_l2c210_data), 942 + L2C_ID("arm,l220-cache", of_l2c220_data), 943 + L2C_ID("arm,pl310-cache", of_l2c310_data), 944 + L2C_ID("brcm,bcm11351-a2-pl310-cache", of_bcm_l2x0_data), 945 + L2C_ID("marvell,aurora-outer-cache", of_aurora_with_outer_data), 946 + L2C_ID("marvell,aurora-system-cache", of_aurora_no_outer_data), 947 + L2C_ID("marvell,tauros3-cache", of_tauros3_data), 948 + /* Deprecated IDs */ 949 + L2C_ID("bcm,bcm11351-a2-pl310-cache", of_bcm_l2x0_data), 1483 950 {} 1484 951 }; 1485 952 1486 953 int __init l2x0_of_init(u32 aux_val, u32 aux_mask) 1487 954 { 955 + const struct l2c_init_data *data; 1488 956 struct device_node *np; 1489 - const struct l2x0_of_data *data; 1490 957 struct resource res; 958 + u32 cache_id, old_aux; 1491 959 1492 960 np = of_find_matching_node(NULL, l2x0_ids); 1493 961 if (!np) ··· 1487 989 1488 990 data = of_match_node(l2x0_ids, np)->data; 1489 991 1490 - /* L2 configuration can only be changed if the cache is disabled */ 1491 - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) { 1492 - if (data->setup) 1493 - data->setup(np, &aux_val, &aux_mask); 1494 - 1495 - /* For aurora cache in no outer mode select the 1496 - * correct mode using the coprocessor*/ 1497 - if (data == &aurora_no_outer_data) 1498 - aurora_broadcast_l2_commands(); 992 + old_aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 993 + if (old_aux != ((old_aux & aux_mask) | aux_val)) { 994 + pr_warn("L2C: platform modifies aux control register: 0x%08x -> 0x%08x\n", 995 + old_aux, (old_aux & aux_mask) | aux_val); 996 + } else if (aux_mask != ~0U && aux_val != 0) { 997 + pr_alert("L2C: platform provided aux values match the hardware, so have no effect. Please remove them.\n"); 1499 998 } 1500 999 1501 - if (data->save) 1502 - data->save(); 1000 + /* All L2 caches are unified, so this property should be specified */ 1001 + if (!of_property_read_bool(np, "cache-unified")) 1002 + pr_err("L2C: device tree omits to specify unified cache\n"); 1503 1003 1504 - of_init = true; 1505 - memcpy(&outer_cache, &data->outer_cache, sizeof(outer_cache)); 1506 - l2x0_init(l2x0_base, aux_val, aux_mask); 1004 + /* L2 configuration can only be changed if the cache is disabled */ 1005 + if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) 1006 + if (data->of_parse) 1007 + data->of_parse(np, &aux_val, &aux_mask); 1008 + 1009 + if (cache_id_part_number_from_dt) 1010 + cache_id = cache_id_part_number_from_dt; 1011 + else 1012 + cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID); 1013 + 1014 + __l2c_init(data, aux_val, aux_mask, cache_id); 1507 1015 1508 1016 return 0; 1509 1017 }
+6 -6
arch/arm/mm/cache-v7.S
··· 59 59 bgt 2b 60 60 cmp r2, #0 61 61 bgt 1b 62 - dsb 62 + dsb st 63 63 isb 64 64 mov pc, lr 65 65 ENDPROC(v7_invalidate_l1) ··· 166 166 finished: 167 167 mov r10, #0 @ swith back to cache level 0 168 168 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr 169 - dsb 169 + dsb st 170 170 isb 171 171 mov pc, lr 172 172 ENDPROC(v7_flush_dcache_all) ··· 335 335 add r0, r0, r2 336 336 cmp r0, r1 337 337 blo 1b 338 - dsb 338 + dsb st 339 339 mov pc, lr 340 340 ENDPROC(v7_flush_kern_dcache_area) 341 341 ··· 368 368 add r0, r0, r2 369 369 cmp r0, r1 370 370 blo 1b 371 - dsb 371 + dsb st 372 372 mov pc, lr 373 373 ENDPROC(v7_dma_inv_range) 374 374 ··· 390 390 add r0, r0, r2 391 391 cmp r0, r1 392 392 blo 1b 393 - dsb 393 + dsb st 394 394 mov pc, lr 395 395 ENDPROC(v7_dma_clean_range) 396 396 ··· 412 412 add r0, r0, r2 413 413 cmp r0, r1 414 414 blo 1b 415 - dsb 415 + dsb st 416 416 mov pc, lr 417 417 ENDPROC(v7_dma_flush_range) 418 418
+6 -5
arch/arm/mm/dma-mapping.c
··· 885 885 static void __dma_page_cpu_to_dev(struct page *page, unsigned long off, 886 886 size_t size, enum dma_data_direction dir) 887 887 { 888 - unsigned long paddr; 888 + phys_addr_t paddr; 889 889 890 890 dma_cache_maint_page(page, off, size, dir, dmac_map_area); 891 891 ··· 901 901 static void __dma_page_dev_to_cpu(struct page *page, unsigned long off, 902 902 size_t size, enum dma_data_direction dir) 903 903 { 904 - unsigned long paddr = page_to_phys(page) + off; 904 + phys_addr_t paddr = page_to_phys(page) + off; 905 905 906 906 /* FIXME: non-speculating: not required */ 907 - /* don't bother invalidating if DMA to device */ 908 - if (dir != DMA_TO_DEVICE) 907 + /* in any case, don't bother invalidating if DMA to device */ 908 + if (dir != DMA_TO_DEVICE) { 909 909 outer_inv_range(paddr, paddr + size); 910 910 911 - dma_cache_maint_page(page, off, size, dir, dmac_unmap_area); 911 + dma_cache_maint_page(page, off, size, dir, dmac_unmap_area); 912 + } 912 913 913 914 /* 914 915 * Mark the D-cache clean for these pages to avoid extra flushing.
+28 -5
arch/arm/mm/flush.c
··· 104 104 #define flush_icache_alias(pfn,vaddr,len) do { } while (0) 105 105 #endif 106 106 107 + #define FLAG_PA_IS_EXEC 1 108 + #define FLAG_PA_CORE_IN_MM 2 109 + 107 110 static void flush_ptrace_access_other(void *args) 108 111 { 109 112 __flush_icache_all(); 110 113 } 111 114 112 - static 113 - void flush_ptrace_access(struct vm_area_struct *vma, struct page *page, 114 - unsigned long uaddr, void *kaddr, unsigned long len) 115 + static inline 116 + void __flush_ptrace_access(struct page *page, unsigned long uaddr, void *kaddr, 117 + unsigned long len, unsigned int flags) 115 118 { 116 119 if (cache_is_vivt()) { 117 - if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) { 120 + if (flags & FLAG_PA_CORE_IN_MM) { 118 121 unsigned long addr = (unsigned long)kaddr; 119 122 __cpuc_coherent_kern_range(addr, addr + len); 120 123 } ··· 131 128 } 132 129 133 130 /* VIPT non-aliasing D-cache */ 134 - if (vma->vm_flags & VM_EXEC) { 131 + if (flags & FLAG_PA_IS_EXEC) { 135 132 unsigned long addr = (unsigned long)kaddr; 136 133 if (icache_is_vipt_aliasing()) 137 134 flush_icache_alias(page_to_pfn(page), uaddr, len); ··· 141 138 smp_call_function(flush_ptrace_access_other, 142 139 NULL, 1); 143 140 } 141 + } 142 + 143 + static 144 + void flush_ptrace_access(struct vm_area_struct *vma, struct page *page, 145 + unsigned long uaddr, void *kaddr, unsigned long len) 146 + { 147 + unsigned int flags = 0; 148 + if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) 149 + flags |= FLAG_PA_CORE_IN_MM; 150 + if (vma->vm_flags & VM_EXEC) 151 + flags |= FLAG_PA_IS_EXEC; 152 + __flush_ptrace_access(page, uaddr, kaddr, len, flags); 153 + } 154 + 155 + void flush_uprobe_xol_access(struct page *page, unsigned long uaddr, 156 + void *kaddr, unsigned long len) 157 + { 158 + unsigned int flags = FLAG_PA_CORE_IN_MM|FLAG_PA_IS_EXEC; 159 + 160 + __flush_ptrace_access(page, uaddr, kaddr, len, flags); 144 161 } 145 162 146 163 /*
+24 -9
arch/arm/mm/highmem.c
··· 18 18 #include <asm/tlbflush.h> 19 19 #include "mm.h" 20 20 21 + pte_t *fixmap_page_table; 22 + 23 + static inline void set_fixmap_pte(int idx, pte_t pte) 24 + { 25 + unsigned long vaddr = __fix_to_virt(idx); 26 + set_pte_ext(fixmap_page_table + idx, pte, 0); 27 + local_flush_tlb_kernel_page(vaddr); 28 + } 29 + 30 + static inline pte_t get_fixmap_pte(unsigned long vaddr) 31 + { 32 + unsigned long idx = __virt_to_fix(vaddr); 33 + return *(fixmap_page_table + idx); 34 + } 35 + 21 36 void *kmap(struct page *page) 22 37 { 23 38 might_sleep(); ··· 78 63 type = kmap_atomic_idx_push(); 79 64 80 65 idx = type + KM_TYPE_NR * smp_processor_id(); 81 - vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 66 + vaddr = __fix_to_virt(idx); 82 67 #ifdef CONFIG_DEBUG_HIGHMEM 83 68 /* 84 69 * With debugging enabled, kunmap_atomic forces that entry to 0. 85 70 * Make sure it was indeed properly unmapped. 86 71 */ 87 - BUG_ON(!pte_none(get_top_pte(vaddr))); 72 + BUG_ON(!pte_none(*(fixmap_page_table + idx))); 88 73 #endif 89 74 /* 90 75 * When debugging is off, kunmap_atomic leaves the previous mapping 91 76 * in place, so the contained TLB flush ensures the TLB is updated 92 77 * with the new mapping. 93 78 */ 94 - set_top_pte(vaddr, mk_pte(page, kmap_prot)); 79 + set_fixmap_pte(idx, mk_pte(page, kmap_prot)); 95 80 96 81 return (void *)vaddr; 97 82 } ··· 109 94 if (cache_is_vivt()) 110 95 __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE); 111 96 #ifdef CONFIG_DEBUG_HIGHMEM 112 - BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 113 - set_top_pte(vaddr, __pte(0)); 97 + BUG_ON(vaddr != __fix_to_virt(idx)); 98 + set_fixmap_pte(idx, __pte(0)); 114 99 #else 115 100 (void) idx; /* to kill a warning */ 116 101 #endif ··· 132 117 133 118 type = kmap_atomic_idx_push(); 134 119 idx = type + KM_TYPE_NR * smp_processor_id(); 135 - vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 120 + vaddr = __fix_to_virt(idx); 136 121 #ifdef CONFIG_DEBUG_HIGHMEM 137 - BUG_ON(!pte_none(get_top_pte(vaddr))); 122 + BUG_ON(!pte_none(*(fixmap_page_table + idx))); 138 123 #endif 139 - set_top_pte(vaddr, pfn_pte(pfn, kmap_prot)); 124 + set_fixmap_pte(idx, pfn_pte(pfn, kmap_prot)); 140 125 141 126 return (void *)vaddr; 142 127 } ··· 148 133 if (vaddr < FIXADDR_START) 149 134 return virt_to_page(ptr); 150 135 151 - return pte_page(get_top_pte(vaddr)); 136 + return pte_page(get_fixmap_pte(vaddr)); 152 137 }
+37 -44
arch/arm/mm/init.c
··· 23 23 #include <linux/dma-contiguous.h> 24 24 #include <linux/sizes.h> 25 25 26 + #include <asm/cp15.h> 26 27 #include <asm/mach-types.h> 27 28 #include <asm/memblock.h> 28 29 #include <asm/prom.h> ··· 36 35 #include <asm/mach/map.h> 37 36 38 37 #include "mm.h" 38 + 39 + #ifdef CONFIG_CPU_CP15_MMU 40 + unsigned long __init __clear_cr(unsigned long mask) 41 + { 42 + cr_alignment = cr_alignment & ~mask; 43 + return cr_alignment; 44 + } 45 + #endif 39 46 40 47 static phys_addr_t phys_initrd_start __initdata = 0; 41 48 static unsigned long phys_initrd_size __initdata = 0; ··· 90 81 * initialization functions, as well as show_mem() for the skipping 91 82 * of holes in the memory map. It is populated by arm_add_memory(). 92 83 */ 93 - struct meminfo meminfo; 94 - 95 84 void show_mem(unsigned int filter) 96 85 { 97 86 int free = 0, total = 0, reserved = 0; 98 - int shared = 0, cached = 0, slab = 0, i; 99 - struct meminfo * mi = &meminfo; 87 + int shared = 0, cached = 0, slab = 0; 88 + struct memblock_region *reg; 100 89 101 90 printk("Mem-info:\n"); 102 91 show_free_areas(filter); 103 92 104 - for_each_bank (i, mi) { 105 - struct membank *bank = &mi->bank[i]; 93 + for_each_memblock (memory, reg) { 106 94 unsigned int pfn1, pfn2; 107 95 struct page *page, *end; 108 96 109 - pfn1 = bank_pfn_start(bank); 110 - pfn2 = bank_pfn_end(bank); 97 + pfn1 = memblock_region_memory_base_pfn(reg); 98 + pfn2 = memblock_region_memory_end_pfn(reg); 111 99 112 100 page = pfn_to_page(pfn1); 113 101 end = pfn_to_page(pfn2 - 1) + 1; ··· 121 115 free++; 122 116 else 123 117 shared += page_count(page) - 1; 124 - page++; 125 - } while (page < end); 118 + pfn1++; 119 + page = pfn_to_page(pfn1); 120 + } while (pfn1 < pfn2); 126 121 } 127 122 128 123 printk("%d pages of RAM\n", total); ··· 137 130 static void __init find_limits(unsigned long *min, unsigned long *max_low, 138 131 unsigned long *max_high) 139 132 { 140 - struct meminfo *mi = &meminfo; 141 - int i; 142 - 143 - /* This assumes the meminfo array is properly sorted */ 144 - *min = bank_pfn_start(&mi->bank[0]); 145 - for_each_bank (i, mi) 146 - if (mi->bank[i].highmem) 147 - break; 148 - *max_low = bank_pfn_end(&mi->bank[i - 1]); 149 - *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]); 133 + *max_low = PFN_DOWN(memblock_get_current_limit()); 134 + *min = PFN_UP(memblock_start_of_DRAM()); 135 + *max_high = PFN_DOWN(memblock_end_of_DRAM()); 150 136 } 151 137 152 138 #ifdef CONFIG_ZONE_DMA ··· 274 274 return phys; 275 275 } 276 276 277 - void __init arm_memblock_init(struct meminfo *mi, 278 - const struct machine_desc *mdesc) 277 + void __init arm_memblock_init(const struct machine_desc *mdesc) 279 278 { 280 - int i; 281 - 282 - for (i = 0; i < mi->nr_banks; i++) 283 - memblock_add(mi->bank[i].start, mi->bank[i].size); 284 - 285 279 /* Register the kernel text, kernel data and initrd with memblock. */ 286 280 #ifdef CONFIG_XIP_KERNEL 287 281 memblock_reserve(__pa(_sdata), _end - _sdata); ··· 406 412 /* 407 413 * The mem_map array can get very big. Free the unused area of the memory map. 408 414 */ 409 - static void __init free_unused_memmap(struct meminfo *mi) 415 + static void __init free_unused_memmap(void) 410 416 { 411 - unsigned long bank_start, prev_bank_end = 0; 412 - unsigned int i; 417 + unsigned long start, prev_end = 0; 418 + struct memblock_region *reg; 413 419 414 420 /* 415 421 * This relies on each bank being in address order. 416 422 * The banks are sorted previously in bootmem_init(). 417 423 */ 418 - for_each_bank(i, mi) { 419 - struct membank *bank = &mi->bank[i]; 420 - 421 - bank_start = bank_pfn_start(bank); 424 + for_each_memblock(memory, reg) { 425 + start = memblock_region_memory_base_pfn(reg); 422 426 423 427 #ifdef CONFIG_SPARSEMEM 424 428 /* 425 429 * Take care not to free memmap entries that don't exist 426 430 * due to SPARSEMEM sections which aren't present. 427 431 */ 428 - bank_start = min(bank_start, 429 - ALIGN(prev_bank_end, PAGES_PER_SECTION)); 432 + start = min(start, 433 + ALIGN(prev_end, PAGES_PER_SECTION)); 430 434 #else 431 435 /* 432 436 * Align down here since the VM subsystem insists that the 433 437 * memmap entries are valid from the bank start aligned to 434 438 * MAX_ORDER_NR_PAGES. 435 439 */ 436 - bank_start = round_down(bank_start, MAX_ORDER_NR_PAGES); 440 + start = round_down(start, MAX_ORDER_NR_PAGES); 437 441 #endif 438 442 /* 439 443 * If we had a previous bank, and there is a space 440 444 * between the current bank and the previous, free it. 441 445 */ 442 - if (prev_bank_end && prev_bank_end < bank_start) 443 - free_memmap(prev_bank_end, bank_start); 446 + if (prev_end && prev_end < start) 447 + free_memmap(prev_end, start); 444 448 445 449 /* 446 450 * Align up here since the VM subsystem insists that the 447 451 * memmap entries are valid from the bank end aligned to 448 452 * MAX_ORDER_NR_PAGES. 449 453 */ 450 - prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES); 454 + prev_end = ALIGN(memblock_region_memory_end_pfn(reg), 455 + MAX_ORDER_NR_PAGES); 451 456 } 452 457 453 458 #ifdef CONFIG_SPARSEMEM 454 - if (!IS_ALIGNED(prev_bank_end, PAGES_PER_SECTION)) 455 - free_memmap(prev_bank_end, 456 - ALIGN(prev_bank_end, PAGES_PER_SECTION)); 459 + if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION)) 460 + free_memmap(prev_end, 461 + ALIGN(prev_end, PAGES_PER_SECTION)); 457 462 #endif 458 463 } 459 464 ··· 528 535 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 529 536 530 537 /* this will put all unused low memory onto the freelists */ 531 - free_unused_memmap(&meminfo); 538 + free_unused_memmap(); 532 539 free_all_bootmem(); 533 540 534 541 #ifdef CONFIG_SA1111
+8 -1
arch/arm/mm/ioremap.c
··· 438 438 EXPORT_SYMBOL(__arm_iounmap); 439 439 440 440 #ifdef CONFIG_PCI 441 + static int pci_ioremap_mem_type = MT_DEVICE; 442 + 443 + void pci_ioremap_set_mem_type(int mem_type) 444 + { 445 + pci_ioremap_mem_type = mem_type; 446 + } 447 + 441 448 int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) 442 449 { 443 450 BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT); ··· 452 445 return ioremap_page_range(PCI_IO_VIRT_BASE + offset, 453 446 PCI_IO_VIRT_BASE + offset + SZ_64K, 454 447 phys_addr, 455 - __pgprot(get_mem_type(MT_DEVICE)->prot_pte)); 448 + __pgprot(get_mem_type(pci_ioremap_mem_type)->prot_pte)); 456 449 } 457 450 EXPORT_SYMBOL_GPL(pci_ioremap_io); 458 451 #endif
+20
arch/arm/mm/l2c-common.c
··· 1 + /* 2 + * Copyright (C) 2010 ARM Ltd. 3 + * Written by Catalin Marinas <catalin.marinas@arm.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + #include <linux/bug.h> 10 + #include <linux/smp.h> 11 + #include <asm/outercache.h> 12 + 13 + void outer_disable(void) 14 + { 15 + WARN_ON(!irqs_disabled()); 16 + WARN_ON(num_online_cpus() > 1); 17 + 18 + if (outer_cache.disable) 19 + outer_cache.disable(); 20 + }
+58
arch/arm/mm/l2c-l2x0-resume.S
··· 1 + /* 2 + * L2C-310 early resume code. This can be used by platforms to restore 3 + * the settings of their L2 cache controller before restoring the 4 + * processor state. 5 + * 6 + * This code can only be used to if you are running in the secure world. 7 + */ 8 + #include <linux/linkage.h> 9 + #include <asm/hardware/cache-l2x0.h> 10 + 11 + .text 12 + 13 + ENTRY(l2c310_early_resume) 14 + adr r0, 1f 15 + ldr r2, [r0] 16 + add r0, r2, r0 17 + 18 + ldmia r0, {r1, r2, r3, r4, r5, r6, r7, r8} 19 + @ r1 = phys address of L2C-310 controller 20 + @ r2 = aux_ctrl 21 + @ r3 = tag_latency 22 + @ r4 = data_latency 23 + @ r5 = filter_start 24 + @ r6 = filter_end 25 + @ r7 = prefetch_ctrl 26 + @ r8 = pwr_ctrl 27 + 28 + @ Check that the address has been initialised 29 + teq r1, #0 30 + moveq pc, lr 31 + 32 + @ The prefetch and power control registers are revision dependent 33 + @ and can be written whether or not the L2 cache is enabled 34 + ldr r0, [r1, #L2X0_CACHE_ID] 35 + and r0, r0, #L2X0_CACHE_ID_RTL_MASK 36 + cmp r0, #L310_CACHE_ID_RTL_R2P0 37 + strcs r7, [r1, #L310_PREFETCH_CTRL] 38 + cmp r0, #L310_CACHE_ID_RTL_R3P0 39 + strcs r8, [r1, #L310_POWER_CTRL] 40 + 41 + @ Don't setup the L2 cache if it is already enabled 42 + ldr r0, [r1, #L2X0_CTRL] 43 + tst r0, #L2X0_CTRL_EN 44 + movne pc, lr 45 + 46 + str r3, [r1, #L310_TAG_LATENCY_CTRL] 47 + str r4, [r1, #L310_DATA_LATENCY_CTRL] 48 + str r6, [r1, #L310_ADDR_FILTER_END] 49 + str r5, [r1, #L310_ADDR_FILTER_START] 50 + 51 + str r2, [r1, #L2X0_AUX_CTRL] 52 + mov r9, #L2X0_CTRL_EN 53 + str r9, [r1, #L2X0_CTRL] 54 + mov pc, lr 55 + ENDPROC(l2c310_early_resume) 56 + 57 + .align 58 + 1: .long l2x0_saved_regs - .
+4
arch/arm/mm/mm.h
··· 2 2 #include <linux/list.h> 3 3 #include <linux/vmalloc.h> 4 4 5 + #include <asm/pgtable.h> 6 + 5 7 /* the upper-most page table pointer */ 6 8 extern pmd_t *top_pmd; 7 9 ··· 95 93 void __init bootmem_init(void); 96 94 void arm_mm_memblock_reserve(void); 97 95 void dma_contiguous_remap(void); 96 + 97 + unsigned long __clear_cr(unsigned long mask);
+105 -135
arch/arm/mm/mmu.c
··· 35 35 #include <asm/mach/arch.h> 36 36 #include <asm/mach/map.h> 37 37 #include <asm/mach/pci.h> 38 + #include <asm/fixmap.h> 38 39 39 40 #include "mm.h" 40 41 #include "tcm.h" ··· 118 117 }; 119 118 120 119 #ifdef CONFIG_CPU_CP15 120 + static unsigned long initial_pmd_value __initdata = 0; 121 + 121 122 /* 122 - * These are useful for identifying cache coherency 123 - * problems by allowing the cache or the cache and 124 - * writebuffer to be turned off. (Note: the write 125 - * buffer should not be on and the cache off). 123 + * Initialise the cache_policy variable with the initial state specified 124 + * via the "pmd" value. This is used to ensure that on ARMv6 and later, 125 + * the C code sets the page tables up with the same policy as the head 126 + * assembly code, which avoids an illegal state where the TLBs can get 127 + * confused. See comments in early_cachepolicy() for more information. 128 + */ 129 + void __init init_default_cache_policy(unsigned long pmd) 130 + { 131 + int i; 132 + 133 + initial_pmd_value = pmd; 134 + 135 + pmd &= PMD_SECT_TEX(1) | PMD_SECT_BUFFERABLE | PMD_SECT_CACHEABLE; 136 + 137 + for (i = 0; i < ARRAY_SIZE(cache_policies); i++) 138 + if (cache_policies[i].pmd == pmd) { 139 + cachepolicy = i; 140 + break; 141 + } 142 + 143 + if (i == ARRAY_SIZE(cache_policies)) 144 + pr_err("ERROR: could not find cache policy\n"); 145 + } 146 + 147 + /* 148 + * These are useful for identifying cache coherency problems by allowing 149 + * the cache or the cache and writebuffer to be turned off. (Note: the 150 + * write buffer should not be on and the cache off). 126 151 */ 127 152 static int __init early_cachepolicy(char *p) 128 153 { 129 - int i; 154 + int i, selected = -1; 130 155 131 156 for (i = 0; i < ARRAY_SIZE(cache_policies); i++) { 132 157 int len = strlen(cache_policies[i].policy); 133 158 134 159 if (memcmp(p, cache_policies[i].policy, len) == 0) { 135 - cachepolicy = i; 136 - cr_alignment &= ~cache_policies[i].cr_mask; 137 - cr_no_alignment &= ~cache_policies[i].cr_mask; 160 + selected = i; 138 161 break; 139 162 } 140 163 } 141 - if (i == ARRAY_SIZE(cache_policies)) 142 - printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n"); 164 + 165 + if (selected == -1) 166 + pr_err("ERROR: unknown or unsupported cache policy\n"); 167 + 143 168 /* 144 169 * This restriction is partly to do with the way we boot; it is 145 170 * unpredictable to have memory mapped using two different sets of ··· 173 146 * change these attributes once the initial assembly has setup the 174 147 * page tables. 175 148 */ 176 - if (cpu_architecture() >= CPU_ARCH_ARMv6) { 177 - printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n"); 178 - cachepolicy = CPOLICY_WRITEBACK; 149 + if (cpu_architecture() >= CPU_ARCH_ARMv6 && selected != cachepolicy) { 150 + pr_warn("Only cachepolicy=%s supported on ARMv6 and later\n", 151 + cache_policies[cachepolicy].policy); 152 + return 0; 179 153 } 180 - flush_cache_all(); 181 - set_cr(cr_alignment); 154 + 155 + if (selected != cachepolicy) { 156 + unsigned long cr = __clear_cr(cache_policies[selected].cr_mask); 157 + cachepolicy = selected; 158 + flush_cache_all(); 159 + set_cr(cr); 160 + } 182 161 return 0; 183 162 } 184 163 early_param("cachepolicy", early_cachepolicy); ··· 217 184 return 0; 218 185 } 219 186 early_param("ecc", early_ecc); 220 - #endif 221 - 222 - static int __init noalign_setup(char *__unused) 223 - { 224 - cr_alignment &= ~CR_A; 225 - cr_no_alignment &= ~CR_A; 226 - set_cr(cr_alignment); 227 - return 1; 228 - } 229 - __setup("noalign", noalign_setup); 230 - 231 - #ifndef CONFIG_SMP 232 - void adjust_cr(unsigned long mask, unsigned long set) 233 - { 234 - unsigned long flags; 235 - 236 - mask &= ~CR_A; 237 - 238 - set &= mask; 239 - 240 - local_irq_save(flags); 241 - 242 - cr_no_alignment = (cr_no_alignment & ~mask) | set; 243 - cr_alignment = (cr_alignment & ~mask) | set; 244 - 245 - set_cr((get_cr() & ~mask) | set); 246 - 247 - local_irq_restore(flags); 248 - } 249 187 #endif 250 188 251 189 #else /* ifdef CONFIG_CPU_CP15 */ ··· 418 414 cachepolicy = CPOLICY_WRITEBACK; 419 415 ecc_mask = 0; 420 416 } 421 - if (is_smp()) 422 - cachepolicy = CPOLICY_WRITEALLOC; 417 + 418 + if (is_smp()) { 419 + if (cachepolicy != CPOLICY_WRITEALLOC) { 420 + pr_warn("Forcing write-allocate cache policy for SMP\n"); 421 + cachepolicy = CPOLICY_WRITEALLOC; 422 + } 423 + if (!(initial_pmd_value & PMD_SECT_S)) { 424 + pr_warn("Forcing shared mappings for SMP\n"); 425 + initial_pmd_value |= PMD_SECT_S; 426 + } 427 + } 423 428 424 429 /* 425 430 * Strip out features not present on earlier architectures. ··· 552 539 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 553 540 #endif 554 541 555 - if (is_smp()) { 556 - /* 557 - * Mark memory with the "shared" attribute 558 - * for SMP systems 559 - */ 542 + /* 543 + * If the initial page tables were created with the S bit 544 + * set, then we need to do the same here for the same 545 + * reasons given in early_cachepolicy(). 546 + */ 547 + if (initial_pmd_value & PMD_SECT_S) { 560 548 user_pgprot |= L_PTE_SHARED; 561 549 kern_pgprot |= L_PTE_SHARED; 562 550 vecs_pgprot |= L_PTE_SHARED; ··· 1075 1061 void __init sanity_check_meminfo(void) 1076 1062 { 1077 1063 phys_addr_t memblock_limit = 0; 1078 - int i, j, highmem = 0; 1064 + int highmem = 0; 1079 1065 phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1; 1066 + struct memblock_region *reg; 1080 1067 1081 - for (i = 0, j = 0; i < meminfo.nr_banks; i++) { 1082 - struct membank *bank = &meminfo.bank[j]; 1083 - phys_addr_t size_limit; 1068 + for_each_memblock(memory, reg) { 1069 + phys_addr_t block_start = reg->base; 1070 + phys_addr_t block_end = reg->base + reg->size; 1071 + phys_addr_t size_limit = reg->size; 1084 1072 1085 - *bank = meminfo.bank[i]; 1086 - size_limit = bank->size; 1087 - 1088 - if (bank->start >= vmalloc_limit) 1073 + if (reg->base >= vmalloc_limit) 1089 1074 highmem = 1; 1090 1075 else 1091 - size_limit = vmalloc_limit - bank->start; 1076 + size_limit = vmalloc_limit - reg->base; 1092 1077 1093 - bank->highmem = highmem; 1094 1078 1095 - #ifdef CONFIG_HIGHMEM 1096 - /* 1097 - * Split those memory banks which are partially overlapping 1098 - * the vmalloc area greatly simplifying things later. 1099 - */ 1100 - if (!highmem && bank->size > size_limit) { 1101 - if (meminfo.nr_banks >= NR_BANKS) { 1102 - printk(KERN_CRIT "NR_BANKS too low, " 1103 - "ignoring high memory\n"); 1104 - } else { 1105 - memmove(bank + 1, bank, 1106 - (meminfo.nr_banks - i) * sizeof(*bank)); 1107 - meminfo.nr_banks++; 1108 - i++; 1109 - bank[1].size -= size_limit; 1110 - bank[1].start = vmalloc_limit; 1111 - bank[1].highmem = highmem = 1; 1112 - j++; 1079 + if (!IS_ENABLED(CONFIG_HIGHMEM) || cache_is_vipt_aliasing()) { 1080 + 1081 + if (highmem) { 1082 + pr_notice("Ignoring RAM at %pa-%pa (!CONFIG_HIGHMEM)\n", 1083 + &block_start, &block_end); 1084 + memblock_remove(reg->base, reg->size); 1085 + continue; 1113 1086 } 1114 - bank->size = size_limit; 1115 - } 1116 - #else 1117 - /* 1118 - * Highmem banks not allowed with !CONFIG_HIGHMEM. 1119 - */ 1120 - if (highmem) { 1121 - printk(KERN_NOTICE "Ignoring RAM at %.8llx-%.8llx " 1122 - "(!CONFIG_HIGHMEM).\n", 1123 - (unsigned long long)bank->start, 1124 - (unsigned long long)bank->start + bank->size - 1); 1125 - continue; 1087 + 1088 + if (reg->size > size_limit) { 1089 + phys_addr_t overlap_size = reg->size - size_limit; 1090 + 1091 + pr_notice("Truncating RAM at %pa-%pa to -%pa", 1092 + &block_start, &block_end, &vmalloc_limit); 1093 + memblock_remove(vmalloc_limit, overlap_size); 1094 + block_end = vmalloc_limit; 1095 + } 1126 1096 } 1127 1097 1128 - /* 1129 - * Check whether this memory bank would partially overlap 1130 - * the vmalloc area. 1131 - */ 1132 - if (bank->size > size_limit) { 1133 - printk(KERN_NOTICE "Truncating RAM at %.8llx-%.8llx " 1134 - "to -%.8llx (vmalloc region overlap).\n", 1135 - (unsigned long long)bank->start, 1136 - (unsigned long long)bank->start + bank->size - 1, 1137 - (unsigned long long)bank->start + size_limit - 1); 1138 - bank->size = size_limit; 1139 - } 1140 - #endif 1141 - if (!bank->highmem) { 1142 - phys_addr_t bank_end = bank->start + bank->size; 1143 - 1144 - if (bank_end > arm_lowmem_limit) 1145 - arm_lowmem_limit = bank_end; 1098 + if (!highmem) { 1099 + if (block_end > arm_lowmem_limit) { 1100 + if (reg->size > size_limit) 1101 + arm_lowmem_limit = vmalloc_limit; 1102 + else 1103 + arm_lowmem_limit = block_end; 1104 + } 1146 1105 1147 1106 /* 1148 1107 * Find the first non-section-aligned page, and point ··· 1131 1144 * occurs before any free memory is mapped. 1132 1145 */ 1133 1146 if (!memblock_limit) { 1134 - if (!IS_ALIGNED(bank->start, SECTION_SIZE)) 1135 - memblock_limit = bank->start; 1136 - else if (!IS_ALIGNED(bank_end, SECTION_SIZE)) 1137 - memblock_limit = bank_end; 1147 + if (!IS_ALIGNED(block_start, SECTION_SIZE)) 1148 + memblock_limit = block_start; 1149 + else if (!IS_ALIGNED(block_end, SECTION_SIZE)) 1150 + memblock_limit = arm_lowmem_limit; 1138 1151 } 1139 - } 1140 - j++; 1141 - } 1142 - #ifdef CONFIG_HIGHMEM 1143 - if (highmem) { 1144 - const char *reason = NULL; 1145 1152 1146 - if (cache_is_vipt_aliasing()) { 1147 - /* 1148 - * Interactions between kmap and other mappings 1149 - * make highmem support with aliasing VIPT caches 1150 - * rather difficult. 1151 - */ 1152 - reason = "with VIPT aliasing cache"; 1153 - } 1154 - if (reason) { 1155 - printk(KERN_CRIT "HIGHMEM is not supported %s, ignoring high memory\n", 1156 - reason); 1157 - while (j > 0 && meminfo.bank[j - 1].highmem) 1158 - j--; 1159 1153 } 1160 1154 } 1161 - #endif 1162 - meminfo.nr_banks = j; 1155 + 1163 1156 high_memory = __va(arm_lowmem_limit - 1) + 1; 1164 1157 1165 1158 /* ··· 1326 1359 #ifdef CONFIG_HIGHMEM 1327 1360 pkmap_page_table = early_pte_alloc(pmd_off_k(PKMAP_BASE), 1328 1361 PKMAP_BASE, _PAGE_KERNEL_TABLE); 1362 + 1363 + fixmap_page_table = early_pte_alloc(pmd_off_k(FIXADDR_START), 1364 + FIXADDR_START, _PAGE_KERNEL_TABLE); 1329 1365 #endif 1330 1366 } 1331 1367 ··· 1431 1461 * just complicate the code. 1432 1462 */ 1433 1463 flush_cache_louis(); 1434 - dsb(); 1464 + dsb(ishst); 1435 1465 isb(); 1436 1466 1437 1467 /* remap level 1 table */
+34 -28
arch/arm/mm/nommu.c
··· 88 88 void __init sanity_check_meminfo_mpu(void) 89 89 { 90 90 int i; 91 - struct membank *bank = meminfo.bank; 92 91 phys_addr_t phys_offset = PHYS_OFFSET; 93 92 phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size; 93 + struct memblock_region *reg; 94 + bool first = true; 95 + phys_addr_t mem_start; 96 + phys_addr_t mem_end; 94 97 95 - /* Initially only use memory continuous from PHYS_OFFSET */ 96 - if (bank_phys_start(&bank[0]) != phys_offset) 97 - panic("First memory bank must be contiguous from PHYS_OFFSET"); 98 + for_each_memblock(memory, reg) { 99 + if (first) { 100 + /* 101 + * Initially only use memory continuous from 102 + * PHYS_OFFSET */ 103 + if (reg->base != phys_offset) 104 + panic("First memory bank must be contiguous from PHYS_OFFSET"); 98 105 99 - /* Banks have already been sorted by start address */ 100 - for (i = 1; i < meminfo.nr_banks; i++) { 101 - if (bank[i].start <= bank_phys_end(&bank[0]) && 102 - bank_phys_end(&bank[i]) > bank_phys_end(&bank[0])) { 103 - bank[0].size = bank_phys_end(&bank[i]) - bank[0].start; 106 + mem_start = reg->base; 107 + mem_end = reg->base + reg->size; 108 + specified_mem_size = reg->size; 109 + first = false; 104 110 } else { 105 - pr_notice("Ignoring RAM after 0x%.8lx. " 106 - "First non-contiguous (ignored) bank start: 0x%.8lx\n", 107 - (unsigned long)bank_phys_end(&bank[0]), 108 - (unsigned long)bank_phys_start(&bank[i])); 109 - break; 111 + /* 112 + * memblock auto merges contiguous blocks, remove 113 + * all blocks afterwards 114 + */ 115 + pr_notice("Ignoring RAM after %pa, memory at %pa ignored\n", 116 + &mem_start, &reg->base); 117 + memblock_remove(reg->base, reg->size); 110 118 } 111 119 } 112 - /* All contiguous banks are now merged in to the first bank */ 113 - meminfo.nr_banks = 1; 114 - specified_mem_size = bank[0].size; 115 120 116 121 /* 117 122 * MPU has curious alignment requirements: Size must be power of 2, and ··· 133 128 */ 134 129 aligned_region_size = (phys_offset - 1) ^ (phys_offset); 135 130 /* Find the max power-of-two sized region that fits inside our bank */ 136 - rounded_mem_size = (1 << __fls(bank[0].size)) - 1; 131 + rounded_mem_size = (1 << __fls(specified_mem_size)) - 1; 137 132 138 133 /* The actual region size is the smaller of the two */ 139 134 aligned_region_size = aligned_region_size < rounded_mem_size 140 135 ? aligned_region_size + 1 141 136 : rounded_mem_size + 1; 142 137 143 - if (aligned_region_size != specified_mem_size) 144 - pr_warn("Truncating memory from 0x%.8lx to 0x%.8lx (MPU region constraints)", 145 - (unsigned long)specified_mem_size, 146 - (unsigned long)aligned_region_size); 138 + if (aligned_region_size != specified_mem_size) { 139 + pr_warn("Truncating memory from %pa to %pa (MPU region constraints)", 140 + &specified_mem_size, &aligned_region_size); 141 + memblock_remove(mem_start + aligned_region_size, 142 + specified_mem_size - aligned_round_size); 147 143 148 - meminfo.bank[0].size = aligned_region_size; 149 - pr_debug("MPU Region from 0x%.8lx size 0x%.8lx (end 0x%.8lx))\n", 150 - (unsigned long)phys_offset, 151 - (unsigned long)aligned_region_size, 152 - (unsigned long)bank_phys_end(&bank[0])); 144 + mem_end = mem_start + aligned_region_size; 145 + } 146 + 147 + pr_debug("MPU Region from %pa size %pa (end %pa))\n", 148 + &phys_offset, &aligned_region_size, &mem_end); 153 149 154 150 } 155 151 ··· 298 292 { 299 293 phys_addr_t end; 300 294 sanity_check_meminfo_mpu(); 301 - end = bank_phys_end(&meminfo.bank[meminfo.nr_banks - 1]); 295 + end = memblock_end_of_DRAM(); 302 296 high_memory = __va(end - 1) + 1; 303 297 } 304 298
+13 -5
arch/arm/mm/proc-v7-3level.S
··· 64 64 mov pc, lr 65 65 ENDPROC(cpu_v7_switch_mm) 66 66 67 + #ifdef __ARMEB__ 68 + #define rl r3 69 + #define rh r2 70 + #else 71 + #define rl r2 72 + #define rh r3 73 + #endif 74 + 67 75 /* 68 76 * cpu_v7_set_pte_ext(ptep, pte) 69 77 * ··· 81 73 */ 82 74 ENTRY(cpu_v7_set_pte_ext) 83 75 #ifdef CONFIG_MMU 84 - tst r2, #L_PTE_VALID 76 + tst rl, #L_PTE_VALID 85 77 beq 1f 86 - tst r3, #1 << (57 - 32) @ L_PTE_NONE 87 - bicne r2, #L_PTE_VALID 78 + tst rh, #1 << (57 - 32) @ L_PTE_NONE 79 + bicne rl, #L_PTE_VALID 88 80 bne 1f 89 - tst r3, #1 << (55 - 32) @ L_PTE_DIRTY 90 - orreq r2, #L_PTE_RDONLY 81 + tst rh, #1 << (55 - 32) @ L_PTE_DIRTY 82 + orreq rl, #L_PTE_RDONLY 91 83 1: strd r2, r3, [r0] 92 84 ALT_SMP(W(nop)) 93 85 ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte
+36 -3
arch/arm/mm/proc-v7.S
··· 169 169 globl_equ cpu_pj4b_do_idle, cpu_v7_do_idle 170 170 #endif 171 171 globl_equ cpu_pj4b_dcache_clean_area, cpu_v7_dcache_clean_area 172 - globl_equ cpu_pj4b_do_suspend, cpu_v7_do_suspend 173 - globl_equ cpu_pj4b_do_resume, cpu_v7_do_resume 174 - globl_equ cpu_pj4b_suspend_size, cpu_v7_suspend_size 172 + #ifdef CONFIG_ARM_CPU_SUSPEND 173 + ENTRY(cpu_pj4b_do_suspend) 174 + stmfd sp!, {r6 - r10} 175 + mrc p15, 1, r6, c15, c1, 0 @ save CP15 - extra features 176 + mrc p15, 1, r7, c15, c2, 0 @ save CP15 - Aux Func Modes Ctrl 0 177 + mrc p15, 1, r8, c15, c1, 2 @ save CP15 - Aux Debug Modes Ctrl 2 178 + mrc p15, 1, r9, c15, c1, 1 @ save CP15 - Aux Debug Modes Ctrl 1 179 + mrc p15, 0, r10, c9, c14, 0 @ save CP15 - PMC 180 + stmia r0!, {r6 - r10} 181 + ldmfd sp!, {r6 - r10} 182 + b cpu_v7_do_suspend 183 + ENDPROC(cpu_pj4b_do_suspend) 184 + 185 + ENTRY(cpu_pj4b_do_resume) 186 + ldmia r0!, {r6 - r10} 187 + mcr p15, 1, r6, c15, c1, 0 @ save CP15 - extra features 188 + mcr p15, 1, r7, c15, c2, 0 @ save CP15 - Aux Func Modes Ctrl 0 189 + mcr p15, 1, r8, c15, c1, 2 @ save CP15 - Aux Debug Modes Ctrl 2 190 + mcr p15, 1, r9, c15, c1, 1 @ save CP15 - Aux Debug Modes Ctrl 1 191 + mcr p15, 0, r10, c9, c14, 0 @ save CP15 - PMC 192 + b cpu_v7_do_resume 193 + ENDPROC(cpu_pj4b_do_resume) 194 + #endif 195 + .globl cpu_pj4b_suspend_size 196 + .equ cpu_pj4b_suspend_size, 4 * 14 175 197 176 198 #endif 177 199 ··· 216 194 __v7_ca7mp_setup: 217 195 __v7_ca12mp_setup: 218 196 __v7_ca15mp_setup: 197 + __v7_ca17mp_setup: 219 198 mov r10, #0 220 199 1: 221 200 #ifdef CONFIG_SMP ··· 526 503 .long 0xff0ffff0 527 504 __v7_proc __v7_ca15mp_setup 528 505 .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info 506 + 507 + /* 508 + * ARM Ltd. Cortex A17 processor. 509 + */ 510 + .type __v7_ca17mp_proc_info, #object 511 + __v7_ca17mp_proc_info: 512 + .long 0x410fc0e0 513 + .long 0xff0ffff0 514 + __v7_proc __v7_ca17mp_setup 515 + .size __v7_ca17mp_proc_info, . - __v7_ca17mp_proc_info 529 516 530 517 /* 531 518 * Qualcomm Inc. Krait processors.
-1
arch/arm/plat-samsung/s5p-sleep.S
··· 22 22 */ 23 23 24 24 #include <linux/linkage.h> 25 - #include <asm/asm-offsets.h> 26 25 27 26 .data 28 27 .align
+1 -2
arch/arm/vfp/entry.S
··· 22 22 @ r9 = normal "successful" return address 23 23 @ r10 = this threads thread_info structure 24 24 @ lr = unrecognised instruction return address 25 - @ IRQs disabled. 25 + @ IRQs enabled. 26 26 @ 27 27 ENTRY(do_vfp) 28 28 inc_preempt_count r10, r4 29 - enable_irq 30 29 ldr r4, .LCvfp 31 30 ldr r11, [r10, #TI_CPU] @ CPU number 32 31 add r10, r10, #TI_VFPSTATE @ r10 = workspace
+110
drivers/of/address.c
··· 701 701 return ioremap(res.start, resource_size(&res)); 702 702 } 703 703 EXPORT_SYMBOL(of_iomap); 704 + 705 + /** 706 + * of_dma_get_range - Get DMA range info 707 + * @np: device node to get DMA range info 708 + * @dma_addr: pointer to store initial DMA address of DMA range 709 + * @paddr: pointer to store initial CPU address of DMA range 710 + * @size: pointer to store size of DMA range 711 + * 712 + * Look in bottom up direction for the first "dma-ranges" property 713 + * and parse it. 714 + * dma-ranges format: 715 + * DMA addr (dma_addr) : naddr cells 716 + * CPU addr (phys_addr_t) : pna cells 717 + * size : nsize cells 718 + * 719 + * It returns -ENODEV if "dma-ranges" property was not found 720 + * for this device in DT. 721 + */ 722 + int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *size) 723 + { 724 + struct device_node *node = of_node_get(np); 725 + const __be32 *ranges = NULL; 726 + int len, naddr, nsize, pna; 727 + int ret = 0; 728 + u64 dmaaddr; 729 + 730 + if (!node) 731 + return -EINVAL; 732 + 733 + while (1) { 734 + naddr = of_n_addr_cells(node); 735 + nsize = of_n_size_cells(node); 736 + node = of_get_next_parent(node); 737 + if (!node) 738 + break; 739 + 740 + ranges = of_get_property(node, "dma-ranges", &len); 741 + 742 + /* Ignore empty ranges, they imply no translation required */ 743 + if (ranges && len > 0) 744 + break; 745 + 746 + /* 747 + * At least empty ranges has to be defined for parent node if 748 + * DMA is supported 749 + */ 750 + if (!ranges) 751 + break; 752 + } 753 + 754 + if (!ranges) { 755 + pr_debug("%s: no dma-ranges found for node(%s)\n", 756 + __func__, np->full_name); 757 + ret = -ENODEV; 758 + goto out; 759 + } 760 + 761 + len /= sizeof(u32); 762 + 763 + pna = of_n_addr_cells(node); 764 + 765 + /* dma-ranges format: 766 + * DMA addr : naddr cells 767 + * CPU addr : pna cells 768 + * size : nsize cells 769 + */ 770 + dmaaddr = of_read_number(ranges, naddr); 771 + *paddr = of_translate_dma_address(np, ranges); 772 + if (*paddr == OF_BAD_ADDR) { 773 + pr_err("%s: translation of DMA address(%pad) to CPU address failed node(%s)\n", 774 + __func__, dma_addr, np->full_name); 775 + ret = -EINVAL; 776 + goto out; 777 + } 778 + *dma_addr = dmaaddr; 779 + 780 + *size = of_read_number(ranges + naddr + pna, nsize); 781 + 782 + pr_debug("dma_addr(%llx) cpu_addr(%llx) size(%llx)\n", 783 + *dma_addr, *paddr, *size); 784 + 785 + out: 786 + of_node_put(node); 787 + 788 + return ret; 789 + } 790 + EXPORT_SYMBOL_GPL(of_dma_get_range); 791 + 792 + /** 793 + * of_dma_is_coherent - Check if device is coherent 794 + * @np: device node 795 + * 796 + * It returns true if "dma-coherent" property was found 797 + * for this device in DT. 798 + */ 799 + bool of_dma_is_coherent(struct device_node *np) 800 + { 801 + struct device_node *node = of_node_get(np); 802 + 803 + while (node) { 804 + if (of_property_read_bool(node, "dma-coherent")) { 805 + of_node_put(node); 806 + return true; 807 + } 808 + node = of_get_next_parent(node); 809 + } 810 + of_node_put(node); 811 + return false; 812 + } 813 + EXPORT_SYMBOL_GPL(of_dma_is_coherent);
+59 -6
drivers/of/platform.c
··· 153 153 EXPORT_SYMBOL(of_device_alloc); 154 154 155 155 /** 156 + * of_dma_configure - Setup DMA configuration 157 + * @dev: Device to apply DMA configuration 158 + * 159 + * Try to get devices's DMA configuration from DT and update it 160 + * accordingly. 161 + * 162 + * In case if platform code need to use own special DMA configuration,it 163 + * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event 164 + * to fix up DMA configuration. 165 + */ 166 + static void of_dma_configure(struct platform_device *pdev) 167 + { 168 + u64 dma_addr, paddr, size; 169 + int ret; 170 + struct device *dev = &pdev->dev; 171 + 172 + #if defined(CONFIG_MICROBLAZE) 173 + pdev->archdata.dma_mask = 0xffffffffUL; 174 + #endif 175 + 176 + /* 177 + * Set default dma-mask to 32 bit. Drivers are expected to setup 178 + * the correct supported dma_mask. 179 + */ 180 + dev->coherent_dma_mask = DMA_BIT_MASK(32); 181 + 182 + /* 183 + * Set it to coherent_dma_mask by default if the architecture 184 + * code has not set it. 185 + */ 186 + if (!dev->dma_mask) 187 + dev->dma_mask = &dev->coherent_dma_mask; 188 + 189 + /* 190 + * if dma-coherent property exist, call arch hook to setup 191 + * dma coherent operations. 192 + */ 193 + if (of_dma_is_coherent(dev->of_node)) { 194 + set_arch_dma_coherent_ops(dev); 195 + dev_dbg(dev, "device is dma coherent\n"); 196 + } 197 + 198 + /* 199 + * if dma-ranges property doesn't exist - just return else 200 + * setup the dma offset 201 + */ 202 + ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); 203 + if (ret < 0) { 204 + dev_dbg(dev, "no dma range information to setup\n"); 205 + return; 206 + } 207 + 208 + /* DMA ranges found. Calculate and set dma_pfn_offset */ 209 + dev->dma_pfn_offset = PFN_DOWN(paddr - dma_addr); 210 + dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); 211 + } 212 + 213 + /** 156 214 * of_platform_device_create_pdata - Alloc, initialize and register an of_device 157 215 * @np: pointer to node to create device for 158 216 * @bus_id: name to assign device ··· 236 178 if (!dev) 237 179 goto err_clear_flag; 238 180 239 - #if defined(CONFIG_MICROBLAZE) 240 - dev->archdata.dma_mask = 0xffffffffUL; 241 - #endif 242 - dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 243 - if (!dev->dev.dma_mask) 244 - dev->dev.dma_mask = &dev->dev.coherent_dma_mask; 181 + of_dma_configure(dev); 245 182 dev->dev.bus = &platform_bus_type; 246 183 dev->dev.platform_data = platform_data; 247 184
+2
include/linux/device.h
··· 692 692 * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all 693 693 * hardware supports 64-bit addresses for consistent allocations 694 694 * such descriptors. 695 + * @dma_pfn_offset: offset of DMA memory range relatively of RAM 695 696 * @dma_parms: A low level driver may set these to teach IOMMU code about 696 697 * segment limitations. 697 698 * @dma_pools: Dma pools (if dma'ble device). ··· 760 759 not all hardware supports 761 760 64 bit addresses for consistent 762 761 allocations such descriptors. */ 762 + unsigned long dma_pfn_offset; 763 763 764 764 struct device_dma_parameters *dma_parms; 765 765
+7
include/linux/dma-mapping.h
··· 129 129 130 130 extern u64 dma_get_required_mask(struct device *dev); 131 131 132 + #ifndef set_arch_dma_coherent_ops 133 + static inline int set_arch_dma_coherent_ops(struct device *dev) 134 + { 135 + return 0; 136 + } 137 + #endif 138 + 132 139 static inline unsigned int dma_get_max_seg_size(struct device *dev) 133 140 { 134 141 return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536;
+14
include/linux/of_address.h
··· 62 62 extern struct of_pci_range *of_pci_range_parser_one( 63 63 struct of_pci_range_parser *parser, 64 64 struct of_pci_range *range); 65 + extern int of_dma_get_range(struct device_node *np, u64 *dma_addr, 66 + u64 *paddr, u64 *size); 67 + extern bool of_dma_is_coherent(struct device_node *np); 65 68 #else /* CONFIG_OF_ADDRESS */ 66 69 static inline struct device_node *of_find_matching_node_by_address( 67 70 struct device_node *from, ··· 91 88 struct of_pci_range *range) 92 89 { 93 90 return NULL; 91 + } 92 + 93 + static inline int of_dma_get_range(struct device_node *np, u64 *dma_addr, 94 + u64 *paddr, u64 *size) 95 + { 96 + return -ENODEV; 97 + } 98 + 99 + static inline bool of_dma_is_coherent(struct device_node *np) 100 + { 101 + return false; 94 102 } 95 103 #endif /* CONFIG_OF_ADDRESS */ 96 104
+2
include/linux/suspend.h
··· 327 327 extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); 328 328 extern int hibernate(void); 329 329 extern bool system_entering_hibernation(void); 330 + asmlinkage int swsusp_save(void); 331 + extern struct pbe *restore_pblist; 330 332 #else /* CONFIG_HIBERNATION */ 331 333 static inline void register_nosave_region(unsigned long b, unsigned long e) {} 332 334 static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
+3
include/linux/uprobes.h
··· 32 32 struct mm_struct; 33 33 struct inode; 34 34 struct notifier_block; 35 + struct page; 35 36 36 37 #define UPROBE_HANDLER_REMOVE 1 37 38 #define UPROBE_HANDLER_MASK 1 ··· 128 127 extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs *regs); 129 128 extern unsigned long arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs *regs); 130 129 extern bool __weak arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs); 130 + extern void __weak arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, 131 + void *src, unsigned long len); 131 132 #else /* !CONFIG_UPROBES */ 132 133 struct uprobes_state { 133 134 };
+17 -8
kernel/events/uprobes.c
··· 1291 1291 if (unlikely(!xol_vaddr)) 1292 1292 return 0; 1293 1293 1294 - /* Initialize the slot */ 1295 - copy_to_page(area->page, xol_vaddr, 1296 - &uprobe->arch.ixol, sizeof(uprobe->arch.ixol)); 1297 - /* 1298 - * We probably need flush_icache_user_range() but it needs vma. 1299 - * This should work on supported architectures too. 1300 - */ 1301 - flush_dcache_page(area->page); 1294 + arch_uprobe_copy_ixol(area->page, xol_vaddr, 1295 + &uprobe->arch.ixol, sizeof(uprobe->arch.ixol)); 1302 1296 1303 1297 return xol_vaddr; 1304 1298 } ··· 1333 1339 1334 1340 tsk->utask->xol_vaddr = 0; 1335 1341 } 1342 + } 1343 + 1344 + void __weak arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, 1345 + void *src, unsigned long len) 1346 + { 1347 + /* Initialize the slot */ 1348 + copy_to_page(page, vaddr, src, len); 1349 + 1350 + /* 1351 + * We probably need flush_icache_user_range() but it needs vma. 1352 + * This should work on most of architectures by default. If 1353 + * architecture needs to do something different it can define 1354 + * its own version of the function. 1355 + */ 1356 + flush_dcache_page(page); 1336 1357 } 1337 1358 1338 1359 /**