Files
linux-nv-oot/drivers/video/tegra/nvmap/nvmap_alloc.h
Ketan Patil 46cb2cd937 video: tegra: nvmap: Move Alloc related code to Alloc Unit
- Query heap functionality belongs to nvmap_alloc unit, as heap is
managed by it. Hence move the function to query the heap to nvmap_alloc
unit.
- Move nvmap_get_user_pages function to nvmap_alloc unit as it is
relevant for nvmap_alloc unit.
- Move nvmap_dma_alloc_attrs/free_attrs functions to nvmap_alloc unit
as they are more relevant for nvmap_alloc unit.
- Move dma_coherent_mem_replica, nvmap_carveout_node structs to
nvmap_alloc unit.
- Cleanup unused macros from nvmap_priv.h

JIRA TMM-5694

Change-Id: I8884831771443de7db0e95c3b2dfc43c03f7c48e
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3214196
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:07 +00:00

116 lines
3.6 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
#ifndef __NVMAP_ALLOC_H
#define __NVMAP_ALLOC_H
struct nvmap_heap;
struct debugfs_info;
struct nvmap_carveout_node;
void *nvmap_altalloc(size_t len);
void nvmap_altfree(void *ptr, size_t len);
int nvmap_alloc_handle(struct nvmap_client *client,
struct nvmap_handle *h, unsigned int heap_mask,
size_t align, u8 kind,
unsigned int flags, unsigned int peer);
int nvmap_alloc_handle_from_va(struct nvmap_client *client,
struct nvmap_handle *h,
ulong addr,
unsigned int flags,
unsigned int heap_mask);
int nvmap_get_user_pages(ulong vaddr,
size_t nr_page, struct page **pages,
bool is_user_flags, u32 user_foll_flags);
void _nvmap_handle_free(struct nvmap_handle *h);
int __nvmap_cache_maint(struct nvmap_client *client,
struct nvmap_cache_op_64 *op);
int __nvmap_do_cache_maint(struct nvmap_client *client, struct nvmap_handle *h,
unsigned long start, unsigned long end,
unsigned int op, bool clean_only_dirty);
void inner_cache_maint(unsigned int op, void *vaddr, size_t size);
struct nvmap_heap_block *nvmap_carveout_alloc(struct nvmap_client *dev,
struct nvmap_handle *handle,
unsigned long type,
phys_addr_t *start);
int nvmap_create_carveout(const struct nvmap_platform_carveout *co);
int nvmap_query_heap_peer(struct nvmap_carveout_node *co_heap, unsigned int *peer);
size_t nvmap_query_heap_size(struct nvmap_heap *heap);
int nvmap_query_heap(struct nvmap_query_heap_params *op, bool is_numa_aware);
struct nvmap_heap *nvmap_block_to_heap(struct nvmap_heap_block *b);
void nvmap_heap_free(struct nvmap_heap_block *block);
void nvmap_heap_destroy(struct nvmap_heap *heap);
int system_heap_free_mem(unsigned long *mem_val);
int __init nvmap_heap_init(void);
void nvmap_heap_deinit(void);
int nvmap_dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
dma_addr_t device_addr, size_t size, int flags);
struct page **nvmap_pages(struct page **pg_pages, u32 nr_pages);
struct page *nvmap_to_page(struct page *page);
#ifdef NVMAP_CONFIG_PAGE_POOLS
int nvmap_page_pool_clear(void);
int nvmap_page_pool_debugfs_init(struct dentry *nvmap_root);
int nvmap_page_pool_init(struct nvmap_device *dev);
int nvmap_page_pool_fini(struct nvmap_device *dev);
#endif /* NVMAP_CONFIG_PAGE_POOLS */
/* helper functions for nvmap_heap struct */
size_t nvmap_get_heap_free_size(struct nvmap_heap *heap);
int nvmap_get_heap_nid(struct nvmap_heap *heap);
#ifdef NVMAP_CONFIG_DEBUG_MAPS
struct rb_root *nvmap_heap_get_device_ptr(struct nvmap_heap *heap);
#endif /* NVMAP_CONFIG_DEBUG_MAPS */
/* helper functions for nvmap_heap_block struct */
phys_addr_t nvmap_get_heap_block_base(struct nvmap_heap_block *block);
void nvmap_set_heap_block_handle(struct nvmap_heap_block *block, struct nvmap_handle *handle);
/* helper functions for debugfs_info struct */
unsigned int nvmap_get_debug_info_heap(struct debugfs_info *info);
int nvmap_get_debug_info_nid(struct debugfs_info *info);
struct debugfs_info *nvmap_create_debugfs_info(void);
void nvmap_free_debugfs_info(struct debugfs_info *info);
void nvmap_set_debugfs_heap(struct debugfs_info *info, unsigned int heap_bit);
void nvmap_set_debugfs_numa(struct debugfs_info *info, int nid);
/* helper functions for nvmap_carveout_node struct */
unsigned int nvmap_get_heap_bit(struct nvmap_carveout_node *co_heap);
struct nvmap_heap *nvmap_get_heap_ptr(struct nvmap_carveout_node *co_heap);
#endif /* __NVMAP_ALLOC_H */