diff --git a/drivers/video/tegra/nvmap/nvmap_alloc.c b/drivers/video/tegra/nvmap/nvmap_alloc.c index ee3bf44b..3149c76b 100644 --- a/drivers/video/tegra/nvmap/nvmap_alloc.c +++ b/drivers/video/tegra/nvmap/nvmap_alloc.c @@ -18,6 +18,7 @@ #include "nvmap_priv.h" #include "nvmap_alloc.h" #include "nvmap_alloc_int.h" +#include "nvmap_dmabuf.h" bool nvmap_convert_carveout_to_iovmm; bool nvmap_convert_iovmm_to_carveout; diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c index 8af6bbd8..d06abd38 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev.c +++ b/drivers/video/tegra/nvmap/nvmap_dev.c @@ -45,6 +45,7 @@ #include "nvmap_priv.h" #include "nvmap_alloc.h" #include "nvmap_ioctl.h" +#include "nvmap_dmabuf.h" #include #define NVMAP_CARVEOUT_KILLER_RETRY_TIME 100 /* msecs */ diff --git a/drivers/video/tegra/nvmap/nvmap_dmabuf.c b/drivers/video/tegra/nvmap/nvmap_dmabuf.c index 8a1c606e..048a029d 100644 --- a/drivers/video/tegra/nvmap/nvmap_dmabuf.c +++ b/drivers/video/tegra/nvmap/nvmap_dmabuf.c @@ -33,6 +33,7 @@ #include "nvmap_priv.h" #include "nvmap_ioctl.h" #include "nvmap_alloc.h" +#include "nvmap_dmabuf.h" #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_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; @@ -554,7 +555,7 @@ err_nomem: 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) { int ret; diff --git a/drivers/video/tegra/nvmap/nvmap_dmabuf.h b/drivers/video/tegra/nvmap/nvmap_dmabuf.h new file mode 100644 index 00000000..40d910a0 --- /dev/null +++ b/drivers/video/tegra/nvmap/nvmap_dmabuf.h @@ -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 */ diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index d2362ff6..1aea0996 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -28,6 +28,7 @@ #include "nvmap_priv.h" #include "nvmap_ioctl.h" #include "nvmap_alloc.h" +#include "nvmap_dmabuf.h" /* * Verifies that the passed ID is a valid handle ID. Then the passed client's diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 50bbba09..48ae2d5c 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -36,6 +36,7 @@ #include "nvmap_ioctl.h" #include "nvmap_priv.h" #include "nvmap_alloc.h" +#include "nvmap_dmabuf.h" #include #include diff --git a/drivers/video/tegra/nvmap/nvmap_priv.h b/drivers/video/tegra/nvmap/nvmap_priv.h index 75249ded..2b0fe4ca 100644 --- a/drivers/video/tegra/nvmap/nvmap_priv.h +++ b/drivers/video/tegra/nvmap/nvmap_priv.h @@ -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, 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); 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 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, 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); -/* 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 nvmap_handle *h); void __nvmap_free_sg_table(struct nvmap_client *client, struct nvmap_handle *h, struct sg_table *sgt); void *__nvmap_mmap(struct nvmap_handle *h); 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, 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) { @@ -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); #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, u32 id); diff --git a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c index 936ab8dc..a34d1186 100644 --- a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c +++ b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c @@ -22,6 +22,7 @@ #include #include "nvmap_priv.h" #include "nvmap_sci_ipc.h" +#include "nvmap_dmabuf.h" struct nvmap_sci_ipc { struct rb_root entries;