<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/include/linux/clocksource.h, branch tegra-10.9.9</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>nohz: Prevent clocksource wrapping during idle</title>
<updated>2010-01-28T23:01:12+00:00</updated>
<author>
<name>Jon Hunter</name>
<email>jon-hunter@ti.com</email>
</author>
<published>2009-08-18T17:45:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a9238ce3bb0fda6e760780b702c6cbd3793087d3'/>
<id>a9238ce3bb0fda6e760780b702c6cbd3793087d3</id>
<content type='text'>
commit 98962465ed9e6ea99c38e0af63fe1dcb5a79dc25 upstream.

The dynamic tick allows the kernel to sleep for periods longer than a
single tick, but it does not limit the sleep time currently. In the
worst case the kernel could sleep longer than the wrap around time of
the time keeping clock source which would result in losing track of
time.

Prevent this by limiting it to the safe maximum sleep time of the
current time keeping clock source. The value is calculated when the
clock source is registered.

[ tglx: simplified the code a bit and massaged the commit msg ]

Signed-off-by: Jon Hunter &lt;jon-hunter@ti.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;1250617512-23567-2-git-send-email-jon-hunter@ti.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 98962465ed9e6ea99c38e0af63fe1dcb5a79dc25 upstream.

The dynamic tick allows the kernel to sleep for periods longer than a
single tick, but it does not limit the sleep time currently. In the
worst case the kernel could sleep longer than the wrap around time of
the time keeping clock source which would result in losing track of
time.

Prevent this by limiting it to the safe maximum sleep time of the
current time keeping clock source. The value is calculated when the
clock source is registered.

[ tglx: simplified the code a bit and massaged the commit msg ]

Signed-off-by: Jon Hunter &lt;jon-hunter@ti.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;1250617512-23567-2-git-send-email-jon-hunter@ti.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>clocksource: Resolve cpu hotplug dead lock with TSC unstable</title>
<updated>2009-08-28T18:25:24+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-08-28T18:25:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7285dd7fd375763bfb8ab1ac9cf3f1206f503c16'/>
<id>7285dd7fd375763bfb8ab1ac9cf3f1206f503c16</id>
<content type='text'>
Martin Schwidefsky analyzed it:
To register a clocksource the clocksource_mutex is acquired and if
necessary timekeeping_notify is called to install the clocksource as
the timekeeper clock. timekeeping_notify uses stop_machine which needs
to take cpu_add_remove_lock mutex.
Starting a new cpu is done with the cpu_add_remove_lock mutex held.
native_cpu_up checks the tsc of the new cpu and if the tsc is no good
clocksource_change_rating is called. Which needs the clocksource_mutex
and the deadlock is complete.

The solution is to replace the TSC via the clocksource watchdog
mechanism. Mark the TSC as unstable and schedule the watchdog work so
it gets removed in the watchdog thread context.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
LKML-Reference: &lt;new-submission&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Martin Schwidefsky analyzed it:
To register a clocksource the clocksource_mutex is acquired and if
necessary timekeeping_notify is called to install the clocksource as
the timekeeper clock. timekeeping_notify uses stop_machine which needs
to take cpu_add_remove_lock mutex.
Starting a new cpu is done with the cpu_add_remove_lock mutex held.
native_cpu_up checks the tsc of the new cpu and if the tsc is no good
clocksource_change_rating is called. Which needs the clocksource_mutex
and the deadlock is complete.

