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

Configure Feed

Select the types of activity you want to include in your feed.

drm/msm: Add VMA unmap reason

Make the VM log a bit more useful by providing a reason for the unmap
(ie. closing VM vs evict/purge, etc)

Signed-off-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Tested-by: Antonino Maniscalco <antomani103@gmail.com>
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/661527/

authored by

Rob Clark and committed by
Rob Clark
0b4339c5 9edc5296

+24 -13
+11 -9
drivers/gpu/drm/msm/msm_gem.c
··· 43 43 return 0; 44 44 } 45 45 46 - static void put_iova_spaces(struct drm_gem_object *obj, struct drm_gpuvm *vm, bool close); 46 + static void put_iova_spaces(struct drm_gem_object *obj, struct drm_gpuvm *vm, 47 + bool close, const char *reason); 47 48 48 49 static void detach_vm(struct drm_gem_object *obj, struct drm_gpuvm *vm) 49 50 { ··· 58 57 drm_gpuvm_bo_for_each_va (vma, vm_bo) { 59 58 if (vma->vm != vm) 60 59 continue; 61 - msm_gem_vma_unmap(vma); 60 + msm_gem_vma_unmap(vma, "detach"); 62 61 msm_gem_vma_close(vma); 63 62 break; 64 63 } ··· 98 97 MAX_SCHEDULE_TIMEOUT); 99 98 100 99 msm_gem_lock_vm_and_obj(&exec, obj, ctx->vm); 101 - put_iova_spaces(obj, ctx->vm, true); 100 + put_iova_spaces(obj, ctx->vm, true, "close"); 102 101 detach_vm(obj, ctx->vm); 103 102 drm_exec_fini(&exec); /* drop locks */ 104 103 } ··· 426 425 * mapping. 427 426 */ 428 427 static void 429 - put_iova_spaces(struct drm_gem_object *obj, struct drm_gpuvm *vm, bool close) 428 + put_iova_spaces(struct drm_gem_object *obj, struct drm_gpuvm *vm, 429 + bool close, const char *reason) 430 430 { 431 431 struct drm_gpuvm_bo *vm_bo, *tmp; 432 432 ··· 442 440 drm_gpuvm_bo_get(vm_bo); 443 441 444 442 drm_gpuvm_bo_for_each_va_safe (vma, vmatmp, vm_bo) { 445 - msm_gem_vma_unmap(vma); 443 + msm_gem_vma_unmap(vma, reason); 446 444 if (close) 447 445 msm_gem_vma_close(vma); 448 446 } ··· 619 617 if (!vma) 620 618 return 0; 621 619 622 - msm_gem_vma_unmap(vma); 620 + msm_gem_vma_unmap(vma, NULL); 623 621 msm_gem_vma_close(vma); 624 622 625 623 return 0; ··· 831 829 GEM_WARN_ON(!is_purgeable(msm_obj)); 832 830 833 831 /* Get rid of any iommu mapping(s): */ 834 - put_iova_spaces(obj, NULL, false); 832 + put_iova_spaces(obj, NULL, false, "purge"); 835 833 836 834 msm_gem_vunmap(obj); 837 835 ··· 869 867 GEM_WARN_ON(is_unevictable(msm_obj)); 870 868 871 869 /* Get rid of any iommu mapping(s): */ 872 - put_iova_spaces(obj, NULL, false); 870 + put_iova_spaces(obj, NULL, false, "evict"); 873 871 874 872 drm_vma_node_unmap(&obj->vma_node, dev->anon_inode->i_mapping); 875 873 ··· 1081 1079 drm_exec_retry_on_contention(&exec); 1082 1080 } 1083 1081 } 1084 - put_iova_spaces(obj, NULL, true); 1082 + put_iova_spaces(obj, NULL, true, "free"); 1085 1083 drm_exec_fini(&exec); /* drop locks */ 1086 1084 } 1087 1085
+1 -1
drivers/gpu/drm/msm/msm_gem.h
··· 168 168 struct drm_gpuva * 169 169 msm_gem_vma_new(struct drm_gpuvm *vm, struct drm_gem_object *obj, 170 170 u64 offset, u64 range_start, u64 range_end); 171 - void msm_gem_vma_unmap(struct drm_gpuva *vma); 171 + void msm_gem_vma_unmap(struct drm_gpuva *vma, const char *reason); 172 172 int msm_gem_vma_map(struct drm_gpuva *vma, int prot, struct sg_table *sgt); 173 173 void msm_gem_vma_close(struct drm_gpuva *vma); 174 174
+12 -3
drivers/gpu/drm/msm/msm_gem_vma.c
··· 53 53 /** @range: size of region to unmap */ 54 54 uint64_t range; 55 55 56 + /** @reason: The reason for the unmap */ 57 + const char *reason; 58 + 56 59 /** 57 60 * @queue_id: The id of the submitqueue the operation is performed 58 61 * on, or zero for (in particular) UNMAP ops triggered outside of ··· 245 242 static void 246 243 vm_unmap_op(struct msm_gem_vm *vm, const struct msm_vm_unmap_op *op) 247 244 { 248 - vm_log(vm, "unmap", op->iova, op->range, op->queue_id); 245 + const char *reason = op->reason; 246 + 247 + if (!reason) 248 + reason = "unmap"; 249 + 250 + vm_log(vm, reason, op->iova, op->range, op->queue_id); 249 251 250 252 vm->mmu->funcs->unmap(vm->mmu, op->iova, op->range); 251 253 } ··· 265 257 } 266 258 267 259 /* Actually unmap memory for the vma */ 268 - void msm_gem_vma_unmap(struct drm_gpuva *vma) 260 + void msm_gem_vma_unmap(struct drm_gpuva *vma, const char *reason) 269 261 { 270 262 struct msm_gem_vm *vm = to_msm_vm(vma->vm); 271 263 struct msm_gem_vma *msm_vma = to_msm_vma(vma); ··· 285 277 vm_unmap_op(vm, &(struct msm_vm_unmap_op){ 286 278 .iova = vma->va.addr, 287 279 .range = vma->va.range, 280 + .reason = reason, 288 281 }); 289 282 290 283 if (!vm->managed) ··· 872 863 drm_exec_retry_on_contention(&exec); 873 864 } 874 865 875 - msm_gem_vma_unmap(vma); 866 + msm_gem_vma_unmap(vma, "close"); 876 867 msm_gem_vma_close(vma); 877 868 878 869 if (obj) {