From: Chen Jeffy <jeffy.chen@rock-chips.com>
To: "Christian König" <christian.koenig@amd.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>
Cc: Andy Yan <andy.yan@rock-chips.com>,
Jianqun Xu <jay.xu@rock-chips.com>,
Maxime Ripard <mripard@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, David Airlie <airlied@linux.ie>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
linux-media@vger.kernel.org, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [Linaro-mm-sig] Re: [PATCH v2] drm/gem: Fix GEM handle release errors
Date: Tue, 9 Aug 2022 18:02:27 +0800 [thread overview]
Message-ID: <6b3e82f9-6902-fd5c-c67d-e2c42c995133@rock-chips.com> (raw)
In-Reply-To: <71e47fe6-440b-e9ea-cd66-8362c41428ca@amd.com>
Hi Christian,
On 8/9 星期二 17:08, Christian König wrote:
> Hi Jeffy,
>
> Am 09.08.22 um 09:55 schrieb Christian König:
>> [SNIP]
>>>>
>>>>>
>>>>>
>>>>> So we are allowing GEM object to have multiple handles, and GEM
>>>>> object could have at most one dma-buf, doesn't that means that
>>>>> dma-buf could map to multiple handles?
>>>>
>>>> No, at least not for the same GEM file private. That's the reason
>>>> why the rb is indexed by the dma_buf object and not the handle.
>>>>
>>>> In other words the rb is so that you have exactly one handle for
>>>> each dma_buf in each file private.
>>>
>>> I don't think so, because if user get multiple handles for the same
>>> GEM obj and use drm_gem_prime_handle_to_fd() for those handles
>>
>> Mhm, that works? This is illegal and should have been prevented somehow.
>
> At least I see the problem now. I'm just not sure how to fix it.
>
> Your v2 patch indeed prevents leakage of the drm_prime_member for the
> additional handles, but those shouldn't have been added in the first place.
>
> The issue is that with this we make it unpredictable which handle is
> returned. E.g. if we have handle 2,5,7 it can be that because of
> re-balancing the tree sometimes 2 and sometimes 5 is returned.
Maybe cache the latest returned handle in the obj(after
drm_gem_prime_fd_to_handle), and clear it when that handle been deleted
in drm_gem_handle_delete()?
Something like:
drm_gem_prime_fd_to_handle
handle = drm_prime_lookup_buf_handle(buf)
obj = obj_from_handle(handle)
if !obj->primary_handle
obj->primary_handle = handle
return obj->primary_handle
Or maybe limit GEM obj with a single lifetime handle?
>
> That's not really a good idea and breaks a couple of assumptions as far
> as I know.
>
> Ideas?
>
> Thanks,
> Christian.
>
next prev parent reply other threads:[~2022-08-09 10:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 8:32 Jeffy Chen
2022-08-07 16:52 ` Christian König
2022-08-08 3:51 ` Chen Jeffy
2022-08-08 18:03 ` Christian König
2022-08-09 1:28 ` Chen Jeffy
2022-08-09 7:55 ` Christian König
2022-08-09 8:54 ` Chen Jeffy
2022-08-09 9:08 ` [Linaro-mm-sig] " Christian König
2022-08-09 10:02 ` Chen Jeffy [this message]
2022-08-09 10:18 ` Christian König
2022-08-10 4:16 ` Chen Jeffy
2022-08-10 9:16 ` Christian König
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=6b3e82f9-6902-fd5c-c67d-e2c42c995133@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=airlied@linux.ie \
--cc=andy.yan@rock-chips.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jay.xu@rock-chips.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®