diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-10-17 13:55:00 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-01 22:06:23 -0400 |
commit | d13c256d5ee11da1664377481543005142d9bd30 (patch) | |
tree | e00ef697d05a20428619c8920ddfcb645fc095d8 /drivers/gpu/nvgpu/include | |
parent | a37cec19f0cf5212cbd472cd8d94acaa1e1cff6d (diff) |
gpu: nvgpu: VM unmap refactoring
Re-organize the unmap code to be better split between OS specific
requirements and common core requirements. The new code flow works
as follows:
nvgpu_vm_unmap()
Is the primary entrance to the unmap path. It takes a VM and a GPU
virtual address to unmap. There's also an optional batch mapping
struct.
This function is responsible for making sure there is a real buffer
and that if it's being called on a fixed mapping then the mapping
will definitely be freed (since buffers are ref-counted). Then this
function decrements the ref-count and returns.
If the ref-count hits zero then __nvgpu_vm_unmap_ref() is called
which just calls __nvgpu_vm_unmap() with the relevant batch struct
if present. This is where the real work is done. __nvgpu_vm_unmap()
clears the GMMU mapping, removes the mapped buffer from the various
lists and trees it may be in and then calls the
nvgpu_vm_unmap_system() function. This function handles any OS
specific stuff and must be defined by all VM OS implementations.
There's a a short cut used by some other core VM code to free
mappings without going through nvgpu_vm_map(). Mostly they just
directly decrement the mapping ref-count which can then call
__nvgpu_vm_unmap_ref() if the ref-count hits zero.
JIRA NVGPU-30
JIRA NVGPU-71
Change-Id: Ic626d37ab936819841bab45214f027b40ffa4e5a
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1583982
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/linux/vm.h | 4 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vm.h | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h index 7aacf496..3d9f9ea6 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h | |||
@@ -98,10 +98,6 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm, | |||
98 | u64 mapping_size, | 98 | u64 mapping_size, |
99 | struct vm_gk20a_mapping_batch *batch); | 99 | struct vm_gk20a_mapping_batch *batch); |
100 | 100 | ||
101 | /* Note: batch may be NULL if unmap op is not part of a batch */ | ||
102 | int nvgpu_vm_unmap_buffer(struct vm_gk20a *vm, u64 offset, | ||
103 | struct vm_gk20a_mapping_batch *batch); | ||
104 | |||
105 | /* find buffer corresponding to va */ | 101 | /* find buffer corresponding to va */ |
106 | int nvgpu_vm_find_buf(struct vm_gk20a *vm, u64 gpu_va, | 102 | int nvgpu_vm_find_buf(struct vm_gk20a *vm, u64 gpu_va, |
107 | struct dma_buf **dmabuf, | 103 | struct dma_buf **dmabuf, |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index e529512b..84c7e0c7 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h | |||
@@ -207,11 +207,19 @@ void nvgpu_vm_put_buffers(struct vm_gk20a *vm, | |||
207 | struct nvgpu_mapped_buf **mapped_buffers, | 207 | struct nvgpu_mapped_buf **mapped_buffers, |
208 | int num_buffers); | 208 | int num_buffers); |
209 | 209 | ||
210 | void nvgpu_vm_unmap_locked(struct nvgpu_mapped_buf *mapped_buffer, | 210 | void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset, |
211 | struct vm_gk20a_mapping_batch *batch); | 211 | struct vm_gk20a_mapping_batch *batch); |
212 | void nvgpu_vm_unmap_locked_ref(struct nvgpu_ref *ref); | ||
213 | 212 | ||
214 | void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset); | 213 | /* |
214 | * Implemented by each OS. Called from within the core VM code to handle OS | ||
215 | * specific components of an nvgpu_mapped_buf. | ||
216 | */ | ||
217 | void nvgpu_vm_unmap_system(struct nvgpu_mapped_buf *mapped_buffer); | ||
218 | |||
219 | /* | ||
220 | * Don't use this outside of the core VM code! | ||
221 | */ | ||
222 | void __nvgpu_vm_unmap_ref(struct nvgpu_ref *ref); | ||
215 | 223 | ||
216 | /* | 224 | /* |
217 | * These all require the VM update lock to be held. | 225 | * These all require the VM update lock to be held. |