Skip to content

Commit 5f9ffe8

Browse files
committed
drm/msm/a6xx: Zap counters across context switch
Any app controlled perfcntr collection (GL_AMD_performance_monitor, etc) does not require counters to maintain state across context switches. So clear them if systemwide profiling is not active. Signed-off-by: Rob Clark <robdclark@chromium.org> Link: https://lore.kernel.org/r/20220304005317.776110-5-robdclark@gmail.com
1 parent 90f45c4 commit 5f9ffe8

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter,
101101
static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,
102102
struct msm_ringbuffer *ring, struct msm_file_private *ctx)
103103
{
104+
bool sysprof = refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1;
104105
phys_addr_t ttbr;
105106
u32 asid;
106107
u64 memptr = rbmemptr(ring, ttbr0);
@@ -111,6 +112,15 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,
111112
if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid))
112113
return;
113114

115+
if (!sysprof) {
116+
/* Turn off protected mode to write to special registers */
117+
OUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1);
118+
OUT_RING(ring, 0);
119+
120+
OUT_PKT4(ring, REG_A6XX_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
121+
OUT_RING(ring, 1);
122+
}
123+
114124
/* Execute the table update */
115125
OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4);
116126
OUT_RING(ring, CP_SMMU_TABLE_UPDATE_0_TTBR0_LO(lower_32_bits(ttbr)));
@@ -137,6 +147,25 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,
137147

138148
OUT_PKT7(ring, CP_EVENT_WRITE, 1);
139149
OUT_RING(ring, 0x31);
150+
151+
if (!sysprof) {
152+
/*
153+
* Wait for SRAM clear after the pgtable update, so the
154+
* two can happen in parallel:
155+
*/
156+
OUT_PKT7(ring, CP_WAIT_REG_MEM, 6);
157+
OUT_RING(ring, CP_WAIT_REG_MEM_0_FUNCTION(WRITE_EQ));
158+
OUT_RING(ring, CP_WAIT_REG_MEM_1_POLL_ADDR_LO(
159+
REG_A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS));
160+
OUT_RING(ring, CP_WAIT_REG_MEM_2_POLL_ADDR_HI(0));
161+
OUT_RING(ring, CP_WAIT_REG_MEM_3_REF(0x1));
162+
OUT_RING(ring, CP_WAIT_REG_MEM_4_MASK(0x1));
163+
OUT_RING(ring, CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES(0));
164+
165+
/* Re-enable protected mode: */
166+
OUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1);
167+
OUT_RING(ring, 1);
168+
}
140169
}
141170

142171
static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)

0 commit comments

Comments
 (0)