diff mbox series

[RFT,1/6] drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop

Message ID 20230901163944.RFT.1.I906acd535bece03b6671d97c2826c6f0444f4728@changeid (mailing list archive)
State New, archived
Headers show
Series drm: drm-misc drivers call drm_atomic_helper_shutdown() at the right times | expand

Commit Message

Doug Anderson Sept. 1, 2023, 11:39 p.m. UTC
As with other places in the Linux kernel--kfree(NULL) being the most
famous example--it's convenient to treat being passed a NULL argument
as a noop in cleanup functions. Let's make
drm_atomic_helper_shutdown() work like this.

This is convenient for DRM devices that use the "component" model. On
these devices we want shutdown to be a noop if the bind() call of the
component hasn't been called yet. As long as drivers are careful to
make sure the drvdata is NULL whenever the driver is not bound then we
can just do a simple call to drm_atomic_helper_shutdown() with the
drvdata at shutdown time.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/gpu/drm/drm_atomic_helper.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

mripard@kernel.org Sept. 4, 2023, 7:55 a.m. UTC | #1
On Fri, 1 Sep 2023 16:39:52 -0700, Douglas Anderson wrote:
> As with other places in the Linux kernel--kfree(NULL) being the most
> famous example--it's convenient to treat being passed a NULL argument
> as a noop in cleanup functions. Let's make
> drm_atomic_helper_shutdown() work like this.
> 
> 
> [ ... ]

Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime
Doug Anderson Sept. 5, 2023, 9:14 p.m. UTC | #2
Hi,

On Mon, Sep 4, 2023 at 12:55 AM Maxime Ripard <mripard@kernel.org> wrote:
>
> On Fri, 1 Sep 2023 16:39:52 -0700, Douglas Anderson wrote:
> > As with other places in the Linux kernel--kfree(NULL) being the most
> > famous example--it's convenient to treat being passed a NULL argument
> > as a noop in cleanup functions. Let's make
> > drm_atomic_helper_shutdown() work like this.
> >
> >
> > [ ... ]
>
> Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks! If there are no objections, I'd tend to land this patch
sometime early next week just to get it out of the queue, even if
other patches in the series are still being discussed / need spinning.
If anyone objects to that idea, please shout.

-Doug
Doug Anderson Sept. 13, 2023, 6:19 p.m. UTC | #3
Hi,

On Tue, Sep 5, 2023 at 2:14 PM Doug Anderson <dianders@chromium.org> wrote:
>
> Hi,
>
> On Mon, Sep 4, 2023 at 12:55 AM Maxime Ripard <mripard@kernel.org> wrote:
> >
> > On Fri, 1 Sep 2023 16:39:52 -0700, Douglas Anderson wrote:
> > > As with other places in the Linux kernel--kfree(NULL) being the most
> > > famous example--it's convenient to treat being passed a NULL argument
> > > as a noop in cleanup functions. Let's make
> > > drm_atomic_helper_shutdown() work like this.
> > >
> > >
> > > [ ... ]
> >
> > Acked-by: Maxime Ripard <mripard@kernel.org>
>
> Thanks! If there are no objections, I'd tend to land this patch
> sometime early next week just to get it out of the queue, even if
> other patches in the series are still being discussed / need spinning.
> If anyone objects to that idea, please shout.

Landed to drm-misc-next.

2a073968289d drm/atomic-helper: drm_atomic_helper_shutdown(NULL)
should be a noop
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 292e38eb6218..71d399397107 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3339,6 +3339,9 @@  void drm_atomic_helper_shutdown(struct drm_device *dev)
 	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
+	if (dev == NULL)
+		return;
+
 	DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
 
 	ret = drm_atomic_helper_disable_all(dev, &ctx);