summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/comptags.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-09-07 18:27:55 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-18 19:00:37 -0400
commitb3446bc0b6fca6cb992667f80a95f8503b6a652a (patch)
tree9882c36bfaef83da9d0a6eefec5e8c3564b93cea /drivers/gpu/nvgpu/common/linux/comptags.c
parentbee9c830c7898ceebf8c396b40598350229a7203 (diff)
gpu: nvgpu: Move dma_buf usage from mm_gk20a.c
Move most of the dma_buf usage present in the mm_gk20a.c code out to Linux specific code and some commom/mm code. There's two primary groups of code: 1. dma_buf priv field code (for holding comptag data) 2. Comptag usage that relies on dma_buf pointers For (1) the dma_buf code was simply moved to common/linux/dmabuf.c since most of this code is clearly Linux specific. The comptag code was a bit more complicated since there is two parts to the comptag code. Firstly there's the code that manages the comptag memory. This is essentially a simple allocator. This was moved to common/mm/comptags.c since it can be shared across all chips. The second set of code is moved to common/linux/comptags.c since it is the interface between dma_bufs and the comptag memory. Two other fixes were done as well: - Add struct gk20a to the comptag allocator init so that the proper nvgpu_vzalloc() function could be used. - Add necessary includes to common/linux/vm_priv.h. JIRA NVGPU-30 JIRA NVGPU-138 Change-Id: I96c57f2763e5ebe18a2f2ee4b33e0e1a2597848c Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1566628 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/comptags.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/comptags.c70
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
23void 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
39int 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}