From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
rafael@kernel.org
Cc: rui.zhang@intel.com, lukasz.luba@arm.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@collabora.com, wenst@chromium.org
Subject: Re: [PATCH v2] thermal: Add support for device tree thermal zones consumers
Date: Tue, 5 Dec 2023 19:47:54 +0100 [thread overview]
Message-ID: <3428b2af-5522-4090-995a-10eaee90c28e@linaro.org> (raw)
In-Reply-To: <03e950a1-0334-40ab-aa77-ac8175877172@collabora.com>
Hi Angelo,
On 05/12/2023 14:48, AngeloGioacchino Del Regno wrote:
> Il 01/12/23 15:18, Daniel Lezcano ha scritto:
[ ... ]
>> Putting apart the fact the change you propose is not relevant as there
>> is already everything in. My comment is about the current state of the
>> thermal framework.
>>
>
> I don't really understand this assertion, and I'm afraid that I'm
> underestimating
> something so, in case, please help me to understand what am I missing here.
Sure. Let me clarify my understanding of you proposal and my assertion.
- A driver needs a thermal zone device structure pointer in order to
read its temperature. But as it is not the creator, it does not have
this pointer.
- As a solution, several drivers are using a specific DT bindings to
map a thermal zone "name/type' with a string to refer from the driver a
specific thermal zone node name. Then the function
thermal_zone_device_get_by_name() is used to retrieve the pointer.
- Your proposal is to provide that mechanism in the thermal_of code
directly, so the code can be factored out for all these drivers.
Is my understanding correct?
My point is:
- The driver are mapping a thermal zone with a name but a node name is
supposed to be unique on DT (but that is implicit)
- A phandle is enough to get the node name, no need to add a thermal
zone name to get the node and then get the thermal zone. It is duplicate
information as the DT uses the node name as a thermal zone name.
We could have:
thermal-zones {
display {
polling-delay-passive = <0>;
polling-delay = <0>;
thermal-sensors = <&display_temp>;
};
};
papirus27@0{
[ ... ]
--- pervasive,thermal-zone = "display";
+++ pervasive,thermal-zone = <&display>;
};
The ux500 is directly calling thermal_zone_device_get_by_name() with the
thermal zone node name.
> For how I see it, in the thermal framewoek I don't see any "somewhat
> standardized"
> helper like the one(s) that I'm introducing with this patch
> (thermal_of_get_zone(),
> thermal_of_get_zone_by_index()), and this is the exact reason why I'm
> proposing
> this patch.
>
> Then again - I mean no disrespect - it's just that I don't understand
> (yet) why you
> are saying that "everything is already available", because I really
> don't see it.
Ok said differently, thermal zone name and type are messy.
Let's clarify that and then let's see with the result if adding this
thermal zone node/name mapping still makes sense.
>> - A thermal zone does not have a name but a type
>>
>> - We use the thermal zone DT node name to register as a name but it
>> is a type from the thermal framework point of view
>
> This is something that I didn't realize before. Thanks for that.
>
> ...and yes, we're registering a "name" from DT as a "type" in the
> framework, this
> is highly confusing and needs to be cleaned up.
>
>>
>> - We can register several thermal zones with the same type (so we
>> can have duplicate names if we use type as name)
>>
>
> ...which makes sense, after realizing that we're registering a TYPE and
> not a NAME,
> and I agree about the logic for which that multiple zones can be of the
> same type.
>
>> - We use thermal_zone_device_get_by_name() but actually it checks
>> against the type and as we can have multiple identical types, the
>> function returns the first one found
>>
>
> The first thing that comes to mind is to rename
> thermal_zone_device_get_by_name()
> to thermal_zone_device_get_by_type(), but then I'd be reintroducing the
> former and
> this gives me concerns about OOT drivers using that and developers
> getting highly
> confused (name->type, but name exists again, so they might erroneously
> just fix the
> call to xxx_by_name() instead of changing it to xxx_by_type()).
> Should I *not* be concerned about that?
Not really :)
TBH, OOT drivers do not exist from upstream POV.
> Any suggestion?
Yes, let's introduce a thermal zone name in the tzd.
- There are now too many parameters to the function
thermal_zone_device_register*(), so we can't add a new 'name' parameter.
Introduce a thermal_zone_device_parameters structure. This structure
will contain all thermal_zone_device_register_* parameter function.
There won't be any functional changes, just how the parameters are
passed. Perhaps, you should use an intermediate function to not have the
change impacting everywhere.
- then add a const char *name field in this structure and in the
thermal_zone_device structure. So we can assign the name to the thermal
zone. The name must be checked against duplicate. If no name is
specified when creating a thermal zone, then name = type.
- In thermal_of, use the node name for the type and the name, that
will be duplicate but we will sort it out later.
- Add the name in sysfs
Second step, track down users of thermal_zone_device_get_by_name() and
check if they can use the name instead of the type. I'm pretty sure it
is the case for most of the callers.
With that, there will be a nice clarification IMHO.
Then we will be able to restate the 'type' with something different
without breaking the existing ABI.
--
<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:[~2023-12-05 18:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 14:48 [PATCH v2] thermal: Add support for device tree thermal zones consumers AngeloGioacchino Del Regno
2023-11-29 13:43 ` AngeloGioacchino Del Regno
2023-11-30 13:22 ` Daniel Lezcano
2023-12-01 9:52 ` AngeloGioacchino Del Regno
2023-12-01 14:18 ` Daniel Lezcano
2023-12-05 13:48 ` AngeloGioacchino Del Regno
2023-12-05 18:47 ` Daniel Lezcano [this message]
2023-12-06 10:00 ` AngeloGioacchino Del Regno
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=3428b2af-5522-4090-995a-10eaee90c28e@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=wenst@chromium.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