summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2012-05-31 15:04:53 +0300
committerSimone Willett <swillett@nvidia.com>2012-06-11 16:27:55 -0700
commitb08927a712005ae3f6941e59f530b7896ac5f407 (patch)
treec6a974f266565dec2b7d619a67d2e9a61677e553
parent273ceab50c24ba53fcc7a90072dd02d1038d2a97 (diff)
video: tegra: host: Abstract nvmap support
Abstract nvmap support to one file, and use it via function pointers from other parts of nvhost. Bug 965206 Change-Id: I4e5e7de4271e0797d117ac8210af4732b6018973 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/105665 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com> Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
-rw-r--r--drivers/video/tegra/Kconfig7
-rw-r--r--drivers/video/tegra/host/Makefile5
-rw-r--r--drivers/video/tegra/host/bus_client.c19
-rw-r--r--drivers/video/tegra/host/chip_support.h24
-rw-r--r--drivers/video/tegra/host/dev.c21
-rw-r--r--drivers/video/tegra/host/dev.h4
-rw-r--r--drivers/video/tegra/host/gr3d/gr3d.c28
-rw-r--r--drivers/video/tegra/host/gr3d/gr3d_t20.c18
-rw-r--r--drivers/video/tegra/host/gr3d/gr3d_t30.c20
-rw-r--r--drivers/video/tegra/host/host1x/host1x_cdma.c43
-rw-r--r--drivers/video/tegra/host/host1x/host1x_cdma.h1
-rw-r--r--drivers/video/tegra/host/host1x/host1x_channel.c8
-rw-r--r--drivers/video/tegra/host/host1x/host1x_debug.c18
-rw-r--r--drivers/video/tegra/host/host1x/host1x_hwctx.h4
-rw-r--r--drivers/video/tegra/host/host1x/host1x_intr.c1
-rw-r--r--drivers/video/tegra/host/mpe/mpe.c39
-rw-r--r--drivers/video/tegra/host/nvhost_cdma.c13
-rw-r--r--drivers/video/tegra/host/nvhost_cdma.h27
-rw-r--r--drivers/video/tegra/host/nvhost_hwctx.h1
-rw-r--r--drivers/video/tegra/host/nvhost_intr.c1
-rw-r--r--drivers/video/tegra/host/nvhost_job.c40
-rw-r--r--drivers/video/tegra/host/nvhost_job.h9
-rw-r--r--drivers/video/tegra/host/nvhost_memmgr.c34
-rw-r--r--drivers/video/tegra/host/nvhost_memmgr.h38
-rw-r--r--drivers/video/tegra/host/nvhost_syncpt.c1
-rw-r--r--drivers/video/tegra/host/nvhost_syncpt.h1
-rw-r--r--drivers/video/tegra/host/nvmap.c100
-rw-r--r--drivers/video/tegra/host/nvmap.h27
-rw-r--r--drivers/video/tegra/host/t20/t20.c4
-rw-r--r--drivers/video/tegra/host/t30/t30.c5
30 files changed, 397 insertions, 164 deletions
diff --git a/drivers/video/tegra/Kconfig b/drivers/video/tegra/Kconfig
index 15c2acfa8cc7..fc057a50d361 100644
--- a/drivers/video/tegra/Kconfig
+++ b/drivers/video/tegra/Kconfig
@@ -7,6 +7,13 @@ config TEGRA_GRHOST
help
Driver for the Tegra graphics host hardware.
+config TEGRA_GRHOST_USE_NVMAP
+ bool "Use nvmap as graphics memory manager"
+ default y
+ help
+ Use nvmap as the graphics memory manager. This is the only
+ choice at the moment.
+
config TEGRA_DC
tristate "Tegra Display Contoller"
depends on ARCH_TEGRA && TEGRA_GRHOST
diff --git a/drivers/video/tegra/host/Makefile b/drivers/video/tegra/host/Makefile
index f228a3ad0396..23a9226da235 100644
--- a/drivers/video/tegra/host/Makefile
+++ b/drivers/video/tegra/host/Makefile
@@ -10,7 +10,8 @@ nvhost-objs = \
dev.o \
debug.o \
bus_client.o \
- chip_support.o
+ chip_support.o \
+ nvhost_memmgr.o
obj-$(CONFIG_TEGRA_GRHOST) += mpe/
obj-$(CONFIG_TEGRA_GRHOST) += gr3d/
@@ -21,3 +22,5 @@ obj-$(CONFIG_TEGRA_GRHOST) += gr2d/
obj-$(CONFIG_TEGRA_GRHOST) += isp/
obj-$(CONFIG_TEGRA_GRHOST) += vi/
obj-$(CONFIG_TEGRA_GRHOST) += nvhost.o
+
+obj-$(CONFIG_TEGRA_GRHOST_USE_NVMAP) += nvmap.o
diff --git a/drivers/video/tegra/host/bus_client.c b/drivers/video/tegra/host/bus_client.c
index 6bfce9a3cb2a..ae532a2cba27 100644
--- a/drivers/video/tegra/host/bus_client.c
+++ b/drivers/video/tegra/host/bus_client.c
@@ -36,7 +36,6 @@
#include <linux/nvhost.h>
#include <linux/nvhost_ioctl.h>
-#include <linux/nvmap.h>
#include <mach/gpufuse.h>
#include <mach/hardware.h>
#include <mach/iomap.h>
@@ -44,6 +43,8 @@
#include "debug.h"
#include "bus_client.h"
#include "dev.h"
+#include "nvhost_memmgr.h"
+#include "chip_support.h"
#include "nvhost_acm.h"
#include "nvhost_channel.h"
@@ -112,7 +113,7 @@ struct nvhost_channel_userctx {
struct nvhost_submit_hdr_ext hdr;
int num_relocshifts;
struct nvhost_job *job;
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
u32 timeout;
u32 priority;
int clientid;
@@ -135,7 +136,7 @@ static int nvhost_channelrelease(struct inode *inode, struct file *filp)
if (priv->job)
nvhost_job_put(priv->job);
- nvmap_client_put(priv->nvmap);
+ mem_op().put_mgr(priv->memmgr);
kfree(priv);
return 0;
}
@@ -188,7 +189,7 @@ static int set_submit(struct nvhost_channel_userctx *ctx)
ctx->hdr.syncpt_id))
return -EIO;
- if (!ctx->nvmap) {
+ if (!ctx->memmgr) {
dev_err(&ndev->dev, "no nvmap context set\n");
return -EFAULT;
}
@@ -196,7 +197,7 @@ static int set_submit(struct nvhost_channel_userctx *ctx)
ctx->job = nvhost_job_alloc(ctx->ch,
ctx->hwctx,
&ctx->hdr,
- ctx->nvmap,
+ ctx->memmgr,
ctx->priority,
ctx->clientid);
if (!ctx->job)
@@ -471,17 +472,17 @@ static long nvhost_channelctl(struct file *filp,
case NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD:
{
int fd = (int)((struct nvhost_set_nvmap_fd_args *)buf)->fd;
- struct nvmap_client *new_client = nvmap_client_get_file(fd);
+ struct mem_mgr *new_client = mem_op().get_mgr_file(fd);
if (IS_ERR(new_client)) {
err = PTR_ERR(new_client);
break;
}
- if (priv->nvmap)
- nvmap_client_put(priv->nvmap);
+ if (priv->memmgr)
+ mem_op().put_mgr(priv->memmgr);
- priv->nvmap = new_client;
+ priv->memmgr = new_client;
break;
}
case NVHOST_IOCTL_CHANNEL_READ_3D_REG:
diff --git a/drivers/video/tegra/host/chip_support.h b/drivers/video/tegra/host/chip_support.h
index d69e1c4bccb9..33fd92eb31c8 100644
--- a/drivers/video/tegra/host/chip_support.h
+++ b/drivers/video/tegra/host/chip_support.h
@@ -30,8 +30,6 @@ struct nvhost_intr;
struct nvhost_syncpt;
struct nvhost_userctx_timeout;
struct nvhost_channel;
-struct nvmap_handle_ref;
-struct nvmap_client;
struct nvhost_hwctx;
struct nvhost_cdma;
struct nvhost_job;
@@ -40,6 +38,8 @@ struct nvhost_syncpt;
struct dentry;
struct nvhost_job;
struct nvhost_intr_syncpt;
+struct mem_handle;
+struct mem_mgr;
struct nvhost_chip_support {
struct {
@@ -75,8 +75,7 @@ struct nvhost_chip_support {
int (*init)(struct push_buffer *);
void (*destroy)(struct push_buffer *);
void (*push_to)(struct push_buffer *,
- struct nvmap_client *,
- struct nvmap_handle_ref *,
+ struct mem_mgr *, struct mem_handle *,
u32 op1, u32 op2);
void (*pop_from)(struct push_buffer *,
unsigned int slots);
@@ -133,6 +132,22 @@ struct nvhost_chip_support {
struct nvhost_channel *(*alloc_nvhost_channel)(int chid);
void (*free_nvhost_channel)(struct nvhost_channel *ch);
} nvhost_dev;
+
+ struct {
+ struct mem_mgr *(*alloc_mgr)(void);
+ void (*put_mgr)(struct mem_mgr *);
+ struct mem_mgr *(*get_mgr)(struct mem_mgr *);
+ struct mem_mgr *(*get_mgr_file)(int fd);
+ struct mem_handle *(*alloc)(struct mem_mgr *,
+ size_t size, size_t align,
+ int flags);
+ struct mem_handle *(*get)(struct mem_mgr *, u32 id);
+ void (*put)(struct mem_mgr *, struct mem_handle *);
+ phys_addr_t (*pin)(struct mem_mgr *, struct mem_handle *);
+ void (*unpin)(struct mem_mgr *, struct mem_handle *);
+ void *(*mmap)(struct mem_handle *);
+ void (*munmap)(struct mem_handle *, void *);
+ } mem;
};
struct nvhost_chip_support *nvhost_get_chip_ops(void);
@@ -144,6 +159,7 @@ struct nvhost_chip_support *nvhost_get_chip_ops(void);
#define intr_op() nvhost_get_chip_ops()->intr
#define cdma_op() nvhost_get_chip_ops()->cdma
#define cdma_pb_op() nvhost_get_chip_ops()->push_buffer
+#define mem_op() (nvhost_get_chip_ops()->mem)
int nvhost_init_chip_support(struct nvhost_master *);
diff --git a/drivers/video/tegra/host/dev.c b/drivers/video/tegra/host/dev.c
index 2c05fbfb7477..5c1e39da72cf 100644
--- a/drivers/video/tegra/host/dev.c
+++ b/drivers/video/tegra/host/dev.c
@@ -45,9 +45,10 @@
#include "t30/t30.h"
#include "bus_client.h"
#include "nvhost_acm.h"
-#include <linux/nvmap.h>
#include "nvhost_channel.h"
#include "nvhost_job.h"
+#include "nvhost_memmgr.h"
+#include "chip_support.h"
#define DRIVER_NAME "host1x"
@@ -444,13 +445,6 @@ static int __devinit nvhost_probe(struct nvhost_device *dev,
if (!host)
return -ENOMEM;
- host->nvmap = nvmap_create_client(nvmap_dev, "nvhost");
- if (!host->nvmap) {
- dev_err(&dev->dev, "unable to create nvmap client\n");
- err = -EIO;
- goto fail;
- }
-
host->reg_mem = request_mem_region(regs->start,
resource_size(regs), dev->name);
if (!host->reg_mem) {
@@ -472,6 +466,13 @@ static int __devinit nvhost_probe(struct nvhost_device *dev,
goto fail;
}
+ host->memmgr = mem_op().alloc_mgr();
+ if (!host->memmgr) {
+ dev_err(&dev->dev, "unable to create nvmap client\n");
+ err = -EIO;
+ goto fail;
+ }
+
/* Register host1x device as bus master */
host->dev = dev;
@@ -509,8 +510,8 @@ static int __devinit nvhost_probe(struct nvhost_device *dev,
fail:
nvhost_free_resources(host);
- if (host->nvmap)
- nvmap_client_put(host->nvmap);
+ if (host->memmgr)
+ mem_op().put_mgr(host->memmgr);
kfree(host);
return err;
}
diff --git a/drivers/video/tegra/host/dev.h b/drivers/video/tegra/host/dev.h
index 41c4fb59b264..332c99924b27 100644
--- a/drivers/video/tegra/host/dev.h
+++ b/drivers/video/tegra/host/dev.h
@@ -24,13 +24,13 @@
#include <linux/cdev.h>
#include "nvhost_syncpt.h"
#include "nvhost_intr.h"
-#include "chip_support.h"
#define TRACE_MAX_LENGTH 128U
#define IFACE_NAME "nvhost"
struct nvhost_hwctx;
struct nvhost_channel;
+struct mem_mgr;
struct nvhost_master {
void __iomem *aperture;
@@ -40,7 +40,7 @@ struct nvhost_master {
struct cdev cdev;
struct device *ctrl;
struct nvhost_syncpt syncpt;
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
struct nvhost_intr intr;
struct nvhost_device *dev;
atomic_t clientid;
diff --git a/drivers/video/tegra/host/gr3d/gr3d.c b/drivers/video/tegra/host/gr3d/gr3d.c
index b621a47bf650..3208ba452bff 100644
--- a/drivers/video/tegra/host/gr3d/gr3d.c
+++ b/drivers/video/tegra/host/gr3d/gr3d.c
@@ -18,7 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <linux/nvmap.h>
#include <linux/slab.h>
#include "t20/t20.h"
@@ -33,6 +32,8 @@
#include "scale3d.h"
#include "bus_client.h"
#include "nvhost_channel.h"
+#include "nvhost_memmgr.h"
+#include "chip_support.h"
#include <mach/hardware.h>
@@ -77,20 +78,20 @@ void nvhost_3dctx_restore_end(struct host1x_hwctx_handler *p, u32 *ptr)
struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
struct nvhost_channel *ch, bool map_restore)
{
- struct nvmap_client *nvmap = nvhost_get_host(ch->dev)->nvmap;
+ struct mem_mgr *memmgr = nvhost_get_host(ch->dev)->memmgr;
struct host1x_hwctx *ctx;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return NULL;
- ctx->restore = nvmap_alloc(nvmap, p->restore_size * 4, 32,
- map_restore ? NVMAP_HANDLE_WRITE_COMBINE
- : NVMAP_HANDLE_UNCACHEABLE, 0);
+ ctx->restore = mem_op().alloc(memmgr, p->restore_size * 4, 32,
+ map_restore ? mem_mgr_flag_write_combine
+ : mem_mgr_flag_uncacheable);
if (IS_ERR_OR_NULL(ctx->restore))
goto fail;
if (map_restore) {
- ctx->restore_virt = nvmap_mmap(ctx->restore);
+ ctx->restore_virt = mem_op().mmap(ctx->restore);
if (!ctx->restore_virt)
goto fail;
} else
@@ -103,7 +104,7 @@ struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
ctx->save_incrs = p->save_incrs;
ctx->save_thresh = p->save_thresh;
ctx->save_slots = p->save_slots;
- ctx->restore_phys = nvmap_pin(nvmap, ctx->restore);
+ ctx->restore_phys = mem_op().pin(memmgr, ctx->restore);
if (IS_ERR_VALUE(ctx->restore_phys))
goto fail;
@@ -113,10 +114,10 @@ struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
fail:
if (map_restore && ctx->restore_virt) {
- nvmap_munmap(ctx->restore, ctx->restore_virt);
+ mem_op().munmap(ctx->restore, ctx->restore_virt);
ctx->restore_virt = NULL;
}
- nvmap_free(nvmap, ctx->restore);
+ mem_op().put(memmgr, ctx->restore);
ctx->restore = NULL;
kfree(ctx);
return NULL;
@@ -131,16 +132,15 @@ void nvhost_3dctx_free(struct kref *ref)
{
struct nvhost_hwctx *nctx = container_of(ref, struct nvhost_hwctx, ref);
struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
- struct nvmap_client *nvmap =
- nvhost_get_host(nctx->channel->dev)->nvmap;
+ struct mem_mgr *memmgr = nvhost_get_host(nctx->channel->dev)->memmgr;
if (ctx->restore_virt) {
- nvmap_munmap(ctx->restore, ctx->restore_virt);
+ mem_op().munmap(ctx->restore, ctx->restore_virt);
ctx->restore_virt = NULL;
}
- nvmap_unpin(nvmap, ctx->restore);
+ mem_op().unpin(memmgr, ctx->restore);
ctx->restore_phys = 0;
- nvmap_free(nvmap, ctx->restore);
+ mem_op().put(memmgr, ctx->restore);
ctx->restore = NULL;
kfree(ctx);
}
diff --git a/drivers/video/tegra/host/gr3d/gr3d_t20.c b/drivers/video/tegra/host/gr3d/gr3d_t20.c
index 5645f5b2b0c6..baa27051c794 100644
--- a/drivers/video/tegra/host/gr3d/gr3d_t20.c
+++ b/drivers/video/tegra/host/gr3d/gr3d_t20.c
@@ -25,6 +25,8 @@
#include "host1x/host1x_hardware.h"
#include "host1x/host1x_syncpt.h"
#include "gr3d.h"
+#include "chip_support.h"
+#include "nvhost_memmgr.h"
#include <linux/slab.h>
@@ -137,7 +139,7 @@ static void save_push_v0(struct nvhost_hwctx *nctx, struct nvhost_cdma *cdma)
struct host1x_hwctx_handler *p = host1x_hwctx_handler(ctx);
nvhost_cdma_push_gather(cdma,
- nvhost_get_host(nctx->channel->dev)->nvmap,
+ nvhost_get_host(nctx->channel->dev)->memmgr,
p->save_buf,
0,
nvhost_opcode_gather(p->save_size),
@@ -353,22 +355,22 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t20_ctxhandler_init(
u32 syncpt, u32 waitbase,
struct nvhost_channel *ch)
{
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
u32 *save_ptr;
struct host1x_hwctx_handler *p;
p = kmalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return NULL;
- nvmap = nvhost_get_host(ch->dev)->nvmap;
+ memmgr = nvhost_get_host(ch->dev)->memmgr;
p->syncpt = syncpt;
p->waitbase = waitbase;
setup_save(p, NULL);
- p->save_buf = nvmap_alloc(nvmap, p->save_size * sizeof(u32), 32,
- NVMAP_HANDLE_WRITE_COMBINE, 0);
+ p->save_buf = mem_op().alloc(memmgr, p->save_size * sizeof(u32), 32,
+ mem_mgr_flag_write_combine);
if (IS_ERR(p->save_buf)) {
p->save_buf = NULL;
return NULL;
@@ -376,14 +378,14 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t20_ctxhandler_init(
p->save_slots = 1;
- save_ptr = nvmap_mmap(p->save_buf);
+ save_ptr = mem_op().mmap(p->save_buf);
if (!save_ptr) {
- nvmap_free(nvmap, p->save_buf);
+ mem_op().put(memmgr, p->save_buf);
p->save_buf = NULL;
return NULL;
}
- p->save_phys = nvmap_pin(nvmap, p->save_buf);
+ p->save_phys = mem_op().pin(memmgr, p->save_buf);
setup_save(p, save_ptr);
diff --git a/drivers/video/tegra/host/gr3d/gr3d_t30.c b/drivers/video/tegra/host/gr3d/gr3d_t30.c
index 4bc7c9f92bb5..2af8079250ac 100644
--- a/drivers/video/tegra/host/gr3d/gr3d_t30.c
+++ b/drivers/video/tegra/host/gr3d/gr3d_t30.c
@@ -25,6 +25,8 @@
#include "host1x/host1x_hardware.h"
#include "host1x/host1x_syncpt.h"
#include "gr3d.h"
+#include "chip_support.h"
+#include "nvhost_memmgr.h"
#include <mach/gpufuse.h>
#include <mach/hardware.h>
@@ -144,7 +146,7 @@ static void save_push_v1(struct nvhost_hwctx *nctx, struct nvhost_cdma *cdma)
ctx->restore_phys);
/* gather the save buffer */
nvhost_cdma_push_gather(cdma,
- nvhost_get_host(nctx->channel->dev)->nvmap,
+ nvhost_get_host(nctx->channel->dev)->memmgr,
p->save_buf,
0,
nvhost_opcode_gather(p->save_size),
@@ -387,7 +389,7 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
u32 syncpt, u32 waitbase,
struct nvhost_channel *ch)
{
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
u32 *save_ptr;
struct host1x_hwctx_handler *p;
@@ -395,7 +397,7 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
if (!p)
return NULL;
- nvmap = nvhost_get_host(ch->dev)->nvmap;
+ memmgr = nvhost_get_host(ch->dev)->memmgr;
register_sets = tegra_gpu_register_sets();
BUG_ON(register_sets == 0 || register_sets > 2);
@@ -405,8 +407,8 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
setup_save(p, NULL);
- p->save_buf = nvmap_alloc(nvmap, p->save_size * 4, 32,
- NVMAP_HANDLE_WRITE_COMBINE, 0);
+ p->save_buf = mem_op().alloc(memmgr, p->save_size * 4, 32,
+ mem_mgr_flag_write_combine);
if (IS_ERR(p->save_buf)) {
p->save_buf = NULL;
return NULL;
@@ -416,18 +418,18 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
if (register_sets == 2)
p->save_slots += 2;
- save_ptr = nvmap_mmap(p->save_buf);
+ save_ptr = mem_op().mmap(p->save_buf);
if (!save_ptr) {
- nvmap_free(nvmap, p->save_buf);
+ mem_op().put(memmgr, p->save_buf);
p->save_buf = NULL;
return NULL;
}
- p->save_phys = nvmap_pin(nvmap, p->save_buf);
+ p->save_phys = mem_op().pin(memmgr, p->save_buf);
setup_save(p, save_ptr);
- nvmap_munmap(p->save_buf, save_ptr);
+ mem_op().munmap(p->save_buf, save_ptr);
p->h.alloc = ctx3d_alloc_v1;
p->h.save_push = save_push_v1;
diff --git a/drivers/video/tegra/host/host1x/host1x_cdma.c b/drivers/video/tegra/host/host1x/host1x_cdma.c
index 4569c3d62494..00289fc6d980 100644
--- a/drivers/video/tegra/host/host1x/host1x_cdma.c
+++ b/drivers/video/tegra/host/host1x/host1x_cdma.c
@@ -23,6 +23,8 @@
#include "nvhost_cdma.h"
#include "nvhost_channel.h"
#include "dev.h"
+#include "chip_support.h"
+#include "nvhost_memmgr.h"
#include "host1x_hardware.h"
#include "host1x_syncpt.h"
@@ -62,38 +64,38 @@ static void push_buffer_reset(struct push_buffer *pb)
static int push_buffer_init(struct push_buffer *pb)
{
struct nvhost_cdma *cdma = pb_to_cdma(pb);
- struct nvmap_client *nvmap = cdma_to_nvmap(cdma);
+ struct mem_mgr *mgr = cdma_to_memmgr(cdma);
pb->mem = NULL;
pb->mapped = NULL;
pb->phys = 0;
- pb->nvmap = NULL;
+ pb->client_handle = NULL;
BUG_ON(!cdma_pb_op().reset);
cdma_pb_op().reset(pb);
/* allocate and map pushbuffer memory */
- pb->mem = nvmap_alloc(nvmap, PUSH_BUFFER_SIZE + 4, 32,
- NVMAP_HANDLE_WRITE_COMBINE, 0);
+ pb->mem = mem_op().alloc(mgr, PUSH_BUFFER_SIZE + 4, 32,
+ mem_mgr_flag_write_combine);
if (IS_ERR_OR_NULL(pb->mem)) {
pb->mem = NULL;
goto fail;
}
- pb->mapped = nvmap_mmap(pb->mem);
+ pb->mapped = mem_op().mmap(pb->mem);
if (pb->mapped == NULL)
goto fail;
/* pin pushbuffer and get physical address */
- pb->phys = nvmap_pin(nvmap, pb->mem);
+ pb->phys = mem_op().pin(mgr, pb->mem);
if (pb->phys >= 0xfffff000) {
pb->phys = 0;
goto fail;
}
/* memory for storing nvmap client and handles for each opcode pair */
- pb->nvmap = kzalloc(NVHOST_GATHER_QUEUE_SIZE *
- sizeof(struct nvmap_client_handle),
+ pb->client_handle = kzalloc(NVHOST_GATHER_QUEUE_SIZE *
+ sizeof(struct mem_mgr_handle),
GFP_KERNEL);
- if (!pb->nvmap)
+ if (!pb->client_handle)
goto fail;
/* put the restart at the end of pushbuffer memory */
@@ -113,22 +115,22 @@ fail:
static void push_buffer_destroy(struct push_buffer *pb)
{
struct nvhost_cdma *cdma = pb_to_cdma(pb);
- struct nvmap_client *nvmap = cdma_to_nvmap(cdma);
+ struct mem_mgr *mgr = cdma_to_memmgr(cdma);
if (pb->mapped)
- nvmap_munmap(pb->mem, pb->mapped);
+ mem_op().munmap(pb->mem, pb->mapped);
if (pb->phys != 0)
- nvmap_unpin(nvmap, pb->mem);
+ mem_op().unpin(mgr, pb->mem);
if (pb->mem)
- nvmap_free(nvmap, pb->mem);
+ mem_op().put(mgr, pb->mem);
- kfree(pb->nvmap);
+ kfree(pb->client_handle);
pb->mem = NULL;
pb->mapped = NULL;
pb->phys = 0;
- pb->nvmap = 0;
+ pb->client_handle = 0;
}
/**
@@ -136,8 +138,8 @@ static void push_buffer_destroy(struct push_buffer *pb)
* Caller must ensure push buffer is not full
*/
static void push_buffer_push_to(struct push_buffer *pb,
- struct nvmap_client *client,
- struct nvmap_handle_ref *handle, u32 op1, u32 op2)
+ struct mem_mgr *client, struct mem_handle *handle,
+ u32 op1, u32 op2)
{
u32 cur = pb->cur;
u32 *p = (u32 *)((u32)pb->mapped + cur);
@@ -145,8 +147,8 @@ static void push_buffer_push_to(struct push_buffer *pb,
BUG_ON(cur == pb->fence);
*(p++) = op1;
*(p++) = op2;
- pb->nvmap[cur_nvmap].client = client;
- pb->nvmap[cur_nvmap].handle = handle;
+ pb->client_handle[cur_nvmap].client = client;
+ pb->client_handle[cur_nvmap].handle = handle;
pb->cur = (cur + 8) & (PUSH_BUFFER_SIZE - 1);
}
@@ -163,8 +165,7 @@ static void push_buffer_pop_from(struct push_buffer *pb,
for (i = 0; i < slots; i++) {
int cur_fence_nvmap = (fence_nvmap+i)
& (NVHOST_GATHER_QUEUE_SIZE - 1);
- struct nvmap_client_handle *h =
- &pb->nvmap[cur_fence_nvmap];
+ struct mem_mgr_handle *h = &pb->client_handle[cur_fence_nvmap];
h->client = NULL;
h->handle = NULL;
}
diff --git a/drivers/video/tegra/host/host1x/host1x_cdma.h b/drivers/video/tegra/host/host1x/host1x_cdma.h
index 374097272d3f..9c533d6a5154 100644
--- a/drivers/video/tegra/host/host1x/host1x_cdma.h
+++ b/drivers/video/tegra/host/host1x/host1x_cdma.h
@@ -36,6 +36,7 @@
* and replaces the original timed out contexts GATHER slots */
#define SYNCPT_INCR_BUFFER_SIZE_WORDS (4096 / sizeof(u32))
+struct nvhost_chip_support;
int host1x_init_cdma_support(struct nvhost_chip_support *);
#endif
diff --git a/drivers/video/tegra/host/host1x/host1x_channel.c b/drivers/video/tegra/host/host1x/host1x_channel.c
index c72e6478b806..4b167a3753a1 100644
--- a/drivers/video/tegra/host/host1x/host1x_channel.c
+++ b/drivers/video/tegra/host/host1x/host1x_channel.c
@@ -142,7 +142,7 @@ static void submit_ctxrestore(struct nvhost_job *job)
/* Send restore buffer to channel */
nvhost_cdma_push_gather(&ch->cdma,
- host->nvmap,
+ host->memmgr,
ctx->restore,
0,
nvhost_opcode_gather(ctx->restore_size),
@@ -187,7 +187,7 @@ void submit_gathers(struct nvhost_job *job)
u32 op1 = nvhost_opcode_gather(job->gathers[i].words);
u32 op2 = job->gathers[i].mem;
nvhost_cdma_push_gather(&job->ch->cdma,
- job->nvmap,
+ job->memmgr,
job->gathers[i].ref,
job->gathers[i].offset,
op1, op2);
@@ -329,7 +329,7 @@ int host1x_channel_read_3d_reg(
job = nvhost_job_alloc(channel, hwctx,
NULL,
- nvhost_get_host(channel->dev)->nvmap, 0, 0);
+ nvhost_get_host(channel->dev)->memmgr, 0, 0);
if (!job) {
err = -ENOMEM;
goto done;
@@ -555,7 +555,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
job = nvhost_job_alloc(ch, hwctx_to_save,
NULL,
- nvhost_get_host(ch->dev)->nvmap, 0, 0);
+ nvhost_get_host(ch->dev)->memmgr, 0, 0);
if (IS_ERR_OR_NULL(job)) {
err = PTR_ERR(job);
mutex_unlock(&ch->submitlock);
diff --git a/drivers/video/tegra/host/host1x/host1x_debug.c b/drivers/video/tegra/host/host1x/host1x_debug.c
index 7de342298c4d..3b14aeeae153 100644
--- a/drivers/video/tegra/host/host1x/host1x_debug.c
+++ b/drivers/video/tegra/host/host1x/host1x_debug.c
@@ -30,6 +30,8 @@
#include "nvhost_channel.h"
#include "host1x_cdma.h"
#include "nvhost_job.h"
+#include "chip_support.h"
+#include "nvhost_memmgr.h"
#define NVHOST_DEBUG_MAX_PAGE_OFFSET 102400
@@ -196,7 +198,7 @@ static void show_channel_gather(struct output *o, u32 addr,
/* Map dmaget cursor to corresponding nvmap_handle */
struct push_buffer *pb = &cdma->push_buffer;
u32 cur = addr - pb->phys;
- struct nvmap_client_handle *nvmap = &pb->nvmap[cur/8];
+ struct mem_mgr_handle *nvmap = &pb->client_handle[cur/8];
u32 *map_addr, offset;
phys_addr_t pin_addr;
@@ -205,25 +207,25 @@ static void show_channel_gather(struct output *o, u32 addr,
return;
}
- map_addr = nvmap_mmap(nvmap->handle);
+ map_addr = mem_op().mmap(nvmap->handle);
if (!map_addr) {
nvhost_debug_output(o, "[could not mmap]\n");
return;
}
/* Get base address from nvmap */
- pin_addr = nvmap_pin(nvmap->client, nvmap->handle);
+ pin_addr = mem_op().pin(nvmap->client, nvmap->handle);
if (IS_ERR_VALUE(pin_addr)) {
nvhost_debug_output(o, "[couldn't pin]\n");
- nvmap_munmap(nvmap->handle, map_addr);
+ mem_op().munmap(nvmap->handle, map_addr);
return;
}
offset = phys_addr - pin_addr;
do_show_channel_gather(o, phys_addr, words, cdma,
pin_addr, map_addr);
- nvmap_unpin(nvmap->client, nvmap->handle);
- nvmap_munmap(nvmap->handle, map_addr);
+ mem_op().unpin(nvmap->client, nvmap->handle);
+ mem_op().munmap(nvmap->handle, map_addr);
#endif
}
@@ -256,7 +258,7 @@ void show_channel_gathers(struct output *o, struct nvhost_cdma *cdma)
for (i = 0; i < job->num_gathers; i++) {
struct nvhost_job_gather *g = &job->gathers[i];
- u32 *mapped = nvmap_mmap(g->ref);
+ u32 *mapped = mem_op().mmap(g->ref);
if (!mapped) {
nvhost_debug_output(o, "[could not mmap]\n");
continue;
@@ -267,7 +269,7 @@ void show_channel_gathers(struct output *o, struct nvhost_cdma *cdma)
do_show_channel_gather(o, g->mem + g->offset,
g->words, cdma, g->mem, mapped);
- nvmap_munmap(g->ref, mapped);
+ mem_op().munmap(g->ref, mapped);
}
}
}
diff --git a/drivers/video/tegra/host/host1x/host1x_hwctx.h b/drivers/video/tegra/host/host1x/host1x_hwctx.h
index b5046c461d9d..13f0071d1e33 100644
--- a/drivers/video/tegra/host/host1x/host1x_hwctx.h
+++ b/drivers/video/tegra/host/host1x/host1x_hwctx.h
@@ -41,7 +41,7 @@ struct host1x_hwctx {
u32 save_thresh;
u32 save_slots;
- struct nvmap_handle_ref *restore;
+ struct mem_handle *restore;
u32 *restore_virt;
phys_addr_t restore_phys;
u32 restore_size;
@@ -55,7 +55,7 @@ struct host1x_hwctx_handler {
u32 waitbase;
u32 restore_size;
u32 restore_incrs;
- struct nvmap_handle_ref *save_buf;
+ struct mem_handle *save_buf;
u32 save_incrs;
u32 save_thresh;
u32 save_slots;
diff --git a/drivers/video/tegra/host/host1x/host1x_intr.c b/drivers/video/tegra/host/host1x/host1x_intr.c
index 2b611faaa708..e8d1a81c49bb 100644
--- a/drivers/video/tegra/host/host1x/host1x_intr.c
+++ b/drivers/video/tegra/host/host1x/host1x_intr.c
@@ -27,6 +27,7 @@
#include "nvhost_intr.h"
#include "dev.h"
#include "host1x_hardware.h"
+#include "chip_support.h"
/*** HW host sync management ***/
diff --git a/drivers/video/tegra/host/mpe/mpe.c b/drivers/video/tegra/host/mpe/mpe.c
index 3fe2fcd8bb50..7468d4b9d753 100644
--- a/drivers/video/tegra/host/mpe/mpe.c
+++ b/drivers/video/tegra/host/mpe/mpe.c
@@ -26,6 +26,8 @@
#include "host1x/host1x_syncpt.h"
#include "host1x/host1x_hwctx.h"
#include "t20/t20.h"
+#include "chip_support.h"
+#include "nvhost_memmgr.h"
#include <linux/slab.h>
#include <linux/resource.h>
@@ -434,23 +436,23 @@ static u32 *save_ram(u32 *ptr, unsigned int *pending,
static struct nvhost_hwctx *ctxmpe_alloc(struct nvhost_hwctx_handler *h,
struct nvhost_channel *ch)
{
- struct nvmap_client *nvmap = nvhost_get_host(ch->dev)->nvmap;
+ struct mem_mgr *memmgr = nvhost_get_host(ch->dev)->memmgr;
struct host1x_hwctx_handler *p = to_host1x_hwctx_handler(h);
struct host1x_hwctx *ctx;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return NULL;
- ctx->restore = nvmap_alloc(nvmap, restore_size * 4, 32,
- NVMAP_HANDLE_WRITE_COMBINE, 0);
+ ctx->restore = mem_op().alloc(memmgr, restore_size * 4, 32,
+ mem_mgr_flag_write_combine);
if (IS_ERR_OR_NULL(ctx->restore)) {
kfree(ctx);
return NULL;
}
- ctx->restore_virt = nvmap_mmap(ctx->restore);
+ ctx->restore_virt = mem_op().mmap(ctx->restore);
if (!ctx->restore_virt) {
- nvmap_free(nvmap, ctx->restore);
+ mem_op().put(memmgr, ctx->restore);
kfree(ctx);
return NULL;
}
@@ -462,7 +464,7 @@ static struct nvhost_hwctx *ctxmpe_alloc(struct nvhost_hwctx_handler *h,
ctx->save_incrs = 3;
ctx->save_thresh = 2;
ctx->save_slots = p->save_slots;
- ctx->restore_phys = nvmap_pin(nvmap, ctx->restore);
+ ctx->restore_phys = mem_op().pin(memmgr, ctx->restore);
ctx->restore_size = restore_size;
ctx->restore_incrs = 1;
@@ -480,13 +482,12 @@ static void ctxmpe_free(struct kref *ref)
{
struct nvhost_hwctx *nctx = container_of(ref, struct nvhost_hwctx, ref);
struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
- struct nvmap_client *nvmap =
- nvhost_get_host(nctx->channel->dev)->nvmap;
+ struct mem_mgr *memmgr = nvhost_get_host(nctx->channel->dev)->memmgr;
if (ctx->restore_virt)
- nvmap_munmap(ctx->restore, ctx->restore_virt);
- nvmap_unpin(nvmap, ctx->restore);
- nvmap_free(nvmap, ctx->restore);
+ mem_op().munmap(ctx->restore, ctx->restore_virt);
+ mem_op().unpin(memmgr, ctx->restore);
+ mem_op().put(memmgr, ctx->restore);
kfree(ctx);
}
@@ -501,7 +502,7 @@ static void ctxmpe_save_push(struct nvhost_hwctx *nctx,
struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
struct host1x_hwctx_handler *h = host1x_hwctx_handler(ctx);
nvhost_cdma_push_gather(cdma,
- nvhost_get_host(nctx->channel->dev)->nvmap,
+ nvhost_get_host(nctx->channel->dev)->memmgr,
h->save_buf,
0,
nvhost_opcode_gather(h->save_size),
@@ -537,7 +538,7 @@ static void ctxmpe_save_service(struct nvhost_hwctx *nctx)
struct nvhost_hwctx_handler *nvhost_mpe_ctxhandler_init(u32 syncpt,
u32 waitbase, struct nvhost_channel *ch)
{
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
u32 *save_ptr;
struct host1x_hwctx_handler *p;
@@ -545,28 +546,28 @@ struct nvhost_hwctx_handler *nvhost_mpe_ctxhandler_init(u32 syncpt,
if (!p)
return NULL;
- nvmap = nvhost_get_host(ch->dev)->nvmap;
+ memmgr = nvhost_get_host(ch->dev)->memmgr;
p->syncpt = syncpt;
p->waitbase = waitbase;
setup_save(p, NULL);
- p->save_buf = nvmap_alloc(nvmap, p->save_size * 4, 32,
- NVMAP_HANDLE_WRITE_COMBINE, 0);
+ p->save_buf = mem_op().alloc(memmgr, p->save_size * 4, 32,
+ mem_mgr_flag_write_combine);
if (IS_ERR(p->save_buf)) {
p->save_buf = NULL;
return NULL;
}
- save_ptr = nvmap_mmap(p->save_buf);
+ save_ptr = mem_op().mmap(p->save_buf);
if (!save_ptr) {
- nvmap_free(nvmap, p->save_buf);
+ mem_op().put(memmgr, p->save_buf);
p->save_buf = NULL;
return NULL;
}
- p->save_phys = nvmap_pin(nvmap, p->save_buf);
+ p->save_phys = mem_op().pin(memmgr, p->save_buf);
p->save_slots = 1;
setup_save(p, save_ptr);
diff --git a/drivers/video/tegra/host/nvhost_cdma.c b/drivers/video/tegra/host/nvhost_cdma.c
index c87415bf5ac2..409d4dd6ecf2 100644
--- a/drivers/video/tegra/host/nvhost_cdma.c
+++ b/drivers/video/tegra/host/nvhost_cdma.c
@@ -24,6 +24,8 @@
#include "nvhost_hwctx.h"
#include "dev.h"
#include "debug.h"
+#include "nvhost_memmgr.h"
+#include "chip_support.h"
#include <asm/cacheflush.h>
#include <linux/slab.h>
@@ -396,13 +398,13 @@ int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job)
}
static void trace_write_gather(struct nvhost_cdma *cdma,
- struct nvmap_handle_ref *ref,
+ struct mem_handle *ref,
u32 offset, u32 words)
{
void *mem = NULL;
if (nvhost_debug_trace_cmdbuf) {
- mem = nvmap_mmap(ref);
+ mem = mem_op().mmap(ref);
if (IS_ERR_OR_NULL(mem))
mem = NULL;
};
@@ -416,12 +418,12 @@ static void trace_write_gather(struct nvhost_cdma *cdma,
for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
trace_nvhost_cdma_push_gather(
cdma_to_channel(cdma)->dev->name,
- (u32)ref->handle,
+ (u32)ref,
min(words - i, TRACE_MAX_LENGTH),
offset + i * sizeof(u32),
mem);
}
- nvmap_munmap(ref, mem);
+ mem_op().munmap(ref, mem);
}
}
@@ -443,8 +445,7 @@ void nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2)
* Blocks as necessary if the push buffer is full.
*/
void nvhost_cdma_push_gather(struct nvhost_cdma *cdma,
- struct nvmap_client *client,
- struct nvmap_handle_ref *handle,
+ struct mem_mgr *client, struct mem_handle *handle,
u32 offset, u32 op1, u32 op2)
{
u32 slots_free = cdma->slots_free;
diff --git a/drivers/video/tegra/host/nvhost_cdma.h b/drivers/video/tegra/host/nvhost_cdma.h
index 2056774a7bc7..e4a19e6ab113 100644
--- a/drivers/video/tegra/host/nvhost_cdma.h
+++ b/drivers/video/tegra/host/nvhost_cdma.h
@@ -25,12 +25,13 @@
#include <linux/semaphore.h>
#include <linux/nvhost.h>
-#include <linux/nvmap.h>
#include <linux/list.h>
struct nvhost_syncpt;
struct nvhost_userctx_timeout;
struct nvhost_job;
+struct mem_mgr;
+struct mem_handle;
/*
* cdma
@@ -46,27 +47,13 @@ struct nvhost_job;
* update - call to update sync queue and push buffer, unpin memory
*/
-struct nvmap_client_handle {
- struct nvmap_client *client;
- struct nvmap_handle_ref *handle;
-};
-
struct push_buffer {
- struct nvmap_handle_ref *mem; /* handle to pushbuffer memory */
+ struct mem_handle *mem; /* handle to pushbuffer memory */
u32 *mapped; /* mapped pushbuffer memory */
u32 phys; /* physical address of pushbuffer */
u32 fence; /* index we've written */
u32 cur; /* index to write to */
- struct nvmap_client_handle *nvmap;
- /* nvmap handle for each opcode pair */
-};
-
-struct syncpt_buffer {
- struct nvmap_handle_ref *mem; /* handle to pushbuffer memory */
- u32 *mapped; /* mapped gather buffer (at channel offset */
- u32 phys; /* physical address (at channel offset) */
- u32 incr_per_buffer; /* max # of incrs per GATHER */
- u32 words_per_incr; /* # of DWORDS in buffer to incr a syncpt */
+ struct mem_mgr_handle *client_handle; /* handle for each opcode pair */
};
struct buffer_timeout {
@@ -106,7 +93,7 @@ struct nvhost_cdma {
#define cdma_to_channel(cdma) container_of(cdma, struct nvhost_channel, cdma)
#define cdma_to_dev(cdma) nvhost_get_host(cdma_to_channel(cdma)->dev)
-#define cdma_to_nvmap(cdma) ((cdma_to_dev(cdma))->nvmap)
+#define cdma_to_memmgr(cdma) ((cdma_to_dev(cdma))->memmgr)
#define pb_to_cdma(pb) container_of(pb, struct nvhost_cdma, push_buffer)
int nvhost_cdma_init(struct nvhost_cdma *cdma);
@@ -115,8 +102,8 @@ void nvhost_cdma_stop(struct nvhost_cdma *cdma);
int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job);
void nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2);
void nvhost_cdma_push_gather(struct nvhost_cdma *cdma,
- struct nvmap_client *client,
- struct nvmap_handle_ref *handle, u32 offset, u32 op1, u32 op2);
+ struct mem_mgr *client,
+ struct mem_handle *handle, u32 offset, u32 op1, u32 op2);
void nvhost_cdma_end(struct nvhost_cdma *cdma,
struct nvhost_job *job);
void nvhost_cdma_update(struct nvhost_cdma *cdma);
diff --git a/drivers/video/tegra/host/nvhost_hwctx.h b/drivers/video/tegra/host/nvhost_hwctx.h
index 75ed0be1a72c..47bc3d408fde 100644
--- a/drivers/video/tegra/host/nvhost_hwctx.h
+++ b/drivers/video/tegra/host/nvhost_hwctx.h
@@ -25,7 +25,6 @@
#include <linux/kref.h>
#include <linux/nvhost.h>
-#include <linux/nvmap.h>
struct nvhost_channel;
struct nvhost_cdma;
diff --git a/drivers/video/tegra/host/nvhost_intr.c b/drivers/video/tegra/host/nvhost_intr.c
index 1f4dd0efbde9..d61602c4e94e 100644
--- a/drivers/video/tegra/host/nvhost_intr.c
+++ b/drivers/video/tegra/host/nvhost_intr.c
@@ -27,6 +27,7 @@
#include <trace/events/nvhost.h>
#include "nvhost_channel.h"
#include "nvhost_hwctx.h"
+#include "chip_support.h"
/*** Wait list management ***/
diff --git a/drivers/video/tegra/host/nvhost_job.c b/drivers/video/tegra/host/nvhost_job.c
index e029449b6184..fb8a61c884e9 100644
--- a/drivers/video/tegra/host/nvhost_job.c
+++ b/drivers/video/tegra/host/nvhost_job.c
@@ -22,13 +22,14 @@
#include <linux/kref.h>
#include <linux/err.h>
#include <linux/vmalloc.h>
-#include <linux/nvmap.h>
#include <trace/events/nvhost.h>
#include "nvhost_channel.h"
#include "nvhost_job.h"
#include "nvhost_hwctx.h"
#include "nvhost_syncpt.h"
#include "dev.h"
+#include "nvhost_memmgr.h"
+#include "chip_support.h"
/* Magic to use to fill freed handle slots */
#define BAD_MAGIC 0xdeadbeef
@@ -43,7 +44,7 @@ static int job_size(struct nvhost_submit_hdr_ext *hdr)
return sizeof(struct nvhost_job)
+ num_relocs * sizeof(struct nvhost_reloc)
+ num_relocs * sizeof(struct nvhost_reloc_shift)
- + num_unpins * sizeof(struct nvmap_handle_ref *)
+ + num_unpins * sizeof(struct mem_handle *)
+ num_waitchks * sizeof(struct nvhost_waitchk)
+ num_cmdbufs * sizeof(struct nvhost_job_gather);
}
@@ -69,7 +70,7 @@ static void init_fields(struct nvhost_job *job,
job->relocshiftarray = num_relocs ? mem : NULL;
mem += num_relocs * sizeof(struct nvhost_reloc_shift);
job->unpins = num_unpins ? mem : NULL;
- mem += num_unpins * sizeof(struct nvmap_handle_ref *);
+ mem += num_unpins * sizeof(struct mem_handle *);
job->waitchk = num_waitchks ? mem : NULL;
mem += num_waitchks * sizeof(struct nvhost_waitchk);
job->gathers = num_cmdbufs ? mem : NULL;
@@ -85,7 +86,7 @@ static void init_fields(struct nvhost_job *job,
struct nvhost_job *nvhost_job_alloc(struct nvhost_channel *ch,
struct nvhost_hwctx *hwctx,
struct nvhost_submit_hdr_ext *hdr,
- struct nvmap_client *nvmap,
+ struct mem_mgr *memmgr,
int priority,
int clientid)
{
@@ -100,7 +101,7 @@ struct nvhost_job *nvhost_job_alloc(struct nvhost_channel *ch,
job->hwctx = hwctx;
if (hwctx)
hwctx->h->get(hwctx);
- job->nvmap = nvmap ? nvmap_client_get(nvmap) : NULL;
+ job->memmgr = memmgr ? mem_op().get_mgr(memmgr) : NULL;
init_fields(job, hdr, priority, clientid);
@@ -125,8 +126,8 @@ static void job_free(struct kref *ref)
job->hwctxref->h->put(job->hwctxref);
if (job->hwctx)
job->hwctx->h->put(job->hwctx);
- if (job->nvmap)
- nvmap_client_put(job->nvmap);
+ if (job->memmgr)
+ mem_op().put_mgr(job->memmgr);
vfree(job);
}
@@ -162,7 +163,7 @@ static int do_relocs(struct nvhost_job *job, u32 cmdbuf_mem, void *cmdbuf_addr)
phys_addr_t target_phys;
int i;
u32 mem_id = 0;
- struct nvmap_handle_ref *target_ref = NULL;
+ struct mem_handle *target_ref = NULL;
/* pin & patch the relocs for one gather */
for (i = 0; i < job->num_relocs; i++) {
@@ -175,14 +176,13 @@ static int do_relocs(struct nvhost_job *job, u32 cmdbuf_mem, void *cmdbuf_addr)
/* check if pin-mem is same as previous */
if (reloc->target != mem_id) {
- target_ref = nvmap_duplicate_handle_id(job->nvmap,
- reloc->target);
+ target_ref = mem_op().get(job->memmgr, reloc->target);
if (IS_ERR(target_ref))
return PTR_ERR(target_ref);
- target_phys = nvmap_pin(job->nvmap, target_ref);
+ target_phys = mem_op().pin(job->memmgr, target_ref);
if (IS_ERR((void *)target_phys)) {
- nvmap_free(job->nvmap, target_ref);
+ mem_op().put(job->memmgr, target_ref);
return target_phys;
}
@@ -267,7 +267,7 @@ int nvhost_job_pin(struct nvhost_job *job, struct nvhost_syncpt *sp)
/* process each gather mem only once */
if (!g->ref) {
- g->ref = nvmap_duplicate_handle_id(job->nvmap,
+ g->ref = mem_op().get(job->memmgr,
job->gathers[i].mem_id);
if (IS_ERR(g->ref)) {
err = PTR_ERR(g->ref);
@@ -275,9 +275,9 @@ int nvhost_job_pin(struct nvhost_job *job, struct nvhost_syncpt *sp)
break;
}
- gather_phys = nvmap_pin(job->nvmap, g->ref);
+ gather_phys = mem_op().pin(job->memmgr, g->ref);
if (IS_ERR((void *)gather_phys)) {
- nvmap_free(job->nvmap, g->ref);
+ mem_op().put(job->memmgr, g->ref);
err = gather_phys;
break;
}
@@ -285,7 +285,7 @@ int nvhost_job_pin(struct nvhost_job *job, struct nvhost_syncpt *sp)
/* store the gather ref into unpin array */
job->unpins[job->num_unpins++] = g->ref;
- gather_addr = nvmap_mmap(g->ref);
+ gather_addr = mem_op().mmap(g->ref);
if (!gather_addr) {
err = -ENOMEM;
break;
@@ -295,7 +295,7 @@ int nvhost_job_pin(struct nvhost_job *job, struct nvhost_syncpt *sp)
if (!err)
err = do_waitchks(job, sp,
g->mem_id, gather_addr);
- nvmap_munmap(g->ref, gather_addr);
+ mem_op().munmap(g->ref, gather_addr);
if (err)
break;
@@ -312,12 +312,12 @@ void nvhost_job_unpin(struct nvhost_job *job)
int i;
for (i = 0; i < job->num_unpins; i++) {
- nvmap_unpin(job->nvmap, job->unpins[i]);
- nvmap_free(job->nvmap, job->unpins[i]);
+ mem_op().unpin(job->memmgr, job->unpins[i]);
+ mem_op().put(job->memmgr, job->unpins[i]);
}
memset(job->unpins, BAD_MAGIC,
- job->num_unpins * sizeof(struct nvmap_handle_ref *));
+ job->num_unpins * sizeof(struct mem_handle *));
job->num_unpins = 0;
}
diff --git a/drivers/video/tegra/host/nvhost_job.h b/drivers/video/tegra/host/nvhost_job.h
index ec1366337279..3b444579c543 100644
--- a/drivers/video/tegra/host/nvhost_job.h
+++ b/drivers/video/tegra/host/nvhost_job.h
@@ -25,7 +25,6 @@
struct nvhost_channel;
struct nvhost_hwctx;
-struct nvmap_client;
struct nvhost_waitchk;
struct nvhost_syncpt;
@@ -34,7 +33,7 @@ struct nvhost_job_gather {
phys_addr_t mem;
u32 mem_id;
int offset;
- struct nvmap_handle_ref *ref;
+ struct mem_handle *ref;
};
/*
@@ -55,7 +54,7 @@ struct nvhost_job {
int clientid;
/* Nvmap to be used for pinning & unpinning memory */
- struct nvmap_client *nvmap;
+ struct mem_mgr *memmgr;
/* Gathers and their memory */
struct nvhost_job_gather *gathers;
@@ -70,7 +69,7 @@ struct nvhost_job {
struct nvhost_reloc *relocarray;
struct nvhost_reloc_shift *relocshiftarray;
int num_relocs;
- struct nvmap_handle_ref **unpins;
+ struct mem_handle **unpins;
int num_unpins;
/* Sync point id, number of increments and end related to the submit */
@@ -102,7 +101,7 @@ struct nvhost_job {
struct nvhost_job *nvhost_job_alloc(struct nvhost_channel *ch,
struct nvhost_hwctx *hwctx,
struct nvhost_submit_hdr_ext *hdr,
- struct nvmap_client *nvmap,
+ struct mem_mgr *memmgr,
int priority, int clientid);
/*
diff --git a/drivers/video/tegra/host/nvhost_memmgr.c b/drivers/video/tegra/host/nvhost_memmgr.c
new file mode 100644
index 000000000000..f530c2e63006
--- /dev/null
+++ b/drivers/video/tegra/host/nvhost_memmgr.c
@@ -0,0 +1,34 @@
+/*
+ * drivers/video/tegra/host/nvhost_memmgr.c
+ *
+ * Tegra Graphics Host Memory Management Abstraction
+ *
+ * Copyright (c) 2012, NVIDIA Corporation.
+ *
+ * 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/kernel.h>
+#include <linux/err.h>
+
+#include "nvhost_memmgr.h"
+#include "nvmap.h"
+
+int nvhost_memmgr_init(struct nvhost_chip_support *chip)
+{
+#ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
+ return nvhost_init_nvmap_support(chip);
+#endif
+ BUG_ON(!"No memory manager selected");
+ return -ENODEV;
+}
diff --git a/drivers/video/tegra/host/nvhost_memmgr.h b/drivers/video/tegra/host/nvhost_memmgr.h
new file mode 100644
index 000000000000..d61379b6ff55
--- /dev/null
+++ b/drivers/video/tegra/host/nvhost_memmgr.h
@@ -0,0 +1,38 @@
+/*
+ * drivers/video/tegra/host/nvhost_memmgr.h
+ *
+ * Tegra Graphics Host Memory Management Abstraction header
+ *
+ * Copyright (c) 2012, NVIDIA Corporation.
+ *
+ * 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_MEM_MGR_H_
+#define _NVHOST_MEM_MGR_H_
+
+struct nvhost_chip_support;
+
+enum mem_mgr_flag {
+ mem_mgr_flag_uncacheable = 0,
+ mem_mgr_flag_write_combine = 1,
+};
+
+struct mem_mgr_handle {
+ struct mem_mgr *client;
+ struct mem_handle *handle;
+};
+
+int nvhost_memmgr_init(struct nvhost_chip_support *chip);
+
+#endif
diff --git a/drivers/video/tegra/host/nvhost_syncpt.c b/drivers/video/tegra/host/nvhost_syncpt.c
index 7550512b0214..34f7a0b08315 100644
--- a/drivers/video/tegra/host/nvhost_syncpt.c
+++ b/drivers/video/tegra/host/nvhost_syncpt.c
@@ -25,6 +25,7 @@
#include "nvhost_syncpt.h"
#include "nvhost_acm.h"
#include "dev.h"
+#include "chip_support.h"
#define MAX_SYNCPT_LENGTH 5
/* Name of sysfs node for min and max value */
diff --git a/drivers/video/tegra/host/nvhost_syncpt.h b/drivers/video/tegra/host/nvhost_syncpt.h
index fcc9fce72071..e39d3c3d8887 100644
--- a/drivers/video/tegra/host/nvhost_syncpt.h
+++ b/drivers/video/tegra/host/nvhost_syncpt.h
@@ -24,7 +24,6 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/nvhost.h>
-#include <linux/nvmap.h>
#include <linux/atomic.h>
/* host managed and invalid syncpt id */
diff --git a/drivers/video/tegra/host/nvmap.c b/drivers/video/tegra/host/nvmap.c
new file mode 100644
index 000000000000..fd82f40c59ff
--- /dev/null
+++ b/drivers/video/tegra/host/nvmap.c
@@ -0,0 +1,100 @@
+/*
+ * drivers/video/tegra/host/nvmap.c
+ *
+ * Tegra Graphics Host Nvmap support
+ *
+ * Copyright (c) 2012, NVIDIA Corporation.
+ *
+ * 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 "chip_support.h"
+#include <linux/nvmap.h>
+
+struct mem_mgr *nvhost_nvmap_alloc_mgr(void)
+{
+ return (struct mem_mgr *)nvmap_create_client(nvmap_dev, "nvhost");
+}
+
+void nvhost_nvmap_put_mgr(struct mem_mgr *mgr)
+{
+ nvmap_client_put((struct nvmap_client *)mgr);
+}
+
+struct mem_mgr *nvhost_nvmap_get_mgr(struct mem_mgr *mgr)
+{
+ return (struct mem_mgr *)nvmap_client_get((struct nvmap_client *)mgr);
+}
+
+struct mem_mgr *nvhost_nvmap_get_mgr_file(int fd)
+{
+ return (struct mem_mgr *)nvmap_client_get_file(fd);
+}
+
+struct mem_handle *nvhost_nvmap_alloc(struct mem_mgr *mgr,
+ size_t size, size_t align, int flags)
+{
+ return (struct mem_handle *)nvmap_alloc((struct nvmap_client *)mgr,
+ size, align, flags, 0);
+}
+
+void nvhost_nvmap_put(struct mem_mgr *mgr, struct mem_handle *handle)
+{
+ return nvmap_free((struct nvmap_client *)mgr,
+ (struct nvmap_handle_ref *)handle);
+}
+
+phys_addr_t nvhost_nvmap_pin(struct mem_mgr *mgr, struct mem_handle *handle)
+{
+ return nvmap_pin((struct nvmap_client *)mgr,
+ (struct nvmap_handle_ref *)handle);
+}
+
+void nvhost_nvmap_unpin(struct mem_mgr *mgr, struct mem_handle *handle)
+{
+ return nvmap_unpin((struct nvmap_client *)mgr,
+ (struct nvmap_handle_ref *)handle);
+}
+
+void *nvhost_nvmap_mmap(struct mem_handle *handle)
+{
+ return nvmap_mmap((struct nvmap_handle_ref *)handle);
+}
+
+void nvhost_nvmap_munmap(struct mem_handle *handle, void *addr)
+{
+ nvmap_munmap((struct nvmap_handle_ref *)handle, addr);
+}
+
+struct mem_handle *nvhost_nvmap_get(struct mem_mgr *mgr, u32 id)
+{
+ return (struct mem_handle *)
+ nvmap_duplicate_handle_id((struct nvmap_client *)mgr, id);
+}
+
+int nvhost_init_nvmap_support(struct nvhost_chip_support *chip)
+{
+ chip->mem.alloc_mgr = nvhost_nvmap_alloc_mgr;
+ chip->mem.put_mgr = nvhost_nvmap_put_mgr;
+ chip->mem.get_mgr = nvhost_nvmap_get_mgr;
+ chip->mem.get_mgr_file = nvhost_nvmap_get_mgr_file;
+ chip->mem.alloc = nvhost_nvmap_alloc;
+ chip->mem.put = nvhost_nvmap_put;
+ chip->mem.get = nvhost_nvmap_get;
+ chip->mem.pin = nvhost_nvmap_pin;
+ chip->mem.unpin = nvhost_nvmap_unpin;
+ chip->mem.mmap = nvhost_nvmap_mmap;
+ chip->mem.munmap = nvhost_nvmap_munmap;
+
+ return 0;
+}
diff --git a/drivers/video/tegra/host/nvmap.h b/drivers/video/tegra/host/nvmap.h
new file mode 100644
index 000000000000..90f64d44f434
--- /dev/null
+++ b/drivers/video/tegra/host/nvmap.h
@@ -0,0 +1,27 @@
+/*
+ * drivers/video/tegra/host/nvmap.h
+ *
+ * Tegra Graphics Host nvmap memory manager
+ *
+ * Copyright (c) 2010-2012, NVIDIA Corporation.
+ *
+ * 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_NVMAP_H
+#define __NVHOST_NVMAP_H
+
+struct nvhost_chip_support;
+int nvhost_init_nvmap_support(struct nvhost_chip_support *op);
+
+#endif
diff --git a/drivers/video/tegra/host/t20/t20.c b/drivers/video/tegra/host/t20/t20.c
index f6713d866f19..50648bc98990 100644
--- a/drivers/video/tegra/host/t20/t20.c
+++ b/drivers/video/tegra/host/t20/t20.c
@@ -32,6 +32,9 @@
#include "nvhost_channel.h"
#include "host1x/host1x_channel.h"
#include "host1x/host1x_cdma.h"
+#include "chip_support.h"
+#include "nvmap.h"
+#include "nvhost_memmgr.h"
#define NVMODMUTEX_2D_FULL (1)
#define NVMODMUTEX_2D_SIMPLE (2)
@@ -239,6 +242,7 @@ int nvhost_init_t20_support(struct nvhost_master *host,
err = nvhost_init_t20_intr_support(op);
if (err)
return err;
+ err = nvhost_memmgr_init(op);
op->nvhost_dev.get_nvhost_device = t20_get_nvhost_device;
op->nvhost_dev.alloc_nvhost_channel = t20_alloc_nvhost_channel;
diff --git a/drivers/video/tegra/host/t30/t30.c b/drivers/video/tegra/host/t30/t30.c
index b2768741546a..e6687fd2153b 100644
--- a/drivers/video/tegra/host/t30/t30.c
+++ b/drivers/video/tegra/host/t30/t30.c
@@ -34,6 +34,8 @@
#include "chip_support.h"
#include "nvhost_channel.h"
#include "host1x/host1x_cdma.h"
+#include "nvmap.h"
+#include "nvhost_memmgr.h"
#define NVMODMUTEX_2D_FULL (1)
#define NVMODMUTEX_2D_SIMPLE (2)
@@ -258,6 +260,9 @@ int nvhost_init_t30_support(struct nvhost_master *host,
err = nvhost_init_t20_intr_support(op);
if (err)
return err;
+ err = nvhost_memmgr_init(op);
+ if (err)
+ return err;
op->nvhost_dev.get_nvhost_device = t30_get_nvhost_device;
op->nvhost_dev.alloc_nvhost_channel = t30_alloc_nvhost_channel;