All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Kevin Hilman <khilman@baylibre.com>, Nicolas Pitre <npitre@baylibre.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Linux PM list <linux-pm@vger.kernel.org>,
	linux-clk <linux-clk@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PM / clk: make PM clock layer compatible with clocks that must sleep
Date: Tue, 19 Jan 2021 21:38:22 +0100	[thread overview]
Message-ID: <CAMuHMdX8T+tO-sT_tgrgEi-D0z2ac7k4Atg13arHN5bA84HqTA@mail.gmail.com> (raw)
In-Reply-To: <7him7sydd6.fsf@baylibre.com>

Hi Kevin, Nicolas,

On Tue, Jan 19, 2021 at 7:45 PM Kevin Hilman <khilman@baylibre.com> wrote:
> [ + Geert.. renesas SoCs are the primary user of PM clk ]

Thanks!

> Nicolas Pitre <npitre@baylibre.com> writes:
> > The clock API splits its interface into sleepable ant atomic contexts:
> >
> > - clk_prepare/clk_unprepare for stuff that might sleep
> >
> > - clk_enable_clk_disable for anything that may be done in atomic context
> >
> > The code handling runtime PM for clocks only calls clk_disable() on
> > suspend requests, and clk_enable on resume requests. This means that
> > runtime PM with clock providers that only have the prepare/unprepare
> > methods implemented is basically useless.
> >
> > Many clock implementations can't accommodate atomic contexts. This is
> > often the case when communication with the clock happens through another
> > subsystem like I2C or SCMI.
> >
> > Let's make the clock PM code useful with such clocks by safely invoking
> > clk_prepare/clk_unprepare upon resume/suspend requests. Of course, when
> > such clocks are registered with the PM layer then pm_runtime_irq_safe()
> > can't be used, and neither pm_runtime_suspend() nor pm_runtime_resume()
> > may be invoked in atomic context.
> >
> > For clocks that do implement the enable and disable methods then
> > everything just works as before.
> >
> > Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

Thanks for your patch!

> > --- a/drivers/base/power/clock_ops.c
> > +++ b/drivers/base/power/clock_ops.c

> > +/**
> > + * pm_clk_op_lock - ensure exclusive access for performing clock operations.
> > + * @psd: pm_subsys_data instance corresponding to the PM clock entry list
> > + *    and clk_op_might_sleep count being used.
> > + * @flags: stored irq flags.
> > + * @fn: string for the caller function's name.
> > + *
> > + * This is used by pm_clk_suspend() and pm_clk_resume() to guard
> > + * against concurrent modifications to the clock entry list and the
> > + * clock_op_might_sleep count. If clock_op_might_sleep is != 0 then
> > + * only the mutex can be locked and those functions can only be used in
> > + * non atomic context. If clock_op_might_sleep == 0 then these functions
> > + * may be used in any context and only the spinlock can be locked.
> > + * Returns -EINVAL if called in atomic context when clock ops might sleep.
> > + */
> > +static int pm_clk_op_lock(struct pm_subsys_data *psd, unsigned long *flags,
> > +                       const char *fn)
> > +{
> > +     bool atomic_context = in_atomic() || irqs_disabled();

Is this safe? Cfr.
https://lore.kernel.org/dri-devel/20200914204209.256266093@linutronix.de/

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2021-01-19 20:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05  3:17 [PATCH] PM / clk: make PM clock layer compatible with clocks that must sleep Nicolas Pitre
2021-01-17 23:49 ` Nicolas Pitre
2021-01-19 20:15   ` Rafael J. Wysocki
2021-01-19 18:45 ` Kevin Hilman
2021-01-19 20:38   ` Geert Uytterhoeven [this message]
2021-01-19 21:22     ` Nicolas Pitre
2021-01-21  9:11 ` Naresh Kamboju
2021-01-21 10:58   ` Geert Uytterhoeven
2021-01-21 12:09     ` Naresh Kamboju
2021-01-21 14:44       ` Rafael J. Wysocki
2021-01-21 16:18         ` Nicolas Pitre
2021-01-21 17:23         ` [PATCH v2] " Nicolas Pitre
2021-01-21 19:01           ` Rafael J. Wysocki
2021-01-22 15:09             ` Rafael J. Wysocki
2021-01-22 15:48               ` Naresh Kamboju
2021-01-22 15:56                 ` Rafael J. Wysocki
2021-01-22 15:59                   ` Nicolas Pitre
2021-01-22 16:00                     ` Nicolas Pitre
2021-01-22 16:02                     ` Rafael J. Wysocki
2021-01-23 23:07                       ` [PATCH v3] " Nicolas Pitre
2021-01-25 18:15                         ` Rafael J. Wysocki
2021-01-25 18:24                           ` Nicolas Pitre
2021-01-25 19:29                             ` [PATCH v4] " Nicolas Pitre
2021-01-27 18:31                               ` Rafael J. Wysocki
     [not found]                               ` <161301451636.1254594.7473642352348913785@swboyd.mtv.corp.google.com>
2021-02-11  7:55                                 ` Geert Uytterhoeven
2021-01-22 15:52               ` [PATCH v2] " Nicolas Pitre
2021-01-05  5:51 [PATCH] " kernel test robot

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=CAMuHMdX8T+tO-sT_tgrgEi-D0z2ac7k4Atg13arHN5bA84HqTA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mturquette@baylibre.com \
    --cc=npitre@baylibre.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@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 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.