Skip to contentSkip to conversation

thermal/core: Rename passive_delay and polling_delay with units

PATCH Superseded Daniel Lezcano 3 participants 10 messages Dec 2, 2020 – Dec 15, 2020 Thermal

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 thermal/core: Rename passive_delay and polling_delay with units

Set the scene to directly store the delays under their jiffies form. Add to the variable name the 'ms' suffix.

---
 drivers/thermal/thermal_core.c  | 10 +++++-----
 drivers/thermal/thermal_of.c    |  8 ++++----
 drivers/thermal/thermal_sysfs.c |  6 +++---
 include/linux/thermal.h         |  8 ++++----
 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/thermal/thermal_core.c +5 -5
index 90e38cc199f4..53f55ceca220 100644
@@ -317,9 +317,9 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
 	mutex_lock(&tz->lock);
 
 	if (!stop && tz->passive)
-		thermal_zone_device_set_polling(tz, tz->passive_delay);
-	else if (!stop && tz->polling_delay)
-		thermal_zone_device_set_polling(tz, tz->polling_delay);
+		thermal_zone_device_set_polling(tz, tz->passive_delay_ms);
+	else if (!stop && tz->polling_delay_ms)
+		thermal_zone_device_set_polling(tz, tz->polling_delay_ms);
 	else
 		thermal_zone_device_set_polling(tz, 0);
 
@@ -1340,8 +1340,8 @@ thermal_zone_device_register(const char *type, int trips, int mask,
 	tz->device.class = &thermal_class;
 	tz->devdata = devdata;
 	tz->trips = trips;
-	tz->passive_delay = passive_delay;
-	tz->polling_delay = polling_delay;
+	tz->passive_delay_ms = passive_delay;
+	tz->polling_delay_ms = polling_delay;
 
 	/* sys I/F */
 	/* Add nodes that are always present via .groups */
drivers/thermal/thermal_of.c +4 -4
index 69ef12f852b7..ebec4a8a8b5a 100644
@@ -865,14 +865,14 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)
 		pr_err("%pOFn: missing polling-delay-passive property\n", np);
 		goto free_tz;
 	}
-	tz->passive_delay = prop;
+	tz->passive_delay_ms = prop;
 
 	ret = of_property_read_u32(np, "polling-delay", &prop);
 	if (ret < 0) {
 		pr_err("%pOFn: missing polling-delay property\n", np);
 		goto free_tz;
 	}
-	tz->polling_delay = prop;
+	tz->polling_delay_ms = prop;
 
 	/*
 	 * REVIST: for now, the thermal framework supports only
@@ -1085,8 +1085,8 @@ int __init of_parse_thermal_zones(void)
 		zone = thermal_zone_device_register(child->name, tz->ntrips,
 						    mask, tz,
 						    ops, tzp,
-						    tz->passive_delay,
-						    tz->polling_delay);
+						    tz->passive_delay_ms,
+						    tz->polling_delay_ms);
 		if (IS_ERR(zone)) {
 			pr_err("Failed to build %pOFn zone %ld\n", child,
 			       PTR_ERR(zone));
drivers/thermal/thermal_sysfs.c +3 -3
index 0866e949339b..f465462d8aa1 100644
@@ -233,12 +233,12 @@ passive_store(struct device *dev, struct device_attribute *attr,
 		return -EINVAL;
 
 	if (state && !tz->forced_passive) {
-		if (!tz->passive_delay)
-			tz->passive_delay = 1000;
+		if (!tz->passive_delay_ms)
+			tz->passive_delay_ms = 1000;
 		thermal_zone_device_rebind_exception(tz, "Processor",
 						     sizeof("Processor"));
 	} else if (!state && tz->forced_passive) {
-		tz->passive_delay = 0;
+		tz->passive_delay_ms = 0;
 		thermal_zone_device_unbind_exception(tz, "Processor",
 						     sizeof("Processor"));
 	}
include/linux/thermal.h +4 -4
index d07ea27e72a9..230d451bf335 100644
@@ -116,9 +116,9 @@ struct thermal_cooling_device {
  * @devdata:	private pointer for device private data
  * @trips:	number of trip points the thermal zone supports
  * @trips_disabled;	bitmap for disabled trips
- * @passive_delay:	number of milliseconds to wait between polls when
+ * @passive_delay_ms:	number of milliseconds to wait between polls when
  *			performing passive cooling.
- * @polling_delay:	number of milliseconds to wait between polls when
+ * @polling_delay_ms:	number of milliseconds to wait between polls when
  *			checking whether trip points have been crossed (0 for
  *			interrupt driven systems)
  * @temperature:	current temperature.  This is only for core code,
@@ -159,8 +159,8 @@ struct thermal_zone_device {
 	void *devdata;
 	int trips;
 	unsigned long trips_disabled;	/* bitmap for disabled trips */
