Fix the problem "pcictl pci0 list" causes "panic: trap_el1h_error" on rockpro64.
The panic occures in bus_space_barrier() in rk3399_pcie.c:rkpcie_conf_read(). We expected bus_space_peek_4() to trap and recover in the path trap_el1h_sync() -> data_abort_handler(), but In fact, the read is delayed until bus_space_barrier(), and we get an SError interrupt (trap_el1h_error) instead of a Synchronous Exception (trap_el1h_sync). To catch this correctly, An implicit barrier in bus_space_peek have been added, and trap the SError interrupt to recover from.
This commit is contained in:
parent
7ddbe09f70
commit
fdfe41cfc9
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus_space.c,v 1.15 2020/12/14 19:32:29 skrll Exp $ */
|
||||
/* $NetBSD: bus_space.c,v 1.16 2021/04/14 05:43:09 ryo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org>
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.15 2020/12/14 19:32:29 skrll Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.16 2021/04/14 05:43:09 ryo Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -702,6 +702,7 @@ generic_bs_pe_1(void *t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
|
||||
if ((error = cpu_set_onfault(&fb)) == 0) {
|
||||
*datap = generic_dsb_bs_r_1(t, bsh, offset);
|
||||
dsb(ld);
|
||||
cpu_unset_onfault();
|
||||
}
|
||||
return error;
|
||||
@ -716,6 +717,7 @@ generic_bs_pe_2(void *t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
|
||||
if ((error = cpu_set_onfault(&fb)) == 0) {
|
||||
*datap = NSWAP(generic_dsb_bs_r_2)(t, bsh, offset);
|
||||
dsb(ld);
|
||||
cpu_unset_onfault();
|
||||
}
|
||||
return error;
|
||||
@ -730,6 +732,7 @@ generic_bs_pe_4(void *t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
|
||||
if ((error = cpu_set_onfault(&fb)) == 0) {
|
||||
*datap = NSWAP(generic_dsb_bs_r_4)(t, bsh, offset);
|
||||
dsb(ld);
|
||||
cpu_unset_onfault();
|
||||
}
|
||||
return error;
|
||||
@ -744,6 +747,7 @@ generic_bs_pe_8(void *t, bus_space_handle_t bsh, bus_size_t offset,
|
||||
|
||||
if ((error = cpu_set_onfault(&fb)) == 0) {
|
||||
*datap = NSWAP(generic_dsb_bs_r_8)(t, bsh, offset);
|
||||
dsb(ld);
|
||||
cpu_unset_onfault();
|
||||
}
|
||||
return error;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.45 2021/03/09 16:44:27 ryo Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.45 2021/03/09 16:44:27 ryo Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $");
|
||||
|
||||
#include "opt_arm_intr_impl.h"
|
||||
#include "opt_compat_netbsd32.h"
|
||||
@ -861,6 +861,26 @@ unknown:
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
trap_el1h_error(struct trapframe *tf)
|
||||
{
|
||||
/*
|
||||
* Normally, we should panic unconditionally,
|
||||
* but SError interrupt may occur when accessing to unmapped(?) I/O
|
||||
* spaces. bus_space_{peek,poke}_{1,2,4,8}() should trap these case.
|
||||
*/
|
||||
struct faultbuf *fb;
|
||||
|
||||
if (curcpu()->ci_intr_depth == 0) {
|
||||
fb = cpu_disable_onfault();
|
||||
if (fb != NULL) {
|
||||
cpu_jump_onfault(tf, fb, EFAULT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic("%s", __func__);
|
||||
}
|
||||
|
||||
#define bad_trap_panic(trapfunc) \
|
||||
void \
|
||||
trapfunc(struct trapframe *tf) \
|
||||
@ -872,7 +892,6 @@ bad_trap_panic(trap_el1t_irq)
|
||||
bad_trap_panic(trap_el1t_fiq)
|
||||
bad_trap_panic(trap_el1t_error)
|
||||
bad_trap_panic(trap_el1h_fiq)
|
||||
bad_trap_panic(trap_el1h_error)
|
||||
bad_trap_panic(trap_el0_fiq)
|
||||
bad_trap_panic(trap_el0_error)
|
||||
bad_trap_panic(trap_el0_32fiq)
|
||||
|
Loading…
Reference in New Issue
Block a user