mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: add FOREIGN_SGT mem flag
Add an internal flag NVGPU_MEM_FLAG_FOREIGN_SGT to specify that the sgt member of an nvgpu_mem must not be freed when the nvgpu_mem is freed. Bug 200145225 Change-Id: I044fb91a5f9d148f38fb0cbf63d0cdfd64a070ce Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1819801 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
f33935f426
commit
9de6d20abb
@@ -177,6 +177,15 @@ struct nvgpu_mem {
|
|||||||
* nvgpu_mem in a system specific way.
|
* nvgpu_mem in a system specific way.
|
||||||
*/
|
*/
|
||||||
#define __NVGPU_MEM_FLAG_NO_DMA (1 << 3)
|
#define __NVGPU_MEM_FLAG_NO_DMA (1 << 3)
|
||||||
|
/*
|
||||||
|
* Some nvgpu_mem objects act as facades to memory buffers owned by
|
||||||
|
* someone else. This internal flag specifies that the sgt field is
|
||||||
|
* "borrowed", and it must not be freed by us.
|
||||||
|
*
|
||||||
|
* Of course the caller will have to make sure that the sgt owner
|
||||||
|
* outlives the nvgpu_mem.
|
||||||
|
*/
|
||||||
|
#define NVGPU_MEM_FLAG_FOREIGN_SGT (1 << 4)
|
||||||
unsigned long mem_flags;
|
unsigned long mem_flags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -392,8 +392,10 @@ void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem)
|
|||||||
if (mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA)
|
if (mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA)
|
||||||
nvgpu_kfree(g, mem->priv.pages);
|
nvgpu_kfree(g, mem->priv.pages);
|
||||||
|
|
||||||
if (mem->priv.sgt)
|
if ((mem->mem_flags & NVGPU_MEM_FLAG_FOREIGN_SGT) == 0 &&
|
||||||
|
mem->priv.sgt != NULL) {
|
||||||
nvgpu_free_sgtable(g, &mem->priv.sgt);
|
nvgpu_free_sgtable(g, &mem->priv.sgt);
|
||||||
|
}
|
||||||
|
|
||||||
dma_dbg_free_done(g, mem->size, "sysmem");
|
dma_dbg_free_done(g, mem->size, "sysmem");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user