amdgpu/Makefile.sources | 1 amdgpu/amdgpu-symbol-check | 2 amdgpu/amdgpu.h | 18 +++++ amdgpu/amdgpu_vm.c | 53 ++++++++++++++ configure.ac | 2 debian/changelog | 7 + debian/libdrm-amdgpu1.symbols | 2 debian/rules | 2 include/drm/drm.h | 41 +++++++++++ include/drm/drm_mode.h | 92 +++++++++++++++++++++++-- tests/amdgpu/Makefile.am | 3 tests/amdgpu/amdgpu_test.c | 7 + tests/amdgpu/amdgpu_test.h | 15 ++++ tests/amdgpu/vm_tests.c | 151 ++++++++++++++++++++++++++++++++++++++++++ xf86drm.c | 38 +++++----- 15 files changed, 403 insertions(+), 31 deletions(-)
New commits: commit a9362d253586a2f0d2c142a5084de1eb283e7c39 Author: Andreas Boll <andreas.boll....@gmail.com> Date: Tue Nov 14 10:10:31 2017 +0100 Upload to unstable. diff --git a/debian/changelog b/debian/changelog index 5551899..d0d865b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdrm (2.4.88-1) UNRELEASED; urgency=medium +libdrm (2.4.88-1) unstable; urgency=medium * New upstream release. * Update libdrm-amdgpu1.symbols and shlibs. - -- Andreas Boll <andreas.boll....@gmail.com> Tue, 14 Nov 2017 09:48:52 +0100 + -- Andreas Boll <andreas.boll....@gmail.com> Tue, 14 Nov 2017 10:10:19 +0100 libdrm (2.4.85-1) unstable; urgency=medium commit 2b0f9f2223df588e1f911f0eb4cb6ab823ee5dbc Author: Andreas Boll <andreas.boll....@gmail.com> Date: Tue Nov 14 10:00:51 2017 +0100 Update libdrm-amdgpu1.symbols and shlibs. diff --git a/debian/changelog b/debian/changelog index c451923..5551899 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ libdrm (2.4.88-1) UNRELEASED; urgency=medium * New upstream release. + * Update libdrm-amdgpu1.symbols and shlibs. -- Andreas Boll <andreas.boll....@gmail.com> Tue, 14 Nov 2017 09:48:52 +0100 diff --git a/debian/libdrm-amdgpu1.symbols b/debian/libdrm-amdgpu1.symbols index 0b516ff..4dde497 100644 --- a/debian/libdrm-amdgpu1.symbols +++ b/debian/libdrm-amdgpu1.symbols @@ -53,3 +53,5 @@ libdrm_amdgpu.so.1 libdrm-amdgpu1 #MINVER# amdgpu_va_range_alloc@Base 2.4.63 amdgpu_va_range_free@Base 2.4.63 amdgpu_va_range_query@Base 2.4.63 + amdgpu_vm_reserve_vmid@Base 2.4.88 + amdgpu_vm_unreserve_vmid@Base 2.4.88 diff --git a/debian/rules b/debian/rules index 113a619..502ddab 100755 --- a/debian/rules +++ b/debian/rules @@ -108,7 +108,7 @@ ifeq ($(NOUVEAU), yes) dh_makeshlibs -plibdrm-nouveau2 -V'libdrm-nouveau2 (>= 2.4.66)' -- -c4 endif dh_makeshlibs -plibdrm-radeon1 -V'libdrm-radeon1 (>= 2.4.39)' -- -c4 - dh_makeshlibs -plibdrm-amdgpu1 -V'libdrm-amdgpu1 (>= 2.4.85)' -- -c4 + dh_makeshlibs -plibdrm-amdgpu1 -V'libdrm-amdgpu1 (>= 2.4.88)' -- -c4 ifeq ($(ARM), yes) dh_makeshlibs -plibdrm-omap1 -V'libdrm-omap1 (>= 2.4.38)' -- -c4 dh_makeshlibs -plibdrm-exynos1 -V'libdrm-exynos1 (>= 2.4.66)' -- -c4 commit 48a5d7be0af0476aca26aed42c2e941716f5c630 Author: Andreas Boll <andreas.boll....@gmail.com> Date: Tue Nov 14 09:49:04 2017 +0100 Bump changelog diff --git a/debian/changelog b/debian/changelog index d866408..c451923 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libdrm (2.4.88-1) UNRELEASED; urgency=medium + + * New upstream release. + + -- Andreas Boll <andreas.boll....@gmail.com> Tue, 14 Nov 2017 09:48:52 +0100 + libdrm (2.4.85-1) unstable; urgency=medium * New upstream release. commit 2fe4c07b38ded7f4b9341512da6e670d3321012b Author: Marek Olšák <marek.ol...@amd.com> Date: Fri Nov 3 17:28:58 2017 +0100 configure.ac: bump version for release diff --git a/configure.ac b/configure.ac index a300ff3..b2d961b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.87], + [2.4.88], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) commit f3091bac21a963f1a3d8ce5db85c0f2b4acbeb49 Author: Andrey Grodzovsky <andrey.grodzov...@amd.com> Date: Thu Nov 2 10:29:55 2017 -0400 amdgpu: Fix wrappers for AMDGPU_VM IOCTL. Rmove amdgpu_context_handle from the interface and use amdgpu_device_handle instead. Uupdate VMID reservation test accordingly. Signed-off-by: Andrey Grodzovsky <andrey.grodzov...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 597fc2b..df85a24 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1496,7 +1496,7 @@ void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, * * \return 0 on success otherwise POSIX Error code */ -int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags); +int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags); /** * Free reserved VMID @@ -1505,7 +1505,7 @@ int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags); * * \return 0 on success otherwise POSIX Error code */ -int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags); +int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, uint32_t flags); #ifdef __cplusplus } diff --git a/amdgpu/amdgpu_vm.c b/amdgpu/amdgpu_vm.c index 304b423..5ba7c08 100644 --- a/amdgpu/amdgpu_vm.c +++ b/amdgpu/amdgpu_vm.c @@ -30,24 +30,24 @@ #include "xf86drm.h" #include "amdgpu_internal.h" -int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags) +int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags) { union drm_amdgpu_vm vm; vm.in.op = AMDGPU_VM_OP_RESERVE_VMID; vm.in.flags = flags; - return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + return drmCommandWriteRead(dev->fd, DRM_AMDGPU_VM, &vm, sizeof(vm)); } -int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags) +int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, uint32_t flags) { union drm_amdgpu_vm vm; vm.in.op = AMDGPU_VM_OP_UNRESERVE_VMID; vm.in.flags = flags; - return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + return drmCommandWriteRead(dev->fd, DRM_AMDGPU_VM, &vm, sizeof(vm)); } diff --git a/tests/amdgpu/vm_tests.c b/tests/amdgpu/vm_tests.c index cbfafe9..5f18310 100644 --- a/tests/amdgpu/vm_tests.c +++ b/tests/amdgpu/vm_tests.c @@ -88,7 +88,7 @@ static void amdgpu_vmid_reserve_test(void) CU_ASSERT_EQUAL(r, 0); flags = 0; - r = amdgpu_vm_reserve_vmid(context_handle, flags); + r = amdgpu_vm_reserve_vmid(device_handle, flags); CU_ASSERT_EQUAL(r, 0); @@ -142,7 +142,7 @@ static void amdgpu_vmid_reserve_test(void) CU_ASSERT_EQUAL(r, 0); flags = 0; - r = amdgpu_vm_unreserve_vmid(context_handle, flags); + r = amdgpu_vm_unreserve_vmid(device_handle, flags); CU_ASSERT_EQUAL(r, 0); commit b617f059ad45517bded1f2d8c8e3a52b60e80bd7 Author: Marek Olšák <marek.ol...@amd.com> Date: Tue Oct 31 15:49:12 2017 +0100 configure.ac: bump version for release diff --git a/configure.ac b/configure.ac index d02a29b..a300ff3 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.86], + [2.4.87], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) commit 76c325ee7d8975248d18f2e0b6b16a03abcef4df Author: Marek Olšák <marek.ol...@amd.com> Date: Tue Oct 31 15:48:23 2017 +0100 amdgpu: fix 32-bit build diff --git a/amdgpu/amdgpu_vm.c b/amdgpu/amdgpu_vm.c index 8a9a0a1..304b423 100644 --- a/amdgpu/amdgpu_vm.c +++ b/amdgpu/amdgpu_vm.c @@ -21,6 +21,9 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "amdgpu.h" #include "amdgpu_drm.h" commit a4b487cd80f7394f3c285d5883a24a07e156f867 Author: Marek Olšák <marek.ol...@amd.com> Date: Tue Oct 31 02:11:20 2017 +0100 configure.ac: bump version for release diff --git a/configure.ac b/configure.ac index 16df3a6..d02a29b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.85], + [2.4.86], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) commit 33dcc29f7ccc554de1fc42f4b95adf056822eabb Author: Andrey Grodzovsky <andrey.grodzov...@amd.com> Date: Fri Oct 27 11:09:11 2017 -0400 amdgpu: Add VMID reservation per GPU context test. The test will Reserve a VMID, submit a command and unreserve the VMID. v2: Wrappers names were changed. Signed-off-by: Andrey Grodzovsky <andrey.grodzov...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am index 8700c4d..e79c1bd 100644 --- a/tests/amdgpu/Makefile.am +++ b/tests/amdgpu/Makefile.am @@ -31,4 +31,5 @@ amdgpu_test_SOURCES = \ uvd_enc_tests.c \ vcn_tests.c \ uve_ib.h \ - deadlock_tests.c + deadlock_tests.c \ + vm_tests.c diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 9925503..a82d9ab 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -103,6 +103,13 @@ static CU_SuiteInfo suites[] = { .pCleanupFunc = suite_deadlock_tests_clean, .pTests = deadlock_tests, }, + { + .pName = "VM Tests", + .pInitFunc = suite_vm_tests_init, + .pCleanupFunc = suite_vm_tests_clean, + .pTests = vm_tests, + }, + CU_SUITE_INFO_NULL, }; diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index ece93f4..4fffbc6 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -150,6 +150,21 @@ int suite_deadlock_tests_clean(); extern CU_TestInfo deadlock_tests[]; /** + * Initialize vm test suite + */ +int suite_vm_tests_init(); + +/** + * Deinitialize deadlock test suite + */ +int suite_vm_tests_clean(); + +/** + * Tests in vm test suite + */ +extern CU_TestInfo vm_tests[]; + +/** * Helper functions */ static inline amdgpu_bo_handle gpu_mem_alloc( diff --git a/tests/amdgpu/vm_tests.c b/tests/amdgpu/vm_tests.c new file mode 100644 index 0000000..cbfafe9 --- /dev/null +++ b/tests/amdgpu/vm_tests.c @@ -0,0 +1,151 @@ +/* + * Copyright 2017 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * +*/ + +#include "CUnit/Basic.h" + +#include "amdgpu_test.h" +#include "amdgpu_drm.h" + +static amdgpu_device_handle device_handle; +static uint32_t major_version; +static uint32_t minor_version; + + +static void amdgpu_vmid_reserve_test(void); + +int suite_vm_tests_init(void) +{ + struct amdgpu_gpu_info gpu_info = {0}; + int r; + + r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle); + + if (r) { + if ((r == -EACCES) && (errno == EACCES)) + printf("\n\nError:%s. " + "Hint:Try to run this test program as root.", + strerror(errno)); + return CUE_SINIT_FAILED; + } + + return CUE_SUCCESS; +} + +int suite_vm_tests_clean(void) +{ + int r = amdgpu_device_deinitialize(device_handle); + + if (r == 0) + return CUE_SUCCESS; + else + return CUE_SCLEAN_FAILED; +} + + +CU_TestInfo vm_tests[] = { + { "resere vmid test", amdgpu_vmid_reserve_test }, + CU_TEST_INFO_NULL, +}; + +static void amdgpu_vmid_reserve_test(void) +{ + amdgpu_context_handle context_handle; + amdgpu_bo_handle ib_result_handle; + void *ib_result_cpu; + uint64_t ib_result_mc_address; + struct amdgpu_cs_request ibs_request; + struct amdgpu_cs_ib_info ib_info; + struct amdgpu_cs_fence fence_status; + uint32_t expired, flags; + int i, r, instance; + amdgpu_bo_list_handle bo_list; + amdgpu_va_handle va_handle; + union drm_amdgpu_vm vm; + static uint32_t *ptr; + + r = amdgpu_cs_ctx_create(device_handle, &context_handle); + CU_ASSERT_EQUAL(r, 0); + + flags = 0; + r = amdgpu_vm_reserve_vmid(context_handle, flags); + CU_ASSERT_EQUAL(r, 0); + + + r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, 0, + &ib_result_handle, &ib_result_cpu, + &ib_result_mc_address, &va_handle); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL, + &bo_list); + CU_ASSERT_EQUAL(r, 0); + + ptr = ib_result_cpu; + + for (i = 0; i < 16; ++i) + ptr[i] = 0xffff1000; + + memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info)); + ib_info.ib_mc_address = ib_result_mc_address; + ib_info.size = 16; + + memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request)); + ibs_request.ip_type = AMDGPU_HW_IP_GFX; + ibs_request.ring = 0; + ibs_request.number_of_ibs = 1; + ibs_request.ibs = &ib_info; + ibs_request.resources = bo_list; + ibs_request.fence_info.handle = NULL; + + r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1); + CU_ASSERT_EQUAL(r, 0); + + + memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence)); + fence_status.context = context_handle; + fence_status.ip_type = AMDGPU_HW_IP_GFX; + fence_status.ip_instance = 0; + fence_status.ring = 0; + fence_status.fence = ibs_request.seq_no; + + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE,0, &expired); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_list_destroy(bo_list); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle, + ib_result_mc_address, 4096); + CU_ASSERT_EQUAL(r, 0); + + flags = 0; + r = amdgpu_vm_unreserve_vmid(context_handle, flags); + CU_ASSERT_EQUAL(r, 0); + + + r = amdgpu_cs_ctx_free(context_handle); + CU_ASSERT_EQUAL(r, 0); +} commit 9b38ea82fc30ccbf38ebc0c55412b27e5a5afd7b Author: Andrey Grodzovsky <andrey.grodzov...@amd.com> Date: Fri Oct 27 11:09:10 2017 -0400 amdgpu: Add wrappers for AMDGPU_VM IOCTL. v2: Rename wrappers to match the IOCTL naming, fix identation and fix make check error. Signed-off-by: Andrey Grodzovsky <andrey.grodzov...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/amdgpu/Makefile.sources b/amdgpu/Makefile.sources index bc3abaa..498b64c 100644 --- a/amdgpu/Makefile.sources +++ b/amdgpu/Makefile.sources @@ -6,6 +6,7 @@ LIBDRM_AMDGPU_FILES := \ amdgpu_gpu_info.c \ amdgpu_internal.h \ amdgpu_vamgr.c \ + amdgpu_vm.c \ util_hash.c \ util_hash.h \ util_hash_table.c \ diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check index 095c3a0..d476038 100755 --- a/amdgpu/amdgpu-symbol-check +++ b/amdgpu/amdgpu-symbol-check @@ -64,6 +64,8 @@ amdgpu_read_mm_registers amdgpu_va_range_alloc amdgpu_va_range_free amdgpu_va_range_query +amdgpu_vm_reserve_vmid +amdgpu_vm_unreserve_vmid EOF done) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index ecc975f..597fc2b 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1489,6 +1489,24 @@ void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, struct drm_amdgpu_cs_chunk_data *data); +/** + * Reserve VMID + * \param context - \c [in] GPU Context + * \param flags - \c [in] TBD + * + * \return 0 on success otherwise POSIX Error code +*/ +int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags); + +/** + * Free reserved VMID + * \param context - \c [in] GPU Context + * \param flags - \c [in] TBD + * + * \return 0 on success otherwise POSIX Error code +*/ +int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags); + #ifdef __cplusplus } #endif diff --git a/amdgpu/amdgpu_vm.c b/amdgpu/amdgpu_vm.c new file mode 100644 index 0000000..8a9a0a1 --- /dev/null +++ b/amdgpu/amdgpu_vm.c @@ -0,0 +1,50 @@ +/* + * Copyright 2017 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + + +#include "amdgpu.h" +#include "amdgpu_drm.h" +#include "xf86drm.h" +#include "amdgpu_internal.h" + +int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags) +{ + union drm_amdgpu_vm vm; + + vm.in.op = AMDGPU_VM_OP_RESERVE_VMID; + vm.in.flags = flags; + + return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + &vm, sizeof(vm)); +} + +int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags) +{ + union drm_amdgpu_vm vm; + + vm.in.op = AMDGPU_VM_OP_UNRESERVE_VMID; + vm.in.flags = flags; + + return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + &vm, sizeof(vm)); +} commit 61ff9779e37179ed5106c0e2452e16500127fb9e Author: Dave Airlie <airl...@redhat.com> Date: Wed Oct 25 07:43:56 2017 +0100 drm/syncobj: fix some whitespace issues These had tabs, just remove them. Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/xf86drm.c b/xf86drm.c index 8a32717..c44621c 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -4155,7 +4155,7 @@ int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle) args.handle = 0; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args); if (ret) - return ret; + return ret; *handle = args.handle; return 0; } @@ -4179,7 +4179,7 @@ int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd) args.handle = handle; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args); if (ret) - return ret; + return ret; *obj_fd = args.fd; return 0; } @@ -4194,7 +4194,7 @@ int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle) args.handle = 0; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args); if (ret) - return ret; + return ret; *handle = args.handle; return 0; } @@ -4221,29 +4221,29 @@ int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd) args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args); if (ret) - return ret; + return ret; *sync_file_fd = args.fd; return 0; } int drmSyncobjWait(int fd, uint32_t *handles, unsigned num_handles, - int64_t timeout_nsec, unsigned flags, - uint32_t *first_signaled) + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled) { - struct drm_syncobj_wait args; - int ret; + struct drm_syncobj_wait args; + int ret; - memclear(args); - args.handles = (intptr_t)handles; - args.timeout_nsec = timeout_nsec; - args.count_handles = num_handles; - args.flags = flags; + memclear(args); + args.handles = (intptr_t)handles; + args.timeout_nsec = timeout_nsec; + args.count_handles = num_handles; + args.flags = flags; - ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &args); - if (ret < 0) - return ret; + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &args); + if (ret < 0) + return ret; - if (first_signaled) - *first_signaled = args.first_signaled; - return ret; + if (first_signaled) + *first_signaled = args.first_signaled; + return ret; } commit 0d889201d106f7f440a0e45b3fef554c31e2a551 Author: Dave Airlie <airl...@redhat.com> Date: Wed Oct 25 16:37:44 2017 +1000 drm: sync drm headers from drm-next. This updates the headers with the contents in drm-next at 62884cd386b876638720ef88374b31a84ca7ee5f This adds leasing and aspect ratio. diff --git a/include/drm/drm.h b/include/drm/drm.h index 4737261..f0bd91d 100644 --- a/include/drm/drm.h +++ b/include/drm/drm.h @@ -731,6 +731,28 @@ struct drm_syncobj_array { __u32 pad; }; +/* Query current scanout sequence number */ +struct drm_crtc_get_sequence { + __u32 crtc_id; /* requested crtc_id */ + __u32 active; /* return: crtc output is active */ + __u64 sequence; /* return: most recent vblank sequence */ + __s64 sequence_ns; /* return: most recent time of first pixel out */ +}; + +/* Queue event to be delivered at specified sequence. Time stamp marks + * when the first pixel of the refresh cycle leaves the display engine + * for the display + */ +#define DRM_CRTC_SEQUENCE_RELATIVE 0x00000001 /* sequence is relative to current */ +#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS 0x00000002 /* Use next sequence if we've missed */ + +struct drm_crtc_queue_sequence { + __u32 crtc_id; + __u32 flags; + __u64 sequence; /* on input, target sequence. on output, actual sequence */ + __u64 user_data; /* user data passed to event */ +}; + #if defined(__cplusplus) } #endif @@ -813,6 +835,9 @@ extern "C" { #define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank) +#define DRM_IOCTL_CRTC_GET_SEQUENCE DRM_IOWR(0x3b, struct drm_crtc_get_sequence) +#define DRM_IOCTL_CRTC_QUEUE_SEQUENCE DRM_IOWR(0x3c, struct drm_crtc_queue_sequence) + #define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) #define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res) @@ -857,6 +882,11 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array) #define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) +#define DRM_IOCTL_MODE_CREATE_LEASE DRM_IOWR(0xC6, struct drm_mode_create_lease) +#define DRM_IOCTL_MODE_LIST_LESSEES DRM_IOWR(0xC7, struct drm_mode_list_lessees) +#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease) +#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) + /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. @@ -887,6 +917,7 @@ struct drm_event { #define DRM_EVENT_VBLANK 0x01 #define DRM_EVENT_FLIP_COMPLETE 0x02 +#define DRM_EVENT_CRTC_SEQUENCE 0x03 struct drm_event_vblank { struct drm_event base; @@ -897,6 +928,16 @@ struct drm_event_vblank { __u32 crtc_id; /* 0 on older kernels that do not support this */ }; +/* Event delivered at sequence. Time stamp marks when the first pixel + * of the refresh cycle leaves the display engine for the display + */ +struct drm_event_crtc_sequence { + struct drm_event base; + __u64 user_data; + __s64 time_ns; + __u64 sequence; +}; + /* typedef area */ typedef struct drm_clip_rect drm_clip_rect_t; typedef struct drm_drawable_info drm_drawable_info_t; diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h index e01f129..5597a87 100644 --- a/include/drm/drm_mode.h +++ b/include/drm/drm_mode.h @@ -75,7 +75,7 @@ extern "C" { * (define not exposed to user space). */ #define DRM_MODE_FLAG_3D_MASK (0x1f<<14) -#define DRM_MODE_FLAG_3D_NONE (0<<14) +#define DRM_MODE_FLAG_3D_NONE (0<<14) #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14) #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14) #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14) @@ -85,6 +85,19 @@ extern "C" { #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14) #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14) +/* Picture aspect ratio options */ +#define DRM_MODE_PICTURE_ASPECT_NONE 0 +#define DRM_MODE_PICTURE_ASPECT_4_3 1 +#define DRM_MODE_PICTURE_ASPECT_16_9 2 + +/* Aspect ratio flag bitmask (4 bits 22:19) */ +#define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19) +#define DRM_MODE_FLAG_PIC_AR_NONE \ + (DRM_MODE_PICTURE_ASPECT_NONE<<19) +#define DRM_MODE_FLAG_PIC_AR_4_3 \ + (DRM_MODE_PICTURE_ASPECT_4_3<<19) +#define DRM_MODE_FLAG_PIC_AR_16_9 \ + (DRM_MODE_PICTURE_ASPECT_16_9<<19) /* DPMS flags */ /* bit compatible with the xorg definitions. */ @@ -100,11 +113,6 @@ extern "C" { #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */ #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */ -/* Picture aspect ratio options */ -#define DRM_MODE_PICTURE_ASPECT_NONE 0 -#define DRM_MODE_PICTURE_ASPECT_4_3 1 -#define DRM_MODE_PICTURE_ASPECT_16_9 2 - /* Dithering mode options */ #define DRM_MODE_DITHERING_OFF 0 #define DRM_MODE_DITHERING_ON 1 @@ -724,7 +732,7 @@ struct drm_format_modifier_blob { /* Where in this blob the modifiers exist (in bytes) */ __u32 modifiers_offset; - /* u32 formats[] */ + /* __u32 formats[] */ /* struct drm_format_modifier modifiers[] */ }; @@ -741,9 +749,9 @@ struct drm_format_modifier { * If the number formats grew to 128, and formats 98-102 are * supported with the modifier: * - * 0x0000003c00000000 0000000000000000 + * 0x0000007c00000000 0000000000000000 * ^ - * |__offset = 64, formats = 0x3c00000000 + * |__offset = 64, formats = 0x7c00000000 * */ __u64 formats; @@ -774,6 +782,72 @@ struct drm_mode_destroy_blob { __u32 blob_id; }; +/** + * Lease mode resources, creating another drm_master. + */ +struct drm_mode_create_lease { + /** Pointer to array of object ids (__u32) */ + __u64 object_ids; + /** Number of object ids */ + __u32 object_count; + /** flags for new FD (O_CLOEXEC, etc) */ + __u32 flags; + + /** Return: unique identifier for lessee. */ + __u32 lessee_id; + /** Return: file descriptor to new drm_master file */ + __u32 fd; +}; + +/** + * List lesses from a drm_master + */ +struct drm_mode_list_lessees { + /** Number of lessees. + * On input, provides length of the array. + * On output, provides total number. No + * more than the input number will be written + * back, so two calls can be used to get + * the size and then the data. + */ + __u32 count_lessees; + __u32 pad; + + /** Pointer to lessees. + * pointer to __u64 array of lessee ids + */ + __u64 lessees_ptr; +}; + +/** + * Get leased objects + */ +struct drm_mode_get_lease { + /** Number of leased objects. + * On input, provides length of the array. + * On output, provides total number. No + * more than the input number will be written + * back, so two calls can be used to get + * the size and then the data. + */ + __u32 count_objects; + __u32 pad; + + /** Pointer to objects. + * pointer to __u32 array of object ids + */ + __u64 objects_ptr; +}; + +/** + * Revoke lease + */ +struct drm_mode_revoke_lease { + /** Unique ID of lessee + */ + __u32 lessee_id; +}; + #if defined(__cplusplus) } #endif