Skip to content

Commit 111fdd2

Browse files
robclarkRob Clark
authored andcommitted
drm/msm: drm_gpuvm conversion
Now that we've realigned deletion and allocation, switch over to using drm_gpuvm/drm_gpuva. This allows us to support multiple VMAs per BO per VM, to allow mapping different parts of a single BO at different virtual addresses, which is a key requirement for sparse/VM_BIND. This prepares us for using drm_gpuvm to translate a batch of MAP/ MAP_NULL/UNMAP operations from userspace into a sequence of map/remap/ unmap steps for updating the page tables. Since, unlike our prior vm/vma setup, with drm_gpuvm the vm_bo holds a reference to the GEM object. To prevent reference loops causing us to leak all GEM objects, we implicitly tear down the mapping when the GEM handle is close or when the obj is unpinned. Which means the submit needs to also hold a reference to the vm_bo, to prevent the VMA from being torn down while the submit is in-flight. Signed-off-by: Rob Clark <[email protected]> Signed-off-by: Rob Clark <[email protected]> Tested-by: Antonino Maniscalco <[email protected]> Reviewed-by: Antonino Maniscalco <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/661479/
1 parent 8ac37c8 commit 111fdd2

File tree

12 files changed

+303
-138
lines changed

12 files changed

+303
-138
lines changed

drivers/gpu/drm/msm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ config DRM_MSM
2121
select DRM_DISPLAY_HELPER
2222
select DRM_BRIDGE_CONNECTOR
2323
select DRM_EXEC
24+
select DRM_GPUVM
2425
select DRM_KMS_HELPER
2526
select DRM_PANEL
2627
select DRM_BRIDGE

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ a2xx_create_vm(struct msm_gpu *gpu, struct platform_device *pdev)
472472
struct msm_mmu *mmu = a2xx_gpummu_new(&pdev->dev, gpu);
473473
struct msm_gem_vm *vm;
474474

475-
vm = msm_gem_vm_create(mmu, "gpu", SZ_16M,
476-
0xfff * SZ_64K);
475+
vm = msm_gem_vm_create(gpu->dev, mmu, "gpu", SZ_16M, 0xfff * SZ_64K, true);
477476

478477
if (IS_ERR(vm) && !IS_ERR(mmu))
479478
mmu->funcs->destroy(mmu);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ static int a6xx_gmu_memory_alloc(struct a6xx_gmu *gmu, struct a6xx_gmu_bo *bo,
13111311
return 0;
13121312
}
13131313

1314-
static int a6xx_gmu_memory_probe(struct a6xx_gmu *gmu)
1314+
static int a6xx_gmu_memory_probe(struct drm_device *drm, struct a6xx_gmu *gmu)
13151315
{
13161316
struct msm_mmu *mmu;
13171317

@@ -1321,7 +1321,7 @@ static int a6xx_gmu_memory_probe(struct a6xx_gmu *gmu)
13211321
if (IS_ERR(mmu))
13221322
return PTR_ERR(mmu);
13231323

1324-
gmu->vm = msm_gem_vm_create(mmu, "gmu", 0x0, 0x80000000);
1324+
gmu->vm = msm_gem_vm_create(drm, mmu, "gmu", 0x0, 0x80000000, true);
13251325
if (IS_ERR(gmu->vm))
13261326
return PTR_ERR(gmu->vm);
13271327

@@ -1940,7 +1940,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
19401940
if (ret)
19411941
goto err_put_device;
19421942

1943-
ret = a6xx_gmu_memory_probe(gmu);
1943+
ret = a6xx_gmu_memory_probe(adreno_gpu->base.dev, gmu);
19441944
if (ret)
19451945
goto err_put_device;
19461946

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,9 +2284,8 @@ a6xx_create_private_vm(struct msm_gpu *gpu)
22842284
if (IS_ERR(mmu))
22852285
return ERR_CAST(mmu);
22862286

2287-
return msm_gem_vm_create(mmu,
2288-
"gpu", ADRENO_VM_START,
2289-
adreno_private_vm_size(gpu));
2287+
return msm_gem_vm_create(gpu->dev, mmu, "gpu", ADRENO_VM_START,
2288+
adreno_private_vm_size(gpu), true);
22902289
}
22912290

22922291
static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ adreno_iommu_create_vm(struct msm_gpu *gpu,
226226
start = max_t(u64, SZ_16M, geometry->aperture_start);
227227
size = geometry->aperture_end - start + 1;
228228

229-
vm = msm_gem_vm_create(mmu, "gpu", start & GENMASK_ULL(48, 0), size);
229+
vm = msm_gem_vm_create(gpu->dev, mmu, "gpu", start & GENMASK_ULL(48, 0),
230+
size, true);
230231

231232
if (IS_ERR(vm) && !IS_ERR(mmu))
232233
mmu->funcs->destroy(mmu);
@@ -414,12 +415,12 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
414415
case MSM_PARAM_VA_START:
415416
if (ctx->vm == gpu->vm)
416417
return UERR(EINVAL, drm, "requires per-process pgtables");
417-
*value = ctx->vm->va_start;
418+
*value = ctx->vm->base.mm_start;
418419
return 0;
419420
case MSM_PARAM_VA_SIZE:
420421
if (ctx->vm == gpu->vm)
421422
return UERR(EINVAL, drm, "requires per-process pgtables");
422-
*value = ctx->vm->va_size;
423+
*value = ctx->vm->base.mm_range;
423424
return 0;
424425
case MSM_PARAM_HIGHEST_BANK_BIT:
425426
*value = adreno_gpu->ubwc_config.highest_bank_bit;

drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,9 @@ static int mdp4_kms_init(struct drm_device *dev)
469469
"contig buffers for scanout\n");
470470
vm = NULL;
471471
} else {
472-
vm = msm_gem_vm_create(mmu,
473-
"mdp4", 0x1000, 0x100000000 - 0x1000);
472+
vm = msm_gem_vm_create(dev, mmu, "mdp4",
473+
0x1000, 0x100000000 - 0x1000,
474+
true);
474475

475476
if (IS_ERR(vm)) {
476477
if (!IS_ERR(mmu))

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ static const struct file_operations fops = {
787787

788788
static const struct drm_driver msm_driver = {
789789
.driver_features = DRIVER_GEM |
790+
DRIVER_GEM_GPUVA |
790791
DRIVER_RENDER |
791792
DRIVER_ATOMIC |
792793
DRIVER_MODESET |

0 commit comments

Comments
 (0)