Skip to contentSkip to conversation

libdrm changes for high priority contexts

PATCH New Andres Rodriguez 3 participants 10 messages Jan 5, 2017 – Jan 9, 2017 7 messages not in the archive DRM drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 libdrm changes for high priority contexts

Hey Emil,

Wanted to check if this is more or less what you were thinking in terms of updating amdgpu_drm.h.

Patch 2 sent as a reference, and waiting for the kernel change to get merged before sending out the final version.

Regards,
Andres

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170105002935.5796-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/3 headers: Sync {amdgpu,radeon}_drm.h with the kernel

Generated using make headers_install from:
airlied/drm-next 2cf026a Merge branch 'linux-4.10' ...

Manually re-added missing RADEON_TILING_R600_NO_SCANOUT as documented on README

---
 include/drm/README       |   7 +-
 include/drm/amdgpu_drm.h | 387 +++++++++++++++++++++++++++++------------------
 include/drm/radeon_drm.h | 128 ++++++++--------
 3 files changed, 307 insertions(+), 215 deletions(-)
include/drm/README +1 -6
index a50b02c..c358b00 100644
@@ -94,10 +94,6 @@ Status: ?
 Promote to fixed size ints, which match the current (32bit) ones.
 
 
-amdgpu_drm.h
- - Using the stdint.h uint*_t over the respective __u* ones
-Status: Trivial.
-
 drm_mode.h
  - Missing DPI encode/connector pair.
 Status: Trivial.
@@ -123,8 +119,7 @@ r128_drm.h
  - Broken compat ioctls.
 
 radeon_drm.h
- - Missing RADEON_TILING_R600_NO_SCANOUT, CIK_TILE_MODE_*, broken UMS ioctls,
-using stdint types.
+ - Missing RADEON_TILING_R600_NO_SCANOUT, CIK_TILE_MODE_*, broken UMS ioctls.
  - Both kernel and libdrm: missing padding -
 drm_radeon_gem_{create,{g,s}et_tiling,set_domain} others ?
 Status: ?
include/drm/amdgpu_drm.h +242 -145

662 lines not on this page · raw message

include/drm/radeon_drm.h +64 -64

215 lines not on this page · raw message

Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170105002935.5796-2-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Thank you Andres. There's a small nit below.

Quoted 6 lines · Andres Rodriguez

Generated using make headers_install from:
airlied/drm-next 2cf026a Merge branch 'linux-4.10' ...

Manually re-added missing RADEON_TILING_R600_NO_SCANOUT as documented on README

"Thou Shalt Not make any manual changes to include/drm/*h"

Please check if there's released open-source userspace which depends on this. If there's none just drop it all together, alternatively please update the kernel header(s).

Thanks
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CACvgo50x_z1XrM-V2jvYf3e3zp4muy0Wyxpimk_5zM9hof28PQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Re: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Quoted 6 lines · Emil Velikov

Thank you Andres. There's a small nit below.

Quoted 3 lines · Andres Rodriguez

Generated using make headers_install from:
airlied/drm-next 2cf026a Merge branch 'linux-4.10' ...

Quoted 8 lines
Quoted 3 lines

Manually re-added missing RADEON_TILING_R600_NO_SCANOUT as documented on README

"Thou Shalt Not make any manual changes to include/drm/*h"

Please check if there's released open-source userspace which depends on this. If there's none just drop it all together, alternatively please update the kernel header(s).

Gallium in mesa depends on this, so I'll update the kernel headers accordingly.

Thanks again for pointing me to the README, it was pretty useful.

Regards,
Andres

Quoted 3 lines

Thanks
Emil

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d5029218-6760-ef97-3dd6-632ad51dc966-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#8 lore raw

RE: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Quoted 23 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Andres Rodriguez
Sent: Monday, January 09, 2017 12:01 PM
To: Emil Velikov
Cc: amd-gfx mailing list
Subject: Re: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Quoted 3 lines · Emil Velikov

Thank you Andres. There's a small nit below.

On 5 January 2017 at 00:29, Andres Rodriguez <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Generated using make headers_install from:
airlied/drm-next 2cf026a Merge branch 'linux-4.10' ...

Manually re-added missing RADEON_TILING_R600_NO_SCANOUT as

documented on

Quoted 2 lines
Quoted 2 lines

README

Quoted 7 lines
Quoted 5 lines

"Thou Shalt Not make any manual changes to include/drm/*h"

Please check if there's released open-source userspace which depends on this. If there's none just drop it all together, alternatively please update the kernel header(s).

Gallium in mesa depends on this, so I'll update the kernel headers accordingly.

IIRC, these are not required for the ioctls, they were just put in here since the header is shared between multiple userspace components.

Alex

Quoted 7 lines

Thanks again for pointing me to the README, it was pretty useful.

Regards,
Andres

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Thanks
Emil

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB165210337024334D288C5F42F7640-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#10 lore raw

Re: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Quoted 25 lines · Alexander
Quoted 25 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Andres Rodriguez
Sent: Monday, January 09, 2017 12:01 PM
To: Emil Velikov
Cc: amd-gfx mailing list
Subject: Re: [PATCH 1/3] headers: Sync {amdgpu,radeon}_drm.h with the kernel

Quoted 3 lines · Emil Velikov

Thank you Andres. There's a small nit below.

On 5 January 2017 at 00:29, Andres Rodriguez <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Generated using make headers_install from:
airlied/drm-next 2cf026a Merge branch 'linux-4.10' ...

Manually re-added missing RADEON_TILING_R600_NO_SCANOUT as

documented on

Quoted 4 lines
Quoted 2 lines

README

"Thou Shalt Not make any manual changes to include/drm/*h"

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Please check if there's released open-source userspace which depends on this. If there's none just drop it all together, alternatively please update the kernel header(s).

Gallium in mesa depends on this, so I'll update the kernel headers accordingly.

IIRC, these are not required for the ioctls, they were just put in here since the header is shared between multiple userspace components.

Alex

Would it still be okay to add it to the kernel side then? Having multiple userspace components depend on it would make it complicated to get a patch merged into each of them.

Andres

Quoted 11 lines
Quoted 11 lines

Thanks again for pointing me to the README, it was pretty useful.

Regards,
Andres

Quoted 2 lines

Thanks
Emil

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw

PATCH 2/3 headers: add new context priority parameter to amdgpu_drm.h

In reply to a message not in the archive

This patch is for reference only, as the corresponding kernel change is still under review.

---
 include/drm/amdgpu_drm.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/drm/amdgpu_drm.h +5 -1
