From patchwork Tue Apr 30 14:32:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16532 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ea0-f200.google.com (mail-ea0-f200.google.com [209.85.215.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 22A9A20065 for ; Tue, 30 Apr 2013 14:32:46 +0000 (UTC) Received: by mail-ea0-f200.google.com with SMTP id z7sf796892eaf.11 for ; Tue, 30 Apr 2013 07:32:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state :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=6Kp58JCiefJlSptCwojUECgBl8adUBt1ebuToW8Rzgk=; b=kblgNTiRMPRwpnPFtksQQW6xfbG1fnlY3SN5hTDip2C4aOMmqxcqLIfpl2oY482LX3 U787tTI8RN0QHEuZc1+ME2aI3Y6wJy8vG5VfjNtPIh8VfJUKg5/N69EVLdGue3wfFe8N ZynmS8xnid/Q9vduj75R5RcexkEqX7a4ShDB61+U0V/MR2Z5WdQ+magXpn+mHYiaRFM0 sRgQkT0dLJuUV5z3jOj0lfrwtYrF0xI0rRyvnqZ4stAW+smlvs2iJW++zdamEY0byurb RpmSRA3t7cvO60KhndwBaWPVq5CvI2Y98whXgmCN9FikF1nOQqQoVqkCjjInMMX4XeYo g0YA== X-Received: by 10.180.198.179 with SMTP id jd19mr6949618wic.5.1367332362040; Tue, 30 Apr 2013 07:32:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.73.4 with SMTP id h4ls155248wiv.40.gmail; Tue, 30 Apr 2013 07:32:41 -0700 (PDT) X-Received: by 10.180.76.230 with SMTP id n6mr25045832wiw.28.1367332361939; Tue, 30 Apr 2013 07:32:41 -0700 (PDT) Received: from mail-ve0-x22c.google.com (mail-ve0-x22c.google.com [2607:f8b0:400c:c01::22c]) by mx.google.com with ESMTPS id eu13si2720165wid.101.2013.04.30.07.32.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:41 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22c is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22c; Received: by mail-ve0-f172.google.com with SMTP id db10so436192veb.17 for ; Tue, 30 Apr 2013 07:32:40 -0700 (PDT) X-Received: by 10.220.169.78 with SMTP id x14mr20055395vcy.41.1367332360826; Tue, 30 Apr 2013 07:32:40 -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.58.127.98 with SMTP id nf2csp109530veb; Tue, 30 Apr 2013 07:32:40 -0700 (PDT) X-Received: by 10.68.178.165 with SMTP id cz5mr75900825pbc.214.1367332359890; Tue, 30 Apr 2013 07:32:39 -0700 (PDT) Received: from mail-da0-x234.google.com (mail-da0-x234.google.com [2607:f8b0:400e:c00::234]) by mx.google.com with ESMTPS id nb4si20795298pbc.234.2013.04.30.07.32.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:39 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::234 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:400e:c00::234; Received: by mail-da0-f52.google.com with SMTP id j17so272084dan.39 for ; Tue, 30 Apr 2013 07:32:39 -0700 (PDT) X-Received: by 10.68.13.228 with SMTP id k4mr3596735pbc.215.1367332359077; Tue, 30 Apr 2013 07:32:39 -0700 (PDT) Received: from localhost ([122.167.112.160]) by mx.google.com with ESMTPSA id at4sm28707399pbc.40.2013.04.30.07.32.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:38 -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, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, Viresh Kumar Subject: [PATCH 1/2] cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers Date: Tue, 30 Apr 2013 20:02:17 +0530 Message-Id: <49cc0bdaea95098d3782c8ff3ea0d6ffe21127aa.1367332148.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: ALoCoQlZOnHv8iwR+a4JvVFaaFnwDSwNqTmG8fuvIXpJ9q5nLMMCgyEL6TFsYGZ0wKJyos43bWBi X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22c 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: , There are two types of INIT/EXIT activities that we need to do for governors: - Done only once per governor (doesn't depend how many instances of governor were there). eg: cpufreq_register_notifier() for conservative governor. - Done per instance of governor, eg: sysfs_{create|remove}_group(). There were some corner cases where current code isn't able to handle them separately and so failing for some test cases. We use two separate variables now for keeping track of above two requirements. - governor->initialized for first one - dbs_data->usage_count for per governor instance Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 11 +++++++---- drivers/cpufreq/cpufreq_governor.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 443442d..5af40ad 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -255,6 +255,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, if (have_governor_per_policy()) { WARN_ON(dbs_data); } else if (dbs_data) { + dbs_data->usage_count++; policy->governor_data = dbs_data; return 0; } @@ -266,6 +267,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, } dbs_data->cdata = cdata; + dbs_data->usage_count = 1; rc = cdata->init(dbs_data); if (rc) { pr_err("%s: POLICY_INIT: init() failed\n", __func__); @@ -294,7 +296,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate, latency * LATENCY_MULTIPLIER)); - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { + if ((cdata->governor == GOV_CONSERVATIVE) && + (!policy->governor->initialized)) { struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; cpufreq_register_notifier(cs_ops->notifier_block, @@ -306,12 +309,12 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, return 0; case CPUFREQ_GOV_POLICY_EXIT: - if ((policy->governor->initialized == 1) || - have_governor_per_policy()) { + if (!--dbs_data->usage_count) { sysfs_remove_group(get_governor_parent_kobj(policy), get_sysfs_attr(dbs_data)); - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { + if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && + (policy->governor->initialized == 1)) { struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; cpufreq_unregister_notifier(cs_ops->notifier_block, diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 8ac3353..e16a961 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -211,6 +211,7 @@ struct common_dbs_data { struct dbs_data { struct common_dbs_data *cdata; unsigned int min_sampling_rate; + int usage_count; void *tuners; /* dbs_mutex protects dbs_enable in governor start/stop */