dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: tomi.valkeinen@ti.com, dri-devel@lists.freedesktop.org
Subject: Re: [RFC 1/7] drm/omap: Use devm_kzalloc() to allocate omap_drm_private
Date: Mon, 04 Sep 2017 17:19:16 +0300	[thread overview]
Message-ID: <5814852.pOhEMP3Ssu@avalon> (raw)
In-Reply-To: <e1fa01aa-bd4e-3bdf-1253-37d59d1272ec@ti.com>

Hi Peter,

On Monday, 4 September 2017 14:16:32 EEST Peter Ujfalusi wrote:
> On 2017-09-04 12:41, Laurent Pinchart wrote:
> > At the moment the memory is freed at .remove() time, which can lead to
> > memory corruption if a user has a handle on the device (for instance an
> > open file handle that is then close()d). Fixing this requires moving
> > memory free to the drm_driver::release() handler. devm_kzalloc() goes in
> > the wrong direction.
> Ah, OK, so the current way is buggy as well.
> 
> How do you plan to fix that?
> I think this should work:
> 
> struct omap_drm_private {
> 	/* First member in the private struct! */
> +	struct drm_device ddev;
> ...
> };
> 
> Use drm_dev_init(&priv->ddev, ...); to initialize the drm_device instead
> of drm_dev_alloc()
> 
> then priv->ddev.dev_private = priv;
> 
> in this case the drm_dev_unref() would free up our omap_drm_private, right?

That's the idea, yes. I got a local patch for that in my tree.

> I think this is what other DRM drivers are doing, not all, but i915 does
> this at least.
> 
> But by the description most of the DRM drivers are doing this wrong, right?

Correct, most drivers get it wrong. We'll have to fix it, but given that we 
have race conditions in the core that prevent proper hot-unplug support at the 
moment, I didn't want to start pushing for fixing drivers. Once we get the 
core sorted out, it will be time to address the other side of the issue.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-09-04 14:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29  7:32 [RFC 0/7] drm/omap: Module parameter for display order configuration Peter Ujfalusi
2017-08-29  7:32 ` [RFC 1/7] drm/omap: Use devm_kzalloc() to allocate omap_drm_private Peter Ujfalusi
2017-09-01 11:10   ` Laurent Pinchart
2017-09-04  9:13     ` Peter Ujfalusi
2017-09-04  9:41       ` Laurent Pinchart
2017-09-04 11:16         ` Peter Ujfalusi
2017-09-04 14:19           ` Laurent Pinchart [this message]
2017-09-05  6:35             ` Peter Ujfalusi
2017-08-29  7:32 ` [RFC 2/7] drm/omap: Allocate drm_device earlier and unref it as last step Peter Ujfalusi
2017-09-01 11:12   ` Laurent Pinchart
2017-08-29  7:32 ` [RFC 3/7] drm/omap: Manage the usable omap_dss_device list within omap_drm_private Peter Ujfalusi
2017-09-01 11:27   ` Laurent Pinchart
2017-09-04  9:19     ` Peter Ujfalusi
2017-09-04  9:45       ` Laurent Pinchart
2017-08-29  7:32 ` [RFC 4/7] drm/omap: Separate the dssdevs array setup from the connect function Peter Ujfalusi
2017-08-29  7:32 ` [RFC 5/7] drm/omap: Do dss_device (display) ordering in omap_drv.c Peter Ujfalusi
2017-09-01 11:32   ` Laurent Pinchart
2017-09-04  9:26     ` Peter Ujfalusi
2017-09-04  9:46       ` Laurent Pinchart
2017-08-29  7:32 ` [RFC 6/7] drm/omap: dss: Remove display ordering from dss/display.c Peter Ujfalusi
2017-08-29  7:32 ` [RFC 7/7] drm/omap: Add kernel parameter to specify the desired display order Peter Ujfalusi
2017-09-01 11:36 ` [RFC 0/7] drm/omap: Module parameter for display order configuration Laurent Pinchart
2017-09-04 10:03   ` Peter Ujfalusi
2018-05-25 20:09     ` Laurent Pinchart
2017-10-05  9:56 ` Pekka Paalanen
2017-10-05 10:01   ` Tomi Valkeinen
2017-10-05 10:43     ` Pekka Paalanen
2017-10-05 11:24       ` Tomi Valkeinen
2017-10-05 11:54         ` Pekka Paalanen

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=5814852.pOhEMP3Ssu@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=peter.ujfalusi@ti.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).