summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h
index f3be65c2..a112623e 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h
@@ -39,7 +39,7 @@ struct nvgpu_gmmu_attrs;
39 * memory actually was allocated from. 39 * memory actually was allocated from.
40 */ 40 */
41enum nvgpu_aperture { 41enum nvgpu_aperture {
42 APERTURE_INVALID, /* unallocated or N/A */ 42 APERTURE_INVALID = 0, /* unallocated or N/A */
43 APERTURE_SYSMEM, 43 APERTURE_SYSMEM,
44 APERTURE_VIDMEM 44 APERTURE_VIDMEM
45}; 45};
@@ -122,6 +122,24 @@ static inline const char *nvgpu_aperture_str(enum nvgpu_aperture aperture)
122 return "UNKNOWN"; 122 return "UNKNOWN";
123} 123}
124 124
125/*
126 * Returns true if the passed nvgpu_mem has been allocated (i.e it's valid for
127 * subsequent use).
128 */
129static inline bool nvgpu_mem_is_valid(struct nvgpu_mem *mem)
130{
131 /*
132 * Internally the DMA APIs must set/unset the aperture flag when
133 * allocating/freeing the buffer. So check that to see if the *mem
134 * has been allocated or not.
135 *
136 * This relies on mem_descs being zeroed before being initialized since
137 * APERTURE_INVALID is equal to 0.
138 */
139 return mem->aperture != APERTURE_INVALID;
140
141}
142
125/** 143/**
126 * nvgpu_mem_create_from_mem - Create a new nvgpu_mem struct from an old one. 144 * nvgpu_mem_create_from_mem - Create a new nvgpu_mem struct from an old one.
127 * 145 *