From: "Christian König" <christian.koenig@amd.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
sumit.semwal@linaro.org, oushixiong@kylinos.cn,
alexander.deucher@amd.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: Pin buffer while vmap'ing exported dma-buf objects
Date: Mon, 18 Aug 2025 15:23:37 +0200 [thread overview]
Message-ID: <6cb1d152-898a-4cc4-a086-44d85cf7a24d@amd.com> (raw)
In-Reply-To: <7c2d8894-7eb5-4c86-a80a-935fcf24ef83@suse.de>
On 18.08.25 14:46, Thomas Zimmermann wrote:
> Hi
>
> Am 18.08.25 um 14:40 schrieb Christian König:
> [...]
>>> +static int amdgpu_dma_buf_vmap(struct dma_buf *dma_buf, struct iosys_map *map)
>>> +{
>>> + struct drm_gem_object *obj = dma_buf->priv;
>>> + struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
>>> + int ret;
>>> +
>>> + /*
>>> + * Pin to keep buffer in place while it's vmap'ed. The actual
>>> + * location is not important as long as it's mapable.
>> Yeah, exactly that won't work here. Most of the locations are not CPU accessible.
>>
>> You could use AMDGPU_GEM_DOMAIN_GTT, that should most likely work in all cases but isn't necessarily the most optimal solution.
>
> No problem about that, but why not a bit more flexibility? When udl copies from the buffer, it is likely pinned to VRAM.
>
> A bit mask of _CPU, _GTT, and _VRAM should work fine. The other domains are probably irrelevant for our use case.
The problem is that as soon as you pin into this domain you get an error if you try to pin into another domain.
So if you try to use the same buffer with udl and amdgpu scanout and pin it into GTT -> error.
If you try to use the same buffer with udl and V4L and pin it into VRAM -> error.
There is not works for everybody case here and we need to guess. Pinning it into GTT is just what works most likely.
Regards,
Christian.
>
> Best regards
> Thomas
>
>>
>> Regards,
>> Christian.
>>
>>> + *
>>> + * This code is required for exporting to GEM-SHMEM without S/G table.
>>> + * Once GEM-SHMEM supports dynamic imports, it should be dropped.
>>> + */
>>> + ret = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_MASK);
>>> + if (ret)
>>> + return ret;
>>> + ret = drm_gem_dmabuf_vmap(dma_buf, map);
>>> + if (ret)
>>> + amdgpu_bo_unpin(bo);
>>> +
>>> + return ret;
>>> +}
>>> +
>>> +static void amdgpu_dma_buf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map)
>>> +{
>>> + struct drm_gem_object *obj = dma_buf->priv;
>>> + struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
>>> +
>>> + drm_gem_dmabuf_vunmap(dma_buf, map);
>>> + amdgpu_bo_unpin(bo);
>>> +}
>>> +
>>> const struct dma_buf_ops amdgpu_dmabuf_ops = {
>>> .attach = amdgpu_dma_buf_attach,
>>> .pin = amdgpu_dma_buf_pin,
>>> @@ -294,8 +326,8 @@ const struct dma_buf_ops amdgpu_dmabuf_ops = {
>>> .release = drm_gem_dmabuf_release,
>>> .begin_cpu_access = amdgpu_dma_buf_begin_cpu_access,
>>> .mmap = drm_gem_dmabuf_mmap,
>>> - .vmap = drm_gem_dmabuf_vmap,
>>> - .vunmap = drm_gem_dmabuf_vunmap,
>>> + .vmap = amdgpu_dma_buf_vmap,
>>> + .vunmap = amdgpu_dma_buf_vunmap,
>>> };
>>> /**
>
next prev parent reply other threads:[~2025-08-18 13:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 8:41 Thomas Zimmermann
2025-08-18 12:40 ` Christian König
2025-08-18 12:46 ` Thomas Zimmermann
2025-08-18 13:23 ` Christian König [this message]
2025-08-18 15:15 ` Thomas Zimmermann
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=6cb1d152-898a-4cc4-a086-44d85cf7a24d@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--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=oushixiong@kylinos.cn \
--cc=simona@ffwll.ch \
--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®