diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/comptags.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/comptags.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/comptags.c b/drivers/gpu/nvgpu/common/linux/comptags.c new file mode 100644 index 00000000..517429d8 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/comptags.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/dma-buf.h> | ||
18 | |||
19 | #include <nvgpu/comptags.h> | ||
20 | |||
21 | #include "dmabuf.h" | ||
22 | |||
23 | void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, | ||
24 | struct gk20a_comptags *comptags) | ||
25 | { | ||
26 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
27 | |||
28 | if (!comptags) | ||
29 | return; | ||
30 | |||
31 | if (!priv) { | ||
32 | memset(comptags, 0, sizeof(*comptags)); | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | *comptags = priv->comptags; | ||
37 | } | ||
38 | |||
39 | int gk20a_alloc_comptags(struct gk20a *g, | ||
40 | struct device *dev, | ||
41 | struct dma_buf *dmabuf, | ||
42 | struct gk20a_comptag_allocator *allocator, | ||
43 | u32 lines) | ||
44 | { | ||
45 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); | ||
46 | u32 ctaglines_allocsize; | ||
47 | u32 offset; | ||
48 | int err; | ||
49 | |||
50 | if (!priv) | ||
51 | return -ENOSYS; | ||
52 | |||
53 | if (!lines) | ||
54 | return -EINVAL; | ||
55 | |||
56 | ctaglines_allocsize = lines; | ||
57 | |||
58 | /* store the allocator so we can use it when we free the ctags */ | ||
59 | priv->comptag_allocator = allocator; | ||
60 | err = gk20a_comptaglines_alloc(allocator, &offset, | ||
61 | ctaglines_allocsize); | ||
62 | if (err) | ||
63 | return err; | ||
64 | |||
65 | priv->comptags.offset = offset; | ||
66 | priv->comptags.lines = lines; | ||
67 | priv->comptags.allocated_lines = ctaglines_allocsize; | ||
68 | |||
69 | return 0; | ||
70 | } | ||