summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-11-19 22:11:55 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-11-19 22:11:55 +0000
commit8b4fbc570dc68077c28460de25474124fdc4231b (patch)
tree0d712401b91957a293e8feaf0668af91c166b83d
parentf7612496c42aad16914c4f2cdc421eac18204f4c (diff)
Be more conservative in openpic_enable_irq() and only reprogram the vector
register if it changes.
-rw-r--r--sys/arch/mvmeppc/dev/openpic.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sys/arch/mvmeppc/dev/openpic.c b/sys/arch/mvmeppc/dev/openpic.c
index 08a9b734478..da618ab7e20 100644
--- a/sys/arch/mvmeppc/dev/openpic.c
+++ b/sys/arch/mvmeppc/dev/openpic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openpic.c,v 1.18 2004/11/19 22:10:24 miod Exp $ */
+/* $OpenBSD: openpic.c,v 1.19 2004/11/19 22:11:54 miod Exp $ */
/*-
* Copyright (c) 1995 Per Fogelstrom
@@ -713,7 +713,7 @@ openpic_enable_irq(irq, type)
int irq;
int type;
{
- u_int x;
+ u_int x, isrc;
#ifdef DIAGNOSTIC
/* skip invalid irqs */
@@ -722,23 +722,26 @@ openpic_enable_irq(irq, type)
#endif
irq -= PIC_OFFSET;
- while ((x = openpic_read(OPENPIC_SRC_VECTOR(irq))) & OPENPIC_ACTIVITY) {
- x = openpic_iack(0);
- openpic_eoi(0);
- }
+ x = openpic_read(OPENPIC_SRC_VECTOR(irq));
- x &= ~(OPENPIC_IMASK|OPENPIC_SENSE_LEVEL|OPENPIC_SENSE_EDGE|
- OPENPIC_POLARITY_POSITIVE);
-#if 1
- if (irq == 0) {
- x |= OPENPIC_POLARITY_POSITIVE;
- }
-#endif
+ isrc = x & ~(OPENPIC_IMASK | OPENPIC_SENSE_LEVEL |
+ OPENPIC_POLARITY_POSITIVE | OPENPIC_ACTIVITY);
+ if (irq == 0)
+ isrc |= OPENPIC_POLARITY_POSITIVE;
if (type == IST_LEVEL)
- x |= OPENPIC_SENSE_LEVEL;
+ isrc |= OPENPIC_SENSE_LEVEL;
else
- x |= OPENPIC_SENSE_EDGE;
- openpic_write(OPENPIC_SRC_VECTOR(irq), x);
+ isrc |= OPENPIC_SENSE_EDGE;
+
+ /* Ack all pending interrupts if this one is pending. */
+ while (x & OPENPIC_ACTIVITY) {
+ (void)openpic_iack(0);
+ openpic_eoi(0);
+ x = openpic_read(OPENPIC_SRC_VECTOR(irq));
+ }
+
+ if (x != isrc)
+ openpic_write(OPENPIC_SRC_VECTOR(irq), isrc);
}
void