···4545 select GENERIC_SMP_IDLE_THREAD4646 select KTIME_SCALAR4747 select GENERIC_CLOCKEVENTS_BROADCAST if SMP4848+ select GENERIC_STRNCPY_FROM_USER4949+ select GENERIC_STRNLEN_USER5050+ select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN4851 help4952 The ARM series is a line of low-power-consumption RISC chip designs5053 licensed by ARM Ltd and targeted at embedded applications and···19631960 DTB. To allow a device tree enabled kernel to be used with such19641961 bootloaders, this option allows zImage to extract the information19651962 from the ATAG list and store it at run time into the appended DTB.19631963+19641964+choice19651965+ prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT19661966+ default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER19671967+19681968+config ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER19691969+ bool "Use bootloader kernel arguments if available"19701970+ help19711971+ Uses the command-line options passed by the boot loader instead of19721972+ the device tree bootargs property. If the boot loader doesn't provide19731973+ any, the device tree bootargs property will be used.19741974+19751975+config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND19761976+ bool "Extend with bootloader kernel arguments"19771977+ help19781978+ The command-line arguments provided by the boot loader will be19791979+ appended to the the device tree bootargs property.19801980+19811981+endchoice1966198219671983config CMDLINE19681984 string "Default kernel command string"
+9
arch/arm/Kconfig.debug
···369369 help370370 Perform tests of kprobes API and instruction set simulation.371371372372+config PID_IN_CONTEXTIDR373373+ bool "Write the current PID to the CONTEXTIDR register"374374+ depends on CPU_COPY_V6375375+ help376376+ Enabling this option causes the kernel to write the current PID to377377+ the PROCID field of the CONTEXTIDR register, at the expense of some378378+ additional instructions during context switch. Say Y here only if you379379+ are planning to use hardware trace tools with this kernel.380380+372381endmenu
+3
arch/arm/Makefile
···1010#1111# Copyright (C) 1995-2001 by Russell King12121313+# Ensure linker flags are correct1414+LDFLAGS :=1515+1316LDFLAGS_vmlinux :=-p --no-undefined -X1417ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)1518LDFLAGS_vmlinux += --be8
+60-2
arch/arm/boot/compressed/atags_to_fdt.c
···11#include <asm/setup.h>22#include <libfdt.h>3344+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)55+#define do_extend_cmdline 166+#else77+#define do_extend_cmdline 088+#endif99+410static int node_offset(void *fdt, const char *node_path)511{612 int offset = fdt_path_offset(fdt, node_path);···4034 if (offset < 0)4135 return offset;4236 return fdt_setprop_cell(fdt, offset, property, val);3737+}3838+3939+static const void *getprop(const void *fdt, const char *node_path,4040+ const char *property, int *len)4141+{4242+ int offset = fdt_path_offset(fdt, node_path);4343+4444+ if (offset == -FDT_ERR_NOTFOUND)4545+ return NULL;4646+4747+ return fdt_getprop(fdt, offset, property, len);4848+}4949+5050+static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)5151+{5252+ char cmdline[COMMAND_LINE_SIZE];5353+ const char *fdt_bootargs;5454+ char *ptr = cmdline;5555+ int len = 0;5656+5757+ /* copy the fdt command line into the buffer */5858+ fdt_bootargs = getprop(fdt, "/chosen", "bootargs", &len);5959+ if (fdt_bootargs)6060+ if (len < COMMAND_LINE_SIZE) {6161+ memcpy(ptr, fdt_bootargs, len);6262+ /* len is the length of the string6363+ * including the NULL terminator */6464+ ptr += len - 1;6565+ }6666+6767+ /* and append the ATAG_CMDLINE */6868+ if (fdt_cmdline) {6969+ len = strlen(fdt_cmdline);7070+ if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {7171+ *ptr++ = ' ';7272+ memcpy(ptr, fdt_cmdline, len);7373+ ptr += len;7474+ }7575+ }7676+ *ptr = '\0';7777+7878+ setprop_string(fdt, "/chosen", "bootargs", cmdline);4379}44804581/*···1207212173 for_each_tag(atag, atag_list) {12274 if (atag->hdr.tag == ATAG_CMDLINE) {123123- setprop_string(fdt, "/chosen", "bootargs",124124- atag->u.cmdline.cmdline);7575+ /* Append the ATAGS command line to the device tree7676+ * command line.7777+ * NB: This means that if the same parameter is set in7878+ * the device tree and in the tags, the one from the7979+ * tags will be chosen.8080+ */8181+ if (do_extend_cmdline)8282+ merge_fdt_bootargs(fdt,8383+ atag->u.cmdline.cmdline);8484+ else8585+ setprop_string(fdt, "/chosen", "bootargs",8686+ atag->u.cmdline.cmdline);12587 } else if (atag->hdr.tag == ATAG_MEM) {12688 if (memcount >= sizeof(mem_reg_property)/4)12789 continue;
···66#ifndef __ASM_ARM_DELAY_H77#define __ASM_ARM_DELAY_H8899+#include <asm/memory.h>910#include <asm/param.h> /* HZ */10111111-extern void __delay(int loops);1212+#define MAX_UDELAY_MS 21313+#define UDELAY_MULT ((UL(2199023) * HZ) >> 11)1414+#define UDELAY_SHIFT 301515+1616+#ifndef __ASSEMBLY__1717+1818+extern struct arm_delay_ops {1919+ void (*delay)(unsigned long);2020+ void (*const_udelay)(unsigned long);2121+ void (*udelay)(unsigned long);2222+} arm_delay_ops;2323+2424+#define __delay(n) arm_delay_ops.delay(n)12251326/*1427 * This function intentionally does not exist; if you see references to···3623 * division by multiplication: you don't have to worry about3724 * loss of precision.3825 *3939- * Use only for very small delays ( < 1 msec). Should probably use a2626+ * Use only for very small delays ( < 2 msec). Should probably use a4027 * lookup table, really, as the multiplications take much too long with4128 * short delays. This is a "reasonable" implementation, though (and the4229 * first constant multiplications gets optimized away if the delay is4330 * a constant)4431 */4545-extern void __udelay(unsigned long usecs);4646-extern void __const_udelay(unsigned long);4747-4848-#define MAX_UDELAY_MS 23232+#define __udelay(n) arm_delay_ops.udelay(n)3333+#define __const_udelay(n) arm_delay_ops.const_udelay(n)49345035#define udelay(n) \5136 (__builtin_constant_p(n) ? \5237 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \5353- __const_udelay((n) * ((2199023U*HZ)>>11))) : \3838+ __const_udelay((n) * UDELAY_MULT)) : \5439 __udelay(n))4040+4141+/* Loop-based definitions for assembly code. */4242+extern void __loop_delay(unsigned long loops);4343+extern void __loop_udelay(unsigned long usecs);4444+extern void __loop_const_udelay(unsigned long);4545+4646+#endif /* __ASSEMBLY__ */55475648#endif /* defined(_ARM_DELAY_H) */5749
···189189190190#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)191191192192+#define user_addr_max() \193193+ (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)194194+192195/*193196 * The "__xxx" versions of the user access functions do not verify the194197 * address space - it must have been done previously with a separate···401398#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0)402399#endif403400404404-extern unsigned long __must_check __strncpy_from_user(char *to, const char __user *from, unsigned long count);405405-extern unsigned long __must_check __strnlen_user(const char __user *s, long n);406406-407401static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)408402{409403 if (access_ok(VERIFY_READ, from, n))···427427 return n;428428}429429430430-static inline long __must_check strncpy_from_user(char *dst, const char __user *src, long count)431431-{432432- long res = -EFAULT;433433- if (access_ok(VERIFY_READ, src, 1))434434- res = __strncpy_from_user(dst, src, count);435435- return res;436436-}430430+extern long strncpy_from_user(char *dest, const char __user *src, long count);437431438438-#define strlen_user(s) strnlen_user(s, ~0UL >> 1)439439-440440-static inline long __must_check strnlen_user(const char __user *s, long n)441441-{442442- unsigned long res = 0;443443-444444- if (__addr_ok(s))445445- res = __strnlen_user(s, n);446446-447447- return res;448448-}432432+extern __must_check long strlen_user(const char __user *str);433433+extern __must_check long strnlen_user(const char __user *str, long n);449434450435#endif /* _ASMARM_UACCESS_H */
+96
arch/arm/include/asm/word-at-a-time.h
···11+#ifndef __ASM_ARM_WORD_AT_A_TIME_H22+#define __ASM_ARM_WORD_AT_A_TIME_H33+44+#ifndef __ARMEB__55+66+/*77+ * Little-endian word-at-a-time zero byte handling.88+ * Heavily based on the x86 algorithm.99+ */1010+#include <linux/kernel.h>1111+1212+struct word_at_a_time {1313+ const unsigned long one_bits, high_bits;1414+};1515+1616+#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }1717+1818+static inline unsigned long has_zero(unsigned long a, unsigned long *bits,1919+ const struct word_at_a_time *c)2020+{2121+ unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;2222+ *bits = mask;2323+ return mask;2424+}2525+2626+#define prep_zero_mask(a, bits, c) (bits)2727+2828+static inline unsigned long create_zero_mask(unsigned long bits)2929+{3030+ bits = (bits - 1) & ~bits;3131+ return bits >> 7;3232+}3333+3434+static inline unsigned long find_zero(unsigned long mask)3535+{3636+ unsigned long ret;3737+3838+#if __LINUX_ARM_ARCH__ >= 53939+ /* We have clz available. */4040+ ret = fls(mask) >> 3;4141+#else4242+ /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */4343+ ret = (0x0ff0001 + mask) >> 23;4444+ /* Fix the 1 for 00 case */4545+ ret &= mask;4646+#endif4747+4848+ return ret;4949+}5050+5151+#ifdef CONFIG_DCACHE_WORD_ACCESS5252+5353+#define zero_bytemask(mask) (mask)5454+5555+/*5656+ * Load an unaligned word from kernel space.5757+ *5858+ * In the (very unlikely) case of the word being a page-crosser5959+ * and the next page not being mapped, take the exception and6060+ * return zeroes in the non-existing part.6161+ */6262+static inline unsigned long load_unaligned_zeropad(const void *addr)6363+{6464+ unsigned long ret, offset;6565+6666+ /* Load word from unaligned pointer addr */6767+ asm(6868+ "1: ldr %0, [%2]\n"6969+ "2:\n"7070+ " .pushsection .fixup,\"ax\"\n"7171+ " .align 2\n"7272+ "3: and %1, %2, #0x3\n"7373+ " bic %2, %2, #0x3\n"7474+ " ldr %0, [%2]\n"7575+ " lsl %1, %1, #0x3\n"7676+ " lsr %0, %0, %1\n"7777+ " b 2b\n"7878+ " .popsection\n"7979+ " .pushsection __ex_table,\"a\"\n"8080+ " .align 3\n"8181+ " .long 1b, 3b\n"8282+ " .popsection"8383+ : "=&r" (ret), "=&r" (offset)8484+ : "r" (addr), "Qo" (*(unsigned long *)addr));8585+8686+ return ret;8787+}8888+8989+9090+#endif /* DCACHE_WORD_ACCESS */9191+9292+#else /* __ARMEB__ */9393+#include <asm-generic/word-at-a-time.h>9494+#endif9595+9696+#endif /* __ASM_ARM_WORD_AT_A_TIME_H */
···4747/* Set at runtime when we know what CPU type we are. */4848static struct arm_pmu *cpu_pmu;49495050-enum arm_perf_pmu_ids5151-armpmu_get_pmu_id(void)5050+const char *perf_pmu_name(void)5251{5353- int id = -ENODEV;5252+ if (!cpu_pmu)5353+ return NULL;54545555- if (cpu_pmu != NULL)5656- id = cpu_pmu->id;5757-5858- return id;5555+ return cpu_pmu->pmu.name;5956}6060-EXPORT_SYMBOL_GPL(armpmu_get_pmu_id);5757+EXPORT_SYMBOL_GPL(perf_pmu_name);61586259int perf_num_counters(void)6360{···757760 cpu_pmu->name, cpu_pmu->num_events);758761 cpu_pmu_init(cpu_pmu);759762 register_cpu_notifier(&pmu_cpu_notifier);760760- armpmu_register(cpu_pmu, "cpu", PERF_TYPE_RAW);763763+ armpmu_register(cpu_pmu, cpu_pmu->name, PERF_TYPE_RAW);761764 } else {762765 pr_info("no hardware support available\n");763766 }
···907907 return ret;908908}909909910910-asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)910910+enum ptrace_syscall_dir {911911+ PTRACE_SYSCALL_ENTER = 0,912912+ PTRACE_SYSCALL_EXIT,913913+};914914+915915+static int ptrace_syscall_trace(struct pt_regs *regs, int scno,916916+ enum ptrace_syscall_dir dir)911917{912918 unsigned long ip;913913-914914- if (why)915915- audit_syscall_exit(regs);916916- else917917- audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0,918918- regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);919919920920 if (!test_thread_flag(TIF_SYSCALL_TRACE))921921 return scno;···927927 * IP = 0 -> entry, =1 -> exit928928 */929929 ip = regs->ARM_ip;930930- regs->ARM_ip = why;930930+ regs->ARM_ip = dir;931931932932- if (why)932932+ if (dir == PTRACE_SYSCALL_EXIT)933933 tracehook_report_syscall_exit(regs, 0);934934 else if (tracehook_report_syscall_entry(regs))935935 current_thread_info()->syscall = -1;936936937937 regs->ARM_ip = ip;938938-939938 return current_thread_info()->syscall;939939+}940940+941941+asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)942942+{943943+ int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER);944944+ audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1,945945+ regs->ARM_r2, regs->ARM_r3);946946+ return ret;947947+}948948+949949+asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno)950950+{951951+ int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT);952952+ audit_syscall_exit(regs);953953+ return ret;940954}
+1-1
arch/arm/kernel/smp.c
···179179 mb();180180181181 /* Tell __cpu_die() that this CPU is now safe to dispose of */182182- complete(&cpu_died);182182+ RCU_NONIDLE(complete(&cpu_died));183183184184 /*185185 * actual CPU shutdown procedure is at least platform (if not
+216-21
arch/arm/kernel/topology.c
···1717#include <linux/percpu.h>1818#include <linux/node.h>1919#include <linux/nodemask.h>2020+#include <linux/of.h>2021#include <linux/sched.h>2222+#include <linux/slab.h>21232224#include <asm/cputype.h>2325#include <asm/topology.h>2626+2727+/*2828+ * cpu power scale management2929+ */3030+3131+/*3232+ * cpu power table3333+ * This per cpu data structure describes the relative capacity of each core.3434+ * On a heteregenous system, cores don't have the same computation capacity3535+ * and we reflect that difference in the cpu_power field so the scheduler can3636+ * take this difference into account during load balance. A per cpu structure3737+ * is preferred because each CPU updates its own cpu_power field during the3838+ * load balance except for idle cores. One idle core is selected to run the3939+ * rebalance_domains for all idle cores and the cpu_power can be updated4040+ * during this sequence.4141+ */4242+static DEFINE_PER_CPU(unsigned long, cpu_scale);4343+4444+unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu)4545+{4646+ return per_cpu(cpu_scale, cpu);4747+}4848+4949+static void set_power_scale(unsigned int cpu, unsigned long power)5050+{5151+ per_cpu(cpu_scale, cpu) = power;5252+}5353+5454+#ifdef CONFIG_OF5555+struct cpu_efficiency {5656+ const char *compatible;5757+ unsigned long efficiency;5858+};5959+6060+/*6161+ * Table of relative efficiency of each processors6262+ * The efficiency value must fit in 20bit and the final6363+ * cpu_scale value must be in the range6464+ * 0 < cpu_scale < 3*SCHED_POWER_SCALE/26565+ * in order to return at most 1 when DIV_ROUND_CLOSEST6666+ * is used to compute the capacity of a CPU.6767+ * Processors that are not defined in the table,6868+ * use the default SCHED_POWER_SCALE value for cpu_scale.6969+ */7070+struct cpu_efficiency table_efficiency[] = {7171+ {"arm,cortex-a15", 3891},7272+ {"arm,cortex-a7", 2048},7373+ {NULL, },7474+};7575+7676+struct cpu_capacity {7777+ unsigned long hwid;7878+ unsigned long capacity;7979+};8080+8181+struct cpu_capacity *cpu_capacity;8282+8383+unsigned long middle_capacity = 1;8484+8585+/*8686+ * Iterate all CPUs' descriptor in DT and compute the efficiency8787+ * (as per table_efficiency). Also calculate a middle efficiency8888+ * as close as possible to (max{eff_i} - min{eff_i}) / 28989+ * This is later used to scale the cpu_power field such that an9090+ * 'average' CPU is of middle power. Also see the comments near9191+ * table_efficiency[] and update_cpu_power().9292+ */9393+static void __init parse_dt_topology(void)9494+{9595+ struct cpu_efficiency *cpu_eff;9696+ struct device_node *cn = NULL;9797+ unsigned long min_capacity = (unsigned long)(-1);9898+ unsigned long max_capacity = 0;9999+ unsigned long capacity = 0;100100+ int alloc_size, cpu = 0;101101+102102+ alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);103103+ cpu_capacity = (struct cpu_capacity *)kzalloc(alloc_size, GFP_NOWAIT);104104+105105+ while ((cn = of_find_node_by_type(cn, "cpu"))) {106106+ const u32 *rate, *reg;107107+ int len;108108+109109+ if (cpu >= num_possible_cpus())110110+ break;111111+112112+ for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)113113+ if (of_device_is_compatible(cn, cpu_eff->compatible))114114+ break;115115+116116+ if (cpu_eff->compatible == NULL)117117+ continue;118118+119119+ rate = of_get_property(cn, "clock-frequency", &len);120120+ if (!rate || len != 4) {121121+ pr_err("%s missing clock-frequency property\n",122122+ cn->full_name);123123+ continue;124124+ }125125+126126+ reg = of_get_property(cn, "reg", &len);127127+ if (!reg || len != 4) {128128+ pr_err("%s missing reg property\n", cn->full_name);129129+ continue;130130+ }131131+132132+ capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;133133+134134+ /* Save min capacity of the system */135135+ if (capacity < min_capacity)136136+ min_capacity = capacity;137137+138138+ /* Save max capacity of the system */139139+ if (capacity > max_capacity)140140+ max_capacity = capacity;141141+142142+ cpu_capacity[cpu].capacity = capacity;143143+ cpu_capacity[cpu++].hwid = be32_to_cpup(reg);144144+ }145145+146146+ if (cpu < num_possible_cpus())147147+ cpu_capacity[cpu].hwid = (unsigned long)(-1);148148+149149+ /* If min and max capacities are equals, we bypass the update of the150150+ * cpu_scale because all CPUs have the same capacity. Otherwise, we151151+ * compute a middle_capacity factor that will ensure that the capacity152152+ * of an 'average' CPU of the system will be as close as possible to153153+ * SCHED_POWER_SCALE, which is the default value, but with the154154+ * constraint explained near table_efficiency[].155155+ */156156+ if (min_capacity == max_capacity)157157+ cpu_capacity[0].hwid = (unsigned long)(-1);158158+ else if (4*max_capacity < (3*(max_capacity + min_capacity)))159159+ middle_capacity = (min_capacity + max_capacity)160160+ >> (SCHED_POWER_SHIFT+1);161161+ else162162+ middle_capacity = ((max_capacity / 3)163163+ >> (SCHED_POWER_SHIFT-1)) + 1;164164+165165+}166166+167167+/*168168+ * Look for a customed capacity of a CPU in the cpu_capacity table during the169169+ * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the170170+ * function returns directly for SMP system.171171+ */172172+void update_cpu_power(unsigned int cpu, unsigned long hwid)173173+{174174+ unsigned int idx = 0;175175+176176+ /* look for the cpu's hwid in the cpu capacity table */177177+ for (idx = 0; idx < num_possible_cpus(); idx++) {178178+ if (cpu_capacity[idx].hwid == hwid)179179+ break;180180+181181+ if (cpu_capacity[idx].hwid == -1)182182+ return;183183+ }184184+185185+ if (idx == num_possible_cpus())186186+ return;187187+188188+ set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);189189+190190+ printk(KERN_INFO "CPU%u: update cpu_power %lu\n",191191+ cpu, arch_scale_freq_power(NULL, cpu));192192+}193193+194194+#else195195+static inline void parse_dt_topology(void) {}196196+static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}197197+#endif198198+199199+200200+/*201201+ * cpu topology management202202+ */2420325204#define MPIDR_SMP_BITMASK (0x3 << 30)26205#define MPIDR_SMP_VALUE (0x2 << 30)···21031 * These masks reflect the current use of the affinity levels.21132 * The affinity level can be up to 16 bits according to ARM ARM21233 */3434+#define MPIDR_HWID_BITMASK 0xFFFFFF2133521436#define MPIDR_LEVEL0_MASK 0x321537#define MPIDR_LEVEL0_SHIFT 0···22141#define MPIDR_LEVEL2_MASK 0xFF22242#define MPIDR_LEVEL2_SHIFT 16223434444+/*4545+ * cpu topology table4646+ */22447struct cputopo_arm cpu_topology[NR_CPUS];2254822649const struct cpumask *cpu_coregroup_mask(int cpu)22750{22851 return &cpu_topology[cpu].core_sibling;5252+}5353+5454+void update_siblings_masks(unsigned int cpuid)5555+{5656+ struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];5757+ int cpu;5858+5959+ /* update core and thread sibling masks */6060+ for_each_possible_cpu(cpu) {6161+ cpu_topo = &cpu_topology[cpu];6262+6363+ if (cpuid_topo->socket_id != cpu_topo->socket_id)6464+ continue;6565+6666+ cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);6767+ if (cpu != cpuid)6868+ cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);6969+7070+ if (cpuid_topo->core_id != cpu_topo->core_id)7171+ continue;7272+7373+ cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling);7474+ if (cpu != cpuid)7575+ cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);7676+ }7777+ smp_wmb();22978}2307923180/*···26657{26758 struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid];26859 unsigned int mpidr;269269- unsigned int cpu;2706027161 /* If the cpu topology has been already set, just return */27262 if (cpuid_topo->core_id != -1)···30799 cpuid_topo->socket_id = -1;308100 }309101310310- /* update core and thread sibling masks */311311- for_each_possible_cpu(cpu) {312312- struct cputopo_arm *cpu_topo = &cpu_topology[cpu];102102+ update_siblings_masks(cpuid);313103314314- if (cpuid_topo->socket_id == cpu_topo->socket_id) {315315- cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);316316- if (cpu != cpuid)317317- cpumask_set_cpu(cpu,318318- &cpuid_topo->core_sibling);319319-320320- if (cpuid_topo->core_id == cpu_topo->core_id) {321321- cpumask_set_cpu(cpuid,322322- &cpu_topo->thread_sibling);323323- if (cpu != cpuid)324324- cpumask_set_cpu(cpu,325325- &cpuid_topo->thread_sibling);326326- }327327- }328328- }329329- smp_wmb();104104+ update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);330105331106 printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",332107 cpuid, cpu_topology[cpuid].thread_id,···325134{326135 unsigned int cpu;327136328328- /* init core mask */137137+ /* init core mask and power*/329138 for_each_possible_cpu(cpu) {330139 struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]);331140···334143 cpu_topo->socket_id = -1;335144 cpumask_clear(&cpu_topo->core_sibling);336145 cpumask_clear(&cpu_topo->thread_sibling);146146+147147+ set_power_scale(cpu, SCHED_POWER_SCALE);337148 }338149 smp_wmb();150150+151151+ parse_dt_topology();339152}
+55-23
arch/arm/kernel/traps.c
···233233#define S_ISA " ARM"234234#endif235235236236-static int __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs)236236+static int __die(const char *str, int err, struct pt_regs *regs)237237{238238- struct task_struct *tsk = thread->task;238238+ struct task_struct *tsk = current;239239 static int die_counter;240240 int ret;241241···245245 /* trap and error numbers are mostly meaningless on ARM */246246 ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV);247247 if (ret == NOTIFY_STOP)248248- return ret;248248+ return 1;249249250250 print_modules();251251 __show_regs(regs);252252 printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",253253- TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);253253+ TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));254254255255 if (!user_mode(regs) || in_interrupt()) {256256 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,···259259 dump_instr(KERN_EMERG, regs);260260 }261261262262- return ret;262262+ return 0;263263}264264265265-static DEFINE_RAW_SPINLOCK(die_lock);265265+static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;266266+static int die_owner = -1;267267+static unsigned int die_nest_count;266268267267-/*268268- * This function is protected against re-entrancy.269269- */270270-void die(const char *str, struct pt_regs *regs, int err)269269+static unsigned long oops_begin(void)271270{272272- struct thread_info *thread = current_thread_info();273273- int ret;274274- enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;271271+ int cpu;272272+ unsigned long flags;275273276274 oops_enter();277275278278- raw_spin_lock_irq(&die_lock);276276+ /* racy, but better than risking deadlock. */277277+ raw_local_irq_save(flags);278278+ cpu = smp_processor_id();279279+ if (!arch_spin_trylock(&die_lock)) {280280+ if (cpu == die_owner)281281+ /* nested oops. should stop eventually */;282282+ else283283+ arch_spin_lock(&die_lock);284284+ }285285+ die_nest_count++;286286+ die_owner = cpu;279287 console_verbose();280288 bust_spinlocks(1);281281- if (!user_mode(regs))282282- bug_type = report_bug(regs->ARM_pc, regs);283283- if (bug_type != BUG_TRAP_TYPE_NONE)284284- str = "Oops - BUG";285285- ret = __die(str, err, thread, regs);289289+ return flags;290290+}286291287287- if (regs && kexec_should_crash(thread->task))292292+static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)293293+{294294+ if (regs && kexec_should_crash(current))288295 crash_kexec(regs);289296290297 bust_spinlocks(0);298298+ die_owner = -1;291299 add_taint(TAINT_DIE);292292- raw_spin_unlock_irq(&die_lock);300300+ die_nest_count--;301301+ if (!die_nest_count)302302+ /* Nest count reaches zero, release the lock. */303303+ arch_spin_unlock(&die_lock);304304+ raw_local_irq_restore(flags);293305 oops_exit();294306295307 if (in_interrupt())296308 panic("Fatal exception in interrupt");297309 if (panic_on_oops)298310 panic("Fatal exception");299299- if (ret != NOTIFY_STOP)300300- do_exit(SIGSEGV);311311+ if (signr)312312+ do_exit(signr);313313+}314314+315315+/*316316+ * This function is protected against re-entrancy.317317+ */318318+void die(const char *str, struct pt_regs *regs, int err)319319+{320320+ enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;321321+ unsigned long flags = oops_begin();322322+ int sig = SIGSEGV;323323+324324+ if (!user_mode(regs))325325+ bug_type = report_bug(regs->ARM_pc, regs);326326+ if (bug_type != BUG_TRAP_TYPE_NONE)327327+ str = "Oops - BUG";328328+329329+ if (__die(str, err, regs))330330+ sig = 0;331331+332332+ oops_end(flags, regs, sig);301333}302334303335void arm_notify_die(const char *str, struct pt_regs *regs,
···11+/*22+ * Delay loops based on the OpenRISC implementation.33+ *44+ * Copyright (C) 2012 ARM Limited55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License version 2 as88+ * published by the Free Software Foundation.99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program; if not, write to the Free Software1717+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1818+ *1919+ * Author: Will Deacon <will.deacon@arm.com>2020+ */2121+2222+#include <linux/delay.h>2323+#include <linux/init.h>2424+#include <linux/kernel.h>2525+#include <linux/module.h>2626+#include <linux/timex.h>2727+2828+/*2929+ * Default to the loop-based delay implementation.3030+ */3131+struct arm_delay_ops arm_delay_ops = {3232+ .delay = __loop_delay,3333+ .const_udelay = __loop_const_udelay,3434+ .udelay = __loop_udelay,3535+};3636+3737+#ifdef ARCH_HAS_READ_CURRENT_TIMER3838+static void __timer_delay(unsigned long cycles)3939+{4040+ cycles_t start = get_cycles();4141+4242+ while ((get_cycles() - start) < cycles)4343+ cpu_relax();4444+}4545+4646+static void __timer_const_udelay(unsigned long xloops)4747+{4848+ unsigned long long loops = xloops;4949+ loops *= loops_per_jiffy;5050+ __timer_delay(loops >> UDELAY_SHIFT);5151+}5252+5353+static void __timer_udelay(unsigned long usecs)5454+{5555+ __timer_const_udelay(usecs * UDELAY_MULT);5656+}5757+5858+void __init init_current_timer_delay(unsigned long freq)5959+{6060+ pr_info("Switching to timer-based delay loop\n");6161+ lpj_fine = freq / HZ;6262+ arm_delay_ops.delay = __timer_delay;6363+ arm_delay_ops.const_udelay = __timer_const_udelay;6464+ arm_delay_ops.udelay = __timer_udelay;6565+}6666+6767+unsigned long __cpuinit calibrate_delay_is_known(void)6868+{6969+ return lpj_fine;7070+}7171+#endif
-43
arch/arm/lib/strncpy_from_user.S
···11-/*22- * linux/arch/arm/lib/strncpy_from_user.S33- *44- * Copyright (C) 1995-2000 Russell King55- *66- * This program is free software; you can redistribute it and/or modify77- * it under the terms of the GNU General Public License version 2 as88- * published by the Free Software Foundation.99- */1010-#include <linux/linkage.h>1111-#include <asm/assembler.h>1212-#include <asm/errno.h>1313-1414- .text1515- .align 51616-1717-/*1818- * Copy a string from user space to kernel space.1919- * r0 = dst, r1 = src, r2 = byte length2020- * returns the number of characters copied (strlen of copied string),2121- * -EFAULT on exception, or "len" if we fill the whole buffer2222- */2323-ENTRY(__strncpy_from_user)2424- mov ip, r12525-1: subs r2, r2, #12626- ldrusr r3, r1, 1, pl2727- bmi 2f2828- strb r3, [r0], #12929- teq r3, #03030- bne 1b3131- sub r1, r1, #1 @ take NUL character out of count3232-2: sub r0, r1, ip3333- mov pc, lr3434-ENDPROC(__strncpy_from_user)3535-3636- .pushsection .fixup,"ax"3737- .align 03838-9001: mov r3, #03939- strb r3, [r0, #0] @ null terminate4040- mov r0, #-EFAULT4141- mov pc, lr4242- .popsection4343-
-40
arch/arm/lib/strnlen_user.S
···11-/*22- * linux/arch/arm/lib/strnlen_user.S33- *44- * Copyright (C) 1995-2000 Russell King55- *66- * This program is free software; you can redistribute it and/or modify77- * it under the terms of the GNU General Public License version 2 as88- * published by the Free Software Foundation.99- */1010-#include <linux/linkage.h>1111-#include <asm/assembler.h>1212-#include <asm/errno.h>1313-1414- .text1515- .align 51616-1717-/* Prototype: unsigned long __strnlen_user(const char *str, long n)1818- * Purpose : get length of a string in user memory1919- * Params : str - address of string in user memory2020- * Returns : length of string *including terminator*2121- * or zero on exception, or n + 1 if too long2222- */2323-ENTRY(__strnlen_user)2424- mov r2, r02525-1:2626- ldrusr r3, r0, 12727- teq r3, #02828- beq 2f2929- subs r1, r1, #13030- bne 1b3131- add r0, r0, #13232-2: sub r0, r0, r23333- mov pc, lr3434-ENDPROC(__strnlen_user)3535-3636- .pushsection .fixup,"ax"3737- .align 03838-9001: mov r0, #03939- mov pc, lr4040- .popsection
+1-1
arch/arm/mach-msm/platsmp.c
···127127 * the boot monitor to read the system wide flags register,128128 * and branch to the address found there.129129 */130130- gic_raise_softirq(cpumask_of(cpu), 1);130130+ gic_raise_softirq(cpumask_of(cpu), 0);131131132132 timeout = jiffies + (1 * HZ);133133 while (time_before(jiffies, timeout)) {
+1-1
arch/arm/mach-omap2/omap-smp.c
···111111 booted = true;112112 }113113114114- gic_raise_softirq(cpumask_of(cpu), 1);114114+ gic_raise_softirq(cpumask_of(cpu), 0);115115116116 /*117117 * Now the secondary core is starting up let it run its
+11-11
arch/arm/mach-pxa/include/mach/regs-ost.h
···77 * OS Timer & Match Registers88 */991010-#define OSMR0 __REG(0x40A00000) /* */1111-#define OSMR1 __REG(0x40A00004) /* */1212-#define OSMR2 __REG(0x40A00008) /* */1313-#define OSMR3 __REG(0x40A0000C) /* */1414-#define OSMR4 __REG(0x40A00080) /* */1515-#define OSCR __REG(0x40A00010) /* OS Timer Counter Register */1616-#define OSCR4 __REG(0x40A00040) /* OS Timer Counter Register */1717-#define OMCR4 __REG(0x40A000C0) /* */1818-#define OSSR __REG(0x40A00014) /* OS Timer Status Register */1919-#define OWER __REG(0x40A00018) /* OS Timer Watchdog Enable Register */2020-#define OIER __REG(0x40A0001C) /* OS Timer Interrupt Enable Register */1010+#define OSMR0 io_p2v(0x40A00000) /* */1111+#define OSMR1 io_p2v(0x40A00004) /* */1212+#define OSMR2 io_p2v(0x40A00008) /* */1313+#define OSMR3 io_p2v(0x40A0000C) /* */1414+#define OSMR4 io_p2v(0x40A00080) /* */1515+#define OSCR io_p2v(0x40A00010) /* OS Timer Counter Register */1616+#define OSCR4 io_p2v(0x40A00040) /* OS Timer Counter Register */1717+#define OMCR4 io_p2v(0x40A000C0) /* */1818+#define OSSR io_p2v(0x40A00014) /* OS Timer Status Register */1919+#define OWER io_p2v(0x40A00018) /* OS Timer Watchdog Enable Register */2020+#define OIER io_p2v(0x40A0001C) /* OS Timer Interrupt Enable Register */21212222#define OSSR_M3 (1 << 3) /* Match status channel 3 */2323#define OSSR_M2 (1 << 2) /* Match status channel 2 */
+4-3
arch/arm/mach-pxa/reset.c
···7777static void do_hw_reset(void)7878{7979 /* Initialize the watchdog and let it fire */8080- OWER = OWER_WME;8181- OSSR = OSSR_M3;8282- OSMR3 = OSCR + 368640; /* ... in 100 ms */8080+ writel_relaxed(OWER_WME, OWER);8181+ writel_relaxed(OSSR_M3, OSSR);8282+ /* ... in 100 ms */8383+ writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);8384}84858586void pxa_restart(char mode, const char *cmd)
···8899#include "hardware.h"10101111+#define IOMEM(x) (x)1212+1113/*1214 * The following code assumes the serial port has already been1315 * initialized by the bootloader. We search for the first enabled
···1010 * pace of the LED.1111 */1212#include <linux/init.h>1313+#include <linux/io.h>13141415#include <mach/hardware.h>1516#include <asm/leds.h>
+1
arch/arm/mach-sa1100/pm.c
···2323 * Storage is local on the stack now.2424 */2525#include <linux/init.h>2626+#include <linux/io.h>2627#include <linux/suspend.h>2728#include <linux/errno.h>2829#include <linux/time.h>
+4-4
arch/arm/mach-sa1100/sleep.S
···3838 orr r4, r4, #MDREFR_K1DB23939 ldr r5, =PPCR40404141- @ Pre-load __udelay into the I-cache4141+ @ Pre-load __loop_udelay into the I-cache4242 mov r0, #14343- bl __udelay4343+ bl __loop_udelay4444 mov r0, r045454646 @ The following must all exist in a single cache line to···5353 @ delay 90us and set CPU PLL to lowest speed5454 @ fixes resume problem on high speed SA11105555 mov r0, #905656- bl __udelay5656+ bl __loop_udelay5757 mov r1, #05858 str r1, [r5]5959 mov r0, #906060- bl __udelay6060+ bl __loop_udelay61616262 /*6363 * SA1110 SDRAM controller workaround. register values:
···2323#include <asm/ptrace.h>24242525#ifdef CONFIG_HW_PERF_EVENTS2626+2727+/*2828+ * OProfile has a curious naming scheme for the ARM PMUs, but they are2929+ * part of the user ABI so we need to map from the perf PMU name for3030+ * supported PMUs.3131+ */3232+static struct op_perf_name {3333+ char *perf_name;3434+ char *op_name;3535+} op_perf_name_map[] = {3636+ { "xscale1", "arm/xscale1" },3737+ { "xscale1", "arm/xscale2" },3838+ { "v6", "arm/armv6" },3939+ { "v6mpcore", "arm/mpcore" },4040+ { "ARMv7 Cortex-A8", "arm/armv7" },4141+ { "ARMv7 Cortex-A9", "arm/armv7-ca9" },4242+};4343+2644char *op_name_from_perf_id(void)2745{2828- enum arm_perf_pmu_ids id = armpmu_get_pmu_id();4646+ int i;4747+ struct op_perf_name names;4848+ const char *perf_name = perf_pmu_name();29493030- switch (id) {3131- case ARM_PERF_PMU_ID_XSCALE1:3232- return "arm/xscale1";3333- case ARM_PERF_PMU_ID_XSCALE2:3434- return "arm/xscale2";3535- case ARM_PERF_PMU_ID_V6:3636- return "arm/armv6";3737- case ARM_PERF_PMU_ID_V6MP:3838- return "arm/mpcore";3939- case ARM_PERF_PMU_ID_CA8:4040- return "arm/armv7";4141- case ARM_PERF_PMU_ID_CA9:4242- return "arm/armv7-ca9";4343- default:4444- return NULL;5050+ for (i = 0; i < ARRAY_SIZE(op_perf_name_map); ++i) {5151+ names = op_perf_name_map[i];5252+ if (!strcmp(names.perf_name, perf_name))5353+ return names.op_name;4554 }5555+5656+ return NULL;4657}4758#endif4859
+1-1
arch/arm/plat-versatile/platsmp.c
···8585 * the boot monitor to read the system wide flags register,8686 * and branch to the address found there.8787 */8888- gic_raise_softirq(cpumask_of(cpu), 1);8888+ gic_raise_softirq(cpumask_of(cpu), 0);89899090 timeout = jiffies + (1 * HZ);9191 while (time_before(jiffies, timeout)) {
···11-/*22- * linux/include/asm-generic/sizes.h33- *44- * This program is free software; you can redistribute it and/or modify55- * it under the terms of the GNU General Public License version 2 as66- * published by the Free Software Foundation.77- */88-#ifndef __ASM_GENERIC_SIZES_H__99-#define __ASM_GENERIC_SIZES_H__1010-1111-#define SZ_1 0x000000011212-#define SZ_2 0x000000021313-#define SZ_4 0x000000041414-#define SZ_8 0x000000081515-#define SZ_16 0x000000101616-#define SZ_32 0x000000201717-#define SZ_64 0x000000401818-#define SZ_128 0x000000801919-#define SZ_256 0x000001002020-#define SZ_512 0x000002002121-2222-#define SZ_1K 0x000004002323-#define SZ_2K 0x000008002424-#define SZ_4K 0x000010002525-#define SZ_8K 0x000020002626-#define SZ_16K 0x000040002727-#define SZ_32K 0x000080002828-#define SZ_64K 0x000100002929-#define SZ_128K 0x000200003030-#define SZ_256K 0x000400003131-#define SZ_512K 0x000800003232-3333-#define SZ_1M 0x001000003434-#define SZ_2M 0x002000003535-#define SZ_4M 0x004000003636-#define SZ_8M 0x008000003737-#define SZ_16M 0x010000003838-#define SZ_32M 0x020000003939-#define SZ_64M 0x040000004040-#define SZ_128M 0x080000004141-#define SZ_256M 0x100000004242-#define SZ_512M 0x200000004343-4444-#define SZ_1G 0x400000004545-#define SZ_2G 0x800000004646-4747-#endif /* __ASM_GENERIC_SIZES_H__ */11+/* This is a placeholder, to be removed over time */22+#include <linux/sizes.h>
+47
include/linux/sizes.h
···11+/*22+ * include/linux/sizes.h33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License version 2 as66+ * published by the Free Software Foundation.77+ */88+#ifndef __LINUX_SIZES_H__99+#define __LINUX_SIZES_H__1010+1111+#define SZ_1 0x000000011212+#define SZ_2 0x000000021313+#define SZ_4 0x000000041414+#define SZ_8 0x000000081515+#define SZ_16 0x000000101616+#define SZ_32 0x000000201717+#define SZ_64 0x000000401818+#define SZ_128 0x000000801919+#define SZ_256 0x000001002020+#define SZ_512 0x000002002121+2222+#define SZ_1K 0x000004002323+#define SZ_2K 0x000008002424+#define SZ_4K 0x000010002525+#define SZ_8K 0x000020002626+#define SZ_16K 0x000040002727+#define SZ_32K 0x000080002828+#define SZ_64K 0x000100002929+#define SZ_128K 0x000200003030+#define SZ_256K 0x000400003131+#define SZ_512K 0x000800003232+3333+#define SZ_1M 0x001000003434+#define SZ_2M 0x002000003535+#define SZ_4M 0x004000003636+#define SZ_8M 0x008000003737+#define SZ_16M 0x010000003838+#define SZ_32M 0x020000003939+#define SZ_64M 0x040000004040+#define SZ_128M 0x080000004141+#define SZ_256M 0x100000004242+#define SZ_512M 0x200000004343+4444+#define SZ_1G 0x400000004545+#define SZ_2G 0x800000004646+4747+#endif /* __LINUX_SIZES_H__ */