diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-15 18:54:16 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-06 21:14:42 -0400 |
commit | fa4ecf5730a75269e85cc41c2ad2ee61307e72a9 (patch) | |
tree | 188ede95097acee261a21f563bf8f844d7874861 /drivers/gpu/nvgpu/include | |
parent | 2ff3a9f374e6e7fb6c468789cf8e0213f2297bdf (diff) |
gpu: nvgpu: Split mem_desc from MM code
Split the mem_desc code out from the MM code. This is to help
simplify the MM code and make it easier to abstract the DMA
allocation routines.
JIRA NVGPU-12
Change-Id: I2ccb643efe6bbed80d1360a580ff5593acb407bd
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1323324
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/mem_desc.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/mem_desc.h b/drivers/gpu/nvgpu/include/nvgpu/mem_desc.h new file mode 100644 index 00000000..528fd7bc --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/mem_desc.h | |||
@@ -0,0 +1,111 @@ | |||
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 | #ifndef __NVGPU_MEM_DESC_H__ | ||
18 | #define __NVGPU_MEM_DESC_H__ | ||
19 | |||
20 | #include <linux/types.h> | ||
21 | |||
22 | #include <nvgpu/list.h> | ||
23 | |||
24 | struct page; | ||
25 | struct sg_table; | ||
26 | |||
27 | struct gk20a; | ||
28 | struct nvgpu_allocator; | ||
29 | |||
30 | /* | ||
31 | * Real location of a buffer - gk20a_aperture_mask() will deduce what will be | ||
32 | * told to the gpu about the aperture, but this flag designates where the | ||
33 | * memory actually was allocated from. | ||
34 | */ | ||
35 | enum gk20a_aperture { | ||
36 | APERTURE_INVALID, /* unallocated or N/A */ | ||
37 | APERTURE_SYSMEM, | ||
38 | APERTURE_VIDMEM | ||
39 | }; | ||
40 | |||
41 | struct mem_desc { | ||
42 | void *cpu_va; /* sysmem only */ | ||
43 | struct page **pages; /* sysmem only */ | ||
44 | struct sg_table *sgt; | ||
45 | enum gk20a_aperture aperture; | ||
46 | size_t size; | ||
47 | u64 gpu_va; | ||
48 | bool fixed; /* vidmem only */ | ||
49 | bool user_mem; /* vidmem only */ | ||
50 | struct nvgpu_allocator *allocator; /* vidmem only */ | ||
51 | struct nvgpu_list_node clear_list_entry; /* vidmem only */ | ||
52 | bool skip_wmb; | ||
53 | unsigned long flags; | ||
54 | }; | ||
55 | |||
56 | static inline struct mem_desc * | ||
57 | mem_desc_from_clear_list_entry(struct nvgpu_list_node *node) | ||
58 | { | ||
59 | return (struct mem_desc *) | ||
60 | ((uintptr_t)node - offsetof(struct mem_desc, clear_list_entry)); | ||
61 | }; | ||
62 | |||
63 | struct mem_desc_sub { | ||
64 | u32 offset; | ||
65 | u32 size; | ||
66 | }; | ||
67 | |||
68 | static inline const char *gk20a_aperture_str(enum gk20a_aperture aperture) | ||
69 | { | ||
70 | switch (aperture) { | ||
71 | case APERTURE_INVALID: return "invalid"; | ||
72 | case APERTURE_SYSMEM: return "sysmem"; | ||
73 | case APERTURE_VIDMEM: return "vidmem"; | ||
74 | }; | ||
75 | return "UNKNOWN"; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Buffer accessors - wrap between begin() and end() if there is no permanent | ||
80 | * kernel mapping for this buffer. | ||
81 | */ | ||
82 | |||
83 | int gk20a_mem_begin(struct gk20a *g, struct mem_desc *mem); | ||
84 | /* nop for null mem, like with free() or vunmap() */ | ||
85 | void gk20a_mem_end(struct gk20a *g, struct mem_desc *mem); | ||
86 | |||
87 | /* word-indexed offset */ | ||
88 | u32 gk20a_mem_rd32(struct gk20a *g, struct mem_desc *mem, u32 w); | ||
89 | /* byte offset (32b-aligned) */ | ||
90 | u32 gk20a_mem_rd(struct gk20a *g, struct mem_desc *mem, u32 offset); | ||
91 | /* memcpy to cpu, offset and size in bytes (32b-aligned) */ | ||
92 | void gk20a_mem_rd_n(struct gk20a *g, struct mem_desc *mem, u32 offset, | ||
93 | void *dest, u32 size); | ||
94 | |||
95 | /* word-indexed offset */ | ||
96 | void gk20a_mem_wr32(struct gk20a *g, struct mem_desc *mem, u32 w, u32 data); | ||
97 | /* byte offset (32b-aligned) */ | ||
98 | void gk20a_mem_wr(struct gk20a *g, struct mem_desc *mem, u32 offset, u32 data); | ||
99 | /* memcpy from cpu, offset and size in bytes (32b-aligned) */ | ||
100 | void gk20a_mem_wr_n(struct gk20a *g, struct mem_desc *mem, u32 offset, | ||
101 | void *src, u32 size); | ||
102 | /* size and offset in bytes (32b-aligned), filled with the constant byte c */ | ||
103 | void gk20a_memset(struct gk20a *g, struct mem_desc *mem, u32 offset, | ||
104 | u32 c, u32 size); | ||
105 | |||
106 | u32 __gk20a_aperture_mask(struct gk20a *g, enum gk20a_aperture aperture, | ||
107 | u32 sysmem_mask, u32 vidmem_mask); | ||
108 | u32 gk20a_aperture_mask(struct gk20a *g, struct mem_desc *mem, | ||
109 | u32 sysmem_mask, u32 vidmem_mask); | ||
110 | |||
111 | #endif | ||