video: tegra: nvmap: Add header file for nvmap_dmabuf unit

Refactor nvmap dmabuf code by creating header file for functions
exposed by the unit and make internal functions static.

JIRA TMM-5625

Change-Id: Ic5e99506a3362937dc5d1eb3bd05047c9ffdac6a
Signed-off-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3203525
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Pritesh Raithatha
2024-08-30 10:55:01 +00:00
committed by Jon Hunter
parent b55db09752
commit db0a9ab702
8 changed files with 36 additions and 21 deletions

View File

@@ -18,6 +18,7 @@
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_alloc.h" #include "nvmap_alloc.h"
#include "nvmap_alloc_int.h" #include "nvmap_alloc_int.h"
#include "nvmap_dmabuf.h"
bool nvmap_convert_carveout_to_iovmm; bool nvmap_convert_carveout_to_iovmm;
bool nvmap_convert_iovmm_to_carveout; bool nvmap_convert_iovmm_to_carveout;

View File

@@ -45,6 +45,7 @@
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_alloc.h" #include "nvmap_alloc.h"
#include "nvmap_ioctl.h" #include "nvmap_ioctl.h"
#include "nvmap_dmabuf.h"
#include <linux/pagewalk.h> #include <linux/pagewalk.h>
#define NVMAP_CARVEOUT_KILLER_RETRY_TIME 100 /* msecs */ #define NVMAP_CARVEOUT_KILLER_RETRY_TIME 100 /* msecs */

View File

