From 434385ca54053b13ac06a5f11cb7564d6740f02d Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Wed, 8 Nov 2017 20:55:47 +0200 Subject: gpu: nvgpu: Clean up comptag data structs and alloc Clean up the comptag-related data structures and allocation logic. The most important change is that we only ever try comptag allocation once to prevent incorrect map aliasing. If we were to retry the allocation on further map calls, the following situation would become possible: (1) Request compressible kind mapping for a buffer. Comptag alloc failed and we proceed with incompressible kind fallback. (2) Request another compressible kind mapping for a buffer. Comptag alloc retry succeeded and now we use the compressible kind. (3) After writes through the compressible kind mapping, the buffer is no longer legible via the fallback incompressible kind mapping. The other changes are about removing the unused comptag-related fields in gk20a_comptags and nvgpu_mapped_buf, and retrieving comptags info only for compressible buffers. We also make nvgpu_ctag_buffer_info and nvgpu_vm_compute_compression as private mm/vm.c definitions, since they're not used elsewhere. Bug 1902982 Change-Id: I0c9fe48ccc585a80dd2c05ec606a079c1c1d41f1 Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1595153 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: svc-mobile-coverity Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/comptags.h | 10 ++++++++-- drivers/gpu/nvgpu/include/nvgpu/vm.h | 17 ----------------- 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/comptags.h b/drivers/gpu/nvgpu/include/nvgpu/comptags.h index 5482d0ce..2d9f034a 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/comptags.h +++ b/drivers/gpu/nvgpu/include/nvgpu/comptags.h @@ -25,8 +25,14 @@ struct nvgpu_os_buffer; struct gk20a_comptags { u32 offset; u32 lines; - u32 allocated_lines; - bool user_mappable; + + /* + * This signals whether allocation has been attempted. Observe + * 'lines' to see whether comptags were actually allocated. We + * try alloc only once per buffer in order not to break + * multiple compressible-kind mappings. + */ + bool allocated; }; struct gk20a_comptag_allocator { diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index abb297ab..c0a4124c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h @@ -110,9 +110,6 @@ struct nvgpu_mapped_buf { u64 size; u32 pgsz_idx; - u32 ctag_offset; - u32 ctag_lines; - u32 ctag_allocated_lines; u32 flags; u32 kind; @@ -143,17 +140,6 @@ mapped_buffer_from_rbtree_node(struct nvgpu_rbtree_node *node) ((uintptr_t)node - offsetof(struct nvgpu_mapped_buf, node)); } -struct nvgpu_ctag_buffer_info { - u64 size; - enum gmmu_pgsz_gk20a pgsz_idx; - u32 flags; - - s16 compr_kind; - s16 incompr_kind; - - u32 ctag_lines; -}; - struct vm_gk20a { struct mm_gk20a *mm; struct gk20a_as_share *as_share; /* as_share this represents */ @@ -221,9 +207,6 @@ void nvgpu_vm_put(struct vm_gk20a *vm); int vm_aspace_id(struct vm_gk20a *vm); int nvgpu_big_pages_possible(struct vm_gk20a *vm, u64 base, u64 size); -int nvgpu_vm_compute_compression(struct vm_gk20a *vm, - struct nvgpu_ctag_buffer_info *binfo); - /* batching eliminates redundant cache flushes and invalidates */ void nvgpu_vm_mapping_batch_start(struct vm_gk20a_mapping_batch *batch); void nvgpu_vm_mapping_batch_finish( -- cgit v1.2.2