From 73ec9f018397b7c47edb7d5cd0e4437e0c3db0ee Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 3 Jul 2024 23:26:11 -0500 Subject: [PATCH] nvk: Silently fail to enumerate if not on nouveau The NVIDIA proprietary driver exposes a DRM device these days and this can trip up NVK as it advertises an NVIDIA device id. We fail to enumerate but the check for nouveau happens too late and we throw a warning. This means tha if NVK is even installed side-by-side with the proprietary driver, we spam warnings on every device enumeration. It's better to fail silently. Fixes: 83786bf1c9c1 ("nvk: add vulkan skeleton") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11441 Part-of: --- src/nouveau/vulkan/nvk_physical_device.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 22cd45d8394..23de0f3e7ab 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -1095,6 +1095,27 @@ nvk_get_vram_heap_available(struct nvk_physical_device *pdev) return pdev->info.vram_size_B - used; } +static bool +drm_device_is_nouveau(const char *path) +{ + int fd = open(path, O_RDWR | O_CLOEXEC); + if (fd < 0) + return false; + + drmVersionPtr ver = drmGetVersion(fd); + if (!ver) { + close(fd); + return false; + } + + const bool is_nouveau = !strncmp("nouveau", ver->name, ver->name_len); + + drmFreeVersion(ver); + close(fd); + + return is_nouveau; +} + VkResult nvk_create_drm_physical_device(struct vk_instance *_instance, drmDevicePtr drm_device, @@ -1131,6 +1152,9 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, return VK_ERROR_INCOMPATIBLE_DRIVER; } + if (!drm_device_is_nouveau(drm_device->nodes[DRM_NODE_RENDER])) + return VK_ERROR_INCOMPATIBLE_DRIVER; + struct nouveau_ws_device *ws_dev = nouveau_ws_device_new(drm_device); if (!ws_dev) return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);