From f873ee506fa1cee87ea316853c82dea72e5418cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 27 Nov 2024 15:49:42 +0100 Subject: [PATCH] Revert "winsys/amdgpu: fix FD mismatch" This reverts commit 92235280595e5c4a74fff35a8ec882adb7382be5. Not needed. (The amdgpu_screen_winsys::input_fd reference in the comment didn't make sense, there was no such thing) Part-of: --- src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 2 +- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 9 ++++----- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index 68989fe702d..ac304232361 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -1652,7 +1652,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws, type = amdgpu_bo_handle_type_gem_flink_name; break; case WINSYS_HANDLE_TYPE_KMS: - if (sws->fd == aws->input_fd) { + if (sws->fd == aws->fd) { whandle->handle = bo->kms_handle; if (bo->is_shared) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index 33f56b4e7c1..d2143d44ab3 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -427,14 +427,13 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, goto fail; aws->dev = dev; - aws->fd = amdgpu_device_get_fd(dev); - /* The device fd might be different from the one we passed because of * libdrm_amdgpu device dedup logic. This can happen if radv is initialized * first. * Get the correct fd or the buffer sharing will not work (see #3424). */ - if (!are_file_descriptions_equal(aws->fd, fd)) { + int device_fd = amdgpu_device_get_fd(dev); + if (!are_file_descriptions_equal(device_fd, fd)) { sws->kms_handles = _mesa_hash_table_create(NULL, kms_handle_hash, kms_handle_equals); if (!sws->kms_handles) @@ -443,9 +442,9 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, * we need it but we'd have to use os_same_file_description() to * compare the fds. */ - aws->input_fd = aws->fd; + aws->fd = device_fd; } else { - aws->input_fd = sws->fd; + aws->fd = sws->fd; } aws->info.drm_major = drm_major; aws->info.drm_minor = drm_minor; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h index 630d15b240a..8baa8ec8ced 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h @@ -50,7 +50,7 @@ struct amdgpu_cs; * * This fd tracking is useful for buffer sharing. As an example, if an app * wants to use drmModeAddFB it'll need a KMS handle valid for its - * fd (== amdgpu_screen_winsys::input_fd). If both fds are identical, there's + * fd (== amdgpu_screen_winsys::fd). If both fds are identical, there's * nothing to do: bo->u.real.kms_handle can be used directly * (see amdgpu_bo_get_handle). If they're different, the BO has to be exported * from the device fd as a dma-buf, then imported to the app fd to get the @@ -188,10 +188,8 @@ static_assert(sizeof(((struct amdgpu_seq_no_fences*)NULL)->valid_fence_mask) * 8 /* One struct amdgpu_winsys is created for one gpu in amdgpu_winsys_create(). */ struct amdgpu_winsys { struct pipe_reference reference; - /* Returned by amdgpu_device_get_fd. */ - int fd; /* See comment above */ - int input_fd; + int fd; /* Protected by bo_fence_lock. */ struct amdgpu_queue queues[AMDGPU_MAX_QUEUES];