From patchwork Sat Aug 3 11:49:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 18753 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A893723981 for ; Sat, 3 Aug 2013 11:50:46 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id m1sf2212009ves.10 for ; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state :x-removed-original-auth:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=0BVIoVxa4Q3dYWNWdTnpfzCzkTIQtaJfDIFRZlbXepE=; b=l97HTfBNvrUBFLbaEb3jmOicPbbwc2HvyH8HRnQoh85pd14HY4/X6BM9XgiPcSG7d1 DwXtNhcG0yVnZAb0NKEexjUrgpEIB9pykmH3B4wRrZlxyXSridAxYzowNxKWhYaq82kq zfHwUBLuy2CpIZ/tiIqo/olkvw4u4xnVsXs6WwFgkFRs7Mz9kGiJEpSFEjBp4bYD7WfH 3WpmnMuvDZ+sPUMOx7KwZ6XAaDYbVEbABStiOBv2W0vB2+K2QPKb464Ha5LZwHDwK41c Qj+J5NK6WUqHtVsqMxPN03STGiXirYFeaMUp16vtqxH2JQO5RLxpcjRTTLz8Zq1EmwcN VD8w== X-Received: by 10.224.172.68 with SMTP id k4mr15166116qaz.1.1375530646463; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.165 with SMTP id q5ls1918918qek.22.gmail; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) X-Received: by 10.220.77.74 with SMTP id f10mr3320690vck.1.1375530646341; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id se5si176709vdc.75.2013.08.03.04.50.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 03 Aug 2013 04:50:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.53; Received: by mail-vb0-f53.google.com with SMTP id i3so1497558vbh.40 for ; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) X-Received: by 10.58.6.210 with SMTP id d18mr3295530vea.96.1375530646221; Sat, 03 Aug 2013 04:50:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.11.8 with SMTP id pc8csp475vcb; Sat, 3 Aug 2013 04:50:45 -0700 (PDT) X-Received: by 10.67.10.45 with SMTP id dx13mr621976pad.31.1375530645217; Sat, 03 Aug 2013 04:50:45 -0700 (PDT) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by mx.google.com with ESMTPS id zr1si10488736pbc.90.2013.08.03.04.50.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 03 Aug 2013 04:50:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.45 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.45; Received: by mail-pa0-f45.google.com with SMTP id bg4so1586236pad.4 for ; Sat, 03 Aug 2013 04:50:44 -0700 (PDT) X-Received: by 10.66.163.229 with SMTP id yl5mr15449782pab.69.1375530644794; Sat, 03 Aug 2013 04:50:44 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id tr10sm15833311pbc.22.2013.08.03.04.50.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 03 Aug 2013 04:50:44 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com, l.majewski@samsung.com, Viresh Kumar Subject: [PATCH 08/10] cpufreq: Fix broken usage of governor->owner's refcount Date: Sat, 3 Aug 2013 17:19:26 +0530 Message-Id: <46faea4c060f91f7102d9d33c816693acc25a917.1375530162.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQm7MfuAiOBJethlKfENAtqt1IUIiZxO4UQT1+C9QoNkN5wCkKLStPkEES4jIep/An+sSJ/l X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Governor's owner refcount usage was broken. We should increment refcount only when CPUFREQ_GOV_POLICY_INIT event has come and should decrement only if CPUFREQ_GOV_POLICY_EXIT has come. Lets fix it. Signed-off-by: Viresh Kumar Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e9b969f..74d4969 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1707,8 +1707,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, } } - if (!try_module_get(policy->governor->owner)) - return -EINVAL; + if (event == CPUFREQ_GOV_POLICY_INIT) + if (!try_module_get(policy->governor->owner)) + return -EINVAL; pr_debug("__cpufreq_governor for CPU %u, event %u\n", policy->cpu, event); @@ -1717,6 +1718,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, if ((!policy->governor_enabled && (event == CPUFREQ_GOV_STOP)) || (policy->governor_enabled && (event == CPUFREQ_GOV_START))) { mutex_unlock(&cpufreq_governor_lock); + if (event == CPUFREQ_GOV_POLICY_INIT) + module_put(policy->governor->owner); return -EBUSY; } @@ -1744,11 +1747,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, mutex_unlock(&cpufreq_governor_lock); } - /* we keep one module reference alive for - each CPU governed by this CPU */ - if ((event != CPUFREQ_GOV_START) || ret) - module_put(policy->governor->owner); - if ((event == CPUFREQ_GOV_STOP) && !ret) + if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) || + ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) module_put(policy->governor->owner); return ret;