help
Force using nvmap instead of dma mapping API
-config TEGRA_GRHOST_USE_DMABUF
- bool "Support dmabuf buffers"
- default y
- select DMA_SHARED_BUFFER
- help
- Support dmabuf buffers.
-
config TEGRA_GRHOST_DEFAULT_TIMEOUT
depends on TEGRA_GRHOST
int "Default timeout for submits"
obj-$(t12x_or_higher_config) += vic03/
obj-$(t12x_or_higher_config) += nvhost_allocator.o
obj-$(CONFIG_TEGRA_GRHOST_USE_NVMAP) += nvmap.o
-obj-$(CONFIG_TEGRA_GRHOST_USE_DMABUF) += dmabuf.o
obj-$(CONFIG_TEGRA_GRHOST_SYNC) += nvhost_sync.o
+++ /dev/null
-/*
- * drivers/video/tegra/host/dmabuf.c
- *
- * Tegra Graphics Host DMA-BUF support
- *
- * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux/dma-buf.h>
-#include <linux/nvhost.h>
-#include "chip_support.h"
-#include "nvhost_memmgr.h"
-
-static inline struct dma_buf_attachment *to_dmabuf_att(struct mem_handle *h)
-{
- return (struct dma_buf_attachment *)(((uintptr_t)h) & ~0x3);
-}
-
-static inline struct dma_buf *to_dmabuf(struct mem_handle *h)
-{
- return to_dmabuf_att(h)->dmabuf;
-}
-
-static inline int to_dmabuf_fd(ulong id)
-{
- return nvhost_memmgr_id(id) >> 2;
-}
-void nvhost_dmabuf_put(struct mem_handle *handle)
-{
- struct dma_buf_attachment *attach = to_dmabuf_att(handle);
- struct dma_buf *dmabuf = attach->dmabuf;
- dma_buf_detach(dmabuf, attach);
- dma_buf_put(dmabuf);
-}
-
-struct sg_table *nvhost_dmabuf_pin(struct mem_handle *handle)
-{
- return dma_buf_map_attachment(to_dmabuf_att(handle),
- DMA_BIDIRECTIONAL);
-}
-
-void nvhost_dmabuf_unpin(struct mem_handle *handle, struct sg_table *sgt)
-{
- dma_buf_unmap_attachment(to_dmabuf_att(handle), sgt, DMA_BIDIRECTIONAL);
-}
-
-
-void *nvhost_dmabuf_mmap(struct mem_handle *handle)
-{
- return dma_buf_vmap(to_dmabuf(handle));
-}
-
-void nvhost_dmabuf_munmap(struct mem_handle *handle, void *addr)
-{
- dma_buf_vunmap(to_dmabuf(handle), addr);
-}
-
-void *nvhost_dmabuf_kmap(struct mem_handle *handle, unsigned int pagenum)
-{
- return dma_buf_kmap(to_dmabuf(handle), pagenum);
-}
-
-void nvhost_dmabuf_kunmap(struct mem_handle *handle, unsigned int pagenum,
- void *addr)
-{
- dma_buf_kunmap(to_dmabuf(handle), pagenum, addr);
-}
-
-size_t nvhost_dmabuf_size(struct mem_handle *handle)
-{
- struct dma_buf_attachment *attach = to_dmabuf_att(handle);
- struct dma_buf *dmabuf = attach->dmabuf;
- return dmabuf->size;
-}
-
-struct mem_handle *nvhost_dmabuf_get(ulong id, struct platform_device *dev)
-{
- struct mem_handle *h;
- struct dma_buf *buf;
-
- buf = dma_buf_get(to_dmabuf_fd(id));
- if (IS_ERR(buf))
- return (struct mem_handle *)buf;
- else {
- h = (struct mem_handle *)dma_buf_attach(buf, &dev->dev);
- if (IS_ERR(h)) {
- dma_buf_put(buf);
- return (struct mem_handle *)h;
- }
- }
-
- return (struct mem_handle *) ((uintptr_t)h | mem_mgr_type_dmabuf);
-}
+++ /dev/null
-/*
- * drivers/video/tegra/host/dmabuf.h
- *
- * Tegra Graphics Host dmabuf memory manager
- *
- * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __NVHOST_DMABUF_H
-#define __NVHOST_DMABUF_H
-
-#include "nvhost_memmgr.h"
-
-struct nvhost_chip_support;
-struct platform_device;
-
-struct mem_mgr *nvhost_dmabuf_alloc_mgr(void);
-void nvhost_dmabuf_put_mgr(struct mem_mgr *mgr);
-struct mem_mgr *nvhost_dmabuf_get_mgr(struct mem_mgr *mgr);
-struct mem_mgr *nvhost_dmabuf_get_mgr_file(int fd);
-void nvhost_dmabuf_put(struct mem_handle *handle);
-struct sg_table *nvhost_dmabuf_pin(struct mem_handle *handle);
-void nvhost_dmabuf_unpin(struct mem_handle *handle, struct sg_table *sgt);
-void *nvhost_dmabuf_mmap(struct mem_handle *handle);
-void nvhost_dmabuf_munmap(struct mem_handle *handle, void *addr);
-void *nvhost_dmabuf_kmap(struct mem_handle *handle, unsigned int pagenum);
-void nvhost_dmabuf_kunmap(struct mem_handle *handle, unsigned int pagenum,
- void *addr);
-struct mem_handle *nvhost_dmabuf_get(ulong id, struct platform_device *dev);
-int nvhost_dmabuf_get_param(struct mem_handle *handle,
- u32 param, u64 *result);
-#endif
#include "nvmap.h"
#include <linux/nvmap.h>
#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
-#include "dmabuf.h"
-#endif
#include "chip_support.h"
struct mem_mgr *nvhost_memmgr_alloc_mgr(void)
struct mem_mgr *mgr = NULL;
#ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
mgr = nvhost_nvmap_alloc_mgr();
-#else
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- mgr = (struct mem_mgr)1;
-#endif
#endif
return mgr;
{
#ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
nvhost_nvmap_put_mgr(mgr);
-#else
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- mgr = (struct mem_mgr)1;
-#endif
#endif
}
struct mem_mgr *mgr = NULL;
#ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
mgr = nvhost_nvmap_get_mgr(_mgr);
-#else
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- mgr = (struct mem_mgr)1;
-#endif
#endif
return mgr;
struct mem_mgr *mgr = NULL;
#ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
mgr = nvhost_nvmap_get_mgr_file(fd);
-#else
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- mgr = (struct mem_mgr)1;
-#endif
#endif
return mgr;
case mem_mgr_type_nvmap:
h = (struct mem_handle *) nvhost_nvmap_get(mgr, id, dev);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- h = (struct mem_handle *) nvhost_dmabuf_get(id, dev);
- break;
#endif
default:
break;
case mem_mgr_type_nvmap:
nvhost_nvmap_put(mgr, handle);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- nvhost_dmabuf_put(handle);
- break;
#endif
default:
break;
case mem_mgr_type_nvmap:
return nvhost_nvmap_pin(mgr, handle, dev, rw_flag);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- return nvhost_dmabuf_pin(handle);
- break;
#endif
default:
return 0;
case mem_mgr_type_nvmap:
nvhost_nvmap_unpin(mgr, handle, dev, sgt);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- nvhost_dmabuf_unpin(handle, sgt);
- break;
#endif
default:
break;
case mem_mgr_type_nvmap:
return nvhost_nvmap_mmap(handle);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- return nvhost_dmabuf_mmap(handle);
- break;
#endif
default:
return 0;
case mem_mgr_type_nvmap:
nvhost_nvmap_munmap(handle, addr);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- nvhost_dmabuf_munmap(handle, addr);
- break;
#endif
default:
break;
case mem_mgr_type_nvmap:
return nvhost_nvmap_kmap(handle, pagenum);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- return nvhost_dmabuf_kmap(handle, pagenum);
- break;
#endif
default:
return 0;
case mem_mgr_type_nvmap:
nvhost_nvmap_kunmap(handle, pagenum, addr);
break;
-#endif
-#ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
- case mem_mgr_type_dmabuf:
- nvhost_dmabuf_kunmap(handle, pagenum, addr);
- break;
#endif
default:
break;