| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lapic.c,v 1.89 2022/09/07 00:40:19 knakahara Exp $ */ | | 1 | /* $NetBSD: lapic.c,v 1.90 2024/02/25 18:27:54 andvar Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000, 2008, 2020 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000, 2008, 2020 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 RedBack Networks Inc. | | 8 | * by RedBack Networks Inc. |
9 | * | | 9 | * |
10 | * Author: Bill Sommerfeld | | 10 | * Author: Bill Sommerfeld |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
31 | * POSSIBILITY OF SUCH DAMAGE. | | 31 | * POSSIBILITY OF SUCH DAMAGE. |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.89 2022/09/07 00:40:19 knakahara Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.90 2024/02/25 18:27:54 andvar Exp $"); |
36 | | | 36 | |
37 | #include "acpica.h" | | 37 | #include "acpica.h" |
38 | #include "ioapic.h" | | 38 | #include "ioapic.h" |
39 | #include "opt_acpi.h" | | 39 | #include "opt_acpi.h" |
40 | #include "opt_ddb.h" | | 40 | #include "opt_ddb.h" |
41 | #include "opt_mpbios.h" /* for MPDEBUG */ | | 41 | #include "opt_mpbios.h" /* for MPDEBUG */ |
42 | #include "opt_multiprocessor.h" | | 42 | #include "opt_multiprocessor.h" |
43 | #include "opt_ntp.h" | | 43 | #include "opt_ntp.h" |
44 | #include "opt_xen.h" | | 44 | #include "opt_xen.h" |
45 | | | 45 | |
46 | | | 46 | |
47 | #include <sys/param.h> | | 47 | #include <sys/param.h> |
48 | #include <sys/proc.h> | | 48 | #include <sys/proc.h> |
| @@ -524,27 +524,27 @@ lapic_get_timecount(struct timecounter * | | | @@ -524,27 +524,27 @@ lapic_get_timecount(struct timecounter * |
524 | uint32_t cur_timer; | | 524 | uint32_t cur_timer; |
525 | int s; | | 525 | int s; |
526 | | | 526 | |
527 | s = splhigh(); | | 527 | s = splhigh(); |
528 | ci = curcpu(); | | 528 | ci = curcpu(); |
529 | | | 529 | |
530 | /* | | 530 | /* |
531 | * Check for a race against the clockinterrupt. | | 531 | * Check for a race against the clockinterrupt. |
532 | * The update of ci_lapic_counter is blocked by splhigh() and | | 532 | * The update of ci_lapic_counter is blocked by splhigh() and |
533 | * the check for a pending clockinterrupt compensates for that. | | 533 | * the check for a pending clockinterrupt compensates for that. |
534 | * | | 534 | * |
535 | * If the current tick is almost the Initial Counter, explicitly | | 535 | * If the current tick is almost the Initial Counter, explicitly |
536 | * check for the pending interrupt bit as the interrupt delivery | | 536 | * check for the pending interrupt bit as the interrupt delivery |
537 | * could be asynchronious and compensate as well. | | 537 | * could be asynchronous and compensate as well. |
538 | * | | 538 | * |
539 | * This can't be done without splhigh() as the calling code might | | 539 | * This can't be done without splhigh() as the calling code might |
540 | * have masked the clockinterrupt already. | | 540 | * have masked the clockinterrupt already. |
541 | * | | 541 | * |
542 | * This code assumes that clockinterrupts are not missed. | | 542 | * This code assumes that clockinterrupts are not missed. |
543 | */ | | 543 | */ |
544 | cur_timer = lapic_gettick(); | | 544 | cur_timer = lapic_gettick(); |
545 | if (cur_timer >= lapic_tval - 1) { | | 545 | if (cur_timer >= lapic_tval - 1) { |
546 | uint16_t reg = LAPIC_IRR + LAPIC_TIMER_VECTOR / 32 * 16; | | 546 | uint16_t reg = LAPIC_IRR + LAPIC_TIMER_VECTOR / 32 * 16; |
547 | | | 547 | |
548 | if (lapic_readreg(reg) & (1 << (LAPIC_TIMER_VECTOR % 32))) { | | 548 | if (lapic_readreg(reg) & (1 << (LAPIC_TIMER_VECTOR % 32))) { |
549 | cur_timer -= lapic_tval; | | 549 | cur_timer -= lapic_tval; |
550 | } | | 550 | } |