From 23396c58db7e9d9c974bb3334a159aad960afc3e Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Mon, 13 Nov 2017 13:52:29 +0200 Subject: gpu: nvgpu: Simplify compbits alloc and add needs_clear Simplify compbits alloc by making the alloc function re-callable for the buffer, and making it return the comptags info. This simplifies the calling code: alloc_or_get vs. get + alloc + get again. Add tracking whether the allocated compbits need clearing before they can be used in PTEs. We do this, since clearing is part of the gmmu map call on vgpu, which can fail. Bug 1902982 Change-Id: Ic4ab8d326910443b128e82491d302a1f49120f5b Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1597130 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 | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 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 92e8aa3e..4a96e07b 100644 --- a/drivers/gpu/nvgpu/common/linux/comptags.c +++ b/drivers/gpu/nvgpu/common/linux/comptags.c @@ -39,10 +39,11 @@ void gk20a_get_comptags(struct nvgpu_os_buffer *buf, *comptags = priv->comptags; } -int gk20a_alloc_comptags(struct gk20a *g, - struct nvgpu_os_buffer *buf, - struct gk20a_comptag_allocator *allocator, - u32 lines) +int gk20a_alloc_or_get_comptags(struct gk20a *g, + struct nvgpu_os_buffer *buf, + struct gk20a_comptag_allocator *allocator, + u32 lines, + struct gk20a_comptags *comptags) { struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, buf->dev); @@ -55,15 +56,23 @@ int gk20a_alloc_comptags(struct gk20a *g, if (!lines) return -EINVAL; + if (priv->comptags.allocated) { + /* already allocated */ + *comptags = priv->comptags; + return 0; + } + /* store the allocator so we can use it when we free the ctags */ priv->comptag_allocator = allocator; err = gk20a_comptaglines_alloc(allocator, &offset, lines); if (!err) { priv->comptags.offset = offset; priv->comptags.lines = lines; + priv->comptags.needs_clear = true; } else { priv->comptags.offset = 0; priv->comptags.lines = 0; + priv->comptags.needs_clear = false; } /* @@ -74,5 +83,14 @@ int gk20a_alloc_comptags(struct gk20a *g, */ priv->comptags.allocated = true; + *comptags = priv->comptags; return 0; } + +void gk20a_mark_comptags_cleared(struct nvgpu_os_buffer *buf) +{ + struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, + buf->dev); + if (priv) + priv->comptags.needs_clear = false; +} -- cgit v1.2.2