CINXE.COM
LKML: Thomas Renninger: Re: [PATCH 2/2] _PPC frequency change issues
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Thomas Renninger: Re: [PATCH 2/2] _PPC frequency change issues</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Thomas Renninger" href="/groupie.php?aid=24015" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2006"> [2006]</a> 聽 <a class="nb" href="/lkml/2006/1"> [Jan]</a> 聽 <a class="nb" href="/lkml/2006/1/25"> [25]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2006/1/25/173" onclick="this.href='/lkml/headers'+'/2006/1/25/173';">[headers]</a>聽 <a href="/lkml/bounce/2006/1/25/173">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2006/1/24/132">First message in thread</a></li><li><a href="/lkml/2006/1/24/132">"Pallipadi, Venkatesh"</a><ul><li class="origin"><a href="">Thomas Renninger</a></li></ul></li></ul><div class="threadlist">Patch in this message</div><ul class="threadlist"><li><a href="/lkml/diff/2006/1/25/173/1">Get diff 1</a></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">From</td><td class="rp" itemprop="author">Thomas Renninger <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH 2/2] _PPC frequency change issues</td></tr><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Wed, 25 Jan 2006 18:39:30 +0100</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">On Tuesday 24 January 2006 18:06, Pallipadi, Venkatesh wrote:<br />> Thanks for identifying the issues and sendint these patches Thomas.<br />><br />> Patch 1 looks clean. New lines seem to contain spaces instead of tabs.<br />> The same issue is there in patch 2 as well. Can you resent it with<br />> indentation fixed.<br />><br />> Patch 2 I am concenred with following hunk.<br />><br />> @@ -161,16 +158,17 @@<br />> cpu_max_freq[cpu] = policy->max;<br />> dprintk("limit event for cpu %u: %u - %u kHz, currently<br />> %u kHz, last set to %u kHz\n", cpu, cpu_min_freq[cpu],<br />> cpu_max_freq[cpu], cpu_cur_freq[cpu], cpu_set_freq[cpu]);<br />> if (policy->max < cpu_set_freq[cpu]) {<br />> - __cpufreq_driver_target(&current_policy[cpu],<br />> policy->max,<br />> - CPUFREQ_RELATION_H);<br />> + if (!__cpufreq_driver_target(policy, policy->max,<br />> + CPUFREQ_RELATION_H))<br />> + cpu_cur_freq[cpu] = policy->max;<br />><br />> Should this me cpu_cur_freq[cpu] = policy->cur instead. As the max<br />> setting may not be supported by the driver, it might have set some<br />> closer available freq<br />><br />> Same comment for below two driver target calls as well.<br />Ok, I all (cpu_max/min/cur_freq) assigned it after setting, this should be OK?<br /><br />Seems as if I had some wrong indentation offset set and had not checked<br />the patch output itself, sorry about that.<br /><br />Tell me if you still see any problems ...<br /><br />Author: Thomas Renninger <trenn@suse.de><br /><br />userspace governor need not to hold it's own cpufreq_policy,<br />better make use of the global core policy.<br />Also fixes a bug in case of frequency changes via _PPC.<br />Old min/max values have wrongly been passed to __cpufreq_driver_target()<br />(kind of buffered) and when max freq was available again, only the old<br />max(normally lowest freq) was still active.<br /><br />cpufreq_userspace.c | 52 <br />+++++++++++++++++++++++++++-------------------------<br /> 1 files changed, 27 insertions(+), 25 deletions(-)<br /><br />Index: linux-2.6.15/drivers/cpufreq/cpufreq_userspace.c<br />===================================================================<br />--- linux-2.6.15.orig/drivers/cpufreq/cpufreq_userspace.c<br />+++ linux-2.6.15/drivers/cpufreq/cpufreq_userspace.c<br />@@ -33,7 +33,6 @@ static unsigned int cpu_min_freq[NR_CPUS<br /> static unsigned int cpu_cur_freq[NR_CPUS]; /* current CPU freq */<br /> static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace <br />*/<br /> static unsigned int cpu_is_managed[NR_CPUS];<br />-static struct cpufreq_policy current_policy[NR_CPUS];<br /> <br /> static DECLARE_MUTEX (userspace_sem); <br /> <br />@@ -64,22 +63,22 @@ static struct notifier_block userspace_c<br /> *<br /> * Sets the CPU frequency to freq.<br /> */<br />-static int cpufreq_set(unsigned int freq, unsigned int cpu)<br />+static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy)<br /> {<br /> int ret = -EINVAL;<br /> <br />- dprintk("cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq);<br />+ dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq);<br /> <br /> down(&userspace_sem);<br />- if (!cpu_is_managed[cpu])<br />+ if (!cpu_is_managed[policy->cpu])<br /> goto err;<br /> <br />- cpu_set_freq[cpu] = freq;<br />+ cpu_set_freq[policy->cpu] = freq;<br /> <br />- if (freq < cpu_min_freq[cpu])<br />- freq = cpu_min_freq[cpu];<br />- if (freq > cpu_max_freq[cpu])<br />- freq = cpu_max_freq[cpu];<br />+ if (freq < cpu_min_freq[policy->cpu])<br />+ freq = cpu_min_freq[policy->cpu];<br />+ if (freq > cpu_max_freq[policy->cpu])<br />+ freq = cpu_max_freq[policy->cpu];<br /> <br /> /*<br /> * We're safe from concurrent calls to ->target() here<br />@@ -88,8 +87,7 @@ static int cpufreq_set(unsigned int freq<br /> * A: cpufreq_set (lock userspace_sem) -> cpufreq_driver_target(lock <br />policy->lock)<br /> * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> <br />cpufreq_governor_userspace (lock userspace_sem)<br /> */<br />- ret = __cpufreq_driver_target(&current_policy[cpu], freq, <br />- CPUFREQ_RELATION_L);<br />+ ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);<br /> <br /> err:<br /> up(&userspace_sem);<br />@@ -113,7 +111,7 @@ store_speed (struct cpufreq_policy *poli<br /> if (ret != 1)<br /> return -EINVAL;<br /> <br />- cpufreq_set(freq, policy->cpu);<br />+ cpufreq_set(freq, policy);<br /> <br /> return count;<br /> }<br />@@ -141,7 +139,6 @@ static int cpufreq_governor_userspace(st<br /> cpu_cur_freq[cpu] = policy->cur;<br /> cpu_set_freq[cpu] = policy->cur;<br /> sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);<br />- memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));<br /> dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, <br />cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);<br /> up(&userspace_sem);<br /> break;<br />@@ -157,20 +154,25 @@ static int cpufreq_governor_userspace(st<br /> break;<br /> case CPUFREQ_GOV_LIMITS:<br /> down(&userspace_sem);<br />- cpu_min_freq[cpu] = policy->min;<br />- cpu_max_freq[cpu] = policy->max;<br />- dprintk("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to <br />%u kHz\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu], <br />cpu_set_freq[cpu]);<br />+ dprintk("limit event for cpu %u: %u - %u kHz,"<br />+ "currently %u kHz, last set to %u kHz\n",<br />+ cpu, policy->min, policy->max,<br />+ cpu_cur_freq[cpu], cpu_set_freq[cpu]);<br /> if (policy->max < cpu_set_freq[cpu]) {<br />- __cpufreq_driver_target(&current_policy[cpu], policy->max, <br />- CPUFREQ_RELATION_H);<br />- } else if (policy->min > cpu_set_freq[cpu]) {<br />- __cpufreq_driver_target(&current_policy[cpu], policy->min, <br />- CPUFREQ_RELATION_L);<br />- } else {<br />- __cpufreq_driver_target(&current_policy[cpu], cpu_set_freq[cpu],<br />- CPUFREQ_RELATION_L);<br />+ __cpufreq_driver_target(policy, policy->max,<br />+ CPUFREQ_RELATION_H);<br />+ }<br />+ else if (policy->min > cpu_set_freq[cpu]) {<br />+ __cpufreq_driver_target(policy, policy->min,<br />+ CPUFREQ_RELATION_L);<br />+ }<br />+ else {<br />+ __cpufreq_driver_target(policy, cpu_set_freq[cpu],<br />+ CPUFREQ_RELATION_L);<br /> }<br />- memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));<br />+ cpu_min_freq[cpu] = policy->min;<br />+ cpu_max_freq[cpu] = policy->max;<br />+ cpu_cur_freq[cpu] = policy->cur;<br /> up(&userspace_sem);<br /> break;<br /> }<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo@vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2006-01-25 18:41 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>