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)
Oct 29 2024, 12:20 PM
Unknown Object (File)
Sep 20 2024, 11:15 AM
Unknown Object (File)
Sep 9 2024, 3:50 AM
Unknown Object (File)
Sep 8 2024, 1:51 PM
Unknown Object (File)
Sep 8 2024, 7:12 AM
Unknown Object (File)
Aug 10 2024, 9:43 AM
Unknown Object (File)
Jul 8 2024, 4:30 AM
Unknown Object (File)
Jul 4 2024, 8:48 AM
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.