summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2011-05-01 21:59:38 +0000
committerkettenis <kettenis@openbsd.org>2011-05-01 21:59:38 +0000
commitb83c2504e340b3fa0dc5deba7f46bfcecb7fd1dd (patch)
tree2b4c716bdd2e32524c425dd8080e546a546e8ac0
parentsync (diff)
downloadwireguard-openbsd-b83c2504e340b3fa0dc5deba7f46bfcecb7fd1dd.tar.xz
wireguard-openbsd-b83c2504e340b3fa0dc5deba7f46bfcecb7fd1dd.zip
Fix counting of interrupts for devices that attach to elroy(4). Shared
interrupts would be counted double, once for the interrupting device and once for the device at the head of the chain. The handlers would run properly though. Avoid this by giving each device its own interrupt counter instead of using the counter provided by the generic interrupt handling code for the head of the chain.
-rw-r--r--sys/arch/hppa/dev/apic.c23
-rw-r--r--sys/arch/hppa/hppa/intr.c5
2 files changed, 16 insertions, 12 deletions
diff --git a/sys/arch/hppa/dev/apic.c b/sys/arch/hppa/dev/apic.c
index 0c58d0fd445..0b88d7740f9 100644
--- a/sys/arch/hppa/dev/apic.c
+++ b/sys/arch/hppa/dev/apic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apic.c,v 1.13 2011/04/23 22:20:22 kettenis Exp $ */
+/* $OpenBSD: apic.c,v 1.14 2011/05/01 21:59:39 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -175,29 +175,30 @@ apic_intr_establish(void *v, pci_intr_handle_t ih,
return NULL;
}
+ cnt = malloc(sizeof(struct evcount), M_DEVBUF, M_NOWAIT);
+ if (!cnt) {
+ free(aiv, M_DEVBUF);
+ return (NULL);
+ }
+
aiv->sc = sc;
aiv->ih = ih;
aiv->handler = handler;
aiv->arg = arg;
aiv->next = NULL;
- aiv->cnt = NULL;
- if (apic_intr_list[irq]) {
- cnt = malloc(sizeof(struct evcount), M_DEVBUF, M_NOWAIT);
- if (!cnt) {
- free(aiv, M_DEVBUF);
- return (NULL);
- }
+ aiv->cnt = cnt;
+
+ evcount_attach(cnt, name, NULL);
- evcount_attach(cnt, name, NULL);
+ if (apic_intr_list[irq]) {
biv = apic_intr_list[irq];
while (biv->next)
biv = biv->next;
biv->next = aiv;
- aiv->cnt = cnt;
return (arg);
}
- if ((iv = cpu_intr_establish(pri, irq, apic_intr, aiv, name))) {
+ if ((iv = cpu_intr_establish(pri, irq, apic_intr, aiv, NULL))) {
ent0 = (31 - irq) & APIC_ENT0_VEC;
ent0 |= apic_get_int_ent0(sc, line);
#if 0
diff --git a/sys/arch/hppa/hppa/intr.c b/sys/arch/hppa/hppa/intr.c
index a703a9dd7f8..87720c8eea4 100644
--- a/sys/arch/hppa/hppa/intr.c
+++ b/sys/arch/hppa/hppa/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.38 2011/03/24 10:52:22 kettenis Exp $ */
+/* $OpenBSD: intr.c,v 1.39 2011/05/01 21:59:38 kettenis Exp $ */
/*
* Copyright (c) 2002-2004 Michael Shalayeff
@@ -229,6 +229,9 @@ cpu_intr_establish(int pri, int irq, int (*handler)(void *), void *arg,
ev->share = iv->share, iv->share = ev;
free(cnt, M_DEVBUF);
iv->cnt = NULL;
+ } else if (name == NULL) {
+ free(cnt, M_DEVBUF);
+ iv->cnt = NULL;
} else
evcount_attach(cnt, name, NULL);