From 2c076a01e5bd0949032ef81cd0e2d37bdecafba5 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 24 May 2022 21:16:30 -0400 Subject: gpu-paging: Functions to support initial working version - Buffer deallocation (+IOCTL) - Buffer reallocation - Private dmabuf user list and accessor --- include/linux/nvmap.h | 18 ++++++++++++++++++ include/uapi/linux/nvmap.h | 2 ++ 2 files changed, 20 insertions(+) (limited to 'include') diff --git a/include/linux/nvmap.h b/include/linux/nvmap.h index b8d267691..7a8181ca5 100644 --- a/include/linux/nvmap.h +++ b/include/linux/nvmap.h @@ -65,6 +65,24 @@ ulong nvmap_iovmm_get_used_pages(void); int nvmap_register_vidmem_carveout(struct device *dma_dev, phys_addr_t base, size_t size); +/* The following two functions are to help enable DRAM + * overprovising via paging. These functions allow the + * physical frames backing an nvmap dma_buf to be freed + * (for example, after their contents has been saved + * elsewhere by paging logic), and to be reallocated + * (such as when other code is ready to repopulate them). + * Both functions preserve any open nvmap handles. + */ +int nvmap_dealloc_dmabuf(struct dma_buf *dmabuf); +int nvmap_realloc_dmabuf(struct dma_buf *dmabuf); + +/* Some drivers (such as nvgpu) store parallel structures + * for each dmabuf to track internal state. To allow these + * drivers to quickly access their state from a *dmabuf or + * FD, we allow them access to a per-dmabuf list_head. + */ +struct list_head* nvmap_get_priv_list(struct dma_buf *dmabuf); + /* * A heap can be mapped to memory other than DRAM. * The HW, controls the memory, can be power gated/ungated diff --git a/include/uapi/linux/nvmap.h b/include/uapi/linux/nvmap.h index 66eda75ce..5fea19ac8 100644 --- a/include/uapi/linux/nvmap.h +++ b/include/uapi/linux/nvmap.h @@ -304,6 +304,8 @@ struct nvmap_handle_parameters { */ #define NVMAP_IOC_FREE _IO(NVMAP_IOC_MAGIC, 4) +#define NVMAP_IOC_DEALLOC _IO(NVMAP_IOC_MAGIC, 9) + /* Maps the region of the specified handle into a user-provided virtual address * that was previously created via an mmap syscall on this fd */ #define NVMAP_IOC_MMAP _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller) -- cgit v1.2.2