]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/prime: remove drm_prime_lookup_buf_by_handle
authorChristian König <christian.koenig@amd.com>
Wed, 4 Jun 2025 11:00:38 +0000 (13:00 +0200)
committerChristian König <christian.koenig@amd.com>
Thu, 12 Jun 2025 13:37:01 +0000 (15:37 +0200)
commitc2aa5603af309968a10f8e0d929ec7662ada5f78
treeba676825c387fe389943dbaa9f36eeb2f0b1ce93
parentc5b4393c5492555e35c08677a326c9c53b275abd
drm/prime: remove drm_prime_lookup_buf_by_handle

This was added by Sima +10 years ago as a solution to avoid exporting
multiple dma-bufs for the same GEM object. I tried to remove it before,
but wasn't 100% sure about all the side effects.

Now Thomas recent modified drm_gem_prime_handle_to_dmabuf() which makes
it obvious that this is a superflous step. We try to look up the DMA-buf
by handle handle and if that fails for some reason (must likely because
the handle is a duplicate) the code just use the DMA-buf from the GEM
object.

Just using the DMA-buf from the GEM object in the first place has the
same effect as far as I can see.

Some more history from Sima:

In d0b2c5334f41 ("drm/prime: Always add exported buffers to the handle
cache") I added this additional lookup. It wasn't part of the bugfix,
but back then the handle list was just a linked list and you could do
lookups in either direction. And I guess I felt like doing a quick lookup
before we grab the next lock makes sense. Premature optimization, I'm
confessing to the crime guilty as charged :-/

Then Chris Wilson in 077675c1e8a1 ("drm: Convert prime dma-buf <-> handle
to rbtree") and added 2 rb trees to support both directions. At that point
that handle2buf lookup really didn't make much sense anymore, but we just
kept it and it's been in the tree confusing people ever since.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Link: https://lore.kernel.org/r/20250604113234.2520-1-christian.koenig@amd.com
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_prime.c