From: "Christian König" <christian.koenig@amd.com>
To: Chen Jeffy <jeffy.chen@rock-chips.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: Wed, 10 Aug 2022 11:16:04 +0200 [thread overview]
Message-ID: <509d8bb0-f030-f8ca-a610-da5faaa6396b@amd.com> (raw)
In-Reply-To: <05488346-ebbd-b1d9-4094-a83daf65f6db@rock-chips.com>
Hi Jeffy,
Am 10.08.22 um 06:16 schrieb Chen Jeffy:
> Hi Christian,
>
> On 8/9 星期二 18:18, Christian König wrote:
>> Hi Jeffy,
>> [SNIP]
>>> 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()?
>>
>> That won't work. The handle is per fpriv, but the same object is used
>> by multiple fpriv instances. >
>> What we could maybe do is to prevent adding multiple lockup
>> structures when there is already one, but that's not something I can
>> easily judge.
>
> So maybe we need to protect that unique lookup structure been deleted
> before deleting the last handle, and make the handle unique for GEM
> obj, in case of that unique lookup's handle been deleted earlier that
> others?
>
> How about adding a GEM obj rbtree too, and make drm_prime_member kref-ed?
>
> So the
> drm_prime_add_buf_handle/drm_gem_handle_create_tail/drm_gem_handle_delete
> would be looking up drm_prime_member by GEM obj, then update dmabuf rb
> and inc/dec drm_prime_member's kref,
> drm_gem_prime_fd_to_handle/drm_gem_prime_handle_to_fd remain unchanged.
I think we should probably come up with an idea what the UAPI should
look like before we try to implement this in the kernel, but in general
I think we should make the solution simpler and not even more complex.
Recording multiple handles for the same DMA-buf/fpriv combination
doesn't seem to make sense, so the duplicated tracking of
handle->dma_buf mapping just seems to be overkill.
So my proposal would be this:
1. Only the first used GEM handle is tracker for each DMA-buf/fpriv
combination.
2. Imports either return this first used handle or allocate a new one if
there isn't any.
3. If the first used handle is closed we allocate a new one on re-import
even when there duplicate handles.
The alternative as we have it now is to just return a more or less
random handle if there are duplicates which doesn't sound like something
we would want.
Daniel, can we agree on that?
Regards,
Christian.
prev parent reply other threads:[~2022-08-10 9:16 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
2022-08-09 10:18 ` Christian König
2022-08-10 4:16 ` Chen Jeffy
2022-08-10 9:16 ` Christian König [this message]
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=509d8bb0-f030-f8ca-a610-da5faaa6396b@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@linux.ie \
--cc=andy.yan@rock-chips.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jay.xu@rock-chips.com \
--cc=jeffy.chen@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®