diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2020-07-16 12:57:31 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2020-07-16 12:57:31 +0000 |
commit | e772ce60137edb470694363d7c0a54e35ce8fee1 (patch) | |
tree | 69abd4409c6f98cbc37f1d53c871ef905f9972d6 /sys | |
parent | 51f68d0ea30910e7e9d6abc60d15edd634fc40ec (diff) |
To be able to have intr_barrier() on arm64, we need to be able to
somehow gain access to the struct cpu_info * used to establish the
interrupt. One possibility is to store the pointer in the cookie
returned by the establish methods. A better way would be to ask
the interrupt controller directly to do barrier.
This means that all external facing interrupt establish functions
need to wrap the cookie in a common way. We already do this for
FDT-based interrupts. Also most PCI controllers already return
the cookie from the FDT API, which is already wrapped. So arm64's
acpi_intr_establish() and acpipci(4) now need to explicitly wrap
it, since they call ic->ic_establish directly, which does not wrap.
ok dlg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/arm64/arm64/acpi_machdep.c | 16 | ||||
-rw-r--r-- | sys/arch/arm64/arm64/intr.c | 7 | ||||
-rw-r--r-- | sys/arch/arm64/dev/acpipci.c | 8 | ||||
-rw-r--r-- | sys/arch/arm64/include/intr.h | 7 |
4 files changed, 27 insertions, 11 deletions
diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c index cc53a607d28..1c1c37dad1c 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.5 2020/07/14 15:34:14 patrick Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.6 2020/07/16 12:57:30 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -138,7 +138,9 @@ acpi_intr_establish(int irq, int flags, int level, int (*func)(void *), void *arg, const char *name) { struct interrupt_controller *ic; + struct arm_intr_handle *aih; uint32_t interrupt[3]; + void *cookie; extern LIST_HEAD(, interrupt_controller) interrupt_controllers; LIST_FOREACH(ic, &interrupt_controllers, ic_list) { @@ -152,8 +154,16 @@ acpi_intr_establish(int irq, int flags, int level, interrupt[1] = irq - 32; interrupt[2] = 0x4; - return ic->ic_establish(ic->ic_cookie, interrupt, level, NULL, - func, arg, (char *)name); + cookie = ic->ic_establish(ic->ic_cookie, interrupt, level, NULL, + func, arg, (char *)name); + if (cookie == NULL) + return NULL; + + aih = malloc(sizeof(*aih), M_DEVBUF, M_WAITOK); + aih->ih_ic = ic; + aih->ih_ih = cookie; + + return aih; } void diff --git a/sys/arch/arm64/arm64/intr.c b/sys/arch/arm64/arm64/intr.c index a5c8db1417e..ca2392c0884 100644 --- a/sys/arch/arm64/arm64/intr.c +++ b/sys/arch/arm64/arm64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.16 2020/07/14 15:34:14 patrick Exp $ */ +/* $OpenBSD: intr.c,v 1.17 2020/07/16 12:57:30 patrick Exp $ */ /* * Copyright (c) 2011 Dale Rahn <drahn@openbsd.org> * @@ -279,11 +279,6 @@ arm_intr_register_fdt(struct interrupt_controller *ic) } } -struct arm_intr_handle { - struct interrupt_controller *ih_ic; - void *ih_ih; -}; - void * arm_intr_establish_fdt(int node, int level, int (*func)(void *), void *cookie, char *name) diff --git a/sys/arch/arm64/dev/acpipci.c b/sys/arch/arm64/dev/acpipci.c index ff5e43a0134..dd21c714d1c 100644 --- a/sys/arch/arm64/dev/acpipci.c +++ b/sys/arch/arm64/dev/acpipci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpipci.c,v 1.17 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: acpipci.c,v 1.18 2020/07/16 12:57:30 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -436,6 +436,7 @@ acpipci_intr_establish(void *v, pci_intr_handle_t ih, int level, { struct acpipci_softc *sc = v; struct interrupt_controller *ic; + struct arm_intr_handle *aih; void *cookie; extern LIST_HEAD(, interrupt_controller) interrupt_controllers; @@ -465,6 +466,11 @@ acpipci_intr_establish(void *v, pci_intr_handle_t ih, int level, &sc->sc_bus_memt, ih.ih_intrpin, addr, data); } else pci_msi_enable(ih.ih_pc, ih.ih_tag, addr, data); + + aih = malloc(sizeof(*aih), M_DEVBUF, M_WAITOK); + aih->ih_ic = ic; + aih->ih_ih = cookie; + cookie = aih; } else { if (ci != NULL && !CPU_IS_PRIMARY(ci)) return NULL; diff --git a/sys/arch/arm64/include/intr.h b/sys/arch/arm64/include/intr.h index 212c388da0a..c3aad4cb9ee 100644 --- a/sys/arch/arm64/include/intr.h +++ b/sys/arch/arm64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.13 2020/07/14 15:34:14 patrick Exp $ */ +/* $OpenBSD: intr.h,v 1.14 2020/07/16 12:57:30 patrick Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -90,6 +90,11 @@ void arm_set_intr_handler(int (*raise)(int), int (*lower)(int), void (*x)(int), void (*setipl)(int), void (*intr_handle)(void *)); +struct arm_intr_handle { + struct interrupt_controller *ih_ic; + void *ih_ih; +}; + struct arm_intr_func { int (*raise)(int); int (*lower)(int); |