.editorconfig | 19 Android.common.mk | 14 Android.mk | 19 README | 6 amdgpu/Android.mk | 8 amdgpu/amdgpu-symbol-check | 3 amdgpu/amdgpu.h | 77 ++ amdgpu/amdgpu_bo.c | 30 - amdgpu/amdgpu_cs.c | 106 +++- amdgpu/amdgpu_device.c | 24 amdgpu/amdgpu_gpu_info.c | 92 ++- amdgpu/amdgpu_internal.h | 4 amdgpu/amdgpu_vamgr.c | 6 autogen.sh | 6 configure.ac | 32 - etnaviv/Android.mk | 8 etnaviv/etnaviv-symbol-check | 1 etnaviv/etnaviv_cmd_stream.c | 33 + etnaviv/etnaviv_drm.h | 8 etnaviv/etnaviv_drmif.h | 2 etnaviv/etnaviv_gpu.c | 72 +- etnaviv/etnaviv_priv.h | 22 exynos/exynos_drm.c | 2 exynos/exynos_drmif.h | 8 exynos/exynos_fimg2d.c | 14 freedreno/Android.mk | 8 freedreno/Makefile.am | 1 freedreno/freedreno_bo.c | 12 freedreno/freedreno_bo_cache.c | 4 freedreno/freedreno_device.c | 5 freedreno/freedreno_priv.h | 56 ++ freedreno/kgsl/kgsl_device.c | 2 freedreno/msm/msm_device.c | 2 freedreno/msm/msm_ringbuffer.c | 7 include/drm/README | 6 include/drm/amdgpu_drm.h | 468 ++++++++++++----- include/drm/drm.h | 3 include/drm/drm_mode.h | 45 + include/drm/i915_drm.h | 276 ++++++++++ intel/Android.mk | 8 intel/intel-symbol-check | 4 intel/intel_bufmgr.h | 11 intel/intel_bufmgr_gem.c | 159 ++++-- intel/intel_decode.c | 3 libkms/Android.mk | 6 libkms/Makefile.am | 4 libkms/exynos.c | 3 libkms/linux.c | 94 --- man/drm-kms.xml | 4 man/drm-memory.xml | 4 man/drm.xml | 6 man/drmAvailable.xml | 4 man/drmHandleEvent.xml | 4 man/drmModeGetResources.xml | 4 nouveau/Android.mk | 8 radeon/Android.mk | 8 tegra/tegra-symbol-check | 7 tests/Makefile.am | 46 - tests/amdgpu/amdgpu_test.c | 259 ++++++++- tests/amdgpu/amdgpu_test.h | 3 tests/amdgpu/basic_tests.c | 134 ++++- tests/amdgpu/bo_tests.c | 13 tests/amdgpu/cs_tests.c | 49 + tests/amdgpu/vce_tests.c | 62 +- tests/auth.c | 138 ----- tests/dristat.c | 285 ---------- tests/drmdevice.c | 60 +- tests/drmstat.c | 419 ---------------- tests/drmtest.c | 135 ----- tests/drmtest.h | 40 - tests/etnaviv/Makefile.am | 1 tests/exynos/Makefile.am | 4 tests/exynos/exynos_fimg2d_test.c | 43 - tests/getclient.c | 61 -- tests/getstats.c | 50 - tests/getversion.c | 49 - tests/lock.c | 264 ---------- tests/modetest/Android.mk | 3 tests/modetest/Makefile.am | 4 tests/modetest/modetest.c | 39 + tests/name_from_fd.c | 58 -- tests/nouveau/Makefile.am | 8 tests/openclose.c | 37 - tests/proptest/Android.mk | 3 tests/setversion.c | 91 --- tests/updatedraw.c | 154 ----- tests/util/Android.mk | 7 tests/util/kms.c | 4 xf86drm.c | 992 ++++++++++++++++++++++++++++++++++---- xf86drm.h | 56 ++ xf86drmMode.c | 26 xf86drmMode.h | 19 92 files changed, 2830 insertions(+), 2638 deletions(-)
New commits: commit 81312f3730c14a2930a7784493701809c7f04a26 Author: Marek Olšák <marek.ol...@amd.com> Date: Wed May 24 17:01:36 2017 +0200 Bump version to 2.4.81 diff --git a/configure.ac b/configure.ac index 43fcf68..1cfb8c2 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.80], + [2.4.81], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) commit eeb51df3ced003515ba4a71492eeb86c145cb77e Author: Leo Liu <leo....@amd.com> Date: Tue Feb 21 11:14:09 2017 -0500 amdgpu/drm: add AMDGPU_HW_IP_VCN_ENC Signed-off-by: Leo Liu <leo....@amd.com> Reviewed-by: Alex Deucher <alexander.deuc...@amd.com> Signed-off-by: Alex Deucher <alexander.deuc...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h index add5163..8cfe68c 100644 --- a/include/drm/amdgpu_drm.h +++ b/include/drm/amdgpu_drm.h @@ -407,7 +407,8 @@ struct drm_amdgpu_gem_va { #define AMDGPU_HW_IP_VCE 4 #define AMDGPU_HW_IP_UVD_ENC 5 #define AMDGPU_HW_IP_VCN_DEC 6 -#define AMDGPU_HW_IP_NUM 7 +#define AMDGPU_HW_IP_VCN_ENC 7 +#define AMDGPU_HW_IP_NUM 8 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1 commit 5faee772721d2d2623e7f5980477de773bc73128 Author: Leo Liu <leo....@amd.com> Date: Tue Feb 7 11:10:48 2017 -0500 amdgpu/drm: add AMDGPU_HW_IP_VCN_DEC Signed-off-by: Leo Liu <leo....@amd.com> Reviewed-by: Alex Deucher <alexander.deuc...@amd.com> Signed-off-by: Alex Deucher <alexander.deuc...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h index 0de4cf6..add5163 100644 --- a/include/drm/amdgpu_drm.h +++ b/include/drm/amdgpu_drm.h @@ -406,7 +406,8 @@ struct drm_amdgpu_gem_va { #define AMDGPU_HW_IP_UVD 3 #define AMDGPU_HW_IP_VCE 4 #define AMDGPU_HW_IP_UVD_ENC 5 -#define AMDGPU_HW_IP_NUM 6 +#define AMDGPU_HW_IP_VCN_DEC 6 +#define AMDGPU_HW_IP_NUM 7 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1 commit 3f457d2a6e2dd74820ad7258edef573ab3b114fd Author: Hawking Zhang <hawking.zh...@amd.com> Date: Thu Jan 5 02:24:53 2017 +0800 amdgpu: add raven family id Signed-off-by: Hawking Zhang <hawking.zh...@amd.com> Signed-off-by: Chunming Zhou <david1.z...@amd.com> Reviewed-by: Junwei Zhang <jerry.zh...@amd.com> Signed-off-by: Alex Deucher <alexander.deuc...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h index 516a9f2..0de4cf6 100644 --- a/include/drm/amdgpu_drm.h +++ b/include/drm/amdgpu_drm.h @@ -816,6 +816,7 @@ struct drm_amdgpu_info_vce_clock_table { #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */ #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */ #define AMDGPU_FAMILY_AI 141 /* Vega10 */ +#define AMDGPU_FAMILY_RV 142 /* Raven */ #if defined(__cplusplus) } commit 41be41f99eb53bd4998b1cd930fa63f0e552d971 Author: Nicolai Hähnle <nicolai.haeh...@amd.com> Date: Sat May 13 23:03:55 2017 +0200 amdgpu: add missing extern "C" headers Signed-off-by: Nicolai Hähnle <nicolai.haeh...@amd.com> Reviewed-by: Michel Dänzer <michel.daen...@amd.com> Reviewed-by: Alex Xie <alexbin....@amd.com> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index fdea905..1901fa8 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -37,6 +37,10 @@ #include <stdint.h> #include <stdbool.h> +#ifdef __cplusplus +extern "C" { +#endif + struct drm_amdgpu_info_hw_ip; /*--------------------------------------------------------------------------*/ @@ -1324,4 +1328,8 @@ int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem); */ const char *amdgpu_get_marketing_name(amdgpu_device_handle dev); +#ifdef __cplusplus +} +#endif + #endif /* #ifdef _AMDGPU_H_ */ commit a2fa2e08692483cf9f4d06caa6e0f0add59e3343 Author: Adam Jackson <a...@redhat.com> Date: Thu May 4 15:57:14 2017 -0400 Fix stray caller of drmCompareDevices Signed-off-by: Adam Jackson <a...@redhat.com> diff --git a/xf86drm.c b/xf86drm.c index 29fea33..728ac78 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3669,7 +3669,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) for (i = 0; i < count; i++) { for (j = i + 1; j < count; j++) { - if (drmCompareDevices(local_devices[i], local_devices[j])) { + if (drmDevicesEqual(local_devices[i], local_devices[j])) { local_devices[i]->available_nodes |= local_devices[j]->available_nodes; node_type = log2(local_devices[j]->available_nodes); memcpy(local_devices[i]->nodes[node_type], commit 7040fea0280bad527ed4b3d5eee7d7bfbf303efc Author: Adam Jackson <a...@redhat.com> Date: Thu May 4 12:25:01 2017 -0400 configure: Fix the <sys/sysmacros.h> check AC_HEADER_MAJOR only defines MAJOR_IN_SYSMACROS if major() is _not_ defined by <sys/types.h> alone. It is, but it warns, and that's ugly. To fix this, push -Werror into CFLAGS when invoking AC_HEADER_MAJOR so the warning makes the compilation test fail. Reviewed-by: Emil Velikov <emil.velil...@collabora.com> Signed-off-by: Adam Jackson <a...@redhat.com> diff --git a/configure.ac b/configure.ac index e5158b7..43fcf68 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,11 @@ AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE AC_FUNC_ALLOCA +save_CFLAGS="$CFLAGS" +export CFLAGS="$CFLAGS -Werror" AC_HEADER_MAJOR +CFLAGS="$save_CFLAGS" + AC_CHECK_HEADERS([sys/sysctl.h sys/select.h]) # Initialize libtool commit 7c27cd7c5da0b87cea0dacd454307e2613d3b415 Author: Adam Jackson <a...@redhat.com> Date: Thu May 4 10:48:56 2017 -0400 Export drmDevicesEqual drmCompareBusInfo was almost this already, but it wasn't exported, its name didn't match its functionality, and while it almost looks like it was usable for sorting due to memcmp it wouldn't work if you had multiple bus types. I don't really want to think about defining a sensible sort order for bus types, so let's at least make it less of a trap for the caller. Invert its boolean sense to be 'true if equal', rename it to describe the types it actually operates on, and export. Reviewed-by: Eric Anholt <e...@anholt.net> Reviewed-by: Emil Velikov <emil.velil...@collabora.com> Signed-off-by: Adam Jackson <a...@redhat.com> diff --git a/xf86drm.c b/xf86drm.c index 685cf69..29fea33 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3029,32 +3029,32 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) #endif } -static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) +int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b) { if (a == NULL || b == NULL) - return -1; + return 0; if (a->bustype != b->bustype) - return -1; + return 0; switch (a->bustype) { case DRM_BUS_PCI: - return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)); + return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)) == 0; case DRM_BUS_USB: - return memcmp(a->businfo.usb, b->businfo.usb, sizeof(drmUsbBusInfo)); + return memcmp(a->businfo.usb, b->businfo.usb, sizeof(drmUsbBusInfo)) == 0; case DRM_BUS_PLATFORM: - return memcmp(a->businfo.platform, b->businfo.platform, sizeof(drmPlatformBusInfo)); + return memcmp(a->businfo.platform, b->businfo.platform, sizeof(drmPlatformBusInfo)) == 0; case DRM_BUS_HOST1X: - return memcmp(a->businfo.host1x, b->businfo.host1x, sizeof(drmHost1xBusInfo)); + return memcmp(a->businfo.host1x, b->businfo.host1x, sizeof(drmHost1xBusInfo)) == 0; default: break; } - return -1; + return 0; } static int drmGetNodeType(const char *name) @@ -3669,7 +3669,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) for (i = 0; i < count; i++) { for (j = i + 1; j < count; j++) { - if (drmCompareBusInfo(local_devices[i], local_devices[j]) == 0) { + if (drmCompareDevices(local_devices[i], local_devices[j])) { local_devices[i]->available_nodes |= local_devices[j]->available_nodes; node_type = log2(local_devices[j]->available_nodes); memcpy(local_devices[i]->nodes[node_type], diff --git a/xf86drm.h b/xf86drm.h index d75ca8c..74f54f1 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -851,6 +851,8 @@ extern void drmFreeDevices(drmDevicePtr devices[], int count); extern int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device); extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices); +extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b); + #if defined(__cplusplus) } #endif commit 00aa2c18810efb896afd9ff0acbadd4aa9540fe6 Author: Edward O'Callaghan <funfunc...@folklore1984.net> Date: Sat Apr 22 16:47:40 2017 +1000 amdgpu: Use the canonical form in branch predicate Suggested-by: Emil Velikov <emil.l.veli...@gmail.com> Signed-off-by: Edward O'Callaghan <funfunc...@folklore1984.net> Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com> diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 0993a6d..868eb7b 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -559,7 +559,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, if (ring >= AMDGPU_CS_MAX_RINGS) return -EINVAL; /* must signal first */ - if (NULL == sem->signal_fence.context) + if (!sem->signal_fence.context) return -EINVAL; pthread_mutex_lock(&ctx->sequence_mutex); commit 2ee1fd2470e96473f27080c01c5ecd710a6ab6c8 Author: Eric Anholt <e...@anholt.net> Date: Tue Apr 25 11:31:27 2017 -0700 Add the DPI encoder/connector types to KMS utils. Signed-off-by: Eric Anholt <e...@anholt.net> Reviewed-by: Daniel Stone <dani...@collabora.com> diff --git a/tests/util/kms.c b/tests/util/kms.c index c008f78..028cc8d 100644 --- a/tests/util/kms.c +++ b/tests/util/kms.c @@ -79,6 +79,7 @@ static const struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, { DRM_MODE_ENCODER_DSI, "DSI" }, { DRM_MODE_ENCODER_DPMST, "DPMST" }, + { DRM_MODE_ENCODER_DPI, "DPI" }, }; const char *util_lookup_encoder_type_name(unsigned int type) @@ -117,6 +118,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_eDP, "eDP" }, { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, + { DRM_MODE_CONNECTOR_DPI, "DPI" }, }; const char *util_lookup_connector_type_name(unsigned int type) commit d75a7ef1d7353cd122e5f8e975e69d2446eaad74 Author: Eric Anholt <e...@anholt.net> Date: Tue Apr 25 11:29:33 2017 -0700 Add pl111 as a KMS driver for utils. Signed-off-by: Eric Anholt <e...@anholt.net> Reviewed-by: Daniel Stone <dani...@collabora.com> diff --git a/tests/util/kms.c b/tests/util/kms.c index 959b688..c008f78 100644 --- a/tests/util/kms.c +++ b/tests/util/kms.c @@ -145,6 +145,7 @@ static const char * const modules[] = { "virtio_gpu", "mediatek", "meson", + "pl111", }; int util_open(const char *device, const char *module) commit 691a21579962d2db2d5cb1de5286fa86ef22214f Author: Ilia Mirkin <imir...@alum.mit.edu> Date: Tue Apr 18 08:54:11 2017 -0400 modetest: fix printing of fourcc on BE machines fourcc is not a string, it's a packed integer. This happens to work out on LE, but gets reversed on BE. Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> Reviewed-by: Michel Dänzer <michel.daen...@amd.com> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index c390d87..b8891ff 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -174,6 +174,15 @@ static const char *mode_flag_names[] = { static bit_name_fn(mode_flag) +static void dump_fourcc(uint32_t fourcc) +{ + printf(" %c%c%c%c", + fourcc, + fourcc >> 8, + fourcc >> 16, + fourcc >> 24); +} + static void dump_encoders(struct device *dev) { drmModeEncoder *encoder; @@ -443,7 +452,7 @@ static void dump_planes(struct device *dev) printf(" formats:"); for (j = 0; j < ovr->count_formats; j++) - printf(" %4.4s", (char *)&ovr->formats[j]); + dump_fourcc(ovr->formats[j]); printf("\n"); if (plane->props) { commit 7cfcd5ef4b394f66c4a6fde705cf7c583a0b0c7b Author: Edward O'Callaghan <funfunc...@folklore1984.net> Date: Wed Apr 19 02:13:19 2017 +1000 amdgpu/: concisely && consistently check null ptrs in canonical form Be consistent and use the canonical form while sanity checking null pointers, also combine a few branches for brevity. v2: rebase on top of 'add amdgpu_cs_wait_fences' series. Signed-off-by: Edward O'Callaghan <funfunc...@folklore1984.net> Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 9adfffa..5ac456b 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -652,7 +652,7 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle, return -EINVAL; list = malloc(number_of_resources * sizeof(struct drm_amdgpu_bo_list_entry)); - if (list == NULL) + if (!list) return -ENOMEM; args.in.operation = AMDGPU_BO_LIST_OP_UPDATE; diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 779c7db..0993a6d 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -59,13 +59,11 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, int i, j, k; int r; - if (NULL == dev) - return -EINVAL; - if (NULL == context) + if (!dev || !context) return -EINVAL; gpu_context = calloc(1, sizeof(struct amdgpu_context)); - if (NULL == gpu_context) + if (!gpu_context) return -ENOMEM; gpu_context->dev = dev; @@ -110,7 +108,7 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context) int i, j, k; int r; - if (NULL == context) + if (!context) return -EINVAL; pthread_mutex_destroy(&context->sequence_mutex); @@ -330,9 +328,7 @@ int amdgpu_cs_submit(amdgpu_context_handle context, uint32_t i; int r; - if (NULL == context) - return -EINVAL; - if (NULL == ibs_request) + if (!context || !ibs_request) return -EINVAL; r = 0; @@ -416,11 +412,7 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, bool busy = true; int r; - if (NULL == fence) - return -EINVAL; - if (NULL == expired) - return -EINVAL; - if (NULL == fence->context) + if (!fence || !expired || !fence->context) return -EINVAL; if (fence->ip_type >= AMDGPU_HW_IP_NUM) return -EINVAL; @@ -493,12 +485,9 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, uint32_t i; /* Sanity check */ - if (NULL == fences) - return -EINVAL; - if (NULL == status) - return -EINVAL; - if (fence_count <= 0) + if (!fences || !status || !fence_count) return -EINVAL; + for (i = 0; i < fence_count; i++) { if (NULL == fences[i].context) return -EINVAL; @@ -518,11 +507,11 @@ int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem) { struct amdgpu_semaphore *gpu_semaphore; - if (NULL == sem) + if (!sem) return -EINVAL; gpu_semaphore = calloc(1, sizeof(struct amdgpu_semaphore)); - if (NULL == gpu_semaphore) + if (!gpu_semaphore) return -ENOMEM; atomic_set(&gpu_semaphore->refcount, 1); @@ -537,14 +526,12 @@ int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, uint32_t ring, amdgpu_semaphore_handle sem) { - if (NULL == ctx) + if (!ctx || !sem) return -EINVAL; if (ip_type >= AMDGPU_HW_IP_NUM) return -EINVAL; if (ring >= AMDGPU_CS_MAX_RINGS) return -EINVAL; - if (NULL == sem) - return -EINVAL; /* sem has been signaled */ if (sem->signal_fence.context) return -EINVAL; @@ -565,14 +552,12 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, uint32_t ring, amdgpu_semaphore_handle sem) { - if (NULL == ctx) + if (!ctx || !sem) return -EINVAL; if (ip_type >= AMDGPU_HW_IP_NUM) return -EINVAL; if (ring >= AMDGPU_CS_MAX_RINGS) return -EINVAL; - if (NULL == sem) - return -EINVAL; /* must signal first */ if (NULL == sem->signal_fence.context) return -EINVAL; @@ -585,9 +570,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem) { - if (NULL == sem) - return -EINVAL; - if (NULL == sem->signal_fence.context) + if (!sem || !sem->signal_fence.context) return -EINVAL; sem->signal_fence.context = NULL;; @@ -601,7 +584,7 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem) static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem) { - if (NULL == sem) + if (!sem) return -EINVAL; if (update_references(&sem->refcount, NULL)) diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index f4b94c9..1efffc6 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -234,8 +234,9 @@ drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev) int amdgpu_query_gpu_info(amdgpu_device_handle dev, struct amdgpu_gpu_info *info) { - if ((dev == NULL) || (info == NULL)) + if (!dev || !info) return -EINVAL; + /* Get ASIC info*/ *info = dev->info; @@ -300,7 +301,7 @@ int amdgpu_query_gds_info(amdgpu_device_handle dev, struct drm_amdgpu_info_gds gds_config = {}; int r; - if (gds_info == NULL) + if (!gds_info) return -EINVAL; r = amdgpu_query_info(dev, AMDGPU_INFO_GDS_CONFIG, commit 90c304584af8e1bac6391530f59bbe9ccac8e06a Author: Nicolai Hähnle <nicolai.haeh...@amd.com> Date: Thu Apr 13 16:43:58 2017 +0200 amdgpu: add a test for amdgpu_cs_wait_fences Signed-off-by: monk.liu <monk....@amd.com> [v2: actually hook up the test case] Signed-off-by: Nicolai Hähnle <nicolai.haeh...@amd.com> Reviewed-by: Alex Deucher <alexander.deuc...@amd.com> diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 4dce67e..8d5844b 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -45,6 +45,7 @@ static void amdgpu_query_info_test(void); static void amdgpu_memory_alloc(void); static void amdgpu_command_submission_gfx(void); static void amdgpu_command_submission_compute(void); +static void amdgpu_command_submission_multi_fence(void); static void amdgpu_command_submission_sdma(void); static void amdgpu_userptr_test(void); static void amdgpu_semaphore_test(void); @@ -59,6 +60,7 @@ CU_TestInfo basic_tests[] = { { "Userptr Test", amdgpu_userptr_test }, { "Command submission Test (GFX)", amdgpu_command_submission_gfx }, { "Command submission Test (Compute)", amdgpu_command_submission_compute }, + { "Command submission Test (Multi-Fence)", amdgpu_command_submission_multi_fence }, { "Command submission Test (SDMA)", amdgpu_command_submission_sdma }, { "SW semaphore Test", amdgpu_semaphore_test }, CU_TEST_INFO_NULL, @@ -1149,6 +1151,104 @@ static void amdgpu_command_submission_sdma(void) amdgpu_command_submission_sdma_copy_linear(); } +static void amdgpu_command_submission_multi_fence_wait_all(bool wait_all) +{ + amdgpu_context_handle context_handle; + amdgpu_bo_handle ib_result_handle, ib_result_ce_handle; + void *ib_result_cpu, *ib_result_ce_cpu; + uint64_t ib_result_mc_address, ib_result_ce_mc_address; + struct amdgpu_cs_request ibs_request[2] = {0}; + struct amdgpu_cs_ib_info ib_info[2]; + struct amdgpu_cs_fence fence_status[2] = {0}; + uint32_t *ptr; + uint32_t expired; + amdgpu_bo_list_handle bo_list; + amdgpu_va_handle va_handle, va_handle_ce; + int r; + int i, ib_cs_num = 2; + + r = amdgpu_cs_ctx_create(device_handle, &context_handle); + 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_bo_alloc_and_map(device_handle, 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, 0, + &ib_result_ce_handle, &ib_result_ce_cpu, + &ib_result_ce_mc_address, &va_handle_ce); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_get_bo_list(device_handle, ib_result_handle, + ib_result_ce_handle, &bo_list); + CU_ASSERT_EQUAL(r, 0); + + memset(ib_info, 0, 2 * sizeof(struct amdgpu_cs_ib_info)); + + /* IT_SET_CE_DE_COUNTERS */ + ptr = ib_result_ce_cpu; + ptr[0] = 0xc0008900; + ptr[1] = 0; + ptr[2] = 0xc0008400; + ptr[3] = 1; + ib_info[0].ib_mc_address = ib_result_ce_mc_address; + ib_info[0].size = 4; + ib_info[0].flags = AMDGPU_IB_FLAG_CE; + + /* IT_WAIT_ON_CE_COUNTER */ + ptr = ib_result_cpu; + ptr[0] = 0xc0008600; + ptr[1] = 0x00000001; + ib_info[1].ib_mc_address = ib_result_mc_address; + ib_info[1].size = 2; + + for (i = 0; i < ib_cs_num; i++) { + ibs_request[i].ip_type = AMDGPU_HW_IP_GFX; + ibs_request[i].number_of_ibs = 2; + ibs_request[i].ibs = ib_info; + ibs_request[i].resources = bo_list; + ibs_request[i].fence_info.handle = NULL; + } + + r = amdgpu_cs_submit(context_handle, 0,ibs_request, ib_cs_num); + + CU_ASSERT_EQUAL(r, 0); + + for (i = 0; i < ib_cs_num; i++) { + fence_status[i].context = context_handle; + fence_status[i].ip_type = AMDGPU_HW_IP_GFX; + fence_status[i].fence = ibs_request[i].seq_no; + } + + r = amdgpu_cs_wait_fences(fence_status, ib_cs_num, wait_all, + AMDGPU_TIMEOUT_INFINITE, + &expired, NULL); + 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); + + r = amdgpu_bo_unmap_and_free(ib_result_ce_handle, va_handle_ce, + ib_result_ce_mc_address, 4096); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_list_destroy(bo_list); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_cs_ctx_free(context_handle); + CU_ASSERT_EQUAL(r, 0); +} + +static void amdgpu_command_submission_multi_fence(void) +{ + amdgpu_command_submission_multi_fence_wait_all(true); + amdgpu_command_submission_multi_fence_wait_all(false); +} + static void amdgpu_userptr_test(void) { int i, r, j; commit d8d45a4938d99337503197fe6d28cbf20b16cc32 Author: Nicolai Hähnle <nicolai.haeh...@amd.com> Date: Thu Apr 13 16:43:14 2017 +0200 amdgpu: add the interface of waiting multiple fences Signed-off-by: Junwei Zhang <jerry.zh...@amd.com> [v2: allow returning the first signaled fence index] Signed-off-by: monk.liu <monk....@amd.com> [v3: - cleanup *status setting - fix amdgpu symbols check v4: simplify return from amdgpu_cs_wait_fences (suggested by Edward O'Callaghan)] Signed-off-by: Nicolai Hähnle <nicolai.haeh...@amd.com> Reviewed-by: Christian König <christian.koe...@amd.com> (v1) Reviewed-by: Jammy Zhou <jammy.z...@amd.com> (v1) Reviewed-by: Alex Deucher <alexander.deuc...@amd.com> diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check index 4d1ae65..81ef9b4 100755 --- a/amdgpu/amdgpu-symbol-check +++ b/amdgpu/amdgpu-symbol-check @@ -33,6 +33,7 @@ amdgpu_cs_query_fence_status amdgpu_cs_query_reset_state amdgpu_cs_signal_semaphore amdgpu_cs_submit +amdgpu_cs_wait_fences amdgpu_cs_wait_semaphore amdgpu_device_deinitialize amdgpu_device_initialize diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 55884b2..fdea905 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -907,6 +907,29 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, uint64_t flags, uint32_t *expired); +/** + * Wait for multiple fences + * + * \param fences - \c [in] The fence array to wait + * \param fence_count - \c [in] The fence count + * \param wait_all - \c [in] If true, wait all fences to be signaled, + * otherwise, wait at least one fence + * \param timeout_ns - \c [in] The timeout to wait, in nanoseconds + * \param status - \c [out] '1' for signaled, '0' for timeout + * \param first - \c [out] the index of the first signaled fence from @fences + * + * \return 0 on success + * <0 - Negative POSIX Error code + * + * \note Currently it supports only one amdgpu_device. All fences come from + * the same amdgpu_device with the same fd. +*/ +int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, + uint32_t fence_count, + bool wait_all, + uint64_t timeout_ns, + uint32_t *status, uint32_t *first); + /* * Query / Info API * diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index fb5b3a8..779c7db 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -443,6 +443,77 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, return r; } +static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences, + uint32_t fence_count, + bool wait_all, + uint64_t timeout_ns, + uint32_t *status, + uint32_t *first) +{ + struct drm_amdgpu_fence *drm_fences; + amdgpu_device_handle dev = fences[0].context->dev; + union drm_amdgpu_wait_fences args; + int r; + uint32_t i; + + drm_fences = alloca(sizeof(struct drm_amdgpu_fence) * fence_count); + for (i = 0; i < fence_count; i++) { + drm_fences[i].ctx_id = fences[i].context->id; + drm_fences[i].ip_type = fences[i].ip_type; + drm_fences[i].ip_instance = fences[i].ip_instance; + drm_fences[i].ring = fences[i].ring; + drm_fences[i].seq_no = fences[i].fence; + } + + memset(&args, 0, sizeof(args)); + args.in.fences = (uint64_t)(uintptr_t)drm_fences; + args.in.fence_count = fence_count; + args.in.wait_all = wait_all; + args.in.timeout_ns = amdgpu_cs_calculate_timeout(timeout_ns); + + r = drmIoctl(dev->fd, DRM_IOCTL_AMDGPU_WAIT_FENCES, &args); + if (r) + return -errno; + + *status = args.out.status; + + if (first) + *first = args.out.first_signaled; + + return 0; +} + +int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, + uint32_t fence_count, + bool wait_all, + uint64_t timeout_ns, + uint32_t *status, + uint32_t *first) +{ + uint32_t i; + + /* Sanity check */ + if (NULL == fences) + return -EINVAL; + if (NULL == status) + return -EINVAL; + if (fence_count <= 0) + return -EINVAL; + for (i = 0; i < fence_count; i++) { + if (NULL == fences[i].context) + return -EINVAL; + if (fences[i].ip_type >= AMDGPU_HW_IP_NUM) + return -EINVAL; + if (fences[i].ring >= AMDGPU_CS_MAX_RINGS) + return -EINVAL; + } + + *status = 0; + + return amdgpu_ioctl_wait_fences(fences, fence_count, wait_all, + timeout_ns, status, first); +} + int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem) { struct amdgpu_semaphore *gpu_semaphore; commit f45853802e910fd472f368a2d461708491fedfa3 Author: Rob Clark <robcl...@freedesktop.org> Date: Sat Apr 15 14:43:17 2017 -0400 freedreno: fix double-free on exit Fixes: a07ae97 ("freedreno: fix device close issues") Signed-off-by: Rob Clark <robcl...@freedesktop.org> diff --git a/freedreno/freedreno_device.c b/freedreno/freedreno_device.c index dba7ec4..12b95fd 100644 --- a/freedreno/freedreno_device.c +++ b/freedreno/freedreno_device.c @@ -112,13 +112,13 @@ struct fd_device * fd_device_ref(struct fd_device *dev) static void fd_device_del_impl(struct fd_device *dev) { + int close_fd = dev->closefd ? dev->fd : -1; fd_bo_cache_cleanup(&dev->bo_cache, 0); drmHashDestroy(dev->handle_table); drmHashDestroy(dev->name_table); dev->funcs->destroy(dev); - if (dev->closefd) - close(dev->fd); - free(dev); + if (close_fd >= 0) + close(close_fd); } drm_private void fd_device_del_locked(struct fd_device *dev) commit f02719c5246d301a50d7e0356bf3fe61b1e945a1 Author: Christian Gmeiner <christian.gmei...@gmail.com> Date: Sat Apr 15 00:45:57 2017 +0200 configure.ac: bump version for release Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com> diff --git a/configure.ac b/configure.ac index a67480c..e5158b7 100644 --- a/configure.ac