From patchwork Thu May 16 09:28:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16983 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C58CC2391B for ; Thu, 16 May 2013 09:31:28 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf3791769yho.10 for ; Thu, 16 May 2013 02:30:50 -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=MypnqootGAHGwCSjNCzdiuZyfDO1zYnT8yEBvvnIjtQ=; b=AvhqffRMiSaD9xyXRPQG8WP/uMek8KT90CVEzb4kuv3z6BFfeVwldGCZgRMetOCQ1r Ge+nTaLdcN4+pHjEHngX7xJkDagfu1D3Y8bPVJ9uRmtUxaiVJj0RlFo/zRNbcmbSosPy 8L2ron3Dzj+BJdfQJRQfcVb9PJDW7D9l/XKdxsCj/cTgQaZAyN/hja/shotVCZrPd7kK 7t0i8kjmf99/n4IwkKep4e4tO9SwL7i2WhnXZvC9FypG1xI01zPh+RhDVqQhlAU2PBFP q6QVqhwuFGr3LegfuX0oUZ/OmR7zEs6bI/eYR99TUMnyl0QsyJVke/BpLmQmuUaakOe8 t/uQ== X-Received: by 10.236.15.34 with SMTP id e22mr20813216yhe.16.1368696649892; Thu, 16 May 2013 02:30:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.164 with SMTP id t4ls1144821qet.28.gmail; Thu, 16 May 2013 02:30:49 -0700 (PDT) X-Received: by 10.52.171.108 with SMTP id at12mr1741066vdc.67.1368696649706; Thu, 16 May 2013 02:30:49 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id f7si3478672vcs.88.2013.05.16.02.30.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 May 2013 02:30:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id ia10so2622377vcb.27 for ; Thu, 16 May 2013 02:30:49 -0700 (PDT) X-Received: by 10.52.20.210 with SMTP id p18mr22978821vde.42.1368696649500; Thu, 16 May 2013 02:30:49 -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.220.126.138 with SMTP id c10csp55995vcs; Thu, 16 May 2013 02:30:49 -0700 (PDT) X-Received: by 10.68.176.37 with SMTP id cf5mr42424272pbc.173.1368696648475; Thu, 16 May 2013 02:30:48 -0700 (PDT) Received: from mail-da0-x232.google.com (mail-da0-x232.google.com [2607:f8b0:400e:c00::232]) by mx.google.com with ESMTPS id 10si4421547pae.112.2013.05.16.02.30.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 May 2013 02:30:48 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::232 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:400e:c00::232; Received: by mail-da0-f50.google.com with SMTP id i23so664557dad.9 for ; Thu, 16 May 2013 02:30:48 -0700 (PDT) X-Received: by 10.68.217.135 with SMTP id oy7mr42813194pbc.133.1368696648061; Thu, 16 May 2013 02:30:48 -0700 (PDT) Received: from localhost ([106.197.193.133]) by mx.google.com with ESMTPSA id kv2sm6122423pbc.28.2013.05.16.02.30.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 May 2013 02:30:47 -0700 (PDT) From: Viresh Kumar To: toddpoynor@google.com Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, android-kernel@googlegroups.com, viresh.kumar@linaro.org Subject: [PATCH 06/16] cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers Date: Thu, 16 May 2013 14:58:44 +0530 Message-Id: <1dc4588c25f6e7a6140cc92e12aecaf0d84170e5.1368696171.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: ALoCoQkBxhtmBhayCm2htljZmNJy6YIr8l3sSknZ01ffu0GzbfnPq/MuB4tjcw8vyvfK9ZCClJZ4 X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 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 the governor there are). eg: cpufreq_register_notifier() for conservative governor. - Done per governor instance, 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 Signed-off-by: Rafael J. Wysocki --- 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 26fbb72..38f959b 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -250,6 +250,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; } @@ -261,6 +262,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__); @@ -289,7 +291,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, @@ -301,12 +304,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 3570d09..8998d3d 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -212,6 +212,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 */