public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* Re: [PATCH v1 2/7] thermal/core: Add thresholds support
       [not found] <20240729150259.1089814-3-daniel.lezcano@linaro.org>
@ 2024-07-30 10:52 ` kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-07-30 10:52 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: llvm, oe-kbuild-all

Hi Daniel,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/thermal]
[also build test ERROR on linus/master v6.11-rc1 next-20240729]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/thermal-core-Encapsulate-more-handle_thermal_trip/20240730-005842
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
patch link:    https://lore.kernel.org/r/20240729150259.1089814-3-daniel.lezcano%40linaro.org
patch subject: [PATCH v1 2/7] thermal/core: Add thresholds support
config: um-allmodconfig (https://download.01.org/0day-ci/archive/20240730/202407301859.vCUJ8nEx-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project ccae7b461be339e717d02f99ac857cf0bc7d17fc)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240730/202407301859.vCUJ8nEx-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407301859.vCUJ8nEx-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/thermal/thermal_thresholds.c:22:15: error: call to undeclared function 'kmalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      22 |         thresholds = kmalloc(sizeof(*thresholds), GFP_KERNEL);
         |                      ^
   drivers/thermal/thermal_thresholds.c:22:15: note: did you mean 'mm_alloc'?
   include/linux/sched/mm.h:16:26: note: 'mm_alloc' declared here
      16 | extern struct mm_struct *mm_alloc(void);
         |                          ^
>> drivers/thermal/thermal_thresholds.c:22:13: error: incompatible integer to pointer conversion assigning to 'struct thresholds *' from 'int' [-Wint-conversion]
      22 |         thresholds = kmalloc(sizeof(*thresholds), GFP_KERNEL);
         |                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/thermal/thermal_thresholds.c:35:2: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      35 |         kfree(tz->thresholds);
         |         ^
   drivers/thermal/thermal_thresholds.c:35:2: note: did you mean 'kvfree'?
   include/linux/rcutiny.h:99:13: note: 'kvfree' declared here
      99 | extern void kvfree(const void *addr);
         |             ^
   drivers/thermal/thermal_thresholds.c:122:3: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     122 |                 kfree(entry);
         |                 ^
   drivers/thermal/thermal_thresholds.c:185:7: error: call to undeclared function 'kmalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     185 |                 t = kmalloc(sizeof(*t), GFP_KERNEL);
         |                     ^
>> drivers/thermal/thermal_thresholds.c:185:5: error: incompatible integer to pointer conversion assigning to 'struct threshold *' from 'int' [-Wint-conversion]
     185 |                 t = kmalloc(sizeof(*t), GFP_KERNEL);
         |                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/thermal/thermal_thresholds.c:214:3: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     214 |                 kfree(t);
         |                 ^
   7 errors generated.


vim +/kmalloc +22 drivers/thermal/thermal_thresholds.c

    17	
    18	int thermal_thresholds_init(struct thermal_zone_device *tz)
    19	{
    20		struct thresholds *thresholds;
    21	
  > 22		thresholds = kmalloc(sizeof(*thresholds), GFP_KERNEL);
    23		if (!thresholds)
    24			return -ENOMEM;
    25	
    26		INIT_LIST_HEAD(&thresholds->list);
    27		tz->thresholds = thresholds;
    28	
    29		return 0;
    30	}
    31	
    32	void thermal_thresholds_exit(struct thermal_zone_device *tz)
    33	{
    34		thermal_thresholds_flush(tz);
  > 35		kfree(tz->thresholds);
    36		tz->thresholds = NULL;
    37	}
    38	
    39	static int __thermal_thresholds_cmp(void *data,
    40					    const struct list_head *l1,
    41					    const struct list_head *l2)
    42	{
    43		struct threshold *t1 = container_of(l1, struct threshold, list);
    44		struct threshold *t2 = container_of(l2, struct threshold, list);
    45	
    46		return t1->temperature - t2->temperature;
    47	}
    48	
    49	static struct threshold *__thermal_thresholds_find(const struct thresholds *thresholds, int temperature)
    50	{
    51		struct threshold *t;
    52	
    53		list_for_each_entry(t, &thresholds->list, list)
    54			if (t->temperature == temperature)
    55				return t;
    56	
    57		return NULL;
    58	}
    59	
    60	static bool __thermal_threshold_is_crossed(struct threshold *threshold, int temperature,
    61						   int last_temperature, int direction,
    62						   int *low, int *high)
    63	{
    64		if (temperature > threshold->temperature && threshold->temperature > *low &&
    65		    (THERMAL_THRESHOLD_WAY_DOWN & threshold->direction))
    66			*low = threshold->temperature;
    67	
    68		if (temperature < threshold->temperature && threshold->temperature < *high &&
    69		    (THERMAL_THRESHOLD_WAY_UP & threshold->direction))
    70			*high = threshold->temperature;
    71	
    72		if (temperature < threshold->temperature &&
    73		    last_temperature >= threshold->temperature &&
    74		    (threshold->direction & direction))
    75			return true;
    76	
    77		if (temperature >= threshold->temperature &&
    78		    last_temperature < threshold->temperature &&
    79		    (threshold->direction & direction))
    80			return true;
    81	
    82		return false;
    83	}
    84	
    85	static bool thermal_thresholds_handle_raising(struct thresholds *thresholds, int temperature,
    86						      int last_temperature, int *low, int *high)
    87	{
    88		struct threshold *t;
    89	
    90		list_for_each_entry(t, &thresholds->list, list) {
    91			if (__thermal_threshold_is_crossed(t, temperature, last_temperature,
    92							   THERMAL_THRESHOLD_WAY_UP, low, high))
    93				return true;
    94		}
    95	
    96		return false;
    97	}
    98	
    99	static bool thermal_thresholds_handle_dropping(struct thresholds *thresholds, int temperature,
   100						       int last_temperature, int *low, int *high)
   101	{
   102		struct threshold *t;
   103	
   104		list_for_each_entry_reverse(t, &thresholds->list, list) {
   105			if (__thermal_threshold_is_crossed(t, temperature, last_temperature,
   106							   THERMAL_THRESHOLD_WAY_DOWN, low, high))
   107				return true;
   108		}
   109	
   110		return false;
   111	}
   112	
   113	void thermal_thresholds_flush(struct thermal_zone_device *tz)
   114	{
   115		struct thresholds *thresholds = tz->thresholds;
   116		struct threshold *entry, *tmp;
   117	
   118		lockdep_assert_held(&tz->lock);
   119	
   120		list_for_each_entry_safe(entry, tmp, &thresholds->list, list) {
   121			list_del(&entry->list);
   122			kfree(entry);
   123		}
   124	
   125		__thermal_zone_device_update(tz, THERMAL_THRESHOLD_FLUSHED);
   126	}
   127	
   128	int thermal_thresholds_handle(struct thermal_zone_device *tz, int *low, int *high)
   129	{
   130		struct thresholds *thresholds = tz->thresholds;
   131	
   132		int temperature = tz->temperature;
   133		int last_temperature = tz->last_temperature;
   134		bool notify;
   135	
   136		lockdep_assert_held(&tz->lock);
   137	
   138		/*
   139		 * We need a second update in order to detect a threshold being crossed
   140		 */
   141		if (last_temperature == THERMAL_TEMP_INVALID)
   142			return 0;
   143	
   144		/*
   145		 * The temperature is stable, so obviously we can not have
   146		 * crossed a threshold.
   147		 */
   148		if (last_temperature == temperature)
   149			return 0;
   150	
   151		/*
   152		 * Since last update the temperature:
   153		 * - increased : thresholds are crossed the way up
   154		 * - decreased : thresholds are crossed the way down
   155		 */
   156		if (temperature > last_temperature)
   157			notify = thermal_thresholds_handle_raising(thresholds, temperature,
   158								   last_temperature, low, high);
   159		else
   160			notify = thermal_thresholds_handle_dropping(thresholds, temperature,
   161								    last_temperature, low, high);
   162	
   163		if (notify)
   164			pr_debug("A threshold has been crossed the way %s, with a temperature=%d, last_temperature=%d\n",
   165				 temperature > last_temperature ? "up" : "down", temperature, last_temperature);
   166	
   167		return 0;
   168	}
   169	
   170	int thermal_thresholds_add(struct thermal_zone_device *tz, int temperature, int direction)
   171	{
   172		struct thresholds *thresholds = tz->thresholds;
   173		struct threshold *t;
   174	
   175		lockdep_assert_held(&tz->lock);
   176	
   177		t = __thermal_thresholds_find(thresholds, temperature);
   178		if (t) {
   179			if (t->direction == direction)
   180				return -EEXIST;
   181	
   182			t->direction |= direction;
   183		} else {
   184	
 > 185			t = kmalloc(sizeof(*t), GFP_KERNEL);
   186			if (!t)
   187				return -ENOMEM;
   188	
   189			INIT_LIST_HEAD(&t->list);
   190			t->temperature = temperature;
   191			t->direction = direction;
   192			list_add(&t->list, &thresholds->list);
   193			list_sort(NULL, &thresholds->list, __thermal_thresholds_cmp);
   194		}
   195	
   196		__thermal_zone_device_update(tz, THERMAL_THRESHOLD_ADDED);
   197	
   198		return 0;
   199	}
   200	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-30 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20240729150259.1089814-3-daniel.lezcano@linaro.org>
2024-07-30 10:52 ` [PATCH v1 2/7] thermal/core: Add thresholds support kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox