Re: [PATCH 1/3] clockevents: Retry programming min delta up to 10 times
From: Thomas Gleixner
Date: Thu Oct 19 2017 - 08:43:40 EST
On Thu, 19 Oct 2017, Matt Redfearn wrote:
> unsigned long long clc;
> int64_t delta;
> + int i;
>
> - delta = dev->min_delta_ns;
> - dev->next_event = ktime_add_ns(ktime_get(), delta);
> + for (i = 0;;) {
Bah. What's wrong with
for (i = 0; i < 10; i++) {
....
if (!(dev->set_next_event((unsigned long) clc, dev))
return 0;
}
return -ETIME;
Hmm?
> + delta = dev->min_delta_ns;
> + dev->next_event = ktime_add_ns(ktime_get(), delta);
>
> - if (clockevent_state_shutdown(dev))
> - return 0;
> + if (clockevent_state_shutdown(dev))
> + return 0;
>
> - dev->retries++;
> - clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
> - return dev->set_next_event((unsigned long) clc, dev);
> + dev->retries++;
> + clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
I'd rather make that:
delta = 0;
for (i = 0; i < 10; i++) {
delta += dev->min_delta_ns;
dev->next_event = ktime_add_ns(ktime_get(), delta);
clc = .....
.....
That makes it more likely to succeed fast. Hmm?
Thanks,
tglx