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

drm/etnaviv: reinstate MMUv1 command buffer window check

The switch to per-process address spaces erroneously dropped the check
which validated that the command buffer is mapped through the linear
apperture as required by the hardware. This turned a system
misconfiguration with a helpful error message into a very hard to
debug issue. Reinstate the check at the appropriate location.

Fixes: 17e4660ae3d7 (drm/etnaviv: implement per-process address spaces on MMUv2)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Guido Günther <agx@sigxcpu.org>

+14 -3
+14 -3
drivers/gpu/drm/etnaviv/etnaviv_mmu.c
··· 328 328 329 329 ret = etnaviv_cmdbuf_suballoc_map(suballoc, ctx, &ctx->cmdbuf_mapping, 330 330 global->memory_base); 331 - if (ret) { 332 - global->ops->free(ctx); 333 - return NULL; 331 + if (ret) 332 + goto out_free; 333 + 334 + if (global->version == ETNAVIV_IOMMU_V1 && 335 + ctx->cmdbuf_mapping.iova > 0x80000000) { 336 + dev_err(global->dev, 337 + "command buffer outside valid memory window\n"); 338 + goto out_unmap; 334 339 } 335 340 336 341 return ctx; 342 + 343 + out_unmap: 344 + etnaviv_cmdbuf_suballoc_unmap(ctx, &ctx->cmdbuf_mapping); 345 + out_free: 346 + global->ops->free(ctx); 347 + return NULL; 337 348 } 338 349 339 350 void etnaviv_iommu_restore(struct etnaviv_gpu *gpu,