Mon Apr 22 22:29:29 2024 UTC (17d)
Add opt_pci.h include to fix NO_PCI_MSI_MSIX build.
(Path from Paolo Pisati in current_users@)

While here:
Simplify mp_cpu_start() ifdefs. MULTIPROCESSOR and HYPERV code falls under
NLAPIC > 0, thus just combine all blocks under this guard.
Rearrange opt_acpi.h include alphabetically.


(andvar)
diff -r1.167 -r1.168 src/sys/arch/x86/x86/intr.c

cvs diff -r1.167 -r1.168 src/sys/arch/x86/x86/intr.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/intr.c 2024/03/05 20:58:05 1.167
+++ src/sys/arch/x86/x86/intr.c 2024/04/22 22:29:28 1.168
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: intr.c,v 1.167 2024/03/05 20:58:05 andvar Exp $ */ 1/* $NetBSD: intr.c,v 1.168 2024/04/22 22:29:28 andvar Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007, 2008, 2009, 2019 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 Andrew Doran, and by Jason R. Thorpe. 8 * by Andrew Doran, and 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.
@@ -123,31 +123,32 @@ @@ -123,31 +123,32 @@
123 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 123 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
124 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 124 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
125 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 125 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
126 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 126 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
127 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 127 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
128 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 128 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
129 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 129 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
130 * SUCH DAMAGE. 130 * SUCH DAMAGE.
131 * 131 *
132 * @(#)isa.c 7.2 (Berkeley) 5/13/91 132 * @(#)isa.c 7.2 (Berkeley) 5/13/91
133 */ 133 */
134 134
135#include <sys/cdefs.h> 135#include <sys/cdefs.h>
136__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.167 2024/03/05 20:58:05 andvar Exp $"); 136__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.168 2024/04/22 22:29:28 andvar Exp $");
137 137
 138#include "opt_acpi.h"
