anv: don't report error with other vendor DRM devices
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 21 Jan 2020 16:19:18 +0000 (18:19 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Jan 2020 18:36:26 +0000 (18:36 +0000)
Enumeration should just skip unsupported DRM devices.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 34c8621c3b37 ("anv: Allow enumerating multiple physical devices")
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2386
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3481>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3481>

src/intel/vulkan/anv_device.c

index 50b0a01debf4a238a610157f2519cf737ed6189f..5599f35304e4d2d408a2aa1db0d3ed36a785f0ba 100644 (file)
@@ -817,13 +817,13 @@ anv_enumerate_physical_devices(struct anv_instance *instance)
 
    /* TODO: Check for more devices ? */
    drmDevicePtr devices[8];
-   VkResult result = VK_ERROR_INCOMPATIBLE_DRIVER;
    int max_devices;
 
    max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
    if (max_devices < 1)
-      return VK_ERROR_INCOMPATIBLE_DRIVER;
+      return VK_SUCCESS;
 
+   VkResult result = VK_SUCCESS;
    for (unsigned i = 0; i < (unsigned)max_devices; i++) {
       if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER &&
           devices[i]->bustype == DRM_BUS_PCI &&
@@ -832,8 +832,15 @@ anv_enumerate_physical_devices(struct anv_instance *instance)
          struct anv_physical_device *pdevice;
          result = anv_physical_device_try_create(instance, devices[i],
                                                  &pdevice);
-         if (result != VK_SUCCESS)
+         /* Incompatible DRM device, skip. */
+         if (result == VK_ERROR_INCOMPATIBLE_DRIVER) {
+            result = VK_SUCCESS;
             continue;
+         }
+
+         /* Error creating the physical device, report the error. */
+         if (result != VK_SUCCESS)
+            break;
 
          list_addtail(&pdevice->link, &instance->physical_devices);
       }
@@ -841,7 +848,7 @@ anv_enumerate_physical_devices(struct anv_instance *instance)
    drmFreeDevices(devices, max_devices);
 
    /* If we successfully enumerated any devices, call it success */
-   return !list_is_empty(&instance->physical_devices) ? VK_SUCCESS : result;
+   return result;
 }
 
 VkResult anv_EnumeratePhysicalDevices(