aboutsummaryrefslogtreecommitdiffstats
path: root/include/nvgpu/linux/nvgpu_mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/nvgpu/linux/nvgpu_mem.h')
-rw-r--r--include/nvgpu/linux/nvgpu_mem.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/include/nvgpu/linux/nvgpu_mem.h b/include/nvgpu/linux/nvgpu_mem.h
new file mode 100644
index 0000000..e5f5031
--- /dev/null
+++ b/include/nvgpu/linux/nvgpu_mem.h
@@ -0,0 +1,89 @@
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_LINUX_NVGPU_MEM_H__
18#define __NVGPU_LINUX_NVGPU_MEM_H__
19
20struct page;
21struct sg_table;
22struct scatterlist;
23struct nvgpu_sgt;
24
25struct gk20a;
26struct nvgpu_mem;
27struct nvgpu_gmmu_attrs;
28
29struct nvgpu_mem_priv {
30 struct page **pages;
31 struct sg_table *sgt;
32 unsigned long flags;
33};
34
35u64 nvgpu_mem_get_addr_sgl(struct gk20a *g, struct scatterlist *sgl);
36struct nvgpu_sgt *nvgpu_mem_linux_sgt_create(struct gk20a *g,
37 struct sg_table *sgt);
38void nvgpu_mem_linux_sgt_free(struct gk20a *g, struct nvgpu_sgt *sgt);
39struct nvgpu_sgt *nvgpu_linux_sgt_create(struct gk20a *g,
40 struct sg_table *sgt);
41/**
42 * __nvgpu_mem_create_from_pages - Create an nvgpu_mem from physical pages.
43 *
44 * @g - The GPU.
45 * @dest - nvgpu_mem to initialize.
46 * @pages - A list of page pointers.
47 * @nr_pages - The number of pages in @pages.
48 *
49 * Create a new nvgpu_mem struct from a pre-existing list of physical pages. The
50 * pages need not be contiguous (the underlying scatter gather list will help
51 * with that). However, note, this API will explicitly make it so that the GMMU
52 * mapping code bypasses SMMU access for the passed pages. This allows one to
53 * make mem_descs that describe MMIO regions or other non-DRAM things.
54 *
55 * This only works for SYSMEM (or other things like SYSMEM - basically just not
56 * VIDMEM). Also, this API is only available for Linux as it heavily depends on
57 * the notion of struct %page.
58 *
59 * The resulting nvgpu_mem should be released with the nvgpu_dma_free() or the
60 * nvgpu_dma_unmap_free() function depending on whether or not the resulting
61 * nvgpu_mem has been mapped. The underlying pages themselves must be cleaned up
62 * by the caller of this API.
63 *
64 * Returns 0 on success, or a relevant error otherwise.
65 */
66int __nvgpu_mem_create_from_pages(struct gk20a *g, struct nvgpu_mem *dest,
67 struct page **pages, int nr_pages);
68
69/**
70 * __nvgpu_mem_create_from_phys - Create an nvgpu_mem from physical mem.
71 *
72 * @g - The GPU.
73 * @dest - nvgpu_mem to initialize.
74 * @src_phys - start address of physical mem
75 * @nr_pages - The number of pages in phys.
76 *
77 * Create a new nvgpu_mem struct from a physical memory aperure. The physical
78 * memory aperture needs to be contiguous for requested @nr_pages. This API
79 * only works for SYSMEM.
80 *
81 * The resulting nvgpu_mem should be released with the nvgpu_dma_free() or the
82 * nvgpu_dma_unmap_free() function depending on whether or not the resulting
83 * nvgpu_mem has been mapped.
84 *
85 * Returns 0 on success, or a relevant error otherwise.
86 */
87int __nvgpu_mem_create_from_phys(struct gk20a *g, struct nvgpu_mem *dest,
88 u64 src_phys, int nr_pages);
89#endif