Sat Apr 28 18:26:53 2018 UTC ()
Cover all pic_maxsources lines for armgic_cpu_init_priorities() and
armgic_cpu_update_priorities().

Previously only the first 32 lines were covered, which is significantly
less than the 1000-some interrupt lines possible.

Only relevant to MULTIPROCESSOR configurations.


(jakllsch)
diff -r1.33 -r1.34 src/sys/arch/arm/cortex/gic.c

cvs diff -r1.33 -r1.34 src/sys/arch/arm/cortex/gic.c (expand / switch to unified diff)

--- src/sys/arch/arm/cortex/gic.c 2018/04/01 04:35:04 1.33
+++ src/sys/arch/arm/cortex/gic.c 2018/04/28 18:26:53 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gic.c,v 1.33 2018/04/01 04:35:04 ryo Exp $ */ 1/* $NetBSD: gic.c,v 1.34 2018/04/28 18:26:53 jakllsch Exp $ */
2/*- 2/*-
3 * Copyright (c) 2012 The NetBSD Foundation, Inc. 3 * Copyright (c) 2012 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Matt Thomas of 3am Software Foundry. 7 * by Matt Thomas of 3am Software Foundry.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#include "opt_ddb.h" 31#include "opt_ddb.h"
32#include "opt_multiprocessor.h" 32#include "opt_multiprocessor.h"
33 33
34#define _INTR_PRIVATE 34#define _INTR_PRIVATE
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.33 2018/04/01 04:35:04 ryo Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.34 2018/04/28 18:26:53 jakllsch Exp $");
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/bus.h> 40#include <sys/bus.h>
41#include <sys/cpu.h> 41#include <sys/cpu.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/evcnt.h> 43#include <sys/evcnt.h>
44#include <sys/intr.h> 44#include <sys/intr.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46 46
47#include <arm/armreg.h> 47#include <arm/armreg.h>
48#include <arm/atomic.h> 48#include <arm/atomic.h>
49#include <arm/cpufunc.h> 49#include <arm/cpufunc.h>
50#include <arm/locore.h> 50#include <arm/locore.h>
@@ -392,37 +392,37 @@ armgic_establish_irq(struct pic_softc *p @@ -392,37 +392,37 @@ armgic_establish_irq(struct pic_softc *p
392 */ 392 */
393 const bus_size_t priority_reg = GICD_IPRIORITYRn(is->is_irq / 4); 393 const bus_size_t priority_reg = GICD_IPRIORITYRn(is->is_irq / 4);
394 uint32_t priority = gicd_read(sc, priority_reg); 394 uint32_t priority = gicd_read(sc, priority_reg);
395 priority &= ~(0xff << byte_shift); 395 priority &= ~(0xff << byte_shift);
396 priority |= armgic_ipl_to_priority(is->is_ipl) << byte_shift; 396 priority |= armgic_ipl_to_priority(is->is_ipl) << byte_shift;
397 gicd_write(sc, priority_reg, priority); 397 gicd_write(sc, priority_reg, priority);
398} 398}
399 399
400#ifdef MULTIPROCESSOR 400#ifdef MULTIPROCESSOR
401static void 401static void
402armgic_cpu_init_priorities(struct armgic_softc *sc) 402armgic_cpu_init_priorities(struct armgic_softc *sc)
403{ 403{
404 /* Set lowest priority, i.e. disable interrupts */ 404 /* Set lowest priority, i.e. disable interrupts */
405 for (size_t i = 0; i < 32; i += 4) { 405 for (size_t i = 0; i < sc->sc_pic.pic_maxsources; i += 4) {
406 const bus_size_t priority_reg = GICD_IPRIORITYRn(i / 4); 406 const bus_size_t priority_reg = GICD_IPRIORITYRn(i / 4);
407 gicd_write(sc, priority_reg, ~0); 407 gicd_write(sc, priority_reg, ~0);
408 } 408 }
409} 409}
410 410
411static void 411static void
412armgic_cpu_update_priorities(struct armgic_softc *sc) 412armgic_cpu_update_priorities(struct armgic_softc *sc)
413{ 413{
414 uint32_t enabled = sc->sc_enabled_local; 414 uint32_t enabled = sc->sc_enabled_local;
415 for (size_t i = 0; i < 32; i += 4, enabled >>= 4) { 415 for (size_t i = 0; i < sc->sc_pic.pic_maxsources; i += 4, enabled >>= 4) {
416 const bus_size_t priority_reg = GICD_IPRIORITYRn(i / 4); 416 const bus_size_t priority_reg = GICD_IPRIORITYRn(i / 4);
417 uint32_t priority = gicd_read(sc, priority_reg); 417 uint32_t priority = gicd_read(sc, priority_reg);
418 uint32_t byte_mask = 0xff; 418 uint32_t byte_mask = 0xff;
419 size_t byte_shift = 0; 419 size_t byte_shift = 0;
420 for (size_t j = 0; j < 4; j++, byte_mask <<= 8, byte_shift += 8) { 420 for (size_t j = 0; j < 4; j++, byte_mask <<= 8, byte_shift += 8) {
421 struct intrsource * const is = sc->sc_pic.pic_sources[i+j]; 421 struct intrsource * const is = sc->sc_pic.pic_sources[i+j];
422 priority |= byte_mask; 422 priority |= byte_mask;
423 if (is == NULL || is == &armgic_dummy_source) 423 if (is == NULL || is == &armgic_dummy_source)
424 continue; 424 continue;
425 priority &= ~byte_mask; 425 priority &= ~byte_mask;
426 priority |= armgic_ipl_to_priority(is->is_ipl) << byte_shift; 426 priority |= armgic_ipl_to_priority(is->is_ipl) << byte_shift;
427 } 427 }
428 gicd_write(sc, priority_reg, priority); 428 gicd_write(sc, priority_reg, priority);