Skip to content

Commit 82b5173

Browse files
committed
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull ARM64 updates from Catalin Marinas: - CPU suspend support on top of PSCI (firmware Power State Coordination Interface) - jump label support - CMA can now be enabled on arm64 - HWCAP bits for crypto and CRC32 extensions - optimised percpu using tpidr_el1 register - code cleanup * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (42 commits) arm64: fix typo in entry.S arm64: kernel: restore HW breakpoint registers in cpu_suspend jump_label: use defined macros instead of hard-coding for better readability arm64, jump label: optimize jump label implementation arm64, jump label: detect %c support for ARM64 arm64: introduce aarch64_insn_gen_{nop|branch_imm}() helper functions arm64: move encode_insn_immediate() from module.c to insn.c arm64: introduce interfaces to hotpatch kernel and module code arm64: introduce basic aarch64 instruction decoding helpers arm64: dts: Reduce size of virtio block device for foundation model arm64: Remove unused __data_loc variable arm64: Enable CMA arm64: Warn on NULL device structure for dma APIs arm64: Add hwcaps for crypto and CRC32 extensions. arm64: drop redundant macros from read_cpuid() arm64: Remove outdated comment arm64: cmpxchg: update macros to prevent warnings arm64: support single-step and breakpoint handler hooks ARM64: fix framepointer check in unwind_frame ARM64: check stack pointer in get_wchan ...
2 parents 15c8102 + 883c057 commit 82b5173

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1859
-403
lines changed

arch/arm/kvm/arm.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <linux/cpu.h>
20+
#include <linux/cpu_pm.h>
2021
#include <linux/errno.h>
2122
#include <linux/err.h>
2223
#include <linux/kvm_host.h>
@@ -853,6 +854,33 @@ static struct notifier_block hyp_init_cpu_nb = {
853854
.notifier_call = hyp_init_cpu_notify,
854855
};
855856

857+
#ifdef CONFIG_CPU_PM
858+
static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
859+
unsigned long cmd,
860+
void *v)
861+
{
862+
if (cmd == CPU_PM_EXIT) {
863+
cpu_init_hyp_mode(NULL);
864+
return NOTIFY_OK;
865+
}
866+
867+
return NOTIFY_DONE;
868+
}
869+
870+
static struct notifier_block hyp_init_cpu_pm_nb = {
871+
.notifier_call = hyp_init_cpu_pm_notifier,
872+
};
873+
874+
static void __init hyp_cpu_pm_init(void)
875+
{
876+
cpu_pm_register_notifier(&hyp_init_cpu_pm_nb);
877+
}
878+
#else
879+
static inline void hyp_cpu_pm_init(void)
880+
{
881+
}
882+
#endif
883+
856884
/**
857885
* Inits Hyp-mode on all online CPUs
858886
*/
@@ -1013,6 +1041,8 @@ int kvm_arch_init(void *opaque)
10131041
goto out_err;
10141042
}
10151043

1044+
hyp_cpu_pm_init();
1045+
10161046
kvm_coproc_table_init();
10171047
return 0;
10181048
out_err:

arch/arm64/Kconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ config ARM64
22
def_bool y
33
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
44
select ARCH_USE_CMPXCHG_LOCKREF
5+
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
56
select ARCH_WANT_OPTIONAL_GPIOLIB
67
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
78
select ARCH_WANT_FRAME_POINTERS
@@ -11,19 +12,27 @@ config ARM64
1112
select BUILDTIME_EXTABLE_SORT
1213
select CLONE_BACKWARDS
1314
select COMMON_CLK
15+
select CPU_PM if (SUSPEND || CPU_IDLE)
16+
select DCACHE_WORD_ACCESS
1417
select GENERIC_CLOCKEVENTS
18+
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
1519
select GENERIC_IOMAP
1620
select GENERIC_IRQ_PROBE
1721
select GENERIC_IRQ_SHOW
1822
select GENERIC_SCHED_CLOCK
1923
select GENERIC_SMP_IDLE_THREAD
24+
select GENERIC_STRNCPY_FROM_USER
25+
select GENERIC_STRNLEN_USER
2026
select GENERIC_TIME_VSYSCALL
2127
select HARDIRQS_SW_RESEND
28+
select HAVE_ARCH_JUMP_LABEL
2229
select HAVE_ARCH_TRACEHOOK
2330
select HAVE_DEBUG_BUGVERBOSE
2431
select HAVE_DEBUG_KMEMLEAK
2532
select HAVE_DMA_API_DEBUG
2633
select HAVE_DMA_ATTRS
34+
select HAVE_DMA_CONTIGUOUS
35+
select HAVE_EFFICIENT_UNALIGNED_ACCESS
2736
select HAVE_GENERIC_DMA_COHERENT
2837
select HAVE_HW_BREAKPOINT if PERF_EVENTS
2938
select HAVE_MEMBLOCK
@@ -275,6 +284,24 @@ config SYSVIPC_COMPAT
275284

