summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-07-17 08:07:33 +0000
committerpatrick <patrick@openbsd.org>2020-07-17 08:07:33 +0000
commit452daaedc6a44247dc76c56f4c33bc4131b7c50c (patch)
tree482245802e7d6304dfe90d749f5b8e7edac4f384 /sys/dev/fdt
parentAdd powerpc64 support; straight copy from octeon. (diff)
downloadwireguard-openbsd-452daaedc6a44247dc76c56f4c33bc4131b7c50c.tar.xz
wireguard-openbsd-452daaedc6a44247dc76c56f4c33bc4131b7c50c.zip
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/dev/fdt')
-rw-r--r--sys/dev/fdt/bcm2835_aux.c3
-rw-r--r--sys/dev/fdt/imxgpc.c3
-rw-r--r--sys/dev/fdt/imxgpio.c16
-rw-r--r--sys/dev/fdt/mvgicp.c26
-rw-r--r--sys/dev/fdt/mvicu.c20
-rw-r--r--sys/dev/fdt/mvkpcie.c13
-rw-r--r--sys/dev/fdt/rkgpio.c13
7 files changed, 84 insertions, 10 deletions
diff --git a/sys/dev/fdt/bcm2835_aux.c b/sys/dev/fdt/bcm2835_aux.c
index 47bc8e492dd..23f7e92e827 100644
--- a/sys/dev/fdt/bcm2835_aux.c
+++ b/sys/dev/fdt/bcm2835_aux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcm2835_aux.c,v 1.5 2020/07/14 15:34:15 patrick Exp $ */
+/* $OpenBSD: bcm2835_aux.c,v 1.6 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
@@ -97,6 +97,7 @@ bcmaux_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_cookie = &sc->sc_ic;
sc->sc_ic.ic_establish = bcm_aux_intr_establish_fdt;
sc->sc_ic.ic_disestablish = fdt_intr_disestablish;
+ sc->sc_ic.ic_barrier = intr_barrier;
fdt_intr_register(&sc->sc_ic);
}
diff --git a/sys/dev/fdt/imxgpc.c b/sys/dev/fdt/imxgpc.c
index d2b367aabfb..87b2f6ae2f0 100644
--- a/sys/dev/fdt/imxgpc.c
+++ b/sys/dev/fdt/imxgpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxgpc.c,v 1.7 2020/04/26 13:20:41 patrick Exp $ */
+/* $OpenBSD: imxgpc.c,v 1.8 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -73,6 +73,7 @@ imxgpc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_cookie = &sc->sc_ic;
sc->sc_ic.ic_establish = fdt_intr_parent_establish;
sc->sc_ic.ic_disestablish = fdt_intr_parent_disestablish;
+ sc->sc_ic.ic_barrier = intr_barrier;
fdt_intr_register(&sc->sc_ic);
printf("\n");
diff --git a/sys/dev/fdt/imxgpio.c b/sys/dev/fdt/imxgpio.c
index a1dab03217a..4da86aad524 100644
--- a/sys/dev/fdt/imxgpio.c
+++ b/sys/dev/fdt/imxgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxgpio.c,v 1.4 2020/07/14 15:34:15 patrick Exp $ */
+/* $OpenBSD: imxgpio.c,v 1.5 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -84,6 +84,7 @@ void imxgpio_intr_disestablish(void *);
void imxgpio_recalc_ipl(struct imxgpio_softc *);
void imxgpio_intr_enable(void *);
void imxgpio_intr_disable(void *);
+void imxgpio_intr_barrier(void *);
struct cfattach imxgpio_ca = {
@@ -135,6 +136,7 @@ imxgpio_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_disestablish = imxgpio_intr_disestablish;
sc->sc_ic.ic_enable = imxgpio_intr_enable;
sc->sc_ic.ic_disable = imxgpio_intr_disable;
+ sc->sc_ic.ic_barrier = imxgpio_intr_barrier;
fdt_intr_register(&sc->sc_ic);
printf("\n");
@@ -409,3 +411,15 @@ imxgpio_intr_disable(void *cookie)
bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR, mask);
splx(s);
}
+
+void
+imxgpio_intr_barrier(void *cookie)
+{
+ struct intrhand *ih = cookie;
+ struct imxgpio_softc *sc = ih->ih_sc;
+
+ if (sc->sc_ih_h && ih->ih_irq >= 16)
+ intr_barrier(sc->sc_ih_h);
+ else if (sc->sc_ih_l)
+ intr_barrier(sc->sc_ih_l);
+}
diff --git a/sys/dev/fdt/mvgicp.c b/sys/dev/fdt/mvgicp.c
index e333dad97c0..8ce3eec2e3c 100644
--- a/sys/dev/fdt/mvgicp.c
+++ b/sys/dev/fdt/mvgicp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvgicp.c,v 1.2 2020/07/14 15:34:15 patrick Exp $ */
+/* $OpenBSD: mvgicp.c,v 1.3 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2019 Patrick Wildt <patrick@blueri.se>
*
@@ -50,6 +50,7 @@ void mvgicp_attach(struct device *, struct device *, void *);
void * mvgicp_intr_establish(void *, uint64_t *, uint64_t *,
int, struct cpu_info *, int (*)(void *), void *, char *);
void mvgicp_intr_disestablish(void *);
+void mvgicp_intr_barrier(void *);
struct cfattach mvgicp_ca = {
sizeof(struct mvgicp_softc), mvgicp_match, mvgicp_attach
@@ -112,6 +113,7 @@ mvgicp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_cookie = sc;
sc->sc_ic.ic_establish_msi = mvgicp_intr_establish;
sc->sc_ic.ic_disestablish = mvgicp_intr_disestablish;
+ sc->sc_ic.ic_barrier = mvgicp_intr_barrier;
fdt_intr_register(&sc->sc_ic);
printf("\n");
@@ -123,6 +125,7 @@ mvgicp_intr_establish(void *self, uint64_t *addr, uint64_t *data,
{
struct mvgicp_softc *sc = (struct mvgicp_softc *)self;
struct interrupt_controller *ic = sc->sc_parent_ic;
+ struct arm_intr_handle *ih;
uint32_t interrupt[3];
uint32_t flags;
void *cookie;
@@ -164,13 +167,30 @@ mvgicp_intr_establish(void *self, uint64_t *addr, uint64_t *data,
if (cookie == NULL)
return NULL;
- sc->sc_spi[*data] = cookie;
+ ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+ ih->ih_ic = ic;
+ ih->ih_ih = cookie;
+
+ sc->sc_spi[*data] = ih;
return &sc->sc_spi[*data];
}
void
mvgicp_intr_disestablish(void *cookie)
{
- fdt_intr_disestablish(*(void **)cookie);
+ struct arm_intr_handle *ih = *(void **)cookie;
+ struct interrupt_controller *ic = ih->ih_ic;
+
+ ic->ic_disestablish(ih->ih_ih);
+ free(ih, M_DEVBUF, sizeof(*ih));
*(void **)cookie = NULL;
}
+
+void
+mvgicp_intr_barrier(void *cookie)
+{
+ struct arm_intr_handle *ih = *(void **)cookie;
+ struct interrupt_controller *ic = ih->ih_ic;
+
+ ic->ic_barrier(ih->ih_ih);
+}
diff --git a/sys/dev/fdt/mvicu.c b/sys/dev/fdt/mvicu.c
index 0659c81a158..805aac01c82 100644
--- a/sys/dev/fdt/mvicu.c
+++ b/sys/dev/fdt/mvicu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvicu.c,v 1.5 2020/07/14 15:34:15 patrick Exp $ */
+/* $OpenBSD: mvicu.c,v 1.6 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
*
@@ -96,6 +96,7 @@ void mvicu_register(struct mvicu_softc *, int, int);
void *mvicu_intr_establish(void *, int *, int, struct cpu_info *,
int (*)(void *), void *, char *);
void mvicu_intr_disestablish(void *);
+void mvicu_intr_barrier(void *);
int
mvicu_match(struct device *parent, void *match, void *aux)
@@ -171,6 +172,7 @@ mvicu_register(struct mvicu_softc *sc, int node, int idx)
sn->sn_ic.ic_cookie = sn;
sn->sn_ic.ic_establish = mvicu_intr_establish;
sn->sn_ic.ic_disestablish = mvicu_intr_disestablish;
+ sn->sn_ic.ic_barrier = mvicu_intr_barrier;
while (node && !phandle) {
phandle = OF_getpropint(node, "msi-parent", 0);
@@ -198,6 +200,7 @@ mvicu_intr_establish(void *cookie, int *cell, int level,
struct mvicu_subnode *sn = cookie;
struct mvicu_softc *sc = sn->sn_sc;
struct interrupt_controller *ic = sn->sn_parent_ic;
+ struct arm_intr_handle *ih;
uint32_t idx, flags;
uint64_t addr, data;
int edge = 0;
@@ -258,7 +261,11 @@ mvicu_intr_establish(void *cookie, int *cell, int level,
(edge ? ICU_INT_EDGE : 0));
}
- return cookie;
+ ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+ ih->ih_ic = ic;
+ ih->ih_ih = cookie;
+
+ return ih;
}
void
@@ -266,3 +273,12 @@ mvicu_intr_disestablish(void *cookie)
{
panic("%s", __func__);
}
+
+void
+mvicu_intr_barrier(void *cookie)
+{
+ struct arm_intr_handle *ih = cookie;
+ struct interrupt_controller *ic = ih->ih_ic;
+
+ ic->ic_barrier(ih->ih_ih);
+}
diff --git a/sys/dev/fdt/mvkpcie.c b/sys/dev/fdt/mvkpcie.c
index 1e3c96b5ae4..511f403bb8e 100644
--- a/sys/dev/fdt/mvkpcie.c
+++ b/sys/dev/fdt/mvkpcie.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvkpcie.c,v 1.6 2020/07/14 15:42:19 patrick Exp $ */
+/* $OpenBSD: mvkpcie.c,v 1.7 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2020 Patrick Wildt <patrick@blueri.se>
@@ -245,6 +245,7 @@ int mvkpcie_intc_intr(void *);
void *mvkpcie_intc_intr_establish_msi(void *, uint64_t *, uint64_t *,
int , struct cpu_info *, int (*)(void *), void *, char *);
void mvkpcie_intc_intr_disestablish_msi(void *);
+void mvkpcie_intc_intr_barrier(void *);
void mvkpcie_intc_recalc_ipl(struct mvkpcie_softc *);
struct mvkpcie_dmamem *mvkpcie_dmamem_alloc(struct mvkpcie_softc *, bus_size_t,
@@ -532,6 +533,7 @@ mvkpcie_attach(struct device *parent, struct device *self, void *aux)
sc->sc_msi_ic.ic_cookie = self;
sc->sc_msi_ic.ic_establish_msi = mvkpcie_intc_intr_establish_msi;
sc->sc_msi_ic.ic_disestablish = mvkpcie_intc_intr_disestablish_msi;
+ sc->sc_msi_ic.ic_barrier = mvkpcie_intc_intr_barrier;
arm_intr_register_fdt(&sc->sc_msi_ic);
config_found(self, &pba, NULL);
@@ -919,6 +921,15 @@ mvkpcie_intc_intr_disestablish_msi(void *cookie)
}
void
+mvkpcie_intc_intr_barrier(void *cookie)
+{
+ struct intrhand *ih = cookie;
+ struct mvkpcie_softc *sc = ih->ih_sc;
+
+ intr_barrier(sc->sc_ih);
+}
+
+void
mvkpcie_intc_recalc_ipl(struct mvkpcie_softc *sc)
{
struct intrhand *ih;
diff --git a/sys/dev/fdt/rkgpio.c b/sys/dev/fdt/rkgpio.c
index e45d533f1c2..4b31efd13e7 100644
--- a/sys/dev/fdt/rkgpio.c
+++ b/sys/dev/fdt/rkgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkgpio.c,v 1.5 2020/07/14 15:34:15 patrick Exp $ */
+/* $OpenBSD: rkgpio.c,v 1.6 2020/07/17 08:07:34 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2019 Patrick Wildt <patrick@blueri.se>
@@ -102,6 +102,7 @@ void rkgpio_intr_disestablish(void *);
void rkgpio_recalc_ipl(struct rkgpio_softc *);
void rkgpio_intr_enable(void *);
void rkgpio_intr_disable(void *);
+void rkgpio_intr_barrier(void *);
int
rkgpio_match(struct device *parent, void *match, void *aux)
@@ -148,6 +149,7 @@ rkgpio_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_disestablish = rkgpio_intr_disestablish;
sc->sc_ic.ic_enable = rkgpio_intr_enable;
sc->sc_ic.ic_disable = rkgpio_intr_disable;
+ sc->sc_ic.ic_barrier = rkgpio_intr_barrier;
fdt_intr_register(&sc->sc_ic);
printf("\n");
@@ -390,3 +392,12 @@ rkgpio_intr_disable(void *cookie)
HSET4(sc, GPIO_INTMASK, 1 << ih->ih_irq);
splx(s);
}
+
+void
+rkgpio_intr_barrier(void *cookie)
+{
+ struct intrhand *ih = cookie;
+ struct rkgpio_softc *sc = ih->ih_sc;
+
+ intr_barrier(sc->sc_ih);
+}