Re: [PATCH v2 3/4] thermal: devfreq_cooling: Refactor code and switch to use Energy Model

2020-02-08 Thread kbuild test robot
Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pm/linux-next]
[also build test WARNING on linus/master next-20200207]
[cannot apply to tip/sched/core linux/master v5.5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/lukasz-luba-arm-com/Add-support-for-devices-in-the-Energy-Model/20200208-123516
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.5.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sparc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All warnings (new ones prefixed by >>):

   In file included from include/linux/devfreq_cooling.h:21:0,
from drivers/thermal/devfreq_cooling.c:14:
   drivers/thermal/devfreq_cooling.c: In function 'freq_get_state':
>> include/linux/thermal.h:24:32: warning: overflow in implicit constant 
>> conversion [-Woverflow]
#define THERMAL_CSTATE_INVALID -1UL
   ^
>> drivers/thermal/devfreq_cooling.c:207:9: note: in expansion of macro 
>> 'THERMAL_CSTATE_INVALID'
 return THERMAL_CSTATE_INVALID;
^~
--
   In file included from include/linux/devfreq_cooling.h:21:0,
from drivers//thermal/devfreq_cooling.c:14:
   drivers//thermal/devfreq_cooling.c: In function 'freq_get_state':
>> include/linux/thermal.h:24:32: warning: overflow in implicit constant 
>> conversion [-Woverflow]
#define THERMAL_CSTATE_INVALID -1UL
   ^
   drivers//thermal/devfreq_cooling.c:207:9: note: in expansion of macro 
'THERMAL_CSTATE_INVALID'
 return THERMAL_CSTATE_INVALID;
^~

vim +24 include/linux/thermal.h

23064088d6aea04 Durgadoss R 2012-09-18  22  
57df8106932b574 Zhang Rui   2013-02-08  23  /* invalid cooling state */
57df8106932b574 Zhang Rui   2013-02-08 @24  #define THERMAL_CSTATE_INVALID -1UL
57df8106932b574 Zhang Rui   2013-02-08  25  

:: The code at line 24 was first introduced by commit
:: 57df8106932b57427df1eaaa13871857f75b1194 Thermal: exynos: fix cooling 
state translation

:: TO: Zhang Rui 
:: CC: Zhang Rui 

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


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 3/4] thermal: devfreq_cooling: Refactor code and switch to use Energy Model

2020-02-08 Thread kbuild test robot
Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pm/linux-next]
[also build test WARNING on linus/master next-20200207]
[cannot apply to tip/sched/core linux/master v5.5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/lukasz-luba-arm-com/Add-support-for-devices-in-the-Energy-Model/20200208-123516
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: x86_64-randconfig-a003-20200208 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.2-10+deb8u1) 4.9.2
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All warnings (new ones prefixed by >>):

   drivers/thermal/devfreq_cooling.c: In function 'freq_get_state':
>> drivers/thermal/devfreq_cooling.c:207:2: warning: overflow in implicit 
>> constant conversion [-Woverflow]
 return THERMAL_CSTATE_INVALID;
 ^

vim +207 drivers/thermal/devfreq_cooling.c

a76caf55e5b356b Ørjan Eide  2015-09-10  188  
a76caf55e5b356b Ørjan Eide  2015-09-10  189  /**
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  190   * freq_get_state() - get the 
performance index corresponding to a frequency
a76caf55e5b356b Ørjan Eide  2015-09-10  191   * @dfc:   Pointer to devfreq 
cooling device
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  192   * @freq:  frequency in kHz
a76caf55e5b356b Ørjan Eide  2015-09-10  193   *
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  194   * Return: the performance index 
associated with the @freq, or
a76caf55e5b356b Ørjan Eide  2015-09-10  195   * THERMAL_CSTATE_INVALID if it 
wasn't found.
a76caf55e5b356b Ørjan Eide  2015-09-10  196   */
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  197  static int
a76caf55e5b356b Ørjan Eide  2015-09-10  198  freq_get_state(struct 
devfreq_cooling_device *dfc, unsigned long freq)
a76caf55e5b356b Ørjan Eide  2015-09-10  199  {
a76caf55e5b356b Ørjan Eide  2015-09-10  200 int i;
a76caf55e5b356b Ørjan Eide  2015-09-10  201  
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  202 for (i = 0; i <= 
dfc->max_level; i++) {
ed9aa27ba36cc93 Lukasz Luba 2020-02-06  203 if 
(dfc->em->table[i].frequency == freq)
a76caf55e5b356b Ørjan Eide  2015-09-10  204 return i;
a76caf55e5b356b Ørjan Eide  2015-09-10  205 }
a76caf55e5b356b Ørjan Eide  2015-09-10  206  
a76caf55e5b356b Ørjan Eide  2015-09-10 @207 return THERMAL_CSTATE_INVALID;
a76caf55e5b356b Ørjan Eide  2015-09-10  208  }
a76caf55e5b356b Ørjan Eide  2015-09-10  209  

