From: Lyude Paul <lyude@redhat.com>
To: Douglas Anderson <dianders@chromium.org>,
dri-devel@lists.freedesktop.org,
Maxime Ripard <mripard@kernel.org>
Cc: airlied@gmail.com, bskeggs@redhat.com, daniel@ffwll.ch,
kherbst@redhat.com, linux-kernel@vger.kernel.org,
nouveau@lists.freedesktop.org
Subject: Re: [RFT PATCH v2 04/12] drm/nouveau: Call drm_atomic_helper_shutdown() or equiv at shutdown time
Date: Fri, 22 Sep 2023 17:06:50 -0400 [thread overview]
Message-ID: <2f7fbd1b606b4d08b8c8c6eefff5898c8faa697c.camel@redhat.com> (raw)
In-Reply-To: <20230921122641.RFT.v2.4.Ie7588ec6e0f93e8bc700e76b265ad1a7ad6b15ad@changeid>
actually very glad to see this because I think I've seen one bug in the wild
as a result of things not getting shut down :)
Reviewed-by: Lyude Paul <lyude@redhat.com>
Tested-by: Lyude Paul <lyude@redhat.com>
On Thu, 2023-09-21 at 12:26 -0700, Douglas Anderson wrote:
> Based on grepping through the source code this driver appears to be
> missing a call to drm_atomic_helper_shutdown() (or
> drm_helper_force_disable_all() if not using atomic) at system shutdown
> time. Among other things, this means that if a panel is in use that it
> won't be cleanly powered off at system shutdown time.
>
> The fact that we should call drm_atomic_helper_shutdown() in the case
> of OS shutdown/restart comes straight out of the kernel doc "driver
> instance overview" in drm_drv.c.
>
> Suggested-by: Maxime Ripard <mripard@kernel.org>
> Reviewed-by: Maxime Ripard <mripard@kernel.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> This commit is only compile-time tested. I made my best guess about
> how to fit this into the existing code. If someone wishes a different
> style, please yell.
>
> (no changes since v1)
>
> drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++++++++
> drivers/gpu/drm/nouveau/nouveau_display.h | 1 +
> drivers/gpu/drm/nouveau/nouveau_drm.c | 13 +++++++++++++
> drivers/gpu/drm/nouveau/nouveau_drv.h | 1 +
> drivers/gpu/drm/nouveau/nouveau_platform.c | 6 ++++++
> 5 files changed, 30 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index d8c92521226d..05c3688ccb76 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -642,6 +642,15 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime)
> disp->fini(dev, runtime, suspend);
> }
>
> +void
> +nouveau_display_shutdown(struct drm_device *dev)
> +{
> + if (drm_drv_uses_atomic_modeset(dev))
> + drm_atomic_helper_shutdown(dev);
> + else
> + drm_helper_force_disable_all(dev);
> +}
> +
> static void
> nouveau_display_create_properties(struct drm_device *dev)
> {
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h
> index 2ab2ddb1eadf..9df62e833cda 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.h
> @@ -47,6 +47,7 @@ void nouveau_display_destroy(struct drm_device *dev);
> int nouveau_display_init(struct drm_device *dev, bool resume, bool runtime);
> void nouveau_display_hpd_resume(struct drm_device *dev);
> void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
> +void nouveau_display_shutdown(struct drm_device *dev);
> int nouveau_display_suspend(struct drm_device *dev, bool runtime);
> void nouveau_display_resume(struct drm_device *dev, bool runtime);
> int nouveau_display_vblank_enable(struct drm_crtc *crtc);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 50589f982d1a..8ecfd66b7aab 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -879,6 +879,18 @@ nouveau_drm_remove(struct pci_dev *pdev)
> pci_disable_device(pdev);
> }
>
> +void
> +nouveau_drm_device_shutdown(struct drm_device *dev)
> +{
> + nouveau_display_shutdown(dev);
> +}
> +
> +static void
> +nouveau_drm_shutdown(struct pci_dev *pdev)
> +{
> + nouveau_drm_device_shutdown(pci_get_drvdata(pdev));
> +}
> +
> static int
> nouveau_do_suspend(struct drm_device *dev, bool runtime)
> {
> @@ -1346,6 +1358,7 @@ nouveau_drm_pci_driver = {
> .id_table = nouveau_drm_pci_table,
> .probe = nouveau_drm_probe,
> .remove = nouveau_drm_remove,
> + .shutdown = nouveau_drm_shutdown,
> .driver.pm = &nouveau_pm_ops,
> };
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
> index 3666a7403e47..aa936cabb6cf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
> @@ -327,6 +327,7 @@ struct drm_device *
> nouveau_platform_device_create(const struct nvkm_device_tegra_func *,
> struct platform_device *, struct nvkm_device **);
> void nouveau_drm_device_remove(struct drm_device *dev);
> +void nouveau_drm_device_shutdown(struct drm_device *dev);
>
> #define NV_PRINTK(l,c,f,a...) do { \
> struct nouveau_cli *_cli = (c); \
> diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c
> index 23cd43a7fd19..b2e82a96411c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_platform.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
> @@ -50,6 +50,11 @@ static int nouveau_platform_remove(struct platform_device *pdev)
> return 0;
> }
>
> +static void nouveau_platform_shutdown(struct platform_device *pdev)
> +{
> + nouveau_drm_device_shutdown(platform_get_drvdata(pdev));
> +}
> +
> #if IS_ENABLED(CONFIG_OF)
> static const struct nvkm_device_tegra_func gk20a_platform_data = {
> .iommu_bit = 34,
> @@ -94,4 +99,5 @@ struct platform_driver nouveau_platform_driver = {
> },
> .probe = nouveau_platform_probe,
> .remove = nouveau_platform_remove,
> + .shutdown = nouveau_platform_shutdown,
> };
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
next prev parent reply other threads:[~2023-09-22 21:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 19:26 [RFT PATCH v2 00/12] drm: call drm_atomic_helper_shutdown() at the right times Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 01/12] drm/imx/dcss: Call drm_atomic_helper_shutdown() at shutdown time Douglas Anderson
2023-09-22 7:56 ` Laurentiu Palcu
2023-09-22 15:44 ` Doug Anderson
2023-09-25 5:47 ` Laurentiu Palcu
2023-09-25 22:53 ` Doug Anderson
2023-09-21 19:26 ` [RFT PATCH v2 02/12] drm/kmb: " Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 03/12] drm/mediatek: " Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 04/12] drm/nouveau: Call drm_atomic_helper_shutdown() or equiv " Douglas Anderson
2023-09-22 21:06 ` Lyude Paul [this message]
2023-11-17 23:00 ` Doug Anderson
2023-12-05 20:45 ` Doug Anderson
2023-12-06 8:14 ` Maxime Ripard
2023-09-21 19:26 ` [RFT PATCH v2 05/12] drm/tegra: Call drm_atomic_helper_shutdown() " Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 06/12] drm/arcpgu: " Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 07/12] drm/amdgpu: " Douglas Anderson
2023-09-25 15:56 ` Deucher, Alexander
2023-09-25 17:04 ` Doug Anderson
2023-09-21 19:26 ` [RFT PATCH v2 08/12] drm/sprd: Call drm_atomic_helper_shutdown() at remove time Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 09/12] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time Douglas Anderson
2023-09-22 5:55 ` Marek Szyprowski
2023-10-06 2:19 ` Inki Dae
2023-10-06 13:50 ` Doug Anderson
2023-10-10 15:46 ` Inki Dae
2023-09-21 19:26 ` [RFT PATCH v2 10/12] drm/gma500: Call drm_helper_force_disable_all() at shutdown/remove time Douglas Anderson
2023-09-21 19:26 ` [RFT PATCH v2 11/12] drm/radeon: " Douglas Anderson
2023-09-25 15:49 ` Deucher, Alexander
2023-09-25 16:09 ` Doug Anderson
2023-09-21 19:26 ` [RFT PATCH v2 12/12] drm/renesas/shmobile: " Douglas Anderson
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=2f7fbd1b606b4d08b8c8c6eefff5898c8faa697c.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=bskeggs@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.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
all inboxes | Powered by JetHome®