Preemption support for A7XX
Subsystems (5)
v2 cover Preemption support for A7XX
This series implements preemption for A7XX targets, which allows the GPU to switch to an higher priority ring when work is pushed to it, reducing latency for high priority submissions.
This series enables L1 preemption with skip_save_restore which requires the following userspace patches to function:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30544
A flag is added to msm_submitqueue_create to only allow submissions from compatible userspace to be preempted, therefore maintaining compatibility.
Some commits from this series are based on a previous series to enable preemption on A6XX targets:
https://lkml.kernel.org/[email protected]
---
Changes in v2:
- Added preept_record_size for X185 in PATCH 3/7
- Added patches to reset perf counters
- Dropped unused defines
- Dropped unused variable (fixes warning)
- Only enable preemption on a750
- Reject MSM_SUBMITQUEUE_ALLOW_PREEMPT for unsupported targets
- Added Akhil's Reviewed-By tags to patches 1/9,2/9,3/9
- Added Neil's Tested-By tags
- Added explanation for UAPI changes in commit message
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Antonino Maniscalco (9):
drm/msm: Fix bv_fence being used as bv_rptr
drm/msm: Add submitqueue setup and close
drm/msm: Add a preempt_record_size field drm/msm/A6xx: Implement preemption for A7XX targets drm/msm/A6xx: Sync relevant adreno_pm4.xml changes drm/msm/A6xx: Use posamble to reset counters on preemption drm/msm/A6xx: Add traces for preemption
drm/msm/A6XX: Add a flag to allow preemption to submitqueue_create drm/msm/A6xx: Enable preemption for A750
drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 4 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 353 +++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 174 ++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 462 +++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 8 +- drivers/gpu/drm/msm/msm_gpu.h | 7 + drivers/gpu/drm/msm/msm_gpu_trace.h | 28 ++ drivers/gpu/drm/msm/msm_ringbuffer.h | 8 + drivers/gpu/drm/msm/msm_submitqueue.c | 13 + .../gpu/drm/msm/registers/adreno/adreno_pm4.xml | 39 +- include/uapi/drm/msm_drm.h | 5 +- 12 files changed, 1062 insertions(+), 40 deletions(-)
---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240815-preemption-a750-t-fcee9a844b39
Best regards,
Signature · 1 line
Antonino Maniscalco <[email protected]>
PATCH v2 1/9 drm/msm: Fix bv_fence being used as bv_rptr
The bv_fence field of rbmemptrs was being used incorrectly as the BV rptr shadow pointer in some places.
Add a bv_rptr field and change the code to use that instead.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -1
@@ -1132,7 +1132,7 @@ static int hw_init(struct msm_gpu *gpu)/* ..which means "always" on A7xx, also for BV shadow */ if (adreno_is_a7xx (adreno_gpu)) {gpu_write64 (gpu,REG_A7XX_CP_BV_RB_RPTR_ADDR , -rbmemptr (gpu->rb[0 ], bv_fence)); +rbmemptr (gpu->rb[0 ], bv_rptr)); }/* Always come up on rb 0 */
drivers/gpu/drm/msm/msm_ringbuffer.h +1 -0
@@ -31,6 +31,7 @@ struct msm_rbmemptrs {volatile uint32_t rptr;volatile uint32_t fence;/* Introduced on A7xx */ +volatile uint32_t bv_rptr;volatile uint32_t bv_fence;volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT ];
Signature · 1 line
2.46.0
PATCH v2 2/9 drm/msm: Add submitqueue setup and close
In reply to Antonino ManiscalcoThis 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 | 10 ++++++++++ 2 files changed, 17 insertions(+)
drivers/gpu/drm/msm/msm_gpu.h +7 -0
@@ -92,6 +92,10 @@ struct msm_gpu_funcs {* for cmdstream that is buffered in this FIFO upstream of the CP fw. */ bool (*progress)(struct msm_gpu *gpu,struct msm_ringbuffer *ring); +int (*submitqueue_setup)(struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue); +void (*submitqueue_close)(struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue); };/* Additional state for iommu faults: */
@@ -522,6 +526,9 @@ struct msm_gpu_submitqueue {struct mutex lock;struct kref ref;struct drm_sched_entity *entity; +struct msm_gpu *gpu; +struct drm_gem_object *bo; +uint64_t bo_iova; };struct msm_gpu_state_bo {
drivers/gpu/drm/msm/msm_submitqueue.c +10 -0
@@ -71,6 +71,11 @@ 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); +idr_destroy (&queue->fence_idr);msm_file_private_put (queue->ctx);
@@ -160,6 +165,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;enum drm_sched_priority sched_prio;unsigned ring_nr;int ret;
@@ -195,6 +201,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, queue->ctx =msm_file_private_get (ctx); queue->id = ctx->queueid++; + queue->gpu = gpu;if (id) *id = queue->id;
@@ -207,6 +214,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 · 1 line
2.46.0
PATCH v2 3/9 drm/msm: Add a `preempt_record_size` field
In reply to Antonino ManiscalcoAdds a field to adreno_info to store the GPU specific preempt record size.
--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 4 ++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + 2 files changed, 5 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +4 -0
@@ -1190,6 +1190,7 @@ static const struct adreno_info a7xx_gpus[] = { .protect = &a730_protect, }, .address_space_size = SZ_16G, + .preempt_record_size = 2860 * SZ_1K, }, { .chip_ids = ADRENO_CHIP_IDS(0x43050a01), /* "C510v2" */ .family = ADRENO_7XX_GEN2,
@@ -1209,6 +1210,7 @@ static const struct adreno_info a7xx_gpus[] = { .gmu_chipid = 0x7020100, }, .address_space_size = SZ_16G, + .preempt_record_size = 4192 * SZ_1K, }, { .chip_ids = ADRENO_CHIP_IDS(0x43050c01), /* "C512v2" */ .family = ADRENO_7XX_GEN2,
@@ -1227,6 +1229,7 @@ static const struct adreno_info a7xx_gpus[] = { .gmu_chipid = 0x7050001, }, .address_space_size = SZ_256G, + .preempt_record_size = 4192 * SZ_1K, }, { .chip_ids = ADRENO_CHIP_IDS(0x43051401), /* "C520v2" */ .family = ADRENO_7XX_GEN3,
@@ -1245,6 +1248,7 @@ static const struct adreno_info a7xx_gpus[] = { .gmu_chipid = 0x7090100, }, .address_space_size = SZ_16G, + .preempt_record_size = 3572 * SZ_1K, } };DECLARE_ADRENO_GPULIST (a7xx);
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1 -0
@@ -111,6 +111,7 @@ struct adreno_info {* {SHRT_MAX, 0} sentinal. */ struct adreno_speedbin *speedbins; +u64 preempt_record_size; }; #define ADRENO_CHIP_IDS(tbl...) (uint32_t[]) { tbl, 0 }
Signature · 1 line
2.46.0
PATCH v2 4/9 drm/msm/A6xx: Implement preemption for A7XX targets
In reply to Antonino ManiscalcoThis 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_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/Makefile +1 -0
@@ -23,6 +23,7 @@ adreno-y := \ adreno/a6xx_gpu.o \ adreno/a6xx_gmu.o \ adreno/a6xx_hfi.o \ + adreno/a6xx_preempt.o \ adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +314 -9
457 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +168 -0
198 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +431 -0
431 lines not on this page · raw message
drivers/gpu/drm/msm/msm_ringbuffer.h +7 -0
@@ -36,6 +36,7 @@ struct msm_rbmemptrs {volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT ];volatile u64 ttbr0; +volatile u32 context_idr; };struct msm_cp_state {
@@ -100,6 +101,12 @@ struct msm_ringbuffer {* preemption. Can be aquired from irq context. */ spinlock_t preempt_lock; + +/* +* Whether we skipped writing wptr and it needs to be updated in the +* future when the ring becomes current. +*/ +bool skip_inline_wptr; }; struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
Signature · 1 line
2.46.0
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)
[snip]
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 425
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +12
-0+ +int a6xx_preempt_submitqueue_setup (struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue) +{ +void *ptr; + +/* +* Create a per submitqueue buffer for the CP to save and restore user +* specific information such as the VPC streamout data. +*/ + ptr =msm_gem_kernel_new (gpu->dev,A6XX_PREEMPT_USER_RECORD_SIZE , +MSM_BO_WC , gpu->aspace, &queue->bo, &queue->bo_iova);
Can this be MSM_BO_MAP_PRIV? Otherwise it is visible (and writeable) by other proceess's userspace generated cmdstream.
And a similar question for the scratch_bo.. I'd have to give some thought to what sort of mischief could be had, but generall kernel mappings that are not MAP_PRIV are a thing to be careful about.
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 42 lines · Rob Clark
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)[snip]
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 425
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +12
-0+ +int a6xx_preempt_submitqueue_setup (struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue) +{ +void *ptr; + +/* +* Create a per submitqueue buffer for the CP to save and restore user +* specific information such as the VPC streamout data. +*/ + ptr =msm_gem_kernel_new (gpu->dev,A6XX_PREEMPT_USER_RECORD_SIZE , +MSM_BO_WC , gpu->aspace, &queue->bo, &queue->bo_iova);Can this be
MSM_BO_MAP_PRIV? Otherwise it is visible (and writeable) by other proceess's userspace generated cmdstream.
Quoted 4 lines
And a similar question for the
scratch_bo.. I'd have to give some thought to what sort of mischief could be had, but generall kernel mappings that are notMAP_PRIVare a thing to be careful about.
It seems like the idea behind this is that it's supposed to be per-context. kgsl allocates it as part of the context, as part of the userspace address space, and then in order to know which user record to use when preempting, before each submit (although really it only needs to be done when setting the pagetable) it does a CP_MEM_WRITE of the user record address to a scratch buffer holding an array of the current user record for each ring. Then when preempting it reads the address for the next ring from the scratch buffer and sets it. I think we need to do that dance too.
Connor
Quoted 2 lines
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 49 lines · Connor Abbott
Quoted 42 lines · Rob Clark
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)[snip]
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 425
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +12
-0+ +int a6xx_preempt_submitqueue_setup (struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue) +{ +void *ptr; + +/* +* Create a per submitqueue buffer for the CP to save and restore user +* specific information such as the VPC streamout data. +*/ + ptr =msm_gem_kernel_new (gpu->dev,A6XX_PREEMPT_USER_RECORD_SIZE , +MSM_BO_WC , gpu->aspace, &queue->bo, &queue->bo_iova);Can this be
MSM_BO_MAP_PRIV? Otherwise it is visible (and writeable) by other proceess's userspace generated cmdstream.Quoted 4 lines
And a similar question for the
scratch_bo.. I'd have to give some thought to what sort of mischief could be had, but generall kernel mappings that are notMAP_PRIVare a thing to be careful about.
Quoted 9 lines
It seems like the idea behind this is that it's supposed to be per-context. kgsl allocates it as part of the context, as part of the userspace address space, and then in order to know which user record to use when preempting, before each submit (although really it only needs to be done when setting the pagetable) it does a
CP_MEM_WRITEof the user record address to a scratch buffer holding an array of the current user record for each ring. Then when preempting it reads the address for the next ring from the scratch buffer and sets it. I think we need to do that dance too.
Moving it into userspace's address space (vm) would be better.
I assume the preempt record is where state is saved/restored? So would need to be in kernel aspace/vm? Or is the fw changing ttbr0 after saving state but before restoring?
BR,
-R
Quoted 4 lines
Connor
Quoted 2 lines
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 61 lines · Rob Clark
Quoted 49 lines · Connor Abbott
Quoted 42 lines · Rob Clark
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)[snip]
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 425
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +12
-0+ +int a6xx_preempt_submitqueue_setup (struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue) +{ +void *ptr; + +/* +* Create a per submitqueue buffer for the CP to save and restore user +* specific information such as the VPC streamout data. +*/ + ptr =msm_gem_kernel_new (gpu->dev,A6XX_PREEMPT_USER_RECORD_SIZE , +MSM_BO_WC , gpu->aspace, &queue->bo, &queue->bo_iova);Can this be
MSM_BO_MAP_PRIV? Otherwise it is visible (and writeable) by other proceess's userspace generated cmdstream.Quoted 4 lines
And a similar question for the
scratch_bo.. I'd have to give some thought to what sort of mischief could be had, but generall kernel mappings that are notMAP_PRIVare a thing to be careful about.Quoted 9 lines
It seems like the idea behind this is that it's supposed to be per-context. kgsl allocates it as part of the context, as part of the userspace address space, and then in order to know which user record to use when preempting, before each submit (although really it only needs to be done when setting the pagetable) it does a
CP_MEM_WRITEof the user record address to a scratch buffer holding an array of the current user record for each ring. Then when preempting it reads the address for the next ring from the scratch buffer and sets it. I think we need to do that dance too.
Quoted 8 lines
Moving it into userspace's address space (vm) would be better.
I assume the preempt record is where state is saved/restored? So would need to be in kernel aspace/vm? Or is the fw changing ttbr0 after saving state but before restoring?
BR,
-R
The preempt record is split into a number of pieces, each with their own address. One of those pieces is the SMMU record with ttbr0 and other SMMU things. Another piece is the "private" context record with sensitive things like RB address/rptr/wptr, although actually the bulk of the registers are saved here. Then the user or "non-private" record is its own piece, which is presumably saved before switching ttbr0 and restored after the SMMU record is restored and ttbr0 is switched.
Connor
Quoted 5 lines
Quoted 5 lines
Connor
Quoted 2 lines
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 72 lines · Connor Abbott
Quoted 61 lines · Rob Clark
Quoted 49 lines · Connor Abbott
Quoted 42 lines · Rob Clark
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)[snip]
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 425
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +12
-0+ +int a6xx_preempt_submitqueue_setup (struct msm_gpu *gpu, +struct msm_gpu_submitqueue *queue) +{ +void *ptr; + +/* +* Create a per submitqueue buffer for the CP to save and restore user +* specific information such as the VPC streamout data. +*/ + ptr =msm_gem_kernel_new (gpu->dev,A6XX_PREEMPT_USER_RECORD_SIZE , +MSM_BO_WC , gpu->aspace, &queue->bo, &queue->bo_iova);Can this be
MSM_BO_MAP_PRIV? Otherwise it is visible (and writeable) by other proceess's userspace generated cmdstream.Quoted 4 lines
And a similar question for the
scratch_bo.. I'd have to give some thought to what sort of mischief could be had, but generall kernel mappings that are notMAP_PRIVare a thing to be careful about.Quoted 9 lines
It seems like the idea behind this is that it's supposed to be per-context. kgsl allocates it as part of the context, as part of the userspace address space, and then in order to know which user record to use when preempting, before each submit (although really it only needs to be done when setting the pagetable) it does a
CP_MEM_WRITEof the user record address to a scratch buffer holding an array of the current user record for each ring. Then when preempting it reads the address for the next ring from the scratch buffer and sets it. I think we need to do that dance too.Quoted 8 lines
Moving it into userspace's address space (vm) would be better.
I assume the preempt record is where state is saved/restored? So would need to be in kernel aspace/vm? Or is the fw changing ttbr0 after saving state but before restoring?
BR,
-R
Quoted 8 lines
The preempt record is split into a number of pieces, each with their own address. One of those pieces is the SMMU record with ttbr0 and other SMMU things. Another piece is the "private" context record with sensitive things like RB address/rptr/wptr, although actually the bulk of the registers are saved here. Then the user or "non-private" record is its own piece, which is presumably saved before switching ttbr0 and restored after the SMMU record is restored and ttbr0 is switched.
Ok, and all these are offsets in the preempt record.. but that part is allocated with MAP_PRIV, so that part should be ok.
Why is the VPC streamout state handled differently?
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
In reply to Antonino ManiscalcoQuoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)
[snip]
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static int a6xx_ucode_load(struct msm_gpu *gpu) · line 1068
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4
-0@@ -784,6 +1062,16 @@ static int a6xx_ucode_load(struct msm_gpu *gpu)msm_gem_object_set_name (a6xx_gpu->shadow_bo,"shadow" ); } + a6xx_gpu->pwrup_reglist_ptr =msm_gem_kernel_new (gpu->dev,PAGE_SIZE , +MSM_BO_WC |MSM_BO_MAP_PRIV , + gpu->aspace, &a6xx_gpu->pwrup_reglist_bo, + &a6xx_gpu->pwrup_reglist_iova);
I guess this could also be MSM_BO_GPU_READONLY?
BR,
-R
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
Quoted 36 lines · Rob Clark
Quoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)[snip]
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static int a6xx_ucode_load(struct msm_gpu *gpu) · line 1068
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4
-0@@ -784,6 +1062,16 @@ static int a6xx_ucode_load(struct msm_gpu *gpu)msm_gem_object_set_name (a6xx_gpu->shadow_bo,"shadow" ); } + a6xx_gpu->pwrup_reglist_ptr =msm_gem_kernel_new (gpu->dev,PAGE_SIZE , +MSM_BO_WC |MSM_BO_MAP_PRIV , + gpu->aspace, &a6xx_gpu->pwrup_reglist_bo, + &a6xx_gpu->pwrup_reglist_iova);I guess this could also be
MSM_BO_GPU_READONLY?
Quoted 2 lines
BR,
-R
Besides containing the the actual reglist this buffer also contains the cpu_gpu_lock structure which is written by the SQE so adding the MSM_BO_GPU_READONLY flag would cause it to fault.
Best regards,
Signature · 1 line
Antonino Maniscalco <[email protected]>
Re: [PATCH v2 4/9] drm/msm/A6xx: Implement preemption for A7XX targets
In reply to Antonino ManiscalcoQuoted 20 lines · Antonino Maniscalco
This 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.
Signed-off-by Sharat Masetty <[email protected]>Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 323 +++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 168 ++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 431 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.h | 7 + 5 files changed, 921 insertions(+), 9 deletions(-)
[snip]
Quoted 22 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +22
-0+void a6xx_preempt_trigger (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +u64 preempt_offset_priv_secure; +unsigned long flags; +struct msm_ringbuffer *ring; +uint64_t user_ctx_iova; +unsigned int cntl; + +if (gpu->nr_rings ==1 ) +return ; + +/* +* Lock to make sure another thread attempting preemption doesn't skip it +* while we are still evaluating the next ring. This makes sure the other +* thread does start preemption if we abort it and avoids a soft lock. +*/ +spin_lock_irqsave (&a6xx_gpu->eval_lock, flags); + +/* +* Try to start preemption by moving from NONE to START. If
drivers/gpu/drm/msm/adreno/a6xx_preempt.c line 220
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c new file +10
-0+* unsuccessful, a preemption is already in flight +*/ +if (!try_preempt_state (a6xx_gpu,PREEMPT_NONE ,PREEMPT_START )) { +spin_unlock_irqrestore (&a6xx_gpu->eval_lock, flags); +return ; + } + + cntl = (((a6xx_gpu->preempt_level <<6 ) &0xC0 ) | + ((a6xx_gpu->skip_save_restore <<9 ) &0x200 ) | + ((a6xx_gpu->uses_gmem <<8 ) &0x100 ) |0x1 );
nit, could we define these fields in the xml, and not open-code register building?
BR,
-R
PATCH v2 5/9 drm/msm/A6xx: Sync relevant adreno_pm4.xml changes
In reply to Antonino ManiscalcoIn mesa CP_SET_CTXSWITCH_IB is renamed to CP_SET_AMBLE and some other names are changed to match KGSL. Import those changes.
The changes have not been merged yet in mesa but are necessary for this series.
--- .../gpu/drm/msm/registers/adreno/adreno_pm4.xml | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-)
drivers/gpu/drm/msm/registers/adreno/adreno_pm4.xml +17 -22
@@ -581,8 +581,7 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> and forcibly switch to the indicated context. </doc> <value name="CP_CONTEXT_SWITCH" value="0x54" variants="A6XX"/> - <!-- Note, kgsl calls this CP_SET_AMBLE: --> - <value name="CP_SET_CTXSWITCH_IB" value="0x55" variants="A6XX-"/> + <value name="CP_SET_AMBLE" value="0x55" variants="A6XX-"/> <!-- Seems to always have the payload:
@@ -2013,42 +2012,38 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) </reg32> </domain> -<domain name="CP_SET_CTXSWITCH_IB" width="32"> +<domain name="CP_SET_AMBLE" width="32"> <doc> - Used by the userspace driver to set various IB's which are - executed during context save/restore for handling - state that isn't restored by the - context switch routine itself. - </doc> - <enum name="ctxswitch_ib"> - <value name="RESTORE_IB" value="0"> + Used by the userspace and kernel drivers to set various IB's + which are executed during context save/restore for handling + state that isn't restored by the context switch routine itself. + </doc> + <enum name="amble_type"> + <value name="PREAMBLE_AMBLE_TYPE" value="0"> <doc>Executed unconditionally when switching back to the context.</doc> </value> - <value name="YIELD_RESTORE_IB" value="1"> + <value name="BIN_PREAMBLE_AMBLE_TYPE" value="1"> <doc> Executed when switching back after switching away during execution of - a CP_SET_MARKER packet with RM6_YIELD as the - payload *and* the normal save routine was - bypassed for a shorter one. I think this is - connected to the "skipsaverestore" bit set by - the kernel when preempting. + a CP_SET_MARKER packet with RM6_BIN_RENDER_END as the + payload *and* skipsaverestore is set. This is + expected to restore static register values not + saved when skipsaverestore is set. </doc> </value> - <value name="SAVE_IB" value="2"> + <value name="POSTAMBLE_AMBLE_TYPE" value="2"> <doc> Executed when switching away from the context, except for context switches initiated via CP_YIELD. </doc> </value> - <value name="RB_SAVE_IB" value="3"> + <value name="KMD_AMBLE_TYPE" value="3"> <doc> This can only be set by the RB (i.e. the kernel) and executes with protected mode off, but - is otherwise similar to SAVE_IB. - - Note, kgsl calls this CP_KMD_AMBLE_TYPE + is otherwise similar to POSTAMBLE_AMBLE_TYPE. </doc> </value> </enum>
@@ -2060,7 +2055,7 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) </reg32> <reg32 offset="2" name="2"> <bitfield name="DWORDS" low="0" high="19" type="uint"/> - <bitfield name="TYPE" low="20" high="21" type="ctxswitch_ib"/> + <bitfield name="TYPE" low="20" high="21" type="amble_type"/> </reg32> </domain>
Signature · 1 line
2.46.0
PATCH v2 6/9 drm/msm/A6xx: Use posamble to reset counters on preemption
In reply to Antonino ManiscalcoUse the postamble to reset perf counters when switching between rings, except when sysprof is enabled, analogously to how they are reset between submissions when switching pagetables.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 +++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 6 ++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 +++++-- 4 files changed, 49 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +13 -1
@@ -366,7 +366,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)static void a6xx_emit_set_pseudo_reg (struct msm_ringbuffer *ring,struct a6xx_gpu *a6xx_gpu,struct msm_gpu_submitqueue *queue) { -u64 preempt_offset_priv_secure; +bool sysprof =refcount_read (&a6xx_gpu->base.base.sysprof_active) >1 ; +u64 preempt_offset_priv_secure, preempt_postamble;OUT_PKT7 (ring,CP_SET_PSEUDO_REG ,15 );
@@ -403,6 +404,17 @@ static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring,/* seems OK to set to 0 to disable it */ OUT_RING (ring,0 );OUT_RING (ring,0 ); + +if (!sysprof && a6xx_gpu->preempt_postamble_len) { + preempt_postamble =SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu); + +OUT_PKT7 (ring,CP_SET_AMBLE ,3 ); +OUT_RING (ring,lower_32_bits (preempt_postamble)); +OUT_RING (ring,upper_32_bits (preempt_postamble)); +OUT_RING (ring,CP_SET_AMBLE_2_DWORDS ( + a6xx_gpu->preempt_postamble_len) | +CP_SET_AMBLE_2_TYPE (KMD_AMBLE_TYPE )); + } }static void a7xx_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit)
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +6 -0
@@ -66,6 +66,7 @@ struct a6xx_gpu {atomic_t preempt_state;spinlock_t eval_lock;struct timer_list preempt_timer; +uint64_t preempt_postamble_len;unsigned int preempt_level;bool uses_gmem;
@@ -99,6 +100,11 @@ struct a6xx_gpu {#define SCRATCH_USER_CTX_IOVA (ring_id, a6xx_gpu) \ (a6xx_gpu->scratch_iova + (ring_id * sizeof(uint64_t))) +#define SCRATCH_PREEMPT_POSTAMBLE_OFFSET (100 * sizeof(u64)) + +#define SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu) \ + (a6xx_gpu->scratch_iova + SCRATCH_PREEMPT_POSTAMBLE_OFFSET) +/* * In order to do lockless preemption we use a simple state machine to progress * through the process.
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +25 -1
@@ -351,6 +351,28 @@ static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,return 0 ; } +static void preempt_prepare_postamble (struct a6xx_gpu *a6xx_gpu) +{ +u32 *postamble = a6xx_gpu->scratch_ptr +SCRATCH_PREEMPT_POSTAMBLE_OFFSET ; +u32 count =0 ; + + postamble[count++] =PKT7 (CP_REG_RMW ,3 ); + postamble[count++] =REG_A6XX_RBBM_PERFCTR_SRAM_INIT_CMD ; + postamble[count++] =0 ; + postamble[count++] =1 ; + + postamble[count++] =PKT7 (CP_WAIT_REG_MEM ,6 ); + postamble[count++] =CP_WAIT_REG_MEM_0_FUNCTION (WRITE_EQ ); + postamble[count++] =CP_WAIT_REG_MEM_1_POLL_ADDR_LO ( +REG_A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS ); + postamble[count++] =CP_WAIT_REG_MEM_2_POLL_ADDR_HI (0 ); + postamble[count++] =CP_WAIT_REG_MEM_3_REF (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_4_MASK (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES (0 ); + + a6xx_gpu->preempt_postamble_len = count; +} +void a6xx_preempt_fini (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -382,10 +404,12 @@ void a6xx_preempt_init(struct msm_gpu *gpu) 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 , +PAGE_SIZE ,MSM_BO_WC , gpu->aspace, &a6xx_gpu->scratch_bo, &a6xx_gpu->scratch_iova); +preempt_prepare_postamble (a6xx_gpu); +if (IS_ERR (a6xx_gpu->scratch_ptr)) goto fail;
drivers/gpu/drm/msm/adreno/adreno_gpu.h +5 -2
@@ -610,12 +610,15 @@ OUT_PKT4(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)OUT_RING (ring,PKT4 (regindx, cnt)); } +#define PKT7 (opcode, cnt) \ + (CP_TYPE7_PKT | (cnt << 0) | (PM4_PARITY(cnt) << 15) | \ + ((opcode & 0x7F) << 16) | (PM4_PARITY(opcode) << 23)) +static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) {adreno_wait_ring (ring, cnt +1 ); -OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | - ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); +OUT_RING (ring,PKT7 (opcode, cnt)); }struct msm_gpu *a2xx_gpu_init (struct drm_device *dev);
Signature · 1 line
2.46.0
Re: [PATCH v2 6/9] drm/msm/A6xx: Use posamble to reset counters on preemption
Quoted 32 lines · Antonino Maniscalco
Use the postamble to reset perf counters when switching between rings, except when sysprof is enabled, analogously to how they are reset between submissions when switching pagetables.
Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 +++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 6 ++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 +++++-- 4 files changed, 49 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +3
-1@@ -366,7 +366,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)static void a6xx_emit_set_pseudo_reg (struct msm_ringbuffer *ring,struct a6xx_gpu *a6xx_gpu,struct msm_gpu_submitqueue *queue) { -u64 preempt_offset_priv_secure; +bool sysprof =refcount_read (&a6xx_gpu->base.base.sysprof_active) >1 ; +u64 preempt_offset_priv_secure, preempt_postamble;OUT_PKT7 (ring,CP_SET_PSEUDO_REG ,15 );@@ -403,6 +404,17 @@ static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring,/* seems OK to set to 0 to disable it */ OUT_RING (ring,0 );OUT_RING (ring,0 ); +
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring, · line 417
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +10
-0+if (!sysprof && a6xx_gpu->preempt_postamble_len) { + preempt_postamble =SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu); + +OUT_PKT7 (ring,CP_SET_AMBLE ,3 ); +OUT_RING (ring,lower_32_bits (preempt_postamble)); +OUT_RING (ring,upper_32_bits (preempt_postamble)); +OUT_RING (ring,CP_SET_AMBLE_2_DWORDS ( + a6xx_gpu->preempt_postamble_len) | +CP_SET_AMBLE_2_TYPE (KMD_AMBLE_TYPE )); + }
Hmm, ok, we set this in the submit path.. but do we need to clear it somehow when transitioning from !sysprof to sysprof?
Also, how does this interact with UMD perfctr queries, I would expect they would prefer save/restore?
BR,
-R
Quoted 100 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0}static void a7xx_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit)drivers/gpu/drm/msm/adreno/a6xx_gpu.h +6
-0@@ -66,6 +66,7 @@ struct a6xx_gpu {atomic_t preempt_state;spinlock_t eval_lock;struct timer_list preempt_timer; +uint64_t preempt_postamble_len;unsigned int preempt_level;bool uses_gmem;@@ -99,6 +100,11 @@ struct a6xx_gpu {#define SCRATCH_USER_CTX_IOVA (ring_id, a6xx_gpu) \ (a6xx_gpu->scratch_iova + (ring_id * sizeof(uint64_t))) +#define SCRATCH_PREEMPT_POSTAMBLE_OFFSET (100 * sizeof(u64)) + +#define SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu) \ + (a6xx_gpu->scratch_iova + SCRATCH_PREEMPT_POSTAMBLE_OFFSET) +/* * In order to do lockless preemption we use a simple state machine to progress * through the process. drivers/gpu/drm/msm/adreno/a6xx_preempt.c +25
-1@@ -351,6 +351,28 @@ static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,return 0 ; } +static void preempt_prepare_postamble (struct a6xx_gpu *a6xx_gpu) +{ +u32 *postamble = a6xx_gpu->scratch_ptr +SCRATCH_PREEMPT_POSTAMBLE_OFFSET ; +u32 count =0 ; + + postamble[count++] =PKT7 (CP_REG_RMW ,3 ); + postamble[count++] =REG_A6XX_RBBM_PERFCTR_SRAM_INIT_CMD ; + postamble[count++] =0 ; + postamble[count++] =1 ; + + postamble[count++] =PKT7 (CP_WAIT_REG_MEM ,6 ); + postamble[count++] =CP_WAIT_REG_MEM_0_FUNCTION (WRITE_EQ ); + postamble[count++] =CP_WAIT_REG_MEM_1_POLL_ADDR_LO ( +REG_A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS ); + postamble[count++] =CP_WAIT_REG_MEM_2_POLL_ADDR_HI (0 ); + postamble[count++] =CP_WAIT_REG_MEM_3_REF (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_4_MASK (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES (0 ); + + a6xx_gpu->preempt_postamble_len = count; +} +void a6xx_preempt_fini (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);@@ -382,10 +404,12 @@ void a6xx_preempt_init(struct msm_gpu *gpu) 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 , +PAGE_SIZE ,MSM_BO_WC , gpu->aspace, &a6xx_gpu->scratch_bo, &a6xx_gpu->scratch_iova); +preempt_prepare_postamble (a6xx_gpu); +if (IS_ERR (a6xx_gpu->scratch_ptr)) goto fail;drivers/gpu/drm/msm/adreno/adreno_gpu.h +5
-3@@ -610,12 +610,15 @@ OUT_PKT4(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)OUT_RING (ring,PKT4 (regindx, cnt)); } +#define PKT7 (opcode, cnt) \ + (CP_TYPE7_PKT | (cnt << 0) | (PM4_PARITY(cnt) << 15) | \ + ((opcode & 0x7F) << 16) | (PM4_PARITY(opcode) << 23)) +static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) {adreno_wait_ring (ring, cnt +1 ); -OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | - ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); +OUT_RING (ring,PKT7 (opcode, cnt)); }struct msm_gpu *a2xx_gpu_init (struct drm_device *dev); --2.46.0
Re: [PATCH v2 6/9] drm/msm/A6xx: Use posamble to reset counters on preemption
Quoted 39 lines · Rob Clark
Quoted 37 lines · Antonino Maniscalco
Use the postamble to reset perf counters when switching between rings, except when sysprof is enabled, analogously to how they are reset between submissions when switching pagetables.
Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 +++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 6 ++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 +++++-- 4 files changed, 49 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-1@@ -366,7 +366,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)static void a6xx_emit_set_pseudo_reg (struct msm_ringbuffer *ring,struct a6xx_gpu *a6xx_gpu,struct msm_gpu_submitqueue *queue) { -u64 preempt_offset_priv_secure; +bool sysprof =refcount_read (&a6xx_gpu->base.base.sysprof_active) >1 ; +u64 preempt_offset_priv_secure, preempt_postamble;OUT_PKT7 (ring,CP_SET_PSEUDO_REG ,15 );@@ -403,6 +404,17 @@ static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring,/* seems OK to set to 0 to disable it */ OUT_RING (ring,0 );OUT_RING (ring,0 ); + +if (!sysprof && a6xx_gpu->preempt_postamble_len) { + preempt_postamble =SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu); + +OUT_PKT7 (ring,CP_SET_AMBLE ,3 ); +OUT_RING (ring,lower_32_bits (preempt_postamble));
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring, · line 417
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5
-0+OUT_RING (ring,upper_32_bits (preempt_postamble)); +OUT_RING (ring,CP_SET_AMBLE_2_DWORDS ( + a6xx_gpu->preempt_postamble_len) | +CP_SET_AMBLE_2_TYPE (KMD_AMBLE_TYPE )); + }Hmm, ok, we set this in the submit path.. but do we need to clear it somehow when transitioning from !sysprof to sysprof?
We can always emit the packet and 0 fields out when sysprof is enabled. Would that be ok for you? Only emitting it when needed might be nontrivial given that there are multiple rings and we would be paying the overhead for emitting it in the more common case (not profiling) anyway.
Quoted 2 lines
Also, how does this interact with UMD perfctr queries, I would expect they would prefer save/restore?
Right so my understanding given previous discussions is that we want to disable preemption from userspace in that case? The vulkan extension requires to acquire and release a lock so we could use that to emit the packets that enable and disable preemption perhaps.
Quoted 99 lines
BR,
-RQuoted 95 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0}static void a7xx_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit)drivers/gpu/drm/msm/adreno/a6xx_gpu.h +6
-0@@ -66,6 +66,7 @@ struct a6xx_gpu {atomic_t preempt_state;spinlock_t eval_lock;struct timer_list preempt_timer; +uint64_t preempt_postamble_len;unsigned int preempt_level;bool uses_gmem;@@ -99,6 +100,11 @@ struct a6xx_gpu {#define SCRATCH_USER_CTX_IOVA (ring_id, a6xx_gpu) \ (a6xx_gpu->scratch_iova + (ring_id * sizeof(uint64_t))) +#define SCRATCH_PREEMPT_POSTAMBLE_OFFSET (100 * sizeof(u64)) + +#define SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu) \ + (a6xx_gpu->scratch_iova + SCRATCH_PREEMPT_POSTAMBLE_OFFSET) +/* * In order to do lockless preemption we use a simple state machine to progress * through the process. drivers/gpu/drm/msm/adreno/a6xx_preempt.c +25
-1@@ -351,6 +351,28 @@ static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,return 0 ; } +static void preempt_prepare_postamble (struct a6xx_gpu *a6xx_gpu) +{ +u32 *postamble = a6xx_gpu->scratch_ptr +SCRATCH_PREEMPT_POSTAMBLE_OFFSET ; +u32 count =0 ; + + postamble[count++] =PKT7 (CP_REG_RMW ,3 ); + postamble[count++] =REG_A6XX_RBBM_PERFCTR_SRAM_INIT_CMD ; + postamble[count++] =0 ; + postamble[count++] =1 ; + + postamble[count++] =PKT7 (CP_WAIT_REG_MEM ,6 ); + postamble[count++] =CP_WAIT_REG_MEM_0_FUNCTION (WRITE_EQ ); + postamble[count++] =CP_WAIT_REG_MEM_1_POLL_ADDR_LO ( +REG_A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS ); + postamble[count++] =CP_WAIT_REG_MEM_2_POLL_ADDR_HI (0 ); + postamble[count++] =CP_WAIT_REG_MEM_3_REF (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_4_MASK (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES (0 ); + + a6xx_gpu->preempt_postamble_len = count; +} +void a6xx_preempt_fini (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);@@ -382,10 +404,12 @@ void a6xx_preempt_init(struct msm_gpu *gpu) 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 , +PAGE_SIZE ,MSM_BO_WC , gpu->aspace, &a6xx_gpu->scratch_bo, &a6xx_gpu->scratch_iova); +preempt_prepare_postamble (a6xx_gpu); +if (IS_ERR (a6xx_gpu->scratch_ptr)) goto fail;drivers/gpu/drm/msm/adreno/adreno_gpu.h +5
-2@@ -610,12 +610,15 @@ OUT_PKT4(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)OUT_RING (ring,PKT4 (regindx, cnt)); } +#define PKT7 (opcode, cnt) \ + (CP_TYPE7_PKT | (cnt << 0) | (PM4_PARITY(cnt) << 15) | \ + ((opcode & 0x7F) << 16) | (PM4_PARITY(opcode) << 23)) +static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) {adreno_wait_ring (ring, cnt +1 ); -OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | - ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); +OUT_RING (ring,PKT7 (opcode, cnt)); }
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0
-1struct msm_gpu *a2xx_gpu_init (struct drm_device *dev); --2.46.0
Best regards,
Signature · 1 line
Antonino Maniscalco <[email protected]>
Re: [PATCH v2 6/9] drm/msm/A6xx: Use posamble to reset counters on preemption
Quoted 51 lines · Antonino Maniscalco
Quoted 39 lines · Rob Clark
Quoted 37 lines · Antonino Maniscalco
Use the postamble to reset perf counters when switching between rings, except when sysprof is enabled, analogously to how they are reset between submissions when switching pagetables.
Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 +++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 6 ++++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 +++++-- 4 files changed, 49 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-1@@ -366,7 +366,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)static void a6xx_emit_set_pseudo_reg (struct msm_ringbuffer *ring,struct a6xx_gpu *a6xx_gpu,struct msm_gpu_submitqueue *queue) { -u64 preempt_offset_priv_secure; +bool sysprof =refcount_read (&a6xx_gpu->base.base.sysprof_active) >1 ; +u64 preempt_offset_priv_secure, preempt_postamble;OUT_PKT7 (ring,CP_SET_PSEUDO_REG ,15 );@@ -403,6 +404,17 @@ static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring,/* seems OK to set to 0 to disable it */ OUT_RING (ring,0 );OUT_RING (ring,0 ); + +if (!sysprof && a6xx_gpu->preempt_postamble_len) { + preempt_postamble =SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu); + +OUT_PKT7 (ring,CP_SET_AMBLE ,3 ); +OUT_RING (ring,lower_32_bits (preempt_postamble));Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_emit_set_pseudo_reg(struct msm_ringbuffer *ring, · line 417
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5
-0+OUT_RING (ring,upper_32_bits (preempt_postamble)); +OUT_RING (ring,CP_SET_AMBLE_2_DWORDS ( + a6xx_gpu->preempt_postamble_len) | +CP_SET_AMBLE_2_TYPE (KMD_AMBLE_TYPE )); + }Hmm, ok, we set this in the submit path.. but do we need to clear it somehow when transitioning from !sysprof to sysprof?
Quoted 4 lines
We can always emit the packet and 0 fields out when sysprof is enabled. Would that be ok for you? Only emitting it when needed might be nontrivial given that there are multiple rings and we would be paying the overhead for emitting it in the more common case (not profiling) anyway.
That sounds like it would work
Quoted 7 lines
Quoted 2 lines
Also, how does this interact with UMD perfctr queries, I would expect they would prefer save/restore?
Right so my understanding given previous discussions is that we want to disable preemption from userspace in that case? The vulkan extension requires to acquire and release a lock so we could use that to emit the packets that enable and disable preemption perhaps.
ack
BR,
-R
Quoted 109 lines
Quoted 99 lines
BR,
-RQuoted 95 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0}static void a7xx_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit)drivers/gpu/drm/msm/adreno/a6xx_gpu.h +6
-0@@ -66,6 +66,7 @@ struct a6xx_gpu {atomic_t preempt_state;spinlock_t eval_lock;struct timer_list preempt_timer; +uint64_t preempt_postamble_len;unsigned int preempt_level;bool uses_gmem;@@ -99,6 +100,11 @@ struct a6xx_gpu {#define SCRATCH_USER_CTX_IOVA (ring_id, a6xx_gpu) \ (a6xx_gpu->scratch_iova + (ring_id * sizeof(uint64_t))) +#define SCRATCH_PREEMPT_POSTAMBLE_OFFSET (100 * sizeof(u64)) + +#define SCRATCH_PREEMPT_POSTAMBLE_IOVA (a6xx_gpu) \ + (a6xx_gpu->scratch_iova + SCRATCH_PREEMPT_POSTAMBLE_OFFSET) +/* * In order to do lockless preemption we use a simple state machine to progress * through the process. drivers/gpu/drm/msm/adreno/a6xx_preempt.c +25
-1@@ -351,6 +351,28 @@ static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,return 0 ; } +static void preempt_prepare_postamble (struct a6xx_gpu *a6xx_gpu) +{ +u32 *postamble = a6xx_gpu->scratch_ptr +SCRATCH_PREEMPT_POSTAMBLE_OFFSET ; +u32 count =0 ; + + postamble[count++] =PKT7 (CP_REG_RMW ,3 ); + postamble[count++] =REG_A6XX_RBBM_PERFCTR_SRAM_INIT_CMD ; + postamble[count++] =0 ; + postamble[count++] =1 ; + + postamble[count++] =PKT7 (CP_WAIT_REG_MEM ,6 ); + postamble[count++] =CP_WAIT_REG_MEM_0_FUNCTION (WRITE_EQ ); + postamble[count++] =CP_WAIT_REG_MEM_1_POLL_ADDR_LO ( +REG_A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS ); + postamble[count++] =CP_WAIT_REG_MEM_2_POLL_ADDR_HI (0 ); + postamble[count++] =CP_WAIT_REG_MEM_3_REF (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_4_MASK (0x1 ); + postamble[count++] =CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES (0 ); + + a6xx_gpu->preempt_postamble_len = count; +} +void a6xx_preempt_fini (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);@@ -382,10 +404,12 @@ void a6xx_preempt_init(struct msm_gpu *gpu) 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 , +PAGE_SIZE ,MSM_BO_WC , gpu->aspace, &a6xx_gpu->scratch_bo, &a6xx_gpu->scratch_iova); +preempt_prepare_postamble (a6xx_gpu); +if (IS_ERR (a6xx_gpu->scratch_ptr)) goto fail;drivers/gpu/drm/msm/adreno/adreno_gpu.h +5
-2@@ -610,12 +610,15 @@ OUT_PKT4(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)OUT_RING (ring,PKT4 (regindx, cnt)); } +#define PKT7 (opcode, cnt) \ + (CP_TYPE7_PKT | (cnt << 0) | (PM4_PARITY(cnt) << 15) | \ + ((opcode & 0x7F) << 16) | (PM4_PARITY(opcode) << 23)) +static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) {adreno_wait_ring (ring, cnt +1 ); -OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | - ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); +OUT_RING (ring,PKT7 (opcode, cnt)); }Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0
-1struct msm_gpu *a2xx_gpu_init (struct drm_device *dev); --2.46.0
Best regards,
--
Antonino Maniscalco <[email protected]>
PATCH v2 7/9 drm/msm/A6xx: Add traces for preemption
In reply to Antonino ManiscalcoAdd trace points corresponding to preemption being triggered and being completed for latency measurement purposes.
--- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 7 +++++++ drivers/gpu/drm/msm/msm_gpu_trace.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +7 -0
@@ -7,6 +7,7 @@#include "a6xx_gpu.h" #include "a6xx_gmu.xml.h" #include "msm_mmu.h" +#include "msm_gpu_trace.h" /* * Try to transition the preemption state from old to new. Return
@@ -143,6 +144,8 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_NONE ); +trace_msm_gpu_preemption_irq (a6xx_gpu->cur_ring->id); +/* * Retrigger preemption to avoid a deadlock that might occur when preemption * is skipped due to it being already in flight when requested.
@@ -259,6 +262,10 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)*/ ring->skip_inline_wptr = false; +trace_msm_gpu_preemption_trigger ( + a6xx_gpu->cur_ring ? a6xx_gpu->cur_ring->id :-1 , + ring ? ring->id :-1 ); +spin_unlock_irqrestore (&ring->preempt_lock, flags); gpu_write64(gpu,
drivers/gpu/drm/msm/msm_gpu_trace.h +28 -0
@@ -177,6 +177,34 @@ TRACE_EVENT(msm_gpu_resume,TP_printk ("%u" , __entry->dummy) ); +TRACE_EVENT (msm_gpu_preemption_trigger, + TP_PROTO(int ring_id_from, int ring_id_to), +TP_ARGS (ring_id_from, ring_id_to), +TP_STRUCT__entry ( + __field(int, ring_id_from) +__field (int, ring_id_to) + ), +TP_fast_assign ( + __entry->ring_id_from = ring_id_from; + __entry->ring_id_to = ring_id_to; + ), +TP_printk ("preempting %u -> %u" , + __entry->ring_id_from, + __entry->ring_id_to) +); + +TRACE_EVENT (msm_gpu_preemption_irq, + TP_PROTO(u32 ring_id), +TP_ARGS (ring_id), +TP_STRUCT__entry ( +__field (u32, ring_id) + ), +TP_fast_assign ( + __entry->ring_id = ring_id; + ), +TP_printk ("preempted to %u" , __entry->ring_id) +); +#endif #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.46.0
PATCH v2 8/9 drm/msm/A6XX: Add a flag to allow preemption to submitqueue_create
In reply to Antonino ManiscalcoSome userspace changes are necessary so add a flag for userspace to advertise support for preemption when creating the submitqueue.
When this flag is not set preemption will not be allowed in the middle of the submitted IBs therefore mantaining compatibility with older userspace.
The flag is rejected if preemption is not supported on the target, this allows userspace to know whether preemption is supported.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++---- drivers/gpu/drm/msm/msm_submitqueue.c | 3 +++ include/uapi/drm/msm_drm.h | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8 -4
@@ -465,8 +465,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)OUT_PKT7 (ring,CP_SET_MARKER ,1 );OUT_RING (ring,0x101 );/* IFPC disable */ -OUT_PKT7 (ring,CP_SET_MARKER ,1 ); -OUT_RING (ring,0x00d );/* IB1LIST start */ +if (submit->queue->flags &MSM_SUBMITQUEUE_ALLOW_PREEMPT ) { +OUT_PKT7 (ring,CP_SET_MARKER ,1 ); +OUT_RING (ring,0x00d );/* IB1LIST start */ + }/* Submit the commands */ for (i =0 ; i < submit->nr_cmds; i++) {
@@ -497,8 +499,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)update_shadow_rptr (gpu, ring); } -OUT_PKT7 (ring,CP_SET_MARKER ,1 ); -OUT_RING (ring,0x00e );/* IB1LIST end */ +if (submit->queue->flags &MSM_SUBMITQUEUE_ALLOW_PREEMPT ) { +OUT_PKT7 (ring,CP_SET_MARKER ,1 ); +OUT_RING (ring,0x00e );/* IB1LIST end */ + }get_stats_counter (ring,REG_A7XX_RBBM_PERFCTR_CP (0 ),rbmemptr_stats (ring, index, cpcycles_end));
drivers/gpu/drm/msm/msm_submitqueue.c +3 -0
@@ -176,6 +176,9 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,if (!priv->gpu)return -ENODEV ; +if (flags &MSM_SUBMITQUEUE_ALLOW_PREEMPT && gpu->nr_rings ==1 ) +return -EINVAL ; + ret =msm_gpu_convert_priority (priv->gpu, prio, &ring_nr, &sched_prio);if (ret)return ret;
include/uapi/drm/msm_drm.h +4 -1
@@ -345,7 +345,10 @@ struct drm_msm_gem_madvise {* backwards compatibility as a "default" submitqueue */ -#define MSM_SUBMITQUEUE_FLAGS (0) +#define MSM_SUBMITQUEUE_ALLOW_PREEMPT 0x00000001 +#define MSM_SUBMITQUEUE_FLAGS ( \ + MSM_SUBMITQUEUE_ALLOW_PREEMPT | \ + 0)/* * The submitqueue priority should be between 0 and MSM_PARAM_PRIORITIES-1,
Signature · 1 line
2.46.0
PATCH v2 9/9 drm/msm/A6xx: Enable preemption for A750
In reply to Antonino ManiscalcoInitialize with 4 rings to enable preemption.
For now only on A750 as other targets require testing.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +3 -1
@@ -2609,7 +2609,9 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)return ERR_PTR (ret); } -if (is_a7xx) +if (adreno_is_a750 (adreno_gpu)) + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_a7xx,4 ); +else if (is_a7xx) ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_a7xx,1 );else if (adreno_has_gmu_wrapper (adreno_gpu)) ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_gmuwrapper,1 );
Signature · 1 line
2.46.0
Re: [PATCH v2 9/9] drm/msm/A6xx: Enable preemption for A750
Quoted 16 lines · Antonino Maniscalco
Initialize with 4 rings to enable preemption.
For now only on A750 as other targets require testing.
Signed-off-by Antonino Maniscalco <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0
drivers/gpu/drm/msm/adreno/a6xx_gpu.c struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) · line 2613
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2
-1@@ -2609,7 +2609,9 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)return ERR_PTR (ret); } -if (is_a7xx) +if (adreno_is_a750 (adreno_gpu)) + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_a7xx,4 );
perhaps it would be useful (to enable others to more easily test), to allow this to be overridden with a modparam.. something like
if ((enable_preemption == 1) || (enable_preemption == -1 &&
(config->info->quirks & ADRENO_QUIRK_PREEMPTION))
That would allow overriding enable_preemption to 1 or 0 on cmdline to force enable/disable preemption.
That plus some instructions about how to test preemption (ie. what deqp tests to run, or similar) would make it easier to "crowd source" the testing (assuming you don't have every a7xx device there is)
BR,
-R
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-1+else if (is_a7xx) ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_a7xx,1 );else if (adreno_has_gmu_wrapper (adreno_gpu)) ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs_gmuwrapper,1 ); --2.46.0