Skip to content

Commit 64275e9

Browse files
committed
Merge tag 'loongarch-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch updates from Huacai Chen: - Select HAVE_CMPXCHG_{LOCAL,DOUBLE} - Add 128-bit atomic cmpxchg support - Add HOTPLUG_SMT implementation - Wire up memfd_secret system call - Fix boot errors and unwind errors for KASAN - Use BPF prog pack allocator and add BPF arena support - Update dts files to add nand controllers - Some bug fixes and other small changes * tag 'loongarch-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: dts: loongson-2k1000: Add nand controller support LoongArch: dts: loongson-2k0500: Add nand controller support LoongArch: BPF: Implement bpf_addr_space_cast instruction LoongArch: BPF: Implement PROBE_MEM32 pseudo instructions LoongArch: BPF: Use BPF prog pack allocator LoongArch: Use IS_ERR_PCPU() macro for KGDB LoongArch: Rework KASAN initialization for PTW-enabled systems LoongArch: Disable instrumentation for setup_ptwalker() LoongArch: Remove some extern variables in source files LoongArch: Guard percpu handler under !CONFIG_PREEMPT_RT LoongArch: Handle percpu handler address for ORC unwinder LoongArch: Use %px to print unmodified unwinding address LoongArch: Prefer top-down allocation after arch_mem_init() LoongArch: Add HOTPLUG_SMT implementation LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE LoongArch: Wire up memfd_secret system call LoongArch: Replace seq_printf() with seq_puts() for simple strings LoongArch: Add 128-bit atomic cmpxchg support LoongArch: Add detection for SC.Q support LoongArch: Select HAVE_CMPXCHG_LOCAL in Kconfig
2 parents 787fe1d + 9286025 commit 64275e9

File tree

26 files changed

+449
-152
lines changed

26 files changed

+449
-152
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,7 @@ Kernel parameters
46614661
nosmt [KNL,MIPS,PPC,EARLY] Disable symmetric multithreading (SMT).
46624662
Equivalent to smt=1.
46634663

4664-
[KNL,X86,PPC,S390] Disable symmetric multithreading (SMT).
4664+
[KNL,LOONGARCH,X86,PPC,S390] Disable symmetric multithreading (SMT).
46654665
nosmt=force: Force disable SMT, cannot be undone
46664666
via the sysfs control file.
46674667

arch/loongarch/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ config LOONGARCH
114114
select GENERIC_TIME_VSYSCALL
115115
select GPIOLIB
116116
select HAS_IOPORT
117+
select HAVE_ALIGNED_STRUCT_PAGE
117118
select HAVE_ARCH_AUDITSYSCALL
118119
select HAVE_ARCH_BITREVERSE
119120
select HAVE_ARCH_JUMP_LABEL
@@ -130,6 +131,8 @@ config LOONGARCH
130131
select HAVE_ARCH_TRANSPARENT_HUGEPAGE
131132
select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD
132133
select HAVE_ASM_MODVERSIONS
134+
select HAVE_CMPXCHG_DOUBLE
135+
select HAVE_CMPXCHG_LOCAL
133136
select HAVE_CONTEXT_TRACKING_USER
134137
select HAVE_C_RECORDMCOUNT
135138
select HAVE_DEBUG_KMEMLEAK
@@ -183,6 +186,7 @@ config LOONGARCH
183186
select HAVE_SYSCALL_TRACEPOINTS
184187
select HAVE_TIF_NOHZ
185188
select HAVE_VIRT_CPU_ACCOUNTING_GEN
189+
select HOTPLUG_SMT if HOTPLUG_CPU
186190
select IRQ_FORCED_THREADING
187191
select IRQ_LOONGARCH_CPU
188192
select LOCK_MM_AND_FIND_VMA

arch/loongarch/boot/dts/loongson-2k0500-ref.dts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@
4141
};
4242
};
4343

44+
&apbdma0 {
45+
status = "okay";
46+
};
47+
48+
&nand {
49+
status = "okay";
50+
51+
#address-cells = <1>;
52+
#size-cells = <0>;
53+
nand@0 {
54+
reg = <0>;
55+
label = "ls2k0500-nand";
56+
nand-use-soft-ecc-engine;
57+
nand-ecc-algo = "bch";
58+
nand-ecc-strength = <8>;
59+
nand-ecc-step-size = <512>;
60+
};
61+
};
62+
4463
&apbdma3 {
4564
status = "okay";
4665
};

arch/loongarch/boot/dts/loongson-2k0500.dtsi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
clock-names = "ref_100m";
8585
};
8686

