From patchwork Mon Feb 8 11:39:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61395 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1383985lbl; Mon, 8 Feb 2016 03:41:13 -0800 (PST) X-Received: by 10.98.42.10 with SMTP id q10mr41590380pfq.73.1454931664205; Mon, 08 Feb 2016 03:41:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bs10si46062182pad.73.2016.02.08.03.41.03; Mon, 08 Feb 2016 03:41:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbcBHLk5 (ORCPT + 11 others); Mon, 8 Feb 2016 06:40:57 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:35199 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbcBHLk4 (ORCPT ); Mon, 8 Feb 2016 06:40:56 -0500 Received: by mail-pa0-f41.google.com with SMTP id ho8so72605945pac.2 for ; Mon, 08 Feb 2016 03:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6+2pdovXBRYJcah+dBG6kwndyBwkcXU26Kp3OSP0Eas=; b=dSlIkB4j/9Ya+/HZ/X9u8lKK7vwHx9A2/6gFW/tqRv8S64Zllyxt5mPvoq+8r/PUqT xT51Jrxn7pu+g7dGGtNCraBKBF2/3mbJ946dvtCpr8xX0ykWiCJAdRYnMGhegSvIzyog 2iFSDhzPsoy2//Ena/gr4Lx/aBqJDxGX2YYR4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=6+2pdovXBRYJcah+dBG6kwndyBwkcXU26Kp3OSP0Eas=; b=SRTv7RH3h/ZyeBgR5LhzDN8Y779L6cWzxbCb5kpr2OAqPiZWF1FxQABKsuE4pCUXsR Z0fr3xOiBPLKVgzA5flFJ9NK8T9N386eFdoxJIvHClItGf/F2Y7GbO7NL86URNQsMBbB 5LQ1dJtjP3310yG6oxQmA2fCibVIQgPG5qZVszZ5ux/STpuCVrrRVP2unA6PbJVFXI3N 40g5zykuQrCyO71dvdMgvVLghi1x3+5SVkQxpNnW46RaUP/Z0u3jbN34NhmZCGhzjxve K05bHRh6RAVF4isBdm5pS5uYRRRX/MJUKIOtWAyXzNW+gmjllLX5Kvb9piwSxu7R66L3 6upQ== X-Gm-Message-State: AG10YORbXg0Qdk0syJwYIBl3z1Xct/P2AP4kJt4SK57E/rb1IzyRa4u2N6xk7wk9ziVS+Q4l X-Received: by 10.67.7.200 with SMTP id de8mr41647190pad.28.1454931655474; Mon, 08 Feb 2016 03:40:55 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id to9sm10025751pab.3.2016.02.08.03.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 03:40:54 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, peterz@infradead.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V3 11/13] cpufreq: governor: Keep list of policy_dbs within dbs_data Date: Mon, 8 Feb 2016 17:09:25 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org An instance of 'struct dbs_data' can support multiple 'struct policy_dbs_info' instances. To traverse all policy_dbs supported by a dbs_data, create a list of policy_dbs within dbs_data. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 12 ++++++++++++ drivers/cpufreq/cpufreq_governor.h | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) -- 2.7.1.370.gb2aa7f8 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index ee3c2d92da53..e267acc67067 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -489,6 +489,11 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) dbs_data->usage_count++; policy_dbs->dbs_data = dbs_data; policy->governor_data = policy_dbs; + + mutex_lock(&dbs_data->mutex); + list_add(&policy_dbs->list, &dbs_data->policy_dbs_list); + mutex_unlock(&dbs_data->mutex); + return 0; } @@ -500,8 +505,11 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) dbs_data->usage_count = 1; dbs_data->gov = gov; + INIT_LIST_HEAD(&dbs_data->policy_dbs_list); mutex_init(&dbs_data->mutex); + list_add(&policy_dbs->list, &dbs_data->policy_dbs_list); + ret = gov->init(dbs_data, !policy->governor->initialized); if (ret) goto free_policy_dbs_info; @@ -554,6 +562,10 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy) struct policy_dbs_info *policy_dbs = policy->governor_data; struct dbs_data *dbs_data = policy_dbs->dbs_data; + mutex_lock(&dbs_data->mutex); + list_del(&policy_dbs->list); + mutex_unlock(&dbs_data->mutex); + if (!--dbs_data->usage_count) { kobject_put(&dbs_data->kobj); diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index ced34ba5a18d..b740633c2fbe 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -74,7 +74,11 @@ struct dbs_data { unsigned int up_threshold; struct kobject kobj; - /* Protect concurrent updates to governor tunables from sysfs */ + struct list_head policy_dbs_list; + /* + * Protect concurrent updates to governor tunables from sysfs and + * policy_dbs_list. + */ struct mutex mutex; }; @@ -132,6 +136,7 @@ struct policy_dbs_info { struct work_struct work; /* dbs_data may be shared between multiple policy objects */ struct dbs_data *dbs_data; + struct list_head list; }; static inline void gov_update_sample_delay(struct policy_dbs_info *policy_dbs,