Skip to content

Commit e0bc833

Browse files
committed
Merge tag 'mips_fixes_4.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS fixes from Paul Burton: "A few MIPS fixes for 4.18: - a GPIO device name fix for a regression in v4.15-rc1. - an errata workaround for the BCM5300X platform. - a fix to ftrace function graph tracing, broken for a long time with the fix applying cleanly back as far as v3.17. - addition of read barriers to in{b,w,l,q}() functions, matching behavior of other architectures & mirroring the equivalent addition to read{b,w,l,q} in v4.17-rc2. Plus changes to wire up new syscalls introduced in the 4.18 cycle: - Restartable sequences support is added, including MIPS support in the selftests. - io_pgetevents is wired up" * tag 'mips_fixes_4.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: MIPS: Wire up io_pgetevents syscall rseq/selftests: Implement MIPS support MIPS: Wire up the restartable sequences (rseq) syscall MIPS: Add syscall detection for restartable sequences MIPS: Add support for restartable sequences MIPS: io: Add barrier after register read in inX() mips: ftrace: fix static function graph tracing MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum MIPS: pb44: Fix i2c-gpio GPIO descriptor table
2 parents 77072ca + 4337aac commit e0bc833

File tree

16 files changed

+807
-22
lines changed

16 files changed

+807
-22
lines changed

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ config MIPS
6565
select HAVE_OPROFILE
6666
select HAVE_PERF_EVENTS
6767
select HAVE_REGS_AND_STACK_ACCESS_API
68+
select HAVE_RSEQ
6869
select HAVE_STACKPROTECTOR
6970
select HAVE_SYSCALL_TRACEPOINTS
7071
select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP

arch/mips/ath79/mach-pb44.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
3535

3636
static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
37-
.dev_id = "i2c-gpio",
37+
.dev_id = "i2c-gpio.0",
3838
.table = {
3939
GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
4040
NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),

arch/mips/bcm47xx/setup.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ static int __init bcm47xx_cpu_fixes(void)
212212
*/
213213
if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
214214
cpu_wait = NULL;
215+
216+
/*
217+
* BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
218+
* Enable ExternalSync for sync instruction to take effect
219+
*/
220+
set_c0_config7(MIPS_CONF7_ES);
215221
break;
216222
#endif
217223
}

arch/mips/include/asm/io.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ static inline type pfx##in##bwlq##p(unsigned long port) \
414414
__val = *__addr; \
415415
slow; \
416416
\
417+
/* prevent prefetching of coherent DMA data prematurely */ \
418+
rmb(); \
417419
return pfx##ioswab##bwlq(__addr, __val); \
418420
}
419421

arch/mips/include/asm/mipsregs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,8 @@
681681
#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
682682

683683
#define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
684+
/* ExternalSync */
685+
#define MIPS_CONF7_ES (_ULCAST_(1) << 8)
684686

685687
#define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
686688
#define MIPS_CONF7_AR (_ULCAST_(1) << 16)
@@ -2765,6 +2767,7 @@ __BUILD_SET_C0(status)
27652767
__BUILD_SET_C0(cause)
27662768
__BUILD_SET_C0(config)
27672769
__BUILD_SET_C0(config5)
2770+
__BUILD_SET_C0(config7)
27682771
__BUILD_SET_C0(intcontrol)
27692772
__BUILD_SET_C0(intctl)
27702773
__BUILD_SET_C0(srsmap)

arch/mips/include/uapi/asm/unistd.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,19 @@
388388
#define __NR_pkey_alloc (__NR_Linux + 364)
389389
#define __NR_pkey_free (__NR_Linux + 365)
390390
#define __NR_statx (__NR_Linux + 366)
391+
#define __NR_rseq (__NR_Linux + 367)
392+
#define __NR_io_pgetevents (__NR_Linux + 368)
391393

392394

393395
/*
394396
* Offset of the last Linux o32 flavoured syscall
395397
*/
396-
#define __NR_Linux_syscalls 366
398+
#define __NR_Linux_syscalls 368
397399

398400
#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
399401

