From ee26a2842ca891d3ae8b1de1b066d29234fc0115 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 24 May 2022 21:11:59 -0400 Subject: gpu-paging: Initial working implementation Supports synchronous page out or in of a specific buffer. Includes fast reverse struct mapped_buf lookup. Requires initial set of changes to nvmap as well. --- drivers/gpu/nvgpu/include/nvgpu/gmmu.h | 17 +++++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/linux/vm.h | 2 ++ drivers/gpu/nvgpu/include/nvgpu/vm.h | 2 ++ 3 files changed, 21 insertions(+) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/gmmu.h b/drivers/gpu/nvgpu/include/nvgpu/gmmu.h index 2fc0d44e..81f829ed 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gmmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gmmu.h @@ -354,6 +354,23 @@ int __nvgpu_get_pte(struct gk20a *g, struct vm_gk20a *vm, u64 vaddr, u32 *pte); */ int __nvgpu_set_pte(struct gk20a *g, struct vm_gk20a *vm, u64 vaddr, u32 *pte); +/** + * __nvgpu_update_paddr - Remap a virtual address to a new physical address + * + * @g - The GPU. + * @vm - VM to look in. + * @vaddr - GPU virtual address. + * @paddr - The new physical address to map to + * + * This function is a combination of __nvgpu_get_pte() and __nvgpu_set_pte(). + * It searches for an existing PTE associated with @vaddr, and then updates + * only the physical address pointed to in the PTE to @paddr. All other + * attributes/fields of the PTE are preserved. + * + * This function returns the number of bytes mapped on success and -EINVAL + * otherwise. + */ +int __nvgpu_update_paddr(struct gk20a *g, struct vm_gk20a *vm, u64 vaddr, u64 paddr); /* * Internal debugging routines. Probably not something you want to use. diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h index 6f3beaa9..b86a428a 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h @@ -49,6 +49,8 @@ struct nvgpu_mapped_buf_priv { struct dma_buf *dmabuf; struct dma_buf_attachment *attachment; struct sg_table *sgt; + // For fast reverse lookup (FD -> mapped_buf) + struct list_head nvmap_priv_entry; }; /* NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL must be set */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index 3867c745..f007d880 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h @@ -261,6 +261,8 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, struct vm_gk20a_mapping_batch *batch, enum nvgpu_aperture aperture); +void nvgpu_vm_remap(struct nvgpu_mapped_buf *m); + void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset, struct vm_gk20a_mapping_batch *batch); -- cgit v1.2.2