aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu
diff options
context:
space:
mode:
authorAndres Rodriguez2017-10-20 09:57:59 -0500
committerBas Nieuwenhuizen2017-10-20 14:51:02 -0500
commit35bc82cee9aab62d556e2ea6dfe29f71ce13dcb3 (patch)
tree7f35ba43a4ab4878e222fa2e811031c04a4e1629 /amdgpu
parentbcae7226a1c36bee22ad747dc12960e52a706cfa (diff)
downloadexternal-libdrm-35bc82cee9aab62d556e2ea6dfe29f71ce13dcb3.tar.gz
external-libdrm-35bc82cee9aab62d556e2ea6dfe29f71ce13dcb3.tar.xz
external-libdrm-35bc82cee9aab62d556e2ea6dfe29f71ce13dcb3.zip
amdgpu: implement context priority for amdgpu_cs_ctx_create2 v3
Add a new context creation function that allows specifying the context priority. A high priority context has the potential of starving lower priority contexts. The current kernel driver implementation allows only apps that hold CAP_SYS_NICE or DRM_MASTER to acquire a priority above AMDGPU_CTX_PRIORITY_NORMAL. v2: corresponding changes for kernel patch v2 v3: Fixed 'make check' symbol error Signed-off-by: Andres Rodriguez <andresx7@gmail.com> Acked-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Diffstat (limited to 'amdgpu')
-rwxr-xr-xamdgpu/amdgpu-symbol-check1
-rw-r--r--amdgpu/amdgpu.h17
-rw-r--r--amdgpu/amdgpu_cs.c17
3 files changed, 29 insertions, 6 deletions
diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check
index d9f89ef3..095c3a08 100755
--- a/amdgpu/amdgpu-symbol-check
+++ b/amdgpu/amdgpu-symbol-check
@@ -30,6 +30,7 @@ amdgpu_cs_chunk_fence_to_dep
30amdgpu_cs_create_semaphore 30amdgpu_cs_create_semaphore
31amdgpu_cs_create_syncobj 31amdgpu_cs_create_syncobj
32amdgpu_cs_ctx_create 32amdgpu_cs_ctx_create
33amdgpu_cs_ctx_create2
33amdgpu_cs_ctx_free 34amdgpu_cs_ctx_free
34amdgpu_cs_destroy_semaphore 35amdgpu_cs_destroy_semaphore
35amdgpu_cs_destroy_syncobj 36amdgpu_cs_destroy_syncobj
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 23cde108..ecc975f1 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -798,8 +798,9 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
798 * context will always be executed in order (first come, first serve). 798 * context will always be executed in order (first come, first serve).
799 * 799 *
800 * 800 *
801 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 801 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
802 * \param context - \c [out] GPU Context handle 802 * \param priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
803 * \param context - \c [out] GPU Context handle
803 * 804 *
804 * \return 0 on success\n 805 * \return 0 on success\n
805 * <0 - Negative POSIX Error code 806 * <0 - Negative POSIX Error code
@@ -807,6 +808,18 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
807 * \sa amdgpu_cs_ctx_free() 808 * \sa amdgpu_cs_ctx_free()
808 * 809 *
809*/ 810*/
811int amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
812 uint32_t priority,
813 amdgpu_context_handle *context);
814/**
815 * Create GPU execution Context
816 *
817 * Refer to amdgpu_cs_ctx_create2 for full documentation. This call
818 * is missing the priority parameter.
819 *
820 * \sa amdgpu_cs_ctx_create2()
821 *
822*/
810int amdgpu_cs_ctx_create(amdgpu_device_handle dev, 823int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
811 amdgpu_context_handle *context); 824 amdgpu_context_handle *context);
812 825
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 9577d5c9..b9fc01e7 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -46,13 +46,14 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);
46/** 46/**
47 * Create command submission context 47 * Create command submission context
48 * 48 *
49 * \param dev - \c [in] amdgpu device handle 49 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
50 * \param context - \c [out] amdgpu context handle 50 * \param priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
51 * \param context - \c [out] GPU Context handle
51 * 52 *
52 * \return 0 on success otherwise POSIX Error code 53 * \return 0 on success otherwise POSIX Error code
53*/ 54*/
54int amdgpu_cs_ctx_create(amdgpu_device_handle dev, 55int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, uint32_t priority,
55 amdgpu_context_handle *context) 56 amdgpu_context_handle *context)
56{ 57{
57 struct amdgpu_context *gpu_context; 58 struct amdgpu_context *gpu_context;
58 union drm_amdgpu_ctx args; 59 union drm_amdgpu_ctx args;
@@ -75,6 +76,8 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
75 /* Create the context */ 76 /* Create the context */
76 memset(&args, 0, sizeof(args)); 77 memset(&args, 0, sizeof(args));
77 args.in.op = AMDGPU_CTX_OP_ALLOC_CTX; 78 args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
79 args.in.priority = priority;
80
78 r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CTX, &args, sizeof(args)); 81 r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CTX, &args, sizeof(args));
79 if (r) 82 if (r)
80 goto error; 83 goto error;
@@ -94,6 +97,12 @@ error:
94 return r; 97 return r;
95} 98}
96 99
100int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
101 amdgpu_context_handle *context)
102{
103 return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, context);
104}
105
97/** 106/**
98 * Release command submission context 107 * Release command submission context
99 * 108 *