[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7a470b3f-fc20-476e-bc97-be9008d5aeef@suse.de>
Date: Mon, 18 Aug 2025 17:15:29 +0200
From: Thomas Zimmermann <tzimmermann@...e.de>
To: Christian König <christian.koenig@....com>,
sumit.semwal@...aro.org, oushixiong@...inos.cn, alexander.deucher@....com,
maarten.lankhorst@...ux.intel.com, mripard@...nel.org, airlied@...il.com,
simona@...ll.ch
Cc: dri-devel@...ts.freedesktop.org, linux-media@...r.kernel.org,
linaro-mm-sig@...ts.linaro.org, linux-kernel@...r.kernel.org,
amd-gfx@...ts.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: Pin buffer while vmap'ing exported dma-buf
objects
Hi Christian
Am 18.08.25 um 15:23 schrieb Christian König:
> 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.
What you're describing is exactly the current situation for udl plus
amdgpu now. When udl tries to pin, amdgpu has already pinned the buffer
to VRAM. So it doesn't work. There needs to be at least VRAM and GTT in
the list. What does work is to try pinning to various domains in the
preferred order.
Best regards
Thomas
>
> 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,
>>>> };
>>>> /**
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Powered by blists - more mailing lists