clockevents: add an optional frequency update function
PATCH 1/2 clockevents: add an optional frequency update function
From: Linus Walleij <[email protected]>
For some clockevents, especially for periodic ones, we get a problem when the frequency of the clock driving the event changes. We previously have a solution for one-shot events that will simply reprogram the next event. This introduces an optional callback so that drivers can update constant timer latch values derived from HZ.
--- include/linux/clockchips.h | 3 +++ kernel/time/clockevents.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
include/linux/clockchips.h +3 -0
@@ -70,6 +70,7 @@ enum clock_event_nofitiers {* @features: features * @retries: number of forced programming retries * @set_mode: set mode function +* @update_freq: function called to update timer clock frequency * @broadcast: function to broadcast events * @min_delta_ticks: minimum delta value in ticks stored for reconfiguration * @max_delta_ticks: maximum delta value in ticks stored for reconfiguration
@@ -97,6 +98,8 @@ struct clock_event_device {void (*broadcast)(const struct cpumask *mask);void (*set_mode)(enum clock_event_mode mode,struct clock_event_device *); +void (*update_freq)(enum clock_event_mode mode, +struct clock_event_device *);unsigned long min_delta_ticks;unsigned long max_delta_ticks;
kernel/time/clockevents.c +6 -2
@@ -346,13 +346,17 @@ void clockevents_config_and_register(struct clock_event_device *dev,* @dev: device to modify * @freq: new device frequency * -* Reconfigure and reprogram a clock event device in oneshot -* mode. Must be called on the cpu for which the device delivers per +* Reconfigure and reprogram a clock event device. +* Must be called on the cpu for which the device delivers per * cpu timer events with interrupts disabled! Returns 0 on success, * -ETIME when the event is in the past. */ int clockevents_update_freq (struct clock_event_device *dev,u32 freq) { +/* Call down to the driver to reconfigure for new frequency */ +if (dev->update_freq) + dev->update_freq (dev->mode, dev); +clockevents_config (dev, freq);if (dev->mode !=CLOCK_EVT_MODE_ONESHOT )
Signature · 1 line
1.7.9.2
PATCH 1/2 clockevents: add an optional frequency update function
Quoted 9 lines · Linus Walleij
From: Linus Walleij <[email protected]>
For some clockevents, especially for periodic ones, we get a problem when the frequency of the clock driving the event changes. We previously have a solution for one-shot events that will simply reprogram the next event. This introduces an optional callback so that drivers can update constant timer latch values derived from HZ.
Quoted 3 lines
Cc Thomas Gleixner <[email protected]>Reported-by Shiraz Hashim <[email protected]>Signed-off-by Linus Walleij <[email protected]>
Poke Thomas on this - are you happy with this patch? If you ACK it I can try to submit it to Russell's patch tracker with 2/2 for v3.6.
Yours,
Linus Walleij
PATCH 1/2 clockevents: add an optional frequency update function
In reply to Linus WalleijOn Tue, 8 May 2012, Linus Walleij wrote:
Sorry for answering late and thanks for the reminder.
kernel/time/clockevents.c void clockevents_config_and_register(struct clock_event_device *dev, · line 358
Quoted 5 lines
int
clockevents_update_freq(struct clock_event_device *dev, u32 freq){kernel/time/clockevents.c +3
-0+/* Call down to the driver to reconfigure for new frequency */ +if (dev->update_freq) + dev->update_freq (dev->mode, dev);
This shouldn't be unconditional. If the device is not used or shut down or in oneshot mode this call is pointless. So this wants to go below.
Quoted 1 line
clockevents_config(dev, freq);
Shouldn't we store the frequency in the clock_event_device structure, so the driver has it handy when either the set_mode, reprogram or update_freq() function is called ?
Quoted 1 line
if (
dev->mode!=CLOCK_EVT_MODE_ONESHOT)
switch (dev->mode) {
case CLOCK_EVT_MODE_ONESHOT:
return clockevents_program_event(dev, dev->next_event, false);
case CLOCK_EVT_MODE_PERIODIC:
if (dev->update_freq)
dev->update_freq(dev->mode, dev);
}
return 0;Thanks,
tglx