The solution is to replace the TSC via the clocksource watchdog
mechanism. Mark the TSC as unstable and schedule the watchdog work so
it gets removed in the watchdog thread context.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
LKML-Reference: &lt;new-submission&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>timekeeping: Update clocksource with stop_machine</title>
<updated>2009-08-15T08:55:46+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=75c5158f70c065b9704b924503d96e8297838f79'/>
<id>75c5158f70c065b9704b924503d96e8297838f79</id>
<content type='text'>
update_wall_time calls change_clocksource HZ times per second to check
if a new clock source is available. In close to 100% of all calls
there is no new clock. Replace the tick based check by an update done
with stop_machine.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134810.711836357@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
update_wall_time calls change_clocksource HZ times per second to check
if a new clock source is available. In close to 100% of all calls
there is no new clock. Replace the tick based check by an update done
with stop_machine.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134810.711836357@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>timekeeping: Move NTP adjusted clock multiplier to struct timekeeper</title>
<updated>2009-08-15T08:55:46+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0a54419836254a27baecd9037103171bcbabaf67'/>
<id>0a54419836254a27baecd9037103171bcbabaf67</id>
<content type='text'>
The clocksource structure has two multipliers, the unmodified multiplier
clock-&gt;mult_orig and the NTP corrected multiplier clock-&gt;mult. The NTP
multiplier is misplaced in the struct clocksource, this is private
information of the timekeeping code. Add the mult field to the struct
timekeeper to contain the NTP corrected value, keep the unmodifed
multiplier in clock-&gt;mult and remove clock-&gt;mult_orig.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134810.149047645@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The clocksource structure has two multipliers, the unmodified multiplier
clock-&gt;mult_orig and the NTP corrected multiplier clock-&gt;mult. The NTP
multiplier is misplaced in the struct clocksource, this is private
information of the timekeeping code. Add the mult field to the struct
timekeeper to contain the NTP corrected value, keep the unmodifed
multiplier in clock-&gt;mult and remove clock-&gt;mult_orig.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134810.149047645@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>timekeeping: Introduce struct timekeeper</title>
<updated>2009-08-15T08:55:46+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=155ec60226ae0ae2aadaa57c951a58a359331030'/>
<id>155ec60226ae0ae2aadaa57c951a58a359331030</id>
<content type='text'>
Add struct timekeeper to keep the internal values timekeeping.c needs
in regard to the currently selected clock source. This moves the
timekeeping intervals, xtime_nsec and the ntp error value from struct
clocksource to struct timekeeper. The raw_time is removed from the
clocksource as well. It gets treated like xtime as a global variable.
Eventually xtime raw_time should be moved to struct timekeeper.

[ tglx: minor cleanup ]

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134809.613209842@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add struct timekeeper to keep the internal values timekeeping.c needs
in regard to the currently selected clock source. This moves the
timekeeping intervals, xtime_nsec and the ntp error value from struct
clocksource to struct timekeeper. The raw_time is removed from the
clocksource as well. It gets treated like xtime as a global variable.
Eventually xtime raw_time should be moved to struct timekeeper.

[ tglx: minor cleanup ]

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134809.613209842@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clocksource: Move watchdog downgrade to a work queue thread</title>
<updated>2009-08-15T08:55:46+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c55c87c892c1875deace0c8fc28787335277fdf2'/>
<id>c55c87c892c1875deace0c8fc28787335277fdf2</id>
<content type='text'>
Move the downgrade of an unstable clocksource from the timer interrupt
context into the process context of a work queue thread. This is
needed to be able to do the clocksource switch with stop_machine.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134809.354926067@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move the downgrade of an unstable clocksource from the timer interrupt
context into the process context of a work queue thread. This is
needed to be able to do the clocksource switch with stop_machine.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134809.354926067@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clocksource: Cleanup clocksource selection</title>
<updated>2009-08-15T08:55:46+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f1b82746c1e93daf24e1ab9bfbd39bcdb2e7018b'/>
<id>f1b82746c1e93daf24e1ab9bfbd39bcdb2e7018b</id>
<content type='text'>
If a non high-resolution clocksource is first set as override clock
and then registered it becomes active even if the system is in one-shot
mode. Move the override check from sysfs_override_clocksource to the
clocksource selection. That fixes the bug and simplifies the code. The
check in clocksource_register for double registration of the same
clocksource is removed without replacement.

To find the initial clocksource a new weak function in jiffies.c is
defined that returns the jiffies clocksource. The architecture code
can then override the weak function with a more suitable clocksource,
e.g. the TOD clock on s390.

[ tglx: Folded in a fix from John Stultz ]

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134808.388024160@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a non high-resolution clocksource is first set as override clock
and then registered it becomes active even if the system is in one-shot
mode. Move the override check from sysfs_override_clocksource to the
clocksource selection. That fixes the bug and simplifies the code. The
check in clocksource_register for double registration of the same
clocksource is removed without replacement.

To find the initial clocksource a new weak function in jiffies.c is
defined that returns the jiffies clocksource. The architecture code
can then override the weak function with a more suitable clocksource,
e.g. the TOD clock on s390.

