All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: rjw@rjwysocki.net, heiko@sntech.de, lukasz.luba@arm.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v1 4/7] powercap/dtpm: Destroy hierarchy function
Date: Thu, 17 Feb 2022 14:12:54 +0100	[thread overview]
Message-ID: <CAPDyKFq1sbLYn+uWmNB-X_tWz0vsLoUY-fyVa2634sZ-nz=ipA@mail.gmail.com> (raw)
In-Reply-To: <0e7bf391-08f1-88b3-14c2-8bbf45ad7491@linaro.org>

On Wed, 16 Feb 2022 at 20:25, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>
> On 16/02/2022 17:31, Ulf Hansson wrote:
> > On Sun, 30 Jan 2022 at 22:02, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
> >>
> >> The hierarchy creation function exits but without a destroy hierarchy
> >> function. Due to that, the modules creating the hierarchy can not be
> >> unloaded properly because they don't have an exit callback.
> >>
> >> Provide the dtpm_destroy_hierarchy() function to remove the previously
> >> created hierarchy.
> >>
> >> The function relies on all the release mechanisms implemented by the
> >> underlying powercap framework.
> >>
> >> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> >> ---
> >>   drivers/powercap/dtpm.c | 43 +++++++++++++++++++++++++++++++++++++++++
> >>   include/linux/dtpm.h    |  3 +++
> >>   2 files changed, 46 insertions(+)
> >>
> >> diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
> >> index 7bddd25a6767..d9d74f981118 100644
> >> --- a/drivers/powercap/dtpm.c
> >> +++ b/drivers/powercap/dtpm.c
> >> @@ -617,3 +617,46 @@ int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table)
> >>          return ret;
> >>   }
> >>   EXPORT_SYMBOL_GPL(dtpm_create_hierarchy);
> >> +
> >> +static void __dtpm_destroy_hierarchy(struct dtpm *dtpm)
> >> +{
> >> +       struct dtpm *child, *aux;
> >> +
> >> +       list_for_each_entry_safe(child, aux, &dtpm->children, sibling)
> >> +               __dtpm_destroy_hierarchy(child);
> >> +
> >> +       /*
> >> +        * At this point, we know all children were removed from the
> >> +        * recursive call before
> >> +        */
> >> +       dtpm_unregister(dtpm);
> >> +}
> >> +
> >> +void dtpm_destroy_hierarchy(void)
> >> +{
> >> +       int i;
> >> +
> >> +       mutex_lock(&dtpm_lock);
> >> +
> >> +       if (!pct)
> >
> > As I kind of indicated in one of the earlier replies, it looks like
> > dtpm_lock is being used to protect the global "pct". What else?
>
> The root node pointer and the lists describing the hierarchy
>
> > Rather than doing it like this, couldn't you instead let
> > dtpm_create_hiearchy() return a handle/cookie for a "dtpm hierarchy".
> > This handle then needs to be passed to dtpm_destroy_hierarchy().
> >
> > In this way, the "pct" doesn't need to be protected and you wouldn't
> > need the global "pct" at all. Although, maybe there would be other
> > problems with this?
>
> The only problem I see with this approach is the dtpm framework is
> designed to be a singleton, no other instance of the hierarchy can exists.

Right. So, it's not likely that we need to change this in future then,
I assume!?

>
> By allowing returning a pointer or whatever, that implies multiple
> controller can be created.

Yes.

>
> In addition that would mean duplicating a global variable for each
> module to store the pointer at init time in order to reuse it at exit time.

Yes, that seems unnecessary. At least as long as the dtpm framework
remains to be a singleton.

Kind regards
Uffe

  reply	other threads:[~2022-02-17 13:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-30 21:02 [PATCH v1 1/7] powercap/dtpm: Change locking scheme Daniel Lezcano
2022-01-30 21:02 ` [PATCH v1 2/7] powercap/dtpm_cpu: Reset per_cpu variable in the release function Daniel Lezcano
2022-02-16 16:24   ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 3/7] powercap/dtpm: Fixup kfree for virtual node Daniel Lezcano
2022-02-16 16:22   ` Ulf Hansson
2022-02-16 18:10     ` Daniel Lezcano
2022-02-17 13:17       ` Ulf Hansson
2022-02-17 13:54         ` Daniel Lezcano
2022-02-17 15:45           ` Ulf Hansson
2022-02-18 13:17             ` Daniel Lezcano
2022-02-22 15:55               ` Ulf Hansson
2022-02-22 15:59                 ` Daniel Lezcano
2022-01-30 21:02 ` [PATCH v1 4/7] powercap/dtpm: Destroy hierarchy function Daniel Lezcano
2022-02-16 16:31   ` Ulf Hansson
2022-02-16 19:25     ` Daniel Lezcano
2022-02-17 13:12       ` Ulf Hansson [this message]
2022-02-17 13:17   ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 5/7] powercap/dtpm: Move the 'root' reset place Daniel Lezcano
2022-02-17 13:19   ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 6/7] powercap/dtpm/dtpm_cpu: Add exit function Daniel Lezcano
2022-02-17 13:20   ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 7/7] dtpm/soc/rk3399: Add the ability to unload the module Daniel Lezcano
2022-01-30 21:02   ` Daniel Lezcano
2022-01-30 21:02   ` Daniel Lezcano
2022-02-17 13:21   ` Ulf Hansson
2022-02-17 13:21     ` Ulf Hansson
2022-02-17 13:21     ` Ulf Hansson
2022-02-16 16:24 ` [PATCH v1 1/7] powercap/dtpm: Change locking scheme Ulf Hansson

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='CAPDyKFq1sbLYn+uWmNB-X_tWz0vsLoUY-fyVa2634sZ-nz=ipA@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.