138#include "opt_intrdebug.h" 139#include "opt_intrdebug.h"
139#include "opt_multiprocessor.h" 140#include "opt_multiprocessor.h"
140#include "opt_acpi.h" 141#include "opt_pci.h"
141 142
142#include <sys/param.h> 143#include <sys/param.h>
143#include <sys/systm.h> 144#include <sys/systm.h>
144#include <sys/kernel.h> 145#include <sys/kernel.h>
145#include <sys/syslog.h> 146#include <sys/syslog.h>
146#include <sys/device.h> 147#include <sys/device.h>
147#include <sys/kmem.h> 148#include <sys/kmem.h>
148#include <sys/proc.h> 149#include <sys/proc.h>
149#include <sys/errno.h> 150#include <sys/errno.h>
150#include <sys/intr.h> 151#include <sys/intr.h>
151#include <sys/cpu.h> 152#include <sys/cpu.h>
152#include <sys/xcall.h> 153#include <sys/xcall.h>
153#include <sys/interrupt.h> 154#include <sys/interrupt.h>
@@ -1356,80 +1357,75 @@ static inline int @@ -1356,80 +1357,75 @@ static inline int
1356redzone_const_or_zero(int x) 1357redzone_const_or_zero(int x)
1357{ 1358{
1358 return redzone_const_or_false(true) ? x : 0; 1359 return redzone_const_or_false(true) ? x : 0;
1359} 1360}
1360#endif 1361#endif
1361 1362
1362/* 1363/*
1363 * Initialize all handlers that aren't dynamically allocated, and exist 1364 * Initialize all handlers that aren't dynamically allocated, and exist
1364 * for each CPU. 1365 * for each CPU.
1365 */ 1366 */
1366void 1367void
1367cpu_intr_init(struct cpu_info *ci) 1368cpu_intr_init(struct cpu_info *ci)
1368{ 1369{
1369#if (NLAPIC > 0) || defined(MULTIPROCESSOR) || \ 
1370 (NHYPERV > 0) 
1371 struct intrsource *isp; 
1372#endif 
1373#if NLAPIC > 0 1370#if NLAPIC > 0
 1371 struct intrsource *isp;
1374 static int first = 1; 1372 static int first = 1;
1375#if defined(MULTIPROCESSOR) 1373#if defined(MULTIPROCESSOR)
1376 int i; 1374 int i;
1377#endif 1375#endif
1378#endif 
1379 1376
1380#if NLAPIC > 0 
1381 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP); 1377 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
1382 isp->is_recurse = Xrecurse_lapic_ltimer; 1378 isp->is_recurse = Xrecurse_lapic_ltimer;
1383 isp->is_resume = Xresume_lapic_ltimer; 1379 isp->is_resume = Xresume_lapic_ltimer;
1384 fake_timer_intrhand.ih_pic = &local_pic; 1380 fake_timer_intrhand.ih_pic = &local_pic;
1385 fake_timer_intrhand.ih_level = IPL_CLOCK; 1381 fake_timer_intrhand.ih_level = IPL_CLOCK;
1386 isp->is_handlers = &fake_timer_intrhand; 1382 isp->is_handlers = &fake_timer_intrhand;
1387 isp->is_pic = &local_pic; 1383 isp->is_pic = &local_pic;
1388 ci->ci_isources[LIR_TIMER] = isp; 1384 ci->ci_isources[LIR_TIMER] = isp;
1389 evcnt_attach_dynamic(&isp->is_evcnt, 1385 evcnt_attach_dynamic(&isp->is_evcnt,
1390 first ? EVCNT_TYPE_INTR : EVCNT_TYPE_MISC, NULL, 1386 first ? EVCNT_TYPE_INTR : EVCNT_TYPE_MISC, NULL,
1391 device_xname(ci->ci_dev), "timer"); 1387 device_xname(ci->ci_dev), "timer");
1392 first = 0; 1388 first = 0;
1393 1389
1394#ifdef MULTIPROCESSOR 1390#ifdef MULTIPROCESSOR
1395 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP); 1391 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
1396 isp->is_recurse = Xrecurse_lapic_ipi; 1392 isp->is_recurse = Xrecurse_lapic_ipi;
1397 isp->is_resume = Xresume_lapic_ipi; 1393 isp->is_resume = Xresume_lapic_ipi;
1398 fake_ipi_intrhand.ih_pic = &local_pic; 1394 fake_ipi_intrhand.ih_pic = &local_pic;
1399 fake_ipi_intrhand.ih_level = IPL_HIGH; 1395 fake_ipi_intrhand.ih_level = IPL_HIGH;
1400 isp->is_handlers = &fake_ipi_intrhand; 1396 isp->is_handlers = &fake_ipi_intrhand;
1401 isp->is_pic = &local_pic; 1397 isp->is_pic = &local_pic;
1402 ci->ci_isources[LIR_IPI] = isp; 1398 ci->ci_isources[LIR_IPI] = isp;
1403 1399
1404 for (i = 0; i < X86_NIPI; i++) 1400 for (i = 0; i < X86_NIPI; i++)
1405 evcnt_attach_dynamic(&ci->ci_ipi_events[i], EVCNT_TYPE_MISC, 1401 evcnt_attach_dynamic(&ci->ci_ipi_events[i], EVCNT_TYPE_MISC,
1406 NULL, device_xname(ci->ci_dev), x86_ipi_names[i]); 1402 NULL, device_xname(ci->ci_dev), x86_ipi_names[i]);
1407#endif 1403#endif /* MULTIPROCESSOR */
1408 1404
1409#if NHYPERV > 0 1405#if NHYPERV > 0
1410 if (hyperv_hypercall_enabled()) { 1406 if (hyperv_hypercall_enabled()) {
1411 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP); 1407 isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
1412 isp->is_recurse = Xrecurse_hyperv_hypercall; 1408 isp->is_recurse = Xrecurse_hyperv_hypercall;
1413 isp->is_resume = Xresume_hyperv_hypercall; 1409 isp->is_resume = Xresume_hyperv_hypercall;
1414 fake_hyperv_intrhand.ih_level = IPL_NET; 1410 fake_hyperv_intrhand.ih_level = IPL_NET;
1415 isp->is_handlers = &fake_hyperv_intrhand; 1411 isp->is_handlers = &fake_hyperv_intrhand;
1416 isp->is_pic = &local_pic; 1412 isp->is_pic = &local_pic;
1417 ci->ci_isources[LIR_HV] = isp; 1413 ci->ci_isources[LIR_HV] = isp;
1418 evcnt_attach_dynamic(&isp->is_evcnt, EVCNT_TYPE_INTR, NULL, 1414 evcnt_attach_dynamic(&isp->is_evcnt, EVCNT_TYPE_INTR, NULL,
1419 device_xname(ci->ci_dev), "Hyper-V hypercall"); 1415 device_xname(ci->ci_dev), "Hyper-V hypercall");
1420 } 1416 }
1421#endif 1417#endif /* NHYPERV > 0 */
1422#endif 1418#endif /* NLAPIC > 0 */
1423 1419
1424#if defined(__HAVE_PREEMPTION) 1420#if defined(__HAVE_PREEMPTION)
1425 x86_init_preempt(ci); 1421 x86_init_preempt(ci);
1426 1422
1427#endif 1423#endif
1428 x86_intr_calculatemasks(ci); 1424 x86_intr_calculatemasks(ci);
1429 1425
1430#if defined(INTRSTACKSIZE) 1426#if defined(INTRSTACKSIZE)
1431 vaddr_t istack; 1427 vaddr_t istack;
1432 1428
1433 /* 1429 /*
1434 * If the red zone is activated, protect both the top and 1430 * If the red zone is activated, protect both the top and
1435 * the bottom of the stack with an unmapped page. 1431 * the bottom of the stack with an unmapped page.