From patchwork Fri Dec 14 10:15:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153808 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881873ljp; Fri, 14 Dec 2018 02:15:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1jVFzQKwf8uZQtD3lhFePQ8SvEFLd0Bm6/eCKF35ECNqiR/6sbixI7DCoYUbbasxiQJh5 X-Received: by 2002:a62:f54f:: with SMTP id n76mr2255138pfh.59.1544782559518; Fri, 14 Dec 2018 02:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782559; cv=none; d=google.com; s=arc-20160816; b=F83pbpLlb6dUyL+zoiQXgugMaFS+pg5UnY/T6TdtNujNexY4FOswfQTenDm9AhVZj6 JJtkfvPiWM3EA+3cMQR+HHJtcPTXO+vE/WhbDRpiPTx2C65v8YDL058sVHHhK5vqUa11 Y6+yBPdvD3J73VIcJTAVykeh/n8rEtrUUSVf7yk4WRv+cgqNSW4YMAYVAbXf0AcFnzXM yLd79eFDIr/Pst7MMdwkEWZscgKDz1sOqmHzB+SWVV7JkT6KFTB48bJEQXVWujnPo6QK bEQSA6a1qK6AAe7/p3q12J/Rwjqw2mHMY5KYZPDzShW8DGXMQYjk/mIw6yfVtYH5+Pzo iOYw== 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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=k+q3LXH3CjWgakw/f+YYrq0Qe9WevdcYeHt4ahB0coVepVALesjxUuAyz97HkK3ZA0 km71xQZN70TYS67GnzQwxVsHuOJfsSRaaG3GgrusopXgfl/1NQyWm5lgeI05UURq9uKg x6p7rxvjJCx92zrUbdOzK//OnhFTtcSD5uvL9FrkYHCa0ojZMUf3P0o0f/v5neL9onjP Gf5MPZEKZFEotgB+8qpHpEXiGd5Zi1HSuyhkHUGKeKH7sf8hicqHaKQnAYYToJTG9BYt YO0KzH8sqo3ZeonS6YSrpbwBo+xrI3/w0YHu8ussgIPGZ5p76lIDGQDJB8/nmeYnlvwH qKMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jLZVNYXP; 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 r77si3710707pfa.186.2018.12.14.02.15.59; Fri, 14 Dec 2018 02:15:59 -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=jLZVNYXP; 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 S1729620AbeLNKP6 (ORCPT + 31 others); Fri, 14 Dec 2018 05:15:58 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34376 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729585AbeLNKPy (ORCPT ); Fri, 14 Dec 2018 05:15:54 -0500 Received: by mail-pf1-f193.google.com with SMTP id h3so2637398pfg.1 for ; Fri, 14 Dec 2018 02:15:53 -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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=jLZVNYXPI8sRndhzeySNVUXvkyvSG49GfBR/xdeF0n3/NHg6+M/EExbHnlCNgjqPz7 8hRFRtD9qzcoDO6pChiptapv7mwFljOBo3jh9X+o8n+yKKexkqvQ1MynFB4KGlY39doT T94oOcFY21nPgyZY/zFogY9VzEpRSYvuPabGc= 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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=FGhuUK3IPmPLC9eVX49x3fnssT1KLnFtI15XkuRldlOJCoeMlGSrHTLNFQA16nezHk jmobp6jsu9ZIXwCiwjtKL6N4nDdrU+P92T7874zb4xIC//WJkntOBS52tK6nhJZ1gGMO NBX9Wv3zlXpa/eE3ivW0S0eTIY17uqgHPBLUDi03nDUJaVLbCxVYapX9QUFeeIUYGHGE B6DaHCuXTvE7I3a1fuEL8JfKBFEPEHrme0KUhjQI4Tnq218aeG69e8tel+A0GH0tEGeN GVECRZ7TSqbhF1+WRv71cBJgVIb2qyV7U3WLeXYV1D594zZMvj4Hoom9LRigANKCcujf asWQ== X-Gm-Message-State: AA+aEWZMIAjtf76gh/K0cxfs+tQVqXJDnoWrp3mX0LyS6ARUGamtzNtw HGp6zPV/ipJIRv145unbsDwnwA== X-Received: by 2002:a63:fd0a:: with SMTP id d10mr2208487pgh.164.1544782553378; Fri, 14 Dec 2018 02:15:53 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id t24sm5697214pfh.21.2018.12.14.02.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:52 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 5/7] PM / Domains: Save OPP table pointer in genpd Date: Fri, 14 Dec 2018 15:45:31 +0530 Message-Id: <5603371d1ad204a7314a3618d362d583b555f6b6.1544782279.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 dev_pm_genpd_set_performance_state() will be required to call dev_pm_opp_xlate_performance_state() going forward to translate from performance state of a sub-domain to performance state of its master. And dev_pm_opp_xlate_performance_state() needs pointers to the OPP tables of both genpd and its master. Lets fetch and save them while the OPP tables are added. Fetching the OPP tables should never fail as we just added the OPP tables and so add a WARN_ON() for such a bug instead of full error paths. Tested-by: Rajendra Nayak 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 Reviewed-by: Ulf Hansson diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4a4e39d12354..1e98c637e069 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1896,12 +1896,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; } @@ -1954,6 +1963,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; @@ -1978,8 +1994,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); @@ -2013,6 +2031,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,