[RFC v1] drm: add reference count of gem object name

Daniel Vetter daniel at ffwll.ch
Sat Dec 1 04:11:06 PST 2012


On Sat, Dec 1, 2012 at 12:30 PM, Daniel Vetter <daniel at ffwll.ch> wrote:
> On Sat, Dec 1, 2012 at 3:26 AM, Inki Dae <inki.dae at samsung.com> wrote:
>> As you know, when the handle is closed, the flink name is also released even
>> though another process opened the flink name to get its own handle.
>> So the flink name becomes invalid. This is the issue I pointed out and this
>> is the fixup this patch tries to do.
>> I think flink name should have dependency of the gem object rather than
>> process.
>> In other words, gem flink name couldn't be used as global key becasue it
>> can't gurantee that the fink name is pointing to same gem object.
>> This patch makes the gem flink name valid as long as the gem object isn't
>> released instead of handle.
>> And this is the reason that we need this patch.
>
> Like I've said, as long as there's a userspace handle around, the
> flink name should not disappear. This additional handle reference
> count is implemented with obj->handle_count, which is incremented in
> drm_gem_handle_create. This function is called both from flink and
> from open ioctls. And that reference is dropped again in
> drm_gem_object_release_handle and the two
> drm_gem_object_handle_unreference variants.
>
> So I guess there's a bug somewhere, so can you please provide a
> minimal testcase which showcases your issue?

I've quickly implemented a testcase for what I believe is your
use-case (i.e. sharing between 3 different open drm files, where we
close the gem handle in the first fd before we open the flink name
again using the 3rd drm fd handle). It seems to work.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list