diff options
author | Sami Kiminki <skiminki@nvidia.com> | 2017-11-13 06:52:29 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-15 16:26:02 -0500 |
commit | 23396c58db7e9d9c974bb3334a159aad960afc3e (patch) | |
tree | 21600214cdd1737075b73354b40fca7fbe97f93e /drivers/gpu/nvgpu/common/linux | |
parent | 434385ca54053b13ac06a5f11cb7564d6740f02d (diff) |
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 <skiminki@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1597130
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 | 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 | } | ||