diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.h')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index 82003cd0..7a627354 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/dma-attrs.h> | 22 | #include <linux/dma-attrs.h> |
23 | #include <linux/iommu.h> | 23 | #include <linux/iommu.h> |
24 | #include <linux/tegra-soc.h> | 24 | #include <linux/tegra-soc.h> |
25 | #include <linux/vmalloc.h> | ||
25 | #include <asm/dma-iommu.h> | 26 | #include <asm/dma-iommu.h> |
26 | #include <asm/cacheflush.h> | 27 | #include <asm/cacheflush.h> |
27 | #include "gk20a_allocator.h" | 28 | #include "gk20a_allocator.h" |
@@ -628,4 +629,31 @@ void gk20a_mm_init_pdb(struct gk20a *g, void *inst_ptr, u64 pdb_addr); | |||
628 | extern const struct gk20a_mmu_level gk20a_mm_levels_64k[]; | 629 | extern const struct gk20a_mmu_level gk20a_mm_levels_64k[]; |
629 | extern const struct gk20a_mmu_level gk20a_mm_levels_128k[]; | 630 | extern const struct gk20a_mmu_level gk20a_mm_levels_128k[]; |
630 | 631 | ||
632 | static inline void *nvgpu_alloc(size_t size, bool clear) | ||
633 | { | ||
634 | void *p; | ||
635 | |||
636 | if (size > PAGE_SIZE) { | ||
637 | if (clear) | ||
638 | p = vzalloc(size); | ||
639 | else | ||
640 | p = vmalloc(size); | ||
641 | } else { | ||
642 | if (clear) | ||
643 | p = kzalloc(size, GFP_KERNEL); | ||
644 | else | ||
645 | p = kmalloc(size, GFP_KERNEL); | ||
646 | } | ||
647 | |||
648 | return p; | ||
649 | } | ||
650 | |||
651 | static inline void nvgpu_free(void *p) | ||
652 | { | ||
653 | if (virt_addr_valid(p)) | ||
654 | kfree(p); | ||
655 | else | ||
656 | vfree(p); | ||
657 | } | ||
658 | |||
631 | #endif /* MM_GK20A_H */ | 659 | #endif /* MM_GK20A_H */ |