linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/11] thermal: add new flag irq-mode for trip point
       [not found] <CGME20181107171019eucas1p1fcb1f44e00265434548d901479f2ea94@eucas1p1.samsung.com>
@ 2018-11-07 17:09 ` Lukasz Luba
       [not found]   ` <CGME20181107171022eucas1p1c2431f0561d9b1357ab569ab77deca34@eucas1p1.samsung.com>
                     ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

Hi all,

This patch set adds a new flag and mechanism in thermal trip points in
DT.  The old implementation in thermal zone in DT sets the same
configuration for all internal trip points. It does not work for all
HW.  There are SoCs which support IRQs for some trip points (i.e.
Exynos 4 has 4 trip points with IRQs). For additional one defined
inside the thermal zone there is a need of 'polling'. When developer
adds polling mode settings inside the thermal zone, all the trip
points will be registered for polling, even those supporting IRQs,
which does not make sense. Thus, developers create workarounds, which
are confusing for some other developers.  To workaround, 
people declare some trip points as 'active' (those with IRQ support).
It allows to bypass polling mode in thermal framework applied for 
all thermal zone's trip points.

Thermal framework defines 4 types of trip points. The 'passive' means
passive cooling using DVFS, 'active' is designed for fan and other
devices actively changing the outside conditions. Therefore, a workaround
mentioned earlier is confusing when someone does not know about the
framework limitations.

This patch set tries to solve the issue by adding one flag inside the
trip point: 'irq-mode;'.  The trip point 'passive' declared in DT with
explicit flag 'irq-mode;' will not register itself as polling mode.
Thermal framework will skip it during scheduling next read out work.
The old global-polling-mode-configuration-inside-thermal-zone is still
valid.  Patch set does not break existing design for trip points which
do not have 'irq-mode' flag - they will use polling.

As an example please check patch #10 for Exynos4 SoC family, where there
is 4 HW supported trip points and there is a need of 6. The rest 2 are
declared as 'passive' without 'irq-mode;' flag, which means polling
mode needed for them.

Patch #1 is a small cleanup in thermal framework.

Change log:
v2
- changed description in cover letter
- change commit messages according to Krzysztof comments
- rebase on top of current mainline (v4.20-rc1)

Regards,
Lukasz Luba

Lukasz Luba (11):
  thermal: remove unused function parameter
  thermal: add irq-mode configuration for trip point
  thermal: add new sysfs file for irq-mode
  Doc: thermal: new irq-mode for trip point
  Doc: DT: thermal: new irq-mode for trip point
  arm64: dts: exynos5433: add support for thermal trip irq-mode
  arm64: dts: exynos7: add support for thermal trip irq-mode
  arm: dts: exynos4: add support for thermal trip irq-mode
  arm: dts: exynos5420: add support for thermal trip irq-mode
  arm: dts: exynos5422: add support for thermal trip irq-mode
  arm: dts: exynos5410: add support for thermal trip irq-mode

 .../devicetree/bindings/thermal/thermal.txt        |   7 ++
 Documentation/thermal/sysfs-api.txt                |   9 ++
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  10 +-
 arch/arm/boot/dts/exynos5410-odroidxu.dts          |  10 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  10 +-
 arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi |  40 +++++---
 arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi     | 105 ++++++++++++++-------
 .../arm64/boot/dts/exynos/exynos7-trip-points.dtsi |   8 ++
 drivers/thermal/of-thermal.c                       |  17 ++++
 drivers/thermal/thermal_core.c                     |  16 ++--
 drivers/thermal/thermal_sysfs.c                    |  53 ++++++++++-
 include/linux/thermal.h                            |   5 +
 12 files changed, 226 insertions(+), 64 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 01/11] thermal: remove unused function parameter
       [not found]   ` <CGME20181107171022eucas1p1c2431f0561d9b1357ab569ab77deca34@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

Clean unused parameter from internal framework function.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 drivers/thermal/thermal_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d6ebc1c..39fc812 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -315,9 +315,7 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
 	mutex_unlock(&tz->lock);
 }
 
-static void handle_non_critical_trips(struct thermal_zone_device *tz,
-				      int trip,
-				      enum thermal_trip_type trip_type)
+static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
 {
 	tz->governor ? tz->governor->throttle(tz, trip) :
 		       def_governor->throttle(tz, trip);
@@ -418,7 +416,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
 	if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
 		handle_critical_trips(tz, trip, type);
 	else
-		handle_non_critical_trips(tz, trip, type);
+		handle_non_critical_trips(tz, trip);
 	/*
 	 * Alright, we handled this trip successfully.
 	 * So, start monitoring again.
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 02/11] thermal: add irq-mode configuration for trip point
       [not found]   ` <CGME20181107171036eucas1p13253d56b463c8f888ab8f8e418635297@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  2018-12-05 15:09       ` Zhang Rui
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

This patch adds support irq mode in trip point.
When that flag is set in DT, there is no need for polling
in thermal framework. Crossing the trip point will rise an IRQ.
The naming convention for tip point 'type' can be confussing
and 'passive' (whic is passive cooling) might be interpretted wrongly.

This mechanism prevents from missue and adds explicit setting
for hardware which support interrupts for pre-configured temperature
threshold.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 drivers/thermal/of-thermal.c   | 17 +++++++++++++++++
 drivers/thermal/thermal_core.c | 10 ++++++++--
 include/linux/thermal.h        |  5 +++++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 4bfdb4a..1a75946a 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -312,6 +312,20 @@ static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
 	return 0;
 }
 
+static int
+of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz, int trip,
+			     bool *mode)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (trip >= data->ntrips || trip < 0)
+		return -EDOM;
+
+	*mode = data->trips[trip].irq_mode;
+
+	return 0;
+}
+
 static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
 				    int *temp)
 {
@@ -394,6 +408,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
 	.set_mode = of_thermal_set_mode,
 
 	.get_trip_type = of_thermal_get_trip_type,
+	.get_trip_irq_mode = of_thermal_get_trip_irq_mode,
 	.get_trip_temp = of_thermal_get_trip_temp,
 	.set_trip_temp = of_thermal_set_trip_temp,
 	.get_trip_hyst = of_thermal_get_trip_hyst,
@@ -827,6 +842,8 @@ static int thermal_of_populate_trip(struct device_node *np,
 		return ret;
 	}
 
+	trip->irq_mode = of_property_read_bool(np, "irq-mode");
+
 	/* Required for cooling map matching */
 	trip->np = np;
 	of_node_get(np);
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 39fc812..6d41e08 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -406,6 +406,7 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
 static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
 {
 	enum thermal_trip_type type;
+	bool irq_mode = false;
 
 	/* Ignore disabled trip points */
 	if (test_bit(trip, &tz->trips_disabled))
@@ -419,9 +420,14 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
 		handle_non_critical_trips(tz, trip);
 	/*
 	 * Alright, we handled this trip successfully.
-	 * So, start monitoring again.
+	 * So, start monitoring in polling mode if
+	 * trip is not using irq HW support.
 	 */
-	monitor_thermal_zone(tz);
+	if (tz->ops->get_trip_irq_mode)
+		tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
+
+	if (!irq_mode)
+		monitor_thermal_zone(tz);
 }
 
 static void update_temperature(struct thermal_zone_device *tz)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 5f4705f..b064565 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -103,6 +103,7 @@ struct thermal_zone_device_ops {
 		enum thermal_device_mode);
 	int (*get_trip_type) (struct thermal_zone_device *, int,
 		enum thermal_trip_type *);
+	int (*get_trip_irq_mode) (struct thermal_zone_device *, int, bool *);
 	int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
 	int (*set_trip_temp) (struct thermal_zone_device *, int, int);
 	int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
@@ -196,6 +197,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_irq_mode_attrs;
 	void *devdata;
 	int trips;
 	unsigned long trips_disabled;	/* bitmap for disabled trips */
@@ -364,6 +366,8 @@ struct thermal_zone_of_device_ops {
  * @temperature: temperature value in miliCelsius
  * @hysteresis: relative hysteresis in miliCelsius
  * @type: trip point type
+ * @irq_mode: to not use polling in framework set support of HW irq (which will
+ *	      be triggered when temperature reaches this level).
  */
 
 struct thermal_trip {
@@ -371,6 +375,7 @@ struct thermal_trip {
 	int temperature;
 	int hysteresis;
 	enum thermal_trip_type type;
+	bool irq_mode;
 };
 
 /* Function declarations */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 03/11] thermal: add new sysfs file for irq-mode
       [not found]   ` <CGME20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

Patch adds show functions for irq-mode feature.
It allocates new attributes and extends the old list.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 drivers/thermal/thermal_sysfs.c | 53 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 2241cea..372b439 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -21,6 +21,8 @@
 
 #include "thermal_core.h"
 
+#define TRIP_ATTR_NUM 4
+
 /* sys I/F for thermal zone */
 
 static ssize_t
@@ -167,6 +169,28 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,
 }
 
 static ssize_t
+trip_point_irq_mode_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
+{
+	struct thermal_zone_device *tz = to_thermal_zone(dev);
+	int trip, ret;
+	bool mode;
+
+	if (!tz->ops->get_trip_irq_mode)
+		return -EPERM;
+
+	if (sscanf(attr->attr.name, "trip_point_%d_irq", &trip) != 1)
+		return -EINVAL;
+
+	ret = tz->ops->get_trip_irq_mode(tz, trip, &mode);
+
+	if (ret)
+		return ret;
+
+	return sprintf(buf, "%d\n", mode);
+}
+
+static ssize_t
 trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
 		      const char *buf, size_t count)
 {
@@ -520,10 +544,19 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
 	if (!tz->trip_type_attrs)
 		return -ENOMEM;
 
+	tz->trip_irq_mode_attrs = kcalloc(tz->trips,
+					  sizeof(*tz->trip_irq_mode_attrs),
+					  GFP_KERNEL);
+	if (!tz->trip_irq_mode_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_irq_mode_attrs);
 		return -ENOMEM;
 	}
 
@@ -533,14 +566,17 @@ 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_irq_mode_attrs);
 			kfree(tz->trip_temp_attrs);
 			return -ENOMEM;
 		}
 	}
 