@@ -33,6 +33,7 @@
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_ioctl.h" #include "nvmap_ioctl.h"
#include "nvmap_alloc.h" #include "nvmap_alloc.h"
#include "nvmap_dmabuf.h"
#define NVMAP_DMABUF_ATTACH nvmap_dmabuf_attach #define NVMAP_DMABUF_ATTACH nvmap_dmabuf_attach
@@ -362,7 +363,7 @@ static int __nvmap_dmabuf_begin_cpu_access(struct dma_buf *dmabuf,
#define NVMAP_DMABUF_BEGIN_CPU_ACCESS __nvmap_dmabuf_begin_cpu_access #define NVMAP_DMABUF_BEGIN_CPU_ACCESS __nvmap_dmabuf_begin_cpu_access
#define NVMAP_DMABUF_END_CPU_ACCESS __nvmap_dmabuf_end_cpu_access #define NVMAP_DMABUF_END_CPU_ACCESS __nvmap_dmabuf_end_cpu_access
int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma) static int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
{ {
struct nvmap_vma_priv *priv; struct nvmap_vma_priv *priv;
@@ -554,7 +555,7 @@ err_nomem:
return ERR_PTR(err); return ERR_PTR(err);
} }
int __nvmap_dmabuf_fd(struct nvmap_client *client, static int __nvmap_dmabuf_fd(struct nvmap_client *client,
struct dma_buf *dmabuf, int flags) struct dma_buf *dmabuf, int flags)
{ {
int ret; int ret;

View File

@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
#ifndef __NVMAP_DMABUF_H
#define __NVMAP_DMABUF_H
int nvmap_dmabuf_stash_init(void);
void nvmap_dmabuf_stash_deinit(void);
bool dmabuf_is_nvmap(struct dma_buf *dmabuf);
struct dma_buf *__nvmap_make_dmabuf(struct nvmap_client *client,
struct nvmap_handle *handle,
bool ro_buf);
int nvmap_get_dmabuf_fd(struct nvmap_client *client,
struct nvmap_handle *h,
bool is_ro);
struct nvmap_handle *nvmap_handle_get_from_dmabuf_fd(
struct nvmap_client *client,
int fd);
int is_nvmap_dmabuf_fd_ro(int fd, bool *is_ro);
int nvmap_dmabuf_duplicate_gen_fd(struct nvmap_client *client,
struct dma_buf *dmabuf);
#endif /* __NVMAP_DMABUF_H */

View File

@@ -28,6 +28,7 @@
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_ioctl.h" #include "nvmap_ioctl.h"
#include "nvmap_alloc.h" #include "nvmap_alloc.h"
#include "nvmap_dmabuf.h"
/* /*
* Verifies that the passed ID is a valid handle ID. Then the passed client's * Verifies that the passed ID is a valid handle ID. Then the passed client's

View File

@@ -36,6 +36,7 @@
#include "nvmap_ioctl.h" #include "nvmap_ioctl.h"
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_alloc.h" #include "nvmap_alloc.h"
#include "nvmap_dmabuf.h"
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/nodemask.h> #include <linux/nodemask.h>

View File

@@ -462,8 +462,6 @@ struct nvmap_handle_ref *nvmap_create_handle_from_va(struct nvmap_client *client
struct nvmap_handle_ref *nvmap_dup_handle_ro(struct nvmap_client *client, struct nvmap_handle_ref *nvmap_dup_handle_ro(struct nvmap_client *client,
int fd); int fd);
int is_nvmap_dmabuf_fd_ro(int fd, bool *is_ro);
int is_nvmap_id_ro(struct nvmap_client *client, int id, bool *is_ro); int is_nvmap_id_ro(struct nvmap_client *client, int id, bool *is_ro);
struct nvmap_handle_ref *nvmap_duplicate_handle(struct nvmap_client *client, struct nvmap_handle_ref *nvmap_duplicate_handle(struct nvmap_client *client,
@@ -492,13 +490,6 @@ void nvmap_handle_add(struct nvmap_device *dev, struct nvmap_handle *h);
int is_nvmap_vma(struct vm_area_struct *vma); int is_nvmap_vma(struct vm_area_struct *vma);
int nvmap_get_dmabuf_fd(struct nvmap_client *client, struct nvmap_handle *h,
bool is_ro);
struct nvmap_handle *nvmap_handle_get_from_dmabuf_fd(
struct nvmap_client *client, int fd);
int nvmap_dmabuf_duplicate_gen_fd(struct nvmap_client *client,
struct dma_buf *dmabuf);
int nvmap_get_handle_param(struct nvmap_client *client, int nvmap_get_handle_param(struct nvmap_client *client,
struct nvmap_handle_ref *ref, u32 param, u64 *result); struct nvmap_handle_ref *ref, u32 param, u64 *result);
@@ -510,23 +501,14 @@ extern void v7_clean_kern_cache_all(void *);
void nvmap_flush_cache(struct page **pages, int numpages); void nvmap_flush_cache(struct page **pages, int numpages);
/* Internal API to support dmabuf */
struct dma_buf *__nvmap_make_dmabuf(struct nvmap_client *client,
struct nvmap_handle *handle, bool ro_buf);
struct sg_table *__nvmap_sg_table(struct nvmap_client *client, struct sg_table *__nvmap_sg_table(struct nvmap_client *client,
struct nvmap_handle *h); struct nvmap_handle *h);
void __nvmap_free_sg_table(struct nvmap_client *client, void __nvmap_free_sg_table(struct nvmap_client *client,
struct nvmap_handle *h, struct sg_table *sgt); struct nvmap_handle *h, struct sg_table *sgt);
void *__nvmap_mmap(struct nvmap_handle *h); void *__nvmap_mmap(struct nvmap_handle *h);
void __nvmap_munmap(struct nvmap_handle *h, void *addr); void __nvmap_munmap(struct nvmap_handle *h, void *addr);
int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma);
struct nvmap_client *__nvmap_create_client(struct nvmap_device *dev, struct nvmap_client *__nvmap_create_client(struct nvmap_device *dev,
const char *name); const char *name);
int __nvmap_dmabuf_fd(struct nvmap_client *client,
struct dma_buf *dmabuf, int flags);
int nvmap_dmabuf_stash_init(void);
void nvmap_dmabuf_stash_deinit(void);
static inline bool nvmap_page_dirty(struct page *page) static inline bool nvmap_page_dirty(struct page *page)
{ {
@@ -804,7 +786,6 @@ void nvmap_add_device_name(char *device_name, u64 dma_mask, u32 heap_type);
void nvmap_remove_device_name(char *device_name, u32 heap_type); void nvmap_remove_device_name(char *device_name, u32 heap_type);
#endif /* NVMAP_CONFIG_DEBUG_MAPS */ #endif /* NVMAP_CONFIG_DEBUG_MAPS */
bool dmabuf_is_nvmap(struct dma_buf *dmabuf);
struct nvmap_handle *nvmap_handle_get_from_id(struct nvmap_client *client, struct nvmap_handle *nvmap_handle_get_from_id(struct nvmap_client *client,
u32 id); u32 id);

View File

@@ -22,6 +22,7 @@
#include <trace/events/nvmap.h> #include <trace/events/nvmap.h>
#include "nvmap_priv.h" #include "nvmap_priv.h"
#include "nvmap_sci_ipc.h" #include "nvmap_sci_ipc.h"
#include "nvmap_dmabuf.h"
struct nvmap_sci_ipc { struct nvmap_sci_ipc {
struct rb_root entries; struct rb_root entries;