On Tue, Jan 22, 2013 at 05:54:21PM -0800, John Stultz wrote:
Well, where do you see the complication?Not sure I'm following you here. I still think the selection ofcomplicated part. Additionally, there may be cases where theDoes the difference matter? The clocksource to use is detected at
timekeeping clocksource is one clocksource and the suspend
clocksource is another. So I think to properly integrate this sort
runtime, if the timekeeping clocksource is no good for suspend time
keeping then it just won't be used. With a distinct
read_persistent_clock API then they are already seperate??
which clocksource to use for suspend timing is problematic
(especially if its not the active timekeeping clocksource). So I
think instead of complicating the generic timekeeping code with the
logic, I'd rather push it off to new read_presistent_clock api.
My thought was to save the cycle_t from *all* the clock sources during
suspend, and then on resume look for the highest priority one where
the driver reports it continued to tick the whole time. The active
timekeeping clock source doesn't seem to come into the equation??
Add
int (*active_during_suspend)(struct clocksource *cs);
cycle_t value_before_suspend;
To struct clocksource.
Before suspend:
foreach(cs,all clocksources) {
if (cs->active_during_suspend)
cs->value_before_suspend = cs->read(cs);
}
After resume:
cycle_t best_delta = 0;
struct clocksource *best_cs = NULL;
foreach(cs,all clocksources) {
if (cs->active_during_suspend &&
(best_cs == NULL || cs->rating > best_cs->rating) &&
cs->active_during_suspend(cs)) {
best_delta = cs->read(cs) - cs->value_before_suspend;
best_cs = cs;
}
}
Update the TSC driver to set the function pointer
active_during_suspend when the CPU supports non-stop TSC. Have it
return true if S3 was the deepest sleep entered during the last
suspend/resume cycle, false otherwise. Ditto for that ARM case.
This seems reasonably simple, compared to adding a new API, new
drivers, new function pointer multiplexors to arches...