From patchwork Mon Nov 26 08:10:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 151990 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5345549ljp; Mon, 26 Nov 2018 00:10:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/X4XynEdlEVQi7dY/x0BxlztBCvlv1dmqnr05wPxiJ1gf/Hg6Gz3fKUtjIbkd0D2IexNsCd X-Received: by 2002:a17:902:5a4d:: with SMTP id f13mr27375582plm.49.1543219826951; Mon, 26 Nov 2018 00:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543219826; cv=none; d=google.com; s=arc-20160816; b=lKMUk0KvLEA/4UMo19OwB5E+OFIvG9gotvYNe1poRfwROs46jx/hREUikm3eOhGfBl ox3phjLFlMu11IrWQrTd3RWKxCpw/uMxZuUDlxVnoeBu/RXAJsNoH3ODANewJwDDgpkT vei/hUzGgpKj5L3fEVC2cJ08OJXsJAkrkwTi72Fketc2kwkxUbN6kT4hyxR9qxe/LLw0 kn+/UNqaX/csrOcfKyIJcJREIxbkk/nd2og4JgXAvBYJTrapwg/kl9cBVV0JipBz8sFV UIHtpEqiEAWx5b0uS8A/9ZuSBygv1jkmNbn4N/RkmL4M3tt4DX0t5yiqtAVZW810eMsg LCiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O17aol/D58byrR6YndIqp0QVKFatgqkI1jJsfGYUpvQ=; b=I4N46TUNKJo9x2X/2AFxZzsbYmciGJi/0eLjeAtk6TXUd7b5Db6SeSBBkzkCHITJYO 0qHIgMCBvE8vbNVdkqd5uTEB/xpmsyAtkD6gLm754LeIobDkp3GO6h8lv4uUHHziGrbO 0p6X2MzcEK5YEjPR8O6kkEUbSfJ0nWC9IS596VcxCcC3evdMrUVs21sSjht+E+nU9HY/ HzxLUi1iWXd1IWh6A85yoc9DYDCq3vRUFZlFeZquSrr4xk+GXivtc/YQmBA9DInUlT6W UQrg8LEoIiSHKKjoLql4cXp5mdD38uZlLqR6Zy1G7h2/UVuXvmgLlHanCcVitK8yS6eT OzqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QBCZRsM7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn22si9906040plb.19.2018.11.26.00.10.26; Mon, 26 Nov 2018 00:10:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QBCZRsM7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726407AbeKZTDo (ORCPT + 32 others); Mon, 26 Nov 2018 14:03:44 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46555 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeKZTDn (ORCPT ); Mon, 26 Nov 2018 14:03:43 -0500 Received: by mail-pg1-f193.google.com with SMTP id w7so5782323pgp.13 for ; Mon, 26 Nov 2018 00:10:24 -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 :mime-version:content-transfer-encoding; bh=O17aol/D58byrR6YndIqp0QVKFatgqkI1jJsfGYUpvQ=; b=QBCZRsM7c0CDjL3a9IctQ5rWPCRNCCbAVwe7Q598+yA7zTaLJXtfjMZDulL89g6L9u twpaP3O0Xu8Ptyyos4mtiC8O9mZULhZEnTOXnZQPL16B9unMLt18nFsp2wbmKI0DorGu daYMKbV+82VJSiKwmk0vEsC3VeN5n8fVqnXGo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O17aol/D58byrR6YndIqp0QVKFatgqkI1jJsfGYUpvQ=; b=QoQdpF9ADnQiwZGDM5/TE3vIdySfhhNe1wEmr50sv8cw9ljNS4UcQ10uexN6GbWmyc 9E2FyePhiG0cfDuBzjokY+/9KIolga5ItcMXpfex0vHCyenDcm6BJYHEANTr5wsQrdUM 4pqgQ9HZF3GalCDPDrB4VHKYw+q+9tUF/HJbU6fmr8Xn+BAaXrLytxekg9KI0oEyiv2y UUO459dLjxgFrV9MZmVPGoAMzSl5UOt0X7FBUvnpqFemcvGXrDio0FHnapuVHFFcelLk Nj0s9MG2wb+0H1klKeL8jqSL6hUinhQtJtUC3zCX2AqZGFrfo7ZMz0PU3/mgxZQTyZoW xrng== X-Gm-Message-State: AGRZ1gKrkEvGKpwMll8cZu+wwso7D8WzmF0088nb9pIevj7S42CGODr9 pI5lJNGrvRC1KXa7VSg3tpTz3g== X-Received: by 2002:a63:cd4c:: with SMTP id a12mr24330079pgj.252.1543219823252; Mon, 26 Nov 2018 00:10:23 -0800 (PST) Received: from localhost ([122.172.88.116]) by smtp.gmail.com with ESMTPSA id k14sm83287429pgs.52.2018.11.26.00.10.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:10:22 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/5] OPP: Add dev_pm_opp_xlate_performance_state() helper Date: Mon, 26 Nov 2018 13:40:01 +0530 Message-Id: <8bb37fb6120221ded6abb53e69c86620aade20f6.1543219386.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a new helper dev_pm_opp_xlate_performance_state() which will be used to translate from pstate of a device to another one. Initially this will be used by genpd to find pstate of a master domain using its sub-domain's pstate. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 59 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++ 2 files changed, 66 insertions(+) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0eaa954b3f6c..99b71f60b6d8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1707,6 +1707,65 @@ void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, dev_err(virt_dev, "Failed to find required device entry\n"); } +/** + * dev_pm_opp_xlate_performance_state() - Find required OPP's pstate for src_table. + * @src_table: OPP table which has dst_table as one of its required OPP table. + * @dst_table: Required OPP table of the src_table. + * @pstate: Current performance state of the src_table. + * + * This Returns pstate of the OPP (present in @dst_table) pointed out by the + * "required-opps" property of the OPP (present in @src_table) which has + * performance state set to @pstate. + * + * Return: Positive performance state on success, otherwise 0 on errors. + */ +unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, + struct opp_table *dst_table, + unsigned int pstate) +{ + struct dev_pm_opp *opp; + unsigned int dest_pstate = 0; + int i; + + /* + * Normally the src_table will have the "required_opps" property set to + * point to one of the OPPs in the dst_table, but in some cases the + * genpd and its master have one to one mapping of performance states + * and so none of them have the "required-opps" property set. Return the + * pstate of the src_table as it is in such cases. + */ + if (!src_table->required_opp_count) + return pstate; + + for (i = 0; i < src_table->required_opp_count; i++) { + if (src_table->required_opp_tables[i]->np == dst_table->np) + break; + } + + if (unlikely(i == src_table->required_opp_count)) { + pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", + __func__, src_table, dst_table); + return 0; + } + + mutex_lock(&src_table->lock); + + list_for_each_entry(opp, &src_table->opp_list, node) { + if (opp->pstate == pstate) { + dest_pstate = opp->required_opps[i]->pstate; + goto unlock; + } + } + + pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, src_table, + dst_table); + +unlock: + mutex_unlock(&src_table->lock); + + return dest_pstate; +} + /** * dev_pm_opp_add() - Add an OPP table from a table definitions * @dev: device for which we do this operation diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2b2c3fd985ab..5a64a81a1789 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -128,6 +128,7 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*s void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev, struct device *virt_dev, int index); void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev); +unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -280,6 +281,12 @@ static inline struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev } static inline void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev) {} + +static inline unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) +{ + return 0; +} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; From patchwork Mon Nov 26 08:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 151991 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5345582ljp; Mon, 26 Nov 2018 00:10:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWzIFi+IRMpJhAbns0g5bPFNJlmCYFeVhKk5a2sblAjY+EtZ6UIbPQEsjTciBXPd57OzLn X-Received: by 2002:a63:585c:: with SMTP id i28mr23968101pgm.178.1543219829271; Mon, 26 Nov 2018 00:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543219829; cv=none; d=google.com; s=arc-20160816; b=YoSCgDXXEyfwaaJcoopIUDa+mnAnBewuHK30ad+LKqFKqGPG/PzLHZAD4k+ZEFVFJV cV9ozl2E0t73xlsqyKrPJ/W5ubQ3lZMNO0aNIPxwL+xXkw4Hf96WmQU9/TzM+RiWqx9K wmltccI74jLKmkOavXOsgE0RJnt8M4tW4gRUX8B/wQE8ce+QtPAinnPJ4h+qfzb0PGNX EJrLrNxGmEOklt8VKaQLvlT34ExiUkjX3DaZmPNIM+F6Tx8YY6Ynq7haLW4oGI7h8dzN EGSauYQSadlvAJ59ptEJAP2wifxSYzTyKW2ceRptzlb5YHnlOmfSmA7k3Yjoqx/jgvfD FDaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=++v3XXRbpVHJuX8RyfyvTaqYBFuAGN2iIxtK4ZIufKQ=; b=wkLkNrEg02LXcOETGyjmEkX51Oc7nwmH4sUiaoKAQYanBsu/NxE+YM4pyHi7eCXP0i Jb0GpJC8QJVnZaoGN6HK2n5Kt117NZAxYZ4ePG55Ie+C3nddSWzyg6AWuKI/Cr16JpYL t4ngOglUqUyeGDtznEc1eykVp+DFnt+03ZuvMqJfmWe9j0zrDpi5mvgMCMBsIOnj4uvv 9NWrgN9zSCjkMuOt1F+UH8TLkBj35atgeK1sFUDJiqc3p1czzZGCnh80DDXADKbkBrry 74rpHvb4gEKPdVMAD5HHWFLvMPp28MJdFSc7muZJ+SwXJVbt5hRZEFR49e9OybbgUWxb qScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqCnAYXK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn22si9906040plb.19.2018.11.26.00.10.28; Mon, 26 Nov 2018 00:10:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqCnAYXK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726435AbeKZTDq (ORCPT + 32 others); Mon, 26 Nov 2018 14:03:46 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36950 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeKZTDp (ORCPT ); Mon, 26 Nov 2018 14:03:45 -0500 Received: by mail-pl1-f194.google.com with SMTP id b5so13505858plr.4 for ; Mon, 26 Nov 2018 00:10:27 -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 :mime-version:content-transfer-encoding; bh=++v3XXRbpVHJuX8RyfyvTaqYBFuAGN2iIxtK4ZIufKQ=; b=OqCnAYXKYFFxfcDQdBH/amjiIdW1xiVkdUh5+TDq0nVt9fP81udsrShE6qgoYxrwMp 2xugRb01JUUZscmyv1RXtbtDgFPCAkqtkojuuUFABQCSFiNSFyLJRpx9C5OFaOjXNGTI ll3/aURzt7SHZ90gSqCftbJxZFMeoqR8V9nIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=++v3XXRbpVHJuX8RyfyvTaqYBFuAGN2iIxtK4ZIufKQ=; b=XPgDaLHrqqebP84oYCJKdGsgtA+EPnHQ0xx5iOAz2PLH3UxaKNNZpb2IjpGQ0y7VR+ rwz4MYkvQAI3MdSPPtNsYdNnCORaR1mCXdrtyy7v7mTtXHS7MMkYZxRioRmWGPJmgb3s Bcr4RbB1CYH5qplZlw2MnNk76c7NRq2iQQnmqh8Llo7wWTWPigEOhxHfCKfhPfoaxY5o N0QWag3UuUhOMGtORSVEQppTug4vT3i8J5wI3vwyhRuJp225y+4dpCFHYeYGtDKRp7MH aFwMqAI68BREwkd2mJu8gkYU2S9oUDgm8T/Q0uGaZuG3XwvGiH0mGP9lXNhji8GQf7N9 7+vQ== X-Gm-Message-State: AA+aEWZ43RwC7vZicf5lyDpS3vlCIWe2L32E3mvHshg4FQsOG+WOinYx hVTlglMwJjGQVAIag8KB0zA8UA== X-Received: by 2002:a17:902:f091:: with SMTP id go17mr27154879plb.235.1543219826521; Mon, 26 Nov 2018 00:10:26 -0800 (PST) Received: from localhost ([122.172.88.116]) by smtp.gmail.com with ESMTPSA id 6sm89302753pfv.30.2018.11.26.00.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:10:25 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Len Brown , Pavel Machek Cc: Viresh Kumar , Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 3/5] PM / Domains: Save OPP table pointer in genpd Date: Mon, 26 Nov 2018 13:40:02 +0530 Message-Id: X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We will need these going forward in hotpath, i.e. from within dev_pm_genpd_set_performance_state(). Lets fetch and save them while the OPP tables are added. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 23 +++++++++++++++++++++-- include/linux/pm_domain.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8e554e6a82a2..0d928359b880 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1907,12 +1907,21 @@ int of_genpd_add_provider_simple(struct device_node *np, ret); goto unlock; } + + /* + * Save table for faster processing while setting performance + * state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table(&genpd->dev); + WARN_ON(!genpd->opp_table); } ret = genpd_add_provider(np, genpd_xlate_simple, genpd); if (ret) { - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } goto unlock; } @@ -1965,6 +1974,13 @@ int of_genpd_add_provider_onecell(struct device_node *np, i, ret); goto error; } + + /* + * Save table for faster processing while setting + * performance state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table_indexed(&genpd->dev, i); + WARN_ON(!genpd->opp_table); } genpd->provider = &np->fwnode; @@ -1989,8 +2005,10 @@ int of_genpd_add_provider_onecell(struct device_node *np, genpd->provider = NULL; genpd->has_provider = false; - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } } mutex_unlock(&gpd_list_lock); @@ -2024,6 +2042,7 @@ void of_genpd_del_provider(struct device_node *np) if (!gpd->set_performance_state) continue; + dev_pm_opp_put_opp_table(gpd->opp_table); dev_pm_opp_of_remove_table(&gpd->dev); } } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 642036952553..9ad101362aef 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -73,6 +73,7 @@ struct genpd_power_state { struct genpd_lock_ops; struct dev_pm_opp; +struct opp_table; struct generic_pm_domain { struct device dev; @@ -94,6 +95,7 @@ struct generic_pm_domain { unsigned int performance_state; /* Aggregated max performance state */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); + struct opp_table *opp_table; /* OPP table of the genpd */ unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, From patchwork Mon Nov 26 08:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 151992 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5345648ljp; Mon, 26 Nov 2018 00:10:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VWogsVI+nqERVU6y6w1YlsxqusjqWevlg0eODdhsVbQMyGcT56f+W8pxBcQ4cuhLczM7xI X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr25479190plh.302.1543219832915; Mon, 26 Nov 2018 00:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543219832; cv=none; d=google.com; s=arc-20160816; b=DA6MCaqheDH4GraMe5i/l4hYpSrhLvK2cFpLYcKMWwWavU3MsAGoQCDlvlqrxwn4sA 8FygYxwU6mVXm2LlCA0SVGDq/lPUfeyrnyuAsEGbuv7mRrO9VJ0FKrX6GzV4Bznm7IsL prvbLX1QKxCuqF90blMV4nUATKTZ68bw//waR7Paynh1TPepryj4+mFlfhGOrv/Q4kum thtyV4b/1kjhLkGLKksEIuh5UxMO42QPilovCKqVtQ2LBnlMuPLos1b8seklJVTOx6oY bodLxWtSKlrrtXuWDXAnTZbXKkJ3Gze4K41VGPFYQlF1YB6xoFL3EORCFRF9Fa7aDOYq 8fhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=sCogn39ffRSYCYWNufUrUOHTiF6dHDOXGg3MfeS7ydWcm2bpREVEWmzTG0W9BUui0S d+pE9+oQ6WQdN6n7DAWaMiipTUxfOPo+YDR01V8gDXl3LjmWy5aJuZ8z8Kb8r3jdREIw iJb/ompOZqUUS/xEuI0o6ArZZNI6Cd1s/gw0Obc0CsLtn6Z9U77/MXqHAdAEb+1/xqFv xoQ6POynzqY1ITvbFzFUPfDLU+HypBYMsxHMAZf02zSDwXWM0wTNXSd9Y9IX/tU/NwE3 e1G9G+Gg0rRpZjtCQvMqb7Qf+CjNstVNudIPPf6jKKsOWkt84YfJpQGRB1c5Ak+F+N4J UMwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLQ+7HTQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si19905180pfk.73.2018.11.26.00.10.32; Mon, 26 Nov 2018 00:10:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLQ+7HTQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbeKZTDt (ORCPT + 32 others); Mon, 26 Nov 2018 14:03:49 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33091 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeKZTDt (ORCPT ); Mon, 26 Nov 2018 14:03:49 -0500 Received: by mail-pl1-f194.google.com with SMTP id z23so13501402plo.0 for ; Mon, 26 Nov 2018 00:10:30 -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 :mime-version:content-transfer-encoding; bh=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=QLQ+7HTQdMzShJXE7t+Oz9eWOxQdypgCasgsGB7kGoxExkPT34ic6ehUvvVl2iXkWd yIIk7EAD1BChWJmt874dyKhY1jpS/HovTG4+28bU7F10g6+qJl8bB3Pm5fiSVoSPO+FD WsNvEZnNo/G+1Y/bYClJb1vxET6pXtQ9WZcfo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=UQcByOjv9oficmbvcYhabwvD2Mfp46GzFHCI+97fkfSvKdFy+HOlFgC2HZjwc+uZ7l s7rgX+yZBflenjwtmE3SSeWDvyqK+YcSCVSUJEB4eLefJtJZfk6NjPP+Rkg2tL1c7Pqr uYcwKyvqaSWXGrs1/Sl3mccAViwBLjueJp4kGMW0Zrpq5Yy4VJLZhH5ObIA331SPvdGB dKMoTiUjc9+VfCpISxQP08Usuo1Lt9WuVXVfU2hWv7VE+OhF0CfV70+P0u2Af2b5hsfH r2jku9N6NbaFEMy3pcihYYm0SXPjZdkC/RtUsXB5MBY/My6NAST32uDmXKItj4KpCTPv DMhQ== X-Gm-Message-State: AA+aEWYk1bIX2vMwrx6fPTR6NyeuKoaUAKr+JgrWfOkK54dY/PMOgk45 as4jO1jAb/cCdovt0Jx9vWHF/A== X-Received: by 2002:a17:902:b592:: with SMTP id a18mr26996386pls.182.1543219829636; Mon, 26 Nov 2018 00:10:29 -0800 (PST) Received: from localhost ([122.172.88.116]) by smtp.gmail.com with ESMTPSA id l64sm70802998pge.73.2018.11.26.00.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:10:29 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 4/5] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Mon, 26 Nov 2018 13:40:03 +0530 Message-Id: <401e29cb9e8d762e076253220f4a5dc22464e9fa.1543219386.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate out _genpd_set_performance_state() and _genpd_reeval_performance_state() from dev_pm_genpd_set_performance_state() to handle performance state update related stuff. This will be used by a later commit. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 105 +++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 43 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 0d928359b880..d6b389a9f678 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,63 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd) static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} #endif +static int _genpd_set_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + int ret; + + ret = genpd->set_performance_state(genpd, state); + if (ret) + return ret; + + genpd->performance_state = state; + return 0; +} + +static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + struct generic_pm_domain_data *pd_data; + struct pm_domain_data *pdd; + + /* New requested state is same as Max requested state */ + if (state == genpd->performance_state) + return 0; + + /* New requested state is higher than Max requested state */ + if (state > genpd->performance_state) + goto update_state; + + /* Traverse all devices within the domain */ + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + pd_data = to_gpd_data(pdd); + + if (pd_data->performance_state > state) + state = pd_data->performance_state; + } + + if (state == genpd->performance_state) + return 0; + + /* + * We aren't propagating performance state changes of a subdomain to its + * masters as we don't have hardware that needs it. Over that, the + * performance states of subdomain and its masters may not have + * one-to-one mapping and would require additional information. We can + * get back to this once we have hardware that needs it. For that + * reason, we don't have to consider performance state of the subdomains + * of genpd here. + */ + +update_state: + if (!genpd_status_on(genpd)) { + genpd->performance_state = state; + return 0; + } + + return _genpd_set_performance_state(genpd, state); +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +314,9 @@ static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - struct generic_pm_domain_data *gpd_data, *pd_data; - struct pm_domain_data *pdd; + struct generic_pm_domain_data *gpd_data; unsigned int prev; - int ret = 0; + int ret; genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) @@ -281,47 +337,10 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) prev = gpd_data->performance_state; gpd_data->performance_state = state; - /* New requested state is same as Max requested state */ - if (state == genpd->performance_state) - goto unlock; - - /* New requested state is higher than Max requested state */ - if (state > genpd->performance_state) - goto update_state; - - /* Traverse all devices within the domain */ - list_for_each_entry(pdd, &genpd->dev_list, list_node) { - pd_data = to_gpd_data(pdd); - - if (pd_data->performance_state > state) - state = pd_data->performance_state; - } - - if (state == genpd->performance_state) - goto unlock; - - /* - * We aren't propagating performance state changes of a subdomain to its - * masters as we don't have hardware that needs it. Over that, the - * performance states of subdomain and its masters may not have - * one-to-one mapping and would require additional information. We can - * get back to this once we have hardware that needs it. For that - * reason, we don't have to consider performance state of the subdomains - * of genpd here. - */ - -update_state: - if (genpd_status_on(genpd)) { - ret = genpd->set_performance_state(genpd, state); - if (ret) { - gpd_data->performance_state = prev; - goto unlock; - } - } - - genpd->performance_state = state; + ret = _genpd_reeval_performance_state(genpd, state); + if (ret) + gpd_data->performance_state = prev; -unlock: genpd_unlock(genpd); return ret; From patchwork Mon Nov 26 08:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 151993 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5345703ljp; Mon, 26 Nov 2018 00:10:36 -0800 (PST) X-Google-Smtp-Source: AJdET5dRUv0XuhUBKOspIo33UTjAiejXsfZQAhZOX5o6tyGNjeR9e8xeVT+a2B26i7LxB0IzsUNe X-Received: by 2002:a62:14d1:: with SMTP id 200mr27120437pfu.103.1543219835873; Mon, 26 Nov 2018 00:10:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543219835; cv=none; d=google.com; s=arc-20160816; b=R5CkxWGgqyZDnx3vhaM/o1WgYJJx1rCFnbAHuE5NPL6iT+753S8VINkMc4tKmR4xsG iiIsNhGrg4L+RanPTMgUclUtnYAlaCnDTjgLUkwat+h69cKZsfZWhHSW/YvSnOtpB9ye IwwXwC/BnIwYik06mWcf7oE6PGA3zD4w3fyf3psdlIZINTS7EzzgMb+2SicCJkpHEKwH z1VWPFzBd50mRJynX0cp47ydO3I+BO/N9LFXTx7mbZRFBVfHKnZFKycFKlV6+erm8iKz MpIg9mIA0KQvtGWBq859voORU70UW43rjRK10xCa+CZRiVBZE3eSoMC/K8TQbIrkmhtw KjeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gdx8Be1U5CqHmPy7KT6mxY75FaEUymFqFA79hpQ5+qU=; b=ofsz3cMs0r67k/YCmM0VW3cqfEMvKApO2BrfHE9ZlXDiyz/eGuSbQVj6LywIGuoI24 7w7mEgOEqnFoxJYJXLK2AY7eiOWb6HRBPIk2v5GY7soNCOOKt/9xvLNMkI8MaNv+1pQo ZtzqCbMXUGGw+WvOJxLVRnlGs+XDIeiXeXLm3PENRI5axwjqmbjhFkRHknPWtkr5a0zV 3APsTiiiIwqvXKFML0K0/zagFxWnhzZuERVd5FJ8pGQ8jLhXsTekQe0SeIvlMz100fzA 2TlKknEbmr/8RpCGU3mG4h0TfRM6EBDwlU4pn4rHUhphj/bl9CLIXL7IzOVMqFmw15hV JYzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="W+O/u9H5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si19905180pfk.73.2018.11.26.00.10.35; Mon, 26 Nov 2018 00:10:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="W+O/u9H5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbeKZTDw (ORCPT + 32 others); Mon, 26 Nov 2018 14:03:52 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:40398 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbeKZTDw (ORCPT ); Mon, 26 Nov 2018 14:03:52 -0500 Received: by mail-pl1-f194.google.com with SMTP id u18so922287plq.7 for ; Mon, 26 Nov 2018 00:10:33 -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 :mime-version:content-transfer-encoding; bh=gdx8Be1U5CqHmPy7KT6mxY75FaEUymFqFA79hpQ5+qU=; b=W+O/u9H5QL4XKpVXiNDpb3N8r0vyauWUT53C8Ofi3yxv3arF7alHFp4z0npaEl9b60 quBlZ2N8irvJNpfCI2iitGZ37gH/eC9NCosz+3CeqKLQECez8SHHbr7bO/gl7wG6gvA6 Qpmpi4XNDJD/yxsv+6e9lShctUJ06/P1OqylU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gdx8Be1U5CqHmPy7KT6mxY75FaEUymFqFA79hpQ5+qU=; b=gV4Y1EIQSXpgGvONEvudQu7xT5zUxEDf0lKBTgKaEUxZR+QUMIgWQehmakX4UhHiJi V82nOKmg0oEWFLTRQ0KRDnUTS+LtmEjMbef64SeezYP2g8KMF+2OnVxO94J9AFgd9RRL PNmgAIngteYISKugFRIS7BgYsKb+MRCI/EfK86LSaanIU4ktWUBTHY0d1oax5H/M/X7/ Q3/DFjOM2NCLNMVC8DiPmJr/MS6GYDDGrf9W7pU5cezS0b3X5tZ4SlK1rUxjZYHX6pMB menvscBEZQSXkr8VfaVfqwx/MnymsQSXLo9ylsW2KEkNT8RayhkwWbv23a/P5O46qplL k+Kw== X-Gm-Message-State: AA+aEWaMQzOgkJnL6ml2IiHbE82JwhsJwIInI4kWZ0Qu+dScte32H631 xxGBYKEN2ZZNN4jqXAkJWMAn+w== X-Received: by 2002:a17:902:1745:: with SMTP id i63mr23699544pli.145.1543219832860; Mon, 26 Nov 2018 00:10:32 -0800 (PST) Received: from localhost ([122.172.88.116]) by smtp.gmail.com with ESMTPSA id s190sm3761340pfb.103.2018.11.26.00.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:10:32 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/5] PM / Domains: Propagate performance state updates Date: Mon, 26 Nov 2018 13:40:04 +0530 Message-Id: <5a29ceb2704239a8efb4db2e47ca155a422a6e57.1543219386.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit updates genpd core to start propagating performance state updates to master domains that have their set_performance_state() callback set. A genpd handles two type of performance states now. The first one is the performance state requirement put on the genpd by the devices and sub-domains under it, which is already represented by genpd->performance_state. The second type, introduced in this commit, is the performance state requirement(s) put by the genpd on its master domain(s). There is a separate value required for each master that the genpd has and so a new field is added to the struct gpd_link (link->performance_state), which represents the link between a genpd and its master. The struct gpd_link also got another field prev_performance_state, which is used by genpd core as a temporary variable during transitions. We need to propagate setting performance state while powering-on a genpd as well, as we ignore performance state requirements from sub-domains which are powered-off. For this reason _genpd_power_on() also received the additional parameter, depth, which is used for hierarchical locking within genpd. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 113 ++++++++++++++++++++++++++++++------ include/linux/pm_domain.h | 4 ++ 2 files changed, 98 insertions(+), 19 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index d6b389a9f678..206e263abe90 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,24 +239,88 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd) static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} #endif +static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, + unsigned int state, int depth); + static int _genpd_set_performance_state(struct generic_pm_domain *genpd, - unsigned int state) + unsigned int state, int depth) { + struct generic_pm_domain *master; + struct gpd_link *link; + unsigned int mstate; int ret; + /* Propagate to masters of genpd */ + list_for_each_entry(link, &genpd->slave_links, slave_node) { + master = link->master; + + if (!master->set_performance_state) + continue; + + if (unlikely(!state)) { + mstate = 0; + } else { + /* Find master's performance state */ + mstate = dev_pm_opp_xlate_performance_state(genpd->opp_table, + master->opp_table, state); + if (unlikely(!mstate)) { + ret = -EINVAL; + goto err; + } + } + + genpd_lock_nested(master, depth + 1); + + link->prev_performance_state = link->performance_state; + link->performance_state = mstate; + ret = _genpd_reeval_performance_state(master, mstate, depth + 1); + if (ret) + link->performance_state = link->prev_performance_state; + + genpd_unlock(master); + + if (ret) + goto err; + } + ret = genpd->set_performance_state(genpd, state); if (ret) - return ret; + goto err; genpd->performance_state = state; return 0; + +err: + /* Encountered an error, lets rollback */ + list_for_each_entry_continue_reverse(link, &genpd->slave_links, + slave_node) { + master = link->master; + + if (!master->set_performance_state) + continue; + + genpd_lock_nested(master, depth + 1); + + mstate = link->prev_performance_state; + link->performance_state = mstate; + + if (_genpd_reeval_performance_state(master, mstate, depth + 1)) { + pr_err("%s: Failed to roll back to %d performance state\n", + master->name, mstate); + } + + genpd_unlock(master); + } + + return ret; } static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, - unsigned int state) + unsigned int state, int depth) { struct generic_pm_domain_data *pd_data; struct pm_domain_data *pdd; + struct gpd_link *link; /* New requested state is same as Max requested state */ if (state == genpd->performance_state) @@ -274,18 +338,27 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, state = pd_data->performance_state; } - if (state == genpd->performance_state) - return 0; - /* - * We aren't propagating performance state changes of a subdomain to its - * masters as we don't have hardware that needs it. Over that, the - * performance states of subdomain and its masters may not have - * one-to-one mapping and would require additional information. We can - * get back to this once we have hardware that needs it. For that - * reason, we don't have to consider performance state of the subdomains - * of genpd here. + * Traverse all powered-on subdomains within the domain. This can be + * done without any additional locking as the link->performance_state + * field is protected by the master genpd->lock, which is already taken. + * + * Also note that link->performance_state (subdomain's performance state + * requirement to master domain) is different from + * link->slave->performance_state (current performance state requirement + * of the devices/sub-domains of the subdomain) and so can have a + * different value. */ + list_for_each_entry(link, &genpd->master_links, master_node) { + if (!genpd_status_on(link->slave)) + continue; + + if (link->performance_state > state) + state = link->performance_state; + } + + if (state == genpd->performance_state) + return 0; update_state: if (!genpd_status_on(genpd)) { @@ -293,7 +366,7 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, return 0; } - return _genpd_set_performance_state(genpd, state); + return _genpd_set_performance_state(genpd, state, depth); } /** @@ -337,7 +410,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) prev = gpd_data->performance_state; gpd_data->performance_state = state; - ret = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_reeval_performance_state(genpd, state, 0); if (ret) gpd_data->performance_state = prev; @@ -347,7 +420,8 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state); -static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) +static int +_genpd_power_on(struct generic_pm_domain *genpd, bool timed, int depth) { unsigned int state_idx = genpd->state_idx; ktime_t time_start; @@ -368,7 +442,8 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); if (unlikely(genpd->set_performance_state)) { - ret = genpd->set_performance_state(genpd, genpd->performance_state); + ret = _genpd_set_performance_state(genpd, + genpd->performance_state, depth); if (ret) { pr_warn("%s: Failed to set performance state %d (%d)\n", genpd->name, genpd->performance_state, ret); @@ -558,7 +633,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) } } - ret = _genpd_power_on(genpd, true); + ret = _genpd_power_on(genpd, true, depth); if (ret) goto err; @@ -963,7 +1038,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock, genpd_unlock(link->master); } - _genpd_power_on(genpd, false); + _genpd_power_on(genpd, false, depth); genpd->status = GPD_STATE_ACTIVE; } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 9ad101362aef..dd364abb649a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -136,6 +136,10 @@ struct gpd_link { struct list_head master_node; struct generic_pm_domain *slave; struct list_head slave_node; + + /* Sub-domain's per-master domain performance state */ + unsigned int performance_state; + unsigned int prev_performance_state; }; struct gpd_timing_data {