diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/comptags.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/comptags.c | 26 |
1 files changed, 22 insertions, 4 deletions
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, | |||
39 | *comptags = priv->comptags; | 39 | *comptags = priv->comptags; |
40 | } | 40 | } |
41 | 41 | ||
42 | int gk20a_alloc_comptags(struct gk20a *g, | 42 | int gk20a_alloc_or_get_comptags(struct gk20a *g, |
43 | struct nvgpu_os_buffer *buf, | 43 | struct nvgpu_os_buffer *buf, |
44 | struct gk20a_comptag_allocator *allocator, | 44 | struct gk20a_comptag_allocator *allocator, |
45 | u32 lines) | 45 | u32 lines, |
46 | struct gk20a_comptags *comptags) | ||
46 | { | 47 | { |
47 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, | 48 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, |
48 | buf->dev); | 49 | buf->dev); |
@@ -55,15 +56,23 @@ int gk20a_alloc_comptags(struct gk20a *g, | |||
55 | if (!lines) | 56 | if (!lines) |
56 | return -EINVAL; | 57 | return -EINVAL; |
57 | 58 | ||
59 | if (priv->comptags.allocated) { | ||
60 | /* already allocated */ | ||
61 | *comptags = priv->comptags; | ||
62 | return 0; | ||
63 | } | ||
64 | |||
58 | /* store the allocator so we can use it when we free the ctags */ | 65 | /* store the allocator so we can use it when we free the ctags */ |
59 | priv->comptag_allocator = allocator; | 66 | priv->comptag_allocator = allocator; |
60 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); | 67 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); |
61 | if (!err) { | 68 | if (!err) { |
62 | priv->comptags.offset = offset; | 69 | priv->comptags.offset = offset; |
63 | priv->comptags.lines = lines; | 70 | priv->comptags.lines = lines; |
71 | priv->comptags.needs_clear = true; | ||
64 | } else { | 72 | } else { |
65 | priv->comptags.offset = 0; | 73 | priv->comptags.offset = 0; |
66 | priv->comptags.lines = 0; | 74 | priv->comptags.lines = 0; |
75 | priv->comptags.needs_clear = false; | ||
67 | } | 76 | } |
68 | 77 | ||
69 | /* | 78 | /* |
@@ -74,5 +83,14 @@ int gk20a_alloc_comptags(struct gk20a *g, | |||
74 | */ | 83 | */ |
75 | priv->comptags.allocated = true; | 84 | priv->comptags.allocated = true; |
76 | 85 | ||
86 | *comptags = priv->comptags; | ||
77 | return 0; | 87 | return 0; |
78 | } | 88 | } |
89 | |||
90 | void gk20a_mark_comptags_cleared(struct nvgpu_os_buffer *buf) | ||
91 | { | ||
92 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, | ||
93 | buf->dev); | ||
94 | if (priv) | ||
95 | priv->comptags.needs_clear = false; | ||
96 | } | ||