From 90d388ebf8d2f9f9d08f6a5c0f638aa8339c1f24 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 28 Jun 2017 17:30:46 -0700 Subject: gpu: nvgpu: Add get/set PTE routines Add new routines for accessing and modifying PTEs in situ. They are: __nvgpu_pte_words() __nvgpu_get_pte() __nvgpu_set_pte() All the details of modifying a page table entry are handled within. Note, however, that these routines will not build page tables. If a PTE does not exist then said PTE will not be created. Instead -EINVAL will be returned. But, keep in mind, a PTE marked as invalid still exists. So this API can be used to mark an invalid PTE valid. JIRA NVGPU-30 Change-Id: Ic8615f209a0c4eb6fa64af9abadcfb3b2c11ee73 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1510447 Reviewed-by: Automatic_Commit_Validation_User Tested-by: Seema Khowala Reviewed-by: Seema Khowala GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/include/nvgpu/gmmu.h | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 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 92e5eb5f..de129a5f 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gmmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gmmu.h @@ -273,6 +273,56 @@ static inline void pd_write(struct gk20a *g, struct nvgpu_gmmu_pd *pd, nvgpu_mem_wr32(g, pd->mem, (pd->mem_offs / sizeof(u32)) + w, data); } +/** + * __nvgpu_pte_words - Compute number of words in a PTE. + * + * @g - The GPU. + * + * This computes and returns the size of a PTE for the passed chip. + */ +u32 __nvgpu_pte_words(struct gk20a *g); + +/** + * __nvgpu_get_pte - Get the contents of a PTE by virtual address + * + * @g - The GPU. + * @vm - VM to look in. + * @vaddr - GPU virtual address. + * @pte - [out] Set to the contents of the PTE. + * + * Find a PTE in the passed VM based on the passed GPU virtual address. This + * will @pte with a copy of the contents of the PTE. @pte must be an array of + * u32s large enough to contain the PTE. This can be computed using + * __nvgpu_pte_words(). + * + * If you wish to write to this PTE then you may modify @pte and then use the + * __nvgpu_set_pte(). + * + * This function returns 0 if the PTE is found and -EINVAL otherwise. + */ +int __nvgpu_get_pte(struct gk20a *g, struct vm_gk20a *vm, u64 vaddr, u32 *pte); + +/** + * __nvgpu_set_pte - Set a PTE based on virtual address + * + * @g - The GPU. + * @vm - VM to look in. + * @vaddr - GPU virtual address. + * @pte - The contents of the PTE to write. + * + * Find a PTE and overwrite the contents of that PTE with the passed in data + * located in @pte. If the PTE does not exist then no writing will happen. That + * is this function will not fill out the page tables for you. The expectation + * is that the passed @vaddr has already been mapped and this is just modifying + * the mapping (for instance changing invalid to valid). + * + * @pte must contain at least the required words for the PTE. See + * __nvgpu_pte_words(). + * + * This function returns 0 on success and -EINVAL otherwise. + */ +int __nvgpu_set_pte(struct gk20a *g, struct vm_gk20a *vm, u64 vaddr, u32 *pte); + /* * Internal debugging routines. Probably not something you want to use. -- cgit v1.2.2