From patchwork Thu Sep 19 02:18:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11151509 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 56CDF1747 for ; Thu, 19 Sep 2019 02:18:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 349B12196E for ; Thu, 19 Sep 2019 02:18:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zY1e9tgp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388324AbfISCS3 (ORCPT ); Wed, 18 Sep 2019 22:18:29 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:39497 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388314AbfISCS2 (ORCPT ); Wed, 18 Sep 2019 22:18:28 -0400 Received: by mail-qt1-f195.google.com with SMTP id n7so2316583qtb.6 for ; Wed, 18 Sep 2019 19:18:26 -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=52eCI/kas6xom7Dj3zgl21pE1+QiZowqYoPJUf9JBJw=; b=zY1e9tgp+KNn071A68ETzMJY2odHuTdOA6ZRY0Ba7Aa1GwQyxNrmTVjDWaBOA6RLue jpycjbNaTJwhHUVaD+D6jtC3jfXmyUexkaOLbAhHgmFokCsrw7EvyjkCmgxuTiOHOT4M MTSAoo+SUBvRorrz38ttRD3IXGVN8aA8akljob5MXV85aOD9G5DtAzaTF8JefNLS53FI S1hK7TpzdWUmUVrsOZAnowftnyeS5PCfjj5zmz9eWhdLblHJUMpCewpg6dCcc8d7YzQ1 f0C63F2Iyl4zn+DNR5ctqT8/ce+U7NmIGqXK0wibhZGU6ImrwjU+XGf0r3HzNopx5gGF X3Lg== 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=52eCI/kas6xom7Dj3zgl21pE1+QiZowqYoPJUf9JBJw=; b=s/8fKiUP7E7yjHmaaWIS1Z1C2sSxWKQowp5PlAmFZLz2rwHBjjNrubfMua2inYnx9f +LsAY+JtZWRT8/qDhyxUWy0tjs8LcpgxVzvZNESCXw7TILoli2E2AvDrsoMgpymodYED 3mJ3pbVsNjoQqzBZg5nBFe7Kh8lDCbZnSQqQQ7NVhNgt/ibFNCBxtXSuLW1avT0+RqtK 9WmtKDMRQWMeZ7AzFdVgFbMMb6lyT6QAAlPmewBIrydaaCn8+0Rq05EyL0B4kcNwRtpn TXGzQVG9AuGI2r5qEG5fv1ItFVO3aaQccgP/BmdVMARzk66nZ3xpnJW61xkk0rABS+o/ 51eQ== X-Gm-Message-State: APjAAAVi4XrZC4vinuf3drbnbMXZqtHdlgxRwDeIpVGGEUH/FkS/B7yy HbyC0VJNy86ptyOAkarfN5tx5Q== X-Google-Smtp-Source: APXvYqymGq1NficwmHv7+EyBMSvUuu+o4iNyhE+oM8mRWDG9Bux64SzcaxFHRJP5uOH34KqZNNp7mg== X-Received: by 2002:a0c:91ce:: with SMTP id r14mr880353qvr.119.1568859505943; Wed, 18 Sep 2019 19:18:25 -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 o52sm5261275qtf.56.2019.09.18.19.18.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Sep 2019 19:18:25 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] dt-bindings: thermal: Introduce monitor-falling parameter to thermal trip point binding Date: Wed, 18 Sep 2019 22:18:20 -0400 Message-Id: <1568859503-19725-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568859503-19725-1-git-send-email-thara.gopinath@linaro.org> References: <1568859503-19725-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 Introduce a new binding parameter to thermal trip point description to indicate whether the temperature level specified by the trip point is monitored for a rise or fall in temperature. Signed-off-by: Thara Gopinath --- Documentation/devicetree/bindings/thermal/thermal.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt index ca14ba9..849a2a9 100644 --- a/Documentation/devicetree/bindings/thermal/thermal.txt +++ b/Documentation/devicetree/bindings/thermal/thermal.txt @@ -90,6 +90,14 @@ Required properties: "critical": Hardware not reliable. Type: string +Optional property: +- monitor-falling: Indicate whether the system action is kick + Type: boolean started when the temperature falls below or rises + above the trip temperature level indicated in + "temperature".If true, the trip point is monitored + for falling temperature else the trip point is + monitored for rising temperature. + * Cooling device maps The cooling device maps node is a node to describe how cooling devices From patchwork Thu Sep 19 02:18:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11151513 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 1393B1745 for ; Thu, 19 Sep 2019 02:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA468217D6 for ; Thu, 19 Sep 2019 02:18:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eoagL2Ho" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388330AbfISCSb (ORCPT ); Wed, 18 Sep 2019 22:18:31 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:34732 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388316AbfISCS3 (ORCPT ); Wed, 18 Sep 2019 22:18:29 -0400 Received: by mail-qt1-f195.google.com with SMTP id j1so2355274qth.1 for ; Wed, 18 Sep 2019 19:18:27 -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=hnMqV/Yia1YygR1EYdN6c9UtAx32hcNfOwxm8eVaTYM=; b=eoagL2Ho32riRPQK1weZiYpbIytlCjkW+ru7mE2enP6E/1J6MXI8dYLN9ZbL0TSvgL ElEo8/fVUCczO5OnPUJQuhmN6UyL9gSi0RVvLnoKMKzmgH6ezTiYhfLfYhDAtJXMClsd sHwL6T6041fq6ZUVgx4mrecGEtKRzMYCvquYUd+LTZDMjKQx/VcmZiS2eESxodx/m+2F GDtNYjhS70G2aHSmcMNL5FrX3lYahyzmjVfLEq51P4OKo/2AQjJGyUfOwz8WWWEl51mj i0ASOSu1d6zJFC1sJ/a37mSX/HDShmjbTtLSm+6riV6sC6Njepz9E13sxGUmB2ho2nBU 1Pog== 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=hnMqV/Yia1YygR1EYdN6c9UtAx32hcNfOwxm8eVaTYM=; b=pTHDUgEQ+KljQwuLWnhCO1ZQcVS7o1Ehx1maHDjoZhLgROOlIimOjapws+x+M/ioJl juEe6p5eMcSYEehCGWV53phzJUf0X/ST7kDWr2hVIaaVP+ghcV7UKHiTXAIaUwwbhAe9 7Ys5D+PDm1An202UHMOji8pWaHjdhDZ7VvbXb4TW6DKw0O8Ept0NDb596GWw9y0+6Hmo ft4m0VpQRdjixJNplS7JxyByAqpMG18+0Ib1jxk97gg5q9t/wfeAesOcpwoyrJy1vF+3 VhnSfhgR/jBw4Lf+Ni7jeajwukpchZX3HJIwGDdtwBl4GGEKc+ZjbNxik9scZiEV5y4j VYkQ== X-Gm-Message-State: APjAAAUEMaMPuUd6NJFvpN1H8W7jaLFQJyhfiHCLtOAIF22wC/lkM4Gy RSl7q928kbXfUP5FYeIqXGp+kQ== X-Google-Smtp-Source: APXvYqwWxJa+e/9Dkm6Gl54NQOL0ymsuCyUJ7oQlERhzz5TBJeXUk2TqkkUc00V/G4aieFshjeb2eQ== X-Received: by 2002:aed:2726:: with SMTP id n35mr850709qtd.171.1568859507091; Wed, 18 Sep 2019 19:18:27 -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 o52sm5261275qtf.56.2019.09.18.19.18.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Sep 2019 19:18:26 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] thermal: Thermal core and sysfs changes needed to support bi-directional monitoring of trip points. Date: Wed, 18 Sep 2019 22:18:21 -0400 Message-Id: <1568859503-19725-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568859503-19725-1-git-send-email-thara.gopinath@linaro.org> References: <1568859503-19725-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 Thermal trip points can be defined to indicate whether a temperature rise or a temperature fall is to be monitored. This property can now be defined in the DT bindings for a trip point. To support this following three changes are introduced to thermal core and sysfs code. 1. Define a new variable in thermal_trip to capture the monitor rising/falling information from trip point DT bindings. 2. Define a new ops in thermal_zone_device_ops that can be populated to indicate whether a trip is being monitored for rising or falling temperature. If the ops is not populated or if the binding is missing in the DT, it is assumed that the trip is being monitored for rising temperature. (default behavior today) 3. Introduce sysfs entries for each trip point to read the direction of monitoring. Signed-off-by: Thara Gopinath --- drivers/thermal/thermal_sysfs.c | 60 ++++++++++++++++++++++++++++++++++++++--- include/linux/thermal.h | 10 +++++++ include/uapi/linux/thermal.h | 2 +- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index aa99edb..b4ef6be 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -216,6 +216,31 @@ trip_point_hyst_show(struct device *dev, struct device_attribute *attr, } static ssize_t +trip_point_monitor_type_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + enum thermal_trip_monitor_type type; + int trip, result; + + if (sscanf(attr->attr.name, "trip_point_%d_monitor_type", &trip) != 1) + return -EINVAL; + + if (!tz->ops->get_trip_monitor_type) + goto exit; + + result = tz->ops->get_trip_monitor_type(tz, trip, &type); + if (result) + return result; + + if (type == THERMAL_TRIP_MONITOR_FALLING) + return sprintf(buf, "falling\n"); + +exit: + return sprintf(buf, "rising\n"); +} + +static ssize_t passive_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -520,10 +545,20 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) if (!tz->trip_type_attrs) return -ENOMEM; + tz->trip_monitor_type_attrs = kcalloc + (tz->trips, + sizeof(*tz->trip_monitor_type_attrs), + GFP_KERNEL); + if (!tz->trip_monitor_type_attrs) { + kfree(tz->trip_type_attrs); + return -ENOMEM; + } + tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), GFP_KERNEL); if (!tz->trip_temp_attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_monitor_type_attrs); return -ENOMEM; } @@ -533,14 +568,16 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) GFP_KERNEL); if (!tz->trip_hyst_attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_monitor_type_attrs); kfree(tz->trip_temp_attrs); return -ENOMEM; } } - attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs = kcalloc(tz->trips * 4 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_monitor_type_attrs); kfree(tz->trip_temp_attrs); if (tz->ops->get_trip_hyst) kfree(tz->trip_hyst_attrs); @@ -559,6 +596,20 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_type_attrs[indx].attr.show = trip_point_type_show; attrs[indx] = &tz->trip_type_attrs[indx].attr.attr; + /* create trip monitor type attribute */ + snprintf(tz->trip_monitor_type_attrs[indx].name, + THERMAL_NAME_LENGTH, "trip_point_%d_monitor_type", + indx); + + sysfs_attr_init(&tz->trip_monitor_type_attrs[indx].attr.attr); + tz->trip_monitor_type_attrs[indx].attr.attr.name = + tz->trip_monitor_type_attrs[indx].name; + tz->trip_monitor_type_attrs[indx].attr.attr.mode = S_IRUGO; + tz->trip_monitor_type_attrs[indx].attr.show = + trip_point_monitor_type_show; + attrs[indx + tz->trips] = + &tz->trip_monitor_type_attrs[indx].attr.attr; + /* create trip temp attribute */ snprintf(tz->trip_temp_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_temp", indx); @@ -574,7 +625,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_temp_attrs[indx].attr.store = trip_point_temp_store; } - attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; + attrs[indx + tz->trips * 2] = + &tz->trip_temp_attrs[indx].attr.attr; /* create Optional trip hyst attribute */ if (!tz->ops->get_trip_hyst) @@ -592,10 +644,10 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store; } - attrs[indx + tz->trips * 2] = + attrs[indx + tz->trips * 3] = &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] = NULL; + attrs[tz->trips * 4] = NULL; tz->trips_attribute_group.attrs = attrs; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e45659c..1435176b 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -70,6 +70,11 @@ enum thermal_trip_type { THERMAL_TRIP_CRITICAL, }; +enum thermal_trip_monitor_type { + THERMAL_TRIP_MONITOR_RISING = 0, + THERMAL_TRIP_MONITOR_FALLING +}; + enum thermal_trend { THERMAL_TREND_STABLE, /* temperature is stable */ THERMAL_TREND_RAISING, /* temperature is raising */ @@ -113,6 +118,8 @@ struct thermal_zone_device_ops { enum thermal_trend *); int (*notify) (struct thermal_zone_device *, int, enum thermal_trip_type); + int (*get_trip_monitor_type)(struct thermal_zone_device *, int, + enum thermal_trip_monitor_type *); }; struct thermal_cooling_device_ops { @@ -196,6 +203,7 @@ struct thermal_zone_device { struct thermal_attr *trip_temp_attrs; struct thermal_attr *trip_type_attrs; struct thermal_attr *trip_hyst_attrs; + struct thermal_attr *trip_monitor_type_attrs; void *devdata; int trips; unsigned long trips_disabled; /* bitmap for disabled trips */ @@ -364,6 +372,7 @@ struct thermal_zone_of_device_ops { * @temperature: temperature value in miliCelsius * @hysteresis: relative hysteresis in miliCelsius * @type: trip point type + * @monitor_type: trip point monitor type. */ struct thermal_trip { @@ -371,6 +380,7 @@ struct thermal_trip { int temperature; int hysteresis; enum thermal_trip_type type; + enum thermal_trip_monitor_type monitor_type; }; /* Function declarations */ diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h index 9621837..c01492c 100644 --- a/include/uapi/linux/thermal.h +++ b/include/uapi/linux/thermal.h @@ -2,7 +2,7 @@ #ifndef _UAPI_LINUX_THERMAL_H #define _UAPI_LINUX_THERMAL_H -#define THERMAL_NAME_LENGTH 20 +#define THERMAL_NAME_LENGTH 30 /* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event" From patchwork Thu Sep 19 02:18:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11151515 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 D20C516B1 for ; Thu, 19 Sep 2019 02:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B06DA21848 for ; Thu, 19 Sep 2019 02:18:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iAArHRRB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388328AbfISCSa (ORCPT ); Wed, 18 Sep 2019 22:18:30 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:45541 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388321AbfISCS3 (ORCPT ); Wed, 18 Sep 2019 22:18:29 -0400 Received: by mail-qt1-f196.google.com with SMTP id c21so2259018qtj.12 for ; Wed, 18 Sep 2019 19:18:29 -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=CdiCEHMKk566XZjegQIR8gg3RICYYDFYb1Lqktv3Klc=; b=iAArHRRBTsV5yhKp9vUFsoOfflBPOmyRZtdEhLbpeyK61kwCKweRNYjzy+Zy04Crif HiQRJ6OaVxKNDg2sZQYLsCbBqPvUnIzBGL55Z0Sl9m4djlYd5UziTnkdP4RIjwxIKsn3 Njc1vxS5Ih18BLZw6HVukX/o+mwgBsM3T7aStWKIPQprYDBmcrptPEuPEsO9RVWiLSpJ P4h1Kl2YSps2naPRH0TObYDVJLLFxfJWieojb0rPfXketj96TOb1vrh0s0V4rJeiuhHB oA3PHt5FM97ORUkV9rziVHeuWb/JXxXwztlcaORgYLLwhrov8bOpgv2xd5vHAvT4h5U4 L66A== 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=CdiCEHMKk566XZjegQIR8gg3RICYYDFYb1Lqktv3Klc=; b=mZIJ8m91BcqPIZilwvlb0XMOySDVMJx88fQt/KcLS0DhHrS1Pr9TcOCqC6LuJ4YrvT gj+Ql8BfuCMZkjbifSYNDUMcj3Bt0ira2zsmusQqzqUc57g3Kdq/VCmR3vdRJQfoAtid 94zvbxeGQTHyxIcGTDzQII9ZwItjfdjC/lAKALYJzXsPP/I78QoYh8lYoDv468SbbCGg 2N02wZRoEZIeQKolv8lSsoiRawfizoBqjmWjmtWk4444ZeFF27yLV74MpjPmIm25ALuJ ln+NWQHUn16uhqRsbeQfUULJqeOhDfkCGPCTHdzJzzB8g0D7338H21cNMqixKi6OncQv H0KQ== X-Gm-Message-State: APjAAAVmDlCxk3TOUe+FVC7352SVI+pd7o4u5+ulmxLsNfQTzIZB3t70 HIY1+Jxe4Os3VCRZ6vtg2ZSpRw== X-Google-Smtp-Source: APXvYqw2+kxRJ8EJ3nEnCluvCd7E46yWcBFu61Ab8biFE5LJvvb+8aL1yzz26d5V+Nb0YUs+87vKkg== X-Received: by 2002:a0c:f712:: with SMTP id w18mr4600436qvn.244.1568859508633; Wed, 18 Sep 2019 19:18:28 -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 o52sm5261275qtf.56.2019.09.18.19.18.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Sep 2019 19:18:27 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] thermal: of-thermal: Extend thermal dt driver to support bi-directional monitoring of a thermal trip point. Date: Wed, 18 Sep 2019 22:18:22 -0400 Message-Id: <1568859503-19725-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568859503-19725-1-git-send-email-thara.gopinath@linaro.org> References: <1568859503-19725-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 Introduce of_thermal_get_trip_monitor_type to return the direction of monitoring of a thermal trip point. Also translate the DT information regarding trip point monitor direction into the thermal framework. Signed-off-by: Thara Gopinath --- drivers/thermal/of-thermal.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index dc5093b..a5f6fdc 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -377,6 +377,20 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, return 0; } +static int of_thermal_get_trip_monitor_type + (struct thermal_zone_device *tz, int trip, + enum thermal_trip_monitor_type *type) +{ + struct __thermal_zone *data = tz->devdata; + + if (trip >= data->ntrips || trip < 0) + return -EDOM; + + *type = data->trips[trip].monitor_type; + + return 0; +} + static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { @@ -401,6 +415,7 @@ static struct thermal_zone_device_ops of_thermal_ops = { .set_trip_temp = of_thermal_set_trip_temp, .get_trip_hyst = of_thermal_get_trip_hyst, .set_trip_hyst = of_thermal_set_trip_hyst, + .get_trip_monitor_type = of_thermal_get_trip_monitor_type, .get_crit_temp = of_thermal_get_crit_temp, .bind = of_thermal_bind, @@ -809,6 +824,7 @@ static int thermal_of_populate_trip(struct device_node *np, { int prop; int ret; + bool is_monitor_falling; ret = of_property_read_u32(np, "temperature", &prop); if (ret < 0) { @@ -830,6 +846,12 @@ static int thermal_of_populate_trip(struct device_node *np, return ret; } + is_monitor_falling = of_property_read_bool(np, "monitor-falling"); + if (is_monitor_falling) + trip->monitor_type = THERMAL_TRIP_MONITOR_FALLING; + else + trip->monitor_type = THERMAL_TRIP_MONITOR_RISING; + /* Required for cooling map matching */ trip->np = np; of_node_get(np); From patchwork Thu Sep 19 02:18:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 11151511 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 CC54216B1 for ; Thu, 19 Sep 2019 02:18:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9FD84217D6 for ; Thu, 19 Sep 2019 02:18:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YilbaR6j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388317AbfISCSd (ORCPT ); Wed, 18 Sep 2019 22:18:33 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:43535 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388345AbfISCSc (ORCPT ); Wed, 18 Sep 2019 22:18:32 -0400 Received: by mail-qt1-f196.google.com with SMTP id c3so2275469qtv.10 for ; Wed, 18 Sep 2019 19:18: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=H7D4s+CkAmLBeZ/6zlhP2G8xuIQDDKxrEeqdqHuDSaE=; b=YilbaR6jBv62EnsBExQZKzQiV2/klUvm9VFz1WjN6yvxoRyUNArOCv19ThV/q2dUji S+8nzP58nrfXl7hAMWWWHjrsALTqpfZ/TIsX9ziepgrgVanl9SnDa/S3yNLgnGMZRgBZ KMld+X7eTF2dvMCg7AqNTCXvetYubo4gUKztyJVRKCvdeD+AM/dga7wURid/ufYhNz+H 24iP7Bch7ZDyI8ENMW4xZYkSaaLVeLH1BuILTVq7H9KIxcC7iB2xbLc8imybqDNyHpjJ LOtCrLOrcCKeiIlBlRdkCGCyeTRG7825WQo5/Uv3J/M713IsjmD9U/l1dKn5XmTSGZwU eZkw== 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=H7D4s+CkAmLBeZ/6zlhP2G8xuIQDDKxrEeqdqHuDSaE=; b=qYWQ8bj5Hu1QQb6EpXo0jS5vAJEdFanjNQ9udi8JYAgYJFWctUezRZb3Ez9oIErsfI ++zSBjyc6D7zn/juVyb5rHYbPm5vMW8xQYZOyl3eak1xgP5ZzKsZNO4r+sr+S/OTz+C3 tJRiMVDyRKYPcXdT0q2sJ/Ao/2u4T99iFwaEPhCXgimMimoZZ2GMvpx9FOmjVMvqmpmv 5ubcRHza6V5OvFx5yB5DMylWNCf5RQJDncroPvQ+yfggmm1ppgwtSOa/oUbw3sZUf1d8 MhPnXyO59LxLmjWP7gbS4PF4l9Bq4KtpBFOVKSx2TMkTAfFsjqHqE0d/u9glmL6n8J8J 13GQ== X-Gm-Message-State: APjAAAX3Zggr2NfJZFc0VZiJ7jxh7hWfhCGj1EpjNNvNUmnFWrwg0ZqA zvJkU8Ce1hPTIs4cbYXYhYFxSQ== X-Google-Smtp-Source: APXvYqwXaeBcVyAp1JNYBKDS7In10ssdhrlNkNgEMbkiLJMfzw7ZWi1vOYe4JONKg6yntHxCTwyi0w== X-Received: by 2002:ac8:4612:: with SMTP id p18mr886307qtn.94.1568859509919; Wed, 18 Sep 2019 19:18: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 o52sm5261275qtf.56.2019.09.18.19.18.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Sep 2019 19:18:29 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] thermal: step_wise: Extend thermal step-wise governor to monitor falling temperature. Date: Wed, 18 Sep 2019 22:18:23 -0400 Message-Id: <1568859503-19725-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1568859503-19725-1-git-send-email-thara.gopinath@linaro.org> References: <1568859503-19725-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 From the step wise governor point of view, the policy decisions that has to taken on a thermal trip point that is defined to be monitored for falling temprature is the mirror opposite of the decisions it has to take on a trip point that is monitored for rising temperature. Signed-off-by: Thara Gopinath --- drivers/thermal/step_wise.c | 59 +++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 6e051cb..aa8e0a0 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -35,7 +35,8 @@ * deactivate the thermal instance */ static unsigned long get_target_state(struct thermal_instance *instance, - enum thermal_trend trend, bool throttle) + enum thermal_trend trend, bool throttle, + enum thermal_trip_monitor_type type) { struct thermal_cooling_device *cdev = instance->cdev; unsigned long cur_state; @@ -65,11 +66,21 @@ static unsigned long get_target_state(struct thermal_instance *instance, switch (trend) { case THERMAL_TREND_RAISING: - if (throttle) { - next_target = cur_state < instance->upper ? - (cur_state + 1) : instance->upper; - if (next_target < instance->lower) - next_target = instance->lower; + if (type == THERMAL_TRIP_MONITOR_FALLING) { + if (cur_state <= instance->lower) { + if (!throttle) + next_target = THERMAL_NO_TARGET; + } else { + if (!throttle) + next_target = cur_state - 1; + } + } else { + if (throttle) { + next_target = cur_state < instance->upper ? + (cur_state + 1) : instance->upper; + if (next_target < instance->lower) + next_target = instance->lower; + } } break; case THERMAL_TREND_RAISE_FULL: @@ -77,14 +88,23 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = instance->upper; break; case THERMAL_TREND_DROPPING: - if (cur_state <= instance->lower) { - if (!throttle) - next_target = THERMAL_NO_TARGET; + if (type == THERMAL_TRIP_MONITOR_FALLING) { + if (throttle) { + next_target = cur_state < instance->upper ? + (cur_state + 1) : instance->upper; + if (next_target < instance->lower) + next_target = instance->lower; + } } else { - if (!throttle) { - next_target = cur_state - 1; - if (next_target > instance->upper) - next_target = instance->upper; + if (cur_state <= instance->lower) { + if (!throttle) + next_target = THERMAL_NO_TARGET; + } else { + if (!throttle) { + next_target = cur_state - 1; + if (next_target > instance->upper) + next_target = instance->upper; + } } } break; @@ -117,6 +137,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) { int trip_temp; enum thermal_trip_type trip_type; + enum thermal_trip_monitor_type monitor_type = + THERMAL_TRIP_MONITOR_RISING; enum thermal_trend trend; struct thermal_instance *instance; bool throttle = false; @@ -130,9 +152,15 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) tz->ops->get_trip_type(tz, trip, &trip_type); } + if (tz->ops->get_trip_monitor_type) + tz->ops->get_trip_monitor_type(tz, trip, &monitor_type); + trend = get_tz_trend(tz, trip); - if (tz->temperature >= trip_temp) { + if (((monitor_type == THERMAL_TRIP_MONITOR_RISING) && + (tz->temperature >= trip_temp)) || + ((monitor_type == THERMAL_TRIP_MONITOR_FALLING) && + (tz->temperature <= trip_temp))) { throttle = true; trace_thermal_zone_trip(tz, trip, trip_type); } @@ -147,7 +175,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) continue; old_target = instance->target; - instance->target = get_target_state(instance, trend, throttle); + instance->target = get_target_state(instance, trend, throttle, + monitor_type); dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", old_target, (int)instance->target);