Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 68dc0b295dcb ("drm/etnaviv: use 'sync points' for performance monitor requests")
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

+14 -6
+14 -6
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
··· 1322 1322 { 1323 1323 u32 val; 1324 1324 1325 + mutex_lock(&gpu->lock); 1326 + 1325 1327 /* disable clock gating */ 1326 1328 val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS); 1327 1329 val &= ~VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING; ··· 1335 1333 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, val); 1336 1334 1337 1335 sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_PRE); 1336 + 1337 + mutex_unlock(&gpu->lock); 1338 1338 } 1339 1339 1340 1340 static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu, ··· 1346 1342 unsigned int i; 1347 1343 u32 val; 1348 1344 1345 + mutex_lock(&gpu->lock); 1346 + 1349 1347 sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_POST); 1350 - 1351 - for (i = 0; i < submit->nr_pmrs; i++) { 1352 - const struct etnaviv_perfmon_request *pmr = submit->pmrs + i; 1353 - 1354 - *pmr->bo_vma = pmr->sequence; 1355 - } 1356 1348 1357 1349 /* disable debug register */ 1358 1350 val = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL); ··· 1359 1359 val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS); 1360 1360 val |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING; 1361 1361 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 + } 1362 1370 } 1363 1371 1364 1372