diff options
author | Mayuresh Kulkarni <mkulkarni@nvidia.com> | 2012-04-13 19:42:37 +0530 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-05-11 14:11:55 -0700 |
commit | 03a0e0eafc0e70fa2c56359d4caa379745ad7259 (patch) | |
tree | ebc2c3daa48f9f82ec707d050e76f106a6e073f7 /drivers/video | |
parent | 881cc68b78cb8b188222ecb29205f5b601a8b2e5 (diff) |
video: tegra: host: move chip_support out of nvhost_master
- currently, nvhost_master holds the reference to struct
chip_support
- the struct chip_support hides the chip specific implementation
for channel submit, cdma, push buffer operations etc. so
it exposed all the internal structures through nvhost_master
- move chip_support to be a part of nvhost_bus since it only has
function pointers to chip specific api implementations
- nvhost_master is host1x device specific private data so
ideally it should not hold reference to chip specifics
Bug 871237
Change-Id: I4f3f48ee5fc47a90288d110ea8eef905150275a0
Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/94421
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/video')
27 files changed, 350 insertions, 234 deletions
diff --git a/drivers/video/tegra/host/Makefile b/drivers/video/tegra/host/Makefile index 0180885af4d7..d47c97571286 100644 --- a/drivers/video/tegra/host/Makefile +++ b/drivers/video/tegra/host/Makefile @@ -9,7 +9,8 @@ nvhost-objs = \ bus.o \ dev.o \ debug.o \ - bus_client.o + bus_client.o \ + chip_support.o obj-$(CONFIG_TEGRA_GRHOST) += mpe/ obj-$(CONFIG_TEGRA_GRHOST) += gr3d/ diff --git a/drivers/video/tegra/host/bus.c b/drivers/video/tegra/host/bus.c index 774aac7bd431..12cb7181702d 100644 --- a/drivers/video/tegra/host/bus.c +++ b/drivers/video/tegra/host/bus.c @@ -17,11 +17,14 @@ * */ +#include <linux/slab.h> #include <linux/pm_runtime.h> #include <linux/nvhost.h> +#include "bus.h" #include "dev.h" +struct nvhost_bus *nvhost_bus_inst; struct nvhost_master *nvhost; struct resource *nvhost_get_resource(struct nvhost_device *dev, @@ -98,7 +101,7 @@ static void nvhost_drv_shutdown(struct device *_dev) int nvhost_driver_register(struct nvhost_driver *drv) { - drv->driver.bus = &nvhost_bus_type; + drv->driver.bus = &nvhost_bus_inst->nvhost_bus_type; if (drv->probe) drv->driver.probe = nvhost_drv_probe; if (drv->remove) @@ -129,7 +132,7 @@ int nvhost_device_register(struct nvhost_device *dev) if (!dev->dev.parent && nvhost && nvhost->dev != dev) dev->dev.parent = &nvhost->dev->dev; - dev->dev.bus = &nvhost_bus_type; + dev->dev.bus = &nvhost_bus_inst->nvhost_bus_type; if (dev->id != -1) dev_set_name(&dev->dev, "%s.%d", dev->name, dev->id); @@ -528,13 +531,6 @@ static const struct dev_pm_ops nvhost_dev_pm_ops = { .runtime_idle = nvhost_pm_runtime_idle, }; -struct bus_type nvhost_bus_type = { - .name = "nvhost", - .match = nvhost_bus_match, - .pm = &nvhost_dev_pm_ops, -}; -EXPORT_SYMBOL(nvhost_bus_type); - static int set_parent(struct device *dev, void *data) { struct nvhost_device *ndev = to_nvhost_device(dev); @@ -549,21 +545,44 @@ int nvhost_bus_add_host(struct nvhost_master *host) nvhost = host; /* Assign host1x as parent to all devices in nvhost bus */ - bus_for_each_dev(&nvhost_bus_type, NULL, host, set_parent); + bus_for_each_dev(&nvhost_bus_inst->nvhost_bus_type, NULL, host, set_parent); return 0; } +struct nvhost_bus *nvhost_bus_get(void) +{ + return nvhost_bus_inst; +} int nvhost_bus_init(void) { int err; + struct nvhost_chip_support *chip_ops; pr_info("host1x bus init\n"); - err = bus_register(&nvhost_bus_type); + nvhost_bus_inst = kzalloc(sizeof(*nvhost_bus_inst), GFP_KERNEL); + if (nvhost_bus_inst == NULL) { + pr_err("%s: Cannot allocate nvhost_bus\n", __func__); + return -ENOMEM; + } + + chip_ops = kzalloc(sizeof(*chip_ops), GFP_KERNEL); + if (chip_ops == NULL) { + pr_err("%s: Cannot allocate nvhost_chip_support\n", __func__); + kfree(nvhost_bus_inst); + nvhost_bus_inst = NULL; + return -ENOMEM; + } + + nvhost_bus_inst->nvhost_bus_type.name = "nvhost"; + nvhost_bus_inst->nvhost_bus_type.match = nvhost_bus_match; + nvhost_bus_inst->nvhost_bus_type.pm = &nvhost_dev_pm_ops; + nvhost_bus_inst->nvhost_chip_ops = chip_ops; + + err = bus_register(&nvhost_bus_inst->nvhost_bus_type); return err; } postcore_initcall(nvhost_bus_init); - diff --git a/drivers/video/tegra/host/bus.h b/drivers/video/tegra/host/bus.h new file mode 100644 index 000000000000..99f820335d60 --- /dev/null +++ b/drivers/video/tegra/host/bus.h @@ -0,0 +1,38 @@ +/* + * drivers/video/tegra/host/bus.h + * + * Tegra Graphics Host bus API header + * + * 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_BUS_H +#define __NVHOST_BUS_H + +#include <linux/types.h> +#include <linux/device.h> + +#include "chip_support.h" + +struct nvhost_bus { + struct nvhost_chip_support *nvhost_chip_ops; + struct bus_type nvhost_bus_type; +}; + +struct nvhost_bus *nvhost_bus_get(void); + +extern struct nvhost_bus *nvhost_bus_inst; + +#endif diff --git a/drivers/video/tegra/host/bus_client.c b/drivers/video/tegra/host/bus_client.c index c6160d6db36e..660e7956edba 100644 --- a/drivers/video/tegra/host/bus_client.c +++ b/drivers/video/tegra/host/bus_client.c @@ -339,12 +339,11 @@ static int nvhost_ioctl_channel_flush( return err; } -static int nvhost_ioctl_channel_read_3d_reg( - struct nvhost_channel_userctx *ctx, +static int nvhost_ioctl_channel_read_3d_reg(struct nvhost_channel_userctx *ctx, struct nvhost_read_3d_reg_args *args) { - BUG_ON(!channel_op(ctx->ch).read3dreg); - return channel_op(ctx->ch).read3dreg(ctx->ch, ctx->hwctx, + BUG_ON(!channel_op().read3dreg); + return channel_op().read3dreg(ctx->ch, ctx->hwctx, args->offset, &args->value); } diff --git a/drivers/video/tegra/host/chip_support.c b/drivers/video/tegra/host/chip_support.c new file mode 100644 index 000000000000..9abb1fa026a4 --- /dev/null +++ b/drivers/video/tegra/host/chip_support.c @@ -0,0 +1,56 @@ +/* + * drivers/video/tegra/host/chip_support.c + * + * Tegra Graphics Host Chip support module + * + * 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/errno.h> + +#include <mach/hardware.h> + +#include "bus.h" +#include "chip_support.h" +#include "t20/t20.h" +#include "t30/t30.h" + +struct nvhost_chip_support *nvhost_get_chip_ops(void) +{ + return (nvhost_bus_get())->nvhost_chip_ops; +} + +int nvhost_init_chip_support(struct nvhost_master *host) +{ + int err = 0; + struct nvhost_chip_support *chip_ops; + + chip_ops = nvhost_get_chip_ops(); + + switch (tegra_get_chipid()) { + case TEGRA_CHIPID_TEGRA2: + err = nvhost_init_t20_support(host, chip_ops); + break; + + case TEGRA_CHIPID_TEGRA3: + err = nvhost_init_t30_support(host, chip_ops); + break; + + default: + err = -ENODEV; + } + + return err; +} diff --git a/drivers/video/tegra/host/chip_support.h b/drivers/video/tegra/host/chip_support.h index 6e32feb9676e..9f56a90d9953 100644 --- a/drivers/video/tegra/host/chip_support.h +++ b/drivers/video/tegra/host/chip_support.h @@ -21,6 +21,8 @@ #define _NVHOST_CHIP_SUPPORT_H_ #include <linux/types.h> +#include "bus.h" + struct output; struct nvhost_master; @@ -35,7 +37,10 @@ struct nvhost_hwctx; struct nvhost_cdma; struct nvhost_job; struct push_buffer; +struct nvhost_syncpt; struct dentry; +struct nvhost_job; +struct nvhost_intr_syncpt; struct nvhost_chip_support { struct { @@ -138,4 +143,16 @@ struct nvhost_chip_support { } nvhost_dev; }; +struct nvhost_chip_support *nvhost_get_chip_ops(void); + +#define host_device_op() nvhost_get_chip_ops()->nvhost_dev +#define channel_cdma_op() nvhost_get_chip_ops()->cdma +#define channel_op() nvhost_get_chip_ops()->channel +#define syncpt_op() nvhost_get_chip_ops()->syncpt +#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 + +int nvhost_init_chip_support(struct nvhost_master *); + #endif /* _NVHOST_CHIP_SUPPORT_H_ */ diff --git a/drivers/video/tegra/host/debug.c b/drivers/video/tegra/host/debug.c index b7adb0e573eb..8a26f92c79f6 100644 --- a/drivers/video/tegra/host/debug.c +++ b/drivers/video/tegra/host/debug.c @@ -22,10 +22,12 @@ #include <linux/io.h> +#include "bus.h" #include "dev.h" #include "debug.h" #include "nvhost_acm.h" #include "nvhost_channel.h" +#include "chip_support.h" pid_t nvhost_debug_null_kickoff_pid; unsigned int nvhost_debug_trace_cmdbuf; @@ -61,8 +63,8 @@ static int show_channels(struct device *dev, void *data) mutex_lock(&ch->reflock); if (ch->refcount) { mutex_lock(&ch->cdma.lock); - m->op.debug.show_channel_fifo(m, ch, o, nvdev->index); - m->op.debug.show_channel_cdma(m, ch, o, nvdev->index); + nvhost_get_chip_ops()->debug.show_channel_fifo(m, ch, o, nvdev->index); + nvhost_get_chip_ops()->debug.show_channel_cdma(m, ch, o, nvdev->index); mutex_unlock(&ch->cdma.lock); } mutex_unlock(&ch->reflock); @@ -74,7 +76,7 @@ static int show_channels(struct device *dev, void *data) static void show_syncpts(struct nvhost_master *m, struct output *o) { int i; - BUG_ON(!m->op.syncpt.name); + BUG_ON(!nvhost_get_chip_ops()->syncpt.name); nvhost_debug_output(o, "---- syncpts ----\n"); for (i = 0; i < m->syncpt.nb_pts; i++) { u32 max = nvhost_syncpt_read_max(&m->syncpt, i); @@ -82,7 +84,7 @@ static void show_syncpts(struct nvhost_master *m, struct output *o) if (!min && !max) continue; nvhost_debug_output(o, "id %d (%s) min %d max %d\n", - i, m->op.syncpt.name(&m->syncpt, i), + i, nvhost_get_chip_ops()->syncpt.name(&m->syncpt, i), min, max); } @@ -101,10 +103,10 @@ static void show_all(struct nvhost_master *m, struct output *o) { nvhost_module_busy(m->dev); - m->op.debug.show_mlocks(m, o); + nvhost_get_chip_ops()->debug.show_mlocks(m, o); show_syncpts(m, o); nvhost_debug_output(o, "---- channels ----\n"); - bus_for_each_dev(&nvhost_bus_type, NULL, o, show_channels); + bus_for_each_dev(&(nvhost_bus_get())->nvhost_bus_type, NULL, o, show_channels); nvhost_module_idle(m->dev); } @@ -144,8 +146,8 @@ void nvhost_debug_init(struct nvhost_master *master) debugfs_create_u32("trace_cmdbuf", S_IRUGO|S_IWUSR, de, &nvhost_debug_trace_cmdbuf); - if (master->op.debug.debug_init) - master->op.debug.debug_init(de); + if (nvhost_get_chip_ops()->debug.debug_init) + nvhost_get_chip_ops()->debug.debug_init(de); debugfs_create_u32("force_timeout_pid", S_IRUGO|S_IWUSR, de, &nvhost_debug_force_timeout_pid); diff --git a/drivers/video/tegra/host/dev.c b/drivers/video/tegra/host/dev.c index 7917e4e20b44..9142b52f72f2 100644 --- a/drivers/video/tegra/host/dev.c +++ b/drivers/video/tegra/host/dev.c @@ -178,7 +178,7 @@ static int match_by_moduleid(struct device *dev, void *data) static struct nvhost_device *get_ndev_by_moduleid(struct nvhost_master *host, u32 id) { - struct device *dev = bus_find_device(&nvhost_bus_type, NULL, (void *)id, + struct device *dev = bus_find_device(&nvhost_bus_inst->nvhost_bus_type, NULL, (void *)id, match_by_moduleid); return dev ? to_nvhost_device(dev) : NULL; @@ -352,11 +352,11 @@ fail: struct nvhost_device *nvhost_get_device(char *name) { - BUG_ON(!host_device_op(nvhost).get_nvhost_device); - return host_device_op(nvhost).get_nvhost_device(nvhost, name); + BUG_ON(!host_device_op().get_nvhost_device); + return host_device_op().get_nvhost_device(nvhost, name); } -static void nvhost_remove_chip_support(struct nvhost_master *host) +static void nvhost_free_resources(struct nvhost_master *host) { kfree(host->channels); host->channels = 0; @@ -365,21 +365,11 @@ static void nvhost_remove_chip_support(struct nvhost_master *host) host->intr.syncpt = 0; } -static int __devinit nvhost_init_chip_support(struct nvhost_master *host) +static int __devinit nvhost_alloc_resources(struct nvhost_master *host) { int err; - switch (tegra_get_chipid()) { - case TEGRA_CHIPID_TEGRA2: - err = nvhost_init_t20_support(host); - break; - - case TEGRA_CHIPID_TEGRA3: - err = nvhost_init_t30_support(host); - break; - default: - return -ENODEV; - } + err = nvhost_init_chip_support(host); if (err) return err; @@ -468,7 +458,7 @@ static int __devinit nvhost_probe(struct nvhost_device *dev) goto fail; } - err = nvhost_init_chip_support(host); + err = nvhost_alloc_resources(host); if (err) { dev_err(&dev->dev, "failed to init chip support\n"); goto fail; @@ -510,7 +500,7 @@ static int __devinit nvhost_probe(struct nvhost_device *dev) return 0; fail: - nvhost_remove_chip_support(host); + nvhost_free_resources(host); if (host->nvmap) nvmap_client_put(host->nvmap); kfree(host); @@ -522,7 +512,7 @@ static int __exit nvhost_remove(struct nvhost_device *dev) struct nvhost_master *host = nvhost_get_drvdata(dev); nvhost_intr_deinit(&host->intr); nvhost_syncpt_deinit(&host->syncpt); - nvhost_remove_chip_support(host); + nvhost_free_resources(host); return 0; } diff --git a/drivers/video/tegra/host/dev.h b/drivers/video/tegra/host/dev.h index b357ef9f29c9..8360725ed88f 100644 --- a/drivers/video/tegra/host/dev.h +++ b/drivers/video/tegra/host/dev.h @@ -45,9 +45,6 @@ struct nvhost_master { struct nvhost_device *dev; struct nvhost_channel *channels; u32 nb_channels; - - struct nvhost_chip_support op; - atomic_t clientid; }; @@ -56,8 +53,6 @@ extern struct nvhost_master *nvhost; void nvhost_debug_init(struct nvhost_master *master); void nvhost_debug_dump(struct nvhost_master *master); -#define host_device_op(host) (host->op.nvhost_dev) - struct nvhost_device *nvhost_get_device(char *name); extern pid_t nvhost_debug_null_kickoff_pid; diff --git a/drivers/video/tegra/host/host1x/host1x_cdma.c b/drivers/video/tegra/host/host1x/host1x_cdma.c index 08762020f366..813b35476f5b 100644 --- a/drivers/video/tegra/host/host1x/host1x_cdma.c +++ b/drivers/video/tegra/host/host1x/host1x_cdma.c @@ -68,8 +68,8 @@ static int push_buffer_init(struct push_buffer *pb) pb->phys = 0; pb->nvmap = NULL; - BUG_ON(!cdma_pb_op(cdma).reset); - cdma_pb_op(cdma).reset(pb); + 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, @@ -103,7 +103,7 @@ static int push_buffer_init(struct push_buffer *pb) return 0; fail: - cdma_pb_op(cdma).destroy(pb); + cdma_pb_op().destroy(pb); return -ENOMEM; } @@ -258,7 +258,7 @@ static int cdma_timeout_init(struct nvhost_cdma *cdma, return 0; fail: - cdma_op(cdma).timeout_destroy(cdma); + cdma_op().timeout_destroy(cdma); return -ENOMEM; } @@ -402,8 +402,8 @@ static void cdma_start(struct nvhost_cdma *cdma) if (cdma->running) return; - BUG_ON(!cdma_pb_op(cdma).putptr); - cdma->last_put = cdma_pb_op(cdma).putptr(&cdma->push_buffer); + BUG_ON(!cdma_pb_op().putptr); + cdma->last_put = cdma_pb_op().putptr(&cdma->push_buffer); writel(host1x_channel_dmactrl(true, false, false), chan_regs + HOST1X_CHANNEL_DMACTRL); @@ -437,8 +437,8 @@ static void cdma_timeout_restart(struct nvhost_cdma *cdma, u32 getptr) if (cdma->running) return; - BUG_ON(!cdma_pb_op(cdma).putptr); - cdma->last_put = cdma_pb_op(cdma).putptr(&cdma->push_buffer); + BUG_ON(!cdma_pb_op().putptr); + cdma->last_put = cdma_pb_op().putptr(&cdma->push_buffer); writel(host1x_channel_dmactrl(true, false, false), chan_regs + HOST1X_CHANNEL_DMACTRL); @@ -477,9 +477,9 @@ static void cdma_timeout_restart(struct nvhost_cdma *cdma, u32 getptr) static void cdma_kick(struct nvhost_cdma *cdma) { u32 put; - BUG_ON(!cdma_pb_op(cdma).putptr); + BUG_ON(!cdma_pb_op().putptr); - put = cdma_pb_op(cdma).putptr(&cdma->push_buffer); + put = cdma_pb_op().putptr(&cdma->push_buffer); if (put != cdma->last_put) { void __iomem *chan_regs = cdma_to_channel(cdma)->aperture; @@ -631,37 +631,37 @@ static void cdma_timeout_handler(struct work_struct *work) "%s: timeout: %d (%s) ctx 0x%p, HW thresh %d, done %d\n", __func__, cdma->timeout.syncpt_id, - syncpt_op(sp).name(sp, cdma->timeout.syncpt_id), + syncpt_op().name(sp, cdma->timeout.syncpt_id), cdma->timeout.ctx, syncpt_val, cdma->timeout.syncpt_val); /* stop HW, resetting channel/module */ - cdma_op(cdma).timeout_teardown_begin(cdma); + cdma_op().timeout_teardown_begin(cdma); nvhost_cdma_update_sync_queue(cdma, sp, &dev->dev->dev); mutex_unlock(&cdma->lock); } -int host1x_init_cdma_support(struct nvhost_master *host) +int host1x_init_cdma_support(struct nvhost_chip_support *op) { - host->op.cdma.start = cdma_start; - host->op.cdma.stop = cdma_stop; - host->op.cdma.kick = cdma_kick; - - host->op.cdma.timeout_init = cdma_timeout_init; - host->op.cdma.timeout_destroy = cdma_timeout_destroy; - host->op.cdma.timeout_teardown_begin = cdma_timeout_teardown_begin; - host->op.cdma.timeout_teardown_end = cdma_timeout_teardown_end; - host->op.cdma.timeout_cpu_incr = cdma_timeout_cpu_incr; - host->op.cdma.timeout_pb_incr = cdma_timeout_pb_incr; - - host->op.push_buffer.reset = push_buffer_reset; - host->op.push_buffer.init = push_buffer_init; - host->op.push_buffer.destroy = push_buffer_destroy; - host->op.push_buffer.push_to = push_buffer_push_to; - host->op.push_buffer.pop_from = push_buffer_pop_from; - host->op.push_buffer.space = push_buffer_space; - host->op.push_buffer.putptr = push_buffer_putptr; + op->cdma.start = cdma_start; + op->cdma.stop = cdma_stop; + op->cdma.kick = cdma_kick; + + op->cdma.timeout_init = cdma_timeout_init; + op->cdma.timeout_destroy = cdma_timeout_destroy; + op->cdma.timeout_teardown_begin = cdma_timeout_teardown_begin; + op->cdma.timeout_teardown_end = cdma_timeout_teardown_end; + op->cdma.timeout_cpu_incr = cdma_timeout_cpu_incr; + op->cdma.timeout_pb_incr = cdma_timeout_pb_incr; + + op->push_buffer.reset = push_buffer_reset; + op->push_buffer.init = push_buffer_init; + op->push_buffer.destroy = push_buffer_destroy; + op->push_buffer.push_to = push_buffer_push_to; + op->push_buffer.pop_from = push_buffer_pop_from; + op->push_buffer.space = push_buffer_space; + op->push_buffer.putptr = push_buffer_putptr; return 0; } diff --git a/drivers/video/tegra/host/host1x/host1x_cdma.h b/drivers/video/tegra/host/host1x/host1x_cdma.h index 60909236a7ca..374097272d3f 100644 --- a/drivers/video/tegra/host/host1x/host1x_cdma.h +++ b/drivers/video/tegra/host/host1x/host1x_cdma.h @@ -36,6 +36,6 @@ * and replaces the original timed out contexts GATHER slots */ #define SYNCPT_INCR_BUFFER_SIZE_WORDS (4096 / sizeof(u32)) -int host1x_init_cdma_support(struct nvhost_master *); +int host1x_init_cdma_support(struct nvhost_chip_support *); #endif diff --git a/drivers/video/tegra/host/host1x/host1x_debug.c b/drivers/video/tegra/host/host1x/host1x_debug.c index 39565bc96465..76483d82528b 100644 --- a/drivers/video/tegra/host/host1x/host1x_debug.c +++ b/drivers/video/tegra/host/host1x/host1x_debug.c @@ -389,11 +389,11 @@ static void t20_debug_show_mlocks(struct nvhost_master *m, struct output *o) nvhost_debug_output(o, "\n"); } -int nvhost_init_t20_debug_support(struct nvhost_master *host) +int nvhost_init_t20_debug_support(struct nvhost_chip_support *op) { - host->op.debug.show_channel_cdma = t20_debug_show_channel_cdma; - host->op.debug.show_channel_fifo = t20_debug_show_channel_fifo; - host->op.debug.show_mlocks = t20_debug_show_mlocks; + op->debug.show_channel_cdma = t20_debug_show_channel_cdma; + op->debug.show_channel_fifo = t20_debug_show_channel_fifo; + op->debug.show_mlocks = t20_debug_show_mlocks; return 0; } diff --git a/drivers/video/tegra/host/host1x/host1x_intr.c b/drivers/video/tegra/host/host1x/host1x_intr.c index 6d2aedbb9803..ac1c7d089fa8 100644 --- a/drivers/video/tegra/host/host1x/host1x_intr.c +++ b/drivers/video/tegra/host/host1x/host1x_intr.c @@ -26,7 +26,6 @@ #include "dev.h" #include "host1x_hardware.h" - /*** HW host sync management ***/ static void t20_intr_init_host_sync(struct nvhost_intr *intr) @@ -199,21 +198,16 @@ static int t20_request_syncpt_irq(struct nvhost_intr_syncpt *syncpt) return 0; } -int nvhost_init_t20_intr_support(struct nvhost_master *host) +int nvhost_init_t20_intr_support(struct nvhost_chip_support *op) { - host->op.intr.init_host_sync = t20_intr_init_host_sync; - host->op.intr.set_host_clocks_per_usec = - t20_intr_set_host_clocks_per_usec; - host->op.intr.set_syncpt_threshold = t20_intr_set_syncpt_threshold; - host->op.intr.enable_syncpt_intr = t20_intr_enable_syncpt_intr; - host->op.intr.disable_all_syncpt_intrs = - t20_intr_disable_all_syncpt_intrs; - host->op.intr.request_host_general_irq = - t20_intr_request_host_general_irq; - host->op.intr.free_host_general_irq = - t20_intr_free_host_general_irq; - host->op.intr.request_syncpt_irq = - t20_request_syncpt_irq; + op->intr.init_host_sync = t20_intr_init_host_sync; + op->intr.set_host_clocks_per_usec = t20_intr_set_host_clocks_per_usec; + op->intr.set_syncpt_threshold = t20_intr_set_syncpt_threshold; + op->intr.enable_syncpt_intr = t20_intr_enable_syncpt_intr; + op->intr.disable_all_syncpt_intrs = t20_intr_disable_all_syncpt_intrs; + op->intr.request_host_general_irq = t20_intr_request_host_general_irq; + op->intr.free_host_general_irq = t20_intr_free_host_general_irq; + op->intr.request_syncpt_irq = t20_request_syncpt_irq; return 0; } diff --git a/drivers/video/tegra/host/host1x/host1x_syncpt.c b/drivers/video/tegra/host/host1x/host1x_syncpt.c index 967bc6fe442c..b7d6587acc61 100644 --- a/drivers/video/tegra/host/host1x/host1x_syncpt.c +++ b/drivers/video/tegra/host/host1x/host1x_syncpt.c @@ -26,6 +26,7 @@ #include "dev.h" #include "host1x_syncpt.h" #include "host1x_hardware.h" +#include "chip_support.h" /** * Write the current syncpoint value back to hw. @@ -140,7 +141,7 @@ static int t20_syncpt_wait_check(struct nvhost_syncpt *sp, dev_dbg(&syncpt_to_dev(sp)->dev->dev, "drop WAIT id %d (%s) thresh 0x%x, min 0x%x\n", wait->syncpt_id, - syncpt_op(sp).name(sp, wait->syncpt_id), + syncpt_op().name(sp, wait->syncpt_id), wait->thresh, nvhost_syncpt_read_min(sp, wait->syncpt_id)); @@ -194,7 +195,7 @@ static void t20_syncpt_debug(struct nvhost_syncpt *sp) continue; dev_info(&syncpt_to_dev(sp)->dev->dev, "id %d (%s) min %d max %d\n", - i, syncpt_op(sp).name(sp, i), + i, syncpt_op().name(sp, i), min, max); } @@ -228,23 +229,23 @@ static void syncpt_mutex_unlock(struct nvhost_syncpt *sp, writel(0, sync_regs + (HOST1X_SYNC_MLOCK_0 + idx * 4)); } -int host1x_init_syncpt_support(struct nvhost_master *host) +int host1x_init_syncpt_support(struct nvhost_master *host, + struct nvhost_chip_support *op) { - host->sync_aperture = host->aperture + (NV_HOST1X_CHANNEL0_BASE + HOST1X_CHANNEL_SYNC_REG_BASE); - host->op.syncpt.reset = t20_syncpt_reset; - host->op.syncpt.reset_wait_base = t20_syncpt_reset_wait_base; - host->op.syncpt.read_wait_base = t20_syncpt_read_wait_base; - host->op.syncpt.update_min = t20_syncpt_update_min; - host->op.syncpt.cpu_incr = t20_syncpt_cpu_incr; - host->op.syncpt.wait_check = t20_syncpt_wait_check; - host->op.syncpt.debug = t20_syncpt_debug; - host->op.syncpt.name = t20_syncpt_name; - host->op.syncpt.mutex_try_lock = syncpt_mutex_try_lock; - host->op.syncpt.mutex_unlock = syncpt_mutex_unlock; + op->syncpt.reset = t20_syncpt_reset; + op->syncpt.reset_wait_base = t20_syncpt_reset_wait_base; + op->syncpt.read_wait_base = t20_syncpt_read_wait_base; + op->syncpt.update_min = t20_syncpt_update_min; + op->syncpt.cpu_incr = t20_syncpt_cpu_incr; + op->syncpt.wait_check = t20_syncpt_wait_check; + op->syncpt.debug = t20_syncpt_debug; + op->syncpt.name = t20_syncpt_name; + op->syncpt.mutex_try_lock = syncpt_mutex_try_lock; + op->syncpt.mutex_unlock = syncpt_mutex_unlock; host->syncpt.nb_pts = NV_HOST1X_SYNCPT_NB_PTS; host->syncpt.nb_bases = NV_HOST1X_SYNCPT_NB_BASES; diff --git a/drivers/video/tegra/host/host1x/host1x_syncpt.h b/drivers/video/tegra/host/host1x/host1x_syncpt.h index 0d263dc92ed5..1e94a2b846eb 100644 --- a/drivers/video/tegra/host/host1x/host1x_syncpt.h +++ b/drivers/video/tegra/host/host1x/host1x_syncpt.h @@ -71,7 +71,10 @@ #define NVWAITBASE_MPE (4) struct nvhost_master; +struct nvhost_chip_support; + int host1x_init_syncpt(struct nvhost_master *host); -int host1x_init_syncpt_support(struct nvhost_master *host); +int host1x_init_syncpt_support(struct nvhost_master *host, + struct nvhost_chip_support *op); #endif diff --git a/drivers/video/tegra/host/nvhost_cdma.c b/drivers/video/tegra/host/nvhost_cdma.c index 57dc781d7af6..4229def79c1e 100644 --- a/drivers/video/tegra/host/nvhost_cdma.c +++ b/drivers/video/tegra/host/nvhost_cdma.c @@ -69,8 +69,8 @@ static unsigned int cdma_status_locked(struct nvhost_cdma *cdma, return list_empty(&cdma->sync_queue) ? 1 : 0; case CDMA_EVENT_PUSH_BUFFER_SPACE: { struct push_buffer *pb = &cdma->push_buffer; - BUG_ON(!cdma_pb_op(cdma).space); - return cdma_pb_op(cdma).space(pb); + BUG_ON(!cdma_pb_op().space); + return cdma_pb_op().space(pb); } default: return 0; @@ -187,8 +187,8 @@ static void update_cdma_locked(struct nvhost_cdma *cdma) /* Pop push buffer slots */ if (job->num_slots) { struct push_buffer *pb = &cdma->push_buffer; - BUG_ON(!cdma_pb_op(cdma).pop_from); - cdma_pb_op(cdma).pop_from(pb, job->num_slots); + BUG_ON(!cdma_pb_op().pop_from); + cdma_pb_op().pop_from(pb, job->num_slots); if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE) signal = true; } @@ -280,7 +280,7 @@ void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma, nvhost_job_dump(dev, job); /* safe to use CPU to incr syncpts */ - cdma_op(cdma).timeout_cpu_incr(cdma, + cdma_op().timeout_cpu_incr(cdma, job->first_get, syncpt_incrs, job->syncpt_end, @@ -303,7 +303,7 @@ void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma, job->timeout = 0; /* update buffer's syncpts in the pushbuffer */ - cdma_op(cdma).timeout_pb_incr(cdma, + cdma_op().timeout_pb_incr(cdma, job->first_get, job->syncpt_incrs, job->num_slots, @@ -328,7 +328,7 @@ void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma, "%s: finished sync_queue modification\n", __func__); /* roll back DMAGET and start up channel again */ - cdma_op(cdma).timeout_teardown_end(cdma, get_restart); + cdma_op().timeout_teardown_end(cdma, get_restart); if (cdma->timeout.ctx) cdma->timeout.ctx->has_timedout = true; @@ -341,7 +341,7 @@ int nvhost_cdma_init(struct nvhost_cdma *cdma) { int err; struct push_buffer *pb = &cdma->push_buffer; - BUG_ON(!cdma_pb_op(cdma).init); + BUG_ON(!cdma_pb_op().init); mutex_init(&cdma->lock); sema_init(&cdma->sem, 0); @@ -351,7 +351,7 @@ int nvhost_cdma_init(struct nvhost_cdma *cdma) cdma->running = false; cdma->torndown = false; - err = cdma_pb_op(cdma).init(pb); + err = cdma_pb_op().init(pb); if (err) return err; return 0; @@ -364,10 +364,10 @@ void nvhost_cdma_deinit(struct nvhost_cdma *cdma) { struct push_buffer *pb = &cdma->push_buffer; - BUG_ON(!cdma_pb_op(cdma).destroy); + BUG_ON(!cdma_pb_op().destroy); BUG_ON(cdma->running); - cdma_pb_op(cdma).destroy(pb); - cdma_op(cdma).timeout_destroy(cdma); + cdma_pb_op().destroy(pb); + cdma_op().timeout_destroy(cdma); } /** @@ -381,8 +381,8 @@ int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job) /* init state on first submit with timeout value */ if (!cdma->timeout.initialized) { int err; - BUG_ON(!cdma_op(cdma).timeout_init); - err = cdma_op(cdma).timeout_init(cdma, + BUG_ON(!cdma_op().timeout_init); + err = cdma_op().timeout_init(cdma, job->syncpt_id); if (err) { mutex_unlock(&cdma->lock); @@ -391,12 +391,12 @@ int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job) } } if (!cdma->running) { - BUG_ON(!cdma_op(cdma).start); - cdma_op(cdma).start(cdma); + BUG_ON(!cdma_op().start); + cdma_op().start(cdma); } cdma->slots_free = 0; cdma->slots_used = 0; - cdma->first_get = cdma_pb_op(cdma).putptr(&cdma->push_buffer); + cdma->first_get = cdma_pb_op().putptr(&cdma->push_buffer); return 0; } @@ -456,20 +456,21 @@ void nvhost_cdma_push_gather(struct nvhost_cdma *cdma, { u32 slots_free = cdma->slots_free; struct push_buffer *pb = &cdma->push_buffer; - BUG_ON(!cdma_pb_op(cdma).push_to); - BUG_ON(!cdma_op(cdma).kick); + + BUG_ON(!cdma_pb_op().push_to); + BUG_ON(!cdma_op().kick); if (handle) trace_write_gather(cdma, handle, offset, op1 & 0xffff); if (slots_free == 0) { - cdma_op(cdma).kick(cdma); + cdma_op().kick(cdma); slots_free = nvhost_cdma_wait_locked(cdma, CDMA_EVENT_PUSH_BUFFER_SPACE); } cdma->slots_free = slots_free - 1; cdma->slots_used++; - cdma_pb_op(cdma).push_to(pb, client, handle, op1, op2); + cdma_pb_op().push_to(pb, client, handle, op1, op2); } /** @@ -483,8 +484,8 @@ void nvhost_cdma_end(struct nvhost_cdma *cdma, { bool was_idle = list_empty(&cdma->sync_queue); - BUG_ON(!cdma_op(cdma).kick); - cdma_op(cdma).kick(cdma); + BUG_ON(!cdma_op().kick); + cdma_op().kick(cdma); BUG_ON(job->syncpt_id == NVSYNCPT_INVALID); diff --git a/drivers/video/tegra/host/nvhost_cdma.h b/drivers/video/tegra/host/nvhost_cdma.h index d9dd25a195cd..2f83d07be9d1 100644 --- a/drivers/video/tegra/host/nvhost_cdma.h +++ b/drivers/video/tegra/host/nvhost_cdma.h @@ -104,10 +104,8 @@ 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_op(cdma) (cdma_to_dev(cdma)->op.cdma) #define cdma_to_nvmap(cdma) ((cdma_to_dev(cdma))->nvmap) #define pb_to_cdma(pb) container_of(pb, struct nvhost_cdma, push_buffer) -#define cdma_pb_op(cdma) (cdma_to_dev(cdma)->op.push_buffer) int nvhost_cdma_init(struct nvhost_cdma *cdma); void nvhost_cdma_deinit(struct nvhost_cdma *cdma); diff --git a/drivers/video/tegra/host/nvhost_channel.c b/drivers/video/tegra/host/nvhost_channel.c index 129a41cc2f42..e09f50a6694e 100644 --- a/drivers/video/tegra/host/nvhost_channel.c +++ b/drivers/video/tegra/host/nvhost_channel.c @@ -22,12 +22,12 @@ #include "dev.h" #include "nvhost_acm.h" #include "nvhost_job.h" +#include "chip_support.h" + #include <trace/events/nvhost.h> #include <linux/nvhost_ioctl.h> #include <linux/slab.h> -#include <linux/platform_device.h> - #define NVHOST_CHANNEL_LOW_PRIO_MAX_WAIT 50 int nvhost_channel_init(struct nvhost_channel *ch, @@ -37,7 +37,7 @@ int nvhost_channel_init(struct nvhost_channel *ch, struct nvhost_device *ndev; /* Link nvhost_device to nvhost_channel */ - err = host_channel_op(dev).init(ch, dev, index); + err = channel_op().init(ch, dev, index); if (err < 0) { dev_err(&dev->dev->dev, "failed to init channel %d\n", index); @@ -58,7 +58,7 @@ int nvhost_channel_submit(struct nvhost_job *job) (void)nvhost_cdma_flush(&job->ch->cdma, NVHOST_CHANNEL_LOW_PRIO_MAX_WAIT); - return channel_op(job->ch).submit(job); + return channel_op().submit(job); } struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch) @@ -86,7 +86,7 @@ struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch) void nvhost_putchannel(struct nvhost_channel *ch, struct nvhost_hwctx *ctx) { - BUG_ON(!channel_cdma_op(ch).stop); + BUG_ON(!channel_cdma_op().stop); if (ctx) { mutex_lock(&ch->submitlock); @@ -101,7 +101,7 @@ void nvhost_putchannel(struct nvhost_channel *ch, struct nvhost_hwctx *ctx) mutex_lock(&ch->reflock); if (ch->refcount == 1) { - channel_cdma_op(ch).stop(&ch->cdma); + channel_cdma_op().stop(&ch->cdma); nvhost_cdma_deinit(&ch->cdma); nvhost_module_suspend(ch->dev); } @@ -114,12 +114,12 @@ int nvhost_channel_suspend(struct nvhost_channel *ch) int ret = 0; mutex_lock(&ch->reflock); - BUG_ON(!channel_cdma_op(ch).stop); + BUG_ON(!channel_cdma_op().stop); if (ch->refcount) { ret = nvhost_module_suspend(ch->dev); if (!ret) - channel_cdma_op(ch).stop(&ch->cdma); + channel_cdma_op().stop(&ch->cdma); } mutex_unlock(&ch->reflock); diff --git a/drivers/video/tegra/host/nvhost_channel.h b/drivers/video/tegra/host/nvhost_channel.h index 4a67596c7cd7..fd3dcbb58e9f 100644 --- a/drivers/video/tegra/host/nvhost_channel.h +++ b/drivers/video/tegra/host/nvhost_channel.h @@ -25,10 +25,10 @@ #include <linux/io.h> #include "nvhost_cdma.h" -#define NVHOST_MAX_WAIT_CHECKS 256 -#define NVHOST_MAX_GATHERS 512 -#define NVHOST_MAX_HANDLES 1280 -#define NVHOST_MAX_POWERGATE_IDS 2 +#define NVHOST_MAX_WAIT_CHECKS 256 +#define NVHOST_MAX_GATHERS 512 +#define NVHOST_MAX_HANDLES 1280 +#define NVHOST_MAX_POWERGATE_IDS 2 struct nvhost_master; struct nvhost_waitchk; @@ -58,8 +58,7 @@ struct nvhost_channel { struct nvhost_cdma cdma; }; -int nvhost_channel_init( - struct nvhost_channel *ch, +int nvhost_channel_init(struct nvhost_channel *ch, struct nvhost_master *dev, int index); int nvhost_channel_submit(struct nvhost_job *job); @@ -68,10 +67,6 @@ struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch); void nvhost_putchannel(struct nvhost_channel *ch, struct nvhost_hwctx *ctx); int nvhost_channel_suspend(struct nvhost_channel *ch); -#define channel_cdma_op(ch) (nvhost_get_host(ch->dev)->op.cdma) -#define channel_op(ch) (nvhost_get_host(ch->dev)->op.channel) -#define host_channel_op(host) (host->op.channel) - int nvhost_channel_drain_read_fifo(void __iomem *chan_regs, u32 *ptr, unsigned int count, unsigned int *pending); diff --git a/drivers/video/tegra/host/nvhost_intr.c b/drivers/video/tegra/host/nvhost_intr.c index d1f7d69fa5f1..4f1edb2585d6 100644 --- a/drivers/video/tegra/host/nvhost_intr.c +++ b/drivers/video/tegra/host/nvhost_intr.c @@ -115,11 +115,11 @@ void reset_threshold_interrupt(struct nvhost_intr *intr, { u32 thresh = list_first_entry(head, struct nvhost_waitlist, list)->thresh; - BUG_ON(!(intr_op(intr).set_syncpt_threshold && - intr_op(intr).enable_syncpt_intr)); + BUG_ON(!(intr_op().set_syncpt_threshold && + intr_op().enable_syncpt_intr)); - intr_op(intr).set_syncpt_threshold(intr, id, thresh); - intr_op(intr).enable_syncpt_intr(intr, id); + intr_op().set_syncpt_threshold(intr, id, thresh); + intr_op().enable_syncpt_intr(intr, id); } @@ -263,8 +263,8 @@ int nvhost_intr_add_action(struct nvhost_intr *intr, u32 id, u32 thresh, BUG_ON(waiter == NULL); - BUG_ON(!(intr_op(intr).set_syncpt_threshold && - intr_op(intr).enable_syncpt_intr)); + BUG_ON(!(intr_op().set_syncpt_threshold && + intr_op().enable_syncpt_intr)); /* initialize a new waiter */ INIT_LIST_HEAD(&waiter->list); @@ -287,8 +287,8 @@ int nvhost_intr_add_action(struct nvhost_intr *intr, u32 id, u32 thresh, spin_unlock(&syncpt->lock); mutex_lock(&intr->mutex); - BUG_ON(!(intr_op(intr).request_syncpt_irq)); - err = intr_op(intr).request_syncpt_irq(syncpt); + BUG_ON(!(intr_op().request_syncpt_irq)); + err = intr_op().request_syncpt_irq(syncpt); mutex_unlock(&intr->mutex); if (err) { @@ -303,11 +303,11 @@ int nvhost_intr_add_action(struct nvhost_intr *intr, u32 id, u32 thresh, if (add_waiter_to_queue(waiter, &syncpt->wait_head)) { /* added at head of list - new threshold value */ - intr_op(intr).set_syncpt_threshold(intr, id, thresh); + intr_op().set_syncpt_threshold(intr, id, thresh); /* added as first waiter - enable interrupt */ if (queue_was_empty) - intr_op(intr).enable_syncpt_intr(intr, id); + intr_op().enable_syncpt_intr(intr, id); } spin_unlock(&syncpt->lock); @@ -373,17 +373,17 @@ void nvhost_intr_deinit(struct nvhost_intr *intr) void nvhost_intr_start(struct nvhost_intr *intr, u32 hz) { - BUG_ON(!(intr_op(intr).init_host_sync && - intr_op(intr).set_host_clocks_per_usec && - intr_op(intr).request_host_general_irq)); + BUG_ON(!(intr_op().init_host_sync && + intr_op().set_host_clocks_per_usec && + intr_op().request_host_general_irq)); mutex_lock(&intr->mutex); - intr_op(intr).init_host_sync(intr); - intr_op(intr).set_host_clocks_per_usec(intr, + intr_op().init_host_sync(intr); + intr_op().set_host_clocks_per_usec(intr, (hz + 1000000 - 1)/1000000); - intr_op(intr).request_host_general_irq(intr); + intr_op().request_host_general_irq(intr); mutex_unlock(&intr->mutex); } @@ -394,12 +394,12 @@ void nvhost_intr_stop(struct nvhost_intr *intr) struct nvhost_intr_syncpt *syncpt; u32 nb_pts = intr_to_dev(intr)->syncpt.nb_pts; - BUG_ON(!(intr_op(intr).disable_all_syncpt_intrs && - intr_op(intr).free_host_general_irq)); + BUG_ON(!(intr_op().disable_all_syncpt_intrs && + intr_op().free_host_general_irq)); mutex_lock(&intr->mutex); - intr_op(intr).disable_all_syncpt_intrs(intr); + intr_op().disable_all_syncpt_intrs(intr); for (id = 0, syncpt = intr->syncpt; id < nb_pts; @@ -421,7 +421,7 @@ void nvhost_intr_stop(struct nvhost_intr *intr) free_syncpt_irq(syncpt); } - intr_op(intr).free_host_general_irq(intr); + intr_op().free_host_general_irq(intr); mutex_unlock(&intr->mutex); } diff --git a/drivers/video/tegra/host/nvhost_intr.h b/drivers/video/tegra/host/nvhost_intr.h index 26ab04ebd4ab..eea9d837998f 100644 --- a/drivers/video/tegra/host/nvhost_intr.h +++ b/drivers/video/tegra/host/nvhost_intr.h @@ -74,7 +74,6 @@ struct nvhost_intr { bool host_general_irq_requested; }; #define intr_to_dev(x) container_of(x, struct nvhost_master, intr) -#define intr_op(intr) (intr_to_dev(intr)->op.intr) #define intr_syncpt_to_intr(is) (is->intr) /** diff --git a/drivers/video/tegra/host/nvhost_syncpt.c b/drivers/video/tegra/host/nvhost_syncpt.c index 59788084e3c2..93068ec7a4d2 100644 --- a/drivers/video/tegra/host/nvhost_syncpt.c +++ b/drivers/video/tegra/host/nvhost_syncpt.c @@ -38,12 +38,12 @@ static const char *max_name = "max"; void nvhost_syncpt_reset(struct nvhost_syncpt *sp) { u32 i; - BUG_ON(!(syncpt_op(sp).reset && syncpt_op(sp).reset_wait_base)); + BUG_ON(!(syncpt_op().reset && syncpt_op().reset_wait_base)); for (i = 0; i < sp->nb_pts; i++) - syncpt_op(sp).reset(sp, i); + syncpt_op().reset(sp, i); for (i = 0; i < sp->nb_bases; i++) - syncpt_op(sp).reset_wait_base(sp, i); + syncpt_op().reset_wait_base(sp, i); wmb(); } @@ -53,17 +53,17 @@ void nvhost_syncpt_reset(struct nvhost_syncpt *sp) void nvhost_syncpt_save(struct nvhost_syncpt *sp) { u32 i; - BUG_ON(!(syncpt_op(sp).update_min && syncpt_op(sp).read_wait_base)); + BUG_ON(!(syncpt_op().update_min && syncpt_op().read_wait_base)); for (i = 0; i < sp->nb_pts; i++) { if (client_managed(i)) - syncpt_op(sp).update_min(sp, i); + syncpt_op().update_min(sp, i); else BUG_ON(!nvhost_syncpt_min_eq_max(sp, i)); } for (i = 0; i < sp->nb_bases; i++) - syncpt_op(sp).read_wait_base(sp, i); + syncpt_op().read_wait_base(sp, i); } /** @@ -73,9 +73,9 @@ u32 nvhost_syncpt_update_min(struct nvhost_syncpt *sp, u32 id) { u32 val; - BUG_ON(!syncpt_op(sp).update_min); + BUG_ON(!syncpt_op().update_min); - val = syncpt_op(sp).update_min(sp, id); + return syncpt_op().update_min(sp, id); trace_nvhost_syncpt_update_min(id, val); return val; @@ -87,9 +87,9 @@ u32 nvhost_syncpt_update_min(struct nvhost_syncpt *sp, u32 id) u32 nvhost_syncpt_read(struct nvhost_syncpt *sp, u32 id) { u32 val; - BUG_ON(!syncpt_op(sp).update_min); + BUG_ON(!syncpt_op().update_min); nvhost_module_busy(syncpt_to_dev(sp)->dev); - val = syncpt_op(sp).update_min(sp, id); + val = syncpt_op().update_min(sp, id); nvhost_module_idle(syncpt_to_dev(sp)->dev); return val; } @@ -100,9 +100,9 @@ u32 nvhost_syncpt_read(struct nvhost_syncpt *sp, u32 id) u32 nvhost_syncpt_read_wait_base(struct nvhost_syncpt *sp, u32 id) { u32 val; - BUG_ON(!syncpt_op(sp).read_wait_base); + BUG_ON(!syncpt_op().read_wait_base); nvhost_module_busy(syncpt_to_dev(sp)->dev); - syncpt_op(sp).read_wait_base(sp, id); + syncpt_op().read_wait_base(sp, id); val = sp->base_val[id]; nvhost_module_idle(syncpt_to_dev(sp)->dev); return val; @@ -114,8 +114,8 @@ u32 nvhost_syncpt_read_wait_base(struct nvhost_syncpt *sp, u32 id) */ void nvhost_syncpt_cpu_incr(struct nvhost_syncpt *sp, u32 id) { - BUG_ON(!syncpt_op(sp).cpu_incr); - syncpt_op(sp).cpu_incr(sp, id); + BUG_ON(!syncpt_op().cpu_incr); + syncpt_op().cpu_incr(sp, id); } /** @@ -156,7 +156,7 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, nvhost_module_busy(syncpt_to_dev(sp)->dev); /* try to read from register */ - val = syncpt_op(sp).update_min(sp, id); + val = syncpt_op().update_min(sp, id); if (nvhost_syncpt_is_expired(sp, id, thresh)) { if (value) *value = val; @@ -208,9 +208,9 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, if (timeout) { dev_warn(&syncpt_to_dev(sp)->dev->dev, "%s: syncpoint id %d (%s) stuck waiting %d, timeout=%d\n", - current->comm, id, syncpt_op(sp).name(sp, id), + current->comm, id, syncpt_op().name(sp, id), thresh, timeout); - syncpt_op(sp).debug(sp); + syncpt_op().debug(sp); if (check_count > MAX_STUCK_CHECK_COUNT) { if (low_timeout) { dev_warn(&syncpt_to_dev(sp)->dev->dev, @@ -294,7 +294,7 @@ bool nvhost_syncpt_is_expired( void nvhost_syncpt_debug(struct nvhost_syncpt *sp) { - syncpt_op(sp).debug(sp); + syncpt_op().debug(sp); } int nvhost_mutex_try_lock(struct nvhost_syncpt *sp, int idx) @@ -303,7 +303,7 @@ int nvhost_mutex_try_lock(struct nvhost_syncpt *sp, int idx) u32 reg; nvhost_module_busy(host->dev); - reg = syncpt_op(sp).mutex_try_lock(sp, idx); + reg = syncpt_op().mutex_try_lock(sp, idx); if (reg) { nvhost_module_idle(host->dev); return -EBUSY; @@ -314,7 +314,7 @@ int nvhost_mutex_try_lock(struct nvhost_syncpt *sp, int idx) void nvhost_mutex_unlock(struct nvhost_syncpt *sp, int idx) { - syncpt_op(sp).mutex_unlock(sp, idx); + syncpt_op().mutex_unlock(sp, idx); nvhost_module_idle(syncpt_to_dev(sp)->dev); atomic_dec(&sp->lock_counts[idx]); } @@ -326,7 +326,7 @@ int nvhost_syncpt_wait_check(struct nvhost_syncpt *sp, struct nvhost_waitchk *wait, int num_waitchk) { - return syncpt_op(sp).wait_check(sp, nvmap, + return syncpt_op().wait_check(sp, nvmap, waitchk_mask, wait, num_waitchk); } diff --git a/drivers/video/tegra/host/nvhost_syncpt.h b/drivers/video/tegra/host/nvhost_syncpt.h index 966a49fbd92c..048eeb96ac2b 100644 --- a/drivers/video/tegra/host/nvhost_syncpt.h +++ b/drivers/video/tegra/host/nvhost_syncpt.h @@ -56,9 +56,7 @@ void nvhost_syncpt_deinit(struct nvhost_syncpt *); #define client_managed(id) (BIT(id) & sp->client_managed) #define syncpt_to_dev(sp) container_of(sp, struct nvhost_master, syncpt) -#define syncpt_op(sp) (syncpt_to_dev(sp)->op.syncpt) -#define SYNCPT_CHECK_PERIOD (2*HZ) - +#define SYNCPT_CHECK_PERIOD (2 * HZ) /** * Updates the value sent to hardware. diff --git a/drivers/video/tegra/host/t20/t20.c b/drivers/video/tegra/host/t20/t20.c index 3f90e6a837c9..02382cba50b7 100644 --- a/drivers/video/tegra/host/t20/t20.c +++ b/drivers/video/tegra/host/t20/t20.c @@ -186,13 +186,14 @@ static int t20_channel_init(struct nvhost_channel *ch, return t20_nvhost_hwctx_handler_init(ch); } -int nvhost_init_t20_channel_support(struct nvhost_master *host) +int nvhost_init_t20_channel_support(struct nvhost_master *host, + struct nvhost_chip_support *op) { host->nb_channels = NVHOST_NUMCHANNELS; - host->op.channel.init = t20_channel_init; - host->op.channel.submit = host1x_channel_submit; - host->op.channel.read3dreg = host1x_channel_read_3d_reg; + op->channel.init = t20_channel_init; + op->channel.submit = host1x_channel_submit; + op->channel.read3dreg = host1x_channel_read_3d_reg; return 0; } @@ -210,26 +211,27 @@ struct nvhost_device *t20_get_nvhost_device(struct nvhost_master *host, return NULL; } -int nvhost_init_t20_support(struct nvhost_master *host) +int nvhost_init_t20_support(struct nvhost_master *host, + struct nvhost_chip_support *op) { int err; /* don't worry about cleaning up on failure... "remove" does it. */ - err = nvhost_init_t20_channel_support(host); + err = nvhost_init_t20_channel_support(host, op); if (err) return err; - err = host1x_init_cdma_support(host); + err = host1x_init_cdma_support(op); if (err) return err; - err = nvhost_init_t20_debug_support(host); + err = nvhost_init_t20_debug_support(op); if (err) return err; - err = host1x_init_syncpt_support(host); + err = host1x_init_syncpt_support(host, op); if (err) return err; - err = nvhost_init_t20_intr_support(host); + err = nvhost_init_t20_intr_support(op); if (err) return err; - host->op.nvhost_dev.get_nvhost_device = t20_get_nvhost_device; + op->nvhost_dev.get_nvhost_device = t20_get_nvhost_device; return 0; } diff --git a/drivers/video/tegra/host/t20/t20.h b/drivers/video/tegra/host/t20/t20.h index 93555a55b589..456d3ae1bc03 100644 --- a/drivers/video/tegra/host/t20/t20.h +++ b/drivers/video/tegra/host/t20/t20.h @@ -22,12 +22,15 @@ struct nvhost_master; struct nvhost_module; +struct nvhost_chip_support; -int nvhost_init_t20_channel_support(struct nvhost_master *); -int nvhost_init_t20_debug_support(struct nvhost_master *); +int nvhost_init_t20_channel_support(struct nvhost_master *, + struct nvhost_chip_support *); +int nvhost_init_t20_debug_support(struct nvhost_chip_support *); int nvhost_init_t20_syncpt_support(struct nvhost_master *); -int nvhost_init_t20_intr_support(struct nvhost_master *); -int nvhost_init_t20_support(struct nvhost_master *host); +int nvhost_init_t20_intr_support(struct nvhost_chip_support *); +int nvhost_init_t20_support(struct nvhost_master *, + struct nvhost_chip_support *); int nvhost_t20_save_context(struct nvhost_module *mod, u32 syncpt_id); #endif /* _NVHOST_T20_H_ */ diff --git a/drivers/video/tegra/host/t30/t30.c b/drivers/video/tegra/host/t30/t30.c index 01009a708d19..6e9b0afe9e43 100644 --- a/drivers/video/tegra/host/t30/t30.c +++ b/drivers/video/tegra/host/t30/t30.c @@ -201,17 +201,18 @@ static int t30_channel_init(struct nvhost_channel *ch, return t30_nvhost_hwctx_handler_init(ch); } -int nvhost_init_t30_channel_support(struct nvhost_master *host) +int nvhost_init_t30_channel_support(struct nvhost_master *host, + struct nvhost_chip_support *op) { - int result = nvhost_init_t20_channel_support(host); - host->op.channel.init = t30_channel_init; + int result = nvhost_init_t20_channel_support(host, op); + op->channel.init = t30_channel_init; return result; } -int nvhost_init_t30_debug_support(struct nvhost_master *host) +int nvhost_init_t30_debug_support(struct nvhost_chip_support *op) { - nvhost_init_t20_debug_support(host); - host->op.debug.debug_init = nvhost_scale3d_debug_init; + nvhost_init_t20_debug_support(op); + op->debug.debug_init = nvhost_scale3d_debug_init; return 0; } @@ -229,26 +230,27 @@ struct nvhost_device *t30_get_nvhost_device(struct nvhost_master *host, return NULL; } -int nvhost_init_t30_support(struct nvhost_master *host) +int nvhost_init_t30_support(struct nvhost_master *host, + struct nvhost_chip_support *op) { int err; /* don't worry about cleaning up on failure... "remove" does it. */ - err = nvhost_init_t30_channel_support(host); + err = nvhost_init_t30_channel_support(host, op); if (err) return err; - err = host1x_init_cdma_support(host); + err = host1x_init_cdma_support(op); if (err) return err; - err = nvhost_init_t30_debug_support(host); + err = nvhost_init_t30_debug_support(op); if (err) return err; - err = host1x_init_syncpt_support(host); + err = host1x_init_syncpt_support(host, op); if (err) return err; - err = nvhost_init_t20_intr_support(host); + err = nvhost_init_t20_intr_support(op); if (err) return err; - host->op.nvhost_dev.get_nvhost_device = t30_get_nvhost_device; + op->nvhost_dev.get_nvhost_device = t30_get_nvhost_device; return 0; } diff --git a/drivers/video/tegra/host/t30/t30.h b/drivers/video/tegra/host/t30/t30.h index 0446dbd19b39..e4db97b5613d 100644 --- a/drivers/video/tegra/host/t30/t30.h +++ b/drivers/video/tegra/host/t30/t30.h @@ -21,9 +21,12 @@ #define _NVHOST_T30_H_ struct nvhost_master; +struct nvhost_chip_support; -int nvhost_init_t30_channel_support(struct nvhost_master *); -int nvhost_init_t30_debug_support(struct nvhost_master *); -int nvhost_init_t30_support(struct nvhost_master *host); +int nvhost_init_t30_channel_support(struct nvhost_master *, + struct nvhost_chip_support *); +int nvhost_init_t30_debug_support(struct nvhost_chip_support *); +int nvhost_init_t30_support(struct nvhost_master *host, + struct nvhost_chip_support *); #endif /* _NVHOST_T30_H_ */ |