diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-08-31 15:53:37 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-08-31 15:53:37 +0000 |
commit | 707dc0c5301af3bd14418a8b4727bc2a23fe21af (patch) | |
tree | 8ec99e726cab326f773aff769785498eea588b8c /sys | |
parent | 612f78e20d8e37678057c35a97388ecf690cf823 (diff) |
Only use the i8254 delay code if we are specifically using the i8254 as
delay func. Otherwise simply delay for a second to calibrate the LAPIC.
Install the lapic delay func only if we were using the i8254 before as
delay func.
Discussed with the hackroom
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/lapic.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c index 7232d629b51..a94689b456d 100644 --- a/sys/arch/amd64/amd64/lapic.c +++ b/sys/arch/amd64/amd64/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.58 2021/06/11 05:33:16 jsg Exp $ */ +/* $OpenBSD: lapic.c,v 1.59 2021/08/31 15:53:36 patrick Exp $ */ /* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */ /*- @@ -521,31 +521,40 @@ lapic_calibrate_timer(struct cpu_info *ci) */ lapic_timer_oneshot(LAPIC_LVTT_M, 0x80000000); - s = intr_disable(); + if (delay_func == i8254_delay) { + s = intr_disable(); - /* wait for current cycle to finish */ - wait_next_cycle(); + /* wait for current cycle to finish */ + wait_next_cycle(); - startapic = lapic_gettick(); + startapic = lapic_gettick(); - /* wait the next hz cycles */ - for (i = 0; i < hz; i++) - wait_next_cycle(); + /* wait the next hz cycles */ + for (i = 0; i < hz; i++) + wait_next_cycle(); - endapic = lapic_gettick(); + endapic = lapic_gettick(); - intr_restore(s); + intr_restore(s); - dtick = hz * rtclock_tval; - dapic = startapic-endapic; + dtick = hz * rtclock_tval; + dapic = startapic-endapic; - /* - * there are TIMER_FREQ ticks per second. - * in dtick ticks, there are dapic bus clocks. - */ - tmp = (TIMER_FREQ * dapic) / dtick; + /* + * there are TIMER_FREQ ticks per second. + * in dtick ticks, there are dapic bus clocks. + */ + tmp = (TIMER_FREQ * dapic) / dtick; - lapic_per_second = tmp; + lapic_per_second = tmp; + } else { + s = intr_disable(); + startapic = lapic_gettick(); + delay(1 * 1000 * 1000); + endapic = lapic_gettick(); + intr_restore(s); + lapic_per_second = startapic - endapic; + } skip_calibration: printf("%s: apic clock running at %dMHz\n", @@ -585,7 +594,7 @@ skip_calibration: * Now that the timer's calibrated, use the apic timer routines * for all our timing needs.. */ - if (delay_func != tsc_delay) + if (delay_func == i8254_delay) delay_func = lapic_delay; initclock_func = lapic_initclocks; } @@ -658,7 +667,7 @@ i82489_ipi_init(int target) i82489_icr_wait(); - i8254_delay(10000); + delay(10000); i82489_writereg(LAPIC_ICRLO, (target & LAPIC_DEST_MASK) | LAPIC_DLMODE_INIT | LAPIC_LVL_TRIG | LAPIC_LVL_DEASSERT); @@ -697,7 +706,7 @@ x2apic_ipi_init(int target) x2apic_writeicr(hi, (target & LAPIC_DEST_MASK) | LAPIC_DLMODE_INIT | LAPIC_LVL_ASSERT ); - i8254_delay(10000); + delay(10000); x2apic_writeicr(0, (target & LAPIC_DEST_MASK) | LAPIC_DLMODE_INIT | LAPIC_LVL_TRIG | LAPIC_LVL_DEASSERT); |