x86, tsc: Fix cpufreq lockup
x86, tsc: Fix cpufreq lockup

Mauro reported that his AMD X2 using the powernow-k8 cpufreq driver
locked up when doing cpu hotplug.

Because we called set_cyc2ns_scale() from the time_cpufreq_notifier()
unconditionally, it gets called multiple times for each freq change,
instead of only the once, when the tsc_khz value actually changes.

Because it gets called more than once, we run out of cyc2ns data slots
and stall, waiting for a free one, but because we're half way offline,
there's no consumers to free slots.

By placing the call inside the condition that actually changes tsc_khz
we avoid superfluous calls and avoid the problem.

Reported-by: Mauro <a08206ef179cc6ccfc53e786ca8ce75c7065b153@hotmail.com>
Tested-by: Mauro <a08206ef179cc6ccfc53e786ca8ce75c7065b153@hotmail.com>
Fixes: 20d1c86a5776 ("sched/clock, x86: Rewrite cyc2ns() to avoid the need to disable IRQs")
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Cc: "Rafael J. Wysocki" <a11f87183a953ab11f50fbafff689c5a7fa3506c@rjwysocki.net>
Cc: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Cc: Bin Gao <51038400620b1c8074b389a6debbda26ff44cc72@intel.com>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Mika Westerberg <afb75201fb002d7fdd2b0b231e006999e00db8a9@linux.intel.com>
Cc: Paul Gortmaker <ae947f3c8df96e1dc851c5e3e5a930ce6d3f1f74@windriver.com>
Cc: Stefani Seibold <35951e2654371df7c68de546b20b3c3794b62aae@seibold.net>
Cc: 2578944098299abf708b08eff6fcf60565553586@vger.kernel.org
Signed-off-by: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs