From patchwork Sat Aug 10 00:58:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 170990 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10715967ile; Fri, 9 Aug 2019 17:58:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWsYxPHr3uMDUqz2Dal6OBb/uN91eQdZsHo103haRIXeAUyVTwpw3DBDxDZhYeN3hlT55D X-Received: by 2002:a17:902:740a:: with SMTP id g10mr22113493pll.82.1565398732537; Fri, 09 Aug 2019 17:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565398732; cv=none; d=google.com; s=arc-20160816; b=JS57TWBCXcwUR/BXHPsnhZvOAF71ccGFjDqv7kO8qMzCfdMcc6O0wKA5rmjNuKX4ms T5APBhVU5Oygcg8D73Xj0se8jdOjFTj3ovYxMnRsvKHNWxQ5p1+/sFnofK8J46U2N3ua DkmdTuxbnwaktz9yB70LgEPl4EmkYGeITy+yvOKE58Y6aFQ0J/sB4ttxO3zwwLDt7v2z ewM453GEhsSpkOyuBh5ivSToKjfNimPcxbr38qDntXqCPykYc+Oz4fkpLr0Znn9PNaNV M1MCrRjzomeNzvEePMIQqPB4PmEuXEA18Tt3hdkWRA/mvqnbh4pPvAa7NX5zlpLtEZ6E YL1A== 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=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=NuytuFea3LseYe8MzpapqISWqzgrywhUo4E46Imd668rlaKSWyAieP6wmVnAS2XgIP Op3Vs7elqc9e+wK5CdKZvndoQqNJawmrElOo4mDx0y0FXkkZLl4zHLyTUjTKn02jp7iM L3TMBsnj47zwyholpuebUNU9ZhP/VXsfRm+fcMjx9Z5Hspzf3a6PhmkrzlDxQ4oGZMNg fhhgDop1JD8nAJTlASlyh+jMFaFqGg99+hETLaaW/7t6t4n44PR/vH8K6WhtsinxyzIN i8GAwUF/jL/tKRLJt3xmb1uldktzHN/9xlZ1fG4YoTpU7LDR5LjWeq1hDwZrMdcItNEh Thqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkbgyLEg; 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; 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 m17si25793031pgc.461.2019.08.09.17.58.52; Fri, 09 Aug 2019 17:58:52 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=hkbgyLEg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbfHJA6v (ORCPT + 11 others); Fri, 9 Aug 2019 20:58:51 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:40328 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfHJA6v (ORCPT ); Fri, 9 Aug 2019 20:58:51 -0400 Received: by mail-qk1-f195.google.com with SMTP id s145so73089702qke.7 for ; Fri, 09 Aug 2019 17:58:50 -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=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=hkbgyLEgZlD9kHpDLYWfPn3m8j+o9fzLN89GQTQxBW9BUB4FkDqyFtttetF+aCOvlw G0sFDZLfF72FRteULz0pNkf92NQIbb2ISdlLx4oVag42hvjYfCStB0Z9sW1R4x1k10J0 IQmiPY4yaEV95Z+ufps543u6cREblT9A1d8THkUyhVdSqO9/x4DUipWpY1R6AbPWgs+U mMEgKPGvG7crdcydB5iGZ8Zc9N8+sZ42ksR1lkm5FpnqaRof0LZLBCDoSe7OKspv9cuB opSpXbTIxCBLskA52VzkGdi5JO8BCk14Jqr22prOnB4k9tqsMTzgg4PFBug1qj1oG4rB Ks4A== 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=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=QmGDiFEps0bsS+bRdLrbVjLCtuN+BrP0PbNVPw73Z97frt6p5XOpbPZirnvR7EXkwJ eQQvRQemJ2b8ibJF7Ujm+ZhXTFnNZ90YDg4HfzPcFRBk3yCua6HjuK9gV9yF0AZbnhz6 5dZGgyQQW9hhVje3cGkrTcas2EAGeKe/yB43FRBPIXFp3EoJkh/ki4M0GpMpRvhKsavg ZkEvL+eJ0TL7hgdzXa8gDIGc1cGJv9YuEu1FVQab3vNyliyZR36GC+/cDYWD69DCqto4 fq79ZWYilynJj58q7VmfKI6ZZjWQmrR+zvNzxPFiF4CzrEFzzC4GPbTqsrh9iVd/rL8L AD6w== X-Gm-Message-State: APjAAAUBiG4WjROb8SXWcq3KMNCY8Ul9aiaIlKoFx0ExhZZW9UBEvi+d AQXd52KlyGL0pxtY7N7zIIWWqg== X-Received: by 2002:a37:8a81:: with SMTP id m123mr20602707qkd.360.1565398730185; Fri, 09 Aug 2019 17:58:50 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id t9sm4603105qtr.29.2019.08.09.17.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Aug 2019 17:58:49 -0700 (PDT) From: Thara Gopinath To: qualcomm-lt@lists.linaro.org, linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, ulf.hansson@linaro.org, rnayak@codeaurora.org Subject: [PATCH 1/4] PM/Domains: Add support for retrieving genpd performance states information Date: Fri, 9 Aug 2019 20:58:44 -0400 Message-Id: <1565398727-23090-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> References: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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. Signed-off-by: Thara Gopinath --- drivers/base/power/domain.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 18 ++++++++++++++++++ 2 files changed, 56 insertions(+) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b063bc4..17e0375 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -413,6 +413,44 @@ 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, + unsigned int *state) +{ + struct generic_pm_domain *genpd; + + genpd = dev_to_genpd(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + genpd_lock(genpd); + *state = genpd->performance_state; + genpd_unlock(genpd); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_performance_state); + +int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count) +{ + struct generic_pm_domain *genpd; + int ret; + + genpd = dev_to_genpd(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + if (unlikely(!genpd->get_performance_state_count)) + return -EINVAL; + + genpd_lock(genpd); + ret = genpd->get_performance_state_count(genpd, count); + genpd_unlock(genpd); + + return ret; +} +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 91d9bf4..0e5f502 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -117,6 +117,8 @@ 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, + unsigned int *count); struct gpd_dev_ops dev_ops; s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; @@ -204,6 +206,10 @@ 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, + unsigned int *state); +int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -251,6 +257,18 @@ 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, + unsigned int *state); +{ + return -ENOTSUPP; +} + +static inline int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count); +{ + return -ENOTSUPP; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif