Skip to content

Commit cd16ed3

Browse files
committed
Merge tag 'riscv-for-linus-5.8-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull more RISC-V updates from Palmer Dabbelt: - Kconfig select statements are now sorted alphanumerically - first-level interrupts are now handled via a full irqchip driver - CPU hotplug is fixed - vDSO calls now use the common vDSO infrastructure * tag 'riscv-for-linus-5.8-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: set the permission of vdso_data to read-only riscv: use vDSO common flow to reduce the latency of the time-related functions riscv: fix build warning of missing prototypes RISC-V: Don't mark init section as non-executable RISC-V: Force select RISCV_INTC for CONFIG_RISCV RISC-V: Remove do_IRQ() function clocksource/drivers/timer-riscv: Use per-CPU timer interrupt irqchip: RISC-V per-HART local interrupt controller driver RISC-V: Rename and move plic_find_hart_id() to arch directory RISC-V: self-contained IPI handling routine RISC-V: Sort select statements alphanumerically
2 parents 55d728b + 01f7638 commit cd16ed3

31 files changed

+500
-183
lines changed

arch/riscv/Kconfig

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,70 @@ config 32BIT
1212

1313
config RISCV
1414
def_bool y
15-
select OF
16-
select OF_EARLY_FLATTREE
17-
select OF_IRQ
15+
select ARCH_CLOCKSOURCE_INIT
1816
select ARCH_HAS_BINFMT_FLAT
17+
select ARCH_HAS_DEBUG_VIRTUAL if MMU
1918
select ARCH_HAS_DEBUG_WX
19+
select ARCH_HAS_GCOV_PROFILE_ALL
20+
select ARCH_HAS_GIGANTIC_PAGE
21+
select ARCH_HAS_MMIOWB
22+
select ARCH_HAS_PTE_SPECIAL
23+
select ARCH_HAS_SET_DIRECT_MAP
24+
select ARCH_HAS_SET_MEMORY
25+
select ARCH_HAS_STRICT_KERNEL_RWX if MMU
26+
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
2027
select ARCH_WANT_FRAME_POINTERS
28+
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
2129
select CLONE_BACKWARDS
2230
select COMMON_CLK
31+
select EDAC_SUPPORT
32+
select GENERIC_ARCH_TOPOLOGY if SMP
33+
select GENERIC_ATOMIC64 if !64BIT
2334
select GENERIC_CLOCKEVENTS
35+
select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
36+
select GENERIC_IOREMAP
37+
select GENERIC_IRQ_MULTI_HANDLER
2438
select GENERIC_IRQ_SHOW
2539
select GENERIC_PCI_IOMAP
40+
select GENERIC_PTDUMP if MMU
2641
select GENERIC_SCHED_CLOCK
42+
select GENERIC_SMP_IDLE_THREAD
2743
select GENERIC_STRNCPY_FROM_USER if MMU
2844
select GENERIC_STRNLEN_USER if MMU
29-
select GENERIC_SMP_IDLE_THREAD
30-
select GENERIC_ATOMIC64 if !64BIT
31-
select GENERIC_IOREMAP
32-
select GENERIC_PTDUMP if MMU
45+
select GENERIC_TIME_VSYSCALL if MMU && 64BIT
46+
select HANDLE_DOMAIN_IRQ
3347
select HAVE_ARCH_AUDITSYSCALL
48+
select HAVE_ARCH_KASAN if MMU && 64BIT
49+
select HAVE_ARCH_KGDB
50+
select HAVE_ARCH_KGDB_QXFER_PKT
51+
select HAVE_ARCH_MMAP_RND_BITS if MMU
3452
select HAVE_ARCH_SECCOMP_FILTER
53+
select HAVE_ARCH_TRACEHOOK
3554
select HAVE_ASM_MODVERSIONS
55+
select HAVE_COPY_THREAD_TLS
3656
select HAVE_DMA_CONTIGUOUS if MMU
57+
select HAVE_EBPF_JIT if MMU
3758
select HAVE_FUTEX_CMPXCHG if FUTEX
59+
select HAVE_GENERIC_VDSO if MMU && 64BIT
60+
select HAVE_PCI
3861
select HAVE_PERF_EVENTS
3962
select HAVE_PERF_REGS
4063
select HAVE_PERF_USER_STACK_DUMP
4164
select HAVE_SYSCALL_TRACEPOINTS
4265
select IRQ_DOMAIN
43-
select SPARSE_IRQ
44-
select SYSCTL_EXCEPTION_TRACE
45-
select HAVE_ARCH_TRACEHOOK
46-
select HAVE_PCI
4766
select MODULES_USE_ELF_RELA if MODULES
4867
select MODULE_SECTIONS if MODULES
49-
select THREAD_INFO_IN_TASK
68+
select OF
69+
select OF_EARLY_FLATTREE
70+
select OF_IRQ
5071
select PCI_DOMAINS_GENERIC if PCI
5172
select PCI_MSI if PCI
73+
select RISCV_INTC
5274
select RISCV_TIMER
53-
select GENERIC_IRQ_MULTI_HANDLER
54-
select GENERIC_ARCH_TOPOLOGY if SMP
55-
select ARCH_HAS_PTE_SPECIAL
56-
select ARCH_HAS_MMIOWB
57-
select ARCH_HAS_DEBUG_VIRTUAL if MMU
58-
select HAVE_EBPF_JIT if MMU
59-
select EDAC_SUPPORT
60-
select ARCH_HAS_GIGANTIC_PAGE
61-
select ARCH_HAS_SET_DIRECT_MAP
62-
select ARCH_HAS_SET_MEMORY
63-
select ARCH_HAS_STRICT_KERNEL_RWX if MMU
64-
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
6575
select SPARSEMEM_STATIC if 32BIT
66-
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
67-
select HAVE_ARCH_MMAP_RND_BITS if MMU
68-
select ARCH_HAS_GCOV_PROFILE_ALL
69-
select HAVE_COPY_THREAD_TLS
70-
select HAVE_ARCH_KASAN if MMU && 64BIT
71-
select HAVE_ARCH_KGDB
72-
select HAVE_ARCH_KGDB_QXFER_PKT
76+
select SPARSE_IRQ
77+
select SYSCTL_EXCEPTION_TRACE
78+
select THREAD_INFO_IN_TASK
7379

7480
config ARCH_MMAP_RND_BITS_MIN
7581
default 18 if 64BIT
@@ -196,11 +202,11 @@ config ARCH_RV64I
196202
bool "RV64I"
197203
select 64BIT
198204
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000
199-
select HAVE_FUNCTION_TRACER
200-
select HAVE_FUNCTION_GRAPH_TRACER
201-
select HAVE_FTRACE_MCOUNT_RECORD
202205
select HAVE_DYNAMIC_FTRACE if MMU
203206
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
207+
select HAVE_FTRACE_MCOUNT_RECORD
208+
select HAVE_FUNCTION_GRAPH_TRACER
209+
select HAVE_FUNCTION_TRACER
204210
select SWIOTLB if MMU
205211

206212
endchoice

arch/riscv/include/asm/clocksource.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_CLOCKSOURCE_H
3+
#define _ASM_CLOCKSOURCE_H
4+
5+
#include <asm/vdso/clocksource.h>
6+
7+
#endif

arch/riscv/include/asm/irq.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
#include <linux/interrupt.h>
1111
#include <linux/linkage.h>
1212

13-
#define NR_IRQS 0
14-
15-
void riscv_timer_interrupt(void);
16-
void riscv_software_interrupt(void);
17-
1813
#include <asm-generic/irq.h>
1914

2015
#endif /* _ASM_RISCV_IRQ_H */

arch/riscv/include/asm/processor.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <linux/const.h>
1010

11+
#include <vdso/processor.h>
12+
1113
#include <asm/ptrace.h>
1214

1315
/*
@@ -58,23 +60,14 @@ static inline void release_thread(struct task_struct *dead_task)
5860
extern unsigned long get_wchan(struct task_struct *p);
5961

6062

61-
static inline void cpu_relax(void)
62-
{
63-
#ifdef __riscv_muldiv
64-
int dummy;
65-
/* In lieu of a halt instruction, induce a long-latency stall. */
66-
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
67-
#endif
68-
barrier();
69-
}
70-
7163
static inline void wait_for_interrupt(void)
7264
{
7365
__asm__ __volatile__ ("wfi");
7466
}
7567

7668
struct device_node;
7769
int riscv_of_processor_hartid(struct device_node *node);
70+
int riscv_of_parent_hartid(struct device_node *node);
7871

7972
extern void riscv_fill_hwcap(void);
8073

arch/riscv/include/asm/smp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ void show_ipi_stats(struct seq_file *p, int prec);
2828
/* SMP initialization hook for setup_arch */
2929
void __init setup_smp(void);
3030

31+
/* Called from C code, this handles an IPI. */
32+
void handle_IPI(struct pt_regs *regs);
33+
3134
/* Hook for the generic smp_call_function_many() routine. */
3235
void arch_send_call_function_ipi_mask(struct cpumask *mask);
3336