87-
dma-controller@1fe10c00 {
87+
apbdma0: dma-controller@1fe10c00 {
8888
compatible = "loongson,ls2k0500-apbdma", "loongson,ls2k1000-apbdma";
8989
reg = <0 0x1fe10c00 0 0x8>;
9090
interrupt-parent = <&eiointc>;
@@ -172,6 +172,16 @@
172172
interrupts = <3>;
173173
};
174174

175+
nand: nand-controller@1ff58000 {
176+
compatible = "loongson,ls2k0500-nand-controller";
177+
reg = <0 0x1ff58000 0 0x24>,
178+
<0 0x1ff58040 0 0x4>;
179+
reg-names = "nand", "nand-dma";
180+
dmas = <&apbdma0 0>;
181+
dma-names = "rxtx";
182+
status = "disabled";
183+
};
184+
175185
pwm@1ff5c000 {
176186
compatible = "loongson,ls2k0500-pwm", "loongson,ls7a-pwm";
177187
reg = <0x0 0x1ff5c000 0x0 0x10>;

arch/loongarch/boot/dts/loongson-2k1000-ref.dts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@
4848
};
4949
};
5050

51+
&apbdma0 {
52+
status = "okay";
53+
};
54+
55+
&nand {
56+
status = "okay";
57+
58+
pinctrl-0 = <&nand_pins_default>;
59+
pinctrl-names = "default";
60+
61+
#address-cells = <1>;
62+
#size-cells = <0>;
63+
nand@0 {
64+
reg = <0>;
65+
label = "ls2k1000-nand";
66+
nand-use-soft-ecc-engine;
67+
nand-ecc-algo = "bch";
68+
nand-ecc-strength = <8>;
69+
nand-ecc-step-size = <512>;
70+
};
71+
};
72+
5173
&apbdma1 {
5274
status = "okay";
5375
};

arch/loongarch/boot/dts/loongson-2k1000.dtsi

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
#thermal-sensor-cells = <1>;
249249
};
250250

251-
dma-controller@1fe00c00 {
251+
apbdma0: dma-controller@1fe00c00 {
252252
compatible = "loongson,ls2k1000-apbdma";
253253
reg = <0x0 0x1fe00c00 0x0 0x8>;
254254
interrupt-parent = <&liointc1>;
@@ -364,6 +364,17 @@
364364
status = "disabled";
365365
};
366366

367+
nand: nand-controller@1fe26000 {
368+
compatible = "loongson,ls2k1000-nand-controller";
369+
reg = <0 0x1fe26000 0 0x24>,
370+
<0 0x1fe26040 0 0x4>,
371+
<0 0x1fe00438 0 0x8>;
372+
reg-names = "nand", "nand-dma", "dma-config";
373+
dmas = <&apbdma0 0>;
374+
dma-names = "rxtx";
375+
status = "disabled";
376+
};
377+
367378
pmc: power-management@1fe27000 {
368379
compatible = "loongson,ls2k1000-pmc", "loongson,ls2k0500-pmc", "syscon";
369380
reg = <0x0 0x1fe27000 0x0 0x58>;

arch/loongarch/include/asm/cmpxchg.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/bits.h>
99
#include <linux/build_bug.h>
1010
#include <asm/barrier.h>
11+
#include <asm/cpu-features.h>
1112

1213
#define __xchg_amo_asm(amswap_db, m, val) \
1314
({ \
@@ -236,6 +237,59 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, unsigned int
236237
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
237238
arch_cmpxchg((ptr), (o), (n)); \
238239
})
240+
241+
union __u128_halves {
242+
u128 full;
243+
struct {
244+
u64 low;
245+
u64 high;
246+
};
247+
};
248+
249+
#define system_has_cmpxchg128() cpu_opt(LOONGARCH_CPU_SCQ)
250+
251+
#define __arch_cmpxchg128(ptr, old, new, llsc_mb) \
252+
({ \
253+
union __u128_halves __old, __new, __ret; \
254+
volatile u64 *__ptr = (volatile u64 *)(ptr); \
255+
\
256+
__old.full = (old); \
257+
__new.full = (new); \
258+
\
259+
__asm__ __volatile__( \
260+
"1: ll.d %0, %3 # 128-bit cmpxchg low \n" \
261+
llsc_mb \
262+
" ld.d %1, %4 # 128-bit cmpxchg high \n" \
263+
" move $t0, %0 \n" \
264+
" move $t1, %1 \n" \
265+
" bne %0, %z5, 2f \n" \
266+
" bne %1, %z6, 2f \n" \
267+
" move $t0, %z7 \n" \
268+
" move $t1, %z8 \n" \
269+
"2: sc.q $t0, $t1, %2 \n" \
270+
" beqz $t0, 1b \n" \
271+
llsc_mb \
272+
: "=&r" (__ret.low), "=&r" (__ret.high) \
273+
: "r" (__ptr), \
274+
"ZC" (__ptr[0]), "m" (__ptr[1]), \
275+
"Jr" (__old.low), "Jr" (__old.high), \
276+
"Jr" (__new.low), "Jr" (__new.high) \
277+
: "t0", "t1", "memory"); \
278+
\
279+
__ret.full; \
280+
})
281+
282+
#define arch_cmpxchg128(ptr, o, n) \
283+
({ \
284+
BUILD_BUG_ON(sizeof(*(ptr)) != 16); \
285+
__arch_cmpxchg128(ptr, o, n, __WEAK_LLSC_MB); \
286+
})
287+
288+
#define arch_cmpxchg128_local(ptr, o, n) \
289+
({ \
290+
BUILD_BUG_ON(sizeof(*(ptr)) != 16); \
291+
__arch_cmpxchg128(ptr, o, n, ""); \
292+
})
239293
#else
240294
#include <asm-generic/cmpxchg-local.h>
241295
#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))

arch/loongarch/include/asm/cpu-features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636
#define cpu_has_cpucfg cpu_opt(LOONGARCH_CPU_CPUCFG)
3737
#define cpu_has_lam cpu_opt(LOONGARCH_CPU_LAM)
38+
#define cpu_has_scq cpu_opt(LOONGARCH_CPU_SCQ)
3839
#define cpu_has_ual cpu_opt(LOONGARCH_CPU_UAL)
3940
#define cpu_has_fpu cpu_opt(LOONGARCH_CPU_FPU)
4041
#define cpu_has_lsx cpu_opt(LOONGARCH_CPU_LSX)

arch/loongarch/include/asm/cpu.h

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,41 @@ static inline char *id_to_core_name(unsigned int id)
9595
*/
9696
#define CPU_FEATURE_CPUCFG 0 /* CPU has CPUCFG */
9797
#define CPU_FEATURE_LAM 1 /* CPU has Atomic instructions */
98-
#define CPU_FEATURE_UAL 2 /* CPU supports unaligned access */
99-
#define CPU_FEATURE_FPU 3 /* CPU has FPU */
100-
#define CPU_FEATURE_LSX 4 /* CPU has LSX (128-bit SIMD) */
101-
#define CPU_FEATURE_LASX 5 /* CPU has LASX (256-bit SIMD) */
102-
#define CPU_FEATURE_CRC32 6 /* CPU has CRC32 instructions */
103-
#define CPU_FEATURE_COMPLEX 7 /* CPU has Complex instructions */
104-
#define CPU_FEATURE_CRYPTO 8 /* CPU has Crypto instructions */
105-
#define CPU_FEATURE_LVZ 9 /* CPU has Virtualization extension */
106-
#define CPU_FEATURE_LBT_X86 10 /* CPU has X86 Binary Translation */
107-
#define CPU_FEATURE_LBT_ARM 11 /* CPU has ARM Binary Translation */
108-
#define CPU_FEATURE_LBT_MIPS 12 /* CPU has MIPS Binary Translation */
109-
#define CPU_FEATURE_TLB 13 /* CPU has TLB */
110-
#define CPU_FEATURE_CSR 14 /* CPU has CSR */
111-
#define CPU_FEATURE_IOCSR 15 /* CPU has IOCSR */
112-
#define CPU_FEATURE_WATCH 16 /* CPU has watchpoint registers */
113-
#define CPU_FEATURE_VINT 17 /* CPU has vectored interrupts */
114-
#define CPU_FEATURE_CSRIPI 18 /* CPU has CSR-IPI */
115-
#define CPU_FEATURE_EXTIOI 19 /* CPU has EXT-IOI */
116-
#define CPU_FEATURE_PREFETCH 20 /* CPU has prefetch instructions */
117-
#define CPU_FEATURE_PMP 21 /* CPU has perfermance counter */
118-
#define CPU_FEATURE_SCALEFREQ 22 /* CPU supports cpufreq scaling */
119-
#define CPU_FEATURE_FLATMODE 23 /* CPU has flat mode */
120-
#define CPU_FEATURE_EIODECODE 24 /* CPU has EXTIOI interrupt pin decode mode */
121-
#define CPU_FEATURE_GUESTID 25 /* CPU has GuestID feature */
122-
#define CPU_FEATURE_HYPERVISOR 26 /* CPU has hypervisor (running in VM) */
123-
#define CPU_FEATURE_PTW 27 /* CPU has hardware page table walker */
124-
#define CPU_FEATURE_LSPW 28 /* CPU has LSPW (lddir/ldpte instructions) */
125-
#define CPU_FEATURE_MSGINT 29 /* CPU has MSG interrupt */
126-
#define CPU_FEATURE_AVECINT 30 /* CPU has AVEC interrupt */
127-
#define CPU_FEATURE_REDIRECTINT 31 /* CPU has interrupt remapping */
98+
#define CPU_FEATURE_SCQ 2 /* CPU has SC.Q instruction */
99+
#define CPU_FEATURE_UAL 3 /* CPU supports unaligned access */
100+
#define CPU_FEATURE_FPU 4 /* CPU has FPU */
101+
#define CPU_FEATURE_LSX 5 /* CPU has LSX (128-bit SIMD) */
102+
#define CPU_FEATURE_LASX 6 /* CPU has LASX (256-bit SIMD) */
103+
#define CPU_FEATURE_CRC32 7 /* CPU has CRC32 instructions */
104+
#define CPU_FEATURE_COMPLEX 8 /* CPU has Complex instructions */
105+
#define CPU_FEATURE_CRYPTO 9 /* CPU has Crypto instructions */
106+
#define CPU_FEATURE_LVZ 10 /* CPU has Virtualization extension */
107+
#define CPU_FEATURE_LBT_X86 11 /* CPU has X86 Binary Translation */
108+
#define CPU_FEATURE_LBT_ARM 12 /* CPU has ARM Binary Translation */
109+
#define CPU_FEATURE_LBT_MIPS 13 /* CPU has MIPS Binary Translation */
110+
#define CPU_FEATURE_TLB 14 /* CPU has TLB */
111+
#define CPU_FEATURE_CSR 15 /* CPU has CSR */
112+
#define CPU_FEATURE_IOCSR 16 /* CPU has IOCSR */
113+
#define CPU_FEATURE_WATCH 17 /* CPU has watchpoint registers */
114+
#define CPU_FEATURE_VINT 18 /* CPU has vectored interrupts */
115+
#define CPU_FEATURE_CSRIPI 19 /* CPU has CSR-IPI */
116+
#define CPU_FEATURE_EXTIOI 20 /* CPU has EXT-IOI */
117+
#define CPU_FEATURE_PREFETCH 21 /* CPU has prefetch instructions */
118+
#define CPU_FEATURE_PMP 22 /* CPU has perfermance counter */
119+
#define CPU_FEATURE_SCALEFREQ 23 /* CPU supports cpufreq scaling */
120+
#define CPU_FEATURE_FLATMODE 24 /* CPU has flat mode */
121+
#define CPU_FEATURE_EIODECODE 25 /* CPU has EXTIOI interrupt pin decode mode */
122+
#define CPU_FEATURE_GUESTID 26 /* CPU has GuestID feature */
123+
#define CPU_FEATURE_HYPERVISOR 27 /* CPU has hypervisor (running in VM) */
124+
#define CPU_FEATURE_PTW 28 /* CPU has hardware page table walker */
125+
#define CPU_FEATURE_LSPW 29 /* CPU has LSPW (lddir/ldpte instructions) */
126+
#define CPU_FEATURE_MSGINT 30 /* CPU has MSG interrupt */
127+
#define CPU_FEATURE_AVECINT 31 /* CPU has AVEC interrupt */
128+
#define CPU_FEATURE_REDIRECTINT 32 /* CPU has interrupt remapping */
128129

129130
#define LOONGARCH_CPU_CPUCFG BIT_ULL(CPU_FEATURE_CPUCFG)
130131
#define LOONGARCH_CPU_LAM BIT_ULL(CPU_FEATURE_LAM)
132+
#define LOONGARCH_CPU_SCQ BIT_ULL(CPU_FEATURE_SCQ)
131133
#define LOONGARCH_CPU_UAL BIT_ULL(CPU_FEATURE_UAL)
132134
#define LOONGARCH_CPU_FPU BIT_ULL(CPU_FEATURE_FPU)
133135
#define LOONGARCH_CPU_LSX BIT_ULL(CPU_FEATURE_LSX)

arch/loongarch/include/asm/setup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
#define _LOONGARCH_SETUP_H
88

99
#include <linux/types.h>
10+
#include <linux/threads.h>
1011
#include <asm/sections.h>
1112
#include <uapi/asm/setup.h>
1213

1314
#define VECSIZE 0x200
1415

1516
extern unsigned long eentry;
1617
extern unsigned long tlbrentry;
18+
extern unsigned long pcpu_handlers[NR_CPUS];
19+
extern long exception_handlers[VECSIZE * 128 / sizeof(long)];
1720
extern char init_command_line[COMMAND_LINE_SIZE];
1821
extern void tlb_init(int cpu);
1922
extern void cpu_cache_init(void);

0 commit comments

Comments
 (0)