diff options
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/linux-dma.c | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index e69274b5..8e62a1d6 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | |||
@@ -174,6 +174,15 @@ struct nvgpu_mem { | |||
174 | * nvgpu_mem in a system specific way. | 174 | * nvgpu_mem in a system specific way. |
175 | */ | 175 | */ |
176 | #define __NVGPU_MEM_FLAG_NO_DMA (1 << 3) | 176 | #define __NVGPU_MEM_FLAG_NO_DMA (1 << 3) |
177 | /* | ||
178 | * Some nvgpu_mem objects act as facades to memory buffers owned by | ||
179 | * someone else. This internal flag specifies that the sgt field is | ||
180 | * "borrowed", and it must not be freed by us. | ||
181 | * | ||
182 | * Of course the caller will have to make sure that the sgt owner | ||
183 | * outlives the nvgpu_mem. | ||
184 | */ | ||
185 | #define NVGPU_MEM_FLAG_FOREIGN_SGT (1 << 4) | ||
177 | unsigned long mem_flags; | 186 | unsigned long mem_flags; |
178 | 187 | ||
179 | /* | 188 | /* |
diff --git a/drivers/gpu/nvgpu/os/linux/linux-dma.c b/drivers/gpu/nvgpu/os/linux/linux-dma.c index 52987a87..d704b2a4 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-dma.c +++ b/drivers/gpu/nvgpu/os/linux/linux-dma.c | |||
@@ -392,8 +392,10 @@ void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem) | |||
392 | if (mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) | 392 | if (mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) |
393 | nvgpu_kfree(g, mem->priv.pages); | 393 | nvgpu_kfree(g, mem->priv.pages); |
394 | 394 | ||
395 | if (mem->priv.sgt) | 395 | if ((mem->mem_flags & NVGPU_MEM_FLAG_FOREIGN_SGT) == 0 && |
396 | mem->priv.sgt != NULL) { | ||
396 | nvgpu_free_sgtable(g, &mem->priv.sgt); | 397 | nvgpu_free_sgtable(g, &mem->priv.sgt); |
398 | } | ||
397 | 399 | ||
398 | dma_dbg_free_done(g, mem->size, "sysmem"); | 400 | dma_dbg_free_done(g, mem->size, "sysmem"); |
399 | 401 | ||