From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 22/22] drm: omapdrm: Perform initialization/cleanup at probe/remove time
Date: Fri, 16 Dec 2016 15:54:21 +0200 [thread overview]
Message-ID: <2379089.6fJ5i85Q6b@avalon> (raw)
In-Reply-To: <0791e4c6-657e-da9e-54ad-021b0617c4d5@ti.com>
Hi Tomi,
On Friday 16 Dec 2016 14:44:26 Tomi Valkeinen wrote:
> On 14/12/16 02:27, Laurent Pinchart wrote:
> > The drm driver .load() operation is prone to race conditions as it
> > initializes the driver after registering the device nodes. Its usage is
> > deprecated, inline it in the probe function and call drm_dev_alloc() and
> > drm_dev_register() explicitly.
> >
> > For consistency inline the .unload() handler in the remove function as
> > well.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > Changes since v1:
> >
> > - Call drm_kms_helper_poll_fini() before omap_fbdev_free() in the remove
> >
> > handler.
> >
> > - Keep storing drm_device in the platform device private data.
> > ---
> >
> > drivers/gpu/drm/omapdrm/omap_connector.c | 2 -
> > drivers/gpu/drm/omapdrm/omap_drv.c | 212 +++++++++++++-------------
> > 2 files changed, 107 insertions(+), 107 deletions(-)
[snip]
> > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c
> > b/drivers/gpu/drm/omapdrm/omap_drv.c index 0a2d461d62cf..a3b37823b271
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
[snip]
> > @@ -837,30 +741,128 @@ static struct drm_driver omap_drm_driver = {
> > .patchlevel = DRIVER_PATCHLEVEL,
> > };
> >
> > -static int pdev_probe(struct platform_device *device)
> > +static int pdev_probe(struct platform_device *pdev)
> > {
> > - int r;
> > + struct omap_drm_platform_data *pdata = pdev->dev.platform_data;
> > + struct omap_drm_private *priv;
> > + struct drm_device *ddev;
> > + unsigned int i;
> > + int ret;
> > +
> > + DBG("%s", pdev->name);
> >
> > if (omapdss_is_initialized() == false)
> > return -EPROBE_DEFER;
> >
> > omap_crtc_pre_init();
> >
> > - r = omap_connect_dssdevs();
> > - if (r) {
> > + ret = omap_connect_dssdevs();
> > + if (ret) {
> > omap_crtc_pre_uninit();
> > - return r;
> > + goto err_crtc_uninit;
>
> This calls omap_crtc_pre_uninit here and in the err handler.
Oops, will fix.
> > + }
> > +
> > + /* Allocate and initialize the driver private structure. */
> > + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> > + if (!priv) {
> > + ret = -ENOMEM;
> > + goto err_disconnect_dssdevs;
> > + }
> > +
> > + priv->omaprev = pdata->omaprev;
> > + priv->wq = alloc_ordered_workqueue("omapdrm", 0);
> > +
> > + init_waitqueue_head(&priv->commit.wait);
> > + spin_lock_init(&priv->commit.lock);
> > + spin_lock_init(&priv->list_lock);
> > + INIT_LIST_HEAD(&priv->obj_list);
> > +
> > + /* Allocate and initialize the DRM device. */
> > + ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev);
> > + if (IS_ERR(ddev)) {
> > + ret = PTR_ERR(ddev);
> > + goto err_free_priv;
> > + }
> > +
> > + ddev->dev_private = priv;
> > + platform_set_drvdata(pdev, ddev);
> > +
> > + omap_gem_init(ddev);
> > +
> > + ret = omap_modeset_init(ddev);
> > + if (ret) {
> > + dev_err(&pdev->dev, "omap_modeset_init failed: ret=%d\n",
ret);
> > + goto err_free_drm_dev;
> > + }
> > +
> > + /* Initialize vblank handling, start with all CRTCs disabled. */
> > + ret = drm_vblank_init(ddev, priv->num_crtcs);
> > + if (ret) {
> > + dev_err(&pdev->dev, "could not init vblank\n");
> > + goto err_cleanup_modeset;
> > }
> >
> > - DBG("%s", device->name);
> > - return drm_platform_init(&omap_drm_driver, device);
> > + for (i = 0; i < priv->num_crtcs; i++)
> > + drm_crtc_vblank_off(priv->crtcs[i]);
> > +
> > + priv->fbdev = omap_fbdev_init(ddev);
> > +
> > + drm_kms_helper_poll_init(ddev);
> > +
> > + /*
> > + * Register the DRM device with the core and the connectors with
> > + * sysfs.
> > + */
> > + ret = drm_dev_register(ddev, 0);
> > + if (ret)
> > + goto err_cleanup_helpers;
> > +
> > + return 0;
> > +
> > +err_cleanup_helpers:
> > + drm_kms_helper_poll_fini(ddev);
> > + if (priv->fbdev)
> > + omap_fbdev_free(ddev);
> > + drm_vblank_cleanup(ddev);
> > +err_cleanup_modeset:
> > + drm_mode_config_cleanup(ddev);
> > + omap_drm_irq_uninstall(ddev);
> > +err_free_drm_dev:
> > + omap_gem_deinit(ddev);
> > + drm_dev_unref(ddev);
> > +err_free_priv:
> > + destroy_workqueue(priv->wq);
> > + kfree(priv);
> > +err_disconnect_dssdevs:
> > + omap_disconnect_dssdevs();
> > +err_crtc_uninit:
> > + omap_crtc_pre_uninit();
> > + return ret;
> > }
> >
> > -static int pdev_remove(struct platform_device *device)
> > +static int pdev_remove(struct platform_device *pdev)
> > {
> > + struct drm_device *ddev = platform_get_drvdata(pdev);
> > + struct omap_drm_private *priv = ddev->dev_private;
> > +
> > DBG("");
> >
> > - drm_put_dev(platform_get_drvdata(device));
> > + drm_dev_unregister(ddev);
> > +
> > + drm_kms_helper_poll_fini(ddev);
> > +
> > + if (priv->fbdev)
> > + omap_fbdev_free(ddev);
> > +
> > + drm_mode_config_cleanup(ddev);
> > +
> > + omap_drm_irq_uninstall(ddev);
> > + omap_gem_deinit(ddev);
> > +
> > + drm_dev_unref(ddev);
> > +
> > + destroy_workqueue(priv->wq);
> > + kfree(priv);
> >
> > omap_disconnect_dssdevs();
> > omap_crtc_pre_uninit();
>
> The old code calls drm_vblank_cleanup(), and the probe's error handling
> calls that, but not remove. Is that correct?
Now that drm_vblank_cleanup() is called by drm_dev_release() we can drop the
call from the probe error path. It used to be needed as the function was
called from drm_dev_unregister().
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-12-16 13:53 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 0:27 [PATCH v4 00/22] OMAP DRM fixes and improvements Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 01/22] drm: omapdrm: fb: Limit number of planes per framebuffer to two Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 02/22] drm: omapdrm: fb: Use format information provided by the DRM core Laurent Pinchart
2016-12-14 10:07 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 03/22] drm: omapdrm: fb: Simplify objects lookup when creating framebuffer Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 04/22] drm: omapdrm: fb: Simplify mode command checks " Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 05/22] drm: omapdrm: fb: Turn framebuffer creation error messages into debug Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 06/22] drm: omapdrm: Handle FIFO underflow IRQs internally Laurent Pinchart
2016-12-14 10:22 ` Tomi Valkeinen
2016-12-14 11:48 ` Laurent Pinchart
2016-12-14 13:13 ` Tomi Valkeinen
2016-12-15 9:02 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 07/22] drm: omapdrm: Handle CRTC error IRQs directly Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 08/22] drm: omapdrm: Handle OCP error IRQ directly Laurent Pinchart
2016-12-14 10:24 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 09/22] drm: omapdrm: Replace DSS manager state check with omapdrm CRTC state Laurent Pinchart
2016-12-14 10:36 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 10/22] drm: omapdrm: Let the DRM core skip plane commit on inactive CRTCs Laurent Pinchart
2016-12-14 10:43 ` Tomi Valkeinen
2016-12-14 11:26 ` Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 11/22] drm: omapdrm: Check the CRTC software state at enable/disable time Laurent Pinchart
2016-12-14 14:54 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 12/22] drm: omapdrm: Prevent processing the same event multiple times Laurent Pinchart
2016-12-15 12:20 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 13/22] drm: omapdrm: Use a spinlock to protect the CRTC pending flag Laurent Pinchart
2016-12-14 0:27 ` [PATCH v4 14/22] drm: omapdrm: Keep vblank interrupt enabled while CRTC is active Laurent Pinchart
2016-12-15 12:52 ` Tomi Valkeinen
2016-12-15 14:51 ` Laurent Pinchart
2016-12-15 14:56 ` Tomi Valkeinen
2016-12-18 2:12 ` [PATCH v4.1 " Laurent Pinchart
2016-12-19 9:06 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 15/22] drm: omapdrm: Don't expose the omap_irq_(un)register() functions Laurent Pinchart
2016-12-15 12:56 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 16/22] drm: omapdrm: Remove unused parameter from omap_drm_irq handler Laurent Pinchart
2016-12-15 12:57 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 17/22] drm: omapdrm: Don't call DISPC power handling in IRQ wait functions Laurent Pinchart
2016-12-15 13:00 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 18/22] drm: omapdrm: Inline the pipe2vbl function Laurent Pinchart
2016-12-14 10:25 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 19/22] drm: omapdrm: Simplify IRQ wait implementation Laurent Pinchart
2016-12-16 12:24 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 20/22] drm: omapdrm: Remove global variables Laurent Pinchart
2016-12-16 12:31 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 21/22] drm: omapdrm: Use sizeof(*var) instead of sizeof(type) for structures Laurent Pinchart
2016-12-15 13:02 ` Tomi Valkeinen
2016-12-14 0:27 ` [PATCH v4 22/22] drm: omapdrm: Perform initialization/cleanup at probe/remove time Laurent Pinchart
2016-12-16 12:44 ` Tomi Valkeinen
2016-12-16 13:54 ` Laurent Pinchart [this message]
2016-12-19 9:15 ` [PATCH v4.1 " Laurent Pinchart
2016-12-19 9:25 ` Tomi Valkeinen
2016-12-14 8:48 ` [PATCH v4 00/22] OMAP DRM fixes and improvements Tomi Valkeinen
2016-12-14 11:50 ` Laurent Pinchart
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=2379089.6fJ5i85Q6b@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=tomi.valkeinen@ti.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.