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: 83786bf1c9 ("nvk: add vulkan skeleton")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11441
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30035>
This commit is contained in:
Faith Ekstrand
2024-07-03 23:26:11 -05:00
committed by Marge Bot
parent 1b56292733
commit 73ec9f0183

View File

@@ -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);