Skip to content

Commit 37dc473

Browse files
committed
drm/etnaviv: hold GPU lock across perfmon sampling
The perfmon sampling mutates shared GPU state (e.g. VIVS_HI_CLOCK_CONTROL to select the pipe for the perf counter reads). To avoid clashing with other functions mutating the same state (e.g. etnaviv_gpu_update_clock) the perfmon sampling needs to hold the GPU lock. Fixes: 68dc0b2 ("drm/etnaviv: use 'sync points' for performance monitor requests") Reviewed-by: Christian Gmeiner <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 72dc70a commit 37dc473

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,8 @@ static void sync_point_perfmon_sample_pre(struct etnaviv_gpu *gpu,
13221322
{
13231323
u32 val;
13241324

1325+
mutex_lock(&gpu->lock);
1326+
13251327
/* disable clock gating */
13261328
val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS);
13271329
val &= ~VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
@@ -1333,6 +1335,8 @@ static void sync_point_perfmon_sample_pre(struct etnaviv_gpu *gpu,
13331335
gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, val);
13341336

13351337
sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_PRE);
1338+
1339+
mutex_unlock(&gpu->lock);
13361340
}
13371341

13381342
static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
@@ -1342,13 +1346,9 @@ static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
13421346
unsigned int i;
13431347
u32 val;
13441348

1345-
sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_POST);
1346-
1347-
for (i = 0; i < submit->nr_pmrs; i++) {
1348-
const struct etnaviv_perfmon_request *pmr = submit->pmrs + i;
1349+
mutex_lock(&gpu->lock);
13491350

1350-
*pmr->bo_vma = pmr->sequence;
1351-
}
1351+
sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_POST);
13521352

13531353
/* disable debug register */
13541354
val = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
@@ -1359,6 +1359,14 @@ static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
13591359
val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS);
13601360
val |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
13611361
gpu_write_power(gpu, VIVS_PM_POWER_CONTROLS, val);
1362+
1363+
mutex_unlock(&gpu->lock);
1364+
1365+
for (i = 0; i < submit->nr_pmrs; i++) {
1366+
const struct etnaviv_perfmon_request *pmr = submit->pmrs + i;
1367+
1368+
*pmr->bo_vma = pmr->sequence;
1369+
}
13621370
}
13631371

13641372

0 commit comments

Comments
 (0)