From patchwork Tue Sep 10 17:14:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11139927 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E95913BD for ; Tue, 10 Sep 2019 17:14:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D837B2171F for ; Tue, 10 Sep 2019 17:14:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rEMMWt7t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394246AbfIJROl (ORCPT ); Tue, 10 Sep 2019 13:14:41 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37664 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394241AbfIJROk (ORCPT ); Tue, 10 Sep 2019 13:14:40 -0400 Received: by mail-qt1-f196.google.com with SMTP id g13so21235300qtj.4 for ; Tue, 10 Sep 2019 10:14:40 -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=dCiF8fdi1tMlpba3ZCHWMNQTExOfXcmO5otqmXgClM8=; b=rEMMWt7tKcNRiWvTKf0j8I1+FhXUqpL+IcsO+vt1qt3at8FvGhG/IjobpztLqTc2ly C5u7tkmpXv3/FWNUziXTfgR2gAPKEatdBHwaaii1fyhFvPPzKBBn7Y2NAYclbUsxOfPD 9gWfFRpkE3F9mbZTOUt1Zm16SZs70qyrgnrWOmT2FwsAaAokXmT71nldQrYLeX8oKnN2 86p8hl1BXkdyw8lFZsvOQau8acRhbXjWJ25bbdtbfE6Hi49MBDpKKfhRalbaeP7IWDjE 98CtQCue1LXh7/SpiZ3s4Xz+QXCfmijOaUy7N+ZbyKryBqcFsSB37Ks3vOyS4SonD+Um mQcA== 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=dCiF8fdi1tMlpba3ZCHWMNQTExOfXcmO5otqmXgClM8=; b=qp2nPIQTPI6dxxHObDcD+DN77IF+uWd5CdysT/eWJ0ytBJuCkheXUSEldE6ZClMRD6 namJwufHyEBNYrjnkJdG/+Pxe43nIjq9J/ESIGrvKSrGzUkLaAVHnVXXeiIh3etWlD8l 7vIKUzfUl8kwd9UgnH2yL4Jeymx/DRhCdWSkGcPgnkABHPZXT7mDPv/TSC+sudLfqFGV GKKwNO149dC6Xuex2lIL2yfNQ5llL96Zgz/pyImMP4W3zfLFQtPlVuIvWBeaM9lsA85V AakVs9KytYJy73+WGwnliTGKHA/C9Jz1/FUKr2CjIExFaUx+ygGJ1NJWKDpujtY+P1WG AO5g== X-Gm-Message-State: APjAAAU41mwKSWjCRxEZCdsC4JrNc7F+zqBu0sLjFZ5Gm0cegfJ/Xm8R il7Wwzxs6+WV+2pah/J+q/dB4w== X-Google-Smtp-Source: APXvYqy13ITSCMnPbkYAN32ta5SIDhKwz2HWi8mDxmmNmTAFGAktekaQqYvXErOyQ+5qgK90anlY9A== X-Received: by 2002:ad4:540c:: with SMTP id f12mr19282996qvt.104.1568135679638; Tue, 10 Sep 2019 10:14:39 -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 g45sm3400713qtc.9.2019.09.10.10.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Sep 2019 10:14:39 -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, robh+dt@kernel.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 v2 1/5] PM/Domains: Add support for retrieving genpd performance states information Date: Tue, 10 Sep 2019 13:14:32 -0400 Message-Id: <1568135676-9328-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568135676-9328-1-git-send-email-thara.gopinath@linaro.org> References: <1568135676-9328-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. 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 --- v1->v2: - Use dev_to_genpd_safe when accessing genpd from a device pointer. - Change the format of dev_pm_genpd_get_performance_state and dev_pm_genpd_performance_state_count to return back the requested parameter rather than taking a point parameter as input. drivers/base/power/domain.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 13 +++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2650ae2..126710e 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 From patchwork Tue Sep 10 17:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11139945 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E79F014ED for ; Tue, 10 Sep 2019 17:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C657D21881 for ; Tue, 10 Sep 2019 17:15:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Hqq+ZhFi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436868AbfIJROn (ORCPT ); Tue, 10 Sep 2019 13:14:43 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42555 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394243AbfIJROl (ORCPT ); Tue, 10 Sep 2019 13:14:41 -0400 Received: by mail-qt1-f194.google.com with SMTP id c17so2297496qtv.9 for ; Tue, 10 Sep 2019 10:14:41 -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=85pIOc0VjXEJVW1VGnKzdHZfrPu0dnHyPG3j4q4cGXI=; b=Hqq+ZhFigBBOZ8KVi3k/1GBGGNXSk+aAlUmrrKb7C5UmaZ6FoAtluRmqcZqeISVKXv leAypDTy0Y9VBEICyka7PNC+myRYAWDKvEv8Usaoj+QgvyZyFwd0rscFFq7NmqcnM5nF 4J2yUegdTxW+cJpAWIRbY8Slqi42kwgByV7FPREkEpk51fb2U8TaPamQhUlTfxhGA7cI D8o/S46/PdI00Vq7JtFUa3E1/e826aT41nMXFSSFoUE93EMFuTp5NCZykLC/MWNhMZy3 p4RRGp16vXYDXXOLxkFGdFVQucfohagdojOaRo7QvL1Cll7qiTHisoVwn6+Qc6jgfXOQ howg== 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=85pIOc0VjXEJVW1VGnKzdHZfrPu0dnHyPG3j4q4cGXI=; b=P5tDhMNZB6yzzBKICcTbogSQXlQXoHGw8sfxzY+Nn6Yta/BFp5d4JWjRMDULGhC/rI CM7t94n2XEEinP9CjrEomIRrwt80QD3kMBqOKzTd7CPAP3hU3vY7N9MUy3FAgA3SkHSj JBOOANhk5+dGQcXn2xUxjrV6643lC3Bb0bgAQXoIkRp398KB4t0epDbCCGeQ1skMrrlC /T9bAhKbJEb27hd2TjmYADytCPjxJ/+tnqyfc4AXPfA/c1H8yPmiOB0jfNgiuWyRAaVG bRFAbUesp8Ne/VJmgAbc/akO3Nf/yU5J0Ow2YhGFvsZSMfyRQLQjEV+jtf8MTzOI/1KG +qGw== X-Gm-Message-State: APjAAAW44DAkBq3HAvOSA7m0Olx6qER0fojARvmqOP/9S8kWhnbaqyZC BtK+GY9cdmDdL9H75XBf8w8ukQ== X-Google-Smtp-Source: APXvYqzJ3KeIDWlW5DCZ0rKR+iZzQQ/izEFFd7jC4UrUByD1xzyZXWg+I301lrMlRkHBjzFbuq4dWw== X-Received: by 2002:a0c:ee22:: with SMTP id l2mr6412105qvs.4.1568135680903; Tue, 10 Sep 2019 10:14:40 -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 g45sm3400713qtc.9.2019.09.10.10.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Sep 2019 10:14:40 -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, robh+dt@kernel.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 v2 2/5] soc: qcom: rpmhpd: Introduce function to retrieve power domain performance state count Date: Tue, 10 Sep 2019 13:14:33 -0400 Message-Id: <1568135676-9328-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568135676-9328-1-git-send-email-thara.gopinath@linaro.org> References: <1568135676-9328-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 Populate .get_performace_state_count in genpd ops to retrieve the count of performance states supported by a rpmh power domain. Signed-off-by: Thara Gopinath --- v1->v2: - Changes ti incorporate the new format of get_performance_state_count. drivers/soc/qcom/rpmhpd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index 5741ec3..9d37534 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -285,6 +285,13 @@ static unsigned int rpmhpd_get_performance_state(struct generic_pm_domain *genpd return dev_pm_opp_get_level(opp); } +static int rpmhpd_performance_states_count(struct generic_pm_domain *domain) +{ + struct rpmhpd *pd = domain_to_rpmhpd(domain); + + return pd->level_count; +} + static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) { int i; @@ -373,6 +380,8 @@ static int rpmhpd_probe(struct platform_device *pdev) rpmhpds[i]->pd.power_on = rpmhpd_power_on; rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state; rpmhpds[i]->pd.opp_to_performance_state = rpmhpd_get_performance_state; + rpmhpds[i]->pd.get_performance_state_count = + rpmhpd_performance_states_count; pm_genpd_init(&rpmhpds[i]->pd, NULL, true); data->domains[i] = &rpmhpds[i]->pd; From patchwork Tue Sep 10 17:14:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11139941 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02B9C924 for ; Tue, 10 Sep 2019 17:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D577F21D6C for ; Tue, 10 Sep 2019 17:15:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LFhaFNAn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437036AbfIJRPA (ORCPT ); Tue, 10 Sep 2019 13:15:00 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46745 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394249AbfIJROn (ORCPT ); Tue, 10 Sep 2019 13:14:43 -0400 Received: by mail-qt1-f193.google.com with SMTP id v11so21572903qto.13 for ; Tue, 10 Sep 2019 10:14:42 -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=pHdUSG06S1sXGHlL1sjMEDPrOFbJ84fKCAwVrFTIeNI=; b=LFhaFNAnkVRzT4lYKU7W1WSI9NH7ihO+uv0URMnSVT/UJgUfAuZJwBrSprbLW9Yy/B b5xcVb8rR3KvFvMYkhC/BaG/aXaeGihJMNQruiK49G0/BQ/BPp/JQwhcKgRh0gLSkRS/ M1+Ui3smnc76FrOKXcWBcZ4JrQ7L5EWsjUoxBfA2td/AgchlqPqgt+tGKBK/JQl74eiE o59VD762axYy8+O7ySYNCY1WsgQXUrgaTxp96cX8ZKg4Ns5egLEuOYVlP2gJFR5Ckc3i wS9/nev0koEcsSbVXyg84TU7vP4DYfFBmoAZnUe61GwMq4oush4Fh7KqqC4PQpn+/1zV hjgA== 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=pHdUSG06S1sXGHlL1sjMEDPrOFbJ84fKCAwVrFTIeNI=; b=fNdZo9kZDKlJlPQbQz7scmcWkmNmZoydT5AaP3xEV8BLmkmNFggZspSUPJ9WGh7tdw 0OFfYYoRUfpw/9aDKQ9c3TnRG6mP/3zIr/FyrLroXzni90al5oc2xjONgIXIrL76S4EV +S+NYjkpFlc5MQXpb1RAzS/0+TIsRfpRtRBxiseUeimOpUgjxdUV6h9ssFMLIC2dRrNu 5GE7pXLMqwdSTO8/WHM0i6uGGNWP91wE/0F3PMACx4WX5CClBpdj2gVMvP1zSrP5N/QJ 6q4GVgMZMBOsozvTrpkAnCRYJNBB8BWKO/P94RxFhbSwKElUpPFMRoRYGV/faOCkx+uX 7dDQ== X-Gm-Message-State: APjAAAUkwV0LPvbzDt/IybGGfYo7BSuMsVFUBwNWjbrioF6a3Qs4fMyP DAg1GKwVpHOpEzCqiU8xAmf98g== X-Google-Smtp-Source: APXvYqzJLerY/k43OHwIVaiwNYn4guYcGyo1M1aaZ+k4SiKXSX8RWI41bTdRmjsTdpTncWtL1Ei5VA== X-Received: by 2002:a05:6214:15d1:: with SMTP id p17mr19340829qvz.74.1568135682152; Tue, 10 Sep 2019 10:14:42 -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 g45sm3400713qtc.9.2019.09.10.10.14.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Sep 2019 10:14:41 -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, robh+dt@kernel.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 3/5] dt-bindings: thermal: Add generic power domain warming device binding Date: Tue, 10 Sep 2019 13:14:34 -0400 Message-Id: <1568135676-9328-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568135676-9328-1-git-send-email-thara.gopinath@linaro.org> References: <1568135676-9328-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 binding to define power domains as thermal warming devices. Signed-off-by: Thara Gopinath --- .../bindings/thermal/pwr-domain-warming.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/pwr-domain-warming.txt diff --git a/Documentation/devicetree/bindings/thermal/pwr-domain-warming.txt b/Documentation/devicetree/bindings/thermal/pwr-domain-warming.txt new file mode 100644 index 0000000..25fc568 --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/pwr-domain-warming.txt @@ -0,0 +1,32 @@ +* Generic power domain based thermal warming device. + +This binding describes the power domains that can be used as a +thermal warming device. + +- compatible: + Usage: required + Value type: + Definition: must be "thermal-power-domain-wdev" + +- #temp-reg-cells: + Usage: required + Value type: + Definition: Must be 2 + +- power-domains: + Usage: required + Value type: + Definition: reference to power-domains that match power-domain-names + +- power-domain-names: + Usage: required + Value type: + Definition: The power-domains that can behave as warming devices + +Example 1 +thermal_wdev: rpmhpd_mx_wdev { + compatible = "thermal-power-domain-wdev"; + #cooling-cells = <2>; + power-domains = <&rpmhpd SDM845_MX>; + power-domain-names = "mx"; + }; From patchwork Tue Sep 10 17:14:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11139933 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DBF914ED for ; Tue, 10 Sep 2019 17:14:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E3EC217D7 for ; Tue, 10 Sep 2019 17:14:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Gjln9GbM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437039AbfIJROp (ORCPT ); Tue, 10 Sep 2019 13:14:45 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41562 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437022AbfIJROo (ORCPT ); Tue, 10 Sep 2019 13:14:44 -0400 Received: by mail-qt1-f195.google.com with SMTP id j10so21598411qtp.8 for ; Tue, 10 Sep 2019 10:14:44 -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=9F/vvtUdvbyD33UWlhzTxkuCa0DWaFmi4SY1XMgTAuU=; b=Gjln9GbM9nOOKTQSIjPm1CBoOEzG7NkuB+2lclA+7WWh/VkMsZYI/bKvD7rTE1SFvD ALgaaqvNXJv/Xs5Gsf38fEEA9nTD8Nhv+SIoUZg9ybNDKIbwJIUtA3xZh46E0GXp3x5b Homia22HCO/9NR9Dl1RqQOasekzh2zUH9G6YoP6ydTXU3WsJhoEJcs2G/mxxVWVyCDcZ 8YcTdb+RP1T9W45TqfYxF3SQGZotGlODA3b9JL7/scUQYvuE1jhHl7L+eiAcAFFhU2WH +W5/ph9mYomGBeW0c/EDzd3liwRoHle3Pvxb6NVYknmirH3EQscqTzeCGFdmP0906FSm 0v1A== 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=9F/vvtUdvbyD33UWlhzTxkuCa0DWaFmi4SY1XMgTAuU=; b=mkuUfI4j3yz7h9ZItKauHcFNBF+6/da/4zRAeZgId6ROe5CoIyqJ4gGSL7kjPM6lma K4WmJ6+Yz+T0iWytNPlftphtDb4mrAI6sAO33Xo75dGBPnqzlrhZSPaDtnaKQO1SFFuf 5LzpA5T5L8bbl1ic6lopDHppPTfmeD3leMiI4IFsHWtKTCSa7gaSffQO8KABADzUKZq5 8B+4sCZ/qibs4kNWdGmLoRkM0t8CHvbDv0H9DgHX5IMsFZgUozi0NkeEv49qO6fCIAPP 1ShlMr7wLFcXbwXUbauzWpFjDKvMDkEVPn5xv6X+wI80uRjRp/o+WzROVatNLcy8Z6cF Wyww== X-Gm-Message-State: APjAAAVxhrVw0Kt/DYJscrjRXePTybj9eVedwzwJ4MPuC91/DRT9+XLN 3keyp45N0cmPsfATkV7C97ePSA== X-Google-Smtp-Source: APXvYqwDgmmlp0YEL9py9MK3LV2mk/9QIqB/9jPn58f5P0VKtYmXKFbQKbMvZkm+ndcDP9DiQR6kiA== X-Received: by 2002:a0c:db94:: with SMTP id m20mr18626455qvk.142.1568135683409; Tue, 10 Sep 2019 10:14:43 -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 g45sm3400713qtc.9.2019.09.10.10.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Sep 2019 10:14:42 -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, robh+dt@kernel.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 4/5] thermal: Add generic power domain warming device driver. Date: Tue, 10 Sep 2019 13:14:35 -0400 Message-Id: <1568135676-9328-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568135676-9328-1-git-send-email-thara.gopinath@linaro.org> References: <1568135676-9328-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 Resources modeled as power domains in linux kenrel can be used to warm the SoC(eg. mx power domain on sdm845). To support this feature, introduce a generic power domain warming device driver that can be plugged into the thermal framework (The thermal framework itself requires further modifiction to support a warming device in place of a cooling device. Those extensions are not introduced in this patch series). Signed-off-by: Thara Gopinath --- v1->v2: - Make power domain based warming device driver a generic driver in the thermal framework. v1 implemented this as a Qualcomm specific driver. - Rename certain variables as per review suggestions on the mailing list. drivers/thermal/Kconfig | 11 +++ drivers/thermal/Makefile | 2 + drivers/thermal/pwr_domain_warming.c | 174 +++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 drivers/thermal/pwr_domain_warming.c diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 9966364..eeb6018 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -187,6 +187,17 @@ config DEVFREQ_THERMAL If you want this support, you should say Y here. +config PWR_DOMAIN_WARMING_THERMAL + bool "Power Domain based warming device" + depends on PM_GENERIC_DOMAINS + depends on PM_GENERIC_DOMAINS_OF + help + This implements the generic power domain based warming + mechanism through increasing the performance state of + a power domain. + + If you want this support, you should say Y here. + config THERMAL_EMULATION bool "Thermal emulation mode support" help diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 74a37c7..382c64a 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -27,6 +27,8 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o # devfreq cooling thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o +thermal_sys-$(CONFIG_PWR_DOMAIN_WARMING_THERMAL) += pwr_domain_warming.o + # platform thermal drivers obj-y += broadcom/ obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o diff --git a/drivers/thermal/pwr_domain_warming.c b/drivers/thermal/pwr_domain_warming.c new file mode 100644 index 0000000..3dd792b --- /dev/null +++ b/drivers/thermal/pwr_domain_warming.c @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct pd_warming_device { + struct thermal_cooling_device *cdev; + struct device *dev; + int max_state; + int cur_state; + bool runtime_resumed; +}; + +static const struct of_device_id pd_wdev_match_table[] = { + { .compatible = "thermal-power-domain-wdev", .data = NULL }, + { } +}; +MODULE_DEVICE_TABLE(of, pd_wdev_match_table); + +static int pd_wdev_get_max_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + + *state = pd_wdev->max_state; + return 0; +} + +static int pd_wdev_get_cur_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + + *state = dev_pm_genpd_get_performance_state(pd_wdev->dev); + + return 0; +} + +static int pd_wdev_set_cur_state(struct thermal_cooling_device *cdev, + unsigned long state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + struct device *dev = pd_wdev->dev; + int ret; + + ret = dev_pm_genpd_set_performance_state(dev, state); + + if (ret) + return ret; + + if (state && !pd_wdev->runtime_resumed) { + ret = pm_runtime_get_sync(dev); + pd_wdev->runtime_resumed = true; + } else if (!state && pd_wdev->runtime_resumed) { + ret = pm_runtime_put(dev); + pd_wdev->runtime_resumed = false; + } + + return ret; +} + +static struct thermal_cooling_device_ops pd_warming_device_ops = { + .get_max_state = pd_wdev_get_max_state, + .get_cur_state = pd_wdev_get_cur_state, + .set_cur_state = pd_wdev_set_cur_state, +}; + +static int pd_wdev_create(struct device *dev, const char *name) +{ + struct pd_warming_device *pd_wdev; + int state_count; + + pd_wdev = devm_kzalloc(dev, sizeof(*pd_wdev), GFP_KERNEL); + if (!pd_wdev) + return -ENOMEM; + + state_count = dev_pm_genpd_performance_state_count(dev); + if (state_count < 0) + return state_count; + + pd_wdev->dev = dev; + pd_wdev->max_state = state_count - 1; + pd_wdev->runtime_resumed = false; + + pm_runtime_enable(dev); + + pd_wdev->cdev = thermal_of_cooling_device_register + (dev->of_node, name, + pd_wdev, + &pd_warming_device_ops); + if (IS_ERR(pd_wdev->cdev)) { + dev_err(dev, "unable to register %s cooling device\n", name); + pm_runtime_disable(dev); + + return PTR_ERR(pd_wdev->cdev); + } + + return 0; +} + +static int pd_wdev_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev, *pd_dev; + const char *pd_name; + int id, count, ret = 0; + + count = of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells"); + + if (count > 1) { + for (id = 0; id < count; id++) { + ret = of_property_read_string_index + (dev->of_node, "power-domain-names", + id, &pd_name); + if (ret) { + dev_err(dev, "Error reading the power domain name %d\n", ret); + continue; + } + + pd_dev = dev_pm_domain_attach_by_id(dev, id); + if (IS_ERR(pd_dev)) { + dev_err(dev, "Error attaching power domain %s %ld\n", pd_name, PTR_ERR(pd_dev)); + continue; + } + + ret = pd_wdev_create(pd_dev, pd_name); + if (ret) { + dev_err(dev, "Error building cooling device %s %d\n", pd_name, ret); + dev_pm_domain_detach(pd_dev, false); + continue; + } + } + } else if (count == 1) { + ret = of_property_read_string_index(dev->of_node, + "power-domain-names", + 0, &pd_name); + if (ret) { + dev_err(dev, "Error reading the power domain name %d\n", ret); + goto exit; + } + + ret = pd_wdev_create(dev, pd_name); + if (ret) { + dev_err(dev, "Error building cooling device %s %d\n", pd_name, ret); + goto exit; + } + } else { + ret = -EINVAL; + } + +exit: + return ret; +} + +static struct platform_driver pd_wdev_driver = { + .driver = { + .name = "qcom-rpmhpd-cdev", + .of_match_table = pd_wdev_match_table, + }, + .probe = pd_wdev_probe, +}; +module_platform_driver(pd_wdev_driver); + +MODULE_DESCRIPTION("Qualcomm RPMHPD cooling device driver"); +MODULE_LICENSE("GPL v2"); From patchwork Tue Sep 10 17:14:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11139939 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A4C6924 for ; Tue, 10 Sep 2019 17:14:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48DB42168B for ; Tue, 10 Sep 2019 17:14:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="m/FgOeOk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437021AbfIJROv (ORCPT ); Tue, 10 Sep 2019 13:14:51 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:34163 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437034AbfIJROp (ORCPT ); Tue, 10 Sep 2019 13:14:45 -0400 Received: by mail-qk1-f193.google.com with SMTP id q203so17833220qke.1 for ; Tue, 10 Sep 2019 10:14:45 -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=AU+QsjQ4gYWceRGENzlR0Louo13bejD+8gOVOvF6PUY=; b=m/FgOeOkaOKNggzNTPEtFXREeobHykEFFFvTpQDO0RpQvNSHhp2AtqgVHN+UjyG80W WWG3b1uQfUUzTJ0Qo0bdgjfsRy05PbvlFclgN1DETTKoJ7t0Wb5bOc7w1Fpe/jxitCOY p49Ll9S6JRw2bxMrZ9pnvQuhK8+28N+ndBI64dUvqY0TO34orTLL+Rh9f+jACW4cQ2pN SZrMhm6B3WoK9PQjDXnZ9/yDV3xkCZb83uJsXllPYdERjtYsYUDvl3Oh1VG8p8TtRgbv Jire4fF4GaSvB0FgRhk+IkaXFKDd82DB8Q9WOysgl/zMV8MGI+jeCrGm5beLdXCgtnl/ t4rw== 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=AU+QsjQ4gYWceRGENzlR0Louo13bejD+8gOVOvF6PUY=; b=WbgEkK9gqUtwTojbkSRqZplFU3ZCrXehaiPqQ/BK36/Ld1r4dxMP7i6AMgw1ph9TsY 5K+r8bGy4rW12Bcmm8JJ4P1hvMV4zf+8EKdKzeCloL0i8XoTpNVQCB06Q/DLH0MTstgU 4bs9YQKRtBTK9tfE4SEPBMPugTQbQcXrEGGzWNLWnaAuVrWTRRslEmGq2MMlzhV1TrbM ceBi67OX4FJWFKB61+5b0FTzB/cjJXXyO5xsWeUEu61geYdWPl9bDh16B5wZHTo9NVjy 7d5mtUhXtADD9PLmAbDhkINbUSdpx6bmOFE7Oeo9skS5DDzpGkxuJwWhe98FtRQ62xVx fwYA== X-Gm-Message-State: APjAAAUtHGvJjyZ46nISwJXinxxOGy0oPqCXjEE7GH4DqQ3JHIgO/qzI No2IomR9ZaKRfZZffmCBt/5HDA== X-Google-Smtp-Source: APXvYqw+xpOzKxIVVLJuA0LAVrvCMbzacPqVJ0yzoUiedeQ7QczZNA+XJZNiz9ALbYhsjyobVyeQXw== X-Received: by 2002:a37:660c:: with SMTP id a12mr30467195qkc.70.1568135684689; Tue, 10 Sep 2019 10:14:44 -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 g45sm3400713qtc.9.2019.09.10.10.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Sep 2019 10:14:44 -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, robh+dt@kernel.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 5/5] arm64: dts: qcom: Add node for RPMH power domain warming device on sdm845. Date: Tue, 10 Sep 2019 13:14:36 -0400 Message-Id: <1568135676-9328-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568135676-9328-1-git-send-email-thara.gopinath@linaro.org> References: <1568135676-9328-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 RPMh hosts power domains that can be used to warm up the SoC. Add nodes for these domains on sdm845 (mx power domain). Signed-off-by: Thara Gopinath --- v1->v2: - Change the dt-entries to reflect the newly introduced generic power domain warming device. arch/arm64/boot/dts/qcom/sdm845.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index f406a43..0a83263 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -3284,6 +3284,13 @@ }; }; + thermal_wdev: rpmhpd_mx_wdev { + compatible = "thermal-power-domain-wdev"; + #cooling-cells = <2>; + power-domains = <&rpmhpd SDM845_MX>; + power-domain-names = "mx"; + }; + thermal-zones { cpu0-thermal { polling-delay-passive = <250>;