From patchwork Wed Oct 16 19:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176518 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7827171ill; Wed, 16 Oct 2019 12:37:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPbCTqMSlxur7tIqSnqi0zsz0wEnO2pG61Yrxgfi10LfjuazrPkU/8dtfj2o8YcCnuX5z2 X-Received: by 2002:a50:af45:: with SMTP id g63mr40527746edd.21.1571254652296; Wed, 16 Oct 2019 12:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571254652; cv=none; d=google.com; s=arc-20160816; b=cVE31PXJCQZv2NjZnsUtUrlZ194AySOIwPQVToQ5lfjIqSQuTBABT7LtrTwCOHiCNv OQKo8CqsNvhxwyuf4IeYmhaurHgj22A5iTLomtsJfNmOUIjvv0p7jTmDoaI4JpTuYbda ojx154iFjH1Zh7IqYnAqo1YD+Kb4TibB0w3ZPd9JoP9QpAEP4iPocUt/7fmkqoujQeeu Yh+dV/3pf/+bE5LFmsM/96kGUSM1t5U41SwPPwW87NrZrTi6nie9cCscLnuyhVocTLW9 SGikrTQMs6UxfklMYqr76DL/mGB2e2t0zG6JayVDi0u/wPdx2J8lR1R2AE/kYP3xCk5f H4Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=O+e4P1QVmJfIMHeM4ld6pm/7hZNUvEAXXUg+herLbDU=; b=UanvjxiHRoJmNK14xoQbUVP0ZinCdEwVx7cZAkxugqsoCKjXOukMV6FtVJJXzEa0NX pW7NJaQN2p8FK0/EH+OBbhVdJSC67dYaXthbZ37lgTsSf1x3rxI5pe2Lt+9kyuDyYrX+ 6K10kuT+WiiSX6UX2YSRWzryMyqS3XQ93MXkcvOePkMin64FliBPj0rmlJ8MnLp3WwIq LOrAI1JccJe0solV4x8hNoW7K/cuVIenKK8cSP7RY1cPxLspRLrHnGFZmIGpILSIMe// 4hZMHyv7Vvt/Hl6EzF1vKpuPBOqae+kTdqWRYosHzQVvFW3sp29W3hYKxGJmRtSDdruK DnRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Km01FxsN; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 b20si17195091edc.359.2019.10.16.12.37.32; Wed, 16 Oct 2019 12:37:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=Km01FxsN; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S2394427AbfJPThb (ORCPT + 8 others); Wed, 16 Oct 2019 15:37:31 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41356 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394418AbfJPThb (ORCPT ); Wed, 16 Oct 2019 15:37:31 -0400 Received: by mail-qt1-f196.google.com with SMTP id v52so37856990qtb.8 for ; Wed, 16 Oct 2019 12:37:30 -0700 (PDT) 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; bh=O+e4P1QVmJfIMHeM4ld6pm/7hZNUvEAXXUg+herLbDU=; b=Km01FxsNsfs4bfJReg3ItWzLtqe5B6Zko3KM06evWv/KNiIuJmW3EURmoJ/YfVReQZ c7A8hFKcFVaNiESaiYjOmaKeunxu2c3xRSSzOFGUmgxQS0kp1RktUlidPtxe0YcrIOB9 RfFmTETa21tkhEcOJP1oxGYwqhQLtuzYcVAb+d2UTJ2HsSeoga+fmks2RbmozcyQ2Wn0 aOXeRGC+taFMKVC0+n0/yfgy/EwaN4/xMApY87zkJ85mivUwoP24IsR1Mj6c8/v95PzF VefQlrEBYFzukAc13s2m7vmLxBrmkbI8rWah6tlJOWbcvHvrNLIG5pV3D/dzaflP+QEh fyrQ== 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; bh=O+e4P1QVmJfIMHeM4ld6pm/7hZNUvEAXXUg+herLbDU=; b=lASoaijLbspKJiP8YjfGG/kAOACEQkznZnhy4ravSJ7pAi0JA7wHydEsjXlkewgINo 1XxtQbBoAumSng1IndONMS6HLmHeL7ZGqJAjTC0kKUYrSRiGL+oXqhOyv6GuPPK2PEs6 y7otkgq9k4MS6MZxhIjjXZMu1sI/Aggvsvq4EKsn1iiLt+mBMzspK0f0Egfuikpdc1hG XZvAvRJTZR9bXF6P16uXbQJzN3sr9ZOhgJO53PdW1JWR1UNXul3MqDFE+rzCJWzoNJqA PG8hoaGt57/TTaSHmm6E3pmslYeGxRq2Z3a5iZgNQ7za3ZYSJRynOZPULzTc+KNMTzyp SsBA== X-Gm-Message-State: APjAAAXBxNINMa9Z6j0FRlPKYb0FWRfnu9O6+k30dlXHAoS6CNTgnuGO ziI5x2aP5OWeOR6c0/AhZhVBzg== X-Received: by 2002:ad4:408c:: with SMTP id l12mr42407364qvp.210.1571254649895; Wed, 16 Oct 2019 12:37:29 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id 54sm16246030qts.75.2019.10.16.12.37.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Oct 2019 12:37:29 -0700 (PDT) From: Thara Gopinath To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/7] PM/Domains: Add support for retrieving genpd performance states information Date: Wed, 16 Oct 2019 15:37:15 -0400 Message-Id: <1571254641-13626-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571254641-13626-1-git-send-email-thara.gopinath@linaro.org> References: <1571254641-13626-1-git-send-email-thara.gopinath@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add two new APIs in the genpd framework, dev_pm_genpd_get_performance_state to return the current performance state of a power domain and dev_pm_genpd_performance_state_count to return the total number of performance states supported by a power domain. Since the genpd framework does not maintain a count of number of performance states supported by a power domain, introduce a new callback(.get_performance_state_count) that can be used to retrieve this information from power domain drivers. These APIs are added to aid the implementation of a power domain as a warming device. Linux kernel cooling device framework(into which warming device can be plugged in) requires during initialization to be provided with the maximum number of states that can be supported. When a power domain acts as a warming device, the max state is the max number of perfomrance states supported by the power domain. The cooling device framework implements API to retrieve the current state of the cooling device. This in turn translates to the current performance state of the power domain. Signed-off-by: Thara Gopinath --- drivers/base/power/domain.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 13 +++++++++++++ 2 files changed, 50 insertions(+) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cc85e87..507e530 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -408,6 +408,43 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state); +int dev_pm_genpd_get_performance_state(struct device *dev) +{ + struct generic_pm_domain *genpd; + unsigned int state; + + genpd = dev_to_genpd_safe(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + genpd_lock(genpd); + state = genpd->performance_state; + genpd_unlock(genpd); + + return state; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_performance_state); + +int dev_pm_genpd_performance_state_count(struct device *dev) +{ + struct generic_pm_domain *genpd; + int count; + + genpd = dev_to_genpd_safe(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + if (unlikely(!genpd->get_performance_state_count)) + return -EINVAL; + + genpd_lock(genpd); + count = genpd->get_performance_state_count(genpd); + genpd_unlock(genpd); + + return count; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_performance_state_count); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index baf02ff..e88e57f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -117,6 +117,7 @@ struct generic_pm_domain { struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); + int (*get_performance_state_count)(struct generic_pm_domain *genpd); struct gpd_dev_ops dev_ops; s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; @@ -204,6 +205,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); +int dev_pm_genpd_get_performance_state(struct device *dev); +int dev_pm_genpd_performance_state_count(struct device *dev); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -251,6 +254,16 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, return -ENOTSUPP; } +static inline int dev_pm_genpd_get_performance_state(struct device *dev) +{ + return -ENOTSUPP; +} + +static inline int dev_pm_genpd_performance_state_count(struct device *dev) +{ + return -ENOTSUPP; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif