drm: Branch 'master' - 4 commits
[email protected] (Emil Velikov)
| Newsgroups | gmane.comp.video.dri.patches |
|---|---|
| Message-ID | <[email protected]> |
tests/drmdevice.c | 13 +++++++++---- xf86drm.c | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) New commits: commit 681fd2ab6da0627ac8b8838eed4b3878c1cb8d25 Author: Emil Velikov <[email protected]> Date: Wed Jul 13 10:01:34 2016 +0100 tests/drmdevice: be move verbose when using open() Print out the node we're attempting to open and a message if/why we fail to do so. Signed-off-by: Emil Velikov <[email protected]> diff --git a/tests/drmdevice.c b/tests/drmdevice.c index ac5f6ff..72e7066 100644 --- a/tests/drmdevice.c +++ b/tests/drmdevice.c @@ -21,8 +21,10 @@ * */ +#include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> @@ -93,12 +95,15 @@ main(void) for (int j = 0; j < DRM_NODE_MAX; j++) { if (devices[i]->available_nodes & 1 << j) { + printf("Opening device %d node %s\n", i, devices[i]->nodes[j]); fd = open(devices[i]->nodes[j], O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) + if (fd < 0) { + printf("Failed - %s (%d)\n", strerror(errno), errno); continue; + } if (drmGetDevice(fd, &device) == 0) { - print_device_info(device, -1); + print_device_info(device, i); drmFreeDevice(&device); } close(fd); commit dd58044530ab57b8c2ee0a56008bc97bd1eecdd9 Author: Emil Velikov <[email protected]> Date: Wed Jul 13 09:43:26 2016 +0100 tests/drmdevice: print out the full 'bus' and 'dev' strings Signed-off-by: Emil Velikov <[email protected]> diff --git a/tests/drmdevice.c b/tests/drmdevice.c index c336327..ac5f6ff 100644 --- a/tests/drmdevice.c +++ b/tests/drmdevice.c @@ -44,8 +44,8 @@ print_device_info(drmDevicePtr device, int i) if (device->bustype == DRM_BUS_PCI) { printf("\t\tpci\n"); printf("\t\t\tdomain\t%04x\n",device->businfo.pci->domain); - printf("\t\t\tbu\t%02x\n", device->businfo.pci->bus); - printf("\t\t\tde\t%02x\n", device->businfo.pci->dev); + printf("\t\t\tbus\t%02x\n", device->businfo.pci->bus); + printf("\t\t\tdev\t%02x\n", device->businfo.pci->dev); printf("\t\t\tfunc\t%1u\n", device->businfo.pci->func); printf("\tdeviceinfo\n"); commit 6c056eecd56374b069ed24c81f59b6638cde2f3a Author: Qiang Yu <[email protected]> Date: Thu Jul 14 17:10:56 2016 +0800 drm: fix drmFreeDevices memory leak on multi GPU setups When in multi GPU case, devices array may have some NULL "hole" in between two devices. So check all array elements and free non-NULL device. Signed-off-by: Qiang Yu <[email protected]> Reviewed-by: Emil Velikov <[email protected]> diff --git a/xf86drm.c b/xf86drm.c index 9bd82b2..9cfca49 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2993,8 +2993,9 @@ void drmFreeDevices(drmDevicePtr devices[], int count) if (devices == NULL) return; - for (i = 0; i < count && devices[i] != NULL; i++) - drmFreeDevice(&devices[i]); + for (i = 0; i < count; i++) + if (devices[i]) + drmFreeDevice(&devices[i]); } static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, commit 3c20893daa0a56b91869d806ae0d3a8d5d8b4cba Author: Qiang Yu <[email protected]> Date: Thu Jul 14 17:10:55 2016 +0800 drm: drmGetDevice return correct device on multi GPU setups Currently drmGetDevice always returns the first device it finds under /dev/dri/. Move the target device to the start of the list during iteration. This way during deduplication it'll preserve its place and will be returned to the user. v2: Keep the memory leak separate. v3: Move the drmFoldDuplicatedDevices description Signed-off-by: Qiang Yu <[email protected]> [Emil Velikov: move drmFoldDuplicatedDevices description, add changelog, reword commit message] Reviewed-by: Emil Velikov <[email protected]> diff --git a/xf86drm.c b/xf86drm.c index 8a858ef..9bd82b2 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3050,6 +3050,11 @@ free_device: return ret; } +/* Consider devices located on the same bus as duplicate and fold the respective + * entries into a single one. + * + * Note: this leaves "gaps" in the array, while preserving the length. + */ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) { int node_type, i, j; @@ -3088,6 +3093,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; @@ -3095,6 +3101,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); @@ -3155,17 +3162,21 @@ 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 */ 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); @@ -3264,7 +3275,6 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) } node_count = i; - /* Fold nodes into a single device if they share the same bus info */ drmFoldDuplicatedDevices(local_devices, node_count); device_count = 0; ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev --