From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Arnd Bergmann <arnd@arndb.de>,
Randy Dunlap <rdunlap@infradead.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
Wei WANG <wei_wang@realsil.com.cn>,
Kai-Heng Feng <kai.heng.feng@canonical.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH -next] misc: rtsx: fix build for CONFIG_PM not set
Date: Sun, 6 Mar 2022 17:57:24 +0000 [thread overview]
Message-ID: <20220306175724.00002fc0@Huawei.com> (raw)
In-Reply-To: <TOXB8R.SKOD9EMPEKSW1@crapouillou.net>
On Sun, 6 Mar 2022 15:29:17 +0000
Paul Cercueil <paul@crapouillou.net> wrote:
> Hi Jonathan,
>
> Le dim., mars 6 2022 at 15:12:12 +0000, Jonathan Cameron
> <Jonathan.Cameron@Huawei.com> a écrit :
> > On Sun, 27 Feb 2022 17:56:31 +0000
> > Paul Cercueil <paul@crapouillou.net> wrote:
> >
> >> Le dim., févr. 27 2022 at 18:51:38 +0100, Arnd Bergmann
> >> <arnd@arndb.de> a écrit :
> >> > On Sun, Feb 27, 2022 at 6:46 PM Paul Cercueil
> >> <paul@crapouillou.net>
> >> > wrote:
> >> >> Le dim., févr. 27 2022 at 18:30:16 +0100, Arnd Bergmann
> >> >>
> >> >> There could be a DEFINE_DEV_PM_OPS(), but I don't think that's
> >> >> really
> >> >> needed - you can very well declare your struct dev_pm_ops
> >> without
> >> >> using
> >> >> one of these macros. Just make sure to use the
> >> SYSTEM_SLEEP_PM_OPS /
> >> >> RUNTIME_PM_OPS macros for the callbacks and pm_ptr() for the
> >> >> device.pm
> >> >> pointer.
> >> >
> >> > Ah, of course, so it comes down to
> >> > s/SET_SYSTEM_SLEEP_PM_OPS/SYSTEM_SLEEP_PM_OPS/ while
> >> > removing all the #ifdef an __maybe_unused annotations. The
> >> pm_ptr()
> >> > in driver.pm makes this slightly more optimized AFAICT, but has no
> >> > effect on behavior, right?
> >>
> >> The use of SYSTEM_SLEEP_PM_OPS makes sure that the callbacks are
> >> dropped if the dev_pm_ops is dead code, and the pm_ptr() must be
> >> used
> >> for the compiler to know that the dev_pm_ops is dead code.
> >>
> >> -Paul
> >>
> >>
> >
> > Hi Paul,
> >
> > We have one remaining case which is still ugly to do.
> > Where both SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS are set and
> > the dev_pm_ops structure is exported.
> >
> > For that one we still need to expose #ifdef fun in the
> > drivers I think.
> >
> > Any suggestions on a clean solution for that?
>
> Use the _EXPORT_DEV_PM_OPS() macro?
>
> If you make it call __EXPORT_SYMBOL() (with two underscores instead of
> one) you can specify the namespace as well. All you need then is a nice
> wrapper macro in pm_runtime.h, that can be used in the driver.
Yup. The patch for adding namespace versions in the first place
did that.
https://lore.kernel.org/linux-iio/20220220181522.541718-1-jic23@kernel.org/T/#m5a3dc798606f88c10870a66e18b5b175e1a30243
I was just hoping we could maybe avoid adding a few more macros, particularly
ones that take lots of arguments like this one will.
We'll have something like 4 more macros
#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
runtime_resume_fn, idle_fn, sec, ns) \
_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
runtime_resume_fn, idle_fn, "_gpl", ns)
#define EXPORT_NS_DEV_PM_OPS() ...
#define EXPORT_DEV_PM_OPS() ...
#define EXPORT_GPL_DEV_PM_OPS() ...
if we provide the same for non NS cases.
I'll roll a patch for next cycle hopefully building on the one referenced
above if Rafael picks that up for this merge window.
Jonathan
>
> Cheers,
> -Paul
>
> > Currently I have this...
> >
> > #ifdef CONFIG_PM
> > const struct dev_pm_ops bmc150_magn_pm_ops = {
> > SYSTEM_SLEEP_PM_OPS(...)
> > RUNTIME_PM_OPS(...)
> > };
> > EXPORT_SYMBOL_NS(bmc150_magn_pm_ops, IIO_BMC150_MAGN);
> > #else
> > static const __maybe_unused dev_pm_ops bmc150_magn_pm_ops = {
> > SYSTEM_SLEEP_PM_OPS(...)
> > RUNTIME_PM_OPS(...)
> > };
> > #endif
> > Not super clean but perhaps we do need
> > EXPORT_NS_DEV_PM_OPS
> > EXPORT_NS_GPL_DEV_PM_OPS
> > and potentially the non namespaced versions.
> >
> > Thanks,
> >
> > Jonathan
>
>
next prev parent reply other threads:[~2022-03-06 17:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-26 22:24 [PATCH -next] misc: rtsx: fix build for CONFIG_PM not set Randy Dunlap
2022-02-27 12:04 ` Arnd Bergmann
2022-02-27 16:57 ` Randy Dunlap
2022-02-27 17:30 ` Arnd Bergmann
2022-02-27 17:46 ` Paul Cercueil
2022-02-27 17:51 ` Arnd Bergmann
2022-02-27 17:56 ` Paul Cercueil
2022-03-06 15:12 ` Jonathan Cameron
2022-03-06 15:29 ` Paul Cercueil
2022-03-06 17:57 ` Jonathan Cameron [this message]
2022-03-06 16:24 ` Jonathan Cameron
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=20220306175724.00002fc0@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=rafael.j.wysocki@intel.com \
--cc=rdunlap@infradead.org \
--cc=wei_wang@realsil.com.cn \
/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