-	attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL);
+	attrs = kcalloc(tz->trips * TRIP_ATTR_NUM + 1, sizeof(*attrs),
+			GFP_KERNEL);
 	if (!attrs) {
 		kfree(tz->trip_type_attrs);
+		kfree(tz->trip_irq_mode_attrs);
 		kfree(tz->trip_temp_attrs);
 		if (tz->ops->get_trip_hyst)
 			kfree(tz->trip_hyst_attrs);
@@ -559,6 +595,19 @@ 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 irq_mode attribute */
+		snprintf(tz->trip_irq_mode_attrs[indx].name,
+			 THERMAL_NAME_LENGTH, "trip_point_%d_irq", indx);
+
+		sysfs_attr_init(&tz->trip_irq_mode_attrs[indx].attr.attr);
+		tz->trip_irq_mode_attrs[indx].attr.attr.name =
+			tz->trip_irq_mode_attrs[indx].name;
+		tz->trip_irq_mode_attrs[indx].attr.attr.mode = S_IRUGO;
+		tz->trip_irq_mode_attrs[indx].attr.show =
+			trip_point_irq_mode_show;
+		attrs[indx + tz->trips * 3] =
+			&tz->trip_irq_mode_attrs[indx].attr.attr;
+
 		/* create trip temp attribute */
 		snprintf(tz->trip_temp_attrs[indx].name, THERMAL_NAME_LENGTH,
 			 "trip_point_%d_temp", indx);
@@ -595,7 +644,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
 		attrs[indx + tz->trips * 2] =
 					&tz->trip_hyst_attrs[indx].attr.attr;
 	}
-	attrs[tz->trips * 3] = NULL;
+	attrs[tz->trips * TRIP_ATTR_NUM] = NULL;
 
 	tz->trips_attribute_group.attrs = attrs;
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 04/11] Doc: thermal: new irq-mode for trip point
       [not found]   ` <CGME20181107171038eucas1p1eb5dce12a1f5f7a3587f82f8396fa075@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

Thermal trip point gets new flag in DT: irq-mode.
Trip point may have a new explicit flag which indicate
IRQ support when the temperature is met (so the thermal framework
deos not need to set polling for it).
It is useful for 'passive' cooling trip point,
which now will not be register for polling the temperature.

Update documentation about irq-mode for trip points.
The new sysfs file shows 1 if the trip point supports IRQ.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 Documentation/thermal/sysfs-api.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt
index 9113997..e405724 100644
--- a/Documentation/thermal/sysfs-api.txt
+++ b/Documentation/thermal/sysfs-api.txt
@@ -272,6 +272,7 @@ Thermal zone device sys I/F, created once it's registered:
     |---trip_point_[0-*]_temp:	Trip point temperature
     |---trip_point_[0-*]_type:	Trip point type
     |---trip_point_[0-*]_hyst:	Hysteresis value for this trip point
+    |---trip_point_[0-*]_irq:	Trip point supports triggering irq
     |---emul_temp:		Emulated temperature set node
     |---sustainable_power:      Sustainable dissipatable power
     |---k_po:                   Proportional term during temperature overshoot
@@ -365,6 +366,10 @@ trip_point_[0-*]_type
 	thermal zone.
 	RO, Optional
 
+trip_point_[0-*]_irq
+	Boolean which indicate that the trip point triggers irq.
+	RO, Optional
+
 trip_point_[0-*]_hyst
 	The hysteresis value for a trip point, represented as an integer
 	Unit: Celsius
@@ -544,12 +549,16 @@ method, the sys I/F structure will be built like this:
     |---available_policies:	step_wise fair_share
     |---trip_point_0_temp:	100000
     |---trip_point_0_type:	critical
+    |---trip_point_0_irq:	1
     |---trip_point_1_temp:	80000
     |---trip_point_1_type:	passive
+    |---trip_point_1_irq:	1
     |---trip_point_2_temp:	70000
     |---trip_point_2_type:	active0
+    |---trip_point_2_irq:	0
     |---trip_point_3_temp:	60000
     |---trip_point_3_type:	active1
+    |---trip_point_3_irq:	1
     |---cdev0:			--->/sys/class/thermal/cooling_device0
     |---cdev0_trip_point:	1	/* cdev0 can be used for passive */
     |---cdev0_weight:           1024
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 05/11] Doc: DT: thermal: new irq-mode for trip point
       [not found]   ` <CGME20181107171039eucas1p2227bd4bc573fd0d2a3a97986004be16b@eucas1p2.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  2018-11-12  8:51       ` Krzysztof Kozlowski
       [not found]       ` <5bea0ecd.1c69fb81.d5613.1c9e@mx.google.com>
  0 siblings, 2 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba

Thermal trip point gets new flag in DT: irq-mode.
Trip point may have a new explicit flag which indicate
IRQ support when the temperature is met (so the thermal framework
deos not need to set polling for it).
It is useful for 'passive' cooling trip point,
which now will not register for polling the temperature.

Update documentation about irq-mode for trip points.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
index ca14ba9..bee21e3 100644
--- a/Documentation/devicetree/bindings/thermal/thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal.txt
@@ -90,6 +90,10 @@ Required properties:
 	"critical":	Hardware not reliable.
   Type: string
 
+- irq-mode:		A flag indicating that trip rises irq, so there is no
+  Type: bool		need of polling in thermal framework.
+  Size: one cell
+
 * Cooling device maps
 
 The cooling device maps node is a node to describe how cooling devices
@@ -256,16 +260,19 @@ thermal-zones {
 				temperature = <90000>; /* millicelsius */
 				hysteresis = <2000>; /* millicelsius */
 				type = "active";
+				irq-mode;
 			};
 			cpu_alert1: cpu-alert1 {
 				temperature = <100000>; /* millicelsius */
 				hysteresis = <2000>; /* millicelsius */
 				type = "passive";
+				irq-mode;
 			};
 			cpu_crit: cpu-crit {
 				temperature = <125000>; /* millicelsius */
 				hysteresis = <2000>; /* millicelsius */
 				type = "critical";
+				irq-mode;
 			};
 		};
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 06/11] arm64: dts: exynos5433: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171041eucas1p1a3cf91435b9071fd6e6f84101ebbcd9f@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  2018-11-12  9:00       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Exynos5433 supports 8 trip point which will trigger IRQ.
Above that number other trip points should be registered
without 'irq-mode' flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi | 105 ++++++++++++++++---------
 1 file changed, 70 insertions(+), 35 deletions(-)

diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
index fe3a0b1..c4330f6 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
@@ -17,37 +17,44 @@ thermal-zones {
 			atlas0_alert_0: atlas0-alert-0 {
 				temperature = <65000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_1: atlas0-alert-1 {
 				temperature = <70000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_2: atlas0-alert-2 {
 				temperature = <75000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_3: atlas0-alert-3 {
 				temperature = <80000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_4: atlas0-alert-4 {
 				temperature = <85000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_5: atlas0-alert-5 {
 				temperature = <90000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas0_alert_6: atlas0-alert-6 {
 				temperature = <95000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 		};
 
@@ -98,37 +105,44 @@ thermal-zones {
 			atlas1_alert_0: atlas1-alert-0 {
 				temperature = <65000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_1: atlas1-alert-1 {
 				temperature = <70000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_2: atlas1-alert-2 {
 				temperature = <75000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_3: atlas1-alert-3 {
 				temperature = <80000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_4: atlas1-alert-4 {
 				temperature = <85000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_5: atlas1-alert-5 {
 				temperature = <90000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			atlas1_alert_6: atlas1-alert-6 {
 				temperature = <95000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 		};
 	};
@@ -141,37 +155,44 @@ thermal-zones {
 			g3d_alert_0: g3d-alert-0 {
 				temperature = <70000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_1: g3d-alert-1 {
 				temperature = <75000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_2: g3d-alert-2 {
 				temperature = <80000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_3: g3d-alert-3 {
 				temperature = <85000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_4: g3d-alert-4 {
 				temperature = <90000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_5: g3d-alert-5 {
 				temperature = <95000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			g3d_alert_6: g3d-alert-6 {
 				temperature = <100000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 		};
 	};
@@ -184,37 +205,44 @@ thermal-zones {
 			apollo_alert_0: apollo-alert-0 {
 				temperature = <65000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_1: apollo-alert-1 {
 				temperature = <70000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_2: apollo-alert-2 {
 				temperature = <75000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_3: apollo-alert-3 {
 				temperature = <80000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_4: apollo-alert-4 {
 				temperature = <85000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_5: apollo-alert-5 {
 				temperature = <90000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			apollo_alert_6: apollo-alert-6 {
 				temperature = <95000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 		};
 
@@ -255,37 +283,44 @@ thermal-zones {
 			isp_alert_0: isp-alert-0 {
 				temperature = <80000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_1: isp-alert-1 {
 				temperature = <85000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_2: isp-alert-2 {
 				temperature = <90000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_3: isp-alert-3 {
 				temperature = <95000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_4: isp-alert-4 {
 				temperature = <100000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_5: isp-alert-5 {
 				temperature = <105000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			isp_alert_6: isp-alert-6 {
 				temperature = <110000>;	/* millicelsius */
 				hysteresis = <1000>;	/* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 		};
 	};
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 07/11] arm64: dts: exynos7: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171042eucas1p1675eb589f3951e516461a0a775ee87da@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Change existing trip points to be expicitly marked with the new flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm64/boot/dts/exynos/exynos7-trip-points.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/exynos7-trip-points.dtsi b/arch/arm64/boot/dts/exynos/exynos7-trip-points.dtsi
index d3301b8..39185af 100644
--- a/arch/arm64/boot/dts/exynos/exynos7-trip-points.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynos7-trip-points.dtsi
@@ -11,40 +11,48 @@ trips {
 		temperature = <75000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-1 {
 		temperature = <80000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-2 {
 		temperature = <85000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-3 {
 		temperature = <90000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-4 {
 		temperature = <95000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-5 {
 		temperature = <100000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-6 {
 		temperature = <110000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
 		type = "passive";
+		irq-mode;
 	};
 	cpu-crit-0 {
 		temperature = <115000>; /* millicelsius */
 		hysteresis = <0>; /* millicelsius */
 		type = "critical";
+		irq-mode;
 	};
 };
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 08/11] arm: dts: exynos4: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171043eucas1p16be3fa901c7bceb129c70fc81dba6e48@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Change existing trip points to be expicitly marked with the new flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
index 021d9fc..5e07289 100644
--- a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -17,22 +17,26 @@ thermal-zones {
 			cpu_alert0: cpu-alert-0 {
 				temperature = <70000>; /* millicelsius */
 				hysteresis = <10000>; /* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			cpu_alert1: cpu-alert-1 {
 				temperature = <95000>; /* millicelsius */
 				hysteresis = <10000>; /* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			cpu_alert2: cpu-alert-2 {
 				temperature = <110000>; /* millicelsius */
 				hysteresis = <10000>; /* millicelsius */
-				type = "active";
+				type = "passive";
+				irq-mode;
 			};
 			cpu_crit0: cpu-crit-0 {
 				temperature = <120000>; /* millicelsius */
 				hysteresis = <0>; /* millicelsius */
 				type = "critical";
+				irq-mode;
 			};
 		};
 		cooling-maps {
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 09/11] arm: dts: exynos5420: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171044eucas1p198434e21cf21ee754302615a6a8f3c20@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Change existing trip points to be expicitly marked with the new flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
index a67a3807..9e16970 100644
--- a/arch/arm/boot/dts/exynos5420-trip-points.dtsi
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -11,21 +11,25 @@ trips {
 	cpu-alert-0 {
 		temperature = <85000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
-		type = "active";
+		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-1 {
 		temperature = <103000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
-		type = "active";
+		type = "passive";
+		irq-mode;
 	};
 	cpu-alert-2 {
 		temperature = <110000>; /* millicelsius */
 		hysteresis = <10000>; /* millicelsius */
-		type = "active";
+		type = "passive";
+		irq-mode;
 	};
 	cpu-crit-0 {
 		temperature = <120000>; /* millicelsius */
 		hysteresis = <0>; /* millicelsius */
 		type = "critical";
+		irq-mode;
 	};
 };
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 10/11] arm: dts: exynos5422: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171045eucas1p26ec5feb1b2a397971c919592f6d87b40@eucas1p2.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Exynos5422 supports 4 trip points which will trigger IRQ.
Additional trip points should be registered without 'irq-mode' flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi | 40 +++++++++++++++-------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
index e522edb..389548f 100644
--- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
@@ -59,22 +59,26 @@
 				cpu0_alert0: cpu-alert-0 {
 					temperature = <50000>; /* millicelsius */
 					hysteresis = <5000>; /* millicelsius */
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu0_alert1: cpu-alert-1 {
 					temperature = <60000>; /* millicelsius */
 					hysteresis = <5000>; /* millicelsius */
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu0_alert2: cpu-alert-2 {
 					temperature = <70000>; /* millicelsius */
 					hysteresis = <5000>; /* millicelsius */
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu0_crit0: cpu-crit-0 {
 					temperature = <120000>; /* millicelsius */
 					hysteresis = <0>; /* millicelsius */
 					type = "critical";
+					irq-mode;
 				};
 				/*
 				 * Exynos542x supports only 4 trip-points
@@ -142,22 +146,26 @@
 				cpu1_alert0: cpu-alert-0 {
 					temperature = <50000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu1_alert1: cpu-alert-1 {
 					temperature = <60000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu1_alert2: cpu-alert-2 {
 					temperature = <70000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu1_crit0: cpu-crit-0 {
 					temperature = <120000>;
 					hysteresis = <0>;
 					type = "critical";
+					irq-mode;
 				};
 				cpu1_alert3: cpu-alert-3 {
 					temperature = <70000>;
@@ -209,22 +217,26 @@
 				cpu2_alert0: cpu-alert-0 {
 					temperature = <50000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu2_alert1: cpu-alert-1 {
 					temperature = <60000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu2_alert2: cpu-alert-2 {
 					temperature = <70000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu2_crit0: cpu-crit-0 {
 					temperature = <120000>;
 					hysteresis = <0>;
 					type = "critical";
+					irq-mode;
 				};
 				cpu2_alert3: cpu-alert-3 {
 					temperature = <70000>;
@@ -276,22 +288,26 @@
 				cpu3_alert0: cpu-alert-0 {
 					temperature = <50000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu3_alert1: cpu-alert-1 {
 					temperature = <60000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu3_alert2: cpu-alert-2 {
 					temperature = <70000>;
 					hysteresis = <5000>;
-					type = "active";
+					type = "passive";
+					irq-mode;
 				};
 				cpu3_crit0: cpu-crit-0 {
 					temperature = <120000>;
 					hysteresis = <0>;
 					type = "critical";
+					irq-mode;
 				};
 				cpu3_alert3: cpu-alert-3 {
 					temperature = <70000>;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 11/11] arm: dts: exynos5410: add support for thermal trip irq-mode
       [not found]   ` <CGME20181107171046eucas1p1649bcf14a88ef9dd183724dde3a98f8c@eucas1p1.samsung.com>
@ 2018-11-07 17:09     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-07 17:09 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm
  Cc: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, b.zolnierkie, krzk, Lukasz Luba, Kukjin Kim,
	linux-samsung-soc

This patch adds support for new flag which indicates
that trip point triggers IRQ when temperature is met.
Change existing trip points to be expicitly marked with the new flag.

Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
---
 arch/arm/boot/dts/exynos5410-odroidxu.dts | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5410-odroidxu.dts b/arch/arm/boot/dts/exynos5410-odroidxu.dts
index 434a759..e85a5d6 100644
--- a/arch/arm/boot/dts/exynos5410-odroidxu.dts
+++ b/arch/arm/boot/dts/exynos5410-odroidxu.dts
@@ -121,22 +121,26 @@
 		cpu_alert0: cpu-alert-0 {
 			temperature = <50000>; /* millicelsius */
 			hysteresis = <5000>; /* millicelsius */
-			type = "active";
+			type = "passive";
+			irq-mode;
 		};
 		cpu_alert1: cpu-alert-1 {
 			temperature = <60000>; /* millicelsius */
 			hysteresis = <5000>; /* millicelsius */
-			type = "active";
+			type = "passive";
+			irq-mode;
 		};
 		cpu_alert2: cpu-alert-2 {
 			temperature = <70000>; /* millicelsius */
 			hysteresis = <5000>; /* millicelsius */
-			type = "active";
+			type = "passive";
+			irq-mode;
 		};
 		cpu_crit0: cpu-crit-0 {
 			temperature = <120000>; /* millicelsius */
 			hysteresis = <0>; /* millicelsius */
 			type = "critical";
+			irq-mode;
 		};
 	};
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 05/11] Doc: DT: thermal: new irq-mode for trip point
  2018-11-07 17:09     ` [PATCH v2 05/11] Doc: DT: " Lukasz Luba
@ 2018-11-12  8:51       ` Krzysztof Kozlowski
  2018-11-13 10:06         ` Lukasz Luba
       [not found]       ` <5bea0ecd.1c69fb81.d5613.1c9e@mx.google.com>
  1 sibling, 1 reply; 23+ messages in thread
From: Krzysztof Kozlowski @ 2018-11-12  8:51 UTC (permalink / raw)
  To: l.luba
  Cc: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm,
	rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, Bartłomiej Żołnierkiewicz

On Wed, 7 Nov 2018 at 18:10, Lukasz Luba <l.luba@partner.samsung.com> wrote:
>

Subject prefix:
dt-bindings: thermal:

> Thermal trip point gets new flag in DT: irq-mode.
> Trip point may have a new explicit flag which indicate
> IRQ support when the temperature is met (so the thermal framework
> deos not need to set polling for it).
> It is useful for 'passive' cooling trip point,
> which now will not register for polling the temperature.

You wrap lines in weird way making it more difficult to read.
I already asked about this while reviewing v1. Please fix it.
https://elixir.bootlin.com/linux/latest/source/Documentation/process/submitting-patches.rst#L633

>
> Update documentation about irq-mode for trip points.
>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
> ---
>  Documentation/devicetree/bindings/thermal/thermal.txt | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
> index ca14ba9..bee21e3 100644
> --- a/Documentation/devicetree/bindings/thermal/thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/thermal.txt
> @@ -90,6 +90,10 @@ Required properties:
>         "critical":     Hardware not reliable.
>    Type: string
>
> +- irq-mode:            A flag indicating that trip rises irq, so there is no

"rises IRQ" (it is an abbreviation).

Best regards,
Krzysztof

> +  Type: bool           need of polling in thermal framework.
> +  Size: one cell
> +
>  * Cooling device maps
>
>  The cooling device maps node is a node to describe how cooling devices
> @@ -256,16 +260,19 @@ thermal-zones {
>                                 temperature = <90000>; /* millicelsius */
>                                 hysteresis = <2000>; /* millicelsius */
>                                 type = "active";
> +                               irq-mode;
>                         };
>                         cpu_alert1: cpu-alert1 {
>                                 temperature = <100000>; /* millicelsius */
>                                 hysteresis = <2000>; /* millicelsius */
>                                 type = "passive";
> +                               irq-mode;
>                         };
>                         cpu_crit: cpu-crit {
>                                 temperature = <125000>; /* millicelsius */
>                                 hysteresis = <2000>; /* millicelsius */
>                                 type = "critical";
> +                               irq-mode;
>                         };
>                 };
>
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 06/11] arm64: dts: exynos5433: add support for thermal trip irq-mode
  2018-11-07 17:09     ` [PATCH v2 06/11] arm64: dts: exynos5433: add support for thermal trip irq-mode Lukasz Luba
@ 2018-11-12  9:00       ` Krzysztof Kozlowski
  2018-11-13 10:10         ` Lukasz Luba
  0 siblings, 1 reply; 23+ messages in thread
From: Krzysztof Kozlowski @ 2018-11-12  9:00 UTC (permalink / raw)
  To: l.luba
  Cc: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm,
	rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, Bartłomiej Żołnierkiewicz, kgene,
	linux-samsung-soc

Thanks Lukasz for patches. I like your work!

I have few more comments which will probably apply for all the DTS commits.

On Wed, 7 Nov 2018 at 18:10, Lukasz Luba <l.luba@partner.samsung.com> wrote:
>
> This patch adds support for new flag which indicates

This patch does not add support. Support for flag was added in your
first drivers/thermal patches in this set. This patch adds new flag.
(and does something more, so read on)

> that trip point triggers IRQ when temperature is met.
> Exynos5433 supports 8 trip point which will trigger IRQ.

/8 trip point/8 trip points/

> Above that number other trip points should be registered
> without 'irq-mode' flag.

Please fix the line-wrap.

>
> Cc: Kukjin Kim <kgene@kernel.org>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-samsung-soc@vger.kernel.org
> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
> ---
>  arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi | 105 ++++++++++++++++---------
>  1 file changed, 70 insertions(+), 35 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
> index fe3a0b1..c4330f6 100644
> --- a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
> +++ b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
> @@ -17,37 +17,44 @@ thermal-zones {
>                         atlas0_alert_0: atlas0-alert-0 {
>                                 temperature = <65000>;  /* millicelsius */
>                                 hysteresis = <1000>;    /* millicelsius */
> -                               type = "active";
> +                               type = "passive";

This change is not explained in commit msg.

Basically you are doing here two things (related to each other). You
clearly define which trip points are IRQ-type and you correct the type
of trip point. Active is incorrect. This second thing is missing in
your commit msg and I believe it is main reason behind this patch. You
should focus then on this reason - start from it. Subject could be
like "Use proper passive type for thermal trip points".

Without this explanation I don't see the strong reason behind that
patch. IOW, everything was working fine before... so why adding this
new flag? Or maybe something was not fine... and then it is real
reason why you are sending the patch. Usually commit message should
answer to the most important question "WHY". Now, it explains
"WHAT"... but I can see it from the source code. However from the code
it is not easy to guess WHY.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 05/11] Doc: DT: thermal: new irq-mode for trip point
  2018-11-12  8:51       ` Krzysztof Kozlowski
@ 2018-11-13 10:06         ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-13 10:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm,
	rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, Bartłomiej Żołnierkiewicz

Hi Krzysztof,

Thanks for the comments.

On 11/12/18 9:51 AM, Krzysztof Kozlowski wrote:
> On Wed, 7 Nov 2018 at 18:10, Lukasz Luba <l.luba@partner.samsung.com> wrote:
>>
> 
> Subject prefix:
> dt-bindings: thermal:
> 
>> Thermal trip point gets new flag in DT: irq-mode.
>> Trip point may have a new explicit flag which indicate
>> IRQ support when the temperature is met (so the thermal framework
>> deos not need to set polling for it).
>> It is useful for 'passive' cooling trip point,
>> which now will not register for polling the temperature.
> 
> You wrap lines in weird way making it more difficult to read.
> I already asked about this while reviewing v1. Please fix it.
> https://elixir.bootlin.com/linux/latest/source/Documentation/process/submitting-patches.rst#L633
>
I will fix it in v3.
>>
>> Update documentation about irq-mode for trip points.
>>
>> Cc: Zhang Rui <rui.zhang@intel.com>
>> Cc: Eduardo Valentin <edubezval@gmail.com>
>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Cc: Rob Herring <robh+dt@kernel.org>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: devicetree@vger.kernel.org
>> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
>> ---
>>   Documentation/devicetree/bindings/thermal/thermal.txt | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
>> index ca14ba9..bee21e3 100644
>> --- a/Documentation/devicetree/bindings/thermal/thermal.txt
>> +++ b/Documentation/devicetree/bindings/thermal/thermal.txt
>> @@ -90,6 +90,10 @@ Required properties:
>>          "critical":     Hardware not reliable.
>>     Type: string
>>
>> +- irq-mode:            A flag indicating that trip rises irq, so there is no
> 
> "rises IRQ" (it is an abbreviation).
ACK
> 
> Best regards,
> Krzysztof
> 


Regards,
Lukasz

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 06/11] arm64: dts: exynos5433: add support for thermal trip irq-mode
  2018-11-12  9:00       ` Krzysztof Kozlowski
@ 2018-11-13 10:10         ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-13 10:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm,
	rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	corbet, Bartłomiej Żołnierkiewicz, kgene,
	linux-samsung-soc

Hi Krzysztof,

On 11/12/18 10:00 AM, Krzysztof Kozlowski wrote:
> Thanks Lukasz for patches. I like your work!
> 
> I have few more comments which will probably apply for all the DTS commits.
> 
> On Wed, 7 Nov 2018 at 18:10, Lukasz Luba <l.luba@partner.samsung.com> wrote:
>>
>> This patch adds support for new flag which indicates
> 
> This patch does not add support. Support for flag was added in your
> first drivers/thermal patches in this set. This patch adds new flag.
> (and does something more, so read on)
Got it, will change the commit message.
> 
>> that trip point triggers IRQ when temperature is met.
>> Exynos5433 supports 8 trip point which will trigger IRQ.
> 
> /8 trip point/8 trip points/
> 
>> Above that number other trip points should be registered
>> without 'irq-mode' flag.
> 
> Please fix the line-wrap.
OK
> 
>>
>> Cc: Kukjin Kim <kgene@kernel.org>
>> Cc: Krzysztof Kozlowski <krzk@kernel.org>
>> Cc: devicetree@vger.kernel.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-samsung-soc@vger.kernel.org
>> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
>> ---
>>   arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi | 105 ++++++++++++++++---------
>>   1 file changed, 70 insertions(+), 35 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
>> index fe3a0b1..c4330f6 100644
>> --- a/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
>> +++ b/arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi
>> @@ -17,37 +17,44 @@ thermal-zones {
>>                          atlas0_alert_0: atlas0-alert-0 {
>>                                  temperature = <65000>;  /* millicelsius */
>>                                  hysteresis = <1000>;    /* millicelsius */
>> -                               type = "active";
>> +                               type = "passive";
> 
> This change is not explained in commit msg.
> 
> Basically you are doing here two things (related to each other). You
> clearly define which trip points are IRQ-type and you correct the type
> of trip point. Active is incorrect. This second thing is missing in
> your commit msg and I believe it is main reason behind this patch. You
> should focus then on this reason - start from it. Subject could be
> like "Use proper passive type for thermal trip points".
> 
> Without this explanation I don't see the strong reason behind that
> patch. IOW, everything was working fine before... so why adding this
> new flag? Or maybe something was not fine... and then it is real
> reason why you are sending the patch. Usually commit message should
> answer to the most important question "WHY". Now, it explains
> "WHAT"... but I can see it from the source code. However from the code
> it is not easy to guess WHY.

OK, I will add the explanation 'why' similar to description from the
cover-letter to all the patches which add this flag in DT files.

> 
> Best regards,
> Krzysztof
> 
> 

Thank you for the review.

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 05/11] Doc: DT: thermal: new irq-mode for trip point
       [not found]       ` <5bea0ecd.1c69fb81.d5613.1c9e@mx.google.com>
@ 2018-11-13 10:13         ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-11-13 10:13 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-arm-kernel, linux-doc, linux-kernel, linux-pm,
	rui.zhang, edubezval, daniel.lezcano, mark.rutland, corbet,
	b.zolnierkie, krzk

Hi Rob,

On 11/12/18 8:09 PM, Rob Herring wrote:
> On Wed, Nov 07, 2018 at 06:09:47PM +0100, Lukasz Luba wrote:
>> Thermal trip point gets new flag in DT: irq-mode.
>> Trip point may have a new explicit flag which indicate
>> IRQ support when the temperature is met (so the thermal framework
>> deos not need to set polling for it).
>> It is useful for 'passive' cooling trip point,
>> which now will not register for polling the temperature.
>>
>> Update documentation about irq-mode for trip points.
> 
> This patch should come before you use it.
OK, I will re-order the patch set in v3.
> 
>>
>> Cc: Zhang Rui <rui.zhang@intel.com>
>> Cc: Eduardo Valentin <edubezval@gmail.com>
>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Cc: Rob Herring <robh+dt@kernel.org>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: devicetree@vger.kernel.org
>> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
>> ---
>>   Documentation/devicetree/bindings/thermal/thermal.txt | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
>> index ca14ba9..bee21e3 100644
>> --- a/Documentation/devicetree/bindings/thermal/thermal.txt
>> +++ b/Documentation/devicetree/bindings/thermal/thermal.txt
>> @@ -90,6 +90,10 @@ Required properties:
>>   	"critical":	Hardware not reliable.
>>     Type: string
>>   
>> +- irq-mode:		A flag indicating that trip rises irq, so there is no
>> +  Type: bool		need of polling in thermal framework.
>> +  Size: one cell
> 
> Should be optional, right?
Yes, it is optional. I will mention about it in change v3.

Thank you for the review.

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 00/11] thermal: add new flag irq-mode for trip point
  2018-11-07 17:09 ` [PATCH v2 00/11] thermal: add new flag irq-mode for trip point Lukasz Luba
                     ` (10 preceding siblings ...)
       [not found]   ` <CGME20181107171046eucas1p1649bcf14a88ef9dd183724dde3a98f8c@eucas1p1.samsung.com>
@ 2018-12-05 15:08   ` Zhang Rui
  2018-12-05 15:33     ` Lukasz Luba
  11 siblings, 1 reply; 23+ messages in thread
From: Zhang Rui @ 2018-12-05 15:08 UTC (permalink / raw)
  To: Lukasz Luba, devicetree, linux-arm-kernel, linux-doc,
	linux-kernel, linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk

On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
> Hi all,
> 
> This patch set adds a new flag and mechanism in thermal trip points
> in
> DT.  The old implementation in thermal zone in DT sets the same
> configuration for all internal trip points. It does not work for all
> HW.  There are SoCs which support IRQs for some trip points (i.e.
> Exynos 4 has 4 trip points with IRQs). For additional one defined
> inside the thermal zone there is a need of 'polling'. When developer
> adds polling mode settings inside the thermal zone, all the trip
> points will be registered for polling, even those supporting IRQs,
> which does not make sense.

we have two timers, one for polling, and one for passive cooling.
I think we are talking about passive cooling timer only, right?
And the real problem is that we have multiple passive trip points and
only part of them support irq_mode, and we don't want to start the
passive polling timer for all of the passive trip points.

thanks,
rui

>  Thus, developers create workarounds, which
> are confusing for some other developers.  To workaround, 
> people declare some trip points as 'active' (those with IRQ support).
> It allows to bypass polling mode in thermal framework applied for 
> all thermal zone's trip points.
> 
> Thermal framework defines 4 types of trip points. The 'passive' means
> passive cooling using DVFS, 'active' is designed for fan and other
> devices actively changing the outside conditions. Therefore, a
> workaround
> mentioned earlier is confusing when someone does not know about the
> framework limitations.
> 
> This patch set tries to solve the issue by adding one flag inside the
> trip point: 'irq-mode;'.  The trip point 'passive' declared in DT
> with
> explicit flag 'irq-mode;' will not register itself as polling mode.
> Thermal framework will skip it during scheduling next read out work.
> The old global-polling-mode-configuration-inside-thermal-zone is
> still
> valid.  Patch set does not break existing design for trip points
> which
> do not have 'irq-mode' flag - they will use polling.
> 
> As an example please check patch #10 for Exynos4 SoC family, where
> there
> is 4 HW supported trip points and there is a need of 6. The rest 2
> are
> declared as 'passive' without 'irq-mode;' flag, which means polling
> mode needed for them.
> 
> Patch #1 is a small cleanup in thermal framework.
> 
> Change log:
> v2
> - changed description in cover letter
> - change commit messages according to Krzysztof comments
> - rebase on top of current mainline (v4.20-rc1)
> 
> Regards,
> Lukasz Luba
> 
> Lukasz Luba (11):
>   thermal: remove unused function parameter
>   thermal: add irq-mode configuration for trip point
>   thermal: add new sysfs file for irq-mode
>   Doc: thermal: new irq-mode for trip point
>   Doc: DT: thermal: new irq-mode for trip point
>   arm64: dts: exynos5433: add support for thermal trip irq-mode
>   arm64: dts: exynos7: add support for thermal trip irq-mode
>   arm: dts: exynos4: add support for thermal trip irq-mode
>   arm: dts: exynos5420: add support for thermal trip irq-mode
>   arm: dts: exynos5422: add support for thermal trip irq-mode
>   arm: dts: exynos5410: add support for thermal trip irq-mode
> 
>  .../devicetree/bindings/thermal/thermal.txt        |   7 ++
>  Documentation/thermal/sysfs-api.txt                |   9 ++
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  10 +-
>  arch/arm/boot/dts/exynos5410-odroidxu.dts          |  10 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  10 +-
>  arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi |  40 +++++---
>  arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi     | 105
> ++++++++++++++-------
>  .../arm64/boot/dts/exynos/exynos7-trip-points.dtsi |   8 ++
>  drivers/thermal/of-thermal.c                       |  17 ++++
>  drivers/thermal/thermal_core.c                     |  16 ++--
>  drivers/thermal/thermal_sysfs.c                    |  53 ++++++++++-
>  include/linux/thermal.h                            |   5 +
>  12 files changed, 226 insertions(+), 64 deletions(-)
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 02/11] thermal: add irq-mode configuration for trip point
  2018-11-07 17:09     ` [PATCH v2 02/11] thermal: add irq-mode configuration for trip point Lukasz Luba
@ 2018-12-05 15:09       ` Zhang Rui
  2018-12-06 19:18         ` Lukasz Luba
  0 siblings, 1 reply; 23+ messages in thread
From: Zhang Rui @ 2018-12-05 15:09 UTC (permalink / raw)
  To: Lukasz Luba, devicetree, linux-arm-kernel, linux-doc,
	linux-kernel, linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk

On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
> This patch adds support irq mode in trip point.
> When that flag is set in DT, there is no need for polling
> in thermal framework. Crossing the trip point will rise an IRQ.
> The naming convention for tip point 'type' can be confussing
> and 'passive' (whic is passive cooling) might be interpretted
> wrongly.
> 
> This mechanism prevents from missue and adds explicit setting
> for hardware which support interrupts for pre-configured temperature
> threshold.
> 
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 17 +++++++++++++++++
>  drivers/thermal/thermal_core.c | 10 ++++++++--
>  include/linux/thermal.h        |  5 +++++
>  3 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-
> thermal.c
> index 4bfdb4a..1a75946a 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -312,6 +312,20 @@ static int of_thermal_get_trip_type(struct
> thermal_zone_device *tz, int trip,
>  	return 0;
>  }
>  
> +static int
> +of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz, int
> trip,
> +			     bool *mode)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (trip >= data->ntrips || trip < 0)
> +		return -EDOM;
> +
> +	*mode = data->trips[trip].irq_mode;
> +
> +	return 0;
> +}
> +
>  static int of_thermal_get_trip_temp(struct thermal_zone_device *tz,
> int trip,
>  				    int *temp)
>  {
> @@ -394,6 +408,7 @@ static struct thermal_zone_device_ops
> of_thermal_ops = {
>  	.set_mode = of_thermal_set_mode,
>  
>  	.get_trip_type = of_thermal_get_trip_type,
> +	.get_trip_irq_mode = of_thermal_get_trip_irq_mode,
>  	.get_trip_temp = of_thermal_get_trip_temp,
>  	.set_trip_temp = of_thermal_set_trip_temp,
>  	.get_trip_hyst = of_thermal_get_trip_hyst,
> @@ -827,6 +842,8 @@ static int thermal_of_populate_trip(struct
> device_node *np,
>  		return ret;
>  	}
>  
> +	trip->irq_mode = of_property_read_bool(np, "irq-mode");
> +
>  	/* Required for cooling map matching */
>  	trip->np = np;
>  	of_node_get(np);
> diff --git a/drivers/thermal/thermal_core.c
> b/drivers/thermal/thermal_core.c
> index 39fc812..6d41e08 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -406,6 +406,7 @@ static void handle_critical_trips(struct
> thermal_zone_device *tz,
>  static void handle_thermal_trip(struct thermal_zone_device *tz, int
> trip)
>  {
>  	enum thermal_trip_type type;
> +	bool irq_mode = false;
>  
>  	/* Ignore disabled trip points */
>  	if (test_bit(trip, &tz->trips_disabled))
> @@ -419,9 +420,14 @@ static void handle_thermal_trip(struct
> thermal_zone_device *tz, int trip)
>  		handle_non_critical_trips(tz, trip);
>  	/*
>  	 * Alright, we handled this trip successfully.
> -	 * So, start monitoring again.
> +	 * So, start monitoring in polling mode if
> +	 * trip is not using irq HW support.
>  	 */
> -	monitor_thermal_zone(tz);
> +	if (tz->ops->get_trip_irq_mode)
> +		tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
> +
> +	if (!irq_mode)
> +		monitor_thermal_zone(tz);
>  }
>  
handle_thermal_trip() is called from thermal_zone_device_update(), and
it is invoked for every trip points.
say, you have a passive trip point 1 that supports irq_mode, and
another passive trip point 2 that does not support irq_mode,
monitor_thermal_zone() is still called in handle_thermal_trip(tz, 2),
and the passive timer will be activated anyway, do I miss something?

thanks,
rui

>  static void update_temperature(struct thermal_zone_device *tz)
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 5f4705f..b064565 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -103,6 +103,7 @@ struct thermal_zone_device_ops {
>  		enum thermal_device_mode);
>  	int (*get_trip_type) (struct thermal_zone_device *, int,
>  		enum thermal_trip_type *);
> +	int (*get_trip_irq_mode) (struct thermal_zone_device *, int,
> bool *);
>  	int (*get_trip_temp) (struct thermal_zone_device *, int, int
> *);
>  	int (*set_trip_temp) (struct thermal_zone_device *, int,
> int);
>  	int (*get_trip_hyst) (struct thermal_zone_device *, int, int
> *);
> @@ -196,6 +197,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_irq_mode_attrs;
>  	void *devdata;
>  	int trips;
>  	unsigned long trips_disabled;	/* bitmap for disabled
> trips */
> @@ -364,6 +366,8 @@ struct thermal_zone_of_device_ops {
>   * @temperature: temperature value in miliCelsius
>   * @hysteresis: relative hysteresis in miliCelsius
>   * @type: trip point type
> + * @irq_mode: to not use polling in framework set support of HW irq
> (which will
> + *	      be triggered when temperature reaches this level).
>   */
>  
>  struct thermal_trip {
> @@ -371,6 +375,7 @@ struct thermal_trip {
>  	int temperature;
>  	int hysteresis;
>  	enum thermal_trip_type type;
> +	bool irq_mode;
>  };
>  
>  /* Function declarations */

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 00/11] thermal: add new flag irq-mode for trip point
  2018-12-05 15:08   ` [PATCH v2 00/11] thermal: add new flag irq-mode for trip point Zhang Rui
@ 2018-12-05 15:33     ` Lukasz Luba
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Luba @ 2018-12-05 15:33 UTC (permalink / raw)
  To: Zhang Rui, devicetree, linux-arm-kernel, linux-doc, linux-kernel,
	linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk

Hi Rui,

On 12/5/18 4:08 PM, Zhang Rui wrote:
> On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
>> Hi all,
>>
>> This patch set adds a new flag and mechanism in thermal trip points
>> in
>> DT.  The old implementation in thermal zone in DT sets the same
>> configuration for all internal trip points. It does not work for all
>> HW.  There are SoCs which support IRQs for some trip points (i.e.
>> Exynos 4 has 4 trip points with IRQs). For additional one defined
>> inside the thermal zone there is a need of 'polling'. When developer
>> adds polling mode settings inside the thermal zone, all the trip
>> points will be registered for polling, even those supporting IRQs,
>> which does not make sense.
> 
> we have two timers, one for polling, and one for passive cooling.
> I think we are talking about passive cooling timer only, right?
> And the real problem is that we have multiple passive trip points and
> only part of them support irq_mode, and we don't want to start the
> passive polling timer for all of the passive trip points.
Yes exactly, we don't want to poll all of them by starting 'passive 
polling timer'.

Regards,
Lukasz
> 
> thanks,
> rui
> 
>>   Thus, developers create workarounds, which
>> are confusing for some other developers.  To workaround,
>> people declare some trip points as 'active' (those with IRQ support).
>> It allows to bypass polling mode in thermal framework applied for
>> all thermal zone's trip points.
>>
>> Thermal framework defines 4 types of trip points. The 'passive' means
>> passive cooling using DVFS, 'active' is designed for fan and other
>> devices actively changing the outside conditions. Therefore, a
>> workaround
>> mentioned earlier is confusing when someone does not know about the
>> framework limitations.
>>
>> This patch set tries to solve the issue by adding one flag inside the
>> trip point: 'irq-mode;'.  The trip point 'passive' declared in DT
>> with
>> explicit flag 'irq-mode;' will not register itself as polling mode.
>> Thermal framework will skip it during scheduling next read out work.
>> The old global-polling-mode-configuration-inside-thermal-zone is
>> still
>> valid.  Patch set does not break existing design for trip points
>> which
>> do not have 'irq-mode' flag - they will use polling.
>>
>> As an example please check patch #10 for Exynos4 SoC family, where
>> there
>> is 4 HW supported trip points and there is a need of 6. The rest 2
>> are
>> declared as 'passive' without 'irq-mode;' flag, which means polling
>> mode needed for them.
>>
>> Patch #1 is a small cleanup in thermal framework.
>>
>> Change log:
>> v2
>> - changed description in cover letter
>> - change commit messages according to Krzysztof comments
>> - rebase on top of current mainline (v4.20-rc1)
>>
>> Regards,
>> Lukasz Luba
>>
>> Lukasz Luba (11):
>>    thermal: remove unused function parameter
>>    thermal: add irq-mode configuration for trip point
>>    thermal: add new sysfs file for irq-mode
>>    Doc: thermal: new irq-mode for trip point
>>    Doc: DT: thermal: new irq-mode for trip point
>>    arm64: dts: exynos5433: add support for thermal trip irq-mode
>>    arm64: dts: exynos7: add support for thermal trip irq-mode
>>    arm: dts: exynos4: add support for thermal trip irq-mode
>>    arm: dts: exynos5420: add support for thermal trip irq-mode
>>    arm: dts: exynos5422: add support for thermal trip irq-mode
>>    arm: dts: exynos5410: add support for thermal trip irq-mode
>>
>>   .../devicetree/bindings/thermal/thermal.txt        |   7 ++
>>   Documentation/thermal/sysfs-api.txt                |   9 ++
>>   arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  10 +-
>>   arch/arm/boot/dts/exynos5410-odroidxu.dts          |  10 +-
>>   arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  10 +-
>>   arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi |  40 +++++---
>>   arch/arm64/boot/dts/exynos/exynos5433-tmu.dtsi     | 105
>> ++++++++++++++-------
>>   .../arm64/boot/dts/exynos/exynos7-trip-points.dtsi |   8 ++
>>   drivers/thermal/of-thermal.c                       |  17 ++++
>>   drivers/thermal/thermal_core.c                     |  16 ++--
>>   drivers/thermal/thermal_sysfs.c                    |  53 ++++++++++-
>>   include/linux/thermal.h                            |   5 +
>>   12 files changed, 226 insertions(+), 64 deletions(-)
>>
> 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 02/11] thermal: add irq-mode configuration for trip point
  2018-12-05 15:09       ` Zhang Rui
@ 2018-12-06 19:18         ` Lukasz Luba
  2018-12-06 19:55           ` Lukasz Luba
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Luba @ 2018-12-06 19:18 UTC (permalink / raw)
  To: Zhang Rui, devicetree, linux-arm-kernel, linux-doc, linux-kernel,
	linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk

Hi Rui,

On 12/5/18 4:09 PM, Zhang Rui wrote:
> On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
>> This patch adds support irq mode in trip point.
>> When that flag is set in DT, there is no need for polling
>> in thermal framework. Crossing the trip point will rise an IRQ.
>> The naming convention for tip point 'type' can be confussing
>> and 'passive' (whic is passive cooling) might be interpretted
>> wrongly.
>>
>> This mechanism prevents from missue and adds explicit setting
>> for hardware which support interrupts for pre-configured temperature
>> threshold.
>>
>> Cc: Zhang Rui <rui.zhang@intel.com>
>> Cc: Eduardo Valentin <edubezval@gmail.com>
>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
>> ---
>>   drivers/thermal/of-thermal.c   | 17 +++++++++++++++++
>>   drivers/thermal/thermal_core.c | 10 ++++++++--
>>   include/linux/thermal.h        |  5 +++++
>>   3 files changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-
>> thermal.c
>> index 4bfdb4a..1a75946a 100644
>> --- a/drivers/thermal/of-thermal.c
>> +++ b/drivers/thermal/of-thermal.c
>> @@ -312,6 +312,20 @@ static int of_thermal_get_trip_type(struct
>> thermal_zone_device *tz, int trip,
>>   	return 0;
>>   }
>>   
>> +static int
>> +of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz, int
>> trip,
>> +			     bool *mode)
>> +{
>> +	struct __thermal_zone *data = tz->devdata;
>> +
>> +	if (trip >= data->ntrips || trip < 0)
>> +		return -EDOM;
>> +
>> +	*mode = data->trips[trip].irq_mode;
>> +
>> +	return 0;
>> +}
>> +
>>   static int of_thermal_get_trip_temp(struct thermal_zone_device *tz,
>> int trip,
>>   				    int *temp)
>>   {
>> @@ -394,6 +408,7 @@ static struct thermal_zone_device_ops
>> of_thermal_ops = {
>>   	.set_mode = of_thermal_set_mode,
>>   
>>   	.get_trip_type = of_thermal_get_trip_type,
>> +	.get_trip_irq_mode = of_thermal_get_trip_irq_mode,
>>   	.get_trip_temp = of_thermal_get_trip_temp,
>>   	.set_trip_temp = of_thermal_set_trip_temp,
>>   	.get_trip_hyst = of_thermal_get_trip_hyst,
>> @@ -827,6 +842,8 @@ static int thermal_of_populate_trip(struct
>> device_node *np,
>>   		return ret;
>>   	}
>>   
>> +	trip->irq_mode = of_property_read_bool(np, "irq-mode");
>> +
>>   	/* Required for cooling map matching */
>>   	trip->np = np;
>>   	of_node_get(np);
>> diff --git a/drivers/thermal/thermal_core.c
>> b/drivers/thermal/thermal_core.c
>> index 39fc812..6d41e08 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -406,6 +406,7 @@ static void handle_critical_trips(struct
>> thermal_zone_device *tz,
>>   static void handle_thermal_trip(struct thermal_zone_device *tz, int
>> trip)
>>   {
>>   	enum thermal_trip_type type;
>> +	bool irq_mode = false;
>>   
>>   	/* Ignore disabled trip points */
>>   	if (test_bit(trip, &tz->trips_disabled))
>> @@ -419,9 +420,14 @@ static void handle_thermal_trip(struct
>> thermal_zone_device *tz, int trip)
>>   		handle_non_critical_trips(tz, trip);
>>   	/*
>>   	 * Alright, we handled this trip successfully.
>> -	 * So, start monitoring again.
>> +	 * So, start monitoring in polling mode if
>> +	 * trip is not using irq HW support.
>>   	 */
>> -	monitor_thermal_zone(tz);
>> +	if (tz->ops->get_trip_irq_mode)
>> +		tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
>> +
>> +	if (!irq_mode)
>> +		monitor_thermal_zone(tz);
>>   }
>>   
> handle_thermal_trip() is called from thermal_zone_device_update(), and
> it is invoked for every trip points.
> say, you have a passive trip point 1 that supports irq_mode, and
> another passive trip point 2 that does not support irq_mode,
> monitor_thermal_zone() is still called in handle_thermal_trip(tz, 2),
> and the passive timer will be activated anyway, do I miss something?
Yes, the passive timer will be activated in your example. It is correct
behavior and does not break anything.
case 1: there is 'k' passive trip points which have irq_mode and 1
additional which does not have 'irq_mode', the framework will start
polling but skip check for those 'k' trip points.
case 2: all of the passive trip points have irq_mode set, the framework
will not register 'scheduled_work' because it will not call 
'monitor_thermal_zone()'.
This is the case of most Exynos platforms, but there is one exception 
which has 'case 1' with 2 trip points not supporting irq_mode.

Regards,
Lukasz

> 
> thanks,
> rui
> 
>>   static void update_temperature(struct thermal_zone_device *tz)
>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>> index 5f4705f..b064565 100644
>> --- a/include/linux/thermal.h
>> +++ b/include/linux/thermal.h
>> @@ -103,6 +103,7 @@ struct thermal_zone_device_ops {
>>   		enum thermal_device_mode);
>>   	int (*get_trip_type) (struct thermal_zone_device *, int,
>>   		enum thermal_trip_type *);
>> +	int (*get_trip_irq_mode) (struct thermal_zone_device *, int,
>> bool *);
>>   	int (*get_trip_temp) (struct thermal_zone_device *, int, int
>> *);
>>   	int (*set_trip_temp) (struct thermal_zone_device *, int,
>> int);
>>   	int (*get_trip_hyst) (struct thermal_zone_device *, int, int
>> *);
>> @@ -196,6 +197,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_irq_mode_attrs;
>>   	void *devdata;
>>   	int trips;
>>   	unsigned long trips_disabled;	/* bitmap for disabled
>> trips */
>> @@ -364,6 +366,8 @@ struct thermal_zone_of_device_ops {
>>    * @temperature: temperature value in miliCelsius
>>    * @hysteresis: relative hysteresis in miliCelsius
>>    * @type: trip point type
>> + * @irq_mode: to not use polling in framework set support of HW irq
>> (which will
>> + *	      be triggered when temperature reaches this level).
>>    */
>>   
>>   struct thermal_trip {
>> @@ -371,6 +375,7 @@ struct thermal_trip {
>>   	int temperature;
>>   	int hysteresis;
>>   	enum thermal_trip_type type;
>> +	bool irq_mode;
>>   };
>>   
>>   /* Function declarations */
> 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 02/11] thermal: add irq-mode configuration for trip point
  2018-12-06 19:18         ` Lukasz Luba
@ 2018-12-06 19:55           ` Lukasz Luba
  2019-01-10 14:20             ` Zhang Rui
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Luba @ 2018-12-06 19:55 UTC (permalink / raw)
  To: Zhang Rui, devicetree, linux-arm-kernel, linux-doc, linux-kernel,
	linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk



On 12/6/18 8:18 PM, Lukasz Luba wrote:
> Hi Rui,
> 
> On 12/5/18 4:09 PM, Zhang Rui wrote:
>> On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
>>> This patch adds support irq mode in trip point.
>>> When that flag is set in DT, there is no need for polling
>>> in thermal framework. Crossing the trip point will rise an IRQ.
>>> The naming convention for tip point 'type' can be confussing
>>> and 'passive' (whic is passive cooling) might be interpretted
>>> wrongly.
>>>
>>> This mechanism prevents from missue and adds explicit setting
>>> for hardware which support interrupts for pre-configured temperature
>>> threshold.
>>>
>>> Cc: Zhang Rui <rui.zhang@intel.com>
>>> Cc: Eduardo Valentin <edubezval@gmail.com>
>>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>>> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
>>> ---
>>>   drivers/thermal/of-thermal.c   | 17 +++++++++++++++++
>>>   drivers/thermal/thermal_core.c | 10 ++++++++--
>>>   include/linux/thermal.h        |  5 +++++
>>>   3 files changed, 30 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-
>>> thermal.c
>>> index 4bfdb4a..1a75946a 100644
>>> --- a/drivers/thermal/of-thermal.c
>>> +++ b/drivers/thermal/of-thermal.c
>>> @@ -312,6 +312,20 @@ static int of_thermal_get_trip_type(struct
>>> thermal_zone_device *tz, int trip,
>>>       return 0;
>>>   }
>>> +static int
>>> +of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz, int
>>> trip,
>>> +                 bool *mode)
>>> +{
>>> +    struct __thermal_zone *data = tz->devdata;
>>> +
>>> +    if (trip >= data->ntrips || trip < 0)
>>> +        return -EDOM;
>>> +
>>> +    *mode = data->trips[trip].irq_mode;
>>> +
>>> +    return 0;
>>> +}
>>> +
>>>   static int of_thermal_get_trip_temp(struct thermal_zone_device *tz,
>>> int trip,
>>>                       int *temp)
>>>   {
>>> @@ -394,6 +408,7 @@ static struct thermal_zone_device_ops
>>> of_thermal_ops = {
>>>       .set_mode = of_thermal_set_mode,
>>>       .get_trip_type = of_thermal_get_trip_type,
>>> +    .get_trip_irq_mode = of_thermal_get_trip_irq_mode,
>>>       .get_trip_temp = of_thermal_get_trip_temp,
>>>       .set_trip_temp = of_thermal_set_trip_temp,
>>>       .get_trip_hyst = of_thermal_get_trip_hyst,
>>> @@ -827,6 +842,8 @@ static int thermal_of_populate_trip(struct
>>> device_node *np,
>>>           return ret;
>>>       }
>>> +    trip->irq_mode = of_property_read_bool(np, "irq-mode");
>>> +
>>>       /* Required for cooling map matching */
>>>       trip->np = np;
>>>       of_node_get(np);
>>> diff --git a/drivers/thermal/thermal_core.c
>>> b/drivers/thermal/thermal_core.c
>>> index 39fc812..6d41e08 100644
>>> --- a/drivers/thermal/thermal_core.c
>>> +++ b/drivers/thermal/thermal_core.c
>>> @@ -406,6 +406,7 @@ static void handle_critical_trips(struct
>>> thermal_zone_device *tz,
>>>   static void handle_thermal_trip(struct thermal_zone_device *tz, int
>>> trip)
>>>   {
>>>       enum thermal_trip_type type;
>>> +    bool irq_mode = false;
>>>       /* Ignore disabled trip points */
>>>       if (test_bit(trip, &tz->trips_disabled))
>>> @@ -419,9 +420,14 @@ static void handle_thermal_trip(struct
>>> thermal_zone_device *tz, int trip)
>>>           handle_non_critical_trips(tz, trip);
>>>       /*
>>>        * Alright, we handled this trip successfully.
>>> -     * So, start monitoring again.
>>> +     * So, start monitoring in polling mode if
>>> +     * trip is not using irq HW support.
>>>        */
>>> -    monitor_thermal_zone(tz);
>>> +    if (tz->ops->get_trip_irq_mode)
>>> +        tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
>>> +
>>> +    if (!irq_mode)
>>> +        monitor_thermal_zone(tz);
>>>   }
>> handle_thermal_trip() is called from thermal_zone_device_update(), and
>> it is invoked for every trip points.
>> say, you have a passive trip point 1 that supports irq_mode, and
>> another passive trip point 2 that does not support irq_mode,
>> monitor_thermal_zone() is still called in handle_thermal_trip(tz, 2),
>> and the passive timer will be activated anyway, do I miss something?
> Yes, the passive timer will be activated in your example. It is correct
> behavior and does not break anything.
> case 1: there is 'k' passive trip points which have irq_mode and 1
> additional which does not have 'irq_mode', the framework will start
> polling but skip check for those 'k' trip points.
> case 2: all of the passive trip points have irq_mode set, the framework
> will not register 'scheduled_work' because it will not call 
> 'monitor_thermal_zone()'.
> This is the case of most Exynos platforms, but there is one exception 
> which has 'case 1' with 2 trip points not supporting irq_mode.
Do you suggest to cover the 'case 1'?
It would be possible after adding a new enum THERMAL_FRAMEWORK_POLL, 
then function:
thermal_zone_device_check() will call
thermal_zone_device_update(tz, THERMAL_FRAMEWORK_POLL)
and in handle_thermal_trip() implement something like:
--------------8<----------------
static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
{
	enum thermal_trip_type type;
	bool irq_mode = false;

	/* Ignore disabled trip points */
	if (test_bit(trip, &tz->trips_disabled))
		return;

	if (tz->ops->get_trip_irq_mode)
		tz->ops->get_trip_irq_mode(tz, trip, &irq_mode)

	if (tz->notify_event == THERMAL_FRAMEWORK_POLL && irq_mode)
		return;
...

	if (!irq_mode)
		monitor_thermal_zone(tz);
}

---------->8-----------------------

I could implement it in v3 if you don't see that it add too much of mess 
and agree for this approach.

Regards,
Lukasz

> 
> Regards,
> Lukasz
> 
>>
>> thanks,
>> rui
>>
>>>   static void update_temperature(struct thermal_zone_device *tz)
>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>> index 5f4705f..b064565 100644
>>> --- a/include/linux/thermal.h
>>> +++ b/include/linux/thermal.h
>>> @@ -103,6 +103,7 @@ struct thermal_zone_device_ops {
>>>           enum thermal_device_mode);
>>>       int (*get_trip_type) (struct thermal_zone_device *, int,
>>>           enum thermal_trip_type *);
>>> +    int (*get_trip_irq_mode) (struct thermal_zone_device *, int,
>>> bool *);
>>>       int (*get_trip_temp) (struct thermal_zone_device *, int, int
>>> *);
>>>       int (*set_trip_temp) (struct thermal_zone_device *, int,
>>> int);
>>>       int (*get_trip_hyst) (struct thermal_zone_device *, int, int
>>> *);
>>> @@ -196,6 +197,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_irq_mode_attrs;
>>>       void *devdata;
>>>       int trips;
>>>       unsigned long trips_disabled;    /* bitmap for disabled
>>> trips */
>>> @@ -364,6 +366,8 @@ struct thermal_zone_of_device_ops {
>>>    * @temperature: temperature value in miliCelsius
>>>    * @hysteresis: relative hysteresis in miliCelsius
>>>    * @type: trip point type
>>> + * @irq_mode: to not use polling in framework set support of HW irq
>>> (which will
>>> + *          be triggered when temperature reaches this level).
>>>    */
>>>   struct thermal_trip {
>>> @@ -371,6 +375,7 @@ struct thermal_trip {
>>>       int temperature;
>>>       int hysteresis;
>>>       enum thermal_trip_type type;
>>> +    bool irq_mode;
>>>   };
>>>   /* Function declarations */
>>
>>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 02/11] thermal: add irq-mode configuration for trip point
  2018-12-06 19:55           ` Lukasz Luba
@ 2019-01-10 14:20             ` Zhang Rui
  0 siblings, 0 replies; 23+ messages in thread
From: Zhang Rui @ 2019-01-10 14:20 UTC (permalink / raw)
  To: Lukasz Luba, devicetree, linux-arm-kernel, linux-doc,
	linux-kernel, linux-pm
  Cc: edubezval, daniel.lezcano, robh+dt, mark.rutland, corbet,
	b.zolnierkie, krzk

Hi, Lukasz,

On 四, 2018-12-06 at 20:55 +0100, Lukasz Luba wrote:
> 
> On 12/6/18 8:18 PM, Lukasz Luba wrote:
> > 
> > Hi Rui,
> > 
> > On 12/5/18 4:09 PM, Zhang Rui wrote:
> > > 
> > > On 三, 2018-11-07 at 18:09 +0100, Lukasz Luba wrote:
> > > > 
> > > > This patch adds support irq mode in trip point.
> > > > When that flag is set in DT, there is no need for polling
> > > > in thermal framework. Crossing the trip point will rise an IRQ.
> > > > The naming convention for tip point 'type' can be confussing
> > > > and 'passive' (whic is passive cooling) might be interpretted
> > > > wrongly.
> > > > 
> > > > This mechanism prevents from missue and adds explicit setting
> > > > for hardware which support interrupts for pre-configured
> > > > temperature
> > > > threshold.
> > > > 
> > > > Cc: Zhang Rui <rui.zhang@intel.com>
> > > > Cc: Eduardo Valentin <edubezval@gmail.com>
> > > > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > > > Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
> > > > ---
> > > >   drivers/thermal/of-thermal.c   | 17 +++++++++++++++++
> > > >   drivers/thermal/thermal_core.c | 10 ++++++++--
> > > >   include/linux/thermal.h        |  5 +++++
> > > >   3 files changed, 30 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-
> > > > thermal.c
> > > > index 4bfdb4a..1a75946a 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -312,6 +312,20 @@ static int of_thermal_get_trip_type(struct
> > > > thermal_zone_device *tz, int trip,
> > > >       return 0;
> > > >   }
> > > > +static int
> > > > +of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz,
> > > > int
> > > > trip,
> > > > +                 bool *mode)
> > > > +{
> > > > +    struct __thermal_zone *data = tz->devdata;
> > > > +
> > > > +    if (trip >= data->ntrips || trip < 0)
> > > > +        return -EDOM;
> > > > +
> > > > +    *mode = data->trips[trip].irq_mode;
> > > > +
> > > > +    return 0;
> > > > +}
> > > > +
> > > >   static int of_thermal_get_trip_temp(struct
> > > > thermal_zone_device *tz,
> > > > int trip,
> > > >                       int *temp)
> > > >   {
> > > > @@ -394,6 +408,7 @@ static struct thermal_zone_device_ops
> > > > of_thermal_ops = {
> > > >       .set_mode = of_thermal_set_mode,
> > > >       .get_trip_type = of_thermal_get_trip_type,
> > > > +    .get_trip_irq_mode = of_thermal_get_trip_irq_mode,
> > > >       .get_trip_temp = of_thermal_get_trip_temp,
> > > >       .set_trip_temp = of_thermal_set_trip_temp,
> > > >       .get_trip_hyst = of_thermal_get_trip_hyst,
> > > > @@ -827,6 +842,8 @@ static int thermal_of_populate_trip(struct
> > > > device_node *np,
> > > >           return ret;
> > > >       }
> > > > +    trip->irq_mode = of_property_read_bool(np, "irq-mode");
> > > > +
> > > >       /* Required for cooling map matching */
> > > >       trip->np = np;
> > > >       of_node_get(np);
> > > > diff --git a/drivers/thermal/thermal_core.c
> > > > b/drivers/thermal/thermal_core.c
> > > > index 39fc812..6d41e08 100644
> > > > --- a/drivers/thermal/thermal_core.c
> > > > +++ b/drivers/thermal/thermal_core.c
> > > > @@ -406,6 +406,7 @@ static void handle_critical_trips(struct
> > > > thermal_zone_device *tz,
> > > >   static void handle_thermal_trip(struct thermal_zone_device
> > > > *tz, int
> > > > trip)
> > > >   {
> > > >       enum thermal_trip_type type;
> > > > +    bool irq_mode = false;
> > > >       /* Ignore disabled trip points */
> > > >       if (test_bit(trip, &tz->trips_disabled))
> > > > @@ -419,9 +420,14 @@ static void handle_thermal_trip(struct
> > > > thermal_zone_device *tz, int trip)
> > > >           handle_non_critical_trips(tz, trip);
> > > >       /*
> > > >        * Alright, we handled this trip successfully.
> > > > -     * So, start monitoring again.
> > > > +     * So, start monitoring in polling mode if
> > > > +     * trip is not using irq HW support.
> > > >        */
> > > > -    monitor_thermal_zone(tz);
> > > > +    if (tz->ops->get_trip_irq_mode)
> > > > +        tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
> > > > +
> > > > +    if (!irq_mode)
> > > > +        monitor_thermal_zone(tz);
> > > >   }
> > > handle_thermal_trip() is called from
> > > thermal_zone_device_update(), and
> > > it is invoked for every trip points.
> > > say, you have a passive trip point 1 that supports irq_mode, and
> > > another passive trip point 2 that does not support irq_mode,
> > > monitor_thermal_zone() is still called in handle_thermal_trip(tz,
> > > 2),
> > > and the passive timer will be activated anyway, do I miss
> > > something?

sorry that I missed this thread.

> > Yes, the passive timer will be activated in your example. It is
> > correct
> > behavior and does not break anything.
> > case 1: there is 'k' passive trip points which have irq_mode and 1
> > additional which does not have 'irq_mode', the framework will start
> > polling but skip check for those 'k' trip points.
> > case 2: all of the passive trip points have irq_mode set, the
> > framework
> > will not register 'scheduled_work' because it will not call 
> > 'monitor_thermal_zone()'.
> > This is the case of most Exynos platforms, but there is one
> > exception 
> > which has 'case 1' with 2 trip points not supporting irq_mode.
> Do you suggest to cover the 'case 1'?

So this solution does not cover case 1.
And for case 2, why not set passive_delay to 0? are they sharing the
same DT file?

> It would be possible after adding a new enum THERMAL_FRAMEWORK_POLL, 
> then function:

hmmm, I think we can
1. use tz->passive to count the passive trip points that need passive
polling.
2. count tz->passive properly in the governors
3. always do passive polling when tz->passive > 0.

This will cover both cases, right?

some sample code to handle this in step_wise governor attached below,

what do you think?

thanks,
rui

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index ee047ca..59d9a1d 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -121,8 +121,15 @@ static void update_passive_instance(struct
thermal_zone_device *tz,
         * If value is +1, activate a passive instance.
         * If value is -1, deactivate a passive instance.
         */
-       if (type == THERMAL_TRIP_PASSIVE || type == THERMAL_TRIPS_NONE)
-               tz->passive += value;
+       if (type != THERMAL_TRIP_PASSIVE && type != THERMAL_TRIPS_NONE)
+               return;
+       if (tz->ops->get_trip_irq_mode) {
+               if (tz->ops->get_trip_irq_mode(tz, trip, &irq_mode))
+                               return;
+               if (irq_mode)
+                               return;
+       }
+       tz->passive += value;
 }


> thermal_zone_device_check() will call
> thermal_zone_device_update(tz, THERMAL_FRAMEWORK_POLL)
> and in handle_thermal_trip() implement something like:
> --------------8<----------------
> static void handle_thermal_trip(struct thermal_zone_device *tz, int
> trip)
> {
> 	enum thermal_trip_type type;
> 	bool irq_mode = false;
> 
> 	/* Ignore disabled trip points */
> 	if (test_bit(trip, &tz->trips_disabled))
> 		return;
> 
> 	if (tz->ops->get_trip_irq_mode)
> 		tz->ops->get_trip_irq_mode(tz, trip, &irq_mode)
> 
> 	if (tz->notify_event == THERMAL_FRAMEWORK_POLL && irq_mode)
> 		return;
> ...
> 
> 	if (!irq_mode)
> 		monitor_thermal_zone(tz);
> }
> 
> ---------->8-----------------------
> 
> I could implement it in v3 if you don't see that it add too much of
> mess 
> and agree for this approach.
> 
> Regards,
> Lukasz
> 
> > 
> > 
> > Regards,
> > Lukasz
> > 
> > > 
> > > 
> > > thanks,
> > > rui
> > > 
> > > > 
> > > >   static void update_temperature(struct thermal_zone_device
> > > > *tz)
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 5f4705f..b064565 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -103,6 +103,7 @@ struct thermal_zone_device_ops {
> > > >           enum thermal_device_mode);
> > > >       int (*get_trip_type) (struct thermal_zone_device *, int,
> > > >           enum thermal_trip_type *);
> > > > +    int (*get_trip_irq_mode) (struct thermal_zone_device *,
> > > > int,
> > > > bool *);
> > > >       int (*get_trip_temp) (struct thermal_zone_device *, int,
> > > > int
> > > > *);
> > > >       int (*set_trip_temp) (struct thermal_zone_device *, int,
> > > > int);
> > > >       int (*get_trip_hyst) (struct thermal_zone_device *, int,
> > > > int
> > > > *);
> > > > @@ -196,6 +197,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_irq_mode_attrs;
> > > >       void *devdata;
> > > >       int trips;
> > > >       unsigned long trips_disabled;    /* bitmap for disabled
> > > > trips */
> > > > @@ -364,6 +366,8 @@ struct thermal_zone_of_device_ops {
> > > >    * @temperature: temperature value in miliCelsius
> > > >    * @hysteresis: relative hysteresis in miliCelsius
> > > >    * @type: trip point type
> > > > + * @irq_mode: to not use polling in framework set support of
> > > > HW irq
> > > > (which will
> > > > + *          be triggered when temperature reaches this level).
> > > >    */
> > > >   struct thermal_trip {
> > > > @@ -371,6 +375,7 @@ struct thermal_trip {
> > > >       int temperature;
> > > >       int hysteresis;
> > > >       enum thermal_trip_type type;
> > > > +    bool irq_mode;
> > > >   };
> > > >   /* Function declarations */
> > > 

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-01-10 14:20 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20181107171019eucas1p1fcb1f44e00265434548d901479f2ea94@eucas1p1.samsung.com>
2018-11-07 17:09 ` [PATCH v2 00/11] thermal: add new flag irq-mode for trip point Lukasz Luba
     [not found]   ` <CGME20181107171022eucas1p1c2431f0561d9b1357ab569ab77deca34@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 01/11] thermal: remove unused function parameter Lukasz Luba
     [not found]   ` <CGME20181107171036eucas1p13253d56b463c8f888ab8f8e418635297@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 02/11] thermal: add irq-mode configuration for trip point Lukasz Luba
2018-12-05 15:09       ` Zhang Rui
2018-12-06 19:18         ` Lukasz Luba
2018-12-06 19:55           ` Lukasz Luba
2019-01-10 14:20             ` Zhang Rui
     [not found]   ` <CGME20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 03/11] thermal: add new sysfs file for irq-mode Lukasz Luba
     [not found]   ` <CGME20181107171038eucas1p1eb5dce12a1f5f7a3587f82f8396fa075@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 04/11] Doc: thermal: new irq-mode for trip point Lukasz Luba
     [not found]   ` <CGME20181107171039eucas1p2227bd4bc573fd0d2a3a97986004be16b@eucas1p2.samsung.com>
2018-11-07 17:09     ` [PATCH v2 05/11] Doc: DT: " Lukasz Luba
2018-11-12  8:51       ` Krzysztof Kozlowski
2018-11-13 10:06         ` Lukasz Luba
     [not found]       ` <5bea0ecd.1c69fb81.d5613.1c9e@mx.google.com>
2018-11-13 10:13         ` Lukasz Luba
     [not found]   ` <CGME20181107171041eucas1p1a3cf91435b9071fd6e6f84101ebbcd9f@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 06/11] arm64: dts: exynos5433: add support for thermal trip irq-mode Lukasz Luba
2018-11-12  9:00       ` Krzysztof Kozlowski
2018-11-13 10:10         ` Lukasz Luba
     [not found]   ` <CGME20181107171042eucas1p1675eb589f3951e516461a0a775ee87da@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 07/11] arm64: dts: exynos7: " Lukasz Luba
     [not found]   ` <CGME20181107171043eucas1p16be3fa901c7bceb129c70fc81dba6e48@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 08/11] arm: dts: exynos4: " Lukasz Luba
     [not found]   ` <CGME20181107171044eucas1p198434e21cf21ee754302615a6a8f3c20@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 09/11] arm: dts: exynos5420: " Lukasz Luba
     [not found]   ` <CGME20181107171045eucas1p26ec5feb1b2a397971c919592f6d87b40@eucas1p2.samsung.com>
2018-11-07 17:09     ` [PATCH v2 10/11] arm: dts: exynos5422: " Lukasz Luba
     [not found]   ` <CGME20181107171046eucas1p1649bcf14a88ef9dd183724dde3a98f8c@eucas1p1.samsung.com>
2018-11-07 17:09     ` [PATCH v2 11/11] arm: dts: exynos5410: " Lukasz Luba
2018-12-05 15:08   ` [PATCH v2 00/11] thermal: add new flag irq-mode for trip point Zhang Rui
2018-12-05 15:33     ` Lukasz Luba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).