gpu: nvgpu: add linux MAPPING_MODIFY ioctl

Add new MAPPING_MODIFY ioctl to the linux nvgpu driver.

This ioctl is used (for example) by the NvRmGpuMappingModify API to
change the kind of an existing mapping.

For compressed mappings the ioctl can be used to do the following:

 * switch between two different compressed kinds
 * switch between compressed and incompressed kinds

For incompressed mappings the ioctl can be used to do the following:

 * switch between two different incompressed kinds

In order to properly update an existing mapping the nvgpu_mapped_buf
structure has been extended to cache the following state when the
mapping is first created:

 * the compression tag offset (if applicable)
 * the GMMU read/write flags
 * the memory aperture

The unused ctag_lines field in the nvgpu_ctag_buffer_info structure
has been replaced with a new ctag_offset field.

Jira NVGPU-6374

Change-Id: I647ab9c2c272e3f9b52f1ccefc5e0de4577c14f1
Signed-off-by: scottl <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2468100
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
scottl
2021-01-08 14:44:25 -08:00
committed by mobile promotions
parent 47f2e68013
commit 456a814db5
6 changed files with 208 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -51,7 +51,7 @@ struct nvgpu_ctag_buffer_info {
#endif
s16 incompr_kind;
u32 ctag_lines;
u32 ctag_offset;
};
#ifdef CONFIG_NVGPU_COMPRESSION
@@ -1292,6 +1292,7 @@ static int nvgpu_vm_do_map(struct vm_gk20a *vm,
nvgpu_assert((binfo_ptr->compr_kind >= 0) &&
(binfo_ptr->compr_kind <= (s16)U8_MAX));
pte_kind = (u8)binfo_ptr->compr_kind;
binfo_ptr->ctag_offset = ctag_offset;
} else
#endif
if (binfo_ptr->incompr_kind != NVGPU_KIND_INVALID) {
@@ -1540,6 +1541,9 @@ int nvgpu_vm_map(struct vm_gk20a *vm,
mapped_buffer->kind = map_key_kind;
mapped_buffer->va_allocated = va_allocated;
mapped_buffer->vm_area = vm_area;
mapped_buffer->ctag_offset = binfo.ctag_offset;
mapped_buffer->rw_flag = rw;
mapped_buffer->aperture = aperture;
nvgpu_insert_mapped_buf(vm, mapped_buffer);