[v2,11/11] thermal/acpi: Use the thermal framework ACPI API
Commit Message
From: Daniel Lezcano <daniel.lezcano@kernel.org>
The thermal framework has a set of functions to fill the trip
points. Those functions are already used by the int340x and the quark
Intel's platform.
Reuse these functions in order to consolidate the generic trip points
usage across the thermal ACPI user.
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 85 +++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 47 deletions(-)
Comments
Hi Daniel,
I love your patch! Yet something to improve:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc6 next-20230203]
[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-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230203174429.3375691-12-daniel.lezcano%40linaro.org
patch subject: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20230204/202302041301.JFOakwDi-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/2c921da06a8ac8f9e047f1a683146e1c5561534a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
git checkout 2c921da06a8ac8f9e047f1a683146e1c5561534a
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_critical':
>> drivers/acpi/thermal.c:274:15: error: implicit declaration of function 'thermal_acpi_critical_trip_temp' [-Werror=implicit-function-declaration]
274 | ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_hot':
>> drivers/acpi/thermal.c:307:15: error: implicit declaration of function 'thermal_acpi_hot_trip_temp'; did you mean 'thermal_zone_get_crit_temp'? [-Werror=implicit-function-declaration]
307 | ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_get_crit_temp
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_passive':
>> drivers/acpi/thermal.c:339:15: error: implicit declaration of function 'thermal_acpi_passive_trip_temp' [-Werror=implicit-function-declaration]
339 | ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_active':
>> drivers/acpi/thermal.c:380:23: error: implicit declaration of function 'thermal_acpi_active_trip_temp' [-Werror=implicit-function-declaration]
380 | ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/thermal_acpi_critical_trip_temp +274 drivers/acpi/thermal.c
257
258 static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_thermal *tz,
259 struct thermal_trip *trips,
260 int *num_trips)
261 {
262 struct thermal_trip trip = {
263 .type = THERMAL_TRIP_CRITICAL,
264 };
265
266 int ret;
267
268 /*
269 * Module parameters disable the critical trip point
270 */
271 if (crt < 0)
272 goto out;
273
> 274 ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
275 if (ret)
276 goto out;
277
278 if (trip.temperature <= 0) {
279 pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
280 goto out;
281 }
282
283 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
284 if (!trips)
285 goto out;
286
287 trips[*num_trips] = trip; /* structure copy */
288
289 if (crt > 0)
290 acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
291
292 (*num_trips)++;
293 out:
294 return trips;
295 }
296
297 static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz,
298 struct thermal_trip *trips,
299 int *num_trips)
300 {
301 struct thermal_trip trip = {
302 .type = THERMAL_TRIP_HOT,
303 };
304
305 int ret;
306
> 307 ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
308 if (ret)
309 goto out;
310
311 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
312 if (!trips)
313 goto out;
314
315 trips[*num_trips] = trip; /* structure copy */
316
317 (*num_trips)++;
318 out:
319 return trips;
320 }
321
322 static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal *tz,
323 struct thermal_trip *trips,
324 int *num_trips)
325 {
326 acpi_status status;
327 struct acpi_handle_list devices;
328 struct thermal_trip trip = {
329 .type = THERMAL_TRIP_PASSIVE
330 };
331 int ret;
332
333 /*
334 * Module parameters disable all passive trip points
335 */
336 if (psv < 0)
337 goto out;
338
> 339 ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
340 if (ret)
341 goto out;
342
343 status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
344 if (ACPI_FAILURE(status)) {
345 acpi_handle_debug(tz->device->handle, "No passive device associated\n");
346 goto out;
347 }
348
349 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
350 if (!trips)
351 goto out;
352
353 trips[*num_trips] = trip; /* structure copy */
354
355 (*num_trips)++;
356 out:
357 return trips;
358 }
359
360 static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal *tz,
361 struct thermal_trip *trips,
362 int *num_trips)
363 {
364 acpi_status status;
365 struct acpi_handle_list devices;
366 int i, ret;
367
368 /*
369 * Module parameters disable all active trip points
370 */
371 if (act < 0)
372 return trips;
373
374 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
375 struct thermal_trip trip = {
376 .type = THERMAL_TRIP_ACTIVE,
377 };
378 char name[5];
379
> 380 ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
381 if (ret)
382 break;
383
384 sprintf(name, "_AL%d", i);
385
386 status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices);
387 if (ACPI_FAILURE(status)) {
388 acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
389 break;
390 }
391
392 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
393 if (!trips)
394 break;
395
396 trips[*num_trips] = trip; /* structure copy */
397
398 (*num_trips)++;
399 }
400
401 /*
402 * We found at least one trip point and we have an override option
403 */
404 if (i && act) {
405 /*
406 * Regarding the ACPI specification AC0 is the highest active
407 * temperature trip point. We will override this one.
408 */
409 acpi_thermal_trips_override(&trips[*num_trips], act * MILLI);
410 }
411
412 return trips;
413 }
414
Hi Daniel,
I love your patch! Yet something to improve:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc6 next-20230203]
[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-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230203174429.3375691-12-daniel.lezcano%40linaro.org
patch subject: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
config: i386-randconfig-a002 (https://download.01.org/0day-ci/archive/20230204/202302041525.ZDaLecDd-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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/intel-lab-lkp/linux/commit/2c921da06a8ac8f9e047f1a683146e1c5561534a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
git checkout 2c921da06a8ac8f9e047f1a683146e1c5561534a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/acpi/thermal.c:274:8: error: implicit declaration of function 'thermal_acpi_critical_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
^
>> drivers/acpi/thermal.c:307:8: error: implicit declaration of function 'thermal_acpi_hot_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
^
drivers/acpi/thermal.c:307:8: note: did you mean 'thermal_zone_get_crit_temp'?
include/linux/thermal.h:347:5: note: 'thermal_zone_get_crit_temp' declared here
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
^
>> drivers/acpi/thermal.c:339:8: error: implicit declaration of function 'thermal_acpi_passive_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
^
>> drivers/acpi/thermal.c:380:9: error: implicit declaration of function 'thermal_acpi_active_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
^
4 errors generated.
vim +/thermal_acpi_critical_trip_temp +274 drivers/acpi/thermal.c
257
258 static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_thermal *tz,
259 struct thermal_trip *trips,
260 int *num_trips)
261 {
262 struct thermal_trip trip = {
263 .type = THERMAL_TRIP_CRITICAL,
264 };
265
266 int ret;
267
268 /*
269 * Module parameters disable the critical trip point
270 */
271 if (crt < 0)
272 goto out;
273
> 274 ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
275 if (ret)
276 goto out;
277
278 if (trip.temperature <= 0) {
279 pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
280 goto out;
281 }
282
283 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
284 if (!trips)
285 goto out;
286
287 trips[*num_trips] = trip; /* structure copy */
288
289 if (crt > 0)
290 acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
291
292 (*num_trips)++;
293 out:
294 return trips;
295 }
296
297 static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz,
298 struct thermal_trip *trips,
299 int *num_trips)
300 {
301 struct thermal_trip trip = {
302 .type = THERMAL_TRIP_HOT,
303 };
304
305 int ret;
306
> 307 ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
308 if (ret)
309 goto out;
310
311 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
312 if (!trips)
313 goto out;
314
315 trips[*num_trips] = trip; /* structure copy */
316
317 (*num_trips)++;
318 out:
319 return trips;
320 }
321
322 static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal *tz,
323 struct thermal_trip *trips,
324 int *num_trips)
325 {
326 acpi_status status;
327 struct acpi_handle_list devices;
328 struct thermal_trip trip = {
329 .type = THERMAL_TRIP_PASSIVE
330 };
331 int ret;
332
333 /*
334 * Module parameters disable all passive trip points
335 */
336 if (psv < 0)
337 goto out;
338
> 339 ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
340 if (ret)
341 goto out;
342
343 status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
344 if (ACPI_FAILURE(status)) {
345 acpi_handle_debug(tz->device->handle, "No passive device associated\n");
346 goto out;
347 }
348
349 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
350 if (!trips)
351 goto out;
352
353 trips[*num_trips] = trip; /* structure copy */
354
355 (*num_trips)++;
356 out:
357 return trips;
358 }
359
360 static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal *tz,
361 struct thermal_trip *trips,
362 int *num_trips)
363 {
364 acpi_status status;
365 struct acpi_handle_list devices;
366 int i, ret;
367
368 /*
369 * Module parameters disable all active trip points
370 */
371 if (act < 0)
372 return trips;
373
374 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
375 struct thermal_trip trip = {
376 .type = THERMAL_TRIP_ACTIVE,
377 };
378 char name[5];
379
> 380 ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
381 if (ret)
382 break;
383
384 sprintf(name, "_AL%d", i);
385
386 status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices);
387 if (ACPI_FAILURE(status)) {
388 acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
389 break;
390 }
391
392 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
393 if (!trips)
394 break;
395
396 trips[*num_trips] = trip; /* structure copy */
397
398 (*num_trips)++;
399 }
400
401 /*
402 * We found at least one trip point and we have an override option
403 */
404 if (i && act) {
405 /*
406 * Regarding the ACPI specification AC0 is the highest active
407 * temperature trip point. We will override this one.
408 */
409 acpi_thermal_trips_override(&trips[*num_trips], act * MILLI);
410 }
411
412 return trips;
413 }
414
@@ -259,8 +259,11 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status = AE_OK;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_CRITICAL,
+ };
+
+ int ret;
/*
* Module parameters disable the critical trip point
@@ -268,14 +271,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (crt < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No critical threshold\n");
+ ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
- if (temp <= 2732) {
- pr_info(FW_BUG "Invalid critical threshold (%llu)\n", temp);
+
+ if (trip.temperature <= 0) {
+ pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
goto out;
}
@@ -283,10 +284,7 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_CRITICAL;
+ trips[*num_trips] = trip; /* structure copy */
if (crt > 0)
acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
@@ -300,23 +298,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_HOT,
+ };
- status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No hot threshold\n");
+ int ret;
+
+ ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_HOT;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -327,9 +323,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
+ struct acpi_handle_list devices;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_PASSIVE
+ };
+ int ret;
/*
* Module parameters disable all passive trip points
@@ -337,26 +336,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
if (psv < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No passive threshold\n");
+ ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
+
status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(tz->device->handle, "No passive device associated\n");
goto out;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_PASSIVE;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -367,10 +361,9 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
- int i;
+ struct acpi_handle_list devices;
+ int i, ret;
/*
* Module parameters disable all active trip points
@@ -379,12 +372,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
return trips;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_ACTIVE,
+ };
char name[5];
- sprintf(name, "_AC%d", i);
-
- status = acpi_evaluate_integer(tz->device->handle, name, NULL, &temp);
- if (ACPI_FAILURE(status))
+ ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
+ if (ret)
break;
sprintf(name, "_AL%d", i);
@@ -394,16 +388,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
break;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
break;
- memset(&trips[*num_trips], 0, sizeof(*trips));
+ trips[*num_trips] = trip; /* structure copy */
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_ACTIVE;
-
(*num_trips)++;
}