Re: [PATCH v3 4/4] thermal: core: Add notifications call in the framework

2020-07-03 Thread kernel test robot
Hi Daniel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.8-rc3 next-20200703]
[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  as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Add-helpers-to-browse-the-cdev-tz-and-governor-list/20200703-165448
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 
ca464639a1c9dd3944eb055ffd2796e8c2e7639f)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

>> drivers/thermal/thermal_helpers.c:178:6: warning: no previous prototype for 
>> function 'thermal_cdev_set_cur_state' [-Wmissing-prototypes]
   void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int 
target)
^
   drivers/thermal/thermal_helpers.c:178:1: note: declare 'static' if the 
function is not intended to be used outside of this translation unit
   void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int 
target)
   ^
   static 
   1 warning generated.

vim +/thermal_cdev_set_cur_state +178 drivers/thermal/thermal_helpers.c

   177  
 > 178  void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, 
 > int target)
   179  {
   180  if (cdev->ops->set_cur_state(cdev, target))
   181  return;
   182  thermal_notify_cdev_update(cdev->id, target);
   183  thermal_cooling_device_stats_update(cdev, target);
   184  }
   185  

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


.config.gz
Description: application/gzip


Re: [PATCH v3 4/4] thermal: core: Add notifications call in the framework

2020-07-03 Thread kernel test robot
Hi Daniel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.8-rc3 next-20200703]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Daniel-Lezcano/thermal-core-Add-helpers-to-browse-the-cdev-tz-and-governor-list/20200703-165448
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: i386-randconfig-s002-20200702 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-3-gfa153962-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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


sparse warnings: (new ones prefixed by >>)

>> drivers/thermal/thermal_helpers.c:178:6: sparse: sparse: symbol 
>> 'thermal_cdev_set_cur_state' was not declared. Should it be static?

Please review and possibly fold the followup patch.

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


.config.gz
Description: application/gzip


Re: [PATCH v3 4/4] thermal: core: Add notifications call in the framework

2020-07-03 Thread Amit Kucheria
On Fri, Jul 3, 2020 at 2:23 PM Daniel Lezcano  wrote:
>
> The generic netlink protocol is implemented but the different
> notification functions are not yet connected to the core code.
>
> These changes add the notification calls in the different
> corresponding places.
>
> Signed-off-by: Daniel Lezcano 

Reviewed-by: Amit Kucheria 

> ---
>  drivers/thermal/thermal_core.c| 21 +
>  drivers/thermal/thermal_helpers.c | 11 +--
>  drivers/thermal/thermal_sysfs.c   | 15 ++-
>  3 files changed, 44 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 5fae1621fb01..25ef29123f72 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -215,6 +215,8 @@ int thermal_zone_device_set_policy(struct 
> thermal_zone_device *tz,
> mutex_unlock(&tz->lock);
> mutex_unlock(&thermal_governor_lock);
>
> +   thermal_notify_tz_gov_change(tz->id, policy);
> +
> return ret;
>  }
>
> @@ -406,12 +408,25 @@ 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;
> +   int trip_temp, hyst = 0;
>
> /* Ignore disabled trip points */
> if (test_bit(trip, &tz->trips_disabled))
> return;
>
> +   tz->ops->get_trip_temp(tz, trip, &trip_temp);
> tz->ops->get_trip_type(tz, trip, &type);
> +   if (tz->ops->get_trip_hyst)
> +   tz->ops->get_trip_hyst(tz, trip, &hyst);
> +
> +   if (tz->last_temperature != THERMAL_TEMP_INVALID) {
> +   if (tz->last_temperature < trip_temp &&
> +   tz->temperature >= trip_temp)
> +   thermal_notify_tz_trip_up(tz->id, trip);
> +   if (tz->last_temperature >= trip_temp &&
> +   tz->temperature < (trip_temp - hyst))
> +   thermal_notify_tz_trip_down(tz->id, trip);
> +   }
>
> if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
> handle_critical_trips(tz, trip, type);
> @@ -443,6 +458,8 @@ static void update_temperature(struct thermal_zone_device 
> *tz)
> mutex_unlock(&tz->lock);
>
> trace_thermal_temperature(tz);
> +
> +   thermal_genl_sampling_temp(tz->id, temp);
>  }
>
>  static void thermal_zone_device_init(struct thermal_zone_device *tz)
> @@ -1405,6 +1422,8 @@ thermal_zone_device_register(const char *type, int 
> trips, int mask,
> if (atomic_cmpxchg(&tz->need_update, 1, 0))
> thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
>
> +   thermal_notify_tz_create(tz->id, tz->type);
> +
> return tz;
>
>  unregister:
> @@ -1476,6 +1495,8 @@ void thermal_zone_device_unregister(struct 
> thermal_zone_device *tz)
> ida_destroy(&tz->ida);
> mutex_destroy(&tz->lock);
> device_unregister(&tz->device);
> +
> +   thermal_notify_tz_delete(tz->id);
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
>
> diff --git a/drivers/thermal/thermal_helpers.c 
> b/drivers/thermal/thermal_helpers.c
> index 87b1256fa2f2..53dd92ccfd19 100644
> --- a/drivers/thermal/thermal_helpers.c
> +++ b/drivers/thermal/thermal_helpers.c
> @@ -175,6 +175,14 @@ void thermal_zone_set_trips(struct thermal_zone_device 
> *tz)
> mutex_unlock(&tz->lock);
>  }
>
> +void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int 
> target)
> +{
> +   if (cdev->ops->set_cur_state(cdev, target))
> +   return;
> +   thermal_notify_cdev_update(cdev->id, target);
> +   thermal_cooling_device_stats_update(cdev, target);
> +}
> +
>  void thermal_cdev_update(struct thermal_cooling_device *cdev)
>  {
> struct thermal_instance *instance;
> @@ -197,8 +205,7 @@ void thermal_cdev_update(struct thermal_cooling_device 
> *cdev)
> target = instance->target;
> }
>
> -   if (!cdev->ops->set_cur_state(cdev, target))
> -   thermal_cooling_device_stats_update(cdev, target);
> +   thermal_cdev_set_cur_state(cdev, target);
>
> cdev->updated = true;
> mutex_unlock(&cdev->lock);
> diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> index aa99edb4dff7..ff449943f757 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -124,7 +124,8 @@ trip_point_temp_store(struct device *dev, struct 
> device_attribute *attr,
>  {
> struct thermal_zone_device *tz = to_thermal_zone(dev);
> int trip, ret;
> -   int temperature;
> +   int temperature, hyst = 0;
> +   enum thermal_trip_type type;
>
> if (!tz->ops->set_trip_temp)
> return -EPERM;
> @@ -139,6 +140,18 @@ trip_point_temp_store(struct device *dev, struct 
> device_attribute *attr,
> if (ret)
> ret