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/common/linux/comptags.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/comptags.c') 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, { struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, buf->dev); - u32 ctaglines_allocsize; u32 offset; int err; @@ -56,18 +55,24 @@ int gk20a_alloc_comptags(struct gk20a *g, if (!lines) return -EINVAL; - ctaglines_allocsize = lines; - /* store the allocator so we can use it when we free the ctags */ priv->comptag_allocator = allocator; - err = gk20a_comptaglines_alloc(allocator, &offset, - ctaglines_allocsize); - if (err) - return err; + err = gk20a_comptaglines_alloc(allocator, &offset, lines); + if (!err) { + priv->comptags.offset = offset; + priv->comptags.lines = lines; + } else { + priv->comptags.offset = 0; + priv->comptags.lines = 0; + } - priv->comptags.offset = offset; - priv->comptags.lines = lines; - priv->comptags.allocated_lines = ctaglines_allocsize; + /* + * We don't report an error here if comptag alloc failed. The + * caller will simply fallback to incompressible kinds. It + * would not be safe to re-allocate comptags anyways on + * successive calls, as that would break map aliasing. + */ + priv->comptags.allocated = true; return 0; } -- cgit v1.2.2