diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index b943aabfc..abcf36f10 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c @@ -204,9 +204,7 @@ int nvgpu_dma_alloc_flags_vid_at(struct gk20a *g, unsigned long flags, } if (at) - mem->fixed = true; - else - mem->fixed = false; + mem->mem_flags |= NVGPU_MEM_FLAG_FIXED; mem->priv.sgt = nvgpu_kzalloc(g, sizeof(struct sg_table)); if (!mem->priv.sgt) { @@ -375,7 +373,7 @@ static void nvgpu_dma_free_vid(struct gk20a *g, struct nvgpu_mem *mem) /* Sanity check - only this supported when allocating. */ WARN_ON(mem->priv.flags != NVGPU_DMA_NO_KERNEL_MAPPING); - if (mem->user_mem) { + if (mem->mem_flags & NVGPU_MEM_FLAG_USER_MEM) { nvgpu_mutex_acquire(&g->mm.vidmem.clear_list_mutex); was_empty = nvgpu_list_empty(&g->mm.vidmem.clear_list_head); nvgpu_list_add_tail(&mem->clear_list_entry, diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 79aa44a58..00892e98a 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -1862,7 +1862,7 @@ int gk20a_vidmem_buf_alloc(struct gk20a *g, size_t bytes) if (!buf->mem) goto err_kfree; - buf->mem->user_mem = true; + buf->mem->mem_flags |= NVGPU_MEM_FLAG_USER_MEM; err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); if (err) diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 397e9ab17..b01fbec54 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h @@ -53,6 +53,21 @@ struct nvgpu_mem { * the struct is just a copy of another nvgpu_mem struct. */ #define NVGPU_MEM_FLAG_SHADOW_COPY (1 << 0) + + /* + * Specify that the GVA mapping is a fixed mapping - that is the caller + * chose the GPU VA, not the GMMU mapping function. Only relevant for + * VIDMEM. + */ +#define NVGPU_MEM_FLAG_FIXED (1 << 1) + + /* + * Set for user generated VIDMEM allocations. This triggers a special + * cleanup path that clears the vidmem on free. Given that the VIDMEM is + * zeroed on boot this means that all user vidmem allocations are + * therefor zeroed (to prevent leaking information in VIDMEM buffers). + */ +#define NVGPU_MEM_FLAG_USER_MEM (1 << 2) unsigned long mem_flags; /* @@ -63,8 +78,6 @@ struct nvgpu_mem { /* * Fields only populated for vidmem allocations. */ - bool fixed; - bool user_mem; struct nvgpu_allocator *allocator; struct nvgpu_list_node clear_list_entry;