From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: rjw@rjwysocki.net, lukasz.luba@arm.com, robh@kernel.org,
heiko@sntech.de, arnd@linaro.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
"open list:GENERIC INCLUDE/ASM HEADER FILES"
<linux-arch@vger.kernel.org>
Subject: Re: [PATCH v5 1/6] powercap/drivers/dtpm: Move dtpm table from init to data section
Date: Mon, 10 Jan 2022 14:33:39 +0100 [thread overview]
Message-ID: <a4581b79-c2b2-c2bd-b96c-98389ea15a1e@linaro.org> (raw)
In-Reply-To: <CAPDyKFpWtVFoqhFrhMQOgHUjggvg_GPYwmeK-jkphQpA7KQZRw@mail.gmail.com>
On 07/01/2022 15:49, Ulf Hansson wrote:
> On Fri, 7 Jan 2022 at 14:15, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>
>> On 31/12/2021 14:33, Ulf Hansson wrote:
>>> On Sat, 18 Dec 2021 at 14:00, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>>>
>>>> The dtpm table is used to let the different dtpm backends to register
>>>> their setup callbacks in a single place and preventing to export
>>>> multiple functions all around the kernel. That allows the dtpm code to
>>>> be self-encapsulated.
>>>
>>> Well, that's not entirely true. The dtpm code and its backends (or
>>> ops, whatever we call them) are already maintained from a single
>>> place, the /drivers/powercap/* directory. I assume we intend to keep
>>> it like this going forward too, right?
>>>
>>> That is also what patch4 with the devfreq backend continues to conform to.
>>>
>>>>
>>>> The dtpm hierarchy will be passed as a parameter by a platform
>>>> specific code and that will lead to the creation of the different dtpm
>>>> nodes.
>>>>
>>>> The function creating the hierarchy could be called from a module at
>>>> init time or when it is loaded. However, at this moment the table is
>>>> already freed as it belongs to the init section and the creation will
>>>> lead to a invalid memory access.
>>>>
>>>> Fix this by moving the table to the data section.
>>>
>>> With the above said, I find it a bit odd to put a table in the data
>>> section like this. Especially, since the only remaining argument for
>>> why, is to avoid exporting functions, which isn't needed anyway.
>>>
>>> I mean, it would be silly if we should continue to put subsystem
>>> specific tables in here, to just let them contain a set of subsystem
>>> specific callbacks.
>>
>> So I tried to change the approach and right now I was not able to find
>> an alternative keeping the code self-encapsulate and without introducing
>> cyclic dependencies.
>>
>> I suggest to keep the patch as it is and double check if it makes sense
>> to change it after adding more dtpm backends
>>
>> Alternatively I can copy the table to a dynamically allocated table.
>
> I am not sure I understand the problem. You don't need a "table of
> callbacks" at all, at least to start with.
>
> Instead, what you need is to make a call to a function, or actually
> one call per supported dtpm type from dtpm_setup_dt() (introduced in
> patch2).
>
> For CPUs, you would simply call dtpm_cpu_setup() (introduced in
> patch3) from dtpm_setup_dt(), rather than walking the dtpm table an
> invoking the ->setup() callback.
>
> Did that make sense to you?
Yeah, I already got the point ;)
I'll convert it to something else, and we will see in the future if that
needs to be converted back to the table.
> Going forward, when we decide to introduce the option to add/remove
> support for dtpm types dynamically, you can then convert to a
> dynamically allocated table.
>
> [...]
>
> Kind regards
> Uffe
>
--
<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:[~2022-01-10 13:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-18 13:00 [PATCH v5 0/6] powercap/drivers/dtpm: Create the dtpm hierarchy Daniel Lezcano
2021-12-18 13:00 ` [PATCH v5 1/6] powercap/drivers/dtpm: Move dtpm table from init to data section Daniel Lezcano
2021-12-31 13:33 ` Ulf Hansson
2022-01-04 8:57 ` Daniel Lezcano
2022-01-07 13:15 ` Daniel Lezcano
2022-01-07 14:49 ` Ulf Hansson
2022-01-10 13:33 ` Daniel Lezcano [this message]
2021-12-18 13:00 ` [PATCH v5 2/6] powercap/drivers/dtpm: Add hierarchy creation Daniel Lezcano
2021-12-31 13:45 ` Ulf Hansson
2022-01-05 16:00 ` Daniel Lezcano
2022-01-07 15:54 ` Ulf Hansson
2022-01-10 15:55 ` Daniel Lezcano
2022-01-11 8:28 ` Ulf Hansson
2022-01-11 17:52 ` Daniel Lezcano
2022-01-12 12:00 ` Ulf Hansson
2022-01-14 19:15 ` Daniel Lezcano
2021-12-18 13:00 ` [PATCH v5 3/6] powercap/drivers/dtpm: Add CPU DT initialization support Daniel Lezcano
2021-12-31 13:46 ` Ulf Hansson
2021-12-18 13:00 ` [PATCH v5 4/6] powercap/drivers/dtpm: Add dtpm devfreq with energy model support Daniel Lezcano
2021-12-18 13:00 ` [PATCH v5 5/6] rockchip/soc/drivers: Add DTPM description for rk3399 Daniel Lezcano
2021-12-31 13:57 ` Ulf Hansson
2022-01-04 9:29 ` Geert Uytterhoeven
2022-01-05 9:21 ` Daniel Lezcano
2022-01-05 11:25 ` Daniel Lezcano
2021-12-18 13:00 ` [PATCH v5 6/6] qcom/soc/drivers: Add DTPM description for sdm845 Daniel Lezcano
2021-12-18 19:47 ` Steev Klimaszewski
2021-12-18 20:11 ` Daniel Lezcano
2021-12-19 18:44 ` Steev Klimaszewski
2021-12-19 20:27 ` Daniel Lezcano
2022-01-07 19:27 ` Bjorn Andersson
2022-01-07 22:07 ` Daniel Lezcano
2022-01-07 23:51 ` Bjorn Andersson
2021-12-23 13:20 ` [PATCH v5 0/6] powercap/drivers/dtpm: Create the dtpm hierarchy Daniel Lezcano
2021-12-23 13:32 ` Ulf Hansson
2021-12-23 13:42 ` 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=a4581b79-c2b2-c2bd-b96c-98389ea15a1e@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=arnd@arndb.de \
--cc=arnd@linaro.org \
--cc=heiko@sntech.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rjw@rjwysocki.net \
--cc=robh@kernel.org \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).