400402
#define __NR_O32_Linux 4000
401-
#define __NR_O32_Linux_syscalls 366
403+
#define __NR_O32_Linux_syscalls 368
402404

403405
#if _MIPS_SIM == _MIPS_SIM_ABI64
404406

@@ -733,16 +735,18 @@
733735
#define __NR_pkey_alloc (__NR_Linux + 324)
734736
#define __NR_pkey_free (__NR_Linux + 325)
735737
#define __NR_statx (__NR_Linux + 326)
738+
#define __NR_rseq (__NR_Linux + 327)
739+
#define __NR_io_pgetevents (__NR_Linux + 328)
736740

737741
/*
738742
* Offset of the last Linux 64-bit flavoured syscall
739743
*/
740-
#define __NR_Linux_syscalls 326
744+
#define __NR_Linux_syscalls 328
741745

742746
#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
743747

744748
#define __NR_64_Linux 5000
745-
#define __NR_64_Linux_syscalls 326
749+
#define __NR_64_Linux_syscalls 328
746750

747751
#if _MIPS_SIM == _MIPS_SIM_NABI32
748752

@@ -1081,15 +1085,17 @@
10811085
#define __NR_pkey_alloc (__NR_Linux + 328)
10821086
#define __NR_pkey_free (__NR_Linux + 329)
10831087
#define __NR_statx (__NR_Linux + 330)
1088+
#define __NR_rseq (__NR_Linux + 331)
1089+
#define __NR_io_pgetevents (__NR_Linux + 332)
10841090

10851091
/*
10861092
* Offset of the last N32 flavoured syscall
10871093
*/
1088-
#define __NR_Linux_syscalls 330
1094+
#define __NR_Linux_syscalls 332
10891095

10901096
#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
10911097

10921098
#define __NR_N32_Linux 6000
1093-
#define __NR_N32_Linux_syscalls 330
1099+
#define __NR_N32_Linux_syscalls 332
10941100

10951101
#endif /* _UAPI_ASM_UNISTD_H */

arch/mips/kernel/entry.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ FEXPORT(ret_from_fork)
7979
jal schedule_tail # a0 = struct task_struct *prev
8080

8181
FEXPORT(syscall_exit)
82+
#ifdef CONFIG_DEBUG_RSEQ
83+
move a0, sp
84+
jal rseq_syscall
85+
#endif
8286
local_irq_disable # make sure need_resched and
8387
# signals dont change between
8488
# sampling and return
@@ -141,6 +145,10 @@ work_notifysig: # deal with pending signals and
141145
j resume_userspace_check
142146

143147
FEXPORT(syscall_exit_partial)
148+
#ifdef CONFIG_DEBUG_RSEQ
149+
move a0, sp
150+
jal rseq_syscall
151+
#endif
144152
local_irq_disable # make sure need_resched doesn't
145153
# change between and return
146154
LONG_L a2, TI_FLAGS($28) # current->work

arch/mips/kernel/mcount.S

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,20 @@ NESTED(_mcount, PT_SIZE, ra)
119119
EXPORT_SYMBOL(_mcount)
120120
PTR_LA t1, ftrace_stub
121121
PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
122-
bne t1, t2, static_trace
122+
beq t1, t2, fgraph_trace
123123
nop
124124

125+
MCOUNT_SAVE_REGS
126+
127+
move a0, ra /* arg1: self return address */
128+
jalr t2 /* (1) call *ftrace_trace_function */
129+
move a1, AT /* arg2: parent's return address */
130+
131+
MCOUNT_RESTORE_REGS
132+
133+
fgraph_trace:
125134
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135+
PTR_LA t1, ftrace_stub
126136
PTR_L t3, ftrace_graph_return
127137
bne t1, t3, ftrace_graph_caller
128138
nop
@@ -131,24 +141,11 @@ EXPORT_SYMBOL(_mcount)
131141
bne t1, t3, ftrace_graph_caller
132142
nop
133143
#endif
134-
b ftrace_stub
135-
#ifdef CONFIG_32BIT
136-
addiu sp, sp, 8
137-
#else
138-
nop
139-
#endif
140144

