From patchwork Mon May 18 05:13:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48673 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 61BFC21411 for ; Mon, 18 May 2015 05:14:42 +0000 (UTC) Received: by lagr1 with SMTP id r1sf33209828lag.3 for ; Sun, 17 May 2015 22:14:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=+olqn+snJsyKKyCdJrlrzpSJqFFW120QiWDQe8Pnt9w=; b=kd6TEMvC+J9gBJJnytzFSNaldvwDieOyp35/Hu5cIGtnG7nzbt85kqGxi/N/E0wMFZ yOUX8RWF2J+r4rFU98cr6ifPOD3IywsAenQ3wYQ7BMQpXhNPknxyRW5kehu5vXwcqWQb qN/gvpraToPQRUiv9B+rZz29RjUwwnnhlVGLq3ArC0wmJe210KLnhyszZ2OHN3LlDEat vCN3/GVX03hLoEt/RY+TZbw9oaUMOyF8luLr89ZyIxVjDgnMFDvHxsZ8du84LIuFtXTw RsoCQ753wqsdospTgVxgbOhnypb3GsQ6nd27d6ejvITDsbgQmbSf12SYFIOxHt0h9YtN H6nA== X-Gm-Message-State: ALoCoQmQibJXeNLSQZ4OevAxUgLUFetR/96GZcNhGp+W2iEZNZfrm/3Zyp1FYSj98FNHdyARRaMU X-Received: by 10.180.35.164 with SMTP id i4mr289893wij.0.1431926081339; Sun, 17 May 2015 22:14:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.133 with SMTP id c5ls578171lac.68.gmail; Sun, 17 May 2015 22:14:41 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr15640713lak.117.1431926081186; Sun, 17 May 2015 22:14:41 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id o7si5939615lbp.164.2015.05.17.22.14.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 22:14:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagr1 with SMTP id r1so120524498lag.0 for ; Sun, 17 May 2015 22:14:41 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr15630049lac.41.1431926081085; Sun, 17 May 2015 22:14:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3711607lbb; Sun, 17 May 2015 22:14:39 -0700 (PDT) X-Received: by 10.68.226.37 with SMTP id rp5mr40245098pbc.21.1431926078980; Sun, 17 May 2015 22:14:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iu9si2678127pbc.77.2015.05.17.22.14.22; Sun, 17 May 2015 22:14:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751223AbbERFOO (ORCPT + 11 others); Mon, 18 May 2015 01:14:14 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:36662 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbbERFON (ORCPT ); Mon, 18 May 2015 01:14:13 -0400 Received: by pdfh10 with SMTP id h10so133406876pdf.3 for ; Sun, 17 May 2015 22:14:13 -0700 (PDT) X-Received: by 10.70.22.131 with SMTP id d3mr40929821pdf.67.1431926053299; Sun, 17 May 2015 22:14:13 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id x2sm8614580pda.31.2015.05.17.22.14.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 22:14:12 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Srivatsa Bhat , Viresh Kumar Subject: [PATCH V5 06/14] cpufreq: Mark policy->governor = NULL for inactive policies Date: Mon, 18 May 2015 10:43:29 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Later commits would change the way policies are managed today. Policies wouldn't be freed on cpu hotplug (currently they aren't freed on suspend), and while the CPU is offline, the sysfs cpufreq files would still be present. Because we don't mark policy->governor as NULL, it still contains pointer of the last used governor. And if the governor is removed, while all the CPUs of a policy are hotplugged out, this pointer wouldn't be valid anymore. And if we try to read the 'scaling_governor', etc. from sysfs, it will result in kernel OOPs. To prevent this, mark policy->governor as NULL for all inactive policies while the governor is removed from kernel. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 16275ba6428e..c08de5e985c7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1083,7 +1083,6 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) if (likely(policy)) { /* Policy should be inactive here */ WARN_ON(!policy_is_inactive(policy)); - policy->governor = NULL; } return policy; @@ -2145,8 +2144,10 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor) /* clear last_governor for all inactive policies */ read_lock_irqsave(&cpufreq_driver_lock, flags); for_each_inactive_policy(policy) { - if (!strcmp(policy->last_governor, governor->name)) + if (!strcmp(policy->last_governor, governor->name)) { + policy->governor = NULL; strcpy(policy->last_governor, "\0"); + } } read_unlock_irqrestore(&cpufreq_driver_lock, flags);