From 5d09c908b0679f060bc89ae70eef681a6783ebbc Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Tue, 22 Aug 2017 16:14:56 +0300 Subject: gpu: nvgpu: Direct GMMU PTE kind control Allow userspace to control directly the PTE kind for the mappings by supplying NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL for MAP_BUFFER_EX. In particular, in this mode, the userspace will tell the kernel whether the kind is compressible, and if so, what is the incompressible fallback kind. By supplying only the compressible kind, the userspace can require that the map kind will not be demoted to the incompressible fallback kind in case of comptag allocation failure. Add also a GPU characteristics flag NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL to signal whether direct kind control is supported. Fix indentation of nvgpu_as_map_buffer_ex_args header comment. Bug 1705731 Change-Id: I317ab474ae53b78eb8fdd31bd6bca0541fcba9a4 Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1543462 Reviewed-by: svc-mobile-coverity Reviewed-by: Konsta Holtta Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: svccoveritychecker Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/ioctl_as.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_as.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_as.c b/drivers/gpu/nvgpu/common/linux/ioctl_as.c index d4242955..cfc4e7ef 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_as.c @@ -79,11 +79,22 @@ static int gk20a_as_ioctl_map_buffer_ex( struct gk20a_as_share *as_share, struct nvgpu_as_map_buffer_ex_args *args) { + s16 compressible_kind; + s16 incompressible_kind; + gk20a_dbg_fn(""); + if (args->flags & NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL) { + compressible_kind = args->compr_kind; + incompressible_kind = args->incompr_kind; + } else { + compressible_kind = args->kind; + incompressible_kind = NV_KIND_INVALID; + } + return nvgpu_vm_map_buffer(as_share->vm, args->dmabuf_fd, &args->offset, args->flags, - args->kind, + compressible_kind, incompressible_kind, args->buffer_offset, args->mapping_size, NULL); @@ -97,6 +108,7 @@ static int gk20a_as_ioctl_map_buffer( return nvgpu_vm_map_buffer(as_share->vm, args->dmabuf_fd, &args->o_a.offset, args->flags, NV_KIND_DEFAULT, + NV_KIND_DEFAULT, 0, 0, NULL); /* args->o_a.offset will be set if !err */ } @@ -158,6 +170,9 @@ static int gk20a_as_ioctl_map_buffer_batch( } for (i = 0; i < args->num_maps; ++i) { + s16 compressible_kind; + s16 incompressible_kind; + struct nvgpu_as_map_buffer_ex_args map_args; memset(&map_args, 0, sizeof(map_args)); @@ -167,10 +182,19 @@ static int gk20a_as_ioctl_map_buffer_batch( break; } + if (map_args.flags & + NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL) { + compressible_kind = map_args.compr_kind; + incompressible_kind = map_args.incompr_kind; + } else { + compressible_kind = map_args.kind; + incompressible_kind = NV_KIND_INVALID; + } + err = nvgpu_vm_map_buffer( as_share->vm, map_args.dmabuf_fd, &map_args.offset, map_args.flags, - map_args.kind, + compressible_kind, incompressible_kind, map_args.buffer_offset, map_args.mapping_size, &batch); -- cgit v1.2.2