[ tglx: Folded in a fix from John Stultz ]

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134808.388024160@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>timekeeping: Remove clocksource inline functions</title>
<updated>2009-08-15T08:55:45+00:00</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a0f7d48bfb95a4c5172a2756dbc4b82afc8e9ae4'/>
<id>a0f7d48bfb95a4c5172a2756dbc4b82afc8e9ae4</id>
<content type='text'>
The three inline functions clocksource_read, clocksource_enable and
clocksource_disable are simple wrappers of an indirect call plus the
copy from and to the mult_orig value. The functions are exclusively
used by the timekeeping code which has intimate knowledge of the
clocksource anyway. Therefore remove the inline functions. No
functional change.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134807.903108946@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The three inline functions clocksource_read, clocksource_enable and
clocksource_disable are simple wrappers of an indirect call plus the
copy from and to the mult_orig value. The functions are exclusively
used by the timekeeping code which has intimate knowledge of the
clocksource anyway. Therefore remove the inline functions. No
functional change.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134807.903108946@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clocksource: Save mult_orig in clocksource_disable()</title>
<updated>2009-07-31T12:12:36+00:00</updated>
<author>
<name>Magnus Damm</name>
<email>magnus.damm@gmail.com</email>
</author>
<published>2009-07-28T21:09:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c7121843685de2bf7f3afd3ae1d6a146010bf1fc'/>
<id>c7121843685de2bf7f3afd3ae1d6a146010bf1fc</id>
<content type='text'>
To fix the common case where -&gt;enable() does not set up
mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Signed-off-by: Magnus Damm &lt;damm@igel.co.jp&gt;
Cc: johnstul@us.ibm.com
Cc: lethal@linux-sh.org
Cc: akpm@linux-foundation.org
LKML-Reference: &lt;20090618152432.10136.9932.sendpatchset@rx1.opensource.se&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To fix the common case where -&gt;enable() does not set up
mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Signed-off-by: Magnus Damm &lt;damm@igel.co.jp&gt;
Cc: johnstul@us.ibm.com
Cc: lethal@linux-sh.org
Cc: akpm@linux-foundation.org
LKML-Reference: &lt;20090618152432.10136.9932.sendpatchset@rx1.opensource.se&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clocksource: setup mult_orig in clocksource_enable()</title>
<updated>2009-05-02T09:45:15+00:00</updated>
<author>
<name>Magnus Damm</name>
<email>magnus.damm@gmail.com</email>
</author>
<published>2009-05-01T05:45:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a25cbd045a2ffc42787d4dbcbb9c7118f5f42732'/>
<id>a25cbd045a2ffc42787d4dbcbb9c7118f5f42732</id>
<content type='text'>
Setup clocksource mult_orig in clocksource_enable().

Clocksource drivers can save power by using keeping the
device clock disabled while the clocksource is unused.

In practice this means that the enable() and disable()
callbacks perform clk_enable() and clk_disable().

The enable() callback may also use clk_get_rate() to get
the clock rate from the clock framework. This information
can then be used to calculate the shift and mult variables.

Currently the mult_orig variable is setup from mult at
registration time only. This is conflicting with the above
case since the clock is disabled and the mult variable is
not yet calculated at the time of registration.

Moving the mult_orig setup code to clocksource_enable()
allows us to both handle the common case with no enable()
callback and the mult-changed-after-enable() case.

[ Impact: allow dynamic clock source usage ]

Signed-off-by: Magnus Damm &lt;damm@igel.co.jp&gt;
LKML-Reference: &lt;20090501054546.8193.10688.sendpatchset@rx1.opensource.se&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Setup clocksource mult_orig in clocksource_enable().

Clocksource drivers can save power by using keeping the
device clock disabled while the clocksource is unused.

In practice this means that the enable() and disable()
callbacks perform clk_enable() and clk_disable().

The enable() callback may also use clk_get_rate() to get
the clock rate from the clock framework. This information
can then be used to calculate the shift and mult variables.

Currently the mult_orig variable is setup from mult at
registration time only. This is conflicting with the above
case since the clock is disabled and the mult variable is
not yet calculated at the time of registration.

Moving the mult_orig setup code to clocksource_enable()
allows us to both handle the common case with no enable()
callback and the mult-changed-after-enable() case.

[ Impact: allow dynamic clock source usage ]

Signed-off-by: Magnus Damm &lt;damm@igel.co.jp&gt;
LKML-Reference: &lt;20090501054546.8193.10688.sendpatchset@rx1.opensource.se&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