arch/riscv/include/asm/vdso.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
#include <linux/types.h>
1212

13+
#ifndef GENERIC_TIME_VSYSCALL
1314
struct vdso_data {
1415
};
16+
#endif
1517

1618
/*
1719
* The VDSO symbols are mapped into Linux so we can just use regular symbol
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_VDSOCLOCKSOURCE_H
3+
#define __ASM_VDSOCLOCKSOURCE_H
4+
5+
#define VDSO_ARCH_CLOCKMODES \
6+
VDSO_CLOCKMODE_ARCHTIMER
7+
8+
#endif
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_VDSO_GETTIMEOFDAY_H
3+
#define __ASM_VDSO_GETTIMEOFDAY_H
4+
5+
#ifndef __ASSEMBLY__
6+
7+
#include <asm/unistd.h>
8+
#include <asm/csr.h>
9+
#include <uapi/linux/time.h>
10+
11+
#define VDSO_HAS_CLOCK_GETRES 1
12+
13+
static __always_inline
14+
int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
15+
struct timezone *_tz)
16+
{
17+
register struct __kernel_old_timeval *tv asm("a0") = _tv;
18+
register struct timezone *tz asm("a1") = _tz;
19+
register long ret asm("a0");
20+
register long nr asm("a7") = __NR_gettimeofday;
21+
22+
asm volatile ("ecall\n"
23+
: "=r" (ret)
24+
: "r"(tv), "r"(tz), "r"(nr)
25+
: "memory");
26+
27+
return ret;
28+
}
29+
30+
static __always_inline
31+
long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
32+
{
33+
register clockid_t clkid asm("a0") = _clkid;
34+
register struct __kernel_timespec *ts asm("a1") = _ts;
35+
register long ret asm("a0");
36+
register long nr asm("a7") = __NR_clock_gettime;
37+
38+
asm volatile ("ecall\n"
39+
: "=r" (ret)
40+
: "r"(clkid), "r"(ts), "r"(nr)
41+
: "memory");
42+
43+
return ret;
44+
}
45+
46+
static __always_inline
47+
int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
48+
{
49+
register clockid_t clkid asm("a0") = _clkid;
50+
register struct __kernel_timespec *ts asm("a1") = _ts;
51+
register long ret asm("a0");
52+
register long nr asm("a7") = __NR_clock_getres;
53+
54+
asm volatile ("ecall\n"
55+
: "=r" (ret)
56+
: "r"(clkid), "r"(ts), "r"(nr)
57+
: "memory");
58+
59+
return ret;
60+
}
61+
62+
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
63+
{
64+
/*
65+
* The purpose of csr_read(CSR_TIME) is to trap the system into
66+
* M-mode to obtain the value of CSR_TIME. Hence, unlike other
67+
* architecture, no fence instructions surround the csr_read()
68+
*/
69+
return csr_read(CSR_TIME);
70+
}
71+
72+
static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
73+
{
74+
return _vdso_data;
75+
}
76+
77+
#endif /* !__ASSEMBLY__ */
78+
79+
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef __ASM_VDSO_PROCESSOR_H
3+
#define __ASM_VDSO_PROCESSOR_H
4+
5+
#ifndef __ASSEMBLY__
6+
7+
static inline void cpu_relax(void)
8+
{
9+
#ifdef __riscv_muldiv
10+
int dummy;
11+
/* In lieu of a halt instruction, induce a long-latency stall. */
12+
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
13+
#endif
14+
barrier();
15+
}
16+
17+
#endif /* __ASSEMBLY__ */
18+
19+
#endif /* __ASM_VDSO_PROCESSOR_H */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_VDSO_VSYSCALL_H
3+
#define __ASM_VDSO_VSYSCALL_H
4+
5+
#ifndef __ASSEMBLY__
6+
7+
#include <linux/timekeeper_internal.h>
8+
#include <vdso/datapage.h>
9+
10+
extern struct vdso_data *vdso_data;
11+
12+
/*
13+
* Update the vDSO data page to keep in sync with kernel timekeeping.
14+
*/
15+
static __always_inline struct vdso_data *__riscv_get_k_vdso_data(void)
16+
{
17+
return vdso_data;
18+
}
19+
20+
#define __arch_get_k_vdso_data __riscv_get_k_vdso_data
21+
22+
/* The asm-generic header needs to be included after the definitions above */
23+
#include <asm-generic/vdso/vsyscall.h>
24+
25+
#endif /* !__ASSEMBLY__ */
26+
27+
#endif /* __ASM_VDSO_VSYSCALL_H */

0 commit comments

Comments
 (0)