From: kettenis Date: Wed, 2 Jun 2021 19:38:14 +0000 (+0000) Subject: Avoid spinning on the kernel lock with interrupts disabled. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=04be1c60337670384415c9885ea5282a024918c9;p=openbsd Avoid spinning on the kernel lock with interrupts disabled. ok gkoehler@ --- diff --git a/sys/arch/powerpc64/dev/xive.c b/sys/arch/powerpc64/dev/xive.c index 5953b66b3aa..5955392c4f2 100644 --- a/sys/arch/powerpc64/dev/xive.c +++ b/sys/arch/powerpc64/dev/xive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xive.c,v 1.15 2020/10/10 17:05:55 kettenis Exp $ */ +/* $OpenBSD: xive.c,v 1.16 2021/06/02 19:38:14 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis * @@ -366,6 +366,31 @@ xive_setipl(int new) intr_restore(msr); } +void +xive_run_handler(struct intrhand *ih) +{ + int handled; + +#ifdef MULTIPROCESSOR + int need_lock; + + if (ih->ih_flags & IPL_MPSAFE) + need_lock = 0; + else + need_lock = (ih->ih_ipl < IPL_SCHED); + + if (need_lock) + KERNEL_LOCK(); +#endif + handled = ih->ih_func(ih->ih_arg); + if (handled) + ih->ih_count.ec_count++; +#ifdef MULTIPROCESSOR + if (need_lock) + KERNEL_UNLOCK(); +#endif +} + void xive_hvi(struct trapframe *frame) { @@ -376,7 +401,6 @@ xive_hvi(struct trapframe *frame) uint32_t *event; uint32_t lirq; int old, new; - int handled; uint16_t ack, he; uint8_t cppr; @@ -415,26 +439,9 @@ xive_hvi(struct trapframe *frame) KASSERT(lirq < XIVE_NUM_IRQS); ih = sc->sc_handler[lirq]; if (ih != NULL) { -#ifdef MULTIPROCESSOR - int need_lock; - - if (ih->ih_flags & IPL_MPSAFE) - need_lock = 0; - else - need_lock = (ih->ih_ipl < IPL_SCHED); - - if (need_lock) - KERNEL_LOCK(); -#endif intr_enable(); - handled = ih->ih_func(ih->ih_arg); + xive_run_handler(ih); intr_disable(); - if (handled) - ih->ih_count.ec_count++; -#ifdef MULTIPROCESSOR - if (need_lock) - KERNEL_UNLOCK(); -#endif xive_eoi(sc, ih); } eq->eq_idx = (eq->eq_idx + 1) & XIVE_EQ_IDX_MASK;