From 6eebc87d99f9f04b2b68e0bc0142c161ab3e669d Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Thu, 12 May 2016 09:32:05 +0300 Subject: gpu: nvgpu: refactor gk20a_mem_{wr,rd} for vidmem To support vidmem, pass g and mem_desc to the buffer memory accessor functions. This allows the functions to select the memory access method based on the buffer aperture instead of using the cpu pointer directly (like until now). The selection and aperture support will be in another patch; this patch only refactors these accessors, but keeps the underlying functionality as-is. gk20a_mem_{rd,wr}32() work as previously; add also gk20a_mem_{rd,wr}() for byte-indexed accesses, gk20a_mem_{rd,wr}_n() for memcpy()-like functionality, and gk20a_memset() for filling buffers with a constant. The 8 and 16 bit accessor functions are removed. vmap()/vunmap() pairs are abstracted to gk20a_mem_{begin,end}() to support other types of mappings or conditions where mapping the buffer is unnecessary or different. Several function arguments that would access these buffers are also changed to take a mem_desc instead of a plain cpu pointer. Some relevant occasions are changed to use the accessor functions instead of cpu pointers without them (e.g., memcpying to and from), but the majority of direct accesses will be adjusted later, when the buffers are moved to support vidmem. JIRA DNVGPU-23 Change-Id: I3dd22e14290c4ab742d42e2dd327ebeb5cd3f25a Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/1121143 Reviewed-by: Ken Adams Tested-by: Ken Adams --- drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.h') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index 7fa0b7fb..e9ac8f18 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h @@ -419,6 +419,34 @@ static inline enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm, return gmmu_page_size_small; } +/* + * Buffer accessors - wrap between begin() and end() if there is no permanent + * kernel mapping for this buffer. + */ + +int gk20a_mem_begin(struct gk20a *g, struct mem_desc *mem); +/* nop for null mem, like with free() or vunmap() */ +void gk20a_mem_end(struct gk20a *g, struct mem_desc *mem); + +/* word-indexed offset */ +u32 gk20a_mem_rd32(struct gk20a *g, struct mem_desc *mem, u32 w); +/* byte offset (32b-aligned) */ +u32 gk20a_mem_rd(struct gk20a *g, struct mem_desc *mem, u32 offset); +/* memcpy to cpu, offset and size in bytes (32b-aligned) */ +void gk20a_mem_rd_n(struct gk20a *g, struct mem_desc *mem, u32 offset, + void *dest, u32 size); + +/* word-indexed offset */ +void gk20a_mem_wr32(struct gk20a *g, struct mem_desc *mem, u32 w, u32 data); +/* byte offset (32b-aligned) */ +void gk20a_mem_wr(struct gk20a *g, struct mem_desc *mem, u32 offset, u32 data); +/* memcpy from cpu, offset and size in bytes (32b-aligned) */ +void gk20a_mem_wr_n(struct gk20a *g, struct mem_desc *mem, u32 offset, + void *src, u32 size); +/* size and offset in bytes (32b-aligned), filled with u32s */ +void gk20a_memset(struct gk20a *g, struct mem_desc *mem, u32 offset, + u32 value, u32 size); + #if 0 /*related to addr bits above, concern below TBD on which is accurate */ #define bar1_instance_block_shift_gk20a() (max_physaddr_bits_gk20a() -\ bus_bar1_block_ptr_s()) @@ -673,7 +701,6 @@ void pde_range_from_vaddr_range(struct vm_gk20a *vm, u64 addr_lo, u64 addr_hi, u32 *pde_lo, u32 *pde_hi); int gk20a_mm_pde_coverage_bit_count(struct vm_gk20a *vm); -u32 *pde_from_index(struct vm_gk20a *vm, u32 i); u32 pte_index_from_vaddr(struct vm_gk20a *vm, u64 addr, enum gmmu_pgsz_gk20a pgsz_idx); void free_gmmu_pages(struct vm_gk20a *vm, @@ -685,7 +712,7 @@ struct gpu_ops; void gk20a_init_mm(struct gpu_ops *gops); const struct gk20a_mmu_level *gk20a_mm_get_mmu_levels(struct gk20a *g, u32 big_page_size); -void gk20a_mm_init_pdb(struct gk20a *g, void *inst_ptr, u64 pdb_addr); +void gk20a_mm_init_pdb(struct gk20a *g, struct mem_desc *mem, u64 pdb_addr); void gk20a_remove_vm(struct vm_gk20a *vm, struct mem_desc *inst_block); -- cgit v1.2.2