From: Al Viro <viro@zeniv.linux.org.uk>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/4] new helper: drm_gem_prime_handle_to_dmabuf()
Date: Thu, 22 Aug 2024 16:20:22 +0100 [thread overview]
Message-ID: <20240822152022.GU504335@ZenIV> (raw)
In-Reply-To: <57520a28-fff2-41ae-850b-fa820d2b0cfa@suse.de>
On Thu, Aug 22, 2024 at 04:41:59PM +0200, Thomas Zimmermann wrote:
> Hi
>
> Am 12.08.24 um 08:59 schrieb Al Viro:
> > Once something had been put into descriptor table, the only thing you
> > can do with it is returning descriptor to userland - you can't withdraw
> > it on subsequent failure exit, etc. You certainly can't count upon
> > it staying in the same slot of descriptor table - another thread
> > could've played with close(2)/dup2(2)/whatnot.
>
> This paragraph appears to refer to the newly added call to fd_install().
It refers to dma_buf_fd() call that had been there all along, actually.
dma_buf_fd() is get_unused_fd_flags() + fd_install(). The reason
for splitting it in new variant and calling get_unused_fd_flags() and
fd_install() separately is that it makes for simpler cleanup; we could
use dma_buf_fd() instead - it would be a bit more clumsy, but that's
it.
The real issue is that drm_gem_prime_handle_to_fd() forces us to make
the thing reachable via descriptor table; it's just what we need when
all we are going to do is returning descriptor to userland, but it's
inherently racy for internal uses - anything put into descriptor table,
be it by fd_install() or by dma_buf_fd(), is fair game for all syscalls
by other threads.
> > Add drm_gem_prime_handle_to_dmabuf() - the "set dmabuf up" parts of
> > drm_gem_prime_handle_to_fd() without the descriptor-related ones.
> > Instead of inserting into descriptor table and returning the file
> > descriptor it just returns the struct file.
> >
> > drm_gem_prime_handle_to_fd() becomes a wrapper for it. Other users
> > will be introduced in the next commit.
> > -int drm_gem_prime_handle_to_fd(struct drm_device *dev,
> > +struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev,
>
> If it's exported it should have kernel docs. At least copy-paste the docs
> from drm_gem_prime_handle_to_fd()
> and reword a few bits.
Point...
next prev parent reply other threads:[~2024-08-23 7:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 6:56 [PATCHES] [drm] file descriptor fixes Al Viro
2024-08-12 6:59 ` [PATCH 1/4] new helper: drm_gem_prime_handle_to_dmabuf() Al Viro
2024-08-12 6:59 ` [PATCH 2/4] amdgpu: fix a race in kfd_mem_export_dmabuf() Al Viro
2024-08-14 22:15 ` Felix Kuehling
2024-08-22 0:29 ` Al Viro
2024-08-22 18:02 ` Alex Deucher
2024-08-12 6:59 ` [PATCH 3/4] amdkfd CRIU fixes Al Viro
2024-08-12 6:59 ` [PATCH 4/4] amdgpu: get rid of bogus includes of fdtable.h Al Viro
2024-08-22 14:41 ` [PATCH 1/4] new helper: drm_gem_prime_handle_to_dmabuf() Thomas Zimmermann
2024-08-22 15:20 ` Al Viro [this message]
2024-08-23 1:57 ` Al Viro
2024-08-23 7:21 ` Thomas Zimmermann
2024-08-23 7:53 ` Al Viro
2024-09-10 16:36 ` Alex Deucher
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=20240822152022.GU504335@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fsdevel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.