Page MenuHomeFreeBSD

re-synchronize TSC-s on SMP systems after resume, if necessary
ClosedPublic

Authored by avg on May 24 2018, 10:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 19, 3:07 PM
Unknown Object (File)
Feb 7 2024, 10:07 PM
Unknown Object (File)
Dec 20 2023, 4:25 AM
Unknown Object (File)
Dec 11 2023, 2:00 AM
Unknown Object (File)
Oct 26 2023, 10:35 AM
Unknown Object (File)
Oct 10 2023, 8:52 PM
Unknown Object (File)
Aug 15 2023, 6:40 PM
Unknown Object (File)
Aug 15 2023, 12:14 PM
Subscribers

Details

Summary

The TSC-s are checked and synchronized only if they were good
originally. That is, invariant, synchronized, etc.

This is necessary on an AMD-based system where after a wakeup from STR I
see that BSP clock differs from AP clocks by a count that roughly
corresponds to one second. The APs are in sync with each other. Not
sure if this is a hardware quirk or a firmware bug.

Test Plan

Tested on the affected system.
This is what I see on boot:

SMP: passed TSC synchronization test

This is what I see after a resume:

SMP: passed TSC synchronization test after adjustment
acpi_timer0: restoring timecounter, ACPI-fast -> TSC-low

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/acpica/acpi.c
3046 ↗(On Diff #42923)

Do APs left on the parking loop still ? I wonder if malloc(9) can be reliably used at that point.

Also note that the code above uses smp_started/EARLY_AP_STARTUP checks, I am not sure why. Either the checks above should be removed, or copy/pasted there.

sys/dev/acpica/acpi.c
3046 ↗(On Diff #42923)

Yes, the APs are released by that time. This is almost a normal context with interrupts enabled, etc. Even device drivers are resumed.

Regarding EARLY_AP_STARTUP, I am not sure why it's here.
Either John was paranoid or he mechanically applied the same change everywhere without giving much analysis to each individual case (considering the number of places where sched_bind is used).

kib added inline comments.
sys/dev/acpica/acpi.c
3046 ↗(On Diff #42923)

Yes, most likely smp_started and ifdef checks should be removed.

This revision is now accepted and ready to land.May 24 2018, 11:56 AM
sys/dev/acpica/acpi.c
2921 ↗(On Diff #42923)

This was probably rather mechanical. I'm not sure why the existing change was there, but
perhaps it was due to 'halt' or 'poweroff' from ddb during early boot? In that case the if
condition should perhaps stay even in the EARLY_AP_STARTUP case.

sys/dev/acpica/acpi.c
2921 ↗(On Diff #42923)

S5 is caught earlier in the function, see line 2987.
Also, the function is not called for halt or reset as far as I can tell.

This revision was automatically updated to reflect the committed changes.