From: Boris Brezillon <boris.brezillon@collabora.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
dri-devel@lists.freedesktop.org, kernel@collabora.com,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] drm/panthor: Fix the CONFIG_PM=n case
Date: Mon, 18 Mar 2024 13:57:44 +0100 [thread overview]
Message-ID: <20240318135744.76208b30@collabora.com> (raw)
In-Reply-To: <70bdc326-3e97-4f6b-ad6d-09473ee85b97@arm.com>
On Mon, 18 Mar 2024 12:18:53 +0000
Robin Murphy <robin.murphy@arm.com> wrote:
> On 18/03/2024 8:58 am, Boris Brezillon wrote:
> > Putting a hard dependency on CONFIG_PM is not possible because of a
> > circular dependency issue, and it's actually not desirable either. In
> > order to support this use case, we forcibly resume at init time, and
> > suspend at unplug time.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202403031944.EOimQ8WK-lkp@intel.com/
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> > Tested by faking CONFIG_PM=n in the driver (basically commenting
> > all pm_runtime calls, and making the panthor_device_suspend/resume()
> > calls unconditional in the panthor_device_unplug/init() path) since
> > CONFIG_ARCH_ROCKCHIP selects CONFIG_PM. Seems to work fine, but I
> > can't be 100% sure this will work correctly on a platform that has
> > CONFIG_PM=n.
> > ---
> > drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++--
> > drivers/gpu/drm/panthor/panthor_drv.c | 4 +++-
> > 2 files changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
> > index 69deb8e17778..ba7aedbb4931 100644
> > --- a/drivers/gpu/drm/panthor/panthor_device.c
> > +++ b/drivers/gpu/drm/panthor/panthor_device.c
> > @@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)
> > pm_runtime_dont_use_autosuspend(ptdev->base.dev);
> > pm_runtime_put_sync_suspend(ptdev->base.dev);
> >
> > + /* If PM is disabled, we need to call the suspend handler manually. */
> > + if (!IS_ENABLED(CONFIG_PM))
> > + panthor_device_suspend(ptdev->base.dev);
> > +
> > /* Report the unplug operation as done to unblock concurrent
> > * panthor_device_unplug() callers.
> > */
> > @@ -218,6 +222,13 @@ int panthor_device_init(struct panthor_device *ptdev)
> > if (ret)
> > return ret;
> >
> > + /* If PM is disabled, we need to call panthor_device_resume() manually. */
> > + if (!IS_ENABLED(CONFIG_PM)) {
> > + ret = panthor_device_resume(ptdev->base.dev);
> > + if (ret)
> > + return ret;
> > + }
> > +
> > ret = panthor_gpu_init(ptdev);
> > if (ret)
> > goto err_rpm_put;
> > @@ -402,7 +413,6 @@ int panthor_device_mmap_io(struct panthor_device *ptdev, struct vm_area_struct *
> > return 0;
> > }
> >
> > -#ifdef CONFIG_PM
> > int panthor_device_resume(struct device *dev)
> > {
> > struct panthor_device *ptdev = dev_get_drvdata(dev);
> > @@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)
> > mutex_unlock(&ptdev->pm.mmio_lock);
> > return ret;
> > }
> > -#endif
> > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> > index ff484506229f..2ea6a9f436db 100644
> > --- a/drivers/gpu/drm/panthor/panthor_drv.c
> > +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> > @@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = {
> > };
> > MODULE_DEVICE_TABLE(of, dt_match);
> >
> > +#ifdef CONFIG_PM
>
> This #ifdef isn't necessary, and in fact will break the !PM build -
> pm_ptr() already takes care of allowing the compiler to optimise out the
> ops structure itself without any further annotations.
Oops, I forgot how pm_ptr() was working (I thought it had 2
definitions, one for the PM case and another for the !PM one).
>
> Thanks,
> Robin.
>
> > static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops,
> > panthor_device_suspend,
> > panthor_device_resume,
> > NULL);
> > +#endif
> >
> > static struct platform_driver panthor_driver = {
> > .probe = panthor_probe,
> > .remove_new = panthor_remove,
> > .driver = {
> > .name = "panthor",
> > - .pm = &panthor_pm_ops,
> > + .pm = pm_ptr(&panthor_pm_ops),
> > .of_match_table = dt_match,
> > },
> > };
prev parent reply other threads:[~2024-03-18 12:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 8:58 [PATCH] drm/panthor: Fix the CONFIG_PM=n case Boris Brezillon
2024-03-18 11:17 ` Liviu Dudau
2024-03-18 11:31 ` Steven Price
2024-03-18 13:08 ` Boris Brezillon
2024-03-18 13:49 ` Steven Price
2024-03-18 14:04 ` Robin Murphy
2024-03-18 14:18 ` Boris Brezillon
2024-03-18 14:34 ` Steven Price
2024-03-18 14:49 ` Boris Brezillon
2024-03-18 14:58 ` Steven Price
2024-03-18 12:18 ` Robin Murphy
2024-03-18 12:57 ` Boris Brezillon [this message]
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=20240318135744.76208b30@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=liviu.dudau@arm.com \
--cc=lkp@intel.com \
--cc=robin.murphy@arm.com \
--cc=steven.price@arm.com \
/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.