Thu Jul 16 21:33:50 2020 UTC ()
Support 128 IRQs instead of 64. This is icky and needs to be cleaned up.


(jmcneill)
diff -r1.14 -r1.15 src/sys/arch/mips/cavium/octeon_intr.c
diff -r1.13 -r1.14 src/sys/arch/mips/cavium/octeonvar.h

cvs diff -r1.14 -r1.15 src/sys/arch/mips/cavium/octeon_intr.c (expand / switch to unified diff)

--- src/sys/arch/mips/cavium/octeon_intr.c 2020/06/23 05:14:39 1.14
+++ src/sys/arch/mips/cavium/octeon_intr.c 2020/07/16 21:33:50 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: octeon_intr.c,v 1.14 2020/06/23 05:14:39 simonb Exp $ */ 1/* $NetBSD: octeon_intr.c,v 1.15 2020/07/16 21:33:50 jmcneill Exp $ */
2/* 2/*
3 * Copyright 2001, 2002 Wasabi Systems, Inc. 3 * Copyright 2001, 2002 Wasabi Systems, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc. 6 * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -34,27 +34,27 @@ @@ -34,27 +34,27 @@
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37/* 37/*
38 * Platform-specific interrupt support for the MIPS Malta. 38 * Platform-specific interrupt support for the MIPS Malta.
39 */ 39 */
40 40
41#include "opt_multiprocessor.h" 41#include "opt_multiprocessor.h"
42 42
43#include "cpunode.h" 43#include "cpunode.h"
44#define __INTR_PRIVATE 44#define __INTR_PRIVATE
45 45
46#include <sys/cdefs.h> 46#include <sys/cdefs.h>
47__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.14 2020/06/23 05:14:39 simonb Exp $"); 47__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.15 2020/07/16 21:33:50 jmcneill Exp $");
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/cpu.h> 50#include <sys/cpu.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/device.h> 52#include <sys/device.h>
53#include <sys/intr.h> 53#include <sys/intr.h>
54#include <sys/kernel.h> 54#include <sys/kernel.h>
55#include <sys/kmem.h> 55#include <sys/kmem.h>
56#include <sys/atomic.h> 56#include <sys/atomic.h>
57 57
58#include <lib/libkern/libkern.h> 58#include <lib/libkern/libkern.h>
59 59
60#include <mips/locore.h> 60#include <mips/locore.h>
@@ -70,27 +70,27 @@ static const struct ipl_sr_map octeon_ip @@ -70,27 +70,27 @@ static const struct ipl_sr_map octeon_ip
70 .sr_bits = { 70 .sr_bits = {
71 [IPL_NONE] = 0, 71 [IPL_NONE] = 0,
72 [IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0, 72 [IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0,
73 [IPL_SOFTNET] = MIPS_SOFT_INT_MASK, 73 [IPL_SOFTNET] = MIPS_SOFT_INT_MASK,
74 [IPL_VM] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0, 74 [IPL_VM] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0,
75 [IPL_SCHED] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0 75 [IPL_SCHED] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0
76 | MIPS_INT_MASK_1 | MIPS_INT_MASK_5, 76 | MIPS_INT_MASK_1 | MIPS_INT_MASK_5,
77 [IPL_DDB] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0 77 [IPL_DDB] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0
78 | MIPS_INT_MASK_1 | MIPS_INT_MASK_5, 78 | MIPS_INT_MASK_1 | MIPS_INT_MASK_5,
79 [IPL_HIGH] = MIPS_INT_MASK, 79 [IPL_HIGH] = MIPS_INT_MASK,
80 }, 80 },
81}; 81};
82 82
83const char * const octeon_intrnames[NIRQS] = { 83const char * octeon_intrnames[NIRQS] = {
84 "workq 0", 84 "workq 0",
85 "workq 1", 85 "workq 1",
86 "workq 2", 86 "workq 2",
87 "workq 3", 87 "workq 3",
88 "workq 4", 88 "workq 4",
89 "workq 5", 89 "workq 5",
90 "workq 6", 90 "workq 6",
91 "workq 7", 91 "workq 7",
92 "workq 8", 92 "workq 8",
93 "workq 9", 93 "workq 9",
94 "workq 10", 94 "workq 10",
95 "workq 11", 95 "workq 11",
96 "workq 12", 96 "workq 12",
@@ -181,52 +181,56 @@ struct octeon_intrhand *octciu_intrs[NIR @@ -181,52 +181,56 @@ struct octeon_intrhand *octciu_intrs[NIR
181#endif 181#endif
182}; 182};
183 183
184kmutex_t octeon_intr_lock; 184kmutex_t octeon_intr_lock;
185 185
186#define X(a) MIPS_PHYS_TO_XKPHYS(OCTEON_CCA_NONE, (a)) 186#define X(a) MIPS_PHYS_TO_XKPHYS(OCTEON_CCA_NONE, (a))
187 187
188struct cpu_softc octeon_cpu0_softc = { 188struct cpu_softc octeon_cpu0_softc = {
189 .cpu_ci = &cpu_info_store, 189 .cpu_ci = &cpu_info_store,
190 .cpu_int0_sum0 = X(CIU_INT0_SUM0), 190 .cpu_int0_sum0 = X(CIU_INT0_SUM0),
191 .cpu_int1_sum0 = X(CIU_INT1_SUM0), 191 .cpu_int1_sum0 = X(CIU_INT1_SUM0),
192 .cpu_int2_sum0 = X(CIU_INT4_SUM0), 192 .cpu_int2_sum0 = X(CIU_INT4_SUM0),
193 193
 194 .cpu_int_sum1 = X(CIU_INT_SUM1),
 195
194 .cpu_int0_en0 = X(CIU_INT0_EN0), 196 .cpu_int0_en0 = X(CIU_INT0_EN0),
195 .cpu_int1_en0 = X(CIU_INT1_EN0), 197 .cpu_int1_en0 = X(CIU_INT1_EN0),
196 .cpu_int2_en0 = X(CIU_INT4_EN00), 198 .cpu_int2_en0 = X(CIU_INT4_EN00),
197 199
198 .cpu_int0_en1 = X(CIU_INT0_EN1), 200 .cpu_int0_en1 = X(CIU_INT0_EN1),
199 .cpu_int1_en1 = X(CIU_INT1_EN1), 201 .cpu_int1_en1 = X(CIU_INT1_EN1),
200 .cpu_int2_en1 = X(CIU_INT4_EN01), 202 .cpu_int2_en1 = X(CIU_INT4_EN01),
201 203
202 .cpu_int32_en = X(CIU_INT32_EN0), 204 .cpu_int32_en = X(CIU_INT32_EN0),
203 205
204 .cpu_wdog = X(CIU_WDOG0), 206 .cpu_wdog = X(CIU_WDOG0),
205 .cpu_pp_poke = X(CIU_PP_POKE0), 207 .cpu_pp_poke = X(CIU_PP_POKE0),
206 208
207#ifdef MULTIPROCESSOR 209#ifdef MULTIPROCESSOR
208 .cpu_mbox_set = X(CIU_MBOX_SET0), 210 .cpu_mbox_set = X(CIU_MBOX_SET0),
209 .cpu_mbox_clr = X(CIU_MBOX_CLR0), 211 .cpu_mbox_clr = X(CIU_MBOX_CLR0),
210#endif 212#endif
211}; 213};
212 214
213#ifdef MULTIPROCESSOR 215#ifdef MULTIPROCESSOR
214/* XXX limit of two CPUs ... */ 216/* XXX limit of two CPUs ... */
215struct cpu_softc octeon_cpu1_softc = { 217struct cpu_softc octeon_cpu1_softc = {
216 .cpu_int0_sum0 = X(CIU_INT2_SUM0), 218 .cpu_int0_sum0 = X(CIU_INT2_SUM0),
217 .cpu_int1_sum0 = X(CIU_INT3_SUM0), 219 .cpu_int1_sum0 = X(CIU_INT3_SUM0),
218 .cpu_int2_sum0 = X(CIU_INT4_SUM1), 220 .cpu_int2_sum0 = X(CIU_INT4_SUM1),
219 221
 222 .cpu_int_sum1 = X(CIU_INT_SUM1),
 223
220 .cpu_int0_en0 = X(CIU_INT2_EN0), 224 .cpu_int0_en0 = X(CIU_INT2_EN0),
221 .cpu_int1_en0 = X(CIU_INT3_EN0), 225 .cpu_int1_en0 = X(CIU_INT3_EN0),
222 .cpu_int2_en0 = X(CIU_INT4_EN10), 226 .cpu_int2_en0 = X(CIU_INT4_EN10),
223 227
224 .cpu_int0_en1 = X(CIU_INT2_EN1), 228 .cpu_int0_en1 = X(CIU_INT2_EN1),
225 .cpu_int1_en1 = X(CIU_INT3_EN1), 229 .cpu_int1_en1 = X(CIU_INT3_EN1),
226 .cpu_int2_en1 = X(CIU_INT4_EN11), 230 .cpu_int2_en1 = X(CIU_INT4_EN11),
227 231
228 .cpu_int32_en = X(CIU_INT32_EN1), 232 .cpu_int32_en = X(CIU_INT32_EN1),
229 233
230 .cpu_wdog = X(CIU_WDOG(1)), 234 .cpu_wdog = X(CIU_WDOG(1)),
231 .cpu_pp_poke = X(CIU_PP_POKE1), 235 .cpu_pp_poke = X(CIU_PP_POKE1),
232 236
@@ -334,35 +338,37 @@ octeon_intr_init(struct cpu_info *ci) @@ -334,35 +338,37 @@ octeon_intr_init(struct cpu_info *ci)
334 338
335 if (ci->ci_dev) 339 if (ci->ci_dev)
336 aprint_verbose_dev(ci->ci_dev, 340 aprint_verbose_dev(ci->ci_dev,
337 "enabling intr masks %#"PRIx64"/%#"PRIx64"/%#"PRIx64"\n", 341 "enabling intr masks %#"PRIx64"/%#"PRIx64"/%#"PRIx64"\n",
338 cpu->cpu_int0_enable0, cpu->cpu_int1_enable0, 342 cpu->cpu_int0_enable0, cpu->cpu_int1_enable0,
339 cpu->cpu_int2_enable0); 343 cpu->cpu_int2_enable0);
340 344
341 mips3_sd(cpu->cpu_int0_en0, cpu->cpu_int0_enable0); 345 mips3_sd(cpu->cpu_int0_en0, cpu->cpu_int0_enable0);
342 mips3_sd(cpu->cpu_int1_en0, cpu->cpu_int1_enable0); 346 mips3_sd(cpu->cpu_int1_en0, cpu->cpu_int1_enable0);
343 mips3_sd(cpu->cpu_int2_en0, cpu->cpu_int2_enable0); 347 mips3_sd(cpu->cpu_int2_en0, cpu->cpu_int2_enable0);
344 348
345 mips3_sd(cpu->cpu_int32_en, 0); 349 mips3_sd(cpu->cpu_int32_en, 0);
346 350
347 mips3_sd(cpu->cpu_int0_en1, 0); // WDOG IPL2 351 mips3_sd(cpu->cpu_int0_en1, cpu->cpu_int0_enable1);
348 mips3_sd(cpu->cpu_int1_en1, 0); // WDOG IPL3 352 mips3_sd(cpu->cpu_int1_en1, cpu->cpu_int1_enable1);
349 mips3_sd(cpu->cpu_int2_en1, 0); // WDOG IPL4 353 mips3_sd(cpu->cpu_int2_en1, cpu->cpu_int2_enable1);
350 354
351#ifdef MULTIPROCESSOR 355#ifdef MULTIPROCESSOR
352 mips3_sd(cpu->cpu_mbox_clr, __BITS(31,0)); 356 mips3_sd(cpu->cpu_mbox_clr, __BITS(31,0));
353#endif 357#endif
354 358
355 for (size_t i = 0; i < NIRQS; i++) { 359 for (int i = 0; i < NIRQS; i++) {
 360 if (octeon_intrnames[i] == NULL)
 361 octeon_intrnames[i] = kmem_asprintf("irq %d", i);
356 evcnt_attach_dynamic(&cpu->cpu_intr_evs[i], 362 evcnt_attach_dynamic(&cpu->cpu_intr_evs[i],
357 EVCNT_TYPE_INTR, NULL, xname, octeon_intrnames[i]); 363 EVCNT_TYPE_INTR, NULL, xname, octeon_intrnames[i]);
358 } 364 }
359} 365}
360 366
361void 367void
362octeon_cal_timer(int corefreq) 368octeon_cal_timer(int corefreq)
363{ 369{
364 /* Compute the number of cycles per second. */ 370 /* Compute the number of cycles per second. */
365 curcpu()->ci_cpu_freq = corefreq; 371 curcpu()->ci_cpu_freq = corefreq;
366 372
367 /* Compute the number of ticks for hz. */ 373 /* Compute the number of ticks for hz. */
368 curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz; 374 curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz;
@@ -401,159 +407,217 @@ octeon_intr_establish(int irq, int ipl,  @@ -401,159 +407,217 @@ octeon_intr_establish(int irq, int ipl,
401 407
402 /* 408 /*
403 * First, make it known. 409 * First, make it known.
404 */ 410 */
405 KASSERTMSG(octciu_intrs[irq] == NULL, "irq %d in use! (%p)", 411 KASSERTMSG(octciu_intrs[irq] == NULL, "irq %d in use! (%p)",
406 irq, octciu_intrs[irq]); 412 irq, octciu_intrs[irq]);
407 413
408 octciu_intrs[irq] = ih; 414 octciu_intrs[irq] = ih;
409 membar_producer(); 415 membar_producer();
410 416
411 /* 417 /*
412 * Now enable it. 418 * Now enable it.
413 */ 419 */
414 const uint64_t irq_mask = __BIT(irq); 420 const int bank = irq / 64;
 421 const uint64_t irq_mask = __BIT(irq % 64);
415 struct cpu_softc * const cpu0 = &octeon_cpu0_softc; 422 struct cpu_softc * const cpu0 = &octeon_cpu0_softc;
416#if MULTIPROCESSOR 423#if MULTIPROCESSOR
417 struct cpu_softc * const cpu1 = &octeon_cpu1_softc; 424 struct cpu_softc * const cpu1 = &octeon_cpu1_softc;
418#endif 425#endif
419 426
420 switch (ipl) { 427 switch (ipl) {
421 case IPL_VM: 428 case IPL_VM:
422 cpu0->cpu_int0_enable0 |= irq_mask; 429 if (bank == 0) {
423 mips3_sd(cpu0->cpu_int0_en0, cpu0->cpu_int0_enable0); 430 cpu0->cpu_int0_enable0 |= irq_mask;
 431 mips3_sd(cpu0->cpu_int0_en0, cpu0->cpu_int0_enable0);
 432 } else {
 433 cpu0->cpu_int0_enable1 |= irq_mask;
 434 mips3_sd(cpu0->cpu_int0_en1, cpu0->cpu_int0_enable1);
 435 }
424 break; 436 break;
425 437
426 case IPL_SCHED: 438 case IPL_SCHED:
427 cpu0->cpu_int1_enable0 |= irq_mask; 439 if (bank == 0) {
428 mips3_sd(cpu0->cpu_int1_en0, cpu0->cpu_int1_enable0); 440 cpu0->cpu_int1_enable0 |= irq_mask;
 441 mips3_sd(cpu0->cpu_int1_en0, cpu0->cpu_int1_enable0);
 442#ifdef MULTIPROCESSOR
 443 cpu1->cpu_int1_enable0 = cpu0->cpu_int1_enable0;
 444 mips3_sd(cpu1->cpu_int1_en0, cpu1->cpu_int1_enable0);
 445#endif
 446 } else {
 447 cpu0->cpu_int1_enable1 |= irq_mask;
 448 mips3_sd(cpu0->cpu_int1_en1, cpu0->cpu_int1_enable1);
429#ifdef MULTIPROCESSOR 449#ifdef MULTIPROCESSOR
430 cpu1->cpu_int1_enable0 = cpu0->cpu_int1_enable0; 450 cpu1->cpu_int1_enable1 = cpu0->cpu_int1_enable1;
431 mips3_sd(cpu1->cpu_int1_en0, cpu1->cpu_int1_enable0); 451 mips3_sd(cpu1->cpu_int1_en1, cpu1->cpu_int1_enable1);
432#endif 452#endif
 453 }
 454
433 break; 455 break;
434 456
435 case IPL_DDB: 457 case IPL_DDB:
436 case IPL_HIGH: 458 case IPL_HIGH:
437 cpu0->cpu_int2_enable0 |= irq_mask; 459 if (bank == 0) {
438 mips3_sd(cpu0->cpu_int2_en0, cpu0->cpu_int2_enable0); 460 cpu0->cpu_int2_enable0 |= irq_mask;
 461 mips3_sd(cpu0->cpu_int2_en0, cpu0->cpu_int2_enable0);
 462#ifdef MULTIPROCESSOR
 463 cpu1->cpu_int2_enable0 = cpu0->cpu_int2_enable0;
 464 mips3_sd(cpu1->cpu_int2_en0, cpu1->cpu_int2_enable0);
 465#endif
 466 } else {
 467 cpu0->cpu_int2_enable1 |= irq_mask;
 468 mips3_sd(cpu0->cpu_int2_en1, cpu0->cpu_int2_enable1);
439#ifdef MULTIPROCESSOR 469#ifdef MULTIPROCESSOR
440 cpu1->cpu_int2_enable0 = cpu0->cpu_int2_enable0; 470 cpu1->cpu_int2_enable1 = cpu0->cpu_int2_enable1;
441 mips3_sd(cpu1->cpu_int2_en0, cpu1->cpu_int2_enable0); 471 mips3_sd(cpu1->cpu_int2_en1, cpu1->cpu_int2_enable1);
442#endif 472#endif
 473 }
443 break; 474 break;
444 } 475 }
445 476
446 mutex_exit(&octeon_intr_lock); 477 mutex_exit(&octeon_intr_lock);
447 478
448 return ih; 479 return ih;
449} 480}
450 481
451void 482void
452octeon_intr_disestablish(void *cookie) 483octeon_intr_disestablish(void *cookie)
453{ 484{
454 struct octeon_intrhand * const ih = cookie; 485 struct octeon_intrhand * const ih = cookie;
455 const int irq = ih->ih_irq & (NIRQS-1); 486 const int irq = ih->ih_irq & (NIRQS-1);
456 const int ipl = ih->ih_ipl; 487 const int ipl = ih->ih_ipl;
457 488
458 mutex_enter(&octeon_intr_lock); 489 mutex_enter(&octeon_intr_lock);
459 490
460 /* 491 /*
461 * First disable it. 492 * First disable it.
462 */ 493 */
463 const uint64_t irq_mask = ~__BIT(irq); 494 const int bank = irq / 64;
 495 const uint64_t irq_mask = ~__BIT(irq % 64);
464 struct cpu_softc * const cpu0 = &octeon_cpu0_softc; 496 struct cpu_softc * const cpu0 = &octeon_cpu0_softc;
465#if MULTIPROCESSOR 497#if MULTIPROCESSOR
466 struct cpu_softc * const cpu1 = &octeon_cpu1_softc; 498 struct cpu_softc * const cpu1 = &octeon_cpu1_softc;
467#endif 499#endif
468 500
469 switch (ipl) { 501 switch (ipl) {
470 case IPL_VM: 502 case IPL_VM:
471 cpu0->cpu_int0_enable0 &= ~irq_mask; 503 if (bank == 0) {
472 mips3_sd(cpu0->cpu_int0_en0, cpu0->cpu_int0_enable0); 504 cpu0->cpu_int0_enable0 &= ~irq_mask;
 505 mips3_sd(cpu0->cpu_int0_en0, cpu0->cpu_int0_enable0);
 506 } else {
 507 cpu0->cpu_int0_enable1 &= ~irq_mask;
 508 mips3_sd(cpu0->cpu_int0_en1, cpu0->cpu_int0_enable1);
 509 }
473 break; 510 break;
474 511
475 case IPL_SCHED: 512 case IPL_SCHED:
476 cpu0->cpu_int1_enable0 &= ~irq_mask; 513 if (bank == 0) {
477 mips3_sd(cpu0->cpu_int1_en0, cpu0->cpu_int1_enable0); 514 cpu0->cpu_int1_enable0 &= ~irq_mask;
 515 mips3_sd(cpu0->cpu_int1_en0, cpu0->cpu_int1_enable0);
 516#ifdef MULTIPROCESSOR
 517 cpu1->cpu_int1_enable0 = cpu0->cpu_int1_enable0;
 518 mips3_sd(cpu1->cpu_int1_en0, cpu1->cpu_int1_enable0);
 519#endif
 520 } else {
 521 cpu0->cpu_int1_enable1 &= ~irq_mask;
 522 mips3_sd(cpu0->cpu_int1_en1, cpu0->cpu_int1_enable1);
478#ifdef MULTIPROCESSOR 523#ifdef MULTIPROCESSOR
479 cpu1->cpu_int1_enable0 = cpu0->cpu_int1_enable0; 524 cpu1->cpu_int1_enable1 = cpu0->cpu_int1_enable1;
480 mips3_sd(cpu1->cpu_int1_en0, cpu1->cpu_int1_enable0); 525 mips3_sd(cpu1->cpu_int1_en1, cpu1->cpu_int1_enable1);
481#endif 526#endif
 527 }
482 break; 528 break;
483 529
484 case IPL_DDB: 530 case IPL_DDB:
485 case IPL_HIGH: 531 case IPL_HIGH:
486 cpu0->cpu_int2_enable0 &= ~irq_mask; 532 if (bank == 0) {
487 mips3_sd(cpu0->cpu_int2_en0, cpu0->cpu_int2_enable0); 533 cpu0->cpu_int2_enable0 &= ~irq_mask;
 534 mips3_sd(cpu0->cpu_int2_en0, cpu0->cpu_int2_enable0);
 535#ifdef MULTIPROCESSOR
 536 cpu1->cpu_int2_enable0 = cpu0->cpu_int2_enable0;
 537 mips3_sd(cpu1->cpu_int2_en0, cpu1->cpu_int2_enable0);
 538#endif
 539 } else {
 540 cpu0->cpu_int2_enable1 &= ~irq_mask;
 541 mips3_sd(cpu0->cpu_int2_en1, cpu0->cpu_int2_enable1);
488#ifdef MULTIPROCESSOR 542#ifdef MULTIPROCESSOR
489 cpu1->cpu_int2_enable0 = cpu0->cpu_int2_enable0; 543 cpu1->cpu_int2_enable1 = cpu0->cpu_int2_enable1;
490 mips3_sd(cpu1->cpu_int2_en0, cpu1->cpu_int2_enable0); 544 mips3_sd(cpu1->cpu_int2_en1, cpu1->cpu_int2_enable1);
491#endif 545#endif
 546 }
492 break; 547 break;
493 } 548 }
494 549
495 /* 550 /*
496 * Now remove it since we shouldn't get interrupts for it. 551 * Now remove it since we shouldn't get interrupts for it.
497 */ 552 */
498 octciu_intrs[irq] = NULL; 553 octciu_intrs[irq] = NULL;
499 554
500 mutex_exit(&octeon_intr_lock); 555 mutex_exit(&octeon_intr_lock);
501 556
502 kmem_free(ih, sizeof(*ih)); 557 kmem_free(ih, sizeof(*ih));
503} 558}
504 559
505void 560void
506octeon_iointr(int ipl, vaddr_t pc, uint32_t ipending) 561octeon_iointr(int ipl, vaddr_t pc, uint32_t ipending)
507{ 562{
508 struct cpu_info * const ci = curcpu(); 563 struct cpu_info * const ci = curcpu();
509 struct cpu_softc * const cpu = ci->ci_softc; 564 struct cpu_softc * const cpu = ci->ci_softc;
 565 int bank;
510 566
511 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE); 567 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
512 KASSERT((ipending & ~MIPS_INT_MASK) == 0); 568 KASSERT((ipending & ~MIPS_INT_MASK) == 0);
513 KASSERT(ipending & MIPS_HARD_INT_MASK); 569 KASSERT(ipending & MIPS_HARD_INT_MASK);
514 uint64_t hwpend = 0; 570 uint64_t hwpend[2] = { 0, 0 };
 571
 572 const uint64_t sum1 = mips3_ld(cpu->cpu_int_sum1);
515 573
516 if (ipending & MIPS_INT_MASK_2) { 574 if (ipending & MIPS_INT_MASK_2) {
517 hwpend = mips3_ld(cpu->cpu_int2_sum0) 575 hwpend[0] = mips3_ld(cpu->cpu_int2_sum0)
518 & cpu->cpu_int2_enable0; 576 & cpu->cpu_int2_enable0;
 577 hwpend[1] = sum1 & cpu->cpu_int2_enable1;
519 } else if (ipending & MIPS_INT_MASK_1) { 578 } else if (ipending & MIPS_INT_MASK_1) {
520 hwpend = mips3_ld(cpu->cpu_int1_sum0) 579 hwpend[0] = mips3_ld(cpu->cpu_int1_sum0)
521 & cpu->cpu_int1_enable0; 580 & cpu->cpu_int1_enable0;
 581 hwpend[1] = sum1 & cpu->cpu_int1_enable1;
522 } else if (ipending & MIPS_INT_MASK_0) { 582 } else if (ipending & MIPS_INT_MASK_0) {
523 hwpend = mips3_ld(cpu->cpu_int0_sum0) 583 hwpend[0] = mips3_ld(cpu->cpu_int0_sum0)
524 & cpu->cpu_int0_enable0; 584 & cpu->cpu_int0_enable0;
 585 hwpend[1] = sum1 & cpu->cpu_int0_enable1;
525 } else { 586 } else {
526 panic("octeon_iointr: unexpected ipending %#x", ipending); 587 panic("octeon_iointr: unexpected ipending %#x", ipending);
527 } 588 }
528 while (hwpend != 0) { 589 for (bank = 0; bank <= 1; bank++) {
529 const int irq = ffs64(hwpend) - 1; 590 while (hwpend[bank] != 0) {
530 hwpend &= ~__BIT(irq); 591 const int bit = ffs64(hwpend[bank]) - 1;
531 592 const int irq = (bank * 64) + bit;
532 struct octeon_intrhand * const ih = octciu_intrs[irq]; 593 hwpend[bank] &= ~__BIT(bit);
533 cpu->cpu_intr_evs[irq].ev_count++; 594
534 if (__predict_true(ih != NULL)) { 595 struct octeon_intrhand * const ih = octciu_intrs[irq];
535#ifdef MULTIPROCESSOR 596 cpu->cpu_intr_evs[irq].ev_count++;
536 if (ipl == IPL_VM) { 597 if (__predict_true(ih != NULL)) {
537 KERNEL_LOCK(1, NULL); 598#ifdef MULTIPROCESSOR
538#endif 599 if (ipl == IPL_VM) {
539 (*ih->ih_func)(ih->ih_arg); 600 KERNEL_LOCK(1, NULL);
540#ifdef MULTIPROCESSOR 601#endif
541 KERNEL_UNLOCK_ONE(NULL); 602 (*ih->ih_func)(ih->ih_arg);
542 } else { 603#ifdef MULTIPROCESSOR
543 (*ih->ih_func)(ih->ih_arg); 604 KERNEL_UNLOCK_ONE(NULL);
544 } 605 } else {
 606 (*ih->ih_func)(ih->ih_arg);
 607 }
545#endif 608#endif
546 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE); 609 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
 610 }
547 } 611 }
548 } 612 }
549 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE); 613 KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
550} 614}
551 615
552#ifdef MULTIPROCESSOR 616#ifdef MULTIPROCESSOR
553__CTASSERT(NIPIS < 16); 617__CTASSERT(NIPIS < 16);
554 618
555int 619int
556octeon_ipi_intr(void *arg) 620octeon_ipi_intr(void *arg)
557{ 621{
558 struct cpu_info * const ci = curcpu(); 622 struct cpu_info * const ci = curcpu();
559 struct cpu_softc * const cpu = ci->ci_softc; 623 struct cpu_softc * const cpu = ci->ci_softc;

cvs diff -r1.13 -r1.14 src/sys/arch/mips/cavium/octeonvar.h (expand / switch to unified diff)

--- src/sys/arch/mips/cavium/octeonvar.h 2020/06/23 05:15:33 1.13
+++ src/sys/arch/mips/cavium/octeonvar.h 2020/07/16 21:33:50 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: octeonvar.h,v 1.13 2020/06/23 05:15:33 simonb Exp $ */ 1/* $NetBSD: octeonvar.h,v 1.14 2020/07/16 21:33:50 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -67,51 +67,57 @@ struct octeon_config { @@ -67,51 +67,57 @@ struct octeon_config {
67 struct mips_pci_chipset mc_pc; 67 struct mips_pci_chipset mc_pc;
68 68
69 struct mips_bus_dma_tag mc_iobus_dmat; 69 struct mips_bus_dma_tag mc_iobus_dmat;
70 struct mips_bus_dma_tag mc_bootbus_dmat; 70 struct mips_bus_dma_tag mc_bootbus_dmat;
71 struct mips_bus_dma_tag mc_core1_dmat; 71 struct mips_bus_dma_tag mc_core1_dmat;
72 struct mips_bus_dma_tag mc_fpa_dmat; 72 struct mips_bus_dma_tag mc_fpa_dmat;
73 73
74 struct extent *mc_io_ex; 74 struct extent *mc_io_ex;
75 struct extent *mc_mem_ex; 75 struct extent *mc_mem_ex;
76 76
77 int mc_mallocsafe; 77 int mc_mallocsafe;
78}; 78};
79 79
80#define NIRQS 64 80#define NIRQS 128
81 81
82struct cpu_softc { 82struct cpu_softc {
83 struct cpu_info *cpu_ci; 83 struct cpu_info *cpu_ci;
84 84
85 uint64_t cpu_int0_sum0; 85 uint64_t cpu_int0_sum0;
86 uint64_t cpu_int1_sum0; 86 uint64_t cpu_int1_sum0;
87 uint64_t cpu_int2_sum0; 87 uint64_t cpu_int2_sum0;
88 88
 89 uint64_t cpu_int_sum1;
 90
89 uint64_t cpu_int0_en0; 91 uint64_t cpu_int0_en0;
90 uint64_t cpu_int1_en0; 92 uint64_t cpu_int1_en0;
91 uint64_t cpu_int2_en0; 93 uint64_t cpu_int2_en0;
92 94
93 uint64_t cpu_int0_en1; 95 uint64_t cpu_int0_en1;
94 uint64_t cpu_int1_en1; 96 uint64_t cpu_int1_en1;
95 uint64_t cpu_int2_en1; 97 uint64_t cpu_int2_en1;
96 98
97 uint64_t cpu_int32_en; 99 uint64_t cpu_int32_en;
98 100
99 struct evcnt cpu_intr_evs[NIRQS]; 101 struct evcnt cpu_intr_evs[NIRQS];
100 102
101 uint64_t cpu_int0_enable0; 103 uint64_t cpu_int0_enable0;
102 uint64_t cpu_int1_enable0; 104 uint64_t cpu_int1_enable0;
103 uint64_t cpu_int2_enable0; 105 uint64_t cpu_int2_enable0;
104 106
 107 uint64_t cpu_int0_enable1;
 108 uint64_t cpu_int1_enable1;
 109 uint64_t cpu_int2_enable1;
 110
105 void *cpu_wdog_sih; // wdog softint handler 111 void *cpu_wdog_sih; // wdog softint handler
106 uint64_t cpu_wdog; 112 uint64_t cpu_wdog;
107 uint64_t cpu_pp_poke; 113 uint64_t cpu_pp_poke;
108 114
109#ifdef MULTIPROCESSOR 115#ifdef MULTIPROCESSOR
110 uint64_t cpu_mbox_set; 116 uint64_t cpu_mbox_set;
111 uint64_t cpu_mbox_clr; 117 uint64_t cpu_mbox_clr;
112#endif 118#endif
113}; 119};
114 120
115/* 121/*
116 * FPA map 122 * FPA map
117 */ 123 */