Date: Tue, 03 Sep 2019 14:07:11 -0000 From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346312 - head/sys/arm/arm Message-ID: <201904171527.x3HFRBHD033626@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Wed Apr 17 15:27:11 2019 New Revision: 346312 URL: https://svnweb.freebsd.org/changeset/base/346312 Log: Only set up the interrupts that will actually be used in arm generic_timer. The code previously set up interrupt handlers for all the interrupt resources available, including for timers that are not in use. That could lead to interrupt storms. For example, if boot firmware enabled the virtual timer but the kernel is using the physical timer, it could get flooded with interrupts on the virtual timer which it cannot shut off. By only setting up an interrupt handler for the hardware that will actually be used, any interrupts from other timer units will remain masked in the interrupt controller. Differential Revision: https://reviews.freebsd.org/D19871 Modified: head/sys/arm/arm/generic_timer.c Modified: head/sys/arm/arm/generic_timer.c ============================================================================== --- head/sys/arm/arm/generic_timer.c Wed Apr 17 14:20:55 2019 (r346311) +++ head/sys/arm/arm/generic_timer.c Wed Apr 17 15:27:11 2019 (r346312) @@ -393,7 +393,7 @@ arm_tmr_attach(device_t dev) pcell_t clock; #endif int error; - int i; + int i, first_timer, last_timer; sc = device_get_softc(dev); if (arm_tmr_sc) @@ -433,17 +433,25 @@ arm_tmr_attach(device_t dev) return (ENXIO); } -#ifdef __arm__ - sc->physical = true; -#else /* __aarch64__ */ - /* If we do not have a virtual timer use the physical. */ - sc->physical = (sc->res[2] == NULL) ? true : false; +#ifdef __aarch64__ + /* Use the virtual timer if we have one. */ + if (sc->res[2] != NULL) { + sc->physical = false; + first_timer = 2; + last_timer = 2; + } else #endif + /* Otherwise set up the secure and non-secure physical timers. */ + { + sc->physical = true; + first_timer = 0; + last_timer = 1; + } arm_tmr_sc = sc; /* Setup secure, non-secure and virtual IRQs handler */ - for (i = 0; i < 3; i++) { + for (i = first_timer; i <= last_timer; i++) { /* If we do not have the interrupt, skip it. */ if (sc->res[i] == NULL) continue;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904171527.x3HFRBHD033626>