Skip to content

Commit efed4f5

Browse files
committed
kern/intr: switch intr_event_handle() to return stray count
Comparable to the current situation. Minor savings, one caller simply passes the count directly through. Differential Revision: https://reviews.freebsd.org/D38449
1 parent 78256b6 commit efed4f5

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

sys/kern/kern_intr.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,9 +1411,9 @@ intr_event_incr(struct intr_event *ie)
14111411
*
14121412
* Return value:
14131413
* o 0: everything ok.
1414-
* o EINVAL: stray interrupt.
1414+
* o non-0: stray interrupt, current count.
14151415
*/
1416-
int
1416+
u_long
14171417
intr_event_handle(struct intr_event *ie, struct trapframe *frame)
14181418
{
14191419
struct intr_handler *ih;
@@ -1431,16 +1431,14 @@ intr_event_handle(struct intr_event *ie, struct trapframe *frame)
14311431

14321432
/* An interrupt with no event is a stray interrupt. */
14331433
if (ie == NULL)
1434-
return (EINVAL);
1434+
return (~0UL);
14351435

14361436
/* Increment the interrupt counter. */
14371437
intr_event_incr(ie);
14381438

14391439
/* An interrupt with no handlers is a stray interrupt. */
1440-
if (CK_SLIST_EMPTY(&ie->ie_handlers)) {
1441-
++ie->ie_stray;
1442-
return (EINVAL);
1443-
}
1440+
if (CK_SLIST_EMPTY(&ie->ie_handlers))
1441+
return (++ie->ie_stray);
14441442

14451443
/*
14461444
* Execute fast interrupt handlers directly.
@@ -1537,7 +1535,7 @@ intr_event_handle(struct intr_event *ie, struct trapframe *frame)
15371535
/* The interrupt is not aknowledged by any filter and has no ithread. */
15381536
if (!thread && !filter) {
15391537
++ie->ie_stray;
1540-
return (stray ? EINVAL : 0);
1538+
return (stray ? ie->ie_stray : 0);
15411539
}
15421540
return (0);
15431541
}

sys/sys/interrupt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int intr_event_describe_handler(struct intr_event *ie, void *cookie,
180180
const char *descr);
181181
int intr_event_destroy(struct intr_event *ie);
182182
void intr_event_incr(struct intr_event *ie);
183-
int intr_event_handle(struct intr_event *ie, struct trapframe *frame);
183+
u_long intr_event_handle(struct intr_event *ie, struct trapframe *frame);
184184
int intr_event_remove_handler(void *cookie);
185185
int intr_event_suspend_handler(void *cookie);
186186
int intr_event_resume_handler(void *cookie);

sys/x86/x86/intr_machdep.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)
306306
{
307307
struct intr_event *ie;
308308
int vector;
309+
u_long strays;
309310

310311
/*
311312
* We count software interrupts when we process them. The
@@ -329,11 +330,11 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)
329330
* For stray interrupts, mask and EOI the source, bump the
330331
* stray count, and log the condition.
331332
*/
332-
if (intr_event_handle(ie, frame) != 0) {
333+
if ((strays = intr_event_handle(ie, frame)) != 0) {
333334
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
334-
if (*isrc->is_straycount < INTR_STRAY_LOG_MAX)
335+
if (strays < INTR_STRAY_LOG_MAX)
335336
log(LOG_ERR, "stray irq%d\n", vector);
336-
else if (*isrc->is_straycount == INTR_STRAY_LOG_MAX)
337+
else if (strays == INTR_STRAY_LOG_MAX)
337338
log(LOG_CRIT,
338339
"too many stray irq %d's: not logging anymore\n",
339340
vector);

0 commit comments

Comments
 (0)