276285
endmenu
277286

287+
menu "Power management options"
288+
289+
source "kernel/power/Kconfig"
290+
291+
config ARCH_SUSPEND_POSSIBLE
292+
def_bool y
293+
294+
config ARM64_CPU_SUSPEND
295+
def_bool PM_SLEEP
296+
297+
endmenu
298+
299+
menu "CPU Power Management"
300+
301+
source "drivers/cpuidle/Kconfig"
302+
303+
endmenu
304+
278305
source "net/Kconfig"
279306

280307
source "drivers/Kconfig"

arch/arm64/boot/dts/foundation-v8.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224

225225
virtio_block@0130000 {
226226
compatible = "virtio,mmio";
227-
reg = <0x130000 0x1000>;
227+
reg = <0x130000 0x200>;
228228
interrupts = <42>;
229229
};
230230
};

arch/arm64/boot/dts/rtsm_ve-motherboard.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@
183183
clocks = <&v2m_oscclk1>, <&v2m_clk24mhz>;
184184
clock-names = "clcdclk", "apb_pclk";
185185
};
186+
187+
virtio_block@0130000 {
188+
compatible = "virtio,mmio";
189+
reg = <0x130000 0x200>;
190+
interrupts = <42>;
191+
};
186192
};
187193

188194
v2m_fixed_3v3: fixedregulator@0 {

arch/arm64/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ generic-y += mman.h
2626
generic-y += msgbuf.h
2727
generic-y += mutex.h
2828
generic-y += pci.h
29-
generic-y += percpu.h
3029
generic-y += poll.h
3130
generic-y += posix_types.h
3231
generic-y += resource.h

arch/arm64/include/asm/cmpxchg.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
158158
return ret;
159159
}
160160

161-
#define cmpxchg(ptr,o,n) \
162-
((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
163-
(unsigned long)(o), \
164-
(unsigned long)(n), \
165-
sizeof(*(ptr))))
166-
167-
#define cmpxchg_local(ptr,o,n) \
168-
((__typeof__(*(ptr)))__cmpxchg((ptr), \
169-
(unsigned long)(o), \
170-
(unsigned long)(n), \
171-
sizeof(*(ptr))))
161+
#define cmpxchg(ptr, o, n) \
162+
({ \
163+
__typeof__(*(ptr)) __ret; \
164+
__ret = (__typeof__(*(ptr))) \
165+
__cmpxchg_mb((ptr), (unsigned long)(o), (unsigned long)(n), \
166+
sizeof(*(ptr))); \
167+
__ret; \
168+
})
169+
170+
#define cmpxchg_local(ptr, o, n) \
171+
({ \
172+
__typeof__(*(ptr)) __ret; \
173+
__ret = (__typeof__(*(ptr))) \
174+
__cmpxchg((ptr), (unsigned long)(o), \
175+
(unsigned long)(n), sizeof(*(ptr))); \
176+
__ret; \
177+
})
172178

173179
#define cmpxchg64(ptr,o,n) cmpxchg((ptr),(o),(n))
174180
#define cmpxchg64_local(ptr,o,n) cmpxchg_local((ptr),(o),(n))

