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
Clean unused parameter from internal framework function.
Cc: Zhang Rui <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
Patch adds show functions for irq-mode feature.
It allocates new attributes and extends the old list.
Cc: Zhang Rui <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
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 <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Lukasz Luba <[email protected]>
---
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
On Wed, 7 Nov 2018 at 18:10, Lukasz Luba <[email protected]> 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 <[email protected]>
> Cc: Eduardo Valentin <[email protected]>
> Cc: Daniel Lezcano <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: [email protected]
> Signed-off-by: Lukasz Luba <[email protected]>
> ---
> 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
>
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 <[email protected]> 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 <[email protected]>
> Cc: Krzysztof Kozlowski <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Lukasz Luba <[email protected]>
> ---
> 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
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 <[email protected]> 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 <[email protected]>
>> Cc: Eduardo Valentin <[email protected]>
>> Cc: Daniel Lezcano <[email protected]>
>> Cc: Rob Herring <[email protected]>
>> Cc: Mark Rutland <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Lukasz Luba <[email protected]>
>> ---
>> 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
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 <[email protected]> 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 <[email protected]>
>> Cc: Krzysztof Kozlowski <[email protected]>
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Signed-off-by: Lukasz Luba <[email protected]>
>> ---
>> 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
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 <[email protected]>
>> Cc: Eduardo Valentin <[email protected]>
>> Cc: Daniel Lezcano <[email protected]>
>> Cc: Rob Herring <[email protected]>
>> Cc: Mark Rutland <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Lukasz Luba <[email protected]>
>> ---
>> 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
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(-)
>
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 <[email protected]>
> Cc: Eduardo Valentin <[email protected]>
> Cc: Daniel Lezcano <[email protected]>
> Signed-off-by: Lukasz Luba <[email protected]>
> ---
> 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 */
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(-)
>>
>
>
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 <[email protected]>
>> Cc: Eduardo Valentin <[email protected]>
>> Cc: Daniel Lezcano <[email protected]>
>> Signed-off-by: Lukasz Luba <[email protected]>
>> ---
>> 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 */
>
>
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 <[email protected]>
>>> Cc: Eduardo Valentin <[email protected]>
>>> Cc: Daniel Lezcano <[email protected]>
>>> Signed-off-by: Lukasz Luba <[email protected]>
>>> ---
>>> 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 */
>>
>>
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 <[email protected]>
> > > > Cc: Eduardo Valentin <[email protected]>
> > > > Cc: Daniel Lezcano <[email protected]>
> > > > Signed-off-by: Lukasz Luba <[email protected]>
> > > > ---
> > > > 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 */
> > >