Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756190Ab3DORWd (ORCPT ); Mon, 15 Apr 2013 13:22:33 -0400 Received: from mail-ob0-f178.google.com ([209.85.214.178]:50650 "EHLO mail-ob0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756146Ab3DORWa (ORCPT ); Mon, 15 Apr 2013 13:22:30 -0400 MIME-Version: 1.0 In-Reply-To: <516C25AE.4050503@intel.com> References: <1923819.6Nb81T2TR8@vostro.rjw.lan> <516C25AE.4050503@intel.com> Date: Mon, 15 Apr 2013 22:52:28 +0530 Message-ID: Subject: Re: linux-next: Tree for Apr 9 [cpufreq: NULL pointer deref] From: Viresh Kumar To: Dirk Brandewie Cc: sedat.dilek@gmail.com, "Rafael J. Wysocki" , Dirk Brandewie , Stephen Rothwell , linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, Linux PM list , Lists linaro-kernel , Nathan Zimmer Content-Type: multipart/mixed; boundary=f46d04479f774bc27d04da697fc2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6927 Lines: 153 --f46d04479f774bc27d04da697fc2 Content-Type: text/plain; charset=ISO-8859-1 On 15 April 2013 21:37, Dirk Brandewie wrote: > If the intel_pstate driver is being used __cpufreq_governor() should NOT be > called intel_pstate does not implement the target() callback. > > Nathan's commit 5800043b2 changed the fence around the call to > __cpufreq_governor() in __cpufreq_remove_dev() here is the relevant hunk. No it isn't. > + if (has_target) > __cpufreq_governor(data, CPUFREQ_GOV_STOP); As it has taken care of this limitation. BUT some of my earlier patches haven't. :( Here is the fix (Sedat please try this and give your tested-by, use the attached patch as gmail might break what i am copying in mail).. Sorry for being late in fixing this issue, i am still down with Tonsil infection and fever.. Today only i got some power to fix it after seeing Dirk's mail. Your tested-by may help me to recover quickly :) @Rafael: I will probably be down for one more week and so not doing any reviews for now... I do check important mails sent directly to me though. ------------x----------------------x------------------ From: Viresh Kumar Date: Mon, 15 Apr 2013 22:43:57 +0530 Subject: [PATCH] cpufreq: Don't call __cpufreq_governor() for drivers without target() Some cpufreq drivers implement their own governor and so don't need us to call generic governors interface via __cpufreq_governor(). Few recent commits haven't obeyed this law well and we saw some regressions. This patch tries to fix this issue. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3564947..a6f6595 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -858,13 +858,18 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, struct device *dev) { struct cpufreq_policy *policy; - int ret = 0; + int ret = 0, has_target = 0; unsigned long flags; policy = cpufreq_cpu_get(sibling); WARN_ON(!policy); - __cpufreq_governor(policy, CPUFREQ_GOV_STOP); + rcu_read_lock(); + has_target = !!rcu_dereference(cpufreq_driver)->target; + rcu_read_unlock(); + + if (has_target) + __cpufreq_governor(policy, CPUFREQ_GOV_STOP); lock_policy_rwsem_write(sibling); @@ -877,8 +882,10 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, unlock_policy_rwsem_write(sibling); - __cpufreq_governor(policy, CPUFREQ_GOV_START); - __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); + if (has_target) { + __cpufreq_governor(policy, CPUFREQ_GOV_START); + __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); + } ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); if (ret) { @@ -1146,7 +1153,8 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif /* If cpu is last user of policy, free policy */ if (cpus == 1) { - __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); + if (has_target) + __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); lock_policy_rwsem_read(cpu); kobj = &data->kobj; --f46d04479f774bc27d04da697fc2 Content-Type: application/octet-stream; name="0001-cpufreq-Don-t-call-__cpufreq_governor-for-drivers-wi.patch" Content-Disposition: attachment; filename="0001-cpufreq-Don-t-call-__cpufreq_governor-for-drivers-wi.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hfjwtdd80 RnJvbSA3MzUyYTNkZDYwYWNkMzg5Y2VmYzQwZmFjMTI4MzdkMzJjOGE2ZjI2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpNZXNzYWdlLUlkOiA8NzM1MmEzZGQ2MGFjZDM4OWNlZmM0MGZhYzEyODM3 ZDMyYzhhNmYyNi4xMzY2MDQ2MjAyLmdpdC52aXJlc2gua3VtYXJAbGluYXJvLm9yZz4KRnJvbTog VmlyZXNoIEt1bWFyIDx2aXJlc2gua3VtYXJAbGluYXJvLm9yZz4KRGF0ZTogTW9uLCAxNSBBcHIg MjAxMyAyMjo0Mzo1NyArMDUzMApTdWJqZWN0OiBbUEFUQ0hdIGNwdWZyZXE6IERvbid0IGNhbGwg X19jcHVmcmVxX2dvdmVybm9yKCkgZm9yIGRyaXZlcnMgd2l0aG91dAogdGFyZ2V0KCkKClNvbWUg Y3B1ZnJlcSBkcml2ZXJzIGltcGxlbWVudCB0aGVpciBvd24gZ292ZXJub3IgYW5kIHNvIGRvbid0 IG5lZWQgdXMgdG8gY2FsbApnZW5lcmljIGdvdmVybm9ycyBpbnRlcmZhY2UgdmlhIF9fY3B1ZnJl cV9nb3Zlcm5vcigpLiBGZXcgcmVjZW50IGNvbW1pdHMgaGF2ZW4ndApvYmV5ZWQgdGhpcyBsYXcg d2VsbCBhbmQgd2Ugc2F3IHNvbWUgcmVncmVzc2lvbnMuCgpUaGlzIHBhdGNoIHRyaWVzIHRvIGZp eCB0aGlzIGlzc3VlLgoKU2lnbmVkLW9mZi1ieTogVmlyZXNoIEt1bWFyIDx2aXJlc2gua3VtYXJA bGluYXJvLm9yZz4KLS0tCiBkcml2ZXJzL2Nwd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ci0tIAoxLjcuMTIucmMyLjE4Lmc2MWI0NzJlCgo= --f46d04479f774bc27d04da697fc2-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/