diff options
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/cde_gk20a.c | 32 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 71 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 3 |
3 files changed, 15 insertions, 91 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c index 095f69c7..ea01914c 100644 --- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Color decompression engine support | 2 | * Color decompression engine support |
3 | * | 3 | * |
4 | * Copyright (c) 2014-2015, NVIDIA Corporation. All rights reserved. | 4 | * Copyright (c) 2014, NVIDIA Corporation. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -979,23 +979,17 @@ __releases(&cde_app->mutex) | |||
979 | map_size = compbits_buf->size - map_offset; | 979 | map_size = compbits_buf->size - map_offset; |
980 | } | 980 | } |
981 | 981 | ||
982 | /* map the destination buffer, if not cached yet */ | 982 | /* map the destination buffer */ |
983 | /* races protected by the cde app mutex above */ | 983 | get_dma_buf(compbits_buf); /* a ref for gk20a_vm_map */ |
984 | map_vaddr = gk20a_vm_cde_mapped(cde_ctx->vm, compbits_buf); | 984 | map_vaddr = gk20a_vm_map(cde_ctx->vm, compbits_buf, 0, |
985 | NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, | ||
986 | compbits_kind, NULL, true, | ||
987 | gk20a_mem_flag_none, | ||
988 | map_offset, map_size); | ||
985 | if (!map_vaddr) { | 989 | if (!map_vaddr) { |
986 | /* take a ref for gk20a_vm_map, pair is in (cached) unmap */ | 990 | dma_buf_put(compbits_buf); |
987 | get_dma_buf(compbits_buf); | 991 | err = -EINVAL; |
988 | map_vaddr = gk20a_vm_map(cde_ctx->vm, compbits_buf, 0, | 992 | goto exit_unlock; |
989 | NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, | ||
990 | compbits_kind, NULL, true, | ||
991 | gk20a_mem_flag_none, | ||
992 | map_offset, map_size); | ||
993 | if (!map_vaddr) { | ||
994 | dma_buf_put(compbits_buf); | ||
995 | err = -EINVAL; | ||
996 | goto exit_unlock; | ||
997 | } | ||
998 | gk20a_vm_mark_cde_mapped(cde_ctx->vm, compbits_buf, map_vaddr); | ||
999 | } | 993 | } |
1000 | 994 | ||
1001 | /* store source buffer compression tags */ | 995 | /* store source buffer compression tags */ |
@@ -1058,7 +1052,9 @@ __releases(&cde_app->mutex) | |||
1058 | 1052 | ||
1059 | exit_unlock: | 1053 | exit_unlock: |
1060 | 1054 | ||
1061 | /* leave map_vaddr mapped - released when unmapped from userspace */ | 1055 | /* unmap the buffers - channel holds references to them now */ |
1056 | if (map_vaddr) | ||
1057 | gk20a_vm_unmap(cde_ctx->vm, map_vaddr); | ||
1062 | 1058 | ||
1063 | mutex_unlock(&g->cde_app.mutex); | 1059 | mutex_unlock(&g->cde_app.mutex); |
1064 | return err; | 1060 | return err; |
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 77f71bc9..67680c4c 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -117,11 +117,6 @@ struct gk20a_dmabuf_priv { | |||
117 | int pin_count; | 117 | int pin_count; |
118 | 118 | ||
119 | struct list_head states; | 119 | struct list_head states; |
120 | |||
121 | /* cached cde compbits buf */ | ||
122 | struct vm_gk20a *cde_vm; | ||
123 | u64 cde_map_vaddr; | ||
124 | int map_count; | ||
125 | }; | 120 | }; |
126 | 121 | ||
127 | static void gk20a_vm_remove_support_nofree(struct vm_gk20a *vm); | 122 | static void gk20a_vm_remove_support_nofree(struct vm_gk20a *vm); |
@@ -203,60 +198,6 @@ void gk20a_mm_unpin(struct device *dev, struct dma_buf *dmabuf, | |||
203 | mutex_unlock(&priv->lock); | 198 | mutex_unlock(&priv->lock); |
204 | } | 199 | } |
205 | 200 | ||
206 | /* CDE compbits buf caching: keep compbit buffer mapped during user mappings. | ||
207 | * Call these four only after dma_buf has a drvdata allocated */ | ||
208 | |||
209 | u64 gk20a_vm_cde_mapped(struct vm_gk20a *vm, struct dma_buf *dmabuf) | ||
210 | { | ||
211 | struct device *dev = dev_from_vm(vm); | ||
212 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
213 | u64 map_vaddr; | ||
214 | |||
215 | mutex_lock(&priv->lock); | ||
216 | map_vaddr = priv->cde_map_vaddr; | ||
217 | mutex_unlock(&priv->lock); | ||
218 | |||
219 | return map_vaddr; | ||
220 | } | ||
221 | |||
222 | void gk20a_vm_mark_cde_mapped(struct vm_gk20a *vm, struct dma_buf *dmabuf, | ||
223 | u64 map_vaddr) | ||
224 | { | ||
225 | struct device *dev = dev_from_vm(vm); | ||
226 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
227 | |||
228 | mutex_lock(&priv->lock); | ||
229 | priv->cde_vm = vm; | ||
230 | priv->cde_map_vaddr = map_vaddr; | ||
231 | mutex_unlock(&priv->lock); | ||
232 | } | ||
233 | |||
234 | static void gk20a_vm_inc_maps(struct vm_gk20a *vm, struct dma_buf *dmabuf) | ||
235 | { | ||
236 | struct device *dev = dev_from_vm(vm); | ||
237 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
238 | |||
239 | mutex_lock(&priv->lock); | ||
240 | priv->map_count++; | ||
241 | mutex_unlock(&priv->lock); | ||
242 | } | ||
243 | |||
244 | static void gk20a_vm_dec_maps(struct vm_gk20a *vm, struct dma_buf *dmabuf, | ||
245 | struct vm_gk20a **cde_vm, u64 *cde_map_vaddr) | ||
246 | { | ||
247 | struct device *dev = dev_from_vm(vm); | ||
248 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
249 | |||
250 | mutex_lock(&priv->lock); | ||
251 | if (--priv->map_count == 0) { | ||
252 | *cde_vm = priv->cde_vm; | ||
253 | *cde_map_vaddr = priv->cde_map_vaddr; | ||
254 | priv->cde_vm = NULL; | ||
255 | priv->cde_map_vaddr = 0; | ||
256 | } | ||
257 | mutex_unlock(&priv->lock); | ||
258 | } | ||
259 | |||
260 | void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, | 201 | void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, |
261 | struct gk20a_comptags *comptags) | 202 | struct gk20a_comptags *comptags) |
262 | { | 203 | { |
@@ -809,8 +750,6 @@ static void gk20a_vm_unmap_user(struct vm_gk20a *vm, u64 offset) | |||
809 | struct device *d = dev_from_vm(vm); | 750 | struct device *d = dev_from_vm(vm); |
810 | int retries; | 751 | int retries; |
811 | struct mapped_buffer_node *mapped_buffer; | 752 | struct mapped_buffer_node *mapped_buffer; |
812 | struct vm_gk20a *cde_vm = NULL; | ||
813 | u64 cde_map_vaddr = 0; | ||
814 | 753 | ||
815 | mutex_lock(&vm->update_gmmu_lock); | 754 | mutex_lock(&vm->update_gmmu_lock); |
816 | 755 | ||
@@ -843,15 +782,9 @@ static void gk20a_vm_unmap_user(struct vm_gk20a *vm, u64 offset) | |||
843 | mapped_buffer->user_mapped--; | 782 | mapped_buffer->user_mapped--; |
844 | if (mapped_buffer->user_mapped == 0) | 783 | if (mapped_buffer->user_mapped == 0) |
845 | vm->num_user_mapped_buffers--; | 784 | vm->num_user_mapped_buffers--; |
846 | |||
847 | gk20a_vm_dec_maps(vm, mapped_buffer->dmabuf, &cde_vm, &cde_map_vaddr); | ||
848 | |||
849 | kref_put(&mapped_buffer->ref, gk20a_vm_unmap_locked_kref); | 785 | kref_put(&mapped_buffer->ref, gk20a_vm_unmap_locked_kref); |
850 | 786 | ||
851 | mutex_unlock(&vm->update_gmmu_lock); | 787 | mutex_unlock(&vm->update_gmmu_lock); |
852 | |||
853 | if (cde_map_vaddr) | ||
854 | gk20a_vm_unmap(cde_vm, cde_map_vaddr); | ||
855 | } | 788 | } |
856 | 789 | ||
857 | u64 gk20a_vm_alloc_va(struct vm_gk20a *vm, | 790 | u64 gk20a_vm_alloc_va(struct vm_gk20a *vm, |
@@ -2665,9 +2598,7 @@ int gk20a_vm_map_buffer(struct vm_gk20a *vm, | |||
2665 | mapping_size); | 2598 | mapping_size); |
2666 | 2599 | ||
2667 | *offset_align = ret_va; | 2600 | *offset_align = ret_va; |
2668 | if (ret_va) { | 2601 | if (!ret_va) { |
2669 | gk20a_vm_inc_maps(vm, dmabuf); | ||
2670 | } else { | ||
2671 | dma_buf_put(dmabuf); | 2602 | dma_buf_put(dmabuf); |
2672 | err = -EINVAL; | 2603 | err = -EINVAL; |
2673 | } | 2604 | } |
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index 99f49aa8..7bb13484 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h | |||
@@ -557,9 +557,6 @@ void gk20a_deinit_vm(struct vm_gk20a *vm); | |||
557 | int gk20a_vm_unmap_buffer(struct vm_gk20a *vm, u64 offset); | 557 | int gk20a_vm_unmap_buffer(struct vm_gk20a *vm, u64 offset); |
558 | void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, | 558 | void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, |
559 | struct gk20a_comptags *comptags); | 559 | struct gk20a_comptags *comptags); |
560 | u64 gk20a_vm_cde_mapped(struct vm_gk20a *vm, struct dma_buf *dmabuf); | ||
561 | void gk20a_vm_mark_cde_mapped(struct vm_gk20a *vm, struct dma_buf *dmabuf, | ||
562 | u64 map_vaddr); | ||
563 | dma_addr_t gk20a_mm_gpuva_to_iova_base(struct vm_gk20a *vm, u64 gpu_vaddr); | 560 | dma_addr_t gk20a_mm_gpuva_to_iova_base(struct vm_gk20a *vm, u64 gpu_vaddr); |
564 | 561 | ||
565 | int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev); | 562 | int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev); |