linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: inki.dae@samsung.com (Inki Dae)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH v3] DRM: add DRM Driver for Samsung SoC EXYNOS4210.
Date: Fri, 02 Sep 2011 21:00:21 +0900	[thread overview]
Message-ID: <001401cc6967$e41f3460$ac5d9d20$%dae@samsung.com> (raw)
In-Reply-To: <CAF6AEGuZb1nhMJwc+k-cwPTPLHTiO1PkHcpGN899Yq3pEMUwkA@mail.gmail.com>

Hello Rob.
Below is my comments.

> -----Original Message-----
> From: Rob Clark [mailto:robdclark at gmail.com]
> Sent: Friday, September 02, 2011 10:18 AM
> To: Inki Dae
> Cc: airlied at linux.ie; dri-devel at lists.freedesktop.org;
> sw0312.kim at samsung.com; linux-kernel at vger.kernel.org;
> kyungmin.park at samsung.com; linux-arm-kernel at lists.infradead.org
> Subject: Re: [RFC][PATCH v3] DRM: add DRM Driver for Samsung SoC
> EXYNOS4210.
> 
> On Thu, Sep 1, 2011 at 8:06 AM, Inki Dae <inki.dae@samsung.com> wrote:
> >> >> > +struct samsung_drm_gem_obj *
> >> >> > + ? ? ? ? ? ? ? find_samsung_drm_gem_object(struct drm_file
> > *file_priv,
> >> >> > + ? ? ? ? ? ? ? ? ? ? ? struct drm_device *dev, unsigned int
handle)
> >> >> > +{
> >> >> > + ? ? ? struct drm_gem_object *gem_obj;
> >> >> > +
> >> >> > + ? ? ? gem_obj = drm_gem_object_lookup(dev, file_priv, handle);
> >> >> > + ? ? ? if (!gem_obj) {
> >> >> > + ? ? ? ? ? ? ? DRM_LOG_KMS("a invalid gem object not registered
to
> >> >> lookup.\n");
> >> >> > + ? ? ? ? ? ? ? return NULL;
> >> >> > + ? ? ? }
> >> >> > +
> >> >> > + ? ? ? /**
> >> >> > + ? ? ? ?* unreference refcount of the gem object.
> >> >> > + ? ? ? ?* at drm_gem_object_lookup(), the gem object was
> referenced.
> >> >> > + ? ? ? ?*/
> >> >> > + ? ? ? drm_gem_object_unreference(gem_obj);
> >> >>
> >> >> this doesn't seem right, to drop the reference before you use the
> >> >> buffer elsewhere..
> >> >>
> >> > No, see drm_gem_object_lookup fxn. at this function, if there is a
> >> object
> >> > found then drm_gem_object_reference is called to increase refcount of
> >> this
> >> > object. if there is any missing point, give me any comment please.
> thank
> >> > you.
> >>
> >>
> >> Right, but I think there is a reason it takes a reference... so that
> >> the object doesn't get free'd from under your feet. ?So pattern
> >> should, I think, be:
> >>
> >> ? obj = lookup(...);
> >> ? ... do stuff w/ obj ...
> >> ? unreference(obj)
> >>
> >> so the caller who is using the looked up obj should unref it when done
> >>
> >> Instead, you have:
> >>
> >> ? obj = lookup(...);
> >> ? unreference(obj);
> >> ? ... do stuff w/ obj ...
> >>
> >>
> >
> > Generally right, but in this case, it is just used to get specific gem
> > object through find_samsung_drm_gem_object() so doesn't reference this
> gem
> > object anywhere.
> > therefore reference and unreference should be done within
> > find_samsung_drm_gem_object(). if there is any point I missed then let
> me
> > know please. thank you.
> >
> 
> Still, it seems like find_samsung_drm_gem_object() is encouraging the
> wrong usage-pattern, even if it works fine today because you know
> somewhere else is holding a reference to the object.  Later if you
> expand your use of GEM objects, this fxn might come back to bite you.
> There is a good reason that drm_gem_object_lookup() takes a reference
> to the object, and it feels wrong to intentionally subvert that.
> 
> (I'm perfectly willing to be overridden on the subject.. there are
> plenty of folks on this list who have been doing the GEM thing longer
> than I have.  But it just seems better to use APIs like
> drm_gem_object_lookup() the way they were intended.)
> 

Ah, you are right. I misunderstanded it. as you pointed out, a gem object
should be unreferenced after doing something with the gem object. so I will
remove find_samsung_drm_gem_object() and use drm_gem_object_lookup()
directly to get a gem object instead. of course, the gem object will be
unreferenced after doing something with it. thank you for your explanation.
:)

> BR,
> -R

  reply	other threads:[~2011-09-02 12:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1314359274-21585-1-git-send-email-inki.dae@samsung.com>
2011-08-31  1:57 ` [RFC][PATCH v3] DRM: add DRM Driver for Samsung SoC EXYNOS4210 Rob Clark
2011-08-31  2:28   ` Joonyoung Shim
2011-08-31  6:51   ` Inki Dae
2011-08-31 16:02     ` Rob Clark
2011-09-01 13:06       ` Inki Dae
2011-09-02  1:02         ` Kyungmin Park
2011-09-02  1:08           ` Rob Clark
2011-09-02  1:18         ` Rob Clark
2011-09-02 12:00           ` Inki Dae [this message]
     [not found]   ` <20110831020652.GA16547@dumpdata.com>
2011-08-31  7:33     ` Inki Dae
2011-08-31  8:38 ` Thomas Hellstrom
2011-09-01  3:57   ` Inki Dae

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='001401cc6967$e41f3460$ac5d9d20$%dae@samsung.com' \
    --to=inki.dae@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).