From 7acc8a556afbc859f1081e7b624a85b4fa6b7eef Mon Sep 17 00:00:00 2001 From: Yash Bhatt Date: Mon, 25 Mar 2024 07:28:30 +0000 Subject: [PATCH] video: tegra: nvmap: Protect dma memory code nvmap_dma_mark_declared_memory_occupied/unoccupied functions are only getting called when CONFIG_TEGRA_VIRTUALIZATION is defined. So protect the functions under the respective flag. Bug 4479027 Change-Id: If4c00084fde5079778f47fc09c91dccde36fe4d4 Signed-off-by: Yash Bhatt Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3103557 GVS: Gerrit_Virtual_Submit Reviewed-by: Ketan Patil Reviewed-by: Pritesh Raithatha Reviewed-by: Sachin Nikam --- drivers/video/tegra/nvmap/nvmap_init.c | 2 ++ drivers/video/tegra/nvmap/nvmap_priv.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/video/tegra/nvmap/nvmap_init.c b/drivers/video/tegra/nvmap/nvmap_init.c index b1ce30ce..ce82286a 100644 --- a/drivers/video/tegra/nvmap/nvmap_init.c +++ b/drivers/video/tegra/nvmap/nvmap_init.c @@ -580,6 +580,7 @@ void nvmap_dma_free_attrs(struct device *dev, size_t size, void *cpu_addr, } EXPORT_SYMBOL(nvmap_dma_free_attrs); +#ifdef CONFIG_TEGRA_VIRTUALIZATION void *nvmap_dma_mark_declared_memory_occupied(struct device *dev, dma_addr_t device_addr, size_t size) { @@ -631,6 +632,7 @@ void nvmap_dma_mark_declared_memory_unoccupied(struct device *dev, bitmap_clear(mem->bitmap, pos, alloc_size); spin_unlock_irqrestore(&mem->spinlock, flags); } +#endif /* CONFIG_TEGRA_VIRTUALIZATION */ void nvmap_dma_release_coherent_memory(struct dma_coherent_mem_replica *mem) { diff --git a/drivers/video/tegra/nvmap/nvmap_priv.h b/drivers/video/tegra/nvmap/nvmap_priv.h index 4f98b613..ed55815d 100644 --- a/drivers/video/tegra/nvmap/nvmap_priv.h +++ b/drivers/video/tegra/nvmap/nvmap_priv.h @@ -881,10 +881,13 @@ void nvmap_remove_device_name(char *device_name, u32 heap_type); bool dmabuf_is_nvmap(struct dma_buf *dmabuf); struct nvmap_handle *nvmap_handle_get_from_id(struct nvmap_client *client, u32 id); + +#ifdef CONFIG_TEGRA_VIRTUALIZATION void *nvmap_dma_mark_declared_memory_occupied(struct device *dev, dma_addr_t device_addr, size_t size); void nvmap_dma_mark_declared_memory_unoccupied(struct device *dev, dma_addr_t device_addr, size_t size); +#endif /* CONFIG_TEGRA_VIRTUALIZATION */ extern void __dma_flush_area(const void *cpu_va, size_t size); extern void __dma_map_area(const void *cpu_va, size_t size, int dir);