diff options
author | Alex Waterman <alexw@nvidia.com> | 2018-02-09 14:57:54 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-02-27 19:03:43 -0500 |
commit | 1170687c33f7506f39aaf47acee5430233e3d1a8 (patch) | |
tree | b41146a14a78eba99b9f326ef63efbe8ba77caab /drivers/gpu/nvgpu/include | |
parent | 71f53272b28b1086b3f34e5e255815c37504ac2c (diff) |
gpu: nvgpu: Use coherent aperture flag
When using a coherent DMA API wee must make sure to program
any aperture fields with the coherent aperture setting. To
do this the nvgpu_aperture_mask() function was modified to
take a third aperture mask argument, a coherent setting, so
that code can use this function to generate coherent aperture
settings.
The aperture choice is some what tricky: the default version
of this function uses the state of the DMA API to determine
what aperture to use for SYSMEM: either coherent or
non-coherent internally. Thus a kernel user need only specify
the normal nvgpu_mem struct and the correct mask should be
chosen. Due to many uses of nvgpu_mem structs not created
directly from the DMA API wrapper it's easier to translate
SYSMEM to SYSMEM_COH after creation.
However, the GMMU mapping code, will encounter buffers from
userspace with difference coerency attributes than the DMA
API. Thus the __nvgpu_aperture_mask() really respects the
aperture setting passed in regardless of the DMA API state.
This aperture setting is pulled from NVGPU_VM_MAP_IO_COHERENT
since this is either passed in from userspace or set by the
kernel when using coherent DMA. The aperture field in attrs
is upgraded to coh if this flag is set.
This change also adds a coherent sysmem mask everywhere that
it can. There's a couple places that do not have a coherent
register field defined yet. These need to eventually be
defined and added.
Lastly the aperture mask code has been mvoed from the Linux
vm.c code to the general vm.c code since this function has
no Linux dependencies.
Note: depends on https://git-master.nvidia.com/r/1664536 for
new register fields.
JIRA EVLR-2333
Change-Id: I4b347911ecb7c511738563fe6c34d0e6aa380d71
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1655220
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/nvgpu_mem.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 2b8b7015..f1ab8a6e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <nvgpu/types.h> | 26 | #include <nvgpu/types.h> |
27 | #include <nvgpu/list.h> | 27 | #include <nvgpu/list.h> |
28 | #include <nvgpu/enabled.h> | ||
28 | 29 | ||
29 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
30 | #include <nvgpu/linux/nvgpu_mem.h> | 31 | #include <nvgpu/linux/nvgpu_mem.h> |
@@ -51,6 +52,10 @@ struct nvgpu_page_alloc; | |||
51 | enum nvgpu_aperture { | 52 | enum nvgpu_aperture { |
52 | APERTURE_INVALID = 0, /* unallocated or N/A */ | 53 | APERTURE_INVALID = 0, /* unallocated or N/A */ |
53 | APERTURE_SYSMEM, | 54 | APERTURE_SYSMEM, |
55 | |||
56 | /* Don't use directly. Use APERTURE_SYSMEM, this is used internally. */ | ||
57 | __APERTURE_SYSMEM_COH, | ||
58 | |||
54 | APERTURE_VIDMEM | 59 | APERTURE_VIDMEM |
55 | }; | 60 | }; |
56 | 61 | ||
@@ -187,12 +192,18 @@ nvgpu_mem_from_clear_list_entry(struct nvgpu_list_node *node) | |||
187 | clear_list_entry)); | 192 | clear_list_entry)); |
188 | }; | 193 | }; |
189 | 194 | ||
190 | static inline const char *nvgpu_aperture_str(enum nvgpu_aperture aperture) | 195 | static inline const char *nvgpu_aperture_str(struct gk20a *g, |
196 | enum nvgpu_aperture aperture) | ||
191 | { | 197 | { |
192 | switch (aperture) { | 198 | switch (aperture) { |
193 | case APERTURE_INVALID: return "INVAL"; | 199 | case APERTURE_INVALID: |
194 | case APERTURE_SYSMEM: return "SYSMEM"; | 200 | return "INVAL"; |
195 | case APERTURE_VIDMEM: return "VIDMEM"; | 201 | case APERTURE_SYSMEM: |
202 | return "SYSMEM"; | ||
203 | case __APERTURE_SYSMEM_COH: | ||
204 | return "SYSCOH"; | ||
205 | case APERTURE_VIDMEM: | ||
206 | return "VIDMEM"; | ||
196 | }; | 207 | }; |
197 | return "UNKNOWN"; | 208 | return "UNKNOWN"; |
198 | } | 209 | } |
@@ -322,9 +333,9 @@ u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem); | |||
322 | u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem); | 333 | u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem); |
323 | 334 | ||
324 | u32 __nvgpu_aperture_mask(struct gk20a *g, enum nvgpu_aperture aperture, | 335 | u32 __nvgpu_aperture_mask(struct gk20a *g, enum nvgpu_aperture aperture, |
325 | u32 sysmem_mask, u32 vidmem_mask); | 336 | u32 sysmem_mask, u32 sysmem_coh_mask, u32 vidmem_mask); |
326 | u32 nvgpu_aperture_mask(struct gk20a *g, struct nvgpu_mem *mem, | 337 | u32 nvgpu_aperture_mask(struct gk20a *g, struct nvgpu_mem *mem, |
327 | u32 sysmem_mask, u32 vidmem_mask); | 338 | u32 sysmem_mask, u32 sysmem_coh_mask, u32 vidmem_mask); |
328 | 339 | ||
329 | u64 nvgpu_mem_iommu_translate(struct gk20a *g, u64 phys); | 340 | u64 nvgpu_mem_iommu_translate(struct gk20a *g, u64 phys); |
330 | 341 | ||