From patchwork Tue May 12 06:52:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48335 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BDDA82121F for ; Tue, 12 May 2015 06:53:10 +0000 (UTC) Received: by wgbbd3 with SMTP id bd3sf11453578wgb.2 for ; Mon, 11 May 2015 23:53:10 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=o2SPvtDs+6iSoaJCMAICqI7mix10aIBZk0OMS48109k=; b=SoZChGzaza6DXSzFsBxGWavmrAOHM2abSl672HGM9imDJ3Jylkwc+4fhBk1i0h0Xr5 F5QGyLkkynPtXuOyuMjynaWnjGTF15oNgr0NvekrUhNZJN2qZet38+zm+B6Pn0GC+ktt 7k7tSeUEVwePeuwIrYO3AG+fXSlNewcuWZR/T+0xC0EU+hVwVjYHd5PAUtKW5t2HrXn6 3UFuIPKdPL6yj+nQsfgrm7V7APMpnbX9nzOi207KgcaTLlnT1n+lZn6LfImK1yJPEaIS hqnKvd10RFmAYwQAILNUY9GVMx+w0nscl6VcMJG9ZHWm79W/i4tbFNgZgxzpbTIXjHlw Eb1g== X-Gm-Message-State: ALoCoQkEo57ckdU3hAPjX3KB3ADX52WuA+jRI/q6YzgtElRZwe9bMNBLRcM01IaST6Khb/I9WNtH X-Received: by 10.112.130.71 with SMTP id oc7mr9790915lbb.23.1431413590051; Mon, 11 May 2015 23:53:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.66 with SMTP id i2ls752284lah.19.gmail; Mon, 11 May 2015 23:53:09 -0700 (PDT) X-Received: by 10.152.45.9 with SMTP id i9mr10736439lam.87.1431413589838; Mon, 11 May 2015 23:53:09 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id l7si9655021lae.121.2015.05.11.23.53.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 23:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laat2 with SMTP id t2so109868643laa.1 for ; Mon, 11 May 2015 23:53:09 -0700 (PDT) X-Received: by 10.112.150.100 with SMTP id uh4mr10657553lbb.112.1431413589633; Mon, 11 May 2015 23:53:09 -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 hn6csp1905661lbb; Mon, 11 May 2015 23:53:08 -0700 (PDT) X-Received: by 10.70.40.164 with SMTP id y4mr25592619pdk.25.1431413587702; Mon, 11 May 2015 23:53:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qf2si21151238pbb.35.2015.05.11.23.53.06; Mon, 11 May 2015 23:53:07 -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 S1752541AbbELGxG (ORCPT + 11 others); Tue, 12 May 2015 02:53:06 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:34099 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369AbbELGxE (ORCPT ); Tue, 12 May 2015 02:53:04 -0400 Received: by pdbqa5 with SMTP id qa5so169854978pdb.1 for ; Mon, 11 May 2015 23:53:04 -0700 (PDT) X-Received: by 10.70.0.201 with SMTP id 9mr25489010pdg.4.1431413584367; Mon, 11 May 2015 23:53:04 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id e12sm15145263pap.40.2015.05.11.23.53.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 23:53:03 -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 V4 06/14] cpufreq: Mark policy->governor = NULL for inactive policies Date: Tue, 12 May 2015 12:22:51 +0530 Message-Id: <03302cfdcebce4e4cb8202fc98916c9cd059023a.1431412012.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: <58eb9c886496ba58c3fbdf5afb261ed89b157d0e.1431065963.git.viresh.kumar@linaro.org> 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.42 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 --- V4->V5: - Rebased on top of [V4 1/14] 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);