From patchwork Fri May 8 06:23:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48149 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 AC90A2121F for ; Fri, 8 May 2015 06:24:58 +0000 (UTC) Received: by lamp14 with SMTP id p14sf20204762lam.3 for ; Thu, 07 May 2015 23:24:57 -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=7aOq5O/Zf3vL1JwP3yfZsVB/YKZrD7+6IIAZOWeJsJQ=; b=WaDt+hY2UIT1uZuLa/g2819cPzHu+yHMEQDZcjN/S4vZBuyFij1wOvJAGksYjW11mm hozwMBnLdr1Y4uqpXgwL+kUvxs9xQAU2sEt9zmN4D+/8IjRdK+/93bCrU3FXiNpoh3qn W5Kpj8PGn2B6KAo8BDVGNhhkO7/Ir3+u1nZ7kkOc1qXyABn/DaBB2YQRxczvKJSrd8Nx jfjtG+wxSc+cj0bRDf9LDZdAsAb6/rybDEmevpp0BprbUYJrznsl2zTOndafxMQmI/Vk zAre5hETGxrjBhI4K9LZJwNTRJDFaItw8iLJp5NH+bhiNEKQ+6nKFq1JnnLCHdK9tLGU B7Zg== X-Gm-Message-State: ALoCoQkT6p2xBjHVIYMfLyL2uM0tm8JB2Ca4DX584/tUn442TK+YlSA58xOyw9pYGM0XhtjKT9Wm X-Received: by 10.194.249.1 with SMTP id yq1mr1249306wjc.2.1431066297618; Thu, 07 May 2015 23:24:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.8.171 with SMTP id dl11ls275941lad.55.gmail; Thu, 07 May 2015 23:24:57 -0700 (PDT) X-Received: by 10.112.65.37 with SMTP id u5mr1698183lbs.44.1431066297462; Thu, 07 May 2015 23:24:57 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id r10si2662812laj.147.2015.05.07.23.24.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 23:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbqq2 with SMTP id qq2so46449341lbb.3 for ; Thu, 07 May 2015 23:24:57 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr1694751laj.88.1431066297298; Thu, 07 May 2015 23:24:57 -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 hn6csp269239lbb; Thu, 7 May 2015 23:24:56 -0700 (PDT) X-Received: by 10.70.98.233 with SMTP id el9mr4084572pdb.54.1431066295523; Thu, 07 May 2015 23:24:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si5783046pdi.227.2015.05.07.23.24.54; Thu, 07 May 2015 23:24:55 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbbEHGYx (ORCPT + 11 others); Fri, 8 May 2015 02:24:53 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:35844 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751309AbbEHGYx (ORCPT ); Fri, 8 May 2015 02:24:53 -0400 Received: by pdea3 with SMTP id a3so67124884pde.3 for ; Thu, 07 May 2015 23:24:53 -0700 (PDT) X-Received: by 10.68.167.162 with SMTP id zp2mr3887451pbb.105.1431066276496; Thu, 07 May 2015 23:24:36 -0700 (PDT) Received: from localhost ([122.172.243.237]) by mx.google.com with ESMTPSA id fk10sm457627pab.18.2015.05.07.23.24.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 May 2015 23:24:35 -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 V3 06/14] cpufreq: Mark policy->governor = NULL for inactive policies Date: Fri, 8 May 2015 11:53:49 +0530 Message-Id: <58eb9c886496ba58c3fbdf5afb261ed89b157d0e.1431065963.git.viresh.kumar@linaro.org> 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.217.182 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 5e87679ec6d1..bd8a47b5054e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1095,7 +1095,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; @@ -2157,8 +2156,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, tpolicy) { - 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);