drm/prime: remove drm_prime_lookup_buf_by_handle
Subsystems (2)
PATCH 1/1 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.
--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)
drivers/gpu/drm/drm_gem.c +1 -1
@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);
drivers/gpu/drm/drm_internal.h +1 -0
@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */
drivers/gpu/drm/drm_prime.c +8 -48
97 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 4 lines · Christian König
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.
Quoted 8 lines
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.
So the history is a bit more funny, might want to add that.
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.
With that added:
Quoted 141 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)drivers/gpu/drm/drm_gem.c +1
-1@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);drivers/gpu/drm/drm_internal.h +1
-0@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */ drivers/gpu/drm/drm_prime.c +8
-48@@ -90,7 +90,6 @@ struct drm_prime_member {uint32_t handle;struct rb_node dmabuf_rb; -struct rb_node handle_rb; }; static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,@@ -122,45 +121,9 @@ static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,rb_link_node (&member->dmabuf_rb, rb, p);rb_insert_color (&member->dmabuf_rb, &prime_fpriv->dmabufs); - rb =NULL ; - p = &prime_fpriv->handles.rb_node; -while (*p) { -struct drm_prime_member *pos; - - rb = *p; - pos = rb_entry(rb, struct drm_prime_member, handle_rb); -if (handle > pos->handle) - p = &rb->rb_right; -else - p = &rb->rb_left; - } -rb_link_node (&member->handle_rb, rb, p); -rb_insert_color (&member->handle_rb, &prime_fpriv->handles); -return 0 ; } -static struct dma_buf *drm_prime_lookup_buf_by_handle (struct drm_prime_file_private *prime_fpriv, -uint32_t handle) -{ -struct rb_node *rb; - - rb = prime_fpriv->handles.rb_node; -while (rb) { -struct drm_prime_member *member; - - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) -return member->dma_buf; -else if (member->handle < handle) - rb = rb->rb_right; -else - rb = rb->rb_left; - } - -return NULL ; -} -static int drm_prime_lookup_buf_handle (struct drm_prime_file_private *prime_fpriv,struct dma_buf *dma_buf,uint32_t *handle)@@ -186,25 +149,28 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri }void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle) {struct rb_node *rb; +if (!dma_buf) +return ; +mutex_lock (&prime_fpriv->lock); - rb = prime_fpriv->handles.rb_node; + rb = prime_fpriv->dmabufs.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) { -rb_erase (&member->handle_rb, &prime_fpriv->handles); + member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); +if (member->dma_buf == dma_buf && member->handle == handle) {rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs);dma_buf_put (member->dma_buf);kfree (member);break ; - }else if (member->handle < handle) { + }else if (member->dma_buf < dma_buf) { rb = rb->rb_right; }else { rb = rb->rb_left;@@ -446,12 +412,6 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev, goto out_unlock; } - dmabuf =drm_prime_lookup_buf_by_handle (&file_priv->prime, handle); -if (dmabuf) { -get_dma_buf (dmabuf); - goto out; - } -mutex_lock (&dev->object_name_lock);/* re-export the original imported/exported object */ if (obj->dma_buf) {Signature · 1 line
2.34.1
Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Simona Vetter
Reviewed-byQuoted 23 lines · Simona Vetter
Quoted 4 lines · Christian König
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.
Quoted 8 lines
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.
So the history is a bit more funny, might want to add that.
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 :-/
Quoted 8 lines
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.With that added:
Reviewed-by Daniel Vetter <[email protected]>
lol :-/
Cheers, Sima
Quoted 148 lines
Quoted 143 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)drivers/gpu/drm/drm_gem.c +1
-1@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);drivers/gpu/drm/drm_internal.h +1
-0@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */ drivers/gpu/drm/drm_prime.c +8
-48@@ -90,7 +90,6 @@ struct drm_prime_member {uint32_t handle;struct rb_node dmabuf_rb; -struct rb_node handle_rb; }; static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,@@ -122,45 +121,9 @@ static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,rb_link_node (&member->dmabuf_rb, rb, p);rb_insert_color (&member->dmabuf_rb, &prime_fpriv->dmabufs); - rb =NULL ; - p = &prime_fpriv->handles.rb_node; -while (*p) { -struct drm_prime_member *pos; - - rb = *p; - pos = rb_entry(rb, struct drm_prime_member, handle_rb); -if (handle > pos->handle) - p = &rb->rb_right; -else - p = &rb->rb_left; - } -rb_link_node (&member->handle_rb, rb, p); -rb_insert_color (&member->handle_rb, &prime_fpriv->handles); -return 0 ; } -static struct dma_buf *drm_prime_lookup_buf_by_handle (struct drm_prime_file_private *prime_fpriv, -uint32_t handle) -{ -struct rb_node *rb; - - rb = prime_fpriv->handles.rb_node; -while (rb) { -struct drm_prime_member *member; - - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) -return member->dma_buf; -else if (member->handle < handle) - rb = rb->rb_right; -else - rb = rb->rb_left; - } - -return NULL ; -} -static int drm_prime_lookup_buf_handle (struct drm_prime_file_private *prime_fpriv,struct dma_buf *dma_buf,uint32_t *handle)@@ -186,25 +149,28 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri }void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle) {struct rb_node *rb; +if (!dma_buf) +return ; +mutex_lock (&prime_fpriv->lock); - rb = prime_fpriv->handles.rb_node; + rb = prime_fpriv->dmabufs.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) { -rb_erase (&member->handle_rb, &prime_fpriv->handles); + member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); +if (member->dma_buf == dma_buf && member->handle == handle) {rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs);dma_buf_put (member->dma_buf);kfree (member);break ; - }else if (member->handle < handle) { + }else if (member->dma_buf < dma_buf) { rb = rb->rb_right; }else { rb = rb->rb_left;@@ -446,12 +412,6 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev, goto out_unlock; } - dmabuf =drm_prime_lookup_buf_by_handle (&file_priv->prime, handle); -if (dmabuf) { -get_dma_buf (dmabuf); - goto out; - } -mutex_lock (&dev->object_name_lock);/* re-export the original imported/exported object */ if (obj->dma_buf) {Signature · 1 line
2.34.1Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 31 lines · Simona Vetter
Quoted 30 lines · Simona Vetter
Quoted 4 lines · Christian König
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.
Quoted 8 lines
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.
So the history is a bit more funny, might want to add that.
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.With that added:
Quoted 7 lines
Quoted 1 line
Reviewed-by Daniel Vetter <[email protected]>lol :-/
Reviewed-by Simona Vetter <[email protected]>Cheers, Sima
This regressed one of our CI IGT tests [1].
BR,
Jani.
[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
Quoted 149 lines
Quoted 149 lines
Quoted 144 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)drivers/gpu/drm/drm_gem.c +1
-1@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);drivers/gpu/drm/drm_internal.h +1
-0@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */ drivers/gpu/drm/drm_prime.c +8
-48@@ -90,7 +90,6 @@ struct drm_prime_member {uint32_t handle;struct rb_node dmabuf_rb; -struct rb_node handle_rb; }; static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,@@ -122,45 +121,9 @@ static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,rb_link_node (&member->dmabuf_rb, rb, p);rb_insert_color (&member->dmabuf_rb, &prime_fpriv->dmabufs); - rb =NULL ; - p = &prime_fpriv->handles.rb_node; -while (*p) { -struct drm_prime_member *pos; - - rb = *p; - pos = rb_entry(rb, struct drm_prime_member, handle_rb); -if (handle > pos->handle) - p = &rb->rb_right; -else - p = &rb->rb_left; - } -rb_link_node (&member->handle_rb, rb, p); -rb_insert_color (&member->handle_rb, &prime_fpriv->handles); -return 0 ; } -static struct dma_buf *drm_prime_lookup_buf_by_handle (struct drm_prime_file_private *prime_fpriv, -uint32_t handle) -{ -struct rb_node *rb; - - rb = prime_fpriv->handles.rb_node; -while (rb) { -struct drm_prime_member *member; - - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) -return member->dma_buf; -else if (member->handle < handle) - rb = rb->rb_right; -else - rb = rb->rb_left; - } - -return NULL ; -} -static int drm_prime_lookup_buf_handle (struct drm_prime_file_private *prime_fpriv,struct dma_buf *dma_buf,uint32_t *handle)@@ -186,25 +149,28 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri }void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle) {struct rb_node *rb; +if (!dma_buf) +return ; +mutex_lock (&prime_fpriv->lock); - rb = prime_fpriv->handles.rb_node; + rb = prime_fpriv->dmabufs.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) { -rb_erase (&member->handle_rb, &prime_fpriv->handles); + member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); +if (member->dma_buf == dma_buf && member->handle == handle) {rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs);dma_buf_put (member->dma_buf);kfree (member);break ; - }else if (member->handle < handle) { + }else if (member->dma_buf < dma_buf) { rb = rb->rb_right; }else { rb = rb->rb_left;@@ -446,12 +412,6 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev, goto out_unlock; } - dmabuf =drm_prime_lookup_buf_by_handle (&file_priv->prime, handle); -if (dmabuf) { -get_dma_buf (dmabuf); - goto out; - } -mutex_lock (&dev->object_name_lock);/* re-export the original imported/exported object */ if (obj->dma_buf) {Signature · 1 line
2.34.1Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 1 line
Jani Nikula, Intel
Quoted 40 lines · Jani Nikula
Quoted 31 lines · Simona Vetter
Quoted 30 lines · Simona Vetter
Quoted 4 lines · Christian König
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.
Quoted 8 lines
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.
So the history is a bit more funny, might want to add that.
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.With that added:
Quoted 7 lines
Quoted 1 line
Reviewed-by Daniel Vetter <[email protected]>lol :-/
Reviewed-by Simona Vetter <[email protected]>Cheers, Sima
Quoted 7 lines
This regressed one of our CI IGT tests [1].
BR,
Jani.[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
[ 66.986238] CPU: 1 UID: 112 PID: 1220 Comm: sddm-greeter-qt Tainted: G U 6.16.0-rc1-uaf #424 PREEMPT(full) [ 66.986242] Tainted: [U]=USER [ 66.986244] Hardware name: LENOVO 21CB007AUK/21CB007AUK, BIOS N3AET85W (1.50 ) 03/04/2025 [ 66.986246] RIP: 0010:drm_prime_destroy_file_private+0x16/0x20 [ 66.986250] Code: 00 00 00 00 00 00 5b 31 d2 31 f6 31 ff c3 66 0f 1f 44 00 00 0f 1f 44 00 00 48 8b 87 90 00 00 00 48 85 c0 75 05 31 c0 31 ff c3 <0f> 0b 31 c0 31 ff c3 0f 1f 00 0f 1f 44 00 00 48 8b 47 70 48 89 f1 [ 66.986253] RSP: 0018:ffffc90002997c78 EFLAGS: 00010286 [ 66.986256] RAX: ffff88812823d550 RBX: ffff888133a00800 RCX: 0000000000000000 [ 66.986259] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888133a00b80 [ 66.986261] RBP: ffff888133a00ad8 R08: 0000000000000000 R09: 0000000000000000 [ 66.986262] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88810d8fc000 [ 66.986264] R13: ffff888133a00ab0 R14: ffff888133a00ab0 R15: dead000000000100 [ 66.986266] FS: 0000795148051c80(0000) GS:ffff8884cb7e1000(0000) knlGS:0000000000000000 [ 66.986269] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 66.986271] CR2: 000079514cc776d0 CR3: 0000000137894005 CR4: 0000000000772ef0 [ 66.986273] PKRU: 55555554 [ 66.986275] Call Trace: [ 66.986276] <TASK> [ 66.986278] drm_file_free+0x234/0x2a0 [ 66.986286] drm_release_noglobal+0x1b/0x80 [ 66.986290] __fput+0x100/0x2c0 [ 66.986296] __x64_sys_close+0x39/0x80 [ 66.986299] do_syscall_64+0x95/0x1290 [ 66.986307] ? lock_acquire+0xe6/0x2e0 [ 66.986311] ? find_held_lock+0x2b/0x80 [ 66.986314] ? __might_fault+0x44/0x80 [ 66.986318] ? lock_release+0x17b/0x2a0 [ 66.986323] ? rcu_is_watching+0xd/0x40 [ 66.986326] ? __rseq_handle_notify_resume+0x44b/0x5f0 [ 66.986332] ? exit_to_user_mode_loop+0x37/0x150 [ 66.986338] ? entry_SYSCALL_64_after_hwframe+0x4b/0x53 [ 66.986341] ? lockdep_hardirqs_on+0x7c/0x110 [ 66.986345] ? do_syscall_64+0x190/0x1290 [ 66.986348] ? lockdep_hardirqs_on+0x7c/0x110 [ 66.986352] ? do_syscall_64+0x190/0x1290 [ 66.986354] ? do_syscall_64+0x190/0x1290 [ 66.986359] entry_SYSCALL_64_after_hwframe+0x4b/0x53 [ 66.986361] RIP: 0033:0x79514b2ab6e2 [ 66.986364] Code: 08 0f 85 71 3a ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 66 2e 0f 1f 84 00 00 00 00 00 66 [ 66.986366] RSP: 002b:00007ffc6e412a78 EFLAGS: 00000246 ORIG_RAX: 0000000000000003 [ 66.986370] RAX: ffffffffffffffda RBX: 0000795148051c80 RCX: 000079514b2ab6e2 [ 66.986371] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000013 [ 66.986373] RBP: 00007ffc6e412aa0 R08: 0000000000000000 R09: 0000000000000000 [ 66.986375] R10: 0000000000000000 R11: 0000000000000246 R12: 00005c4e70a4df20 [ 66.986377] R13: 00005c4e70a46240 R14: 0000000000000008 R15: 00005c4e70e0fab8 [ 66.986388] </TASK> [ 66.986390] irq event stamp: 484049 [ 66.986391] hardirqs last enabled at (484055): [<ffffffff813c6602>] __up_console_sem+0x62/0x80 [ 66.986395] hardirqs last disabled at (484060): [<ffffffff813c65e7>] __up_console_sem+0x47/0x80 [ 66.986398] softirqs last enabled at (483398): [<ffffffff8131c50f>] __irq_exit_rcu+0xef/0x170 [ 66.986402] softirqs last disabled at (483393): [<ffffffff8131c50f>] __irq_exit_rcu+0xef/0x170 [ 66.986405] ---[ end trace 0000000000000000 ]---
Regards,
Tvrtko
Quoted 153 lines
Quoted 152 lines
Quoted 152 lines
Quoted 147 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)drivers/gpu/drm/drm_gem.c +1
-1@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);drivers/gpu/drm/drm_internal.h +1
-0@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */ drivers/gpu/drm/drm_prime.c +8
-48@@ -90,7 +90,6 @@ struct drm_prime_member {uint32_t handle;struct rb_node dmabuf_rb; -struct rb_node handle_rb; }; static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,@@ -122,45 +121,9 @@ static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,rb_link_node (&member->dmabuf_rb, rb, p);rb_insert_color (&member->dmabuf_rb, &prime_fpriv->dmabufs); - rb =NULL ; - p = &prime_fpriv->handles.rb_node; -while (*p) { -struct drm_prime_member *pos; - - rb = *p; - pos = rb_entry(rb, struct drm_prime_member, handle_rb); -if (handle > pos->handle) - p = &rb->rb_right; -else - p = &rb->rb_left; - } -rb_link_node (&member->handle_rb, rb, p); -rb_insert_color (&member->handle_rb, &prime_fpriv->handles); -return 0 ; } -static struct dma_buf *drm_prime_lookup_buf_by_handle (struct drm_prime_file_private *prime_fpriv, -uint32_t handle) -{ -struct rb_node *rb; - - rb = prime_fpriv->handles.rb_node; -while (rb) { -struct drm_prime_member *member; - - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) -return member->dma_buf; -else if (member->handle < handle) - rb = rb->rb_right; -else - rb = rb->rb_left; - } - -return NULL ; -} -static int drm_prime_lookup_buf_handle (struct drm_prime_file_private *prime_fpriv,struct dma_buf *dma_buf,uint32_t *handle)@@ -186,25 +149,28 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri }void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle) {struct rb_node *rb; +if (!dma_buf) +return ; +mutex_lock (&prime_fpriv->lock); - rb = prime_fpriv->handles.rb_node; + rb = prime_fpriv->dmabufs.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) { -rb_erase (&member->handle_rb, &prime_fpriv->handles); + member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); +if (member->dma_buf == dma_buf && member->handle == handle) {rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs);dma_buf_put (member->dma_buf);kfree (member);break ; - }else if (member->handle < handle) { + }else if (member->dma_buf < dma_buf) { rb = rb->rb_right; }else { rb = rb->rb_left;@@ -446,12 +412,6 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev, goto out_unlock; } - dmabuf =drm_prime_lookup_buf_by_handle (&file_priv->prime, handle); -if (dmabuf) { -get_dma_buf (dmabuf); - goto out; - } -mutex_lock (&dev->object_name_lock);/* re-export the original imported/exported object */ if (obj->dma_buf) {Signature · 1 line
2.34.1Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 5 lines · Tvrtko Ursulin
Quoted 4 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
Quoted 8 lines
Quoted 5 lines
BR,
Jani.[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel
Hi,
Quoted 20 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 9 lines · Tvrtko Ursulin
Quoted 8 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
BR,
Jani.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.
Quoted 4 lines
BR,
Jani.
Br
Other Jani
Quoted 4 lines
--
Jani Nikula, Intel
Quoted 28 lines · Jani
Hi,
Quoted 26 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 5 lines · Tvrtko Ursulin
Quoted 4 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
Quoted 8 lines
Quoted 5 lines
BR,
Jani.[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
Potentially, but any idea what's going wrong? Sounds like I missed something, but I don't see what.
Regards,
Christian.
Quoted 14 lines
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.Quoted 4 lines
BR,
Jani.Br
Other JaniQuoted 4 lines
--
Jani Nikula, Intel
Quoted 23 lines · Christian König
Quoted 22 lines · Jani
Hi,
Quoted 20 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 9 lines · Tvrtko Ursulin
Quoted 8 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
BR,
Jani.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
Potentially, but any idea what's going wrong? Sounds like I missed something, but I don't see what.
Oh! I now see what's going on.
Looks like the code previously had a race condition and by removing the extra check I made the race condition 100% likely.
Ups, I think a simple revert won't do it here. Give me a second.
Regards,
Christian.
Quoted 19 lines
Regards,
Christian.Quoted 14 lines
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.Quoted 4 lines
BR,
Jani.Br
Other JaniQuoted 4 lines
--
Jani Nikula, Intel
Simona Vetter
Acked-byQuoted 31 lines · Christian König
Quoted 30 lines · Christian König
Quoted 28 lines · Jani
Hi,
Quoted 26 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 5 lines · Tvrtko Ursulin
Quoted 4 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
Quoted 8 lines
Quoted 5 lines
BR,
Jani.[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
Quoted 7 lines
Quoted 1 line
Potentially, but any idea what's going wrong? Sounds like I missed something, but I don't see what.
Oh! I now see what's going on.
Looks like the code previously had a race condition and by removing the extra check I made the race condition 100% likely.
Ups, I think a simple revert won't do it here. Give me a second.
Please make sure you cc: xe-devel so intel-gfx-ci can pick it up and test. It's a bit embarrassing.
Also since this breaks things quite badly might be good to push the revert right away since I don't think we can land the proper fix before the w/e. For that
Cheers, Sima
Quoted 24 lines
Regards,
Christian.Quoted 19 lines
Regards,
Christian.Quoted 14 lines
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.Quoted 4 lines
BR,
Jani.Br
Other JaniQuoted 4 lines
--
Jani Nikula, Intel
Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 40 lines · Simona Vetter
Quoted 31 lines · Christian König
Quoted 30 lines · Christian König
Quoted 28 lines · Jani
Hi,
Quoted 26 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 5 lines · Tvrtko Ursulin
Quoted 4 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
Quoted 8 lines
Quoted 5 lines
BR,
Jani.[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
Quoted 7 lines
Quoted 1 line
Potentially, but any idea what's going wrong? Sounds like I missed something, but I don't see what.
Oh! I now see what's going on.
Looks like the code previously had a race condition and by removing the extra check I made the race condition 100% likely.
Ups, I think a simple revert won't do it here. Give me a second.
Quoted 8 lines
Please make sure you cc: xe-devel so intel-gfx-ci can pick it up and test. It's a bit embarrassing.
Also since this breaks things quite badly might be good to push the revert right away since I don't think we can land the proper fix before the w/e. For that
Acked-by Simona Vetter <[email protected]>
Done.
The basic problem is that the existing code which checked obj->dma_buf is basically broken.
Because of flink and/or GETFB2 for example it can be that you get two GEM handles for the same GEM object. But in prime we always want to return the same handle for each DMA-buf.
So if somebody would export one of those duplicated handles we would add all of them to the prime rb tree and so change the handle which would be returned. I strongly think that is not something intentional.
I've send out a patch to address this, but I'm not sure about what the preferred approach to fixing this is?
Regards,
Christian.
Quoted 27 lines
Cheers, Sima
Quoted 24 lines
Regards,
Christian.Quoted 19 lines
Regards,
Christian.Quoted 14 lines
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.Quoted 4 lines
BR,
Jani.Br
Other JaniQuoted 4 lines
--
Jani Nikula, Intel
Quoted 22 lines · Jani
Hi,
Quoted 20 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Jani Nikula
Sent: Friday, 13 June 2025 14.02
To: Tvrtko Ursulin <[email protected]>; Simona Vetter <[email protected]>; Christian König <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/prime: removedrm_prime_lookup_buf_by_handleQuoted 9 lines · Tvrtko Ursulin
Quoted 8 lines · Jani Nikula
Quoted 1 line · Simona Vetter
On Wed, Jun 04, 2025 at 05:36:22PM +0200, Simona Vetter wrote:
This regressed one of our CI IGT tests [1].
BR,
Jani.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14463
It also explodes even more trivially when logging into a KDE Wayland session:
Smells like a revert, and back to the drawing board, perhaps?
I would say so. Looks like this on our CI https://intel-gfx-ci.01.org/tree/drm-tip/igt@prime_self_import@basic-with_one_bo.html
And systems stop testing anything after (see eg https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt_runner0.txt ) when aborts happens.
Oops, sorry, I should have asked for a CI run to make sure, because I did review igt_prime test coverage a bit while looking at this patch to make sure we're not screwing up too badly.
-Sima
Quoted 12 lines
Quoted 5 lines
BR,
Jani.Br
Other JaniQuoted 4 lines
--
Jani Nikula, Intel
Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 4 lines · Christian König
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.
Quoted 8 lines
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.
This screwed up i915/xe:
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt@prime_self_import@basic-with_one_bo.html
Quoted 140 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_internal.h | 1 + drivers/gpu/drm/drm_prime.c | 56 +++++----------------------------- 3 files changed, 10 insertions(+), 49 deletions(-)drivers/gpu/drm/drm_gem.c +1
-1@@ -282,7 +282,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)if (obj->funcs->close) obj->funcs->close (obj, file_priv); -drm_prime_remove_buf_handle (&file_priv->prime, id); +drm_prime_remove_buf_handle (&file_priv->prime, obj->dma_buf, id);drm_vma_node_revoke (&obj->vma_node, file_priv);drm_gem_object_handle_put_unlocked (obj);drivers/gpu/drm/drm_internal.h +1
-0@@ -86,6 +86,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,void drm_prime_init_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_destroy_file_private (struct drm_prime_file_private *prime_fpriv);void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle);/* drm_managed.c */ drivers/gpu/drm/drm_prime.c +8
-48@@ -90,7 +90,6 @@ struct drm_prime_member {uint32_t handle;struct rb_node dmabuf_rb; -struct rb_node handle_rb; }; static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,@@ -122,45 +121,9 @@ static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,rb_link_node (&member->dmabuf_rb, rb, p);rb_insert_color (&member->dmabuf_rb, &prime_fpriv->dmabufs); - rb =NULL ; - p = &prime_fpriv->handles.rb_node; -while (*p) { -struct drm_prime_member *pos; - - rb = *p; - pos = rb_entry(rb, struct drm_prime_member, handle_rb); -if (handle > pos->handle) - p = &rb->rb_right; -else - p = &rb->rb_left; - } -rb_link_node (&member->handle_rb, rb, p); -rb_insert_color (&member->handle_rb, &prime_fpriv->handles); -return 0 ; } -static struct dma_buf *drm_prime_lookup_buf_by_handle (struct drm_prime_file_private *prime_fpriv, -uint32_t handle) -{ -struct rb_node *rb; - - rb = prime_fpriv->handles.rb_node; -while (rb) { -struct drm_prime_member *member; - - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) -return member->dma_buf; -else if (member->handle < handle) - rb = rb->rb_right; -else - rb = rb->rb_left; - } - -return NULL ; -} -static int drm_prime_lookup_buf_handle (struct drm_prime_file_private *prime_fpriv,struct dma_buf *dma_buf,uint32_t *handle)@@ -186,25 +149,28 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri }void drm_prime_remove_buf_handle (struct drm_prime_file_private *prime_fpriv, +struct dma_buf *dma_buf,uint32_t handle) {struct rb_node *rb; +if (!dma_buf) +return ; +mutex_lock (&prime_fpriv->lock); - rb = prime_fpriv->handles.rb_node; + rb = prime_fpriv->dmabufs.rb_node;while (rb) {struct drm_prime_member *member; - member = rb_entry(rb, struct drm_prime_member, handle_rb); -if (member->handle == handle) { -rb_erase (&member->handle_rb, &prime_fpriv->handles); + member = rb_entry(rb, struct drm_prime_member, dmabuf_rb); +if (member->dma_buf == dma_buf && member->handle == handle) {rb_erase (&member->dmabuf_rb, &prime_fpriv->dmabufs);dma_buf_put (member->dma_buf);kfree (member);break ; - }else if (member->handle < handle) { + }else if (member->dma_buf < dma_buf) { rb = rb->rb_right; }else { rb = rb->rb_left;@@ -446,12 +412,6 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev, goto out_unlock; } - dmabuf =drm_prime_lookup_buf_by_handle (&file_priv->prime, handle); -if (dmabuf) { -get_dma_buf (dmabuf); - goto out; - } -mutex_lock (&dev->object_name_lock);/* re-export the original imported/exported object */ if (obj->dma_buf) {Signature · 1 line
2.34.1
Signature · 2 lines
Ville Syrjälä Intel
Quoted 11 lines · Ville Syrjälä
Quoted 10 lines · Christian König
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.
Quoted 5 lines
Quoted 2 lines
Just using the DMA-buf from the GEM object in the first place has the same effect as far as I can see.
This screwed up i915/xe:
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16692/bat-twl-1/igt@prime_self_import@basic-with_one_bo.html
Never mind. Already being discussed.
Signature · 2 lines
Ville Syrjälä Intel