:: The code at line 207 was first introduced by commit
:: a76caf55e5b356ba20a5a43ac4d9f7a04b20941d thermal: Add devfreq cooling

:: TO: Ørjan Eide 
:: CC: Eduardo Valentin 

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


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/4] thermal: devfreq_cooling: Refactor code and switch to use Energy Model

2020-02-07 Thread lukasz . luba
From: Lukasz Luba 

The overhauled Energy Model (EM) framework support also devfreq devices.
The unified API interface of the EM can be used in the thermal subsystem to
not duplicate code. The power table now is taken from EM structure and
there is no need to maintain calculation for it locally. In case when the
EM is not provided by the device a simple interface for cooling device is
used.

There is also an improvement in code related to enabling/disabling OPPs,
which prevents from race condition with devfreq governors.

Reviewed-by: Steven Rostedt (VMware)  # for tracing code
Signed-off-by: Lukasz Luba 
---
 drivers/thermal/devfreq_cooling.c | 427 ++
 include/linux/devfreq_cooling.h   |  17 --
 include/trace/events/thermal.h|  19 +-
 3 files changed, 202 insertions(+), 261 deletions(-)

diff --git a/drivers/thermal/devfreq_cooling.c 
b/drivers/thermal/devfreq_cooling.c
index a87d4fa031c8..1b9f61b6532d 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * devfreq_cooling: Thermal cooling device implementation for devices using
  *  devfreq
  *
- * Copyright (C) 2014-2015 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Copyright (C) 2014-2020 ARM Limited
  *
  * TODO:
  *- If OPPs are added or removed after devfreq cooling has
@@ -20,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,37 +32,56 @@ static DEFINE_IDA(devfreq_ida);
  * @cdev:  Pointer to associated thermal cooling device.
  * @devfreq:   Pointer to associated devfreq device.
  * @cooling_state: Current cooling state.
- * @power_table:   Pointer to table with maximum power draw for each
- * cooling state. State is the index into the table, and
- * the power is in mW.
- * @freq_table:Pointer to a table with the frequencies sorted in 
descending
- * order.  You can index the table by cooling device state
- * @freq_table_size:   Size of the @freq_table and @power_table
- * @power_ops: Pointer to devfreq_cooling_power, used to generate the
- * @power_table.
+ * @freq_table:Pointer to a table with the frequencies.
+ * @max_level: It is the last index, that is, one less than the number of the
+ * OPPs
+ * @power_ops: Pointer to devfreq_cooling_power, a more precised model.
  * @res_util:  Resource utilization scaling factor for the power.
  * It is multiplied by 100 to minimize the error. It is used
  * for estimation of the power budget instead of using
  * 'utilization' (which is 'busy_time / 'total_time').
- * The 'res_util' range is from 100 to (power_table[state] * 100)
- * for the corresponding 'state'.
- * @capped_state:  index to cooling state with in dynamic power budget
+ * The 'res_util' range is from 100 to power * 100 for the
+ * corresponding 'state'.
+ * @em:Energy Model which represents the associated Devfreq 
device
  */
 struct devfreq_cooling_device {
int id;
struct thermal_cooling_device *cdev;
struct devfreq *devfreq;
unsigned long cooling_state;
-   u32 *power_table;
u32 *freq_table;
-   size_t freq_table_size;
+   size_t max_level;
struct devfreq_cooling_power *power_ops;
u32 res_util;
-   int capped_state;
+   struct em_perf_domain *em;
 };
 
+static unsigned long _find_freq_for_state(struct devfreq_cooling_device *dfc,
+ unsigned long cdev_state)
+{
+   unsigned long freq;
+
+   if (dfc->em) {
+   freq = dfc->em->table[dfc->max_level - cdev_state].frequency;
+   /* Energy Model frequencies are in kHz */
+   return freq * 1000;
+   } else {
+   return dfc->freq_table[cdev_state];
+   }
+}
+
+static void _update_devfreq_max_freq(struct devfreq *df, unsigned long 
max_freq)
+{
+   dev_dbg(df->dev.parent, "devfreq_cooling: max_freq=%luHz\n", max_freq);
+
+   mutex_lock(&df->lock);
+   df->scaling_max_freq = max_freq;
+   update_devfreq(df);
+   mutex_unlock(&df->lock);
+}
+
 /**
- * partition_enable_opps() - disable all opps above a given state
+ * partition_enable_opps() - disable all OPPs above a given state
  * @dfc:   Pointer to devfreq we are operating on
  * @cdev_state:cooling device state we're setting
  *
@@ -79,16