mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation
@ 2024-03-31  8:37 Stephen Horvath
  2024-04-02 19:40 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Horvath @ 2024-03-31  8:37 UTC (permalink / raw)
  To: Rafael J. Wysocki, Zhang Rui, Len Brown, linux-acpi, linux-kernel
  Cc: Stephen Horvath

Some laptops where the thermal control is handled by the EC may
provide trip points that fail the kernels new validation, but still have
working temperature sensors. An example of this is the Framework 13 AMD.

This patch allows the thermal zone to still be registered without trip
points if the trip points fail validation, allowing the temperature
sensor to be viewed and used by the user.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218586
Fixes: 9c8647224e9f ("ACPI: thermal: Use library functions to obtain trip point temperature values")
Signed-off-by: Stephen Horvath <s.horvath@outlook.com.au>
---
 V1 -> V2: Referenced bug tracker in commit, and switched to using
                `thermal_tripless_zone_device_register` as per the
                suggestion of Rafael J. Wysocki.

 drivers/acpi/thermal.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 302dce0b2b50..10044c56b85e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -662,14 +662,16 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
 {
 	int result;
 
-	tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
-								   trip_table,
-								   trip_count,
-								   tz,
-								   &acpi_thermal_zone_ops,
-								   NULL,
-								   passive_delay,
-								   tz->polling_frequency * 100);
+	if (trip_count) {
+		tz->thermal_zone = thermal_zone_device_register_with_trips(
+			"acpitz", trip_table, trip_count, tz,
+			&acpi_thermal_zone_ops, NULL, passive_delay,
+			tz->polling_frequency * 100);
+	} else {
+		tz->thermal_zone = thermal_tripless_zone_device_register(
+			"acpitz", tz, &acpi_thermal_zone_ops, NULL);
+	}
+
 	if (IS_ERR(tz->thermal_zone))
 		return PTR_ERR(tz->thermal_zone);
 
@@ -903,8 +905,6 @@ static int acpi_thermal_add(struct acpi_device *device)
 
 	if (trip == trip_table) {
 		pr_warn(FW_BUG "No valid trip points!\n");
-		result = -ENODEV;
-		goto free_memory;
 	}
 
 	result = acpi_thermal_register_thermal_zone(tz, trip_table,

base-commit: 4cece764965020c22cff7665b18a012006359095
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation
  2024-03-31  8:37 [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation Stephen Horvath
@ 2024-04-02 19:40 ` Rafael J. Wysocki
  2024-04-02 22:43   ` Stephen Horvath
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2024-04-02 19:40 UTC (permalink / raw)
  To: Stephen Horvath
  Cc: Rafael J. Wysocki, Zhang Rui, Len Brown, linux-acpi, linux-kernel

On Sun, Mar 31, 2024 at 10:37 AM Stephen Horvath
<s.horvath@outlook.com.au> wrote:
>
> Some laptops where the thermal control is handled by the EC may
> provide trip points that fail the kernels new validation, but still have
> working temperature sensors. An example of this is the Framework 13 AMD.
>
> This patch allows the thermal zone to still be registered without trip
> points if the trip points fail validation, allowing the temperature
> sensor to be viewed and used by the user.
>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218586
> Fixes: 9c8647224e9f ("ACPI: thermal: Use library functions to obtain trip point temperature values")
> Signed-off-by: Stephen Horvath <s.horvath@outlook.com.au>
> ---
>  V1 -> V2: Referenced bug tracker in commit, and switched to using
>                 `thermal_tripless_zone_device_register` as per the
>                 suggestion of Rafael J. Wysocki.
>
>  drivers/acpi/thermal.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index 302dce0b2b50..10044c56b85e 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -662,14 +662,16 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
>  {
>         int result;
>
> -       tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
> -                                                                  trip_table,
> -                                                                  trip_count,
> -                                                                  tz,
> -                                                                  &acpi_thermal_zone_ops,
> -                                                                  NULL,
> -                                                                  passive_delay,
> -                                                                  tz->polling_frequency * 100);
> +       if (trip_count) {
> +               tz->thermal_zone = thermal_zone_device_register_with_trips(
> +                       "acpitz", trip_table, trip_count, tz,
> +                       &acpi_thermal_zone_ops, NULL, passive_delay,
> +                       tz->polling_frequency * 100);
> +       } else {
> +               tz->thermal_zone = thermal_tripless_zone_device_register(
> +                       "acpitz", tz, &acpi_thermal_zone_ops, NULL);
> +       }
> +
>         if (IS_ERR(tz->thermal_zone))
>                 return PTR_ERR(tz->thermal_zone);
>
> @@ -903,8 +905,6 @@ static int acpi_thermal_add(struct acpi_device *device)
>
>         if (trip == trip_table) {
>                 pr_warn(FW_BUG "No valid trip points!\n");
> -               result = -ENODEV;
> -               goto free_memory;
>         }
>
>         result = acpi_thermal_register_thermal_zone(tz, trip_table,
>
> base-commit: 4cece764965020c22cff7665b18a012006359095
> --

Applied as 6.9-rc material under a modified subject ("ACPI: thermal:
Register thermal zones without valid trip points"), with some
redundant braces removed and with some white space adjusted.

Please verify the result at
https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=bleeding-edge&id=8a4ff5452dd0cdcc35940460bb777d836bece11c

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation
  2024-04-02 19:40 ` Rafael J. Wysocki
@ 2024-04-02 22:43   ` Stephen Horvath
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Horvath @ 2024-04-02 22:43 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Zhang Rui, Len Brown, linux-acpi, linux-kernel

On 3/4/24 05:40, Rafael J. Wysocki wrote:> Applied as 6.9-rc material 
under a modified subject ("ACPI: thermal:
> Register thermal zones without valid trip points"), with some
> redundant braces removed and with some white space adjusted.
> 
> Please verify the result at
> https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=bleeding-edge&id=8a4ff5452dd0cdcc35940460bb777d836bece11c

Hi Rafael, it works!

Thanks a lot for your help!

Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02 22:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31  8:37 [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation Stephen Horvath
2024-04-02 19:40 ` Rafael J. Wysocki
2024-04-02 22:43   ` Stephen Horvath

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

all inboxes | Powered by JetHome®