diff options
author | Sami Kiminki <skiminki@nvidia.com> | 2017-11-08 13:55:47 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-15 16:25:58 -0500 |
commit | 434385ca54053b13ac06a5f11cb7564d6740f02d (patch) | |
tree | 04cbfac9575af77c90e11da0fd8488fa221f2581 /drivers/gpu/nvgpu/common/linux | |
parent | 3ff666c4b97c5ad869aefe0d9c335c187962c20e (diff) |
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 <skiminki@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1595153
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/comptags.c | 25 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/dmabuf.c | 4 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vm.c | 3 |
3 files changed, 18 insertions, 14 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/comptags.c b/drivers/gpu/nvgpu/common/linux/comptags.c index f55989f7..92e8aa3e 100644 --- a/drivers/gpu/nvgpu/common/linux/comptags.c +++ b/drivers/gpu/nvgpu/common/linux/comptags.c | |||
@@ -46,7 +46,6 @@ int gk20a_alloc_comptags(struct gk20a *g, | |||
46 | { | 46 | { |
47 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, | 47 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, |
48 | buf->dev); | 48 | buf->dev); |
49 | u32 ctaglines_allocsize; | ||
50 | u32 offset; | 49 | u32 offset; |
51 | int err; | 50 | int err; |
52 | 51 | ||
@@ -56,18 +55,24 @@ int gk20a_alloc_comptags(struct gk20a *g, | |||
56 | if (!lines) | 55 | if (!lines) |
57 | return -EINVAL; | 56 | return -EINVAL; |
58 | 57 | ||
59 | ctaglines_allocsize = lines; | ||
60 | |||
61 | /* store the allocator so we can use it when we free the ctags */ | 58 | /* store the allocator so we can use it when we free the ctags */ |
62 | priv->comptag_allocator = allocator; | 59 | priv->comptag_allocator = allocator; |
63 | err = gk20a_comptaglines_alloc(allocator, &offset, | 60 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); |
64 | ctaglines_allocsize); | 61 | if (!err) { |
65 | if (err) | 62 | priv->comptags.offset = offset; |
66 | return err; | 63 | priv->comptags.lines = lines; |
64 | } else { | ||
65 | priv->comptags.offset = 0; | ||
66 | priv->comptags.lines = 0; | ||
67 | } | ||
67 | 68 | ||
68 | priv->comptags.offset = offset; | 69 | /* |
69 | priv->comptags.lines = lines; | 70 | * We don't report an error here if comptag alloc failed. The |
70 | priv->comptags.allocated_lines = ctaglines_allocsize; | 71 | * caller will simply fallback to incompressible kinds. It |
72 | * would not be safe to re-allocate comptags anyways on | ||
73 | * successive calls, as that would break map aliasing. | ||
74 | */ | ||
75 | priv->comptags.allocated = true; | ||
71 | 76 | ||
72 | return 0; | 77 | return 0; |
73 | } | 78 | } |
diff --git a/drivers/gpu/nvgpu/common/linux/dmabuf.c b/drivers/gpu/nvgpu/common/linux/dmabuf.c index 6b44ff55..08cf5f2b 100644 --- a/drivers/gpu/nvgpu/common/linux/dmabuf.c +++ b/drivers/gpu/nvgpu/common/linux/dmabuf.c | |||
@@ -41,11 +41,11 @@ static void gk20a_mm_delete_priv(void *_priv) | |||
41 | 41 | ||
42 | g = priv->g; | 42 | g = priv->g; |
43 | 43 | ||
44 | if (priv->comptags.lines) { | 44 | if (priv->comptags.allocated && priv->comptags.lines) { |
45 | BUG_ON(!priv->comptag_allocator); | 45 | BUG_ON(!priv->comptag_allocator); |
46 | gk20a_comptaglines_free(priv->comptag_allocator, | 46 | gk20a_comptaglines_free(priv->comptag_allocator, |
47 | priv->comptags.offset, | 47 | priv->comptags.offset, |
48 | priv->comptags.allocated_lines); | 48 | priv->comptags.lines); |
49 | } | 49 | } |
50 | 50 | ||
51 | /* Free buffer states */ | 51 | /* Free buffer states */ |
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index d6d86c94..8e464627 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c | |||
@@ -132,7 +132,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, | |||
132 | nvgpu_log(g, gpu_dbg_map, | 132 | nvgpu_log(g, gpu_dbg_map, |
133 | "gv: 0x%04x_%08x + 0x%-7zu " | 133 | "gv: 0x%04x_%08x + 0x%-7zu " |
134 | "[dma: 0x%010llx, pa: 0x%010llx] " | 134 | "[dma: 0x%010llx, pa: 0x%010llx] " |
135 | "pgsz=%-3dKb as=%-2d ctags=%d start=%d " | 135 | "pgsz=%-3dKb as=%-2d " |
136 | "flags=0x%x apt=%s (reused)", | 136 | "flags=0x%x apt=%s (reused)", |
137 | u64_hi32(mapped_buffer->addr), u64_lo32(mapped_buffer->addr), | 137 | u64_hi32(mapped_buffer->addr), u64_lo32(mapped_buffer->addr), |
138 | os_buf->dmabuf->size, | 138 | os_buf->dmabuf->size, |
@@ -140,7 +140,6 @@ struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, | |||
140 | (u64)sg_phys(mapped_buffer->os_priv.sgt->sgl), | 140 | (u64)sg_phys(mapped_buffer->os_priv.sgt->sgl), |
141 | vm->gmmu_page_sizes[mapped_buffer->pgsz_idx] >> 10, | 141 | vm->gmmu_page_sizes[mapped_buffer->pgsz_idx] >> 10, |
142 | vm_aspace_id(vm), | 142 | vm_aspace_id(vm), |
143 | mapped_buffer->ctag_lines, mapped_buffer->ctag_offset, | ||
144 | mapped_buffer->flags, | 143 | mapped_buffer->flags, |
145 | nvgpu_aperture_str(gk20a_dmabuf_aperture(g, os_buf->dmabuf))); | 144 | nvgpu_aperture_str(gk20a_dmabuf_aperture(g, os_buf->dmabuf))); |
146 | 145 | ||