141-
static_trace:
142-
MCOUNT_SAVE_REGS
143-
144-
move a0, ra /* arg1: self return address */
145-
jalr t2 /* (1) call *ftrace_trace_function */
146-
move a1, AT /* arg2: parent's return address */
147-
148-
MCOUNT_RESTORE_REGS
149145
#ifdef CONFIG_32BIT
150146
addiu sp, sp, 8
151147
#endif
148+
152149
.globl ftrace_stub
153150
ftrace_stub:
154151
RETURN_BACK

arch/mips/kernel/scall32-o32.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,5 @@ EXPORT(sys_call_table)
590590
PTR sys_pkey_alloc
591591
PTR sys_pkey_free /* 4365 */
592592
PTR sys_statx
593+
PTR sys_rseq
594+
PTR sys_io_pgetevents

arch/mips/kernel/scall64-64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,6 @@ EXPORT(sys_call_table)
439439
PTR sys_pkey_alloc
440440
PTR sys_pkey_free /* 5325 */
441441
PTR sys_statx
442+
PTR sys_rseq
443+
PTR sys_io_pgetevents
442444
.size sys_call_table,.-sys_call_table

arch/mips/kernel/scall64-n32.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,6 @@ EXPORT(sysn32_call_table)
434434
PTR sys_pkey_alloc
435435
PTR sys_pkey_free
436436
PTR sys_statx /* 6330 */
437+
PTR sys_rseq
438+
PTR compat_sys_io_pgetevents
437439
.size sysn32_call_table,.-sysn32_call_table

arch/mips/kernel/scall64-o32.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,4 +583,6 @@ EXPORT(sys32_call_table)
583583
PTR sys_pkey_alloc
584584
PTR sys_pkey_free /* 4365 */
585585
PTR sys_statx
586+
PTR sys_rseq
587+
PTR compat_sys_io_pgetevents
586588
.size sys32_call_table,.-sys32_call_table

arch/mips/kernel/signal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
801801
regs->regs[0] = 0; /* Don't deal with this again. */
802802
}
803803

804+
rseq_signal_deliver(regs);
805+
804806
if (sig_uses_siginfo(&ksig->ka, abi))
805807
ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn,
806808
ksig, regs, oldset);
@@ -868,6 +870,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
868870
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
869871
clear_thread_flag(TIF_NOTIFY_RESUME);
870872
tracehook_notify_resume(regs);
873+
rseq_handle_notify_resume(regs);
871874
}
872875

873876
user_enter();

tools/testing/selftests/rseq/param_test.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@ unsigned int yield_mod_cnt, nr_abort;
137137
"subic. %%" INJECT_ASM_REG ", %%" INJECT_ASM_REG ", 1\n\t" \
138138
"bne 222b\n\t" \
139139
"333:\n\t"
140+
141+
#elif defined(__mips__)
142+
143+
#define RSEQ_INJECT_INPUT \
144+
, [loop_cnt_1]"m"(loop_cnt[1]) \
145+
, [loop_cnt_2]"m"(loop_cnt[2]) \
146+
, [loop_cnt_3]"m"(loop_cnt[3]) \
147+
, [loop_cnt_4]"m"(loop_cnt[4]) \
148+
, [loop_cnt_5]"m"(loop_cnt[5]) \
149+
, [loop_cnt_6]"m"(loop_cnt[6])
150+
151+
#define INJECT_ASM_REG "$5"
152+
153+
#define RSEQ_INJECT_CLOBBER \
154+
, INJECT_ASM_REG
155+
156+
#define RSEQ_INJECT_ASM(n) \
157+
"lw " INJECT_ASM_REG ", %[loop_cnt_" #n "]\n\t" \
158+
"beqz " INJECT_ASM_REG ", 333f\n\t" \
159+
"222:\n\t" \
160+
"addiu " INJECT_ASM_REG ", -1\n\t" \
161+
"bnez " INJECT_ASM_REG ", 222b\n\t" \
162+
"333:\n\t"
163+
140164
#else
141165
#error unsupported target
142166
#endif

0 commit comments

Comments
 (0)