From patchwork Mon Apr 15 17:22:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2446431 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8CE54DF2E5 for ; Mon, 15 Apr 2013 17:22:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756068Ab3DORWc (ORCPT ); Mon, 15 Apr 2013 13:22:32 -0400 Received: from mail-ob0-f181.google.com ([209.85.214.181]:37098 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756139Ab3DORWa (ORCPT ); Mon, 15 Apr 2013 13:22:30 -0400 Received: by mail-ob0-f181.google.com with SMTP id wo10so4375764obc.12 for ; Mon, 15 Apr 2013 10:22:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=2zN8W6hWgR8s8xSfsqW4FuDbTYN8Sbi5ZE6fBUCdN0s=; b=VDlO44Pp9sxp8RohEAV+QqeskPxrvuS9bOoRgDsFZxpRqpEPS6mGG1bhyw5TZoTbxH sfCGFSJmTYfAQa0hQBAxdmLf3bAZ+geJ1VmcHCruRupiQeNjAMlkvc4wkiUkVff7AJer CHPhiQBe0rBl7gQZ+nqW8OUQDGuSF+8ZXacw6m6j7jd6wrd3U/ogimVmzWGGytxV6ng6 ygTXKhsv16muARifIM91bsIC1HiJngsX2T7Wh80F+OL6BR0Tl0mz7OHzkJUZan2gDR4v 3hpN5IcsK6Nl2mveiTvmGo4cOTK9r7c4MMnQdZtiAuMhomq1hEg4mZKAnvxQ1kkjgL7W C3sA== MIME-Version: 1.0 X-Received: by 10.182.49.102 with SMTP id t6mr7728935obn.75.1366046548909; Mon, 15 Apr 2013 10:22:28 -0700 (PDT) Received: by 10.182.127.82 with HTTP; Mon, 15 Apr 2013 10:22:28 -0700 (PDT) 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 X-Gm-Message-State: ALoCoQm47ATfOUJmLoiXPVVrEUfmM/bpgCequTKh+0cs1R0w/iRsdMMBrqTOQSZwhp1w6/MqtHh/ Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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(-) @@ -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; 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);