amd/common/virtio: use device fd to init sync provider

Use fd after dup instead of the one before dup to avoid
drm_syncobj_find failed in guest kernel when dev is found in
dev_list.

When dev is not found in dev_list, it uses device fd which is
duplicated, to init sync provider. And when it's found, the same
device fd should be used. Otherwise, it would caused inconsistency
and failures like in the Android domU CTS test where the guest
kernel attempts to locate a syncobj. This occurs because
vdrm_device_connect and VIRTGPU_EXECBUFFER ioctl use fd after dup
while util_sync_provider_drm uses the one before dup.

The fix has been validated with the CtsSdkSandboxWebkitTestCases in
Android domU, and the previously failing test cases no longer occur.

Signed-off-by: Ruitang.Wang@amd.com
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39520>
This commit is contained in:
Wang Ruitang 2026-01-26 17:55:40 +08:00 committed by Marge Bot
parent d679236e09
commit e11c04c0cc

View file

@ -189,7 +189,7 @@ int amdvgpu_device_initialize(int fd, uint32_t *drm_major, uint32_t *drm_minor,
init_sync_provider:
*p = vdrm_vpipe_get_sync(dev->vdev);
if (!(*p))
*p = util_sync_provider_drm(fd);
*p = util_sync_provider_drm(dev->fd);
return 0;
}