-	int passive_delay;
-	int polling_delay;
+	int passive_delay_ms;
+	int polling_delay_ms;
 	int temperature;
 	int last_temperature;
 	int emul_temperature;
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/4 thermal/core: Precompute the jiffies

The delays are stored in ms units and when the polling function is called this delay is converted into jiffies at each call.

Instead of doing the conversion again and again, compute the jiffies at init time and use the value directly when setting the polling.

---
 drivers/thermal/thermal_core.c  |  5 +++--
 drivers/thermal/thermal_core.h  | 18 ++++++++++++++++++
 drivers/thermal/thermal_sysfs.c |  4 ++--
 include/linux/thermal.h         |  7 +++++++
 4 files changed, 30 insertions(+), 4 deletions(-)
drivers/thermal/thermal_core.c +3 -2
index 53f55ceca220..3111ca2c87a1 100644
@@ -1340,8 +1340,9 @@ thermal_zone_device_register(const char *type, int trips, int mask,
 	tz->device.class = &thermal_class;
 	tz->devdata = devdata;
 	tz->trips = trips;
-	tz->passive_delay_ms = passive_delay;
-	tz->polling_delay_ms = polling_delay;
+
+	thermal_zone_set_passive_delay(tz, passive_delay);
+	thermal_zone_set_polling_delay(tz, polling_delay);
 
 	/* sys I/F */
 	/* Add nodes that are always present via .groups */
drivers/thermal/thermal_core.h +18 -0
index 8df600fa7b79..2c9551ed5ef8 100644
@@ -128,6 +128,24 @@ int thermal_build_list_of_policies(char *buf);
 /* Helpers */
 void thermal_zone_set_trips(struct thermal_zone_device *tz);
 
+static inline void thermal_zone_set_passive_delay(
+	struct thermal_zone_device *tz, int delay_ms)
+{
+	tz->passive_delay_ms = delay_ms;
+	tz->passive_delay_jiffies = msecs_to_jiffies(delay_ms);
+	if (delay_ms > 1000)
+		tz->passive_delay_jiffies = round_jiffies(tz->passive_delay_jiffies);
+}
+
+static inline void thermal_zone_set_polling_delay(
+	struct thermal_zone_device *tz, int delay_ms)
+{
+	tz->polling_delay_ms = delay_ms;
+	tz->polling_delay_jiffies = msecs_to_jiffies(delay_ms);
+	if (delay_ms > 1000)
+		tz->polling_delay_jiffies = round_jiffies(tz->polling_delay_jiffies);
+}
+
 /* sysfs I/F */
 int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
 void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
drivers/thermal/thermal_sysfs.c +2 -2
index f465462d8aa1..9598b288a0a1 100644
@@ -234,11 +234,11 @@ passive_store(struct device *dev, struct device_attribute *attr,
 
 	if (state && !tz->forced_passive) {
 		if (!tz->passive_delay_ms)
-			tz->passive_delay_ms = 1000;
+			thermal_zone_set_passive_delay(tz, 1000);
 		thermal_zone_device_rebind_exception(tz, "Processor",
 						     sizeof("Processor"));
 	} else if (!state && tz->forced_passive) {
-		tz->passive_delay_ms = 0;
+		thermal_zone_set_passive_delay(tz, 0);
 		thermal_zone_device_unbind_exception(tz, "Processor",
 						     sizeof("Processor"));
 	}
include/linux/thermal.h +7 -0
index 230d451bf335..5dd9bdb6c6ad 100644
@@ -118,9 +118,14 @@ struct thermal_cooling_device {
  * @trips_disabled;	bitmap for disabled trips
  * @passive_delay_ms:	number of milliseconds to wait between polls when
  *			performing passive cooling.
+ * @passive_delay_jiffies: number of jiffies to wait between polls when
+ *			performing passive cooling.
  * @polling_delay_ms:	number of milliseconds to wait between polls when
  *			checking whether trip points have been crossed (0 for
  *			interrupt driven systems)
+ * @polling_delay_jiffies: number of jiffies to wait between polls when
+ *			checking whether trip points have been crossed (0 for
+ *			interrupt driven systems)
  * @temperature:	current temperature.  This is only for core code,
  *			drivers should use thermal_zone_get_temp() to get the
  *			current temperature
@@ -161,6 +166,8 @@ struct thermal_zone_device {
 	unsigned long trips_disabled;	/* bitmap for disabled trips */
 	int passive_delay_ms;
 	int polling_delay_ms;
+	int passive_delay_jiffies;
+	int polling_delay_jiffies;
 	int temperature;
 	int last_temperature;
 	int emul_temperature;
Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/4 thermal/core: Remove ms based delay fields

In reply to Daniel Lezcano

The code does no longer use the ms unit based fields to set the delays as they are replaced by the jiffies.

Remove them.

---
 drivers/thermal/thermal_core.h  | 2 --
 drivers/thermal/thermal_sysfs.c | 2 +-
 include/linux/thermal.h         | 7 -------
 3 files changed, 1 insertion(+), 10 deletions(-)
drivers/thermal/thermal_core.h +0 -2
index 2c9551ed5ef8..5baa308ee7a5 100644
@@ -131,7 +131,6 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz);
 static inline void thermal_zone_set_passive_delay(
 	struct thermal_zone_device *tz, int delay_ms)
 {
-	tz->passive_delay_ms = delay_ms;
 	tz->passive_delay_jiffies = msecs_to_jiffies(delay_ms);
 	if (delay_ms > 1000)
 		tz->passive_delay_jiffies = round_jiffies(tz->passive_delay_jiffies);
@@ -140,7 +139,6 @@ static inline void thermal_zone_set_passive_delay(
 static inline void thermal_zone_set_polling_delay(
 	struct thermal_zone_device *tz, int delay_ms)
 {
-	tz->polling_delay_ms = delay_ms;
 	tz->polling_delay_jiffies = msecs_to_jiffies(delay_ms);
 	if (delay_ms > 1000)
 		tz->polling_delay_jiffies = round_jiffies(tz->polling_delay_jiffies);
drivers/thermal/thermal_sysfs.c +1 -1
index 9598b288a0a1..8532b1dd0608 100644
@@ -233,7 +233,7 @@ passive_store(struct device *dev, struct device_attribute *attr,
 		return -EINVAL;
 
 	if (state && !tz->forced_passive) {
-		if (!tz->passive_delay_ms)
+		if (!tz->passive_delay_jiffies)
 			thermal_zone_set_passive_delay(tz, 1000);
 		thermal_zone_device_rebind_exception(tz, "Processor",
 						     sizeof("Processor"));
include/linux/thermal.h +0 -7
index 5dd9bdb6c6ad..f23a388ded15 100644
@@ -116,13 +116,8 @@ struct thermal_cooling_device {
  * @devdata:	private pointer for device private data
  * @trips:	number of trip points the thermal zone supports
  * @trips_disabled;	bitmap for disabled trips
- * @passive_delay_ms:	number of milliseconds to wait between polls when
- *			performing passive cooling.
  * @passive_delay_jiffies: number of jiffies to wait between polls when
  *			performing passive cooling.
- * @polling_delay_ms:	number of milliseconds to wait between polls when
- *			checking whether trip points have been crossed (0 for
- *			interrupt driven systems)
  * @polling_delay_jiffies: number of jiffies to wait between polls when
  *			checking whether trip points have been crossed (0 for
  *			interrupt driven systems)
@@ -164,8 +159,6 @@ struct thermal_zone_device {
 	void *devdata;
 	int trips;
 	unsigned long trips_disabled;	/* bitmap for disabled trips */
-	int passive_delay_ms;
-	int polling_delay_ms;
 	int passive_delay_jiffies;
 	int polling_delay_jiffies;
 	int temperature;
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/4 thermal/core: Use precomputed jiffies for the polling

In reply to Daniel Lezcano

The delays are also stored in jiffies based unit. Use them instead of the ms.

---
 drivers/thermal/thermal_core.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/thermal/thermal_core.c +4 -9
index 3111ca2c87a1..237480429ba9 100644
@@ -291,14 +291,9 @@ static int __init thermal_register_governors(void)
 static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
 					    int delay)
 {
-	if (delay > 1000)
+	if (delay)
 		mod_delayed_work(system_freezable_power_efficient_wq,
-				 &tz->poll_queue,
-				 round_jiffies(msecs_to_jiffies(delay)));
-	else if (delay)
-		mod_delayed_work(system_freezable_power_efficient_wq,
-				 &tz->poll_queue,
-				 msecs_to_jiffies(delay));
+				 &tz->poll_queue, delay);
 	else
 		cancel_delayed_work(&tz->poll_queue);
 }
@@ -317,9 +312,9 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
 	mutex_lock(&tz->lock);
 
 	if (!stop && tz->passive)
-		thermal_zone_device_set_polling(tz, tz->passive_delay_ms);
+		thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
 	else if (!stop && tz->polling_delay_ms)
-		thermal_zone_device_set_polling(tz, tz->polling_delay_ms);
+		thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
 	else
 		thermal_zone_device_set_polling(tz, 0);
 
Signature · 1 line
2.17.1
#8 lore raw
In reply to Daniel Lezcano
I love your patch! Yet something to improve:

Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.10-rc6 next-20201201] [cannot apply to thermal/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: i386-randconfig-a001-20201202 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/ade78f158731d79d859533d4370cc2a1294be32e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150
        git checkout ade78f158731d79d859533d4370cc2a1294be32e
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/platform/x86/acerhdf.c: In function 'acerhdf_check_param':

>> drivers/platform/x86/acerhdf.c:339:12: error: 'struct thermal_zone_device' has no member named 'polling_delay'; did you mean 'polling_delay_ms'?
     339 |   thermal->polling_delay = interval*1000;
         |            ^~~~~~~~~~~~~
         |            polling_delay_ms

vim +339 drivers/platform/x86/acerhdf.c

e86435eb91b2bff Peter Feuerer 2009-06-21  322  
e86435eb91b2bff Peter Feuerer 2009-06-21  323  static void acerhdf_check_param(struct thermal_zone_device *thermal)
e86435eb91b2bff Peter Feuerer 2009-06-21  324  {
e86435eb91b2bff Peter Feuerer 2009-06-21  325  	if (fanon > ACERHDF_MAX_FANON) {
e86435eb91b2bff Peter Feuerer 2009-06-21  326  		pr_err("fanon temperature too high, set to %d\n",
e86435eb91b2bff Peter Feuerer 2009-06-21  327  		       ACERHDF_MAX_FANON);
e86435eb91b2bff Peter Feuerer 2009-06-21  328  		fanon = ACERHDF_MAX_FANON;
e86435eb91b2bff Peter Feuerer 2009-06-21  329  	}
e86435eb91b2bff Peter Feuerer 2009-06-21  330  
e86435eb91b2bff Peter Feuerer 2009-06-21  331  	if (kernelmode && prev_interval != interval) {
e86435eb91b2bff Peter Feuerer 2009-06-21  332  		if (interval > ACERHDF_MAX_INTERVAL) {
e86435eb91b2bff Peter Feuerer 2009-06-21  333  			pr_err("interval too high, set to %d\n",
e86435eb91b2bff Peter Feuerer 2009-06-21  334  			       ACERHDF_MAX_INTERVAL);
e86435eb91b2bff Peter Feuerer 2009-06-21  335  			interval = ACERHDF_MAX_INTERVAL;
e86435eb91b2bff Peter Feuerer 2009-06-21  336  		}
e86435eb91b2bff Peter Feuerer 2009-06-21  337  		if (verbose)
eecc5bbc612a8b0 Joe Perches   2011-11-29  338  			pr_notice("interval changed to: %d\n", interval);
e86435eb91b2bff Peter Feuerer 2009-06-21 @339  		thermal->polling_delay = interval*1000;
e86435eb91b2bff Peter Feuerer 2009-06-21  340  		prev_interval = interval;
e86435eb91b2bff Peter Feuerer 2009-06-21  341  	}
e86435eb91b2bff Peter Feuerer 2009-06-21  342  }

e86435eb91b2bff Peter Feuerer 2009-06-21 343

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#9 lore raw
In reply to Daniel Lezcano
I love your patch! Yet something to improve:

Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.10-rc6 next-20201201] [cannot apply to thermal/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: nios2-randconfig-r021-20201202 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ade78f158731d79d859533d4370cc2a1294be32e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150 git checkout ade78f158731d79d859533d4370cc2a1294be32e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/thermal/thermal_of.c: In function 'thermal_of_build_thermal_zone':

>> drivers/thermal/thermal_of.c:868:6: error: 'struct __thermal_zone' has no member named 'passive_delay_ms'; did you mean 'passive_delay'?
     868 |  tz->passive_delay_ms = prop;
         |      ^~~~~~~~~~~~~~~~
         |      passive_delay
>> drivers/thermal/thermal_of.c:875:6: error: 'struct __thermal_zone' has no member named 'polling_delay_ms'; did you mean 'polling_delay'?
     875 |  tz->polling_delay_ms = prop;
         |      ^~~~~~~~~~~~~~~~
         |      polling_delay
   drivers/thermal/thermal_of.c: In function 'of_parse_thermal_zones':
   drivers/thermal/thermal_of.c:1088:15: error: 'struct __thermal_zone' has no member named 'passive_delay_ms'; did you mean 'passive_delay'?
    1088 |           tz->passive_delay_ms,
         |               ^~~~~~~~~~~~~~~~
         |               passive_delay
   drivers/thermal/thermal_of.c:1089:15: error: 'struct __thermal_zone' has no member named 'polling_delay_ms'; did you mean 'polling_delay'?
    1089 |           tz->polling_delay_ms);
         |               ^~~~~~~~~~~~~~~~
         |               polling_delay
--
   drivers/thermal/da9062-thermal.c: In function 'da9062_thermal_poll_on':
>> drivers/thermal/da9062-thermal.c:98:43: error: 'struct thermal_zone_device' has no member named 'passive_delay'; did you mean 'passive_delay_ms'?
      98 |   delay = msecs_to_jiffies(thermal->zone->passive_delay);
         |                                           ^~~~~~~~~~~~~
         |                                           passive_delay_ms
   In file included from include/linux/printk.h:409,
                    from include/linux/kernel.h:16,
                    from include/linux/interrupt.h:6,
                    from drivers/thermal/da9062-thermal.c:22:
   drivers/thermal/da9062-thermal.c: In function 'da9062_thermal_probe':
   drivers/thermal/da9062-thermal.c:248:18: error: 'struct thermal_zone_device' has no member named 'passive_delay'; did you mean 'passive_delay_ms'?
     248 |   thermal->zone->passive_delay);
         |                  ^~~~~~~~~~~~~
   include/linux/dynamic_debug.h:129:15: note: in definition of macro '__dynamic_func_call'
     129 |   func(&id, ##__VA_ARGS__);  \
         |               ^~~~~~~~~~~
   include/linux/dynamic_debug.h:161:2: note: in expansion of macro '_dynamic_func_call'
     161 |  _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
         |  ^~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:123:2: note: in expansion of macro 'dynamic_dev_dbg'
     123 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~~~~~~~~~~
   drivers/thermal/da9062-thermal.c:246:2: note: in expansion of macro 'dev_dbg'
     246 |  dev_dbg(&pdev->dev,
         |  ^~~~~~~

vim +868 drivers/thermal/thermal_of.c

831
832 /**
833 * thermal_of_build_thermal_zone - parse and fill one thermal zone data
834 * @np: DT node containing a thermal zone node
835 *
836 * This function parses a thermal zone type of node represented by
837 * @np parameter and fills the read data into a __thermal_zone data structure
838 * and return this pointer.
839 *
840 * TODO: Missing properties to parse: thermal-sensor-names
841 *
842 * Return: On success returns a valid struct __thermal_zone,
843 * otherwise, it returns a corresponding ERR_PTR(). Caller must
844 * check the return value with help of IS_ERR() helper.
845 */
846 static struct __thermal_zone
847 __init *thermal_of_build_thermal_zone(struct device_node *np)
848 {
849 struct device_node *child = NULL, *gchild;
850 struct __thermal_zone *tz;
851 int ret, i;
852 u32 prop, coef[2];
853
854 if (!np) {
855 pr_err("no thermal zone np\n");
856 return ERR_PTR(-EINVAL);
857 }
858
859 tz = kzalloc(sizeof(*tz), GFP_KERNEL);
860 if (!tz)
861 return ERR_PTR(-ENOMEM);
862
863 ret = of_property_read_u32(np, "polling-delay-passive", &prop);
864 if (ret < 0) {
865 pr_err("%pOFn: missing polling-delay-passive property\n", np);
866 goto free_tz;
867 }

 > 868		tz->passive_delay_ms = prop;
   869	
   870		ret = of_property_read_u32(np, "polling-delay", &prop);
   871		if (ret < 0) {
   872			pr_err("%pOFn: missing polling-delay property\n", np);
   873			goto free_tz;
   874		}
 > 875		tz->polling_delay_ms = prop;

876
877 /*
878 * REVIST: for now, the thermal framework supports only
879 * one sensor per thermal zone. Thus, we are considering
880 * only the first two values as slope and offset.
881 */
882 ret = of_property_read_u32_array(np, "coefficients", coef, 2);
883 if (ret == 0) {
884 tz->slope = coef[0];
885 tz->offset = coef[1];
886 } else {
887 tz->slope = 1;
888 tz->offset = 0;
889 }
890
891 /* trips */
892 child = of_get_child_by_name(np, "trips");
893
894 /* No trips provided */
895 if (!child)
896 goto finish;
897
898 tz->ntrips = of_get_child_count(child);
899 if (tz->ntrips == 0) /* must have at least one child */
900 goto finish;
901
902 tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL);
903 if (!tz->trips) {
904 ret = -ENOMEM;
905 goto free_tz;
906 }
907
908 i = 0;
909 for_each_child_of_node(child, gchild) {
910 ret = thermal_of_populate_trip(gchild, &tz->trips[i++]);
911 if (ret)
912 goto free_trips;
913 }
914
915 of_node_put(child);
916
917 /* cooling-maps */
918 child = of_get_child_by_name(np, "cooling-maps");
919
920 /* cooling-maps not provided */
921 if (!child)
922 goto finish;
923
924 tz->num_tbps = of_get_child_count(child);
925 if (tz->num_tbps == 0)
926 goto finish;
927
928 tz->tbps = kcalloc(tz->num_tbps, sizeof(*tz->tbps), GFP_KERNEL);
929 if (!tz->tbps) {
930 ret = -ENOMEM;
931 goto free_trips;
932 }
933
934 i = 0;
935 for_each_child_of_node(child, gchild) {
936 ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++],
937 tz->trips, tz->ntrips);
938 if (ret)
939 goto free_tbps;
940 }
941
942 finish:
943 of_node_put(child);
944
945 return tz;
946
947 free_tbps:
948 for (i = i - 1; i >= 0; i--) {
949 struct __thermal_bind_params *tbp = tz->tbps + i;
950 int j;
951
952 for (j = 0; j < tbp->count; j++)
953 of_node_put(tbp->tcbp[j].cooling_device);
954
955 kfree(tbp->tcbp);
956 }
957
958 kfree(tz->tbps);
959 free_trips:
960 for (i = 0; i < tz->ntrips; i++)
961 of_node_put(tz->trips[i].np);
962 kfree(tz->trips);
963 of_node_put(gchild);
964 free_tz:
965 kfree(tz);
966 of_node_put(child);
967
968 return ERR_PTR(ret);
969 }
970

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#6 lore raw

Re: [PATCH 4/4] thermal/core: Remove ms based delay fields

In reply to Daniel Lezcano
I love your patch! Yet something to improve:

Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.10-rc6 next-20201201] [cannot apply to thermal/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: riscv-randconfig-r025-20201202 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 2671fccf0381769276ca8246ec0499adcb9b0355)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/6882dfdda2ded695a08357272d350db4e24fe59d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150 git checkout 6882dfdda2ded695a08357272d350db4e24fe59d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

           return inl(addr);
                  ^~~~~~~~~
   arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
   #define inl(c)          ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
                                                                           ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
   #define readl_cpu(c)            ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
                                                                                        ^
   include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/thermal/thermal_core.c:22:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:13:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outb(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
   #define outb(v,c)       ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
   #define writeb_cpu(v, c)        ((void)__raw_writeb((v), (c)))
                                                             ^
   In file included from drivers/thermal/thermal_core.c:22:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:13:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outw(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
   #define outw(v,c)       ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
   #define writew_cpu(v, c)        ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
                                                                                     ^
   In file included from drivers/thermal/thermal_core.c:22:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:13:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outl(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
   #define outl(v,c)       ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
   #define writel_cpu(v, c)        ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
                                                                                     ^
   In file included from drivers/thermal/thermal_core.c:22:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:13:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
                                                     ~~~~~~~~~~ ^
>> drivers/thermal/thermal_core.c:316:24: error: no member named 'polling_delay_ms' in 'struct thermal_zone_device'
           else if (!stop && tz->polling_delay_ms)
                             ~~  ^

7 warnings and 1 error generated.

vim +316 drivers/thermal/thermal_core.c

b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  305  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  306  static void monitor_thermal_zone(struct thermal_zone_device *tz)
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  307  {
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  308  	bool stop;
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  309  
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  310  	stop = should_stop_polling(tz);
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  311  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  312  	mutex_lock(&tz->lock);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  313  
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  314  	if (!stop && tz->passive)
07314bdc38fa26c drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02  315  		thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
ade78f158731d79 drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02 @316  	else if (!stop && tz->polling_delay_ms)
07314bdc38fa26c drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02  317  		thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  318  	else
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  319  		thermal_zone_device_set_polling(tz, 0);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  320  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  321  	mutex_unlock(&tz->lock);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  322  }
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  323  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#7 lore raw

Re: [PATCH 4/4] thermal/core: Remove ms based delay fields

In reply to Daniel Lezcano
I love your patch! Yet something to improve:

Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.10-rc6 next-20201201] [cannot apply to thermal/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: nios2-randconfig-r021-20201202 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6882dfdda2ded695a08357272d350db4e24fe59d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-core-Rename-passive_delay-and-polling_delay-with-units/20201202-201150 git checkout 6882dfdda2ded695a08357272d350db4e24fe59d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/thermal/thermal_core.c: In function 'monitor_thermal_zone':

>> drivers/thermal/thermal_core.c:316:24: error: 'struct thermal_zone_device' has no member named 'polling_delay_ms'; did you mean 'polling_delay_jiffies'?
     316 |  else if (!stop && tz->polling_delay_ms)
         |                        ^~~~~~~~~~~~~~~~
         |                        polling_delay_jiffies

vim +316 drivers/thermal/thermal_core.c

b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  305  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  306  static void monitor_thermal_zone(struct thermal_zone_device *tz)
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  307  {
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  308  	bool stop;
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  309  
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  310  	stop = should_stop_polling(tz);
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  311  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  312  	mutex_lock(&tz->lock);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  313  
b56bdff78e0b65f drivers/thermal/thermal_core.c Andrzej Pietrasiewicz 2020-06-29  314  	if (!stop && tz->passive)
07314bdc38fa26c drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02  315  		thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
ade78f158731d79 drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02 @316  	else if (!stop && tz->polling_delay_ms)
07314bdc38fa26c drivers/thermal/thermal_core.c Daniel Lezcano        2020-12-02  317  		thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  318  	else
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  319  		thermal_zone_device_set_polling(tz, 0);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  320  
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  321  	mutex_unlock(&tz->lock);
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  322  }
0c01ebbfd3caf1d drivers/thermal/thermal_sys.c  Durgadoss R           2012-09-18  323  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw

Re: [PATCH 2/4] thermal/core: Precompute the jiffies

In reply to Daniel Lezcano

Hi Daniel,

Quoted 5 lines · Daniel Lezcano

The delays are stored in ms units and when the polling function is called this delay is converted into jiffies at each call.

Instead of doing the conversion again and again, compute the jiffies at init time and use the value directly when setting the polling.

A generic comment. You can avoid patch 1 of this series and directly
have patch 2 , right? There is no need to rename polling_delay/passive_delay to *_delay_ms and then remove it again?

Quoted 40 lines
---
  drivers/thermal/thermal_core.c  |  5 +++--
  drivers/thermal/thermal_core.h  | 18 ++++++++++++++++++
  drivers/thermal/thermal_sysfs.c |  4 ++--
  include/linux/thermal.h         |  7 +++++++
  4 files changed, 30 insertions(+), 4 deletions(-)
drivers/thermal/thermal_core.c +3 -2
index 53f55ceca220..3111ca2c87a1 100644
@@ -1340,8 +1340,9 @@ thermal_zone_device_register(const char *type, int trips, int mask,
  	tz->device.class = &thermal_class;
  	tz->devdata = devdata;
  	tz->trips = trips;
-	tz->passive_delay_ms = passive_delay;
-	tz->polling_delay_ms = polling_delay;
+
+	thermal_zone_set_passive_delay(tz, passive_delay);
+	thermal_zone_set_polling_delay(tz, polling_delay);
 
  	/* sys I/F */
  	/* Add nodes that are always present via .groups */
drivers/thermal/thermal_core.h +7 -0
index 8df600fa7b79..2c9551ed5ef8 100644
@@ -128,6 +128,24 @@ int thermal_build_list_of_policies(char *buf);
  /* Helpers */
  void thermal_zone_set_trips(struct thermal_zone_device *tz);
 
+static inline void thermal_zone_set_passive_delay(
+	struct thermal_zone_device *tz, int delay_ms)
+{
+	tz->passive_delay_ms = delay_ms;
+	tz->passive_delay_jiffies = msecs_to_jiffies(delay_ms);
+	if (delay_ms > 1000)
+		tz->passive_delay_jiffies = round_jiffies(tz->passive_delay_jiffies);

drivers/thermal/thermal_core.h int thermal_build_list_of_policies(char *buf); · line 147

Quoted 10 lines
drivers/thermal/thermal_core.h +10 -0
+}
+
+static inline void thermal_zone_set_polling_delay(
+	struct thermal_zone_device *tz, int delay_ms)
+{
+	tz->polling_delay_ms = delay_ms;
+	tz->polling_delay_jiffies = msecs_to_jiffies(delay_ms);
+	if (delay_ms > 1000)
+		tz->polling_delay_jiffies = round_jiffies(tz->polling_delay_jiffies);
+}

How about one function instead?
static inline void thermal_zone_set_delay_jiffies(int *delay_jiffes, int delay_ms)

{
	*delay_jiffies = msecs_to_jiffies(delay_ms);
	if (delay_ms > 1000)
		*delay_jiffies = round_jiffies(*delay_jiffies);
}

And then calling thermal_zone_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay)..

Regards
Thara

Quoted 51 lines
drivers/thermal/thermal_core.h +1 -0
+
  /* sysfs I/F */
  int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
  void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
drivers/thermal/thermal_sysfs.c +2 -2
index f465462d8aa1..9598b288a0a1 100644
@@ -234,11 +234,11 @@ passive_store(struct device *dev, struct device_attribute *attr,
 
  	if (state && !tz->forced_passive) {
  		if (!tz->passive_delay_ms)
-			tz->passive_delay_ms = 1000;
+			thermal_zone_set_passive_delay(tz, 1000);
  		thermal_zone_device_rebind_exception(tz, "Processor",
  						     sizeof("Processor"));
  	} else if (!state && tz->forced_passive) {
-		tz->passive_delay_ms = 0;
+		thermal_zone_set_passive_delay(tz, 0);
  		thermal_zone_device_unbind_exception(tz, "Processor",
  						     sizeof("Processor"));
  	}
include/linux/thermal.h +7 -0
index 230d451bf335..5dd9bdb6c6ad 100644
@@ -118,9 +118,14 @@ struct thermal_cooling_device {
   * @trips_disabled;	bitmap for disabled trips
   * @passive_delay_ms:	number of milliseconds to wait between polls when
   *			performing passive cooling.
+ * @passive_delay_jiffies: number of jiffies to wait between polls when
+ *			performing passive cooling.
   * @polling_delay_ms:	number of milliseconds to wait between polls when
   *			checking whether trip points have been crossed (0 for
   *			interrupt driven systems)
+ * @polling_delay_jiffies: number of jiffies to wait between polls when
+ *			checking whether trip points have been crossed (0 for
+ *			interrupt driven systems)
   * @temperature:	current temperature.  This is only for core code,
   *			drivers should use thermal_zone_get_temp() to get the
   *			current temperature
@@ -161,6 +166,8 @@ struct thermal_zone_device {
  	unsigned long trips_disabled;	/* bitmap for disabled trips */
  	int passive_delay_ms;
  	int polling_delay_ms;
+	int passive_delay_jiffies;
+	int polling_delay_jiffies;
  	int temperature;
  	int last_temperature;
  	int emul_temperature;
Signature · 2 lines
Warm Regards
Thara
#3 lore raw

Re: [PATCH 2/4] thermal/core: Precompute the jiffies

Quoted 6 lines · Thara Gopinath

Hi Daniel,

Quoted 3 lines · Daniel Lezcano

The delays are stored in ms units and when the polling function is called this delay is converted into jiffies at each call.

Quoted 6 lines
Quoted 2 lines

Instead of doing the conversion again and again, compute the jiffies at init time and use the value directly when setting the polling.

A generic comment. You can avoid patch 1 of this series and directly have patch 2 , right? There is no need to rename polling_delay/passive_delay to *_delay_ms and then remove it again?

Yes, I can simplify that.

Quoted 3 lines
Quoted 3 lines

---

[ ... ]

Quoted 12 lines

drivers/thermal/thermal_core.h int thermal_build_list_of_policies(char *buf); · line 147

Quoted 8 lines
drivers/thermal/thermal_core.h +8 -0
+static inline void thermal_zone_set_polling_delay(
+	struct thermal_zone_device *tz, int delay_ms)
+{
+	tz->polling_delay_ms = delay_ms;
+	tz->polling_delay_jiffies = msecs_to_jiffies(delay_ms);
+	if (delay_ms > 1000)
+		tz->polling_delay_jiffies = round_jiffies(tz->polling_delay_jiffies);
+}

How about one function instead?
static inline void thermal_zone_set_delay_jiffies(int *delay_jiffes, int delay_ms)

Quoted 8 lines
{
	*delay_jiffies = msecs_to_jiffies(delay_ms);
	if (delay_ms > 1000)
		*delay_jiffies = round_jiffies(*delay_jiffies);
}

And then calling thermal_zone_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay)..

Yes, agree. I'll do this change.

Thanks for the review

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog