summaryrefslogtreecommitdiff
path: root/drivers/video
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2012-06-15 07:43:07 +0300
committerSimone Willett <swillett@nvidia.com>2012-06-18 18:52:39 -0700
commit4624dd8bed05435978ae4381cbcfc0382726941c (patch)
tree776eadb190e03ebddd5e272360338eb40bf7b828 /drivers/video
parent9923fdb793c254e9787cdae56cc0c4e4529f3c52 (diff)
video: tegra: host: Use chip_ops for save context
Call drain fifo and save context functions via nvhost_chip_support. Earlier client drivers called into host1x code directly, which makes each client driver SoC specific. Change-Id: I4f805abad21012e59e11bf6a98fa46441c71c51a Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/109101 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com> Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com> Reviewed-by: Ken Adams <kadams@nvidia.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/tegra/host/chip_support.h4
-rw-r--r--drivers/video/tegra/host/gr3d/gr3d.c8
-rw-r--r--drivers/video/tegra/host/gr3d/gr3d_t20.c6
-rw-r--r--drivers/video/tegra/host/host1x/host1x_channel.c12
-rw-r--r--drivers/video/tegra/host/host1x/host1x_channel.h4
-rw-r--r--drivers/video/tegra/host/mpe/mpe.c16
-rw-r--r--drivers/video/tegra/host/nvhost_channel.c17
-rw-r--r--drivers/video/tegra/host/nvhost_channel.h4
-rw-r--r--drivers/video/tegra/host/t20/t20.c2
9 files changed, 44 insertions, 29 deletions
diff --git a/drivers/video/tegra/host/chip_support.h b/drivers/video/tegra/host/chip_support.h
index c6860e611550..5bc0c9f63e1d 100644
--- a/drivers/video/tegra/host/chip_support.h
+++ b/drivers/video/tegra/host/chip_support.h
@@ -52,6 +52,10 @@ struct nvhost_chip_support {
struct nvhost_hwctx *hwctx,
u32 offset,
u32 *value);
+ int (*save_context)(struct nvhost_channel *channel);
+ int (*drain_read_fifo)(struct nvhost_channel *ch,
+ u32 *ptr, unsigned int count,
+ unsigned int *pending);
} channel;
struct {
diff --git a/drivers/video/tegra/host/gr3d/gr3d.c b/drivers/video/tegra/host/gr3d/gr3d.c
index 5338ce9edb7a..3cc041d3b3bb 100644
--- a/drivers/video/tegra/host/gr3d/gr3d.c
+++ b/drivers/video/tegra/host/gr3d/gr3d.c
@@ -147,13 +147,7 @@ void nvhost_3dctx_put(struct nvhost_hwctx *ctx)
int nvhost_gr3d_prepare_power_off(struct nvhost_device *dev)
{
- struct nvhost_hwctx *cur_ctx = dev->channel->cur_ctx;
- int err = 0;
- if (cur_ctx)
- err = host1x_save_context(dev,
- to_host1x_hwctx_handler(cur_ctx->h)->syncpt);
-
- return err;
+ return nvhost_channel_save_context(dev->channel);
}
enum gr3d_ip_ver {
diff --git a/drivers/video/tegra/host/gr3d/gr3d_t20.c b/drivers/video/tegra/host/gr3d/gr3d_t20.c
index 88bb2be6b8a9..23cd1557c420 100644
--- a/drivers/video/tegra/host/gr3d/gr3d_t20.c
+++ b/drivers/video/tegra/host/gr3d/gr3d_t20.c
@@ -200,7 +200,7 @@ static void __init save_end_v0(struct host1x_hwctx_handler *h, u32 *ptr)
}
static u32 *save_regs_v0(u32 *ptr, unsigned int *pending,
- void __iomem *chan_regs,
+ struct nvhost_channel *ch,
const struct hwctx_reginfo *regs,
unsigned int nr_regs)
{
@@ -218,7 +218,7 @@ static u32 *save_regs_v0(u32 *ptr, unsigned int *pending,
ptr += RESTORE_INDIRECT_SIZE;
break;
}
- drain_result = host1x_drain_read_fifo(chan_regs,
+ drain_result = nvhost_channel_drain_read_fifo(ch,
ptr, count, pending);
BUG_ON(drain_result < 0);
ptr += count;
@@ -344,7 +344,7 @@ static void ctx3d_save_service(struct nvhost_hwctx *nctx)
u32 *ptr = (u32 *)ctx->restore_virt + RESTORE_BEGIN_SIZE;
unsigned int pending = 0;
- ptr = save_regs_v0(ptr, &pending, nctx->channel->aperture,
+ ptr = save_regs_v0(ptr, &pending, nctx->channel,
ctxsave_regs_3d_global,
ARRAY_SIZE(ctxsave_regs_3d_global));
diff --git a/drivers/video/tegra/host/host1x/host1x_channel.c b/drivers/video/tegra/host/host1x/host1x_channel.c
index 03ba72ca46a0..09f022b0f94d 100644
--- a/drivers/video/tegra/host/host1x/host1x_channel.c
+++ b/drivers/video/tegra/host/host1x/host1x_channel.c
@@ -461,8 +461,7 @@ int host1x_channel_read_3d_reg(
nvhost_intr_put_ref(&nvhost_get_host(channel->dev)->intr, ref);
/* Read the register value from FIFO */
- err = host1x_drain_read_fifo(channel->aperture,
- value, 1, &pending);
+ err = host1x_drain_read_fifo(channel, value, 1, &pending);
/* Indicate we've read the value */
nvhost_syncpt_cpu_incr(&nvhost_get_host(channel->dev)->syncpt,
@@ -486,11 +485,12 @@ done:
}
-int host1x_drain_read_fifo(void __iomem *chan_regs,
+int host1x_drain_read_fifo(struct nvhost_channel *ch,
u32 *ptr, unsigned int count, unsigned int *pending)
{
unsigned int entries = *pending;
unsigned long timeout = jiffies + NV_FIFO_READ_TIMEOUT;
+ void __iomem *chan_regs = ch->aperture;
while (count) {
unsigned int num;
@@ -528,9 +528,9 @@ int host1x_drain_read_fifo(void __iomem *chan_regs,
return 0;
}
-int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
+int host1x_save_context(struct nvhost_channel *ch)
{
- struct nvhost_channel *ch = dev->channel;
+ struct nvhost_device *dev = ch->dev;
struct nvhost_hwctx *hwctx_to_save;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
u32 syncpt_incrs, syncpt_val;
@@ -539,6 +539,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
void *ctx_waiter = NULL, *wakeup_waiter = NULL;
struct nvhost_job *job;
struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+ u32 syncpt_id;
ctx_waiter = nvhost_intr_alloc_waiter();
wakeup_waiter = nvhost_intr_alloc_waiter();
@@ -569,6 +570,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
hwctx_to_save->valid = true;
ch->ctxhandler->get(hwctx_to_save);
ch->cur_ctx = NULL;
+ syncpt_id = to_host1x_hwctx_handler(hwctx_to_save->h)->syncpt;
syncpt_incrs = to_host1x_hwctx(hwctx_to_save)->save_incrs;
syncpt_val = nvhost_syncpt_incr_max(&nvhost_get_host(ch->dev)->syncpt,
diff --git a/drivers/video/tegra/host/host1x/host1x_channel.h b/drivers/video/tegra/host/host1x/host1x_channel.h
index 4113dbcada20..98a67c7985ab 100644
--- a/drivers/video/tegra/host/host1x/host1x_channel.h
+++ b/drivers/video/tegra/host/host1x/host1x_channel.h
@@ -37,9 +37,9 @@ int host1x_channel_read_3d_reg(
u32 *value);
/* Reads words from FIFO */
-int host1x_drain_read_fifo(void __iomem *chan_regs,
+int host1x_drain_read_fifo(struct nvhost_channel *ch,
u32 *ptr, unsigned int count, unsigned int *pending);
-int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id);
+int host1x_save_context(struct nvhost_channel *ch);
#endif
diff --git a/drivers/video/tegra/host/mpe/mpe.c b/drivers/video/tegra/host/mpe/mpe.c
index 9f9055311b35..7b76393de6c6 100644
--- a/drivers/video/tegra/host/mpe/mpe.c
+++ b/drivers/video/tegra/host/mpe/mpe.c
@@ -396,7 +396,7 @@ static u32 *save_regs(u32 *ptr, unsigned int *pending,
u32 count = regs->count;
++ptr; /* restore incr */
if (regs->type == HWCTX_REGINFO_NORMAL) {
- host1x_drain_read_fifo(channel->aperture,
+ nvhost_channel_drain_read_fifo(channel,
ptr, count, pending);
ptr += count;
} else {
@@ -405,8 +405,8 @@ static u32 *save_regs(u32 *ptr, unsigned int *pending,
BUG_ON(msi->out_pos >= NR_WRITEBACKS);
word = msi->out[msi->out_pos++];
} else {
- host1x_drain_read_fifo(channel->aperture,
- &word, 1, pending);
+ nvhost_channel_drain_read_fifo(channel,
+ &word, 1, pending);
if (regs->type == HWCTX_REGINFO_STASH) {
BUG_ON(msi->in_pos >= NR_STASHES);
msi->in[msi->in_pos++] = word;
@@ -426,7 +426,7 @@ static u32 *save_ram(u32 *ptr, unsigned int *pending,
{
int err = 0;
ptr += RESTORE_RAM_SIZE;
- err = host1x_drain_read_fifo(channel->aperture, ptr, words, pending);
+ err = nvhost_channel_drain_read_fifo(channel, ptr, words, pending);
WARN_ON(err);
return ptr + words;
}
@@ -583,13 +583,7 @@ struct nvhost_hwctx_handler *nvhost_mpe_ctxhandler_init(u32 syncpt,
int nvhost_mpe_prepare_power_off(struct nvhost_device *dev)
{
- struct nvhost_hwctx *cur_ctx = dev->channel->cur_ctx;
- int err = 0;
- if (cur_ctx)
- err = host1x_save_context(dev,
- to_host1x_hwctx_handler(cur_ctx->h)->syncpt);
-
- return err;
+ return nvhost_channel_save_context(dev->channel);
}
enum mpe_ip_ver {
diff --git a/drivers/video/tegra/host/nvhost_channel.c b/drivers/video/tegra/host/nvhost_channel.c
index ad303cf0a22d..fd309ee9917b 100644
--- a/drivers/video/tegra/host/nvhost_channel.c
+++ b/drivers/video/tegra/host/nvhost_channel.c
@@ -169,3 +169,20 @@ void nvhost_free_channel_internal(struct nvhost_channel *ch,
kfree(ch);
(*current_channel_count)--;
}
+
+int nvhost_channel_save_context(struct nvhost_channel *ch)
+{
+ struct nvhost_hwctx *cur_ctx = ch->cur_ctx;
+ int err = 0;
+ if (cur_ctx)
+ err = channel_op().save_context(ch);
+
+ return err;
+
+}
+
+int nvhost_channel_drain_read_fifo(struct nvhost_channel *ch,
+ u32 *ptr, unsigned int count, unsigned int *pending)
+{
+ return channel_op().drain_read_fifo(ch, ptr, count, pending);
+}
diff --git a/drivers/video/tegra/host/nvhost_channel.h b/drivers/video/tegra/host/nvhost_channel.h
index b3a904d5a3ee..d7f096db1ffa 100644
--- a/drivers/video/tegra/host/nvhost_channel.h
+++ b/drivers/video/tegra/host/nvhost_channel.h
@@ -59,7 +59,7 @@ 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);
-int nvhost_channel_drain_read_fifo(void __iomem *chan_regs,
+int nvhost_channel_drain_read_fifo(struct nvhost_channel *ch,
u32 *ptr, unsigned int count, unsigned int *pending);
int nvhost_channel_read_3d_reg(struct nvhost_channel *channel,
@@ -72,4 +72,6 @@ struct nvhost_channel *nvhost_alloc_channel_internal(int chindex,
void nvhost_free_channel_internal(struct nvhost_channel *ch,
int *current_channel_count);
+int nvhost_channel_save_context(struct nvhost_channel *ch);
+
#endif
diff --git a/drivers/video/tegra/host/t20/t20.c b/drivers/video/tegra/host/t20/t20.c
index 93e73e501ce0..1f8f14394b67 100644
--- a/drivers/video/tegra/host/t20/t20.c
+++ b/drivers/video/tegra/host/t20/t20.c
@@ -294,6 +294,8 @@ int nvhost_init_t20_channel_support(struct nvhost_master *host,
op->channel.init = t20_channel_init;
op->channel.submit = host1x_channel_submit;
op->channel.read3dreg = host1x_channel_read_3d_reg;
+ op->channel.save_context = host1x_save_context;
+ op->channel.drain_read_fifo = host1x_drain_read_fifo;
return 0;
}