summaryrefslogtreecommitdiff
path: root/sys/arch/arm64
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2020-07-17 08:07:35 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2020-07-17 08:07:35 +0000
commit1cc824a280e35f9095cfcada0a61fd6a5d6f9a42 (patch)
tree423b0e2bb0db50023841196c6f3781f4dcb92b75 /sys/arch/arm64
parent9c3ebab344c210f63472587b920035fd415238b4 (diff)
Re-work intr_barrier(9) on arm64 to remove layer violation. So far we
have stored the struct cpu_info * in the wrapper around the interrupt handler cookie, but since we can have a few layers inbetween, this does not seem very nice. Instead have each and every interrupt controller provide a barrier function. This means that intr_barrier(9) will in the end be executed by the interrupt controller that actually wired the pin to a core. And that's the only place where the information is stored. ok kettenis@
Diffstat (limited to 'sys/arch/arm64')
-rw-r--r--sys/arch/arm64/arm64/acpi_machdep.c3
-rw-r--r--sys/arch/arm64/arm64/intr.c22
-rw-r--r--sys/arch/arm64/dev/acpipci.c3
-rw-r--r--sys/arch/arm64/dev/agintc.c22
-rw-r--r--sys/arch/arm64/dev/ampintc.c22
-rw-r--r--sys/arch/arm64/include/intr.h4
6 files changed, 62 insertions, 14 deletions
diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c
index 4e6f7223438..920f0bde318 100644
--- a/sys/arch/arm64/arm64/acpi_machdep.c
+++ b/sys/arch/arm64/arm64/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.7 2020/07/16 13:03:39 patrick Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.8 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@@ -162,7 +162,6 @@ acpi_intr_establish(int irq, int flags, int level,
aih = malloc(sizeof(*aih), M_DEVBUF, M_WAITOK);
aih->ih_ic = ic;
aih->ih_ih = cookie;
- aih->ih_cpu = NULL;
return aih;
}
diff --git a/sys/arch/arm64/arm64/intr.c b/sys/arch/arm64/arm64/intr.c
index 6a793594345..9d5514878c9 100644
--- a/sys/arch/arm64/arm64/intr.c
+++ b/sys/arch/arm64/arm64/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.18 2020/07/16 13:03:39 patrick Exp $ */
+/* $OpenBSD: intr.c,v 1.19 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
@@ -32,6 +32,7 @@ uint32_t arm_intr_map_msi(int, uint64_t *);
void *arm_intr_prereg_establish_fdt(void *, int *, int, struct cpu_info *,
int (*)(void *), void *, char *);
void arm_intr_prereg_disestablish_fdt(void *);
+void arm_intr_prereg_barrier_fdt(void *);
int arm_dflt_splraise(int);
int arm_dflt_spllower(int);
@@ -220,6 +221,16 @@ arm_intr_prereg_disestablish_fdt(void *cookie)
}
void
+arm_intr_prereg_barrier_fdt(void *cookie)
+{
+ struct intr_prereg *ip = cookie;
+ struct interrupt_controller *ic = ip->ip_ic;
+
+ if (ip->ip_ic != NULL && ip->ip_ih != NULL)
+ ic->ic_barrier(ip->ip_ih);
+}
+
+void
arm_intr_init_fdt_recurse(int node)
{
struct interrupt_controller *ic;
@@ -231,6 +242,7 @@ arm_intr_init_fdt_recurse(int node)
ic->ic_cookie = ic;
ic->ic_establish = arm_intr_prereg_establish_fdt;
ic->ic_disestablish = arm_intr_prereg_disestablish_fdt;
+ ic->ic_barrier = arm_intr_prereg_barrier_fdt;
arm_intr_register_fdt(ic);
}
@@ -373,7 +385,6 @@ arm_intr_establish_fdt_idx_cpu(int node, int idx, int level, struct cpu_info *ci
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
ih->ih_ic = ic;
ih->ih_ih = val;
- ih->ih_cpu = ci;
return ih;
}
@@ -446,7 +457,6 @@ arm_intr_establish_fdt_imap_cpu(int node, int *reg, int nreg, int level,
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
ih->ih_ic = ic;
ih->ih_ih = val;
- ih->ih_cpu = ci;
free(map, M_DEVBUF, len);
return ih;
@@ -485,7 +495,6 @@ arm_intr_establish_fdt_msi_cpu(int node, uint64_t *addr, uint64_t *data,
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
ih->ih_ic = ic;
ih->ih_ih = val;
- ih->ih_cpu = ci;
return ih;
}
@@ -549,7 +558,6 @@ arm_intr_parent_establish_fdt(void *cookie, int *cell, int level,
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
ih->ih_ic = ic;
ih->ih_ih = val;
- ih->ih_cpu = ci;
return ih;
}
@@ -823,7 +831,9 @@ void
intr_barrier(void *cookie)
{
struct arm_intr_handle *ih = cookie;
- sched_barrier(ih->ih_cpu);
+ struct interrupt_controller *ic = ih->ih_ic;
+
+ ic->ic_barrier(ih->ih_ih);
}
/*
diff --git a/sys/arch/arm64/dev/acpipci.c b/sys/arch/arm64/dev/acpipci.c
index f6c76c7aafb..4652cade90e 100644
--- a/sys/arch/arm64/dev/acpipci.c
+++ b/sys/arch/arm64/dev/acpipci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpipci.c,v 1.19 2020/07/16 13:03:39 patrick Exp $ */
+/* $OpenBSD: acpipci.c,v 1.20 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@@ -470,7 +470,6 @@ acpipci_intr_establish(void *v, pci_intr_handle_t ih, int level,
aih = malloc(sizeof(*aih), M_DEVBUF, M_WAITOK);
aih->ih_ic = ic;
aih->ih_ih = cookie;
- aih->ih_cpu = ci;
cookie = aih;
} else {
if (ci != NULL && !CPU_IS_PRIMARY(ci))
diff --git a/sys/arch/arm64/dev/agintc.c b/sys/arch/arm64/dev/agintc.c
index bde190a4ed4..11d73e05111 100644
--- a/sys/arch/arm64/dev/agintc.c
+++ b/sys/arch/arm64/dev/agintc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agintc.c,v 1.25 2020/07/15 12:36:01 patrick Exp $ */
+/* $OpenBSD: agintc.c,v 1.26 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2007, 2009, 2011, 2017 Dale Rahn <drahn@dalerahn.com>
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
@@ -170,6 +170,7 @@ struct intrhand {
int ih_irq; /* IRQ number */
struct evcount ih_count;
char *ih_name;
+ struct cpu_info *ih_ci; /* CPU the IRQ runs on */
};
struct intrq {
@@ -220,6 +221,7 @@ void agintc_intr_disable(struct agintc_softc *, int);
void agintc_route(struct agintc_softc *, int, int,
struct cpu_info *);
void agintc_route_irq(void *, int, struct cpu_info *);
+void agintc_intr_barrier(void *);
void agintc_wait_rwp(struct agintc_softc *sc);
void agintc_r_wait_rwp(struct agintc_softc *sc);
uint32_t agintc_r_ictlr(void);
@@ -597,6 +599,7 @@ agintc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_disestablish = agintc_intr_disestablish;
sc->sc_ic.ic_route = agintc_route_irq;
sc->sc_ic.ic_cpu_enable = agintc_cpuinit;
+ sc->sc_ic.ic_barrier = agintc_intr_barrier;
arm_intr_register_fdt(&sc->sc_ic);
restore_interrupts(psw);
@@ -872,6 +875,14 @@ agintc_route(struct agintc_softc *sc, int irq, int enable, struct cpu_info *ci)
}
void
+agintc_intr_barrier(void *cookie)
+{
+ struct intrhand *ih = cookie;
+
+ sched_barrier(ih->ih_ci);
+}
+
+void
agintc_run_handler(struct intrhand *ih, void *frame, int s)
{
void *arg;
@@ -1006,6 +1017,7 @@ agintc_intr_establish(int irqno, int level, struct cpu_info *ci,
ih->ih_flags = level & IPL_FLAGMASK;
ih->ih_irq = irqno;
ih->ih_name = name;
+ ih->ih_ci = ci;
psw = disable_interrupts();
@@ -1224,6 +1236,7 @@ void agintc_msi_attach(struct device *, struct device *, void *);
void *agintc_intr_establish_msi(void *, uint64_t *, uint64_t *,
int , struct cpu_info *, int (*)(void *), void *, char *);
void agintc_intr_disestablish_msi(void *);
+void agintc_intr_barrier_msi(void *);
struct agintc_msi_softc {
struct device sc_dev;
@@ -1409,6 +1422,7 @@ agintc_msi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_cookie = sc;
sc->sc_ic.ic_establish_msi = agintc_intr_establish_msi;
sc->sc_ic.ic_disestablish = agintc_intr_disestablish_msi;
+ sc->sc_ic.ic_barrier = agintc_intr_barrier_msi;
arm_intr_register_fdt(&sc->sc_ic);
return;
@@ -1556,6 +1570,12 @@ agintc_intr_disestablish_msi(void *cookie)
*(void **)cookie = NULL;
}
+void
+agintc_intr_barrier_msi(void *cookie)
+{
+ agintc_intr_barrier(*(void **)cookie);
+}
+
struct agintc_dmamem *
agintc_dmamem_alloc(bus_dma_tag_t dmat, bus_size_t size, bus_size_t align)
{
diff --git a/sys/arch/arm64/dev/ampintc.c b/sys/arch/arm64/dev/ampintc.c
index eaaa35589f4..ae501973ce3 100644
--- a/sys/arch/arm64/dev/ampintc.c
+++ b/sys/arch/arm64/dev/ampintc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ampintc.c,v 1.18 2020/07/14 15:52:20 patrick Exp $ */
+/* $OpenBSD: ampintc.c,v 1.19 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2007,2009,2011 Dale Rahn <drahn@openbsd.org>
*
@@ -156,6 +156,7 @@ struct intrhand {
int ih_irq; /* IRQ number */
struct evcount ih_count;
char *ih_name;
+ struct cpu_info *ih_ci; /* CPU the IRQ runs on */
};
struct intrq {
@@ -191,6 +192,7 @@ void ampintc_intr_disable(int);
void ampintc_intr_config(int, int);
void ampintc_route(int, int, struct cpu_info *);
void ampintc_route_irq(void *, int, struct cpu_info *);
+void ampintc_intr_barrier(void *);
int ampintc_ipi_combined(void *);
int ampintc_ipi_nop(void *);
@@ -373,6 +375,7 @@ ampintc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_disestablish = ampintc_intr_disestablish;
sc->sc_ic.ic_route = ampintc_route_irq;
sc->sc_ic.ic_cpu_enable = ampintc_cpuinit;
+ sc->sc_ic.ic_barrier = ampintc_intr_barrier;
arm_intr_register_fdt(&sc->sc_ic);
/* attach GICv2M frame controller */
@@ -630,6 +633,14 @@ ampintc_route_irq(void *v, int enable, struct cpu_info *ci)
}
void
+ampintc_intr_barrier(void *cookie)
+{
+ struct intrhand *ih = cookie;
+
+ sched_barrier(ih->ih_ci);
+}
+
+void
ampintc_irq_handler(void *frame)
{
struct ampintc_softc *sc = ampintc;
@@ -758,6 +769,7 @@ ampintc_intr_establish(int irqno, int type, int level, struct cpu_info *ci,
ih->ih_flags = level & IPL_FLAGMASK;
ih->ih_irq = irqno;
ih->ih_name = name;
+ ih->ih_ci = ci;
psw = disable_interrupts();
@@ -833,6 +845,7 @@ void ampintc_msi_attach(struct device *, struct device *, void *);
void *ampintc_intr_establish_msi(void *, uint64_t *, uint64_t *,
int , struct cpu_info *, int (*)(void *), void *, char *);
void ampintc_intr_disestablish_msi(void *);
+void ampintc_intr_barrier_msi(void *);
struct ampintc_msi_softc {
struct device sc_dev;
@@ -897,6 +910,7 @@ ampintc_msi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_cookie = sc;
sc->sc_ic.ic_establish_msi = ampintc_intr_establish_msi;
sc->sc_ic.ic_disestablish = ampintc_intr_disestablish_msi;
+ sc->sc_ic.ic_barrier = ampintc_intr_barrier_msi;
arm_intr_register_fdt(&sc->sc_ic);
}
@@ -933,6 +947,12 @@ ampintc_intr_disestablish_msi(void *cookie)
*(void **)cookie = NULL;
}
+void
+ampintc_intr_barrier_msi(void *cookie)
+{
+ ampintc_intr_barrier(*(void **)cookie);
+}
+
#ifdef MULTIPROCESSOR
int
ampintc_ipi_ddb(void *v)
diff --git a/sys/arch/arm64/include/intr.h b/sys/arch/arm64/include/intr.h
index e4bf1545112..7d299072ef7 100644
--- a/sys/arch/arm64/include/intr.h
+++ b/sys/arch/arm64/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.15 2020/07/16 13:03:39 patrick Exp $ */
+/* $OpenBSD: intr.h,v 1.16 2020/07/17 08:07:33 patrick Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -93,7 +93,6 @@ void arm_set_intr_handler(int (*raise)(int), int (*lower)(int),
struct arm_intr_handle {
struct interrupt_controller *ih_ic;
void *ih_ih;
- struct cpu_info *ih_cpu;
};
struct arm_intr_func {
@@ -151,6 +150,7 @@ struct interrupt_controller {
void (*ic_disable)(void *);
void (*ic_route)(void *, int, struct cpu_info *);
void (*ic_cpu_enable)(void);
+ void (*ic_barrier)(void *);
LIST_ENTRY(interrupt_controller) ic_list;
uint32_t ic_phandle;