diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/comptags.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/comptags.c b/drivers/gpu/nvgpu/common/linux/comptags.c index 4a96e07b..7d095793 100644 --- a/drivers/gpu/nvgpu/common/linux/comptags.c +++ b/drivers/gpu/nvgpu/common/linux/comptags.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <nvgpu/linux/vm.h> | 21 | #include <nvgpu/linux/vm.h> |
22 | 22 | ||
23 | #include "gk20a/gk20a.h" | ||
23 | #include "dmabuf.h" | 24 | #include "dmabuf.h" |
24 | 25 | ||
25 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | 26 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, |
@@ -42,26 +43,33 @@ void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | |||
42 | int gk20a_alloc_or_get_comptags(struct gk20a *g, | 43 | int gk20a_alloc_or_get_comptags(struct gk20a *g, |
43 | struct nvgpu_os_buffer *buf, | 44 | struct nvgpu_os_buffer *buf, |
44 | struct gk20a_comptag_allocator *allocator, | 45 | struct gk20a_comptag_allocator *allocator, |
45 | u32 lines, | ||
46 | struct gk20a_comptags *comptags) | 46 | struct gk20a_comptags *comptags) |
47 | { | 47 | { |
48 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, | 48 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, |
49 | buf->dev); | 49 | buf->dev); |
50 | u32 offset; | 50 | u32 offset; |
51 | int err; | 51 | int err; |
52 | unsigned int ctag_granularity; | ||
53 | u32 lines; | ||
52 | 54 | ||
53 | if (!priv) | 55 | if (!priv) |
54 | return -ENOSYS; | 56 | return -ENOSYS; |
55 | 57 | ||
56 | if (!lines) | ||
57 | return -EINVAL; | ||
58 | |||
59 | if (priv->comptags.allocated) { | 58 | if (priv->comptags.allocated) { |
60 | /* already allocated */ | 59 | /* |
60 | * already allocated | ||
61 | */ | ||
61 | *comptags = priv->comptags; | 62 | *comptags = priv->comptags; |
62 | return 0; | 63 | return 0; |
63 | } | 64 | } |
64 | 65 | ||
66 | ctag_granularity = g->ops.fb.compression_page_size(g); | ||
67 | lines = DIV_ROUND_UP_ULL(buf->dmabuf->size, ctag_granularity); | ||
68 | |||
69 | /* 0-sized buffer? Shouldn't occur, but let's check anyways. */ | ||
70 | if (lines < 1) | ||
71 | return -EINVAL; | ||
72 | |||
65 | /* store the allocator so we can use it when we free the ctags */ | 73 | /* store the allocator so we can use it when we free the ctags */ |
66 | priv->comptag_allocator = allocator; | 74 | priv->comptag_allocator = allocator; |
67 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); | 75 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); |