diff options
Diffstat (limited to 'common/recipes-graphics/drm/libdrm-2.4.66/0084-drm-Fix-multi-GPU-drmGetDevice-return-wrong-device.patch')
-rw-r--r-- | common/recipes-graphics/drm/libdrm-2.4.66/0084-drm-Fix-multi-GPU-drmGetDevice-return-wrong-device.patch | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/common/recipes-graphics/drm/libdrm-2.4.66/0084-drm-Fix-multi-GPU-drmGetDevice-return-wrong-device.patch b/common/recipes-graphics/drm/libdrm-2.4.66/0084-drm-Fix-multi-GPU-drmGetDevice-return-wrong-device.patch new file mode 100644 index 00000000..7f8d9f7d --- /dev/null +++ b/common/recipes-graphics/drm/libdrm-2.4.66/0084-drm-Fix-multi-GPU-drmGetDevice-return-wrong-device.patch @@ -0,0 +1,67 @@ +From 77886f605b2ea3db8c807a9e955c554f01ca831a Mon Sep 17 00:00:00 2001 +From: Qiang Yu <Qiang.Yu@amd.com> +Date: Sat, 9 Jul 2016 12:00:41 +0800 +Subject: [PATCH 084/117] drm: Fix multi GPU drmGetDevice return wrong device + +drmGetDevice will always return the first device it find +under /dev/dri/. This is not true for multi GPU situation. + +Change-Id: I2a85a8a4feba8a5cc517ad75c6afb532fa07c53d +Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> +Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> +--- + xf86drm.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/xf86drm.c b/xf86drm.c +index 6689f7c..19001db 100644 +--- a/xf86drm.c ++++ b/xf86drm.c +@@ -3087,6 +3087,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) + int maj, min; + int ret, i, node_count; + int max_count = 16; ++ dev_t find_rdev; + + if (fd == -1 || device == NULL) + return -EINVAL; +@@ -3094,6 +3095,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) + if (fstat(fd, &sbuf)) + return -errno; + ++ find_rdev = sbuf.st_rdev; + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); + +@@ -3154,17 +3156,24 @@ int drmGetDevice(int fd, drmDevicePtr *device) + local_devices = temp; + } + +- local_devices[i] = d; ++ /* store target at local_devices[0] for ease to use below */ ++ if (find_rdev == sbuf.st_rdev && i) { ++ local_devices[i] = local_devices[0]; ++ local_devices[0] = d; ++ } ++ else ++ local_devices[i] = d; + i++; + } + node_count = i; + +- /* Fold nodes into a single device if they share the same bus info */ ++ /* Fold nodes into a single device if they share the same bus info ++ * and nodes with same bus info will be merged into the first node ++ * position in local_devices */ + drmFoldDuplicatedDevices(local_devices, node_count); + + *device = local_devices[0]; +- for (i = 1; i < node_count && local_devices[i]; i++) +- drmFreeDevice(&local_devices[i]); ++ drmFreeDevices(&local_devices[1], node_count - 1); + + closedir(sysdir); + free(local_devices); +-- +2.7.4 + |