allow DRM_MASTER to change client's priorities v2
Subsystems (3)
PATCH 1/1 allow DRM_MASTER to change client's priorities v2
Updated with Christian's request to simplify the process priority override interface.
Series available in the wip-process-priorities-v2 branch of:git://people.freedesktop.org/~lostgoat/linux
_______________________________________________
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): 20170626203658.3951-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/8 drm/amdgpu: add parameter to allocate high priority contexts v11
Add a new context creation parameter to express a global context priority.
The priority ranking in descending order is as follows:
* AMDGPU_CTX_PRIORITY_HIGH_HW
* AMDGPU_CTX_PRIORITY_HIGH_SW
* AMDGPU_CTX_PRIORITY_NORMAL
* AMDGPU_CTX_PRIORITY_LOW_SW
* AMDGPU_CTX_PRIORITY_LOW_HW
The driver will attempt to schedule work to the hardware according to the priorities. No latency or throughput guarantees are provided by this patch.
This interface intends to service the EGL_IMG_context_priority extension, and vulkan equivalents.
Setting a priority above NORMAL requires CAP_SYS_NICE or DRM_MASTER.
v2: Instead of using flags, repurpose __pad
v3: Swap enum values of _NORMAL _HIGH for backwards compatibility
v4: Validate usermode priority and store it
v5: Move priority validation into amdgpu_ctx_ioctl(), headline reword
v6: add UAPI note regarding priorities requiring CAP_SYS_ADMIN
v7: remove ctx->priority
v8: added AMDGPU_CTX_PRIORITY_LOW, s/CAP_SYS_ADMIN/CAP_SYS_NICE
v9: change the priority parameter to __s32
v10: split priorities into _SW and _HW
v11: Allow DRM_MASTER without CAP_SYS_NICE
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 61 +++++++++++++++++++++++++-- drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 5 ++- include/uapi/drm/amdgpu_drm.h | 10 ++++- 3 files changed, 70 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +57 -4
@@ -23,13 +23,40 @@*/ #include <drm/drmP.h> +#include <drm/drm_auth.h> #include "amdgpu.h" -static int amdgpu_ctx_init (struct amdgpu_device *adev,struct amdgpu_ctx *ctx) +static int amdgpu_ctx_priority_permit (struct drm_file *filp, +enum amd_sched_priority priority) +{ +/* NORMAL and below are accessible by everyone */ +if (priority <=AMD_SCHED_PRIORITY_NORMAL ) +return 0 ; + +if (capable (CAP_SYS_NICE )) +return 0 ; + +if (drm_is_current_master (filp)) +return 0 ; + +return -EACCES ; +} + +static int amdgpu_ctx_init (struct amdgpu_device *adev, +enum amd_sched_priority priority, +struct drm_file *filp, +struct amdgpu_ctx *ctx) {unsigned i, j;int r; +if (priority <0 || priority >=AMD_SCHED_PRIORITY_MAX ) +return -EINVAL ; + + r =amdgpu_ctx_priority_permit (filp, priority); +if (r) +return r; +memset (ctx,0 ,sizeof (*ctx)); ctx->adev = adev;kref_init (&ctx->refcount);
@@ -51,7 +78,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)struct amdgpu_ring *ring = adev->rings[i];struct amd_sched_rq *rq; - rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL ]; + rq = &ring->sched.sched_rq[priority];if (ring == &adev->gfx.kiq.ring)continue ;
@@ -100,6 +127,8 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx)static int amdgpu_ctx_alloc (struct amdgpu_device *adev,struct amdgpu_fpriv *fpriv, +struct drm_file *filp, +enum amd_sched_priority priority,uint32_t *id) {struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr;
@@ -117,8 +146,9 @@ static int amdgpu_ctx_alloc(struct amdgpu_device *adev,kfree (ctx);return r; } + *id = (uint32_t )r; - r =amdgpu_ctx_init (adev, ctx); + r =amdgpu_ctx_init (adev, priority, filp, ctx);if (r) {idr_remove (&mgr->ctx_handles, *id); *id =0 ;
@@ -188,11 +218,30 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,return 0 ; } +static enum amd_sched_priority amdgpu_to_sched_priority (int amdgpu_priority) +{ +switch (amdgpu_priority) { +case AMDGPU_CTX_PRIORITY_HIGH_HW : +return AMD_SCHED_PRIORITY_HIGH_HW ; +case AMDGPU_CTX_PRIORITY_HIGH_SW : +return AMD_SCHED_PRIORITY_HIGH_SW ; +case AMDGPU_CTX_PRIORITY_NORMAL : +return AMD_SCHED_PRIORITY_NORMAL ; +case AMDGPU_CTX_PRIORITY_LOW_SW : +case AMDGPU_CTX_PRIORITY_LOW_HW : +return AMD_SCHED_PRIORITY_LOW ; +default : +WARN (1 ,"Invalid context priority %d\n" , amdgpu_priority); +return AMD_SCHED_PRIORITY_NORMAL ; + } +} +int amdgpu_ctx_ioctl (struct drm_device *dev,void *data,struct drm_file *filp) {int r;uint32_t id; +enum amd_sched_priority priority;union drm_amdgpu_ctx *args = data;struct amdgpu_device *adev = dev->dev_private;
@@ -200,10 +249,14 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, r =0 ; id = args->in.ctx_id; + priority =amdgpu_to_sched_priority (args->in.priority); + +if (priority >=AMD_SCHED_PRIORITY_MAX ) +return -EINVAL ;switch (args->in.op) {case AMDGPU_CTX_OP_ALLOC_CTX : - r =amdgpu_ctx_alloc (adev, fpriv, &id); + r =amdgpu_ctx_alloc (adev, fpriv, filp, priority, &id); args->out.alloc.ctx_id = id;break ;case AMDGPU_CTX_OP_FREE_CTX :
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +4 -1
@@ -115,7 +115,10 @@ struct amd_sched_backend_ops {enum amd_sched_priority {AMD_SCHED_PRIORITY_MIN , -AMD_SCHED_PRIORITY_NORMAL =AMD_SCHED_PRIORITY_MIN , +AMD_SCHED_PRIORITY_LOW =AMD_SCHED_PRIORITY_MIN , +AMD_SCHED_PRIORITY_NORMAL , +AMD_SCHED_PRIORITY_HIGH_SW , +AMD_SCHED_PRIORITY_HIGH_HW ,AMD_SCHED_PRIORITY_KERNEL ,AMD_SCHED_PRIORITY_MAX };
include/uapi/drm/amdgpu_drm.h +9 -1
@@ -162,13 +162,21 @@ union drm_amdgpu_bo_list {/* unknown cause */ #define AMDGPU_CTX_UNKNOWN_RESET 3 +/* Context priority level */ +#define AMDGPU_CTX_PRIORITY_LOW_HW -1023 +#define AMDGPU_CTX_PRIORITY_LOW_SW -512 +#define AMDGPU_CTX_PRIORITY_NORMAL 0 +/* Selecting a priority above NORMAL requires CAP_SYS_NICE or DRM_MASTER */ +#define AMDGPU_CTX_PRIORITY_HIGH_SW 512 +#define AMDGPU_CTX_PRIORITY_HIGH_HW 1023 +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; +__s32 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
PATCH 2/8 drm/amdgpu: add framework for HW specific priority settings v9
In reply to a message not in the archiveAdd an initial framework for changing the HW priorities of rings. The framework allows requesting priority changes for the lifetime of an amdgpu_job. After the job completes the priority will decay to the next lowest priority for which a request is still valid.
A new ring function set_priority() can now be populated to take care of the HW specific programming sequence for priority changes.
v2: set priority before emitting IB, and take a ref on amdgpu_job
v3: use AMD_SCHED_PRIORITY_* instead of AMDGPU_CTX_PRIORITY_*
v4: plug amdgpu_ring_restore_priority_cb into amdgpu_job_free_cb
v5: use atomic for tracking job priorities instead of last_job
v6: rename amdgpu_ring_priority_[get/put]() and align parameters
v7: replace spinlocks with mutexes for KIQ compatibility
v8: raise ring priority during cs_ioctl, instead of job_run
v9: priority_get() before push_job()
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 76 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 15 ++++++ drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 7 +++ 5 files changed, 103 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -1102,6 +1102,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, job->uf_sequence = cs->out.handle;amdgpu_job_free_resources (job);amdgpu_cs_parser_fini (p,0 , true); +amdgpu_ring_priority_get (job->ring, +amd_sched_get_job_priority (&job->base));trace_amdgpu_cs_ioctl (job);amd_sched_entity_push_job (&job->base);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -0
@@ -101,6 +101,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job *s_job) { struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); +amdgpu_ring_priority_put (job->ring,amd_sched_get_job_priority (s_job));dma_fence_put (job->fence);amdgpu_sync_free (&job->sync);amdgpu_sync_free (&job->dep_sync);
@@ -137,6 +138,8 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, job->fence_ctx = entity->fence_context; *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job); +amdgpu_ring_priority_get (job->ring, +amd_sched_get_job_priority (&job->base));amd_sched_entity_push_job (&job->base);return 0 ;
@@ -201,6 +204,7 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job)/* if gpu reset, hw fence will be replaced here */ dma_fence_put (job->fence); job->fence =dma_fence_get (fence); +amdgpu_job_free_resources (job);return fence; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +75 -1
97 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +15 -0
@@ -24,6 +24,7 @@#ifndef __AMDGPU_RING_H__#define __AMDGPU_RING_H__ +#include <drm/amdgpu_drm.h> #include "gpu_scheduler.h" /* max number of rings */
@@ -56,6 +57,7 @@ struct amdgpu_device;struct amdgpu_ring ;struct amdgpu_ib ;struct amdgpu_cs_parser ; +struct amdgpu_job ;/* * Fences.
@@ -147,6 +149,9 @@ struct amdgpu_ring_funcs {void (*emit_rreg)(struct amdgpu_ring *ring,uint32_t reg);void (*emit_wreg)(struct amdgpu_ring *ring,uint32_t reg,uint32_t val);void (*emit_tmz)(struct amdgpu_ring *ring,bool start); +/* priority functions */ +void (*set_priority) (struct amdgpu_ring *ring, +enum amd_sched_priority priority); };struct amdgpu_ring {
@@ -187,6 +192,12 @@ struct amdgpu_ring {volatile u32 *cond_exe_cpu_addr;unsigned vm_inv_eng;bool has_compute_vm_bug; + +atomic_t num_jobs[AMD_SCHED_PRIORITY_MAX ]; +struct mutex priority_mutex; +/* protected by priority_mutex */ +int priority; +#if defined(CONFIG_DEBUG_FS )struct dentry *ent;#endif
@@ -197,6 +208,10 @@ void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count);void amdgpu_ring_generic_pad_ib (struct amdgpu_ring *ring,struct amdgpu_ib *ib);void amdgpu_ring_commit (struct amdgpu_ring *ring);void amdgpu_ring_undo (struct amdgpu_ring *ring); +void amdgpu_ring_priority_get (struct amdgpu_ring *ring, +enum amd_sched_priority priority); +void amdgpu_ring_priority_put (struct amdgpu_ring *ring, +enum amd_sched_priority priority);int amdgpu_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring,unsigned ring_size,struct amdgpu_irq_src *irq_src,unsigned irq_type);
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +7 -0
@@ -170,4 +170,11 @@ void amd_sched_job_recovery(struct amd_gpu_scheduler *sched);bool amd_sched_dependency_optimized (struct dma_fence * fence,struct amd_sched_entity *entity);void amd_sched_job_kickout (struct amd_sched_job *s_job); + +static inline enum amd_sched_priority +amd_sched_get_job_priority (struct amd_sched_job *job) +{ +return (job->s_entity->rq - job->sched->sched_rq); +} +#endif
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): 20170626203658.3951-3-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Christian König
Reviewed-byRe: [PATCH 2/8] drm/amdgpu: add framework for HW specific priority settings v9
Am 26.06.2017 um 22:36 schrieb Andres Rodriguez:
Quoted 17 lines
Add an initial framework for changing the HW priorities of rings. The framework allows requesting priority changes for the lifetime of an
amdgpu_job. After the job completes the priority will decay to the next lowest priority for which a request is still valid.A new ring function
set_priority()can now be populated to take care of the HW specific programming sequence for priority changes.v2: set priority before emitting IB, and take a ref on
amdgpu_job
v3: use AMD_SCHED_PRIORITY_* instead of AMDGPU_CTX_PRIORITY_*
v4: plugamdgpu_ring_restore_priority_cbintoamdgpu_job_free_cb
v5: use atomic for tracking job priorities instead oflast_job
v6: rename amdgpu_ring_priority_[get/put]() and align parameters
v7: replace spinlocks with mutexes for KIQ compatibility
v8: raise ring priority duringcs_ioctl, instead ofjob_run
v9:priority_get()beforepush_job()
Quoted 1 line
Signed-off-by Andres Rodriguez <[email protected]>
Quoted 214 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 76 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 15 ++++++ drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 7 +++ 5 files changed, 103 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-0@@ -1102,6 +1102,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, job->uf_sequence = cs->out.handle;amdgpu_job_free_resources (job);amdgpu_cs_parser_fini (p,0 , true); +amdgpu_ring_priority_get (job->ring, +amd_sched_get_job_priority (&job->base));trace_amdgpu_cs_ioctl (job);amd_sched_entity_push_job (&job->base);drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4
-0@@ -101,6 +101,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job *s_job) { struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); +amdgpu_ring_priority_put (job->ring,amd_sched_get_job_priority (s_job));dma_fence_put (job->fence);amdgpu_sync_free (&job->sync);amdgpu_sync_free (&job->dep_sync);@@ -137,6 +138,8 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, job->fence_ctx = entity->fence_context; *f =dma_fence_get (&job->base.s_fence->finished);amdgpu_job_free_resources (job); +amdgpu_ring_priority_get (job->ring, +amd_sched_get_job_priority (&job->base));amd_sched_entity_push_job (&job->base);return 0 ;@@ -201,6 +204,7 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job)/* if gpu reset, hw fence will be replaced here */ dma_fence_put (job->fence); job->fence =dma_fence_get (fence); +amdgpu_job_free_resources (job);return fence; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +75
-1@@ -155,6 +155,75 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring) }/** +* amdgpu_ring_priority_put - restore a ring's priority +* +* @ring: amdgpu_ring structure holding the information +* @priority: target priority +* +* Release a request for executing at @priority +*/ +void amdgpu_ring_priority_put (struct amdgpu_ring *ring, +enum amd_sched_priority priority) +{ +int i; + +if (!ring->funcs->set_priority) +return ; + +if (atomic_dec_return (&ring->num_jobs[priority]) >0 ) +return ; + +/* no need to restore if the job is already at the lowest priority */ +if (priority ==AMD_SCHED_PRIORITY_NORMAL ) +return ; + +mutex_lock (&ring->priority_mutex); +/* something higher prio is executing, no need to decay */ +if (ring->priority > priority) + goto out_unlock; + +/* decay priority to the next level with a job available */ +for (i = priority; i >=AMD_SCHED_PRIORITY_MIN ; i--) { +if (i ==AMD_SCHED_PRIORITY_NORMAL + ||atomic_read (&ring->num_jobs[i])) { + ring->priority = i; + ring->funcs->set_priority (ring, i); +break ; + } + } + +out_unlock: +mutex_unlock (&ring->priority_mutex); +} + +/** +* amdgpu_ring_priority_get - change the ring's priority +* +* @ring: amdgpu_ring structure holding the information +* @priority: target priority +* +* Request a ring's priority to be raised to @priority (refcounted). +*/ +void amdgpu_ring_priority_get (struct amdgpu_ring *ring, +enum amd_sched_priority priority) +{ +if (!ring->funcs->set_priority) +return ; + +atomic_inc (&ring->num_jobs[priority]); + +mutex_lock (&ring->priority_mutex); +if (priority <= ring->priority) + goto out_unlock; + + ring->priority = priority; + ring->funcs->set_priority (ring, priority); + +out_unlock: +mutex_unlock (&ring->priority_mutex); +} + +/** * amdgpu_ring_init - init driver ring struct. * * @adev: amdgpu_device pointer @@ -169,7 +238,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned max_dw, struct amdgpu_irq_src *irq_src, unsigned irq_type) { - int r; + int r, i;if (ring->adev ==NULL ) {if (adev->num_rings >=AMDGPU_MAX_RINGS )@@ -255,9 +324,14 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, } ring->max_dw = max_dw; + ring->priority =AMD_SCHED_PRIORITY_NORMAL ; +mutex_init (&ring->priority_mutex);INIT_LIST_HEAD (&ring->lru_list);amdgpu_ring_lru_touch (adev, ring); +for (i =0 ; i <AMD_SCHED_PRIORITY_MAX ; ++i) +atomic_set (&ring->num_jobs[i],0 ); +if (amdgpu_debugfs_ring_init (adev, ring)) {DRM_ERROR ("Failed to register debugfs file for rings !\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +15
-0@@ -24,6 +24,7 @@#ifndef __AMDGPU_RING_H__#define __AMDGPU_RING_H__ +#include <drm/amdgpu_drm.h> #include "gpu_scheduler.h" /* max number of rings */ @@ -56,6 +57,7 @@ struct amdgpu_device;struct amdgpu_ring ;struct amdgpu_ib ;struct amdgpu_cs_parser ; +struct amdgpu_job ;/* * Fences. @@ -147,6 +149,9 @@ struct amdgpu_ring_funcs {void (*emit_rreg)(struct amdgpu_ring *ring,uint32_t reg);void (*emit_wreg)(struct amdgpu_ring *ring,uint32_t reg,uint32_t val);void (*emit_tmz)(struct amdgpu_ring *ring,bool start); +/* priority functions */ +void (*set_priority) (struct amdgpu_ring *ring, +enum amd_sched_priority priority); };struct amdgpu_ring {@@ -187,6 +192,12 @@ struct amdgpu_ring {volatile u32 *cond_exe_cpu_addr;unsigned vm_inv_eng;bool has_compute_vm_bug; + +atomic_t num_jobs[AMD_SCHED_PRIORITY_MAX ]; +struct mutex priority_mutex; +/* protected by priority_mutex */ +int priority; +#if defined(CONFIG_DEBUG_FS )struct dentry *ent;#endif @@ -197,6 +208,10 @@ void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count);void amdgpu_ring_generic_pad_ib (struct amdgpu_ring *ring,struct amdgpu_ib *ib);void amdgpu_ring_commit (struct amdgpu_ring *ring);void amdgpu_ring_undo (struct amdgpu_ring *ring); +void amdgpu_ring_priority_get (struct amdgpu_ring *ring, +enum amd_sched_priority priority); +void amdgpu_ring_priority_put (struct amdgpu_ring *ring, +enum amd_sched_priority priority);int amdgpu_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring,unsigned ring_size,struct amdgpu_irq_src *irq_src,unsigned irq_type);drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +0
-0@@ -170,4 +170,11 @@ void amd_sched_job_recovery(struct amd_gpu_scheduler *sched); bool amd_sched_dependency_optimized(struct dma_fence* fence,
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h void amd_sched_job_recovery(struct amd_gpu_scheduler *sched); · line 180
Quoted 10 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +7
-0struct amd_sched_entity *entity);void amd_sched_job_kickout (struct amd_sched_job *s_job); + +static inline enum amd_sched_priority +amd_sched_get_job_priority (struct amd_sched_job *job) +{ +return (job->s_entity->rq - job->sched->sched_rq); +} +#endif
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/8 drm/amdgpu: implement ring set_priority for gfx_v8 compute v9
In reply to a message not in the archiveProgramming CP_HQD_QUEUE_PRIORITY enables a queue to take priority over other queues on the same pipe. Multiple queues on a pipe are timesliced so this gives us full precedence over other queues.
Programming CP_HQD_PIPE_PRIORITY changes the SPI_ARB_PRIORITY of the wave as follows:
0x2: CS_H
0x1: CS_M
0x0: CS_LThe SPI block will then dispatch work according to the policy set by SPI_ARB_PRIORITY. In the current policy CS_H is higher priority than gfx.
In order to prevent getting stuck in loops of resources bouncing between GFX and high priority compute and introducing further latency, we statically reserve a portion of the pipe.
v2: fix srbm_select to ring->queue and use ring->funcs->type
v3: use AMD_SCHED_PRIORITY_* instead of AMDGPU_CTX_PRIORITY_*
v4: switch int to enum amd_sched_priority
v5: corresponding changes for srbm_lock
v6: change CU reservation to PIPE_PERCENT allocation
v7: use kiq instead of MMIO
v8: back to MMIO, and make the implementation sleep safe.
v9: corresponding changes for splitting HIGH into _HW/_SW
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 + drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 105 +++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -1114,6 +1114,10 @@ struct amdgpu_gfx {bool in_suspend;/* NGG */ struct amdgpu_ngg ngg; + +/* pipe reservation */ +struct mutex pipe_reserve_mutex; +DECLARE_BITMAP (pipe_reserve_bitmap,AMDGPU_MAX_COMPUTE_QUEUES ); }; int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -2019,6 +2019,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->vm_manager.vm_pte_num_rings =0 ; adev->gart.gart_funcs =NULL ; adev->fence_context =dma_fence_context_alloc (AMDGPU_MAX_RINGS ); +bitmap_zero (adev->gfx.pipe_reserve_bitmap,AMDGPU_MAX_COMPUTE_QUEUES ); adev->smc_rreg = &amdgpu_invalid_rreg; adev->smc_wreg = &amdgpu_invalid_wreg;
@@ -2047,6 +2048,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->pm.mutex);mutex_init (&adev->gfx.gpu_clock_mutex);mutex_init (&adev->srbm_mutex); +mutex_init (&adev->gfx.pipe_reserve_mutex);mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +105 -0
117 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
PATCH 4/8 drm/amdgpu: make amdgpu_to_sched_priority detect invalid parameters
In reply to a message not in the archiveReturning invalid priorities as _NORMAL is a backwards compatibility quirk of amdgpu_ctx_ioctl(). Move this detail one layer up where it belongs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 +++++--- drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +5 -3
@@ -232,7 +232,7 @@ static enum amd_sched_priority amdgpu_to_sched_priority(int amdgpu_priority)return AMD_SCHED_PRIORITY_LOW ;default :WARN (1 ,"Invalid context priority %d\n" , amdgpu_priority); -return AMD_SCHED_PRIORITY_NORMAL ; +return AMD_SCHED_PRIORITY_INVALID ; } }
@@ -251,8 +251,10 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, id = args->in.ctx_id; priority =amdgpu_to_sched_priority (args->in.priority); -if (priority >=AMD_SCHED_PRIORITY_MAX ) -return -EINVAL ; +/* For backwards compatibility reasons, we need to accept +* ioctls with garbage in the priority field */ +if (priority ==AMD_SCHED_PRIORITY_INVALID ) + priority =AMD_SCHED_PRIORITY_NORMAL ;switch (args->in.op) {case AMDGPU_CTX_OP_ALLOC_CTX :
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2 -1
@@ -120,7 +120,8 @@ enum amd_sched_priority {AMD_SCHED_PRIORITY_HIGH_SW ,AMD_SCHED_PRIORITY_HIGH_HW ,AMD_SCHED_PRIORITY_KERNEL , - AMD_SCHED_PRIORITY_MAX +AMD_SCHED_PRIORITY_MAX , + AMD_SCHED_PRIORITY_INVALID = -1 };/**
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/8 drm/amd/sched: allow clients to edit an entity's rq v2
In reply to a message not in the archiveThis is useful for changing an entity's priority at runtime.
v2: don't modify the order of amd_sched_entity members
--- drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 26 +++++++++++++++++++++++--- drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 3 +++ 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +23 -3
@@ -133,6 +133,7 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched, entity->rq = rq; entity->sched = sched; +spin_lock_init (&entity->rq_lock);spin_lock_init (&entity->queue_lock); r =kfifo_alloc (&entity->job_queue, jobs *sizeof (void *),GFP_KERNEL );if (r)
@@ -204,8 +205,6 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity)void amd_sched_entity_fini (struct amd_gpu_scheduler *sched,struct amd_sched_entity *entity) { -struct amd_sched_rq *rq = entity->rq; -if (!amd_sched_entity_is_initialized (sched, entity))return ;
@@ -215,7 +214,8 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched,*/ wait_event (sched->job_scheduled,amd_sched_entity_is_idle (entity)); -amd_sched_rq_remove_entity (rq, entity); +amd_sched_entity_set_rq (entity,NULL ); +kfifo_free (&entity->job_queue); }
@@ -236,6 +236,24 @@ static void amd_sched_entity_clear_dep(struct dma_fence *f, struct dma_fence_cbdma_fence_put (f); } +void amd_sched_entity_set_rq (struct amd_sched_entity *entity, +struct amd_sched_rq *rq) +{ +if (entity->rq == rq) +return ; + +spin_lock (&entity->rq_lock); + +if (entity->rq) +amd_sched_rq_remove_entity (entity->rq, entity); + + entity->rq = rq; +if (rq) +amd_sched_rq_add_entity (rq, entity); + +spin_unlock (&entity->rq_lock); +} +bool amd_sched_dependency_optimized (struct dma_fence * fence,struct amd_sched_entity *entity) {
@@ -333,7 +351,9 @@ static bool amd_sched_entity_in(struct amd_sched_job *sched_job)/* first job wakes up scheduler */ if (first) {/* Add the entity to the run queue */ +spin_lock (&entity->rq_lock);amd_sched_rq_add_entity (entity->rq, entity); +spin_unlock (&entity->rq_lock);amd_sched_wakeup (sched); }return added;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +3 -0
@@ -39,6 +39,7 @@ struct amd_sched_rq;struct amd_sched_entity {struct list_head list;struct amd_sched_rq *rq; +spinlock_t rq_lock;struct amd_gpu_scheduler *sched;spinlock_t queue_lock;
@@ -154,6 +155,8 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,void amd_sched_entity_fini (struct amd_gpu_scheduler *sched,struct amd_sched_entity *entity);void amd_sched_entity_push_job (struct amd_sched_job *sched_job); +void amd_sched_entity_set_rq (struct amd_sched_entity *entity, +struct amd_sched_rq *rq);int amd_sched_fence_slab_init (void );void amd_sched_fence_slab_fini (void );
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): 20170626203658.3951-6-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Christian König
Reviewed-byRe: [PATCH 5/8] drm/amd/sched: allow clients to edit an entity's rq v2
Am 26.06.2017 um 22:36 schrieb Andres Rodriguez:
Quoted 5 lines
This is useful for changing an entity's priority at runtime.
v2: don't modify the order of
amd_sched_entitymembersSigned-off-by Andres Rodriguez <[email protected]>
Quoted 84 lines
--- drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 26 +++++++++++++++++++++++--- drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 3 +++ 2 files changed, 26 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +23
-3@@ -133,6 +133,7 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched, entity->rq = rq; entity->sched = sched; +spin_lock_init (&entity->rq_lock);spin_lock_init (&entity->queue_lock); r =kfifo_alloc (&entity->job_queue, jobs *sizeof (void *),GFP_KERNEL );if (r)@@ -204,8 +205,6 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity)void amd_sched_entity_fini (struct amd_gpu_scheduler *sched,struct amd_sched_entity *entity) { -struct amd_sched_rq *rq = entity->rq; -if (!amd_sched_entity_is_initialized (sched, entity))return ;@@ -215,7 +214,8 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched,*/ wait_event (sched->job_scheduled,amd_sched_entity_is_idle (entity)); -amd_sched_rq_remove_entity (rq, entity); +amd_sched_entity_set_rq (entity,NULL ); +kfifo_free (&entity->job_queue); }@@ -236,6 +236,24 @@ static void amd_sched_entity_clear_dep(struct dma_fence *f, struct dma_fence_cbdma_fence_put (f); } +void amd_sched_entity_set_rq (struct amd_sched_entity *entity, +struct amd_sched_rq *rq) +{ +if (entity->rq == rq) +return ; + +spin_lock (&entity->rq_lock); + +if (entity->rq) +amd_sched_rq_remove_entity (entity->rq, entity); + + entity->rq = rq; +if (rq) +amd_sched_rq_add_entity (rq, entity); + +spin_unlock (&entity->rq_lock); +} +bool amd_sched_dependency_optimized (struct dma_fence * fence,struct amd_sched_entity *entity) {@@ -333,7 +351,9 @@ static bool amd_sched_entity_in(struct amd_sched_job *sched_job)/* first job wakes up scheduler */ if (first) {/* Add the entity to the run queue */ +spin_lock (&entity->rq_lock);amd_sched_rq_add_entity (entity->rq, entity); +spin_unlock (&entity->rq_lock);amd_sched_wakeup (sched); }return added;drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +1
-0@@ -39,6 +39,7 @@ struct amd_sched_rq;struct amd_sched_entity {struct list_head list;struct amd_sched_rq *rq; +spinlock_t rq_lock;struct amd_gpu_scheduler *sched;spinlock_t queue_lock;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h int amd_sched_entity_init(struct amd_gpu_scheduler *sched, · line 162
Quoted 8 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2
-0@@ -154,6 +155,8 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,void amd_sched_entity_fini (struct amd_gpu_scheduler *sched,struct amd_sched_entity *entity);void amd_sched_entity_push_job (struct amd_sched_job *sched_job); +void amd_sched_entity_set_rq (struct amd_sched_entity *entity, +struct amd_sched_rq *rq);int amd_sched_fence_slab_init (void );void amd_sched_fence_slab_fini (void );
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/8 drm/amdgpu: introduce AMDGPU_CTX_PRIORITY_UNSET
In reply to a message not in the archiveUse _INVALID to identify bad parameters and _UNSET to represent the lack of interest in a specific value.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 ++ drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 3 ++- include/uapi/drm/amdgpu_drm.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2 -0
@@ -230,6 +230,8 @@ static enum amd_sched_priority amdgpu_to_sched_priority(int amdgpu_priority)case AMDGPU_CTX_PRIORITY_LOW_SW :case AMDGPU_CTX_PRIORITY_LOW_HW :return AMD_SCHED_PRIORITY_LOW ; +case AMDGPU_CTX_PRIORITY_UNSET : +return AMD_SCHED_PRIORITY_UNSET ;default :WARN (1 ,"Invalid context priority %d\n" , amdgpu_priority);return AMD_SCHED_PRIORITY_INVALID ;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2 -1
@@ -122,7 +122,8 @@ enum amd_sched_priority {AMD_SCHED_PRIORITY_HIGH_HW ,AMD_SCHED_PRIORITY_KERNEL ,AMD_SCHED_PRIORITY_MAX , - AMD_SCHED_PRIORITY_INVALID = -1 +AMD_SCHED_PRIORITY_INVALID =-1 , + AMD_SCHED_PRIORITY_UNSET = -2 };/**
include/uapi/drm/amdgpu_drm.h +1 -0
@@ -163,6 +163,7 @@ union drm_amdgpu_bo_list {#define AMDGPU_CTX_UNKNOWN_RESET 3/* Context priority level */ +#define AMDGPU_CTX_PRIORITY_UNSET -2048#define AMDGPU_CTX_PRIORITY_LOW_HW -1023#define AMDGPU_CTX_PRIORITY_LOW_SW -512#define AMDGPU_CTX_PRIORITY_NORMAL 0
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/8 drm/amdgpu: add plumbing for ctx priority changes v2
In reply to a message not in the archiveIntroduce amdgpu_ctx_priority_override(). A mechanism to override a context's priority.
An override can be terminated by setting the override to AMD_SCHED_PRIORITY_UNSET.
v2: change refcounted interface for a direct set
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -1
@@ -825,7 +825,9 @@ struct amdgpu_ctx {spinlock_t ring_lock;struct dma_fence **fences;struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS ]; -bool preamble_presented; +bool preamble_presented; +enum amd_sched_priority init_priority; +enum amd_sched_priority override_priority; };struct amdgpu_ctx_mgr {
@@ -842,6 +844,8 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, struct dma_fence *fence);struct dma_fence *amdgpu_ctx_get_fence (struct amdgpu_ctx *ctx,struct amdgpu_ring *ring,uint64_t seq); +void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx, +enum amd_sched_priority priority);int amdgpu_ctx_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +29 -0
@@ -72,6 +72,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, } ctx->reset_counter =atomic_read (&adev->gpu_reset_counter); + ctx->init_priority = priority; + ctx->override_priority =AMD_SCHED_PRIORITY_UNSET ;/* create context entity for each ring */ for (i =0 ; i < adev->num_rings; i++) {
@@ -360,6 +362,33 @@ struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,return fence; } +void amdgpu_ctx_priority_override (struct amdgpu_ctx *ctx, +enum amd_sched_priority priority) +{ +int i; +struct amdgpu_device *adev = ctx->adev; +struct amd_sched_rq *rq; +struct amd_sched_entity *entity; +struct amdgpu_ring *ring; +enum amd_sched_priority ctx_prio; + + ctx->override_priority = priority; + + ctx_prio = (ctx->override_priority ==AMD_SCHED_PRIORITY_UNSET ) ? + ctx->init_priority : ctx->override_priority; + +for (i =0 ; i < adev->num_rings; i++) { + ring = adev->rings[i]; + entity = &ctx->rings[i].entity; + rq = &ring->sched.sched_rq[ctx_prio]; + +if (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) +continue ; + +amd_sched_entity_set_rq (entity, rq); + } +} +void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr) {mutex_init (&mgr->lock);
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/8 drm/amdgpu: add interface for editing a foreign process's priority v3
In reply to a message not in the archiveThe AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE ioctls are used to set the priority of a different process in the current system.
When a request is dropped, the process's contexts will be restored to the priority specified at context creation time.
A request can be dropped by setting the override priority to AMDGPU_CTX_PRIORITY_UNSET.
An fd is used to identify the remote process. This is simpler than passing a pid number, which is vulnerable to re-use, etc.
This functionality is limited to DRM_MASTER since abuse of this interface can have a negative impact on the system's performance.
v2: removed unused output structure
v3: change refcounted interface for a regular set operation
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 21 +----- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 109 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h | 34 ++++++++++ include/uapi/drm/amdgpu_drm.h | 17 +++++ 6 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -25,7 +25,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ - amdgpu_queue_mgr.o + amdgpu_queue_mgr.o amdgpu_sched.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -20
@@ -25,6 +25,7 @@#include <drm/drmP.h> #include <drm/drm_auth.h> #include "amdgpu.h" +#include "amdgpu_sched.h" static int amdgpu_ctx_priority_permit (struct drm_file *filp,enum amd_sched_priority priority)
@@ -220,26 +221,6 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,return 0 ; } -static enum amd_sched_priority amdgpu_to_sched_priority (int amdgpu_priority) -{ -switch (amdgpu_priority) { -case AMDGPU_CTX_PRIORITY_HIGH_HW : -return AMD_SCHED_PRIORITY_HIGH_HW ; -case AMDGPU_CTX_PRIORITY_HIGH_SW : -return AMD_SCHED_PRIORITY_HIGH_SW ; -case AMDGPU_CTX_PRIORITY_NORMAL : -return AMD_SCHED_PRIORITY_NORMAL ; -case AMDGPU_CTX_PRIORITY_LOW_SW : -case AMDGPU_CTX_PRIORITY_LOW_HW : -return AMD_SCHED_PRIORITY_LOW ; -case AMDGPU_CTX_PRIORITY_UNSET : -return AMD_SCHED_PRIORITY_UNSET ; -default : -WARN (1 ,"Invalid context priority %d\n" , amdgpu_priority); -return AMD_SCHED_PRIORITY_INVALID ; - } -} -int amdgpu_ctx_ioctl (struct drm_device *dev,void *data,struct drm_file *filp) {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
@@ -28,6 +28,7 @@#include <drm/drmP.h> #include "amdgpu.h" #include <drm/amdgpu_drm.h> +#include "amdgpu_sched.h" #include "amdgpu_uvd.h" #include "amdgpu_vce.h"
@@ -1017,6 +1018,7 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {DRM_IOCTL_DEF_DRV (AMDGPU_GEM_CREATE , amdgpu_gem_create_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_CTX , amdgpu_ctx_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_VM , amdgpu_vm_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (AMDGPU_SCHED , amdgpu_sched_ioctl,DRM_MASTER ),DRM_IOCTL_DEF_DRV (AMDGPU_BO_LIST , amdgpu_bo_list_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),/* KMS */ DRM_IOCTL_DEF_DRV(AMDGPU_GEM_MMAP, amdgpu_gem_mmap_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c new file +109 -0
109 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright 2017 Valve Corporation +* +* 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. +* +* Authors: Andres Rodriguez <[email protected]> +*/ + +#ifndef __AMDGPU_SCHED_H__ +#define __AMDGPU_SCHED_H__ + +#include <drm/drmP.h> + +enum amd_sched_priority amdgpu_to_sched_priority (int amdgpu_priority); +int amdgpu_sched_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp); + +#endif // __AMDGPU_SCHED_H__
include/uapi/drm/amdgpu_drm.h +17 -0
@@ -52,6 +52,7 @@ extern "C" {#define DRM_AMDGPU_GEM_USERPTR 0x11#define DRM_AMDGPU_WAIT_FENCES 0x12#define DRM_AMDGPU_VM 0x13 +#define DRM_AMDGPU_SCHED 0x14#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -67,6 +68,7 @@ extern "C" {#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm) +#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -221,6 +223,21 @@ union drm_amdgpu_vm {struct drm_amdgpu_vm_out out; }; +/* sched ioctl */ +#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1 + +struct drm_amdgpu_sched_in { +/* AMDGPU_SCHED_OP_* */ +__u32 op; +__u32 fd; +__s32 priority; +__u32 flags; +}; + +union drm_amdgpu_sched { +struct drm_amdgpu_sched_in in; +}; +/* * This is not a reliable API and you should expect it to fail for any * number of reasons and have fallback path that do not use userptr to
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx