diff -Nru libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_device.c libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_device.c --- libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_device.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_device.c 2015-08-18 21:03:13.000000000 +0000 @@ -43,6 +43,7 @@ #include "amdgpu_drm.h" #include "amdgpu_internal.h" #include "util_hash_table.h" +#include "util_math.h" #define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) #define UINT_TO_PTR(x) ((void *)((intptr_t)(x))) @@ -129,7 +130,8 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev) { - amdgpu_vamgr_reference(&dev->vamgr, NULL); + amdgpu_vamgr_deinit(dev->vamgr); + free(dev->vamgr); util_hash_table_destroy(dev->bo_flink_names); util_hash_table_destroy(dev->bo_handles); pthread_mutex_destroy(&dev->bo_table_mutex); @@ -173,6 +175,7 @@ int flag_auth = 0; int flag_authexist=0; uint32_t accel_working = 0; + uint64_t start, max; *device_handle = NULL; @@ -249,7 +252,26 @@ if (r) goto cleanup; - dev->vamgr = amdgpu_vamgr_get_global(dev); + dev->vamgr = calloc(1, sizeof(struct amdgpu_bo_va_mgr)); + if (dev->vamgr == NULL) + goto cleanup; + + amdgpu_vamgr_init(dev->vamgr, dev->dev_info.virtual_address_offset, + dev->dev_info.virtual_address_max, + dev->dev_info.virtual_address_alignment); + + max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff); + start = amdgpu_vamgr_find_va(dev->vamgr, + max - dev->dev_info.virtual_address_offset, + dev->dev_info.virtual_address_alignment, 0); + if (start > 0xffffffff) + goto free_va; /* shouldn't get here */ + + dev->vamgr_32 = calloc(1, sizeof(struct amdgpu_bo_va_mgr)); + if (dev->vamgr_32 == NULL) + goto free_va; + amdgpu_vamgr_init(dev->vamgr_32, start, max, + dev->dev_info.virtual_address_alignment); *major_version = dev->major_version; *minor_version = dev->minor_version; @@ -259,6 +281,13 @@ return 0; +free_va: + r = -ENOMEM; + amdgpu_vamgr_free_va(dev->vamgr, start, + max - dev->dev_info.virtual_address_offset); + amdgpu_vamgr_deinit(dev->vamgr); + free(dev->vamgr); + cleanup: if (dev->fd >= 0) close(dev->fd); diff -Nru libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu.h libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu.h --- libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu.h 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu.h 2015-08-18 21:03:13.000000000 +0000 @@ -1075,6 +1075,11 @@ uint32_t *values); /** + * Flag to request VA address range in the 32bit address space +*/ +#define AMDGPU_VA_RANGE_32_BIT 0x1 + +/** * Allocate virtual address range * * \param dev - [in] Device handle. See #amdgpu_device_initialize() diff -Nru libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_internal.h libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_internal.h --- libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_internal.h 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_internal.h 2015-08-18 21:03:13.000000000 +0000 @@ -52,7 +52,6 @@ }; struct amdgpu_bo_va_mgr { - atomic_t refcount; /* the start virtual address */ uint64_t va_offset; uint64_t va_max; @@ -66,6 +65,7 @@ uint64_t address; uint64_t size; enum amdgpu_gpu_va_range range; + struct amdgpu_bo_va_mgr *vamgr; }; struct amdgpu_device { @@ -83,7 +83,10 @@ pthread_mutex_t bo_table_mutex; struct drm_amdgpu_info_device dev_info; struct amdgpu_gpu_info info; + /** The global VA manager for the whole virtual address space */ struct amdgpu_bo_va_mgr *vamgr; + /** The VA manager for the 32bit address space */ + struct amdgpu_bo_va_mgr *vamgr_32; }; struct amdgpu_bo { @@ -121,12 +124,10 @@ drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo); -drm_private struct amdgpu_bo_va_mgr* -amdgpu_vamgr_get_global(struct amdgpu_device *dev); +drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start, + uint64_t max, uint64_t alignment); -drm_private void -amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, - struct amdgpu_bo_va_mgr *src); +drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr); drm_private uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, diff -Nru libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_vamgr.c libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_vamgr.c --- libdrm-2.4.63+git20150814.f045da45/amdgpu/amdgpu_vamgr.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/amdgpu/amdgpu_vamgr.c 2015-08-18 21:03:13.000000000 +0000 @@ -33,8 +33,6 @@ #include "amdgpu_internal.h" #include "util_math.h" -static struct amdgpu_bo_va_mgr vamgr = {{0}}; - int amdgpu_va_range_query(amdgpu_device_handle dev, enum amdgpu_gpu_va_range type, uint64_t *start, uint64_t *end) { @@ -46,17 +44,18 @@ return -EINVAL; } -static void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, struct amdgpu_device *dev) +drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start, + uint64_t max, uint64_t alignment) { - mgr->va_offset = dev->dev_info.virtual_address_offset; - mgr->va_max = dev->dev_info.virtual_address_max; - mgr->va_alignment = dev->dev_info.virtual_address_alignment; + mgr->va_offset = start; + mgr->va_max = max; + mgr->va_alignment = alignment; list_inithead(&mgr->va_holes); pthread_mutex_init(&mgr->bo_va_mutex, NULL); } -static void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr) +drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr) { struct amdgpu_bo_va_hole *hole; LIST_FOR_EACH_ENTRY(hole, &mgr->va_holes, list) { @@ -66,26 +65,6 @@ pthread_mutex_destroy(&mgr->bo_va_mutex); } -drm_private struct amdgpu_bo_va_mgr * -amdgpu_vamgr_get_global(struct amdgpu_device *dev) -{ - int ref; - ref = atomic_inc_return(&vamgr.refcount); - - if (ref == 1) - amdgpu_vamgr_init(&vamgr, dev); - return &vamgr; -} - -drm_private void -amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, - struct amdgpu_bo_va_mgr *src) -{ - if (update_references(&(*dst)->refcount, NULL)) - amdgpu_vamgr_deinit(*dst); - *dst = src; -} - drm_private uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, uint64_t alignment, uint64_t base_required) @@ -102,7 +81,7 @@ pthread_mutex_lock(&mgr->bo_va_mutex); /* TODO: using more appropriate way to track the holes */ /* first look for a hole */ - LIST_FOR_EACH_ENTRY_SAFE(hole, n, &vamgr.va_holes, list) { + LIST_FOR_EACH_ENTRY_SAFE(hole, n, &mgr->va_holes, list) { if (base_required) { if(hole->offset > base_required || (hole->offset + hole->size) < (base_required + size)) @@ -252,23 +231,39 @@ amdgpu_va_handle *va_range_handle, uint64_t flags) { - va_base_alignment = MAX2(va_base_alignment, dev->vamgr->va_alignment); - size = ALIGN(size, vamgr.va_alignment); + struct amdgpu_bo_va_mgr *vamgr; + + if (flags & AMDGPU_VA_RANGE_32_BIT) + vamgr = dev->vamgr_32; + else + vamgr = dev->vamgr; - *va_base_allocated = amdgpu_vamgr_find_va(dev->vamgr, size, + va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment); + size = ALIGN(size, vamgr->va_alignment); + + *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size, va_base_alignment, va_base_required); + if (!(flags & AMDGPU_VA_RANGE_32_BIT) && + (*va_base_allocated == AMDGPU_INVALID_VA_ADDRESS)) { + /* fallback to 32bit address */ + vamgr = dev->vamgr_32; + *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size, + va_base_alignment, va_base_required); + } + if (*va_base_allocated != AMDGPU_INVALID_VA_ADDRESS) { struct amdgpu_va* va; va = calloc(1, sizeof(struct amdgpu_va)); if(!va){ - amdgpu_vamgr_free_va(dev->vamgr, *va_base_allocated, size); + amdgpu_vamgr_free_va(vamgr, *va_base_allocated, size); return -ENOMEM; } va->dev = dev; va->address = *va_base_allocated; va->size = size; va->range = va_range_type; + va->vamgr = vamgr; *va_range_handle = va; } else { return -EINVAL; @@ -281,7 +276,9 @@ { if(!va_range_handle || !va_range_handle->address) return 0; - amdgpu_vamgr_free_va(va_range_handle->dev->vamgr, va_range_handle->address, + + amdgpu_vamgr_free_va(va_range_handle->vamgr, + va_range_handle->address, va_range_handle->size); free(va_range_handle); return 0; diff -Nru libdrm-2.4.63+git20150814.f045da45/ChangeLog libdrm-2.4.64+git20150818.ab2fadab/ChangeLog --- libdrm-2.4.63+git20150814.f045da45/ChangeLog 2015-08-14 17:51:47.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/ChangeLog 2015-08-18 21:03:36.000000000 +0000 @@ -1,9 +1,183 @@ -commit 2065b5578fc8ccdcd89086c5879f6d16b5ed6ec5 +commit b08997bc041f35b0714446de2fc9fd79d372bea4 Author: Robert Hooker -Date: Fri Aug 14 13:51:22 2015 -0400 +Date: Tue Aug 18 17:03:13 2015 -0400 Add debian tree from origin/debian-unstable +commit ab2fadabde3829b1ec56bd4756165dd9bd281488 +Author: Rob Clark +Date: Tue Aug 18 11:56:50 2015 -0400 + + Bump version for release + + Signed-off-by: Rob Clark + +commit 04a118d800280c88aed5cb4a5f29fdfb5a38e36b +Author: Rob Clark +Date: Tue Aug 18 10:53:36 2015 -0400 + + freedreno: update freedreno-symbol-check + + Signed-off-by: Rob Clark + +commit 5e5a3c48b83fb3929e57cb4e7261624a327137f3 +Author: Thierry Reding +Date: Wed Apr 9 09:00:49 2014 +0200 + + libdrm: Make indentation consistent + + Use tabs and spaces consistently to align function arguments on + subsequent lines with those of the first line. + + Acked-by: Laurent Pinchart + Signed-off-by: Thierry Reding + +commit d2d361cddd2bdf8f1bf627b9ebe8ca802156f8af +Author: Thierry Reding +Date: Wed Apr 9 08:59:04 2014 +0200 + + libdrm: Remove gratuitous blank lines + + Usage of blank lines can be a matter of taste, of course, but for these + we can surely all agree that they're not needed and inconsistent. + + Acked-by: Laurent Pinchart + Signed-off-by: Thierry Reding + +commit 56d8dd6a9c03680700e0b0043cb56e0af7e3e3de +Author: Jammy Zhou +Date: Mon Aug 17 11:09:09 2015 +0800 + + amdgpu: make vamgr per device v2 + + Each device can have its own vamgr, so make it per device now. + This can fix the failure with multiple GPUs used in one single + process. + + v2: rebase + + Signed-off-by: Jammy Zhou + Reviewed-by: Christian König + +commit ffa305d0fc926418e4dff432381ead8907dc18d9 +Author: Jammy Zhou +Date: Mon Aug 17 11:09:08 2015 +0800 + + amdgpu: add flag to support 32bit VA address v4 + + The AMDGPU_VA_RANGE_32_BIT flag is added to request VA range in the + 32bit address space for amdgpu_va_range_alloc. + + The 32bit address space is reserved at initialization time, and managed + with a separate VAMGR as part of the global VAMGR. And if no enough VA + space available in range above 4GB, this reserved range can be used as + fallback. + + v2: add comment for AMDGPU_VA_RANGE_32_BIT, and add vamgr to va_range + v3: rebase to Emil's drm_private series + v4: fix one warning + + Signed-off-by: Jammy Zhou + Reviewed-by: Christian König + +commit 102ab6f0049c2c85857fd19f098bc5b51e2a8a60 +Author: Jammy Zhou +Date: Mon Aug 17 11:09:07 2015 +0800 + + amdgpu: improve amdgpu_vamgr_init + + Make it a generic function independent of the device info. + + Signed-off-by: Jammy Zhou + Reviewed-by: Christian König + +commit 15ba8768f7002d220002d424790ff2e89310c07f +Author: Rob Clark +Date: Mon Aug 17 10:33:59 2015 -0400 + + freedreno: add fd_pipe_wait_timeout() + + We need to pass through a timeout parameter to implement + pipe->fence_finish() properly. + + Signed-off-by: Rob Clark + +commit 4413f191a051847c53a6150df199d35a106b6cf4 +Author: Rob Clark +Date: Tue Jul 21 12:55:29 2015 -0400 + + freedreno/msm: dump out submit info on error + + User should only see these with LIBGL_DEBUG=verbose. But in case you + are hitting issues like "handle X at index Y already on submit list" + errors from the kernel, this gives some useful visibility for debug. + + Signed-off-by: Rob Clark + +commit 9e34ee4f75ef559ff3a3c6d4b8f285453eea1f29 +Author: Rob Clark +Date: Tue Jul 21 11:57:00 2015 -0400 + + freedreno/msm: fix issue where same bo is on multiple rings + + It should be a less common case, but it is possible for a single bo to + be on multiple rings, for example when sharing a buffer across multiple + pipe_context's created from same pipe_screen. + + So rather than completely fall over in this case, fallback to slow-path + of looping over all bo's in the ring's bo-table (but retain the fast- + path of constant-lookup for the first ring the buffer is on). + + Signed-off-by: Rob Clark + +commit 2fa58ef8f43b41a6d12396ff637f09860665072f +Author: Rob Clark +Date: Tue Jul 21 12:11:36 2015 -0400 + + freedreno/msm: reorg ringbuffer struct + + Group the parts related to building out submit ioctl into their own + sub-struct. Split out from next commit since it is just boring churn. + + Signed-off-by: Rob Clark + +commit 2a34176123b1dbf55d129248a431afb185e6a37c +Author: Michel Dänzer +Date: Mon Aug 17 18:43:39 2015 +0900 + + tests/amdgpu: Remove unused local variable 'i' + + Reviewed-by: Christian König + +commit 25784d3af2f37d86fb25ee6cfa4afa6f3448af9b +Author: Michel Dänzer +Date: Mon Aug 17 18:41:11 2015 +0900 + + tests/amdgpu: Include config.h first + + Fixes build failure on 32-bit because _FILE_OFFSET_BITS wasn't defined to + 64. + + Reviewed-by: Christian König + +commit f05a74fb9cb07a02c9bade65d66ba6949a2567a2 +Author: Thierry Reding +Date: Fri Jan 23 17:08:21 2015 +0100 + + tests: modetest: Accept connector names in addition to connector IDs + + Allow connector names to be used in the specification of the -s option. + This requires storing the string passed on the command-line so that it + can later be resolved to a connector ID (after the DRM device has been + opened). + + Connector names are constructed from the connector type name and + connector type ID using the same format as used internally in the + Linux kernel. + + Signed-off-by: Thierry Reding + Signed-off-by: Laurent Pinchart + commit f045da45fee94a7179cced09a20b691c5167cef4 Author: Marek Olšák Date: Fri Aug 14 14:19:29 2015 +0200 diff -Nru libdrm-2.4.63+git20150814.f045da45/configure libdrm-2.4.64+git20150818.ab2fadab/configure --- libdrm-2.4.63+git20150814.f045da45/configure 2015-08-14 17:51:42.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/configure 2015-08-18 21:03:30.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libdrm 2.4.63. +# Generated by GNU Autoconf 2.69 for libdrm 2.4.64. # # Report bugs to . # @@ -591,8 +591,8 @@ # Identity of this package. PACKAGE_NAME='libdrm' PACKAGE_TARNAME='libdrm' -PACKAGE_VERSION='2.4.63' -PACKAGE_STRING='libdrm 2.4.63' +PACKAGE_VERSION='2.4.64' +PACKAGE_STRING='libdrm 2.4.64' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=DRI' PACKAGE_URL='' @@ -1418,7 +1418,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libdrm 2.4.63 to adapt to many kinds of systems. +\`configure' configures libdrm 2.4.64 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1488,7 +1488,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libdrm 2.4.63:";; + short | recursive ) echo "Configuration of libdrm 2.4.64:";; esac cat <<\_ACEOF @@ -1654,7 +1654,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libdrm configure 2.4.63 +libdrm configure 2.4.64 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2077,7 +2077,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libdrm $as_me 2.4.63, which was +It was created by libdrm $as_me 2.4.64, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3316,7 +3316,7 @@ # Define the identity of the package. PACKAGE='libdrm' - VERSION='2.4.63' + VERSION='2.4.64' cat >>confdefs.h <<_ACEOF @@ -14716,7 +14716,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libdrm $as_me 2.4.63, which was +This file was extended by libdrm $as_me 2.4.64, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14782,7 +14782,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libdrm config.status 2.4.63 +libdrm config.status 2.4.64 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru libdrm-2.4.63+git20150814.f045da45/configure.ac libdrm-2.4.64+git20150818.ab2fadab/configure.ac --- libdrm-2.4.63+git20150814.f045da45/configure.ac 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/configure.ac 2015-08-18 21:03:13.000000000 +0000 @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.63], + [2.4.64], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) diff -Nru libdrm-2.4.63+git20150814.f045da45/debian/changelog libdrm-2.4.64+git20150818.ab2fadab/debian/changelog --- libdrm-2.4.63+git20150814.f045da45/debian/changelog 2015-08-18 21:16:28.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/debian/changelog 2015-08-18 21:16:28.000000000 +0000 @@ -1,18 +1,26 @@ -libdrm (2.4.63+git20150814.f045da45-0ubuntu0sarvatt~trusty) trusty; urgency=high +libdrm (2.4.64+git20150818.ab2fadab-0ubuntu0sarvatt~trusty) trusty; urgency=high - * Checkout from git 20150814 (master branch) up to commit - f045da45fee94a7179cced09a20b691c5167cef4 + * Checkout from git 20150818 (master branch) up to commit + ab2fadabde3829b1ec56bd4756165dd9bd281488 * Only added debian/ tree from origin/debian-unstable - -- Robert Hooker Fri, 14 Aug 2015 13:51:48 -0400 + -- Robert Hooker Tue, 18 Aug 2015 17:03:37 -0400 -libdrm (2.4.63-1) UNRELEASED; urgency=medium +libdrm (2.4.64-1) UNRELEASED; urgency=medium * New upstream release. + * Bump symbols file and shlibs for libdrm-freedreno1. + + -- Robert Hooker Tue, 18 Aug 2015 16:05:01 -0400 + +libdrm (2.4.63-1) unstable; urgency=medium + + [ Robert Hooker ] + * New upstream release. - Drop Fix-headers-inclusion-in-xf86drmMode.c.diff, upstream. * Add new libdrm-amdgpu1 package. - -- Robert Hooker Fri, 14 Aug 2015 13:15:14 -0400 + -- Timo Aaltonen Sat, 15 Aug 2015 18:55:57 +0300 libdrm (2.4.62-1) unstable; urgency=medium diff -Nru libdrm-2.4.63+git20150814.f045da45/debian/libdrm-freedreno1.symbols libdrm-2.4.64+git20150818.ab2fadab/debian/libdrm-freedreno1.symbols --- libdrm-2.4.63+git20150814.f045da45/debian/libdrm-freedreno1.symbols 2015-08-18 21:16:28.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/debian/libdrm-freedreno1.symbols 2015-08-18 21:16:28.000000000 +0000 @@ -21,6 +21,7 @@ fd_pipe_get_param@Base 0 fd_pipe_new@Base 0 fd_pipe_wait@Base 0 + fd_pipe_wait_timeout@Base 2.4.64 fd_ringbuffer_del@Base 0 fd_ringbuffer_emit_reloc_ring@Base 0 fd_ringbuffer_flush@Base 0 diff -Nru libdrm-2.4.63+git20150814.f045da45/debian/rules libdrm-2.4.64+git20150818.ab2fadab/debian/rules --- libdrm-2.4.63+git20150814.f045da45/debian/rules 2015-08-18 21:16:28.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/debian/rules 2015-08-18 21:16:28.000000000 +0000 @@ -106,7 +106,7 @@ dh_makeshlibs -plibdrm-radeon1 -V'libdrm-radeon1 (>= 2.4.39)' -- -c4 ifeq ($(ARM), yes) dh_makeshlibs -plibdrm-omap1 -V'libdrm-omap1 (>= 2.4.38)' -- -c4 - dh_makeshlibs -plibdrm-freedreno1 -V'libdrm-freedreno1 (>= 2.4.57)' -- -c4 + dh_makeshlibs -plibdrm-freedreno1 -V'libdrm-freedreno1 (>= 2.4.64)' -- -c4 dh_makeshlibs -plibdrm-exynos1 -V'libdrm-exynos1 (>= 2.4.60)' -- -c4 dh_makeshlibs -plibdrm-tegra0 -V'libdrm-tegra0' -- -c4 endif diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_drmif.h libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_drmif.h --- libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_drmif.h 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_drmif.h 2015-08-18 21:03:13.000000000 +0000 @@ -86,6 +86,9 @@ int fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value); int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp); +/* timeout in nanosec */ +int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp, + uint64_t timeout); /* buffer-object functions: diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_pipe.c libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_pipe.c --- libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_pipe.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_pipe.c 2015-08-18 21:03:13.000000000 +0000 @@ -72,5 +72,11 @@ int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp) { - return pipe->funcs->wait(pipe, timestamp); + return fd_pipe_wait_timeout(pipe, timestamp, ~0); +} + +int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp, + uint64_t timeout) +{ + return pipe->funcs->wait(pipe, timestamp, timeout); } diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_priv.h libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_priv.h --- libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno_priv.h 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno_priv.h 2015-08-18 21:03:13.000000000 +0000 @@ -100,7 +100,7 @@ struct fd_pipe_funcs { struct fd_ringbuffer * (*ringbuffer_new)(struct fd_pipe *pipe, uint32_t size); int (*get_param)(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value); - int (*wait)(struct fd_pipe *pipe, uint32_t timestamp); + int (*wait)(struct fd_pipe *pipe, uint32_t timestamp, uint64_t timeout); void (*destroy)(struct fd_pipe *pipe); }; diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno-symbol-check libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno-symbol-check --- libdrm-2.4.63+git20150814.f045da45/freedreno/freedreno-symbol-check 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/freedreno-symbol-check 2015-08-18 21:03:13.000000000 +0000 @@ -32,6 +32,7 @@ fd_pipe_get_param fd_pipe_new fd_pipe_wait +fd_pipe_wait_timeout fd_ringbuffer_del fd_ringbuffer_emit_reloc_ring fd_ringbuffer_flush diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/kgsl/kgsl_pipe.c libdrm-2.4.64+git20150818.ab2fadab/freedreno/kgsl/kgsl_pipe.c --- libdrm-2.4.63+git20150814.f045da45/freedreno/kgsl/kgsl_pipe.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/kgsl/kgsl_pipe.c 2015-08-18 21:03:13.000000000 +0000 @@ -56,7 +56,8 @@ } } -static int kgsl_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp) +static int kgsl_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp, + uint64_t timeout) { struct kgsl_pipe *kgsl_pipe = to_kgsl_pipe(pipe); struct kgsl_device_waittimestamp req = { diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_bo.c libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_bo.c --- libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_bo.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_bo.c 2015-08-18 21:03:13.000000000 +0000 @@ -75,7 +75,7 @@ .op = op, }; - get_abs_timeout(&req.timeout, 5000); + get_abs_timeout(&req.timeout, 5000000000); return drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_CPU_PREP, &req, sizeof(req)); } @@ -129,7 +129,6 @@ { struct msm_bo *msm_bo; struct fd_bo *bo; - unsigned i; msm_bo = calloc(1, sizeof(*msm_bo)); if (!msm_bo) @@ -139,8 +138,5 @@ bo->funcs = &funcs; bo->fd = -1; - for (i = 0; i < ARRAY_SIZE(msm_bo->list); i++) - list_inithead(&msm_bo->list[i]); - return bo; } diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_pipe.c libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_pipe.c --- libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_pipe.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_pipe.c 2015-08-18 21:03:13.000000000 +0000 @@ -54,7 +54,8 @@ } } -static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp) +static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp, + uint64_t timeout) { struct fd_device *dev = pipe->dev; struct drm_msm_wait_fence req = { @@ -62,7 +63,7 @@ }; int ret; - get_abs_timeout(&req.timeout, 5000); + get_abs_timeout(&req.timeout, timeout); ret = drmCommandWrite(dev->fd, DRM_MSM_WAIT_FENCE, &req, sizeof(req)); if (ret) { diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_priv.h libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_priv.h --- libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_priv.h 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_priv.h 2015-08-18 21:03:13.000000000 +0000 @@ -71,8 +71,19 @@ struct fd_bo base; uint64_t offset; uint64_t presumed; - uint32_t indexp1[FD_PIPE_MAX]; /* index plus 1 */ - struct list_head list[FD_PIPE_MAX]; + /* in the common case, a bo won't be referenced by more than a single + * (parent) ring[*]. So to avoid looping over all the bo's in the + * reloc table to find the idx of a bo that might already be in the + * table, we cache the idx in the bo. But in order to detect the + * slow-path where bo is ref'd in multiple rb's, we also must track + * the current_ring for which the idx is valid. See bo2idx(). + * + * [*] in case multiple ringbuffers, ie. one toplevel and other rb(s) + * used for IB target(s), the toplevel rb is the parent which is + * tracking bo's for the submit + */ + struct fd_ringbuffer *current_ring; + uint32_t idx; }; static inline struct msm_bo * to_msm_bo(struct fd_bo *x) @@ -85,13 +96,13 @@ drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev, uint32_t size, uint32_t handle); -static inline void get_abs_timeout(struct drm_msm_timespec *tv, uint32_t ms) +static inline void get_abs_timeout(struct drm_msm_timespec *tv, uint64_t ns) { struct timespec t; - uint32_t s = ms / 1000; + uint32_t s = ns / 1000000000; clock_gettime(CLOCK_MONOTONIC, &t); tv->tv_sec = t.tv_sec + s; - tv->tv_nsec = t.tv_nsec + ((ms - (s * 1000)) * 1000000); + tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000); } #endif /* MSM_PRIV_H_ */ diff -Nru libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_ringbuffer.c libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_ringbuffer.c --- libdrm-2.4.63+git20150814.f045da45/freedreno/msm/msm_ringbuffer.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/freedreno/msm/msm_ringbuffer.c 2015-08-18 21:03:13.000000000 +0000 @@ -31,6 +31,7 @@ #endif #include +#include #include "freedreno_ringbuffer.h" #include "msm_priv.h" @@ -39,23 +40,32 @@ struct fd_ringbuffer base; struct fd_bo *ring_bo; - struct list_head submit_list; + /* submit ioctl related tables: */ + struct { + /* bo's table: */ + struct drm_msm_gem_submit_bo *bos; + uint32_t nr_bos, max_bos; + + /* cmd's table: */ + struct drm_msm_gem_submit_cmd *cmds; + uint32_t nr_cmds, max_cmds; + + /* reloc's table: */ + struct drm_msm_gem_submit_reloc *relocs; + uint32_t nr_relocs, max_relocs; + } submit; - /* bo's table: */ - struct drm_msm_gem_submit_bo *bos; + /* should have matching entries in submit.bos: */ + struct fd_bo **bos; uint32_t nr_bos, max_bos; - /* cmd's table: */ - struct drm_msm_gem_submit_cmd *cmds; - uint32_t nr_cmds, max_cmds; + /* should have matching entries in submit.cmds: */ struct fd_ringbuffer **rings; uint32_t nr_rings, max_rings; - - /* reloc's table: */ - struct drm_msm_gem_submit_reloc *relocs; - uint32_t nr_relocs, max_relocs; }; +static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER; + static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz) { if ((nr + 1) > *max) { @@ -78,31 +88,51 @@ return (struct msm_ringbuffer *)x; } +static uint32_t append_bo(struct fd_ringbuffer *ring, struct fd_bo *bo) +{ + struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); + uint32_t idx; + + idx = APPEND(&msm_ring->submit, bos); + idx = APPEND(msm_ring, bos); + + msm_ring->submit.bos[idx].flags = 0; + msm_ring->submit.bos[idx].handle = bo->handle; + msm_ring->submit.bos[idx].presumed = to_msm_bo(bo)->presumed; + + msm_ring->bos[idx] = fd_bo_ref(bo); + + return idx; +} + /* add (if needed) bo, return idx: */ static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t flags) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); struct msm_bo *msm_bo = to_msm_bo(bo); - int id = ring->pipe->id; uint32_t idx; - if (!msm_bo->indexp1[id]) { - struct list_head *list = &msm_bo->list[id]; - idx = APPEND(msm_ring, bos); - msm_ring->bos[idx].flags = 0; - msm_ring->bos[idx].handle = bo->handle; - msm_ring->bos[idx].presumed = msm_bo->presumed; - msm_bo->indexp1[id] = idx + 1; - - assert(LIST_IS_EMPTY(list)); - fd_bo_ref(bo); - list_addtail(list, &msm_ring->submit_list); + pthread_mutex_lock(&idx_lock); + if (!msm_bo->current_ring) { + idx = append_bo(ring, bo); + msm_bo->current_ring = ring; + msm_bo->idx = idx; + } else if (msm_bo->current_ring == ring) { + idx = msm_bo->idx; } else { - idx = msm_bo->indexp1[id] - 1; + /* slow-path: */ + for (idx = 0; idx < msm_ring->nr_bos; idx++) + if (msm_ring->bos[idx] == bo) + break; + if (idx == msm_ring->nr_bos) { + /* not found */ + idx = append_bo(ring, bo); + } } + pthread_mutex_unlock(&idx_lock); if (flags & FD_RELOC_READ) - msm_ring->bos[idx].flags |= MSM_SUBMIT_BO_READ; + msm_ring->submit.bos[idx].flags |= MSM_SUBMIT_BO_READ; if (flags & FD_RELOC_WRITE) - msm_ring->bos[idx].flags |= MSM_SUBMIT_BO_WRITE; + msm_ring->submit.bos[idx].flags |= MSM_SUBMIT_BO_WRITE; return idx; } @@ -110,7 +140,7 @@ struct drm_msm_gem_submit_cmd *cmd, struct fd_bo *bo) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); - return msm_ring->bos[cmd->submit_idx].handle == bo->handle; + return msm_ring->submit.bos[cmd->submit_idx].handle == bo->handle; } static uint32_t offset_bytes(void *end, void *start) @@ -127,8 +157,8 @@ uint32_t i; /* figure out if we already have a cmd buf: */ - for (i = 0; i < msm_ring->nr_cmds; i++) { - cmd = &msm_ring->cmds[i]; + for (i = 0; i < msm_ring->submit.nr_cmds; i++) { + cmd = &msm_ring->submit.cmds[i]; if ((cmd->submit_offset == submit_offset) && (cmd->size == size) && (cmd->type == type) && @@ -139,10 +169,10 @@ /* create cmd buf if not: */ if (!cmd) { - uint32_t idx = APPEND(msm_ring, cmds); + uint32_t idx = APPEND(&msm_ring->submit, cmds); APPEND(msm_ring, rings); msm_ring->rings[idx] = target_ring; - cmd = &msm_ring->cmds[idx]; + cmd = &msm_ring->submit.cmds[idx]; cmd->type = type; cmd->submit_idx = bo2idx(ring, target_bo, FD_RELOC_READ); cmd->submit_offset = submit_offset; @@ -165,8 +195,8 @@ uint32_t i; /* a binary search would be more clever.. */ - for (i = start; i < msm_ring->nr_relocs; i++) { - struct drm_msm_gem_submit_reloc *reloc = &msm_ring->relocs[i]; + for (i = start; i < msm_ring->submit.nr_relocs; i++) { + struct drm_msm_gem_submit_reloc *reloc = &msm_ring->submit.relocs[i]; if (reloc->submit_offset >= offset) return i; } @@ -180,13 +210,15 @@ unsigned i; /* for each of the cmd buffers, clear their reloc's: */ - for (i = 0; i < msm_ring->nr_cmds; i++) { + for (i = 0; i < msm_ring->submit.nr_cmds; i++) { struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]); - target_ring->nr_relocs = 0; + target_ring->submit.nr_relocs = 0; } - msm_ring->nr_relocs = 0; - msm_ring->nr_cmds = 0; + msm_ring->submit.nr_relocs = 0; + msm_ring->submit.nr_cmds = 0; + msm_ring->submit.nr_bos = 0; + msm_ring->nr_rings = 0; msm_ring->nr_bos = 0; } @@ -197,9 +229,8 @@ struct drm_msm_gem_submit req = { .pipe = to_msm_pipe(ring->pipe)->pipe, }; - struct msm_bo *msm_bo = NULL, *tmp; - uint32_t i, submit_offset, size; - int ret, id = ring->pipe->id; + uint32_t i, j, submit_offset, size; + int ret; submit_offset = offset_bytes(last_start, ring->start); size = offset_bytes(ring->cur, last_start); @@ -207,18 +238,18 @@ get_cmd(ring, ring, ring_bo, submit_offset, size, MSM_SUBMIT_CMD_BUF); /* needs to be after get_cmd() as that could create bos/cmds table: */ - req.bos = VOID2U64(msm_ring->bos), - req.nr_bos = msm_ring->nr_bos; - req.cmds = VOID2U64(msm_ring->cmds), - req.nr_cmds = msm_ring->nr_cmds; + req.bos = VOID2U64(msm_ring->submit.bos), + req.nr_bos = msm_ring->submit.nr_bos; + req.cmds = VOID2U64(msm_ring->submit.cmds), + req.nr_cmds = msm_ring->submit.nr_cmds; /* for each of the cmd's fix up their reloc's: */ - for (i = 0; i < msm_ring->nr_cmds; i++) { - struct drm_msm_gem_submit_cmd *cmd = &msm_ring->cmds[i]; + for (i = 0; i < msm_ring->submit.nr_cmds; i++) { + struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i]; struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]); uint32_t a = find_next_reloc_idx(target_ring, 0, cmd->submit_offset); uint32_t b = find_next_reloc_idx(target_ring, a, cmd->submit_offset + cmd->size); - cmd->relocs = VOID2U64(&target_ring->relocs[a]); + cmd->relocs = VOID2U64(&target_ring->submit.relocs[a]); cmd->nr_relocs = (b > a) ? b - a : 0; } @@ -228,19 +259,35 @@ &req, sizeof(req)); if (ret) { ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno)); + ERROR_MSG(" pipe: %u", req.pipe); + for (i = 0; i < msm_ring->submit.nr_bos; i++) { + struct drm_msm_gem_submit_bo *bo = &msm_ring->submit.bos[i]; + ERROR_MSG(" bos[%d]: handle=%u, flags=%x", i, bo->handle, bo->flags); + } + for (i = 0; i < msm_ring->submit.nr_cmds; i++) { + struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i]; + struct drm_msm_gem_submit_reloc *relocs = U642VOID(cmd->relocs); + ERROR_MSG(" cmd[%d]: type=%u, submit_idx=%u, submit_offset=%u, size=%u\n", + i, cmd->type, cmd->submit_idx, cmd->submit_offset, cmd->size); + for (j = 0; j < cmd->nr_relocs; j++) { + struct drm_msm_gem_submit_reloc *r = &relocs[j]; + ERROR_MSG(" reloc[%d]: submit_offset=%u, or=%08x, shift=%d, reloc_idx=%u" + ", reloc_offset=%"PRIu64, j, r->submit_offset, r->or, r->shift, + r->reloc_idx, r->reloc_offset); + } + } } else { /* update timestamp on all rings associated with submit: */ - for (i = 0; i < msm_ring->nr_cmds; i++) { + for (i = 0; i < msm_ring->submit.nr_cmds; i++) { struct fd_ringbuffer *target_ring = msm_ring->rings[i]; if (!ret) target_ring->last_timestamp = req.fence; } } - LIST_FOR_EACH_ENTRY_SAFE(msm_bo, tmp, &msm_ring->submit_list, list[id]) { - struct list_head *list = &msm_bo->list[id]; - list_delinit(list); - msm_bo->indexp1[id] = 0; + for (i = 0; i < msm_ring->nr_bos; i++) { + struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]); + msm_bo->current_ring = NULL; fd_bo_del(&msm_bo->base); } @@ -261,10 +308,10 @@ struct fd_ringbuffer *parent = ring->parent ? ring->parent : ring; struct msm_bo *msm_bo = to_msm_bo(r->bo); struct drm_msm_gem_submit_reloc *reloc; - uint32_t idx = APPEND(msm_ring, relocs); + uint32_t idx = APPEND(&msm_ring->submit, relocs); uint32_t addr; - reloc = &msm_ring->relocs[idx]; + reloc = &msm_ring->submit.relocs[idx]; reloc->reloc_idx = bo2idx(parent, r->bo, r->flags); reloc->reloc_offset = r->offset; @@ -333,8 +380,6 @@ ring = &msm_ring->base; ring->funcs = &funcs; - list_inithead(&msm_ring->submit_list); - msm_ring->ring_bo = fd_bo_new(pipe->dev, size, 0); if (!msm_ring->ring_bo) { ERROR_MSG("ringbuffer allocation failed"); diff -Nru libdrm-2.4.63+git20150814.f045da45/.lastcommit libdrm-2.4.64+git20150818.ab2fadab/.lastcommit --- libdrm-2.4.63+git20150814.f045da45/.lastcommit 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/.lastcommit 2015-08-18 21:03:13.000000000 +0000 @@ -1 +1 @@ -commit f045da45fee94a7179cced09a20b691c5167cef4 +commit ab2fadabde3829b1ec56bd4756165dd9bd281488 diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/amdgpu_test.c libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/amdgpu_test.c --- libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/amdgpu_test.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/amdgpu_test.c 2015-08-18 21:03:13.000000000 +0000 @@ -20,6 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/basic_tests.c libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/basic_tests.c --- libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/basic_tests.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/basic_tests.c 2015-08-18 21:03:13.000000000 +0000 @@ -20,6 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/bo_tests.c libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/bo_tests.c --- libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/bo_tests.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/bo_tests.c 2015-08-18 21:03:13.000000000 +0000 @@ -20,6 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "CUnit/Basic.h" diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/cs_tests.c libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/cs_tests.c --- libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/cs_tests.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/cs_tests.c 2015-08-18 21:03:13.000000000 +0000 @@ -20,6 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "CUnit/Basic.h" diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/vce_tests.c libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/vce_tests.c --- libdrm-2.4.63+git20150814.f045da45/tests/amdgpu/vce_tests.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/amdgpu/vce_tests.c 2015-08-18 21:03:13.000000000 +0000 @@ -21,6 +21,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include @@ -396,7 +400,7 @@ static void amdgpu_cs_vce_encode(void) { uint32_t vbuf_size, bs_size = 0x154000, cpb_size; - int i, r; + int r; vbuf_size = enc.width * enc.height * 1.5; cpb_size = vbuf_size * 10; diff -Nru libdrm-2.4.63+git20150814.f045da45/tests/modetest/modetest.c libdrm-2.4.64+git20150818.ab2fadab/tests/modetest/modetest.c --- libdrm-2.4.63+git20150814.f045da45/tests/modetest/modetest.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/tests/modetest/modetest.c 2015-08-18 21:03:13.000000000 +0000 @@ -77,6 +77,7 @@ drmModeConnector *connector; drmModeObjectProperties *props; drmModePropertyRes **props_info; + char *name; }; struct fb { @@ -372,18 +373,18 @@ int i, j; printf("Connectors:\n"); - printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n"); + printf("id\tencoder\tstatus\t\tname\t\tsize (mm)\tmodes\tencoders\n"); for (i = 0; i < dev->resources->res->count_connectors; i++) { struct connector *_connector = &dev->resources->connectors[i]; drmModeConnector *connector = _connector->connector; if (!connector) continue; - printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\t", + printf("%d\t%d\t%s\t%-15s\t%dx%d\t\t%d\t", connector->connector_id, connector->encoder_id, connector_status_str(connector->connection), - connector_type_str(connector->connector_type), + _connector->name, connector->mmWidth, connector->mmHeight, connector->count_modes); @@ -509,12 +510,13 @@ static void free_resources(struct resources *res) { + int i; + if (!res) return; #define free_resource(_res, __res, type, Type) \ do { \ - int i; \ if (!(_res)->type##s) \ break; \ for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \ @@ -527,7 +529,6 @@ #define free_properties(_res, __res, type) \ do { \ - int i; \ for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \ drmModeFreeObjectProperties(res->type##s[i].props); \ free(res->type##s[i].props_info); \ @@ -539,6 +540,10 @@ free_resource(res, res, crtc, Crtc); free_resource(res, res, encoder, Encoder); + + for (i = 0; i < res->res->count_connectors; i++) + free(res->connectors[i].name); + free_resource(res, res, connector, Connector); free_resource(res, res, fb, FB); @@ -600,6 +605,15 @@ get_resource(res, res, connector, Connector); get_resource(res, res, fb, FB); + /* Set the name of all connectors based on the type name and the per-type ID. */ + for (i = 0; i < res->res->count_connectors; i++) { + struct connector *connector = &res->connectors[i]; + + asprintf(&connector->name, "%s-%u", + connector_type_str(connector->connector->connector_type), + connector->connector->connector_type_id); + } + #define get_properties(_res, __res, type, Type) \ do { \ int i; \ @@ -666,6 +680,21 @@ return -1; } +static drmModeConnector *get_connector_by_name(struct device *dev, const char *name) +{ + struct connector *connector; + int i; + + for (i = 0; i < dev->resources->res->count_connectors; i++) { + connector = &dev->resources->connectors[i]; + + if (strcmp(connector->name, name) == 0) + return connector->connector; + } + + return NULL; +} + static drmModeConnector *get_connector_by_id(struct device *dev, uint32_t id) { drmModeConnector *connector; @@ -706,6 +735,7 @@ * can bind it with a free crtc. */ struct pipe_arg { + const char **cons; uint32_t *con_ids; unsigned int num_cons; uint32_t crtc_id; @@ -821,8 +851,8 @@ pipe->mode_str, pipe->vrefresh); if (mode == NULL) { fprintf(stderr, - "failed to find mode \"%s\" for connector %u\n", - pipe->mode_str, pipe->con_ids[i]); + "failed to find mode \"%s\" for connector %s\n", + pipe->mode_str, pipe->cons[i]); return -EINVAL; } } @@ -1122,7 +1152,7 @@ printf("setting mode %s-%dHz@%s on connectors ", pipe->mode_str, pipe->mode->vrefresh, pipe->format_str); for (j = 0; j < pipe->num_cons; ++j) - printf("%u, ", pipe->con_ids[j]); + printf("%s, ", pipe->cons[j]); printf("crtc %d\n", pipe->crtc->crtc->crtc_id); ret = drmModeSetCrtc(dev->fd, pipe->crtc->crtc->crtc_id, fb_id, @@ -1311,18 +1341,24 @@ /* Count the number of connectors and allocate them. */ pipe->num_cons = 1; - for (p = arg; isdigit(*p) || *p == ','; ++p) { + for (p = arg; *p && *p != ':' && *p != '@'; ++p) { if (*p == ',') pipe->num_cons++; } pipe->con_ids = calloc(pipe->num_cons, sizeof(*pipe->con_ids)); - if (pipe->con_ids == NULL) + pipe->cons = calloc(pipe->num_cons, sizeof(*pipe->cons)); + if (pipe->con_ids == NULL || pipe->cons == NULL) return -1; /* Parse the connectors. */ for (i = 0, p = arg; i < pipe->num_cons; ++i, p = endp + 1) { - pipe->con_ids[i] = strtoul(p, &endp, 10); + endp = strpbrk(p, ",@:"); + if (!endp) + break; + + pipe->cons[i] = strndup(p, endp - p); + if (*endp != ',') break; } @@ -1484,6 +1520,32 @@ return 1; } +static int pipe_resolve_connectors(struct device *dev, struct pipe_arg *pipe) +{ + drmModeConnector *connector; + unsigned int i; + uint32_t id; + char *endp; + + for (i = 0; i < pipe->num_cons; i++) { + id = strtoul(pipe->cons[i], &endp, 10); + if (endp == pipe->cons[i]) { + connector = get_connector_by_name(dev, pipe->cons[i]); + if (!connector) { + fprintf(stderr, "no connector named '%s'\n", + pipe->cons[i]); + return -ENODEV; + } + + id = connector->connector_id; + } + + pipe->con_ids[i] = id; + } + + return 0; +} + static char optstr[] = "cdD:efM:P:ps:Cvw:"; int main(int argc, char **argv) @@ -1499,7 +1561,7 @@ char *device = NULL; char *module = NULL; unsigned int i; - int count = 0, plane_count = 0; + unsigned int count = 0, plane_count = 0; unsigned int prop_count = 0; struct pipe_arg *pipe_args = NULL; struct plane_arg *plane_args = NULL; @@ -1641,6 +1703,14 @@ return 1; } + for (i = 0; i < count; i++) { + if (pipe_resolve_connectors(&dev, &pipe_args[i]) < 0) { + free_resources(dev.resources); + drmClose(dev.fd); + return 1; + } + } + #define dump_resource(dev, res) if (res) dump_##res(dev) dump_resource(&dev, encoders); diff -Nru libdrm-2.4.63+git20150814.f045da45/xf86drmMode.c libdrm-2.4.64+git20150818.ab2fadab/xf86drmMode.c --- libdrm-2.4.63+git20150814.f045da45/xf86drmMode.c 2015-08-14 17:51:22.000000000 +0000 +++ libdrm-2.4.64+git20150818.ab2fadab/xf86drmMode.c 2015-08-18 21:03:13.000000000 +0000 @@ -114,7 +114,6 @@ drmFree(ptr->connectors); drmFree(ptr->encoders); drmFree(ptr); - } void drmModeFreeFB(drmModeFBPtr ptr) @@ -132,7 +131,6 @@ return; drmFree(ptr); - } void drmModeFreeConnector(drmModeConnectorPtr ptr) @@ -145,7 +143,6 @@ drmFree(ptr->props); drmFree(ptr->modes); drmFree(ptr); - } void drmModeFreeEncoder(drmModeEncoderPtr ptr) @@ -252,7 +249,7 @@ } int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, - uint8_t bpp, uint32_t pitch, uint32_t bo_handle, + uint8_t bpp, uint32_t pitch, uint32_t bo_handle, uint32_t *buf_id) { struct drm_mode_fb_cmd f; @@ -340,7 +337,6 @@ return DRM_IOCTL(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty); } - /* * Crtc functions */ @@ -377,9 +373,8 @@ return r; } - int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, - uint32_t x, uint32_t y, uint32_t *connectors, int count, + uint32_t x, uint32_t y, uint32_t *connectors, int count, drmModeModeInfoPtr mode) { struct drm_mode_crtc crtc; @@ -610,7 +605,6 @@ return DRM_IOCTL(fd, DRM_IOCTL_MODE_DETACHMODE, &res); } - drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id) { struct drm_mode_get_property prop; @@ -944,7 +938,6 @@ uint32_t crtc_w, uint32_t crtc_h, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h) - { struct drm_mode_set_plane s; @@ -965,7 +958,6 @@ return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPLANE, &s); } - drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id) { struct drm_mode_get_plane ovr, counts;