summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-06-28 01:52:27 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-06-28 01:52:27 +0000
commit9c37e1f32dbe8da7496bb5fe00d00e9d3423541f (patch)
tree15610a98e1bf6694723cdc62e0747af3ac539908
parentad859de0f075c553882080921983e2565d6ec816 (diff)
Use new event counter API for interrupt counting on amd64. Based in part
on some changes in the i386 codebase.
-rw-r--r--sys/arch/amd64/amd64/genassym.cf3
-rw-r--r--sys/arch/amd64/amd64/intr.c8
-rw-r--r--sys/arch/amd64/amd64/lapic.c9
-rw-r--r--sys/arch/amd64/amd64/vector.S7
-rw-r--r--sys/arch/amd64/include/intr.h11
-rw-r--r--sys/arch/amd64/include/types.h3
-rw-r--r--sys/arch/amd64/isa/clock.c5
-rw-r--r--sys/arch/amd64/isa/isa_machdep.c9
-rw-r--r--sys/arch/amd64/pci/pci_machdep.c4
-rw-r--r--sys/arch/amd64/pci/pciide_machdep.c5
10 files changed, 44 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/genassym.cf b/sys/arch/amd64/amd64/genassym.cf
index 43f25173c7f..8fc08e90ef2 100644
--- a/sys/arch/amd64/amd64/genassym.cf
+++ b/sys/arch/amd64/amd64/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.6 2004/06/25 11:03:27 art Exp $
+# $OpenBSD: genassym.cf,v 1.7 2004/06/28 01:52:24 deraadt Exp $
# Written by Artur Grabowski art@openbsd.org, Public Domain
@@ -125,6 +125,7 @@ member ih_fun
member ih_arg
member ih_next
member ih_level
+member IH_COUNT ih_count.ec_count
struct ioapic_softc
member IOAPIC_SC_REG sc_reg
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c
index d3bbfa778dc..bcc97c7f7b4 100644
--- a/sys/arch/amd64/amd64/intr.c
+++ b/sys/arch/amd64/amd64/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.3 2004/06/26 05:29:17 art Exp $ */
+/* $OpenBSD: intr.c,v 1.4 2004/06/28 01:52:24 deraadt Exp $ */
/* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */
/*
@@ -347,7 +347,7 @@ found:
void *
intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level,
- int (*handler)(void *), void *arg)
+ int (*handler)(void *), void *arg, char *what)
{
struct intrhand **p, *q, *ih;
struct cpu_info *ci;
@@ -438,6 +438,9 @@ intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level,
ih->ih_pin = pin;
ih->ih_cpu = ci;
ih->ih_slot = slot;
+ evcount_attach(&ih->ih_count, what, (void *)&ih->ih_level,
+ &evcount_intr);
+
*p = ih;
intr_calculatemasks(ci);
@@ -525,6 +528,7 @@ intr_disestablish(struct intrhand *ih)
idt_vec_free(idtvec);
}
+ evcount_detach(&ih->ih_count);
free(ih, M_DEVBUF);
simple_unlock(&ci->ci_slock);
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c
index 70c1536fb13..c2d19b38054 100644
--- a/sys/arch/amd64/amd64/lapic.c
+++ b/sys/arch/amd64/amd64/lapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lapic.c,v 1.2 2004/06/27 16:17:50 deraadt Exp $ */
+/* $OpenBSD: lapic.c,v 1.3 2004/06/28 01:52:24 deraadt Exp $ */
/* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
@@ -63,6 +63,8 @@
#include <machine/i82489reg.h>
#include <machine/i82489var.h>
+struct evcount clk_count;
+
void lapic_delay(int);
void lapic_microtime(struct timeval *);
static u_int32_t lapic_gettick(void);
@@ -194,6 +196,7 @@ void
lapic_boot_init(lapic_base)
paddr_t lapic_base;
{
+ static u_int64_t clk_irq = 0;
lapic_map(lapic_base);
@@ -206,6 +209,8 @@ lapic_boot_init(lapic_base)
idt_allocmap[LAPIC_TIMER_VECTOR] = 1;
idt_vec_set(LAPIC_TIMER_VECTOR, Xintr_lapic_ltimer);
+
+ evcount_attach(&clk_count, "clock", (void *)&clk_irq, &evcount_intr);
}
static inline u_int32_t lapic_gettick()
@@ -231,6 +236,8 @@ lapic_clockintr(void *arg, struct intrframe frame)
{
hardclock((struct clockframe *)&frame);
+
+ clk_count.ec_count++;
}
void
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index 9504d3112b4..db35fbd1edd 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: vector.S,v 1.3 2004/06/25 17:27:01 andreas Exp $ */
+/* $OpenBSD: vector.S,v 1.4 2004/06/28 01:52:24 deraadt Exp $ */
/* $NetBSD: vector.S,v 1.2 2003/05/04 23:46:41 fvdl Exp $ */
/*
@@ -414,7 +414,10 @@ IDTVEC(intr_/**/name/**/num) ;\
movq %rsp, %rdi ;\
8: movl %r12d,CPUVAR(ILEVEL) ;\
call *IH_FUN(%rbx) /* call it */ ;\
- movq IH_NEXT(%rbx),%rbx /* next handler in chain */ ;\
+ orq %rax,%rax /* should it be counted? */ ;\
+ jz 4f ;\
+ incq IH_COUNT(%rbx) ;\
+4: movq IH_NEXT(%rbx),%rbx /* next handler in chain */ ;\
testq %rbx,%rbx ;\
jnz 6b ;\
5: \
diff --git a/sys/arch/amd64/include/intr.h b/sys/arch/amd64/include/intr.h
index 69d6247e700..cba5f9e11f1 100644
--- a/sys/arch/amd64/include/intr.h
+++ b/sys/arch/amd64/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.4 2004/06/26 05:29:17 art Exp $ */
+/* $OpenBSD: intr.h,v 1.5 2004/06/28 01:52:26 deraadt Exp $ */
/* $NetBSD: intr.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
/*-
@@ -45,6 +45,8 @@
#ifndef _LOCORE
#include <machine/cpu.h>
+#include <sys/evcount.h>
+
/*
* Struct describing an interrupt source for a CPU. struct cpu_info
* has an array of MAX_INTR_SOURCES of these. The index in the array
@@ -103,7 +105,7 @@ struct intrhand {
int ih_slot;
struct cpu_info *ih_cpu;
int ih_irq;
- char *ih_what;
+ struct evcount ih_count;
};
#define IMASK(ci,level) (ci)->ci_imask[(level)]
@@ -218,8 +220,9 @@ int x86_nmi(void);
void intr_calculatemasks(struct cpu_info *);
int intr_allocate_slot_cpu(struct cpu_info *, struct pic *, int, int *);
int intr_allocate_slot(struct pic *, int, int, int, struct cpu_info **, int *,
- int *);
-void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *);
+ int *);
+void *intr_establish(int, struct pic *, int, int, int, int (*)(void *),
+ void *, char *);
void intr_disestablish(struct intrhand *);
void cpu_intr_init(struct cpu_info *);
int intr_find_mpmapping(int bus, int pin, int *handle);
diff --git a/sys/arch/amd64/include/types.h b/sys/arch/amd64/include/types.h
index 6b7458c307a..8ef62891ef4 100644
--- a/sys/arch/amd64/include/types.h
+++ b/sys/arch/amd64/include/types.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: types.h,v 1.3 2004/06/22 01:16:50 art Exp $ */
+/* $OpenBSD: types.h,v 1.4 2004/06/28 01:52:26 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -70,5 +70,6 @@ typedef long register_t;
#define __HAVE_NWSCONS
#define __HAVE_GENERIC_SOFT_INTERRUPTS
#define __HAVE_CPUINFO
+#define __HAVE_EVCOUNT
#endif /* _MACHTYPES_H_ */
diff --git a/sys/arch/amd64/isa/clock.c b/sys/arch/amd64/isa/clock.c
index 2132a6e5b63..88d469685c9 100644
--- a/sys/arch/amd64/isa/clock.c
+++ b/sys/arch/amd64/isa/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.4 2004/06/25 11:03:28 art Exp $ */
+/* $OpenBSD: clock.c,v 1.5 2004/06/28 01:52:26 deraadt Exp $ */
/* $NetBSD: clock.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */
/*-
@@ -508,7 +508,8 @@ i8254_initclocks()
* XXX If you're doing strange things with multiple clocks, you might
* want to keep track of clock handlers.
*/
- isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK, clockintr,0,"clock");
+ isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK, clockintr,
+ 0, "clock");
isa_intr_establish(NULL, 8, IST_PULSE, IPL_CLOCK, rtcintr, 0, "rtc");
mc146818_write(NULL, MC_REGA, MC_BASE_32_KHz | MC_RATE_128_Hz);
diff --git a/sys/arch/amd64/isa/isa_machdep.c b/sys/arch/amd64/isa/isa_machdep.c
index 2b3e249e7ae..4487ec16026 100644
--- a/sys/arch/amd64/isa/isa_machdep.c
+++ b/sys/arch/amd64/isa/isa_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isa_machdep.c,v 1.2 2004/06/13 21:49:13 niklas Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.3 2004/06/28 01:52:26 deraadt Exp $ */
/* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */
#define ISA_DMA_STATS
@@ -370,7 +370,8 @@ isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg, ih_what)
struct intrhand **p, *q, *ih;
static struct intrhand fakehand = {fakeintr};
- return intr_establish(irq, &i8259_pic, irq, type, level, ih_fun, ih_arg);
+ return intr_establish(irq, &i8259_pic, irq, type, level, ih_fun,
+ ih_arg, ih_what);
/* no point in sleeping unless someone can free memory. */
ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
@@ -426,7 +427,8 @@ isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg, ih_what)
ih->ih_next = NULL;
ih->ih_level = level;
ih->ih_irq = irq;
- ih->ih_what = ih_what;
+ evcount_attach(&ih->ih_count, ih_what, (void *)&ih->ih_irq,
+ &evcount_intr);
*p = ih;
return (ih);
@@ -460,6 +462,7 @@ isa_intr_disestablish(ic, arg)
*p = q->ih_next;
else
panic("intr_disestablish: handler not registered");
+ evcount_detach(&ih->ih_count);
free(ih, M_DEVBUF);
if (intrhand[irq] == NULL)
diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c
index e1af0882118..aa29dc115bc 100644
--- a/sys/arch/amd64/pci/pci_machdep.c
+++ b/sys/arch/amd64/pci/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.c,v 1.2 2004/06/25 11:03:28 art Exp $ */
+/* $OpenBSD: pci_machdep.c,v 1.3 2004/06/28 01:52:26 deraadt Exp $ */
/* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
@@ -635,7 +635,7 @@ pci_intr_establish(pc, ih, level, func, arg, what)
}
#endif
- return intr_establish(irq, pic, pin, IST_LEVEL, level, func, arg);
+ return intr_establish(irq, pic, pin, IST_LEVEL, level, func, arg, what);
}
void
diff --git a/sys/arch/amd64/pci/pciide_machdep.c b/sys/arch/amd64/pci/pciide_machdep.c
index 9b24cf40032..17e30d1c5e3 100644
--- a/sys/arch/amd64/pci/pciide_machdep.c
+++ b/sys/arch/amd64/pci/pciide_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pciide_machdep.c,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: pciide_machdep.c,v 1.2 2004/06/28 01:52:26 deraadt Exp $ */
/* $NetBSD: pciide_machdep.c,v 1.2 1999/02/19 18:01:27 mycroft Exp $ */
/*
@@ -64,7 +64,8 @@ pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
void *cookie;
irq = PCIIDE_COMPAT_IRQ(chan);
- cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg, dev->dv_xname);
+ cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg,
+ dev->dv_xname);
return (cookie);
}