OSDN Git Service

drm: fix multi GPU drmGetDevices only return one device
authorQiang Yu <Qiang.Yu@amd.com>
Mon, 6 Jun 2016 16:29:16 +0000 (12:29 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 6 Jun 2016 16:29:16 +0000 (12:29 -0400)
When multi GPU present, after drmFoldDuplicatedDevices
merge same busid deveces, two different devices may be
seperated by zero in local_devices[]. The for loop
should check all local_devices instead of exit when
meet a zero.

Reviewed-by: Jim Qu <Jim.Qu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
xf86drm.c

index 45aa5fc..4fdcaf8 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3267,7 +3267,10 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
     drmFoldDuplicatedDevices(local_devices, node_count);
 
     device_count = 0;
-    for (i = 0; i < node_count && local_devices[i]; i++) {
+    for (i = 0; i < node_count; i++) {
+           if (!local_devices[i])
+                   continue;
+
         if ((devices != NULL) && (device_count < max_devices))
             devices[device_count] = local_devices[i];
         else