arch/arm64/include/asm/cpu_ops.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ struct device_node;
3939
* from the cpu to be killed.
4040
* @cpu_die: Makes a cpu leave the kernel. Must not fail. Called from the
4141
* cpu being killed.
42+
* @cpu_suspend: Suspends a cpu and saves the required context. May fail owing
43+
* to wrong parameters or error conditions. Called from the
44+
* CPU being suspended. Must be called with IRQs disabled.
4245
*/
4346
struct cpu_operations {
4447
const char *name;
@@ -50,6 +53,9 @@ struct cpu_operations {
5053
int (*cpu_disable)(unsigned int cpu);
5154
void (*cpu_die)(unsigned int cpu);
5255
#endif
56+
#ifdef CONFIG_ARM64_CPU_SUSPEND
57+
int (*cpu_suspend)(unsigned long);
58+
#endif
5359
};
5460

5561
extern const struct cpu_operations *cpu_ops[NR_CPUS];

arch/arm64/include/asm/cputype.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
#ifndef __ASM_CPUTYPE_H
1717
#define __ASM_CPUTYPE_H
1818

19-
#define ID_MIDR_EL1 "midr_el1"
20-
#define ID_MPIDR_EL1 "mpidr_el1"
21-
#define ID_CTR_EL0 "ctr_el0"
22-
23-
#define ID_AA64PFR0_EL1 "id_aa64pfr0_el1"
24-
#define ID_AA64DFR0_EL1 "id_aa64dfr0_el1"
25-
#define ID_AA64AFR0_EL1 "id_aa64afr0_el1"
26-
#define ID_AA64ISAR0_EL1 "id_aa64isar0_el1"
27-
#define ID_AA64MMFR0_EL1 "id_aa64mmfr0_el1"
28-
2919
#define INVALID_HWID ULONG_MAX
3020

3121
#define MPIDR_HWID_BITMASK 0xff00ffffff
3222

23+
#define MPIDR_LEVEL_BITS_SHIFT 3
24+
#define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT)
25+
#define MPIDR_LEVEL_MASK ((1 << MPIDR_LEVEL_BITS) - 1)
26+
27+
#define MPIDR_LEVEL_SHIFT(level) \
28+
(((1 << level) >> 1) << MPIDR_LEVEL_BITS_SHIFT)
29+
30+
#define MPIDR_AFFINITY_LEVEL(mpidr, level) \
31+
((mpidr >> MPIDR_LEVEL_SHIFT(level)) & MPIDR_LEVEL_MASK)
32+
3333
#define read_cpuid(reg) ({ \
3434
u64 __val; \
35-
asm("mrs %0, " reg : "=r" (__val)); \
35+
asm("mrs %0, " #reg : "=r" (__val)); \
3636
__val; \
3737
})
3838

@@ -54,12 +54,12 @@
5454
*/
5555
static inline u32 __attribute_const__ read_cpuid_id(void)
5656
{
57-
return read_cpuid(ID_MIDR_EL1);
57+
return read_cpuid(MIDR_EL1);
5858
}
5959

6060
static inline u64 __attribute_const__ read_cpuid_mpidr(void)
6161
{
62-
return read_cpuid(ID_MPIDR_EL1);
62+
return read_cpuid(MPIDR_EL1);
6363
}
6464

6565
static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
@@ -74,7 +74,7 @@ static inline unsigned int __attribute_const__ read_cpuid_part_number(void)
7474

7575
static inline u32 __attribute_const__ read_cpuid_cachetype(void)
7676
{
77-
return read_cpuid(ID_CTR_EL0);
77+
return read_cpuid(CTR_EL0);
7878
}
7979

8080
#endif /* __ASSEMBLY__ */

arch/arm64/include/asm/debug-monitors.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ struct task_struct;
6262

6363
#define DBG_ARCH_ID_RESERVED 0 /* In case of ptrace ABI updates. */
6464

65+
#define DBG_HOOK_HANDLED 0
66+
#define DBG_HOOK_ERROR 1
67+
68+
struct step_hook {
69+
struct list_head node;
70+
int (*fn)(struct pt_regs *regs, unsigned int esr);
71+
};
72+
73+
void register_step_hook(struct step_hook *hook);
74+
void unregister_step_hook(struct step_hook *hook);
75+
76+
struct break_hook {
77+
struct list_head node;
78+
u32 esr_val;
79+
u32 esr_mask;
80+
int (*fn)(struct pt_regs *regs, unsigned int esr);
81+
};
82+
83+
void register_break_hook(struct break_hook *hook);
84+
void unregister_break_hook(struct break_hook *hook);
85+
6586
u8 debug_monitors_arch(void);
6687

6788
void enable_debug_monitors(enum debug_el el);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 and
6+
* only version 2 as published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*/
13+
14+
#ifndef _ASM_DMA_CONTIGUOUS_H
15+
#define _ASM_DMA_CONTIGUOUS_H
16+
17+
#ifdef __KERNEL__
18+
#ifdef CONFIG_DMA_CMA
19+
20+
#include <linux/types.h>
21+
#include <asm-generic/dma-contiguous.h>
22+
23+
static inline void
24+
dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { }
25+
26+
#endif
27+
#endif
28+
29+
#endif

arch/arm64/include/asm/futex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
" cbnz %w3, 1b\n" \
3131
"3:\n" \
3232
" .pushsection .fixup,\"ax\"\n" \
33+
" .align 2\n" \
3334
"4: mov %w0, %w5\n" \
3435
" b 3b\n" \
3536
" .popsection\n" \

arch/arm64/include/asm/hardirq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/threads.h>
2121
#include <asm/irq.h>
2222

23-
#define NR_IPI 4
23+
#define NR_IPI 5
2424

2525
typedef struct {
2626
unsigned int __softirq_pending;

0 commit comments

Comments
 (0)