Preemption support for A6xx targets
Subsystems (4)
cover Preemption support for A6xx targets
This is a revised preemption support patchset follows Jordan's recent "drm/msm: Add A6XX device support" patch series. Preemption allows the GPU to switch to a higher priority ringbuffer when one is ready, thereby improving user experience. A6xx hardware supports various preemption levels each with different granularities and different switch-out-switch-in times.
This series starts off by adding basic preemption support for A6xx targets, leading up to the tip of the stack which enables L1 level preemption. This is a more fine grained version and faster than the default level.
Sharat Masetty (6):
drm/msm: Add submitqueue setup and close drm/msm: Add new PM4 type7 opcodes drm/msm/A6xx: Implement preemption for A6XX targets drm/msm/A6xx: Enable preemption for A6xx targets drm/msm/Adreno: Refactor some preemption code drm/msm/A6xx: Enable L1 preemption level
drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 26 -- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 55 ++--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 44 ++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 148 ++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 110 +++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 366 ++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 54 ++++ drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h | 2 + drivers/gpu/drm/msm/msm_gpu.h | 7 + drivers/gpu/drm/msm/msm_submitqueue.c | 15 +- 11 files changed, 757 insertions(+), 71 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a6xx_preempt.c
--
1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/6 drm/msm: Add submitqueue setup and close
This patch adds a bit of infrastructure to give the different Adreno targets the flexibility to setup the submitqueues per their needs.
--- drivers/gpu/drm/msm/msm_gpu.h | 7 +++++++ drivers/gpu/drm/msm/msm_submitqueue.c | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_gpu.h +7 -0
@@ -69,6 +69,10 @@ struct msm_gpu_funcs {int (*debugfs_init)(struct msm_gpu *gpu,struct drm_minor *minor);#endif int (*gpu_busy)(struct msm_gpu *gpu,uint64_t *value); +int (*submitqueue_setup)(struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue); +void (*submitqueue_close)(struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue); };struct msm_gpu {
@@ -173,6 +177,9 @@ struct msm_gpu_submitqueue {int faults;struct list_head node;struct kref ref; +struct msm_gpu *gpu; +struct drm_gem_object *bo; +uint64_t bo_iova; };static inline void gpu_write (struct msm_gpu *gpu,u32 reg,u32 data)
drivers/gpu/drm/msm/msm_submitqueue.c +13 -2
@@ -18,6 +18,10 @@ void msm_submitqueue_destroy(struct kref *kref) {struct msm_gpu_submitqueue *queue =container_of (kref, struct msm_gpu_submitqueue, ref); +struct msm_gpu *gpu = queue->gpu; + +if (gpu && gpu->funcs->submitqueue_close) + gpu->funcs->submitqueue_close (gpu, queue);kfree (queue); }
@@ -65,6 +69,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, {struct msm_drm_private *priv = drm->dev_private;struct msm_gpu_submitqueue *queue; +struct msm_gpu *gpu = priv->gpu;if (!ctx)return -ENODEV ;
@@ -77,11 +82,14 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,kref_init (&queue->ref); queue->flags = flags; -if (priv->gpu) { -if (prio >= priv->gpu->nr_rings) +if (gpu) { +if (prio >= gpu->nr_rings) { +kfree (queue);return -EINVAL ; + } queue->prio = prio; + queue->gpu = gpu; }write_lock (&ctx->queuelock);
@@ -95,6 +103,9 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,write_unlock (&ctx->queuelock); +if (gpu && gpu->funcs->submitqueue_setup) + gpu->funcs->submitqueue_setup (gpu, queue); +return 0 ; }
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 1520489185-21828-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
PATCH 2/6 drm/msm: Add new PM4 type7 opcodes
This patch adds the following two opcodes:
CP_SET_MARKER opcode is a way to tell CP the current mode of GPU operation(useful if preemption is in use).
CP_SET_PSEUDO_REG opcode will instruct CP to set a bunch of internal CP registers, again useful for the preemption save/restore sequence.
--- drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h +2 -0
@@ -202,6 +202,8 @@ enum adreno_pm4_type3_packets {CP_EXEC_CS =51 ,CP_PERFCOUNTER_ACTION =80 ,CP_SMMU_TABLE_UPDATE =83 , +CP_SET_MARKER =101 , +CP_SET_PSEUDO_REG =86 ,CP_CONTEXT_REG_BUNCH =92 ,CP_YIELD_ENABLE =28 , CP_SKIP_IB2_ENABLE_GLOBAL = 29,
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 5/6 drm/msm/Adreno: Refactor some preemption code
In reply to a message not in the archiveThe preemption state machine related code is same across Adreno targets, so move the common code to a common header file to avoid code duplication.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 26 --------------- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 55 +++++++++---------------------- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 26 --------------- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 55 +++++++++---------------------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 54 ++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 132 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +0 -26
@@ -54,32 +54,6 @@ struct a5xx_gpu {#endif /* -* In order to do lockless preemption we use a simple state machine to progress -* through the process. -* -* PREEMPT_NONE - no preemption in progress. Next state START. -* PREEMPT_START - The trigger is evaulating if preemption is possible. Next -* states: TRIGGERED, NONE -* PREEMPT_ABORT - An intermediate state before moving back to NONE. Next -* state: NONE. -* PREEMPT_TRIGGERED: A preemption has been executed on the hardware. Next -* states: FAULTED, PENDING -* PREEMPT_FAULTED: A preemption timed out (never completed). This will trigger -* recovery. Next state: N/A -* PREEMPT_PENDING: Preemption complete interrupt fired - the callback is -* checking the success of the operation. Next state: FAULTED, NONE. -*/ - -enum preempt_state { -PREEMPT_NONE =0 , -PREEMPT_START , -PREEMPT_ABORT , -PREEMPT_TRIGGERED , -PREEMPT_FAULTED , -PREEMPT_PENDING , -}; - -/* * struct a5xx_preempt_record is a shared buffer between the microcode and the * CPU to store the state for preemption. The record itself is much larger * (64k) but most of that is used by the CP for storage.
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +15 -40
110 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +0 -26
@@ -54,32 +54,6 @@ struct a6xx_gpu { (a6xx_gpu->scratch_iova + (ring_id *sizeof (uint64_t )))/* -* In order to do lockless preemption we use a simple state machine to progress -* through the process. -* -* PREEMPT_NONE - no preemption in progress. Next state START. -* PREEMPT_START - The trigger is evaluating if preemption is possible. Next -* states: TRIGGERED, NONE -* PREEMPT_ABORT - An intermediate state before moving back to NONE. Next -* state: NONE. -* PREEMPT_TRIGGERED: A preemption has been executed on the hardware. Next -* states: FAULTED, PENDING -* PREEMPT_FAULTED: A preemption timed out (never completed). This will trigger -* recovery. Next state: N/A -* PREEMPT_PENDING: Preemption complete interrupt fired - the callback is -* checking the success of the operation. Next state: FAULTED, NONE. - */ - -enum a6xx_preempt_state { -PREEMPT_NONE =0 , -PREEMPT_START , -PREEMPT_ABORT , -PREEMPT_TRIGGERED , -PREEMPT_FAULTED , -PREEMPT_PENDING , -}; - -/* * ID values used by SET_PSEUDO_REG PM4 command. These determine which of the * various internal CP registers to write to. Used in the save/restore * preemption sequence.
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +15 -40
110 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.h +54 -0
58 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 3/6 drm/msm/A6xx: Implement preemption for A6XX targets
In reply to Sharat MasettyThis patch implements preemption feature for A6xx targets, this allows the GPU to switch to a higher priority ringbuffer if one is ready. A6XX hardware as such supports multiple levels of preemption granularities, ranging from coarse grained(ringbuffer level) to a more fine grained such as draw-call level or a bin boundary level preemption. This patch enables the basic preemption level, with more fine grained preemption support to follow.
--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 44 ++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 146 +++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 136 +++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 383 ++++++++++++++++++++++++++++++ 5 files changed, 708 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a6xx_preempt.c
drivers/gpu/drm/msm/Makefile +1 -0
@@ -13,6 +13,7 @@ msm-y := \ adreno/a6xx_gpu.o \ adreno/a6xx_gmu.o \ adreno/a6xx_hfi.o \ + adreno/a6xx_preempt.o \ hdmi/hdmi.o \ hdmi/hdmi_audio.o \ hdmi/hdmi_bridge.o \
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +44 -0
50 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +144 -2
227 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +136 -0
152 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +383 -0
383 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm/msm/A6xx: Enable preemption for A6xx targets
In reply to Sharat MasettyThis patch simply increases the number of available ringbuffers, therefore enabling preemption.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -1
@@ -1040,7 +1040,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->registers = a6xx_registers; adreno_gpu->reg_offsets = a6xx_register_offsets; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 ); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,4 );if (ret) {a6xx_destroy (&(a6xx_gpu->base.base));return ERR_PTR (ret);
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm/msm/A6xx: Enable L1 preemption level
In reply to Sharat MasettyThis patch enables L1 level which is a finer grained preemption at either a draw call or a bin boundary. The worst case switching latency is higher in this case but that is a trade off we make for enabling faster preemption.
--- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +10 -2
@@ -301,9 +301,17 @@ void a6xx_preempt_init(struct msm_gpu *gpu) }/* TODO: make this configurable? */ - a6xx_gpu->preempt_level =0 ; +/* +* Use L1 preemption level which is preemption at either the draw call +* level or the bin boundary level +*/ + a6xx_gpu->preempt_level =1 ; a6xx_gpu->uses_gmem =1 ; - a6xx_gpu->skip_save_restore =0 ; +/* +* Skip CP save and restore when preempting between bins, use +* this only when the preemption level is 1 +*/ + a6xx_gpu->skip_save_restore =1 ; a6xx_gpu->scratch_ptr = msm_gem_kernel_new(gpu->dev, gpu->nr_rings * sizeof(uint64_t), MSM_BO_WC,
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel