From patchwork Thu Jun 4 01:53:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 211908 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50485C433E0 for ; Thu, 4 Jun 2020 01:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AAF020738 for ; Thu, 4 Jun 2020 01:53:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TTHUNmNT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbgFDBxX (ORCPT ); Wed, 3 Jun 2020 21:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728000AbgFDBxW (ORCPT ); Wed, 3 Jun 2020 21:53:22 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33FBFC08C5C1 for ; Wed, 3 Jun 2020 18:53:22 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id f18so4524087qkh.1 for ; Wed, 03 Jun 2020 18:53:22 -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 :mime-version:content-transfer-encoding; bh=OXFBxnWXYnn/70SvWtr9K2MHoufkLsFwRRiIi6zZBfk=; b=TTHUNmNTBK6ssrGE4vNIHuoGl36/IKA184BiSEt8dXIB0bXbrx0XulkgtaLviqMvuW tiIHAKyJPYZreacCzAGf8kljq9QG3N1PG/bNUFHp6FKanpARhYnd1lj2lOa6FWJptBym L3dMIgXoBnK89BgeVPpe8GHacwrkCx5LaXP0Aq0Xj0HBxajAOPuALcf5U/FjaB+Z1voT vf9KlCpD5m6T105XsMMrDnc2eE2+NRpCmzy6IkeydAUxAPeb6uqYMzZgBWZcU5IkBZgX EYrGk3+RyAqITb8mgfYGzzvQrK11Ct5wGRbMIFnMdg3+5dZJ1/4HOLZ606IzJqO/iePB GkYg== 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=OXFBxnWXYnn/70SvWtr9K2MHoufkLsFwRRiIi6zZBfk=; b=J84jEtQBt6fAC1zfASxNA/ETrYnOG/lRzZUhtFPjpPV06obFR9YURW2ua0roPfkSt9 eeLBMnzxorKlBP/ZJGcL08olfLcvsyErkeWsuZzfQUPuTSDoIXq8Q9ghQZ3P0K/rcgIA Gm/hjz+x6uoCUyy3weTCeGPin6XIf28oiiFxlxJG92aXQp2F2+WudMIIyZx2VYEypbTz ROhtu4GfqAxKaAui2pF3X64+07a6kvttlDYn+KpWFFNgiSevwDrD0H+duOs1doNZodIw 45qvANFIq15TQllx1TfidcOjyrYhy7qD8oxk+X1/yG/P3qWd+pjNyu+w5sfTOa3vjdn7 35Sw== X-Gm-Message-State: AOAM5323K9y54M2rhWTQ55kdQIgWpc3ck/PfNt0stZAmL+e8ecIdyWrL eSsvDxMRLy+3NmtARL5+f+s0Ow== X-Google-Smtp-Source: ABdhPJxtYPvU4sjsI6bm1cB56yIjkZm4HSRbup9Y6NQzxcUlyQ8iJvQmJ9f/YKDFoggQ1o/Vl5DgyA== X-Received: by 2002:a05:620a:15a5:: with SMTP id f5mr2710795qkk.9.1591235601365; Wed, 03 Jun 2020 18:53:21 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id t74sm2986439qka.21.2020.06.03.18.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 18:53:19 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org, robh@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 v6 1/6] PM/Domains: Add support for retrieving genpd performance states information Date: Wed, 3 Jun 2020 21:53:12 -0400 Message-Id: <20200604015317.31389-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200604015317.31389-1-thara.gopinath@linaro.org> References: <20200604015317.31389-1-thara.gopinath@linaro.org> MIME-Version: 1.0 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 Reviewed-by: Ulf Hansson Reviewed-by: Bjorn Andersson --- 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 0a01df608849..88f8773cabe7 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 9ec78ee53652..7d415350380f 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 Thu Jun 4 01:53:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 211906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8531DC433E2 for ; Thu, 4 Jun 2020 01:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CC4220772 for ; Thu, 4 Jun 2020 01:53:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wWp6CJTq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgFDBxq (ORCPT ); Wed, 3 Jun 2020 21:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbgFDBxZ (ORCPT ); Wed, 3 Jun 2020 21:53:25 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929DBC08C5C2 for ; Wed, 3 Jun 2020 18:53:24 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id u17so3980496qtq.1 for ; Wed, 03 Jun 2020 18:53:24 -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 :mime-version:content-transfer-encoding; bh=6zVKcLTPmnGwe40Y367QYIcZACR6WrRrYV644jQUiEs=; b=wWp6CJTqDOyoFiDlZn1RLWo8Hmy/EWuTSribqdOwk5CHkQFGicLYbtiYIQm7t8I4le NOl2bkCeWBwACjo4HVqTt84VS6fc7Wc2rEeC6ecL3qnnWqwgXOqt2tdnjMRnKIMcT/vw eWAtV/7ViPZqHAiQEOWlrLnX2STnNR8nElsEHk46SfWRfwkb/2rxFkvb1nfdWi6IFBoO q3ydaxZqnD6beBnYQPDoWREQLRaVTVWO9fOmu1T+w/g32pI50Hgh3FarYsrGxrJ5cwZJ NgIi3WCFwXD9nZl85/64TMJMnJ4PqHj53uYKV/C5v5oVnidr/s6KWZv9vHKMDQaGl/Bq Azbg== 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=6zVKcLTPmnGwe40Y367QYIcZACR6WrRrYV644jQUiEs=; b=ANQXRdfQ7Kq/SE1OLkOJtPioit5S1uDBEWg0ik6/2ViwAiMI+/v8MNm8jpRylfqxAo 4vUGvgFpxy9XzpUNLwYdPGnAZZv27Dbks0gJTouuKkEEpCAIKQEdTNbgvfkb9Kx7APyb 9iJiWcRk3rXvbIzR9MF3UkytvL86btT+u6e/VwXPvqm6jfR+CoF+XtPCI/yq/G1Kt1pM B4evvEhsSvtJ4C7K93p+jxmkA3S5mDDFsey8yWOhJWJqXl9kn3N4HkKRpr5hQp9kzPTk 2Ot/ACE/320RIClFeY/3DjZLQAkEv3U6SYvSKrKC1BwHWQH6k38y6l/4XeLkql60kmDV 55jg== X-Gm-Message-State: AOAM532lZcvT4DPAzvetByGg5dMsNle7nBQ3NrSOEWbbrscrfYB7s+Zh 8LSJ6QlBYwZ1kDOevqimC+EM9g== X-Google-Smtp-Source: ABdhPJx3QMOwNKw/vg6Qo4Do37BesTxVwG1EFm8RXWKL64cET36kH8f3if6rvKhrSBWCgRScsulADw== X-Received: by 2002:ac8:42c3:: with SMTP id g3mr2208401qtm.313.1591235603690; Wed, 03 Jun 2020 18:53:23 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id t74sm2986439qka.21.2020.06.03.18.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 18:53:23 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org, robh@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 v6 3/6] thermal: Add generic power domain warming device driver. Date: Wed, 3 Jun 2020 21:53:14 -0400 Message-Id: <20200604015317.31389-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200604015317.31389-1-thara.gopinath@linaro.org> References: <20200604015317.31389-1-thara.gopinath@linaro.org> MIME-Version: 1.0 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 kernel 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 --- v3->v4: - Removed late_init hook pd_warming_device_ops. - Use of_genpd_add_device instead of pm_genpd_add_device to attach device to the generic power domain. - Use thermal_of_cooling_device_parent_register to register the cooling device so that the device with genpd attached can be made parent of the cooling device. - With above changes, remove reference to generic_pm_domain in pd_warming_device. v4->v5: - All the below changes are as per Ulf's review comments. - Renamed pwr_domain_warming.c and pwr_domain_warming.h to pd_warming.c and pd_warming.h. - Renamed pwr_domain_warming_register API to of_pd_warming_register. - Dropped in-param pd_name to of_pd_warming_register. - Introduced ID allocator to uniquely identify each power domain warming device. - Introduced pd_warming_release to handle device kfree for pd_warming_device. - Introduced pm_genpd_remove_device in the error exit path of of_pd_warming_register. v5->v6: - Fixed issues with ->release() and kfree(dev) as pointed out by Ulf. drivers/thermal/Kconfig | 10 +++ drivers/thermal/Makefile | 4 + drivers/thermal/pd_warming.c | 169 +++++++++++++++++++++++++++++++++++ include/linux/pd_warming.h | 29 ++++++ 4 files changed, 212 insertions(+) create mode 100644 drivers/thermal/pd_warming.c create mode 100644 include/linux/pd_warming.h diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index e53314ea9e25..3a0bcf3e8bd9 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -206,6 +206,16 @@ 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_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 86c506410cc0..14fa696a08bd 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -28,7 +28,11 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o # devfreq cooling thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o +#pwr domain warming +thermal_sys-$(CONFIG_PWR_DOMAIN_WARMING_THERMAL) += pd_warming.o + obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o + # platform thermal drivers obj-y += broadcom/ obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o diff --git a/drivers/thermal/pd_warming.c b/drivers/thermal/pd_warming.c new file mode 100644 index 000000000000..1ea93481c79b --- /dev/null +++ b/drivers/thermal/pd_warming.c @@ -0,0 +1,169 @@ +// 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 id; + int max_state; + int cur_state; + bool runtime_resumed; +}; + +static DEFINE_IDA(pd_ida); + +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 void pd_warming_release(struct device *dev) +{ + struct pd_warming_device *pd_wdev; + + pd_wdev = container_of(dev, struct pd_warming_device, dev); + kfree(pd_wdev); +} + +struct thermal_cooling_device * +of_pd_warming_register(struct device *parent, int pd_id) +{ + struct pd_warming_device *pd_wdev; + struct of_phandle_args pd_args; + char cdev_name[THERMAL_NAME_LENGTH]; + int ret; + + pd_wdev = kzalloc(sizeof(*pd_wdev), GFP_KERNEL); + if (!pd_wdev) + return ERR_PTR(-ENOMEM); + + dev_set_name(&pd_wdev->dev, "%s_%d_warming_dev", + dev_name(parent), pd_id); + pd_wdev->dev.parent = parent; + pd_wdev->dev.release = pd_warming_release; + + ret = device_register(&pd_wdev->dev); + if (ret) { + put_device(&pd_wdev->dev); + goto out; + } + + ret = ida_simple_get(&pd_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto unregister_device; + + pd_wdev->id = ret; + + pd_args.np = parent->of_node; + pd_args.args[0] = pd_id; + pd_args.args_count = 1; + + ret = of_genpd_add_device(&pd_args, &pd_wdev->dev); + + if (ret) + goto remove_ida; + + ret = dev_pm_genpd_performance_state_count(&pd_wdev->dev); + if (ret < 0) + goto out_genpd; + + pd_wdev->max_state = ret - 1; + pm_runtime_enable(&pd_wdev->dev); + pd_wdev->runtime_resumed = false; + + snprintf(cdev_name, sizeof(cdev_name), "thermal-pd-%d", pd_wdev->id); + pd_wdev->cdev = thermal_of_cooling_device_register + (NULL, cdev_name, pd_wdev, + &pd_warming_device_ops); + if (IS_ERR(pd_wdev->cdev)) { + pr_err("unable to register %s cooling device\n", cdev_name); + ret = PTR_ERR(pd_wdev->cdev); + goto out_runtime_disable; + } + + return pd_wdev->cdev; + +out_runtime_disable: + pm_runtime_disable(&pd_wdev->dev); +out_genpd: + pm_genpd_remove_device(&pd_wdev->dev); +remove_ida: + ida_simple_remove(&pd_ida, pd_wdev->id); +unregister_device: + device_unregister(&pd_wdev->dev); +out: + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(of_pd_warming_register); + +void pd_warming_unregister(struct thermal_cooling_device *cdev) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + struct device *dev = &pd_wdev->dev; + + if (pd_wdev->runtime_resumed) { + dev_pm_genpd_set_performance_state(dev, 0); + pm_runtime_put(dev); + pd_wdev->runtime_resumed = false; + } + pm_runtime_disable(dev); + pm_genpd_remove_device(dev); + ida_simple_remove(&pd_ida, pd_wdev->id); + thermal_cooling_device_unregister(cdev); + device_unregister(dev); +} +EXPORT_SYMBOL_GPL(pd_warming_unregister); diff --git a/include/linux/pd_warming.h b/include/linux/pd_warming.h new file mode 100644 index 000000000000..550a5683b56d --- /dev/null +++ b/include/linux/pd_warming.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd. + */ +#ifndef __PWR_DOMAIN_WARMING_H__ +#define __PWR_DOMAIN_WARMING_H__ + +#include +#include + +#ifdef CONFIG_PWR_DOMAIN_WARMING_THERMAL +struct thermal_cooling_device * +of_pd_warming_register(struct device *parent, int pd_id); + +void pd_warming_unregister(struct thermal_cooling_device *cdev); + +#else +static inline struct thermal_cooling_device * +of_pd_warming_register(struct device *parent, int pd_id) +{ + return ERR_PTR(-ENOSYS); +} + +static inline void +pd_warming_unregister(struct thermal_cooling_device *cdev) +{ +} +#endif /* CONFIG_PWR_DOMAIN_WARMING_THERMAL */ +#endif /* __PWR_DOMAIN_WARMING_H__ */ From patchwork Thu Jun 4 01:53:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 211907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 108FBC433E2 for ; Thu, 4 Jun 2020 01:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD9A120738 for ; Thu, 4 Jun 2020 01:53:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PSKnA+A3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728051AbgFDBxc (ORCPT ); Wed, 3 Jun 2020 21:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgFDBx3 (ORCPT ); Wed, 3 Jun 2020 21:53:29 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13E7C08C5C6 for ; Wed, 3 Jun 2020 18:53:28 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id j32so3932671qte.10 for ; Wed, 03 Jun 2020 18:53:28 -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 :mime-version:content-transfer-encoding; bh=cx1RfItm8P+5zdZthMwhmTFP4jusIpmaSOa4M7MTCuw=; b=PSKnA+A32FTYGNyVZ3JCedIaquwwdMV72TXnPo6jQ5OtwjCTbqy4v+cayuXvcEV+h3 zdwZeJ8nrs6vtj5J4AFvYymjLdeGkrP7+DzUYcHY3H5dq429Gd+ioqTgp2GB256edagr sin0Mxjm1Ra82p1Ny8wMEEm/SuvoitD95Xr3cZVdoYK+AVezR0e+1Prav2RMCe6iU/4N j1wM0QWac4RMmJtIRdAVp7wUCmO68mfJzJrebTnWL+k6lvZzFmAdxWU+7SulimOiLd9C Jh18p/7qP8dlgFw5GljRiy5MWLAyuGZylM0Pb46DCNgWAaP4u1VrXQ8eo0cUk++O30yp R+hA== 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=cx1RfItm8P+5zdZthMwhmTFP4jusIpmaSOa4M7MTCuw=; b=VnlIzls8DBWSuF6uh5TTtWRND6XEYyDG7RFOxwZktJfpsnlOZnlacBnfTJQzE1Yd8s kCejAfDcrwECfKB3CcIz0aUWXJetBiDHSV5em3LrpjWwo4t4zUOAbaK55xThR/fv8+Jm JBgm8/yhqcv4iWTZ6nyJbwJdnf7i4hsWjmvFxsI7peRGCddppnU2DxyZTXebFZZdPcwc /tj0Qi5fOXdm3MsJ6qSG3y+rvmXfU9LyBbBWMKsHPhoRzgh7Ndg3T7QDW91o/V6TV4Rc xms1FnOVokG882wDGH8TfKQWcf/IW5VpoaLYohDAG39VPwujoH0RttVIPT1Aynqi423e amQA== X-Gm-Message-State: AOAM531kP/hJmouEc+zEJ9vOmnI9dXyPKK/RcbONETT2DmZFySNLTKOP F1Zgx/lmWTRBGFD2Z1aP1RjjLA== X-Google-Smtp-Source: ABdhPJzFuQ11RGaUFX9ez2ZUYVbvhFKr+5CSf9niClZmUapncKEZa/DruY85eifIRSadG1SF4IIQrg== X-Received: by 2002:ac8:450a:: with SMTP id q10mr2274459qtn.328.1591235608210; Wed, 03 Jun 2020 18:53:28 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id t74sm2986439qka.21.2020.06.03.18.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 18:53:27 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org, robh@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 v6 6/6] arm64: dts: qcom: Indicate rpmhpd hosts a power domain that can be used as a warming device. Date: Wed, 3 Jun 2020 21:53:17 -0400 Message-Id: <20200604015317.31389-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200604015317.31389-1-thara.gopinath@linaro.org> References: <20200604015317.31389-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org RPMh hosts mx power domain that can be used to warm up the SoC. Indicate this by using #cooling-cells property. Signed-off-by: Thara Gopinath Reviewed-by: Ulf Hansson Reviewed-by: Bjorn Andersson --- v3->v4: - Removed subnode to indicate that mx power domain is a warming device. Instead #cooling-cells is used as a power domain provider property to indicate if the provider hosts a power domain that can be used as a warming device. arch/arm64/boot/dts/qcom/sdm845.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index 8eb5a31346d2..dcc3bcd16b68 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -3854,6 +3854,7 @@ rpmhpd: power-controller { compatible = "qcom,sdm845-rpmhpd"; #power-domain-cells = <1>; + #cooling-cells = <2>; operating-points-v2 = <&rpmhpd_opp_table>; rpmhpd_opp_table: opp-table {