dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 06/13] drm: add minor-lookup/release helpers
Date: Fri, 21 Feb 2014 08:37:33 +0100	[thread overview]
Message-ID: <20140221073732.GF22574@ulmo.nvidia.com> (raw)
In-Reply-To: <CANq1E4SP8RbJp4urqWcqYf85kTxK=rR4nJ5hX8AGb=Q9NdaObw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1962 bytes --]

On Fri, Feb 21, 2014 at 08:34:15AM +0100, David Herrmann wrote:
> Hi
> 
> On Fri, Feb 21, 2014 at 8:09 AM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> > On Wed, Jan 29, 2014 at 03:01:53PM +0100, David Herrmann wrote:
> > [...]
> >> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> >> index c51333e..d3232b6 100644
> >> --- a/drivers/gpu/drm/drm_stub.c
> >> +++ b/drivers/gpu/drm/drm_stub.c
> >> @@ -356,6 +356,45 @@ static void drm_unplug_minor(struct drm_minor *minor)
> >>  }
> >>
> >>  /**
> >> + * drm_minor_acquire - Acquire a DRM minor
> >> + * @minor_id: Minor ID of the DRM-minor
> >> + *
> >> + * Looks up the given minor-ID and returns the respective DRM-minor object. The
> >> + * refence-count of the underlying device is increased so you must release this
> >> + * object with drm_minor_release().
> >> + *
> >> + * As long as you hold this minor, it is guaranteed that the object and the
> >> + * minor->dev pointer will stay valid! However, the device may get unplugged and
> >> + * unregistered while you hold the minor.
> >> + *
> >> + * Returns:
> >> + * Pointer to minor-object with increased device-refcount, or PTR_ERR on
> >> + * failure.
> >> + */
> >> +struct drm_minor *drm_minor_acquire(unsigned int minor_id)
> >> +{
> >> +     struct drm_minor *minor;
> >> +
> >> +     minor = idr_find(&drm_minors_idr, minor_id);
> >> +     if (!minor)
> >> +             return ERR_PTR(-ENODEV);
> >> +
> >> +     drm_dev_ref(minor->dev);
> >
> > Is it possible that somebody would drop the last reference on the device
> > right between the idr_find() call and drm_dev_ref()? In which case both
> > the device and the minor will have become invalid when drm_dev_ref() is
> > called.
> 
> No, it's locked via the drm_global_mutex. And later I introduce a
> spinlock here that protects this in case we remove the global lock.

Indeed. Thanks for clarifying.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

  reply	other threads:[~2014-02-21  7:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 14:01 [PATCH 00/13] DRM Reliable Minor-IDs David Herrmann
2014-01-29 14:01 ` [PATCH 01/13] drm: group dev-lifetime related members David Herrmann
2014-01-29 14:01 ` [PATCH 02/13] drm: skip redundant minor-lookup in open path David Herrmann
2014-01-29 14:01 ` [PATCH 03/13] drm: remove unused DRM_MINOR_UNASSIGNED David Herrmann
2014-01-29 14:01 ` [PATCH 04/13] drm: turn DRM_MINOR_* into enum David Herrmann
2014-01-29 14:01 ` [PATCH 05/13] drm: provide device-refcount David Herrmann
2014-02-12 13:25   ` Daniel Vetter
2014-02-12 14:44     ` David Herrmann
2014-02-12 16:26       ` Daniel Vetter
2014-02-12 16:40         ` Greg KH
2014-02-12 17:48           ` David Herrmann
2014-02-12 18:31             ` Daniel Vetter
2014-02-12 18:38             ` Greg KH
2014-02-21  7:01   ` Thierry Reding
2014-02-24 13:51     ` David Herrmann
2014-01-29 14:01 ` [PATCH 06/13] drm: add minor-lookup/release helpers David Herrmann
2014-02-21  7:09   ` Thierry Reding
2014-02-21  7:34     ` David Herrmann
2014-02-21  7:37       ` Thierry Reding [this message]
2014-01-29 14:01 ` [PATCH 07/13] drm: allocate minors early David Herrmann
2014-01-29 14:01 ` [PATCH 08/13] drm: move drm_put_minor() to drm_minor_free() David Herrmann
2014-01-29 14:01 ` [PATCH 09/13] drm: rename drm_unplug/get_minor() to drm_minor_register/unregister() David Herrmann
2014-02-21  7:21   ` Thierry Reding
2014-02-24 13:52     ` David Herrmann
2014-01-29 14:01 ` [PATCH 10/13] drm: remove unneeded #ifdef CONFIG_DEBUGFS David Herrmann
2014-01-29 14:01 ` [PATCH 11/13] drm: remove redundant minor->device field David Herrmann
2014-02-12 13:36   ` Daniel Vetter
2014-02-21  7:30     ` Thierry Reding
2014-02-21 20:07       ` David Herrmann
2014-01-29 14:01 ` [PATCH 12/13] drm: make minor-IDs reliable David Herrmann
2014-01-29 14:02 ` [PATCH 13/13] drm: remove redundant minor->index David Herrmann
2014-02-21  7:30 ` [PATCH 00/13] DRM Reliable Minor-IDs Thierry Reding

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=20140221073732.GF22574@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@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