summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-09-21 11:14:28 +0000
committerkettenis <kettenis@openbsd.org>2020-09-21 11:14:28 +0000
commita940e3defb95f631e2df364fa2099915a0afa610 (patch)
treec7677ecede8dced8544984d8b7f4064b5afe75f2
parentFix memory leak in "iov". (diff)
downloadwireguard-openbsd-a940e3defb95f631e2df364fa2099915a0afa610.tar.xz
wireguard-openbsd-a940e3defb95f631e2df364fa2099915a0afa610.zip
Correctly pass the "struct cpu_info" pointer along when establishing
interrupts. This fixes IPIs on machines with certain (newer?) OPAL firmware. It also allows implementing pci_intr_establish_cpu(9), which is needed for distributing interrupt handlers across CPUs. tested by gkoehler@
-rw-r--r--sys/arch/powerpc64/dev/opal.c4
-rw-r--r--sys/arch/powerpc64/dev/phb.c8
-rw-r--r--sys/arch/powerpc64/dev/xicp.c7
-rw-r--r--sys/arch/powerpc64/dev/xics.c4
-rw-r--r--sys/arch/powerpc64/dev/xive.c8
-rw-r--r--sys/arch/powerpc64/include/intr.h6
-rw-r--r--sys/arch/powerpc64/include/pci_machdep.h11
-rw-r--r--sys/arch/powerpc64/powerpc64/intr.c15
8 files changed, 35 insertions, 28 deletions
diff --git a/sys/arch/powerpc64/dev/opal.c b/sys/arch/powerpc64/dev/opal.c
index 72a645a8163..65573322aa8 100644
--- a/sys/arch/powerpc64/dev/opal.c
+++ b/sys/arch/powerpc64/dev/opal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opal.c,v 1.8 2020/07/10 23:22:48 gkoehler Exp $ */
+/* $OpenBSD: opal.c,v 1.9 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -216,7 +216,7 @@ opal_attach_deferred(struct device *self)
for (i = 0; i < sc->sc_nintr; i++) {
intr_establish(sc->sc_intr[i].oi_isn, IST_LEVEL, IPL_TTY,
- opal_intr, &sc->sc_intr[i], sc->sc_dev.dv_xname);
+ NULL, opal_intr, &sc->sc_intr[i], sc->sc_dev.dv_xname);
}
}
diff --git a/sys/arch/powerpc64/dev/phb.c b/sys/arch/powerpc64/dev/phb.c
index b0e286cce4c..5b4c251b36b 100644
--- a/sys/arch/powerpc64/dev/phb.c
+++ b/sys/arch/powerpc64/dev/phb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: phb.c,v 1.15 2020/09/01 19:12:11 kettenis Exp $ */
+/* $OpenBSD: phb.c,v 1.16 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -93,7 +93,7 @@ void phb_conf_write(void *, pcitag_t, int, pcireg_t);
int phb_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
const char *phb_intr_string(void *, pci_intr_handle_t);
-void *phb_intr_establish(void *, pci_intr_handle_t, int,
+void *phb_intr_establish(void *, pci_intr_handle_t, int, struct cpu_info *,
int (*)(void *), void *, char *);
void phb_intr_disestablish(void *, void *);
@@ -517,7 +517,7 @@ phb_intr_string(void *v, pci_intr_handle_t ih)
void *
phb_intr_establish(void *v, pci_intr_handle_t ih, int level,
- int (*func)(void *), void *arg, char *name)
+ struct cpu_info *ci, int (*func)(void *), void *arg, char *name)
{
struct phb_softc *sc = v;
void *cookie = NULL;
@@ -553,7 +553,7 @@ phb_intr_establish(void *v, pci_intr_handle_t ih, int level,
return NULL;
cookie = intr_establish(sc->sc_msi_ranges[0] + xive,
- IST_EDGE, level, func, arg, name);
+ IST_EDGE, level, ci, func, arg, name);
if (cookie == NULL)
return NULL;
diff --git a/sys/arch/powerpc64/dev/xicp.c b/sys/arch/powerpc64/dev/xicp.c
index 7ad28e23703..0d0c81e1eea 100644
--- a/sys/arch/powerpc64/dev/xicp.c
+++ b/sys/arch/powerpc64/dev/xicp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xicp.c,v 1.1 2020/08/23 19:18:42 kettenis Exp $ */
+/* $OpenBSD: xicp.c,v 1.2 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -97,7 +97,7 @@ struct cfdriver xicp_cd = {
};
void xicp_exi(struct trapframe *);
-void *xicp_intr_establish(uint32_t, int, int,
+void *xicp_intr_establish(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *);
void xicp_intr_send_ipi(void *);
void xicp_setipl(int);
@@ -175,10 +175,9 @@ xicp_intr_send_ipi(void *cookie)
}
void *
-xicp_intr_establish(uint32_t girq, int type, int level,
+xicp_intr_establish(uint32_t girq, int type, int level, struct cpu_info *ci,
int (*func)(void *), void *arg, const char *name)
{
- struct cpu_info *ci = cpu_info_primary;
struct intrhand *ih;
int64_t error;
uint16_t server;
diff --git a/sys/arch/powerpc64/dev/xics.c b/sys/arch/powerpc64/dev/xics.c
index 36dcd933c83..9483b666137 100644
--- a/sys/arch/powerpc64/dev/xics.c
+++ b/sys/arch/powerpc64/dev/xics.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xics.c,v 1.2 2020/07/22 16:49:13 kettenis Exp $ */
+/* $OpenBSD: xics.c,v 1.3 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -80,7 +80,7 @@ xics_intr_establish(void *cookie, int *cell, int level,
uint32_t girq = cell[0];
int type = cell[1];
- return _intr_establish(girq, type, level, func, arg, name);
+ return _intr_establish(girq, type, level, ci, func, arg, name);
}
void
diff --git a/sys/arch/powerpc64/dev/xive.c b/sys/arch/powerpc64/dev/xive.c
index b6796f3addd..c5174591d7f 100644
--- a/sys/arch/powerpc64/dev/xive.c
+++ b/sys/arch/powerpc64/dev/xive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xive.c,v 1.12 2020/09/03 20:02:02 kettenis Exp $ */
+/* $OpenBSD: xive.c,v 1.13 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -150,7 +150,7 @@ struct cfdriver xive_cd = {
};
void xive_hvi(struct trapframe *);
-void *xive_intr_establish(uint32_t, int, int,
+void *xive_intr_establish(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *);
void xive_intr_send_ipi(void *);
void xive_setipl(int);
@@ -248,7 +248,7 @@ xive_activate(struct device *self, int act)
}
void *
-xive_intr_establish(uint32_t girq, int type, int level,
+xive_intr_establish(uint32_t girq, int type, int level, struct cpu_info *ci,
int (*func)(void *), void *arg, const char *name)
{
struct xive_softc *sc = xive_sc;
@@ -285,7 +285,7 @@ xive_intr_establish(uint32_t girq, int type, int level,
return NULL;
}
- error = opal_xive_set_irq_config(girq, mfpir(),
+ error = opal_xive_set_irq_config(girq, ci->ci_pir,
xive_prio(level & IPL_IRQMASK), lirq);
if (error != OPAL_SUCCESS) {
if (trig != eoi && trig != 0)
diff --git a/sys/arch/powerpc64/include/intr.h b/sys/arch/powerpc64/include/intr.h
index 89569713cf5..053a1c16b76 100644
--- a/sys/arch/powerpc64/include/intr.h
+++ b/sys/arch/powerpc64/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.10 2020/08/23 13:50:34 kettenis Exp $ */
+/* $OpenBSD: intr.h,v 1.11 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -87,7 +87,7 @@ void intr_init(void);
#define IST_EDGE 0
#define IST_LEVEL 1
-void *intr_establish(uint32_t, int, int,
+void *intr_establish(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *);
#define IPI_NOP 0
@@ -97,7 +97,7 @@ void intr_send_ipi(struct cpu_info *, int);
extern void (*_exi)(struct trapframe *);
extern void (*_hvi)(struct trapframe *);
-extern void *(*_intr_establish)(uint32_t, int, int,
+extern void *(*_intr_establish)(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *);
extern void (*_intr_send_ipi)(void *);
extern void (*_setipl)(int);
diff --git a/sys/arch/powerpc64/include/pci_machdep.h b/sys/arch/powerpc64/include/pci_machdep.h
index d44e0b01537..3bf94cef243 100644
--- a/sys/arch/powerpc64/include/pci_machdep.h
+++ b/sys/arch/powerpc64/include/pci_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.h,v 1.3 2020/09/01 19:09:47 kettenis Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.4 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -73,7 +73,8 @@ struct ppc64_pci_chipset {
int, pci_intr_handle_t *);
const char *(*pc_intr_string)(void *, pci_intr_handle_t);
void *(*pc_intr_establish)(void *, pci_intr_handle_t,
- int, int (*)(void *), void *, char *);
+ int, struct cpu_info *, int (*)(void *), void *,
+ char *);
void (*pc_intr_disestablish)(void *, void *);
};
@@ -103,7 +104,11 @@ struct ppc64_pci_chipset {
#define pci_intr_string(c, ih) \
(*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
#define pci_intr_establish(c, ih, l, h, a, nm) \
- (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a), (nm))
+ (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), NULL, (h), (a),\
+ (nm))
+#define pci_intr_establish_cpu(c, ih, l, ci, h, a, nm) \
+ (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (ci), (h), (a),\
+ (nm))
#define pci_intr_disestablish(c, iv) \
(*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
#define pci_probe_device_hook(c, a) (0)
diff --git a/sys/arch/powerpc64/powerpc64/intr.c b/sys/arch/powerpc64/powerpc64/intr.c
index efb54b5e790..c6fc13137a2 100644
--- a/sys/arch/powerpc64/powerpc64/intr.c
+++ b/sys/arch/powerpc64/powerpc64/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.6 2020/08/23 13:50:34 kettenis Exp $ */
+/* $OpenBSD: intr.c,v 1.7 2020/09/21 11:14:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -28,7 +28,7 @@
/* Dummy implementations. */
void dummy_exi(struct trapframe *);
void dummy_hvi(struct trapframe *);
-void *dummy_intr_establish(uint32_t, int, int,
+void *dummy_intr_establish(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *);
void dummy_intr_send_ipi(void *);
void dummy_setipl(int);
@@ -39,7 +39,7 @@ void dummy_setipl(int);
*/
void (*_exi)(struct trapframe *) = dummy_exi;
void (*_hvi)(struct trapframe *) = dummy_hvi;
-void *(*_intr_establish)(uint32_t, int, int,
+void *(*_intr_establish)(uint32_t, int, int, struct cpu_info *,
int (*)(void *), void *, const char *) = dummy_intr_establish;
void (*_intr_send_ipi)(void *) = dummy_intr_send_ipi;
void (*_setipl)(int) = dummy_setipl;
@@ -57,10 +57,13 @@ hvi_intr(struct trapframe *frame)
}
void *
-intr_establish(uint32_t girq, int type, int level,
+intr_establish(uint32_t girq, int type, int level, struct cpu_info *ci,
int (*func)(void *), void *arg, const char *name)
{
- return (*_intr_establish)(girq, type, level, func, arg, name);
+ if (ci == NULL)
+ ci = cpu_info_primary;
+
+ return (*_intr_establish)(girq, type, level, ci, func, arg, name);
}
#define SI_TO_IRQBIT(x) (1 << (x))
@@ -179,7 +182,7 @@ dummy_hvi(struct trapframe *frame)
}
void *
-dummy_intr_establish(uint32_t girq, int type, int level,
+dummy_intr_establish(uint32_t girq, int type, int level, struct cpu_info *ci,
int (*func)(void *), void *arg, const char *name)
{
return NULL;