From patchwork Thu Dec 19 22:21:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11304493 X-Patchwork-Delegate: rui.zhang@intel.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 1CA14109A for ; Thu, 19 Dec 2019 22:22:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECAF72465E for ; Thu, 19 Dec 2019 22:22:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OBYavYa3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbfLSWWJ (ORCPT ); Thu, 19 Dec 2019 17:22:09 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51086 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbfLSWWJ (ORCPT ); Thu, 19 Dec 2019 17:22:09 -0500 Received: by mail-wm1-f67.google.com with SMTP id a5so7019768wmb.0 for ; Thu, 19 Dec 2019 14:22:07 -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; bh=+EdJlshrU/x9lwXaiDsMcX871Y/B3IPP2mzwerHvxc0=; b=OBYavYa3Os4P3wLJqYc7ViOZC9UtFFSArzXrXdPXO3u/P6Fp+c/tZWkJ+54mrV5+Ql PPVp8YdxWqA59qeUMnStPysx3l+AICJR1TLM3NIVcUzMV+FaC6ciUwqpvmNt6AfUCwxW aqGQKQiwTUKWxaSGkfsLgiFxZfgmx5LMAd+Lz9dha6Z8sHPIQ5P8wg6ByWQid7SW+lWd romJPspM/EhgfAVanxijAsqNdPmyOlb15lVhMRxRIVi84XVf52/y7lS7RHyxN+Il3xsh 9c3EqCphIVONRXpK69tJ316L7xSYrE2gXEMpR3WCKHlHVu6sWl0oQzvjwRH7mq1atxw0 rJ5w== 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; bh=+EdJlshrU/x9lwXaiDsMcX871Y/B3IPP2mzwerHvxc0=; b=GcqKlql08OnsYRGBdbPi5MEu/GjpvcZ1F4VB1KKfi4EkwhtDicru/0IAxqympmm14S HTyzg7rh12UzbhgGvORO7gwGRcxOGlzRKUs1gQGouW6m7+YWidLCuNAWy4MxOIPKtRbD JAW7DFBpVM/XfrxwFTiei8nn4q7xvX6rULjUuqX/0S/XVCCP4+151hGY0HCo7kfSmyU/ Bg/3TVsuKInCGDUUVNMagT0APerSxd1m6NrWVLP2D9FqGqTGkCCuGpgiu3pIUKVM4l2g NGJsX4pcsw13F+0G7gXFX80PK0sazM6HGYdrmXNr5HWcCbPW+mySiohHM5X2PO/92ZXz QSXQ== X-Gm-Message-State: APjAAAWDa86Rz4vMjQmXyIpLgufqkLXtDkfplUtNfaEu8jbFgotalLa0 SD8Paw9ruzFVoaJsPoUVcpksSg== X-Google-Smtp-Source: APXvYqxIwrQqO/WUQCmlhV0J4pjiUCYJdYEful8OM0YCNQMEt1xhhWrR6SBU+q4pjINCvhcrEuKT2w== X-Received: by 2002:a7b:c19a:: with SMTP id y26mr12429961wmi.152.1576794126696; Thu, 19 Dec 2019 14:22:06 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:58d:4e9b:2833:86c3]) by smtp.gmail.com with ESMTPSA id q68sm8942295wme.14.2019.12.19.14.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 14:22:06 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: Zhang Rui , Eduardo Valentin , Amit Kucheria , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] thermal/drivers/of-thermal: Make of_thermal_destroy_zones static Date: Thu, 19 Dec 2019 23:21:52 +0100 Message-Id: <20191219222154.16100-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The function of_thermal_destroy_zones() is only used internally by the of_parse_thermal_zones() for rollbacking in case of error. Make it static and tag it as an __init function. Signed-off-by: Daniel Lezcano --- drivers/thermal/of-thermal.c | 64 +++++++++++++++++----------------- drivers/thermal/thermal_core.h | 2 -- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index dc5093be553e..4333cd5f1073 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -998,6 +998,38 @@ static inline void of_thermal_free_zone(struct __thermal_zone *tz) kfree(tz); } +/** + * of_thermal_destroy_zones - remove all zones parsed and allocated resources + * + * Finds all zones parsed and added to the thermal framework and remove them + * from the system, together with their resources. + * + */ +static __init void of_thermal_destroy_zones(void) +{ + struct device_node *np, *child; + + np = of_find_node_by_name(NULL, "thermal-zones"); + if (!np) { + pr_debug("unable to find thermal zones\n"); + return; + } + + for_each_available_child_of_node(np, child) { + struct thermal_zone_device *zone; + + zone = thermal_zone_get_zone_by_name(child->name); + if (IS_ERR(zone)) + continue; + + thermal_zone_device_unregister(zone); + kfree(zone->tzp); + kfree(zone->ops); + of_thermal_free_zone(zone->devdata); + } + of_node_put(np); +} + /** * of_parse_thermal_zones - parse device tree thermal data * @@ -1087,35 +1119,3 @@ int __init of_parse_thermal_zones(void) return -ENOMEM; } - -/** - * of_thermal_destroy_zones - remove all zones parsed and allocated resources - * - * Finds all zones parsed and added to the thermal framework and remove them - * from the system, together with their resources. - * - */ -void of_thermal_destroy_zones(void) -{ - struct device_node *np, *child; - - np = of_find_node_by_name(NULL, "thermal-zones"); - if (!np) { - pr_debug("unable to find thermal zones\n"); - return; - } - - for_each_available_child_of_node(np, child) { - struct thermal_zone_device *zone; - - zone = thermal_zone_get_zone_by_name(child->name); - if (IS_ERR(zone)) - continue; - - thermal_zone_device_unregister(zone); - kfree(zone->tzp); - kfree(zone->ops); - of_thermal_free_zone(zone->devdata); - } - of_node_put(np); -} diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 207b0cda70da..a9bf00e91d64 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -92,14 +92,12 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, /* device tree support */ #ifdef CONFIG_THERMAL_OF int of_parse_thermal_zones(void); -void of_thermal_destroy_zones(void); int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); const struct thermal_trip * of_thermal_get_trip_points(struct thermal_zone_device *); #else static inline int of_parse_thermal_zones(void) { return 0; } -static inline void of_thermal_destroy_zones(void) { } static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) { return 0; From patchwork Thu Dec 19 22:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11304457 X-Patchwork-Delegate: rui.zhang@intel.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 CC6E7109A for ; Thu, 19 Dec 2019 22:19:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EEE8227BF for ; Thu, 19 Dec 2019 22:19:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UELwUgkI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbfLSWTx (ORCPT ); Thu, 19 Dec 2019 17:19:53 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35728 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbfLSWTv (ORCPT ); Thu, 19 Dec 2019 17:19:51 -0500 Received: by mail-wr1-f68.google.com with SMTP id g17so7553167wro.2 for ; Thu, 19 Dec 2019 14:19:50 -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; bh=xIw0nWMVvmMwb4Q12xq9FnKNnehOct3euxpTG4ta6kw=; b=UELwUgkIqMLM8KbzghW/nxo2zlVq5P1wRHZQUzemcp1Mo4En6J69er+/z19UrnXzq7 4HWSjAk+mRtSYwkLpV0E70UgihbarSN4mbe41sDDk/fTL33TfqmA44/eiUmYo4Werjy2 Z1NmTMYj1xIYm1jjYDhBQ2bjLvrH42FibRjvlf7t5WV5ZxJYLRs3uDjkNtVKqyVsPozN r91Aht9GVlVNOPAPNvxZTCeLr0vtxmeHo9ROBM2yXck7D7JMjjyH6T9hfg2E2NDELFT+ HpB9sxM+GD5/Arv6Y63UTZ4J6zEZ1BXoI6+M79zEvpj7O0THPCzg4N97UOuxdqx4bSks jnOQ== 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=xIw0nWMVvmMwb4Q12xq9FnKNnehOct3euxpTG4ta6kw=; b=et/k5C4iUVZY/xODOI5kPpncc5M5CGTKEJVPYpoQSGV3bRp2QDtBt1b8R5FvQTACas duSR5CwoudJTMnXSdGRKDXdIwnHO2W4rDhTfcuxXDj/z42i8hVZ/Bd2/pKBN512Ww+lV OSgp9zFz/We3wGj2b/N8eKJEJzImSG+918XKo6apDBYZa7Ux5GUj7n4yxZdsA7KT17Sm SVewNNdy7i5b4f9O9hfowpWI5rgBLS986W72+uLb+ZswGwnlRtGQrhS9wxCzVXbzh737 Wc1WtoKA/L/CjlzCukNDFnz9o2tITMlemiQqybRZ4LlHaMtSsQ1+zpMJnQ9V6WNI+pef YpiA== X-Gm-Message-State: APjAAAWzOx6ZO2l9G90Vt1y0qIt+L1yvz9inAodSFU7lHCq5bcqIFqNq E6hyqXET8jrk+awUb39HSjl+ew== X-Google-Smtp-Source: APXvYqzilQIba81xsMAm/XzNo8yOiToCMG0j4CoenolEuzgNB9N7sIv8+//Szr3GBzVBI0YM7rAOzQ== X-Received: by 2002:adf:ef49:: with SMTP id c9mr11527564wrp.292.1576793989331; Thu, 19 Dec 2019 14:19:49 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:58d:4e9b:2833:86c3]) by smtp.gmail.com with ESMTPSA id n189sm8161765wme.33.2019.12.19.14.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 14:19:48 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: "Rafael J. Wysocki" , linux-pm@vger.kernel.org (open list:CPU IDLE TIME MANAGEMENT FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] thermal: cpuidle: Register cpuidle cooling device Date: Thu, 19 Dec 2019 23:19:28 +0100 Message-Id: <20191219221932.15930-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219221932.15930-1-daniel.lezcano@linaro.org> References: <20191219221932.15930-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpuidle driver can be used as a cooling device by injecting idle cycles. The DT binding for the idle state added an optional When the property is set, register the cpuidle driver with the idle state node pointer as a cooling device. The thermal framework will do the association automatically with the thermal zone via the cooling-device defined in the device tree cooling-maps section. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/dt_idle_states.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index d06d21a9525d..34bd65197342 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "DT idle-states: " fmt +#include #include #include #include @@ -205,6 +206,13 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, err = -EINVAL; break; } + + if (of_find_property(state_node, "#cooling-cells", NULL)) { + err = cpuidle_of_cooling_register(state_node, drv); + if (err) + break; + } + of_node_put(state_node); }