From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-pm@vger.kernel.org, lukasz.luba@arm.com, quic_manafm@quicinc.com
Subject: Re: [PATCH v2 2/7] thermal/core: Add thresholds support
Date: Wed, 4 Sep 2024 10:43:48 +0200 [thread overview]
Message-ID: <3459b7a6-d82b-4c2b-aed6-a97ad67f89db@linaro.org> (raw)
In-Reply-To: <CAJZ5v0h=DgBSiFbdmnzSFjEJd6sdBffCODspxmM-G92FN2HGiA@mail.gmail.com>
On 22/08/2024 13:30, Rafael J. Wysocki wrote:
> On Wed, Aug 21, 2024 at 10:05 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>>
>> On Fri, Aug 16, 2024 at 10:12 AM Daniel Lezcano
>> <daniel.lezcano@linaro.org> wrote:
>
> [cut]
>
>>> --- /dev/null
>>> +++ b/drivers/thermal/thermal_thresholds.c
>>> @@ -0,0 +1,241 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +/*
>>> + * Copyright 2024 Linaro Limited
>>> + *
>>> + * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
>>> + *
>>> + * Thermal thresholds
>>> + */
>>> +#include <linux/list.h>
>>> +#include <linux/list_sort.h>
>>> +#include <linux/slab.h>
>>> +
>>> +#include "thermal_core.h"
>>
>> +#include "thermal_thresholds.h"
>>
>>> +
>>> +struct thresholds {
>>> + struct list_head list;
>>> +};
>>
>> This duplicates the definition in the header file.
>>
>> Besides, why is the wrapper struct needed?
>
> On second thought, it can hold a pointer to the first threshold that
> was strictly above the zone temperature when
> thermal_thresholds_handle() ran last time, so something like:
>
> struct thresholds {
> struct list_head list;
> struct user_threhold *first_above;
> };
>
> and first_above == NULL would mean that the zone temperature was above
> all of the threshold or at the highest one.
>
> Then thermal_thresholds_handle() could do something like:
>
> tr = tz->user_thresholds.first_above;
>
> if (tr && tz->temperature >= tr->temperature) {
> do {
> if (tr->direction & THERMAL_THRESHOLD_WAY_UP)
> notify = true;
>
> if (tr->list_node.next != &tz->user_thresholds.list) {
> tr = list_next_entry(tr, list_node);
> else
> tr = NULL;
> } while (tr && tz->temperature >= tr->temperature);
> } else {
> if (!tr)
> tr = list_last_entry(&tz->user_thresholds.list,
> struct user_threshold, list_node);
>
> while (tz->temperature < tr->temperature)
> if (tr->direction & THERMAL_THRESHOLD_WAY_DOWN)
> notify = true;
>
> if (tr->list_node.prev != &tz->user_thresholds.list) {
> tr = list_prev_entry(tr, list_node);
> else
> break;
> }
> if (tz->temperature >= tr->temperature)
> tr = NULL;
> }
> tz->user_thresholds.first_above = tr;
>
> which is a bit simpler than the code in the current patch.
TBH, it is probably a matter of taste but I don't see how it is simpler,
especially if someone wants to to understand or add something in the
code. I would prefer to keep the initial routine which was already tested.
[ ... ]
>
> Also, I'm not sure why "high" and "low" are needed at all.
>
> The current and last zone temperature could be included in the
> notification just fine and user space should be able to figure out
> which thresholds are affected.
I'm not sure to get the question. high and low are needed because the
thermal core will call set_trips(). The trips and the thresholds are
combined to find out the high and low temperature to program the driver
to trigger an interrupt.
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2024-09-04 8:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 8:12 [PATCH v2 0/7] Add thermal thresholds support Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 1/7] thermal/core: Compute low and high boundaries in thermal_zone_device_update() Daniel Lezcano
2024-08-16 11:34 ` Rafael J. Wysocki
2024-08-16 12:06 ` Daniel Lezcano
2024-08-19 14:07 ` Rafael J. Wysocki
2024-08-16 8:12 ` [PATCH v2 2/7] thermal/core: Add thresholds support Daniel Lezcano
2024-08-21 20:05 ` Rafael J. Wysocki
2024-08-22 11:30 ` Rafael J. Wysocki
2024-09-04 8:43 ` Daniel Lezcano [this message]
2024-08-22 17:20 ` Daniel Lezcano
2024-08-22 20:09 ` Rafael J. Wysocki
2024-08-16 8:12 ` [PATCH v2 3/7] thermal/core: Connect the threshold with the core Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 4/7] thermal/netlink: Add the commands and the events for the thresholds Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 5/7] tools/lib/thermal: Make more generic the command encoding function Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 6/7] tools/lib/thermal: Add the threshold netlink ABI Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 7/7] tools/thermal/thermal-engine: Take into account the thresholds API Daniel Lezcano
2024-08-21 19:06 ` [PATCH v2 0/7] Add thermal thresholds support Rafael J. Wysocki
2024-08-21 20:04 ` Pandruvada, Srinivas
2024-08-21 20:20 ` Rafael J. Wysocki
2024-08-21 22:16 ` Pandruvada, Srinivas
2024-08-22 9:41 ` Rafael J. Wysocki
2024-08-22 12:11 ` Pandruvada, Srinivas
2024-08-22 12:52 ` Pandruvada, Srinivas
2024-08-22 13:01 ` Rafael J. Wysocki
2024-08-22 17:08 ` Daniel Lezcano
2024-08-22 18:12 ` Pandruvada, Srinivas
2024-08-22 16:51 ` Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3459b7a6-d82b-4c2b-aed6-a97ad67f89db@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=quic_manafm@quicinc.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox