From 563955aead6be2526472c5a68cd1fc7446b217a5 Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Mon, 14 Oct 2019 12:04:01 -0400 Subject: [PATCH] gpu: nvgpu: posix: improve nvgpu_vm_find_mapping for testing The nvgpu_vm_find_mapping API was always returning NULL. For test purposes, this new implementation is similar to the one in use for Linux. JIRA NVGPU-909 Change-Id: Id311fe367ddfb1539fecd86fae4bb3a8f2d91491 Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/2217678 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/posix-vm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/os/posix/posix-vm.c b/drivers/gpu/nvgpu/os/posix/posix-vm.c index d2e0b8b2b..5dce48648 100644 --- a/drivers/gpu/nvgpu/os/posix/posix-vm.c +++ b/drivers/gpu/nvgpu/os/posix/posix-vm.c @@ -38,10 +38,18 @@ struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, u32 flags, s16 kind) { - /* - * No map caching for now. - */ - return NULL; + struct nvgpu_mapped_buf *mapped_buffer = NULL; + + mapped_buffer = nvgpu_vm_find_mapped_buf(vm, map_addr); + if (mapped_buffer == NULL) { + return NULL; + } + + if (mapped_buffer->flags != flags) { + return NULL; + } + + return mapped_buffer; } void nvgpu_vm_unmap_system(struct nvgpu_mapped_buf *mapped_buffer)