index 3961836..2d331ee 100644
@@ -160,13 +160,17 @@ union drm_amdgpu_bo_list {
 /* unknown cause */
 #define AMDGPU_CTX_UNKNOWN_RESET	3
 
+/* Context priority level */
+#define AMDGPU_CTX_PRIORITY_NORMAL	0
+#define AMDGPU_CTX_PRIORITY_HIGH	1
+
 struct drm_amdgpu_ctx_in {
 	/** AMDGPU_CTX_OP_* */
 	__u32	op;
 	/** For future use, no flags defined so far */
 	__u32	flags;
 	__u32	ctx_id;
-	__u32	_pad;
+	__u32	priority;
 };
 
 union drm_amdgpu_ctx_out {
Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170105002935.5796-3-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw

Re: [PATCH 2/3] headers: add new context priority parameter to amdgpu_drm.h

Quoted 3 lines · Andres Rodriguez

This patch is for reference only, as the corresponding kernel change is still under review.

Obviously one would sync this in a similar fashion to 1/3 but as-is this is pretty good.

Quoted 10 lines
---
 include/drm/amdgpu_drm.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/drm/amdgpu_drm.h +0 -0
index 3961836..2d331ee 100644

include/drm/amdgpu_drm.h union drm_amdgpu_bo_list { · line 166

Quoted 7 lines
include/drm/amdgpu_drm.h +4 -0
@@ -160,13 +160,17 @@ union drm_amdgpu_bo_list {
 /* unknown cause */
 #define AMDGPU_CTX_UNKNOWN_RESET       3
 
+/* Context priority level */
+#define AMDGPU_CTX_PRIORITY_NORMAL     0
+#define AMDGPU_CTX_PRIORITY_HIGH       1
+

Thanks for this correction.

include/drm/amdgpu_drm.h union drm_amdgpu_bo_list { · line 173

Quoted 8 lines
include/drm/amdgpu_drm.h +1 -1
 struct drm_amdgpu_ctx_in {
        /** AMDGPU_CTX_OP_* */
        __u32   op;
        /** For future use, no flags defined so far */
        __u32   flags;
        __u32   ctx_id;
-       __u32   _pad;
+       __u32   priority;

Please don't forget the "check if this doesn't explode on {old,new} {kernel,userspace} combos" from earlier.
If you haven't already, you might want to mention why its safe in the commit message of the kernel patch.

-Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CACvgo53xrtLkCVj4xcZ7BzrsFWXJMBLMqNFkgYau3Gro-3KDjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

Re: [PATCH 2/3] headers: add new context priority parameter to amdgpu_drm.h

Quoted 34 lines · Emil Velikov
Quoted 3 lines · Andres Rodriguez

This patch is for reference only, as the corresponding kernel change is still under review.

Obviously one would sync this in a similar fashion to 1/3 but as-is this is pretty good.

Quoted 10 lines
---
  include/drm/amdgpu_drm.h | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
include/drm/amdgpu_drm.h +0 -0
index 3961836..2d331ee 100644

include/drm/amdgpu_drm.h union drm_amdgpu_bo_list { · line 166

Quoted 7 lines
include/drm/amdgpu_drm.h +4 -0
@@ -160,13 +160,17 @@ union drm_amdgpu_bo_list {
  /* unknown cause */
  #define AMDGPU_CTX_UNKNOWN_RESET       3
 
+/* Context priority level */
+#define AMDGPU_CTX_PRIORITY_NORMAL     0
+#define AMDGPU_CTX_PRIORITY_HIGH       1
+

Thanks for this correction.

include/drm/amdgpu_drm.h union drm_amdgpu_bo_list { · line 173

Quoted 8 lines
include/drm/amdgpu_drm.h +1 -1
  struct drm_amdgpu_ctx_in {
         /** AMDGPU_CTX_OP_* */
         __u32   op;
         /** For future use, no flags defined so far */
         __u32   flags;
         __u32   ctx_id;
-       __u32   _pad;
+       __u32   priority;
Quoted 4 lines

Please don't forget the "check if this doesn't explode on {old,new} {kernel,userspace} combos" from earlier.
If you haven't already, you might want to mention why its safe in the commit message of the kernel patch.

I'll make sure to put in the details when I resend the patch. Thankfully libdrm-amdgpu is pretty sane and always memsets all the ioctl structs before passing them to the kernel.

Thanks,
Andres

Quoted 2 lines

-Emil

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#16 lore raw

PATCH 3/3 amdgpu: implement context priority for amdgpu_cs_ctx_create2 v3

In reply to a message not in the archive

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 only allows only the root user to allocate high priority contexts.

v2: corresponding changes for kernel patch v2
v3: Swap enum values of _NORMAL/_HIGH for backwards compatibility
Fixed 'make check' symbol error

---
 amdgpu/amdgpu-symbol-check |  1 +
 amdgpu/amdgpu.h            | 17 +++++++++++++++--
 amdgpu/amdgpu_cs.c         | 17 +++++++++++++----
 3 files changed, 29 insertions(+), 6 deletions(-)
amdgpu/amdgpu-symbol-check +1 -0
index 87f4fd2..f3772ac 100755
@@ -26,6 +26,7 @@ amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_create_semaphore
 amdgpu_cs_ctx_create
+amdgpu_cs_ctx_create2
 amdgpu_cs_ctx_free
 amdgpu_cs_destroy_semaphore
 amdgpu_cs_query_fence_status
amdgpu/amdgpu.h +15 -2
index 7b26a04..eef7a62 100644
@@ -794,8 +794,9 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
  * context will always be executed in order (first come, first serve).
  *
  *
- * \param   dev	    - \c [in] Device handle. See #amdgpu_device_initialize()
- * \param   context - \c [out] GPU Context handle
+ * \param   dev      - \c [in] Device handle. See #amdgpu_device_initialize()
+ * \param   priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
+ * \param   context  - \c [out] GPU Context handle
  *
  * \return   0 on success\n
  *          <0 - Negative POSIX Error code
@@ -803,6 +804,18 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
  * \sa amdgpu_cs_ctx_free()
  *
 */
+int amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
+			 uint32_t priority,
+			 amdgpu_context_handle *context);
+/**
+ * Create GPU execution Context
+ *
+ * Refer to amdgpu_cs_ctx_create2 for full documentation. This call
+ * is missing the priority parameter.
+ *
+ * \sa amdgpu_cs_ctx_create2()
+ *
+*/
 int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
 			 amdgpu_context_handle *context);
 
amdgpu/amdgpu_cs.c +13 -4
index fb5b3a8..ce0656e 100644
@@ -46,13 +46,14 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);
 /**
  * Create command submission context
  *
- * \param   dev - \c [in] amdgpu device handle
- * \param   context - \c [out] amdgpu context handle
+ * \param   dev      - \c [in] Device handle. See #amdgpu_device_initialize()
+ * \param   priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
+ * \param   context  - \c [out] GPU Context handle
  *
  * \return  0 on success otherwise POSIX Error code
 */
-int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
-			 amdgpu_context_handle *context)
+int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, uint32_t priority,
+							amdgpu_context_handle *context)
 {
 	struct amdgpu_context *gpu_context;
 	union drm_amdgpu_ctx args;
@@ -77,6 +78,8 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
 	/* Create the context */
 	memset(&args, 0, sizeof(args));
 	args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
+	args.in.priority = priority;
+
 	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CTX, &args, sizeof(args));
 	if (r)
 		goto error;
@@ -96,6 +99,12 @@ error:
 	return r;
 }
 
+int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
+			 amdgpu_context_handle *context)
+{
+	return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, context);
+}
+
 /**
  * Release command submission context
  *
Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx