zink: fix bo_export caching

When creating and caching the bo_export object for a given zink_bo, the
screen file descriptor was used. Since no buffer object's file descriptor
would match that, bo_export objects were continuously added to the exports
list and no bo_export was effectively picked from the cache. Using the
buffer object's file descriptor avoids that.

Signed-off-by: Zan Dobersek <zdobersek@igalia.com>
Fixes: b0fe621459 ("zink: add back kms handling")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31715>
This commit is contained in:
Zan Dobersek
2024-10-17 14:03:12 +02:00
committed by Marge Bot
parent cfdb653f1c
commit b44480e86a

View File

@@ -130,7 +130,7 @@ bo_destroy(struct zink_screen *screen, struct pb_buffer *pbuf)
simple_mtx_lock(&bo->u.real.export_lock);
list_for_each_entry_safe(struct bo_export, export, &bo->u.real.exports, link) {
struct drm_gem_close args = { .handle = export->gem_handle };
drmIoctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &args);
drmIoctl(screen->drm_fd, DRM_IOCTL_GEM_CLOSE, &args);
list_del(&export->link);
free(export);
}
@@ -1216,7 +1216,7 @@ zink_bo_get_kms_handle(struct zink_screen *screen, struct zink_bo *bo, int fd, u
if (success) {
list_addtail(&export->link, &bo->u.real.exports);
export->gem_handle = *handle;
export->drm_fd = screen->drm_fd;
export->drm_fd = fd;
} else {
mesa_loge("zink: failed drmPrimeFDToHandle %s", strerror(errno));
FREE(export);