summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vm.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/vm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c
index 2e29f0f7..f4ac3d41 100644
--- a/drivers/gpu/nvgpu/common/linux/vm.c
+++ b/drivers/gpu/nvgpu/common/linux/vm.c
@@ -23,6 +23,8 @@
23#include <nvgpu/vm_area.h> 23#include <nvgpu/vm_area.h>
24#include <nvgpu/nvgpu_mem.h> 24#include <nvgpu/nvgpu_mem.h>
25#include <nvgpu/page_allocator.h> 25#include <nvgpu/page_allocator.h>
26#include <nvgpu/vidmem.h>
27#include <nvgpu/enabled.h>
26 28
27#include <nvgpu/linux/nvgpu_mem.h> 29#include <nvgpu/linux/nvgpu_mem.h>
28 30
@@ -34,6 +36,33 @@
34#include "vm_priv.h" 36#include "vm_priv.h"
35#include "os_linux.h" 37#include "os_linux.h"
36 38
39/*
40 * Temporary location for this code until a dmabuf.c file exists.
41 */
42enum nvgpu_aperture gk20a_dmabuf_aperture(struct gk20a *g,
43 struct dma_buf *dmabuf)
44{
45 struct gk20a *buf_owner = gk20a_vidmem_buf_owner(dmabuf);
46 bool unified_memory = nvgpu_is_enabled(g, NVGPU_MM_UNIFIED_MEMORY);
47
48 if (buf_owner == NULL) {
49 /* Not nvgpu-allocated, assume system memory */
50 return APERTURE_SYSMEM;
51 } else if (WARN_ON(buf_owner == g && unified_memory)) {
52 /* Looks like our video memory, but this gpu doesn't support
53 * it. Warn about a bug and bail out */
54 nvgpu_warn(g,
55 "dmabuf is our vidmem but we don't have local vidmem");
56 return APERTURE_INVALID;
57 } else if (buf_owner != g) {
58 /* Someone else's vidmem */
59 return APERTURE_INVALID;
60 } else {
61 /* Yay, buf_owner == g */
62 return APERTURE_VIDMEM;
63 }
64}
65
37static struct nvgpu_mapped_buf *__nvgpu_vm_find_mapped_buf_reverse( 66static struct nvgpu_mapped_buf *__nvgpu_vm_find_mapped_buf_reverse(
38 struct vm_gk20a *vm, struct dma_buf *dmabuf, u32 kind) 67 struct vm_gk20a *vm, struct dma_buf *dmabuf, u32 kind)
39{ 68{