video: tegra: host: Access nvhost_master via drvdata
Terje Bergstrom [Mon, 2 Jan 2012 09:14:26 +0000 (11:14 +0200)]
Use standard drvdata interface for storing and accessing nvhost_master.

Reviewed-on: http://git-master/r/72846

Change-Id: I191987c8f6d313a6ede9b59f723269cb6a197e8a
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/76815
Reviewed-by: Automatic_Commit_Validation_User

16 files changed:
drivers/media/video/tegra/nvavp/nvavp_dev.c
drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/dc_priv.h
drivers/video/tegra/dc/dsi.c
drivers/video/tegra/dc/ext/dev.c
drivers/video/tegra/host/bus.c
drivers/video/tegra/host/dev.c
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/gr3d/gr3d_t20.c
drivers/video/tegra/host/gr3d/gr3d_t30.c
drivers/video/tegra/host/host1x/host1x_channel.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/nvhost_acm.c
drivers/video/tegra/host/nvhost_cdma.h
drivers/video/tegra/host/nvhost_channel.h
include/linux/nvhost.h

index 1c27429..bf4bac9 100644 (file)
@@ -1024,7 +1024,7 @@ static int tegra_nvavp_open(struct inode *inode, struct file *filp)
 
        filp->private_data = clientctx;
 
-       nvhost_module_busy(nvavp->nvhost_dev->host->dev);
+       nvhost_module_busy(nvhost_get_host(nvavp->nvhost_dev)->dev);
        mutex_unlock(&nvavp->open_lock);
 
        return ret;
@@ -1039,7 +1039,7 @@ static int tegra_nvavp_release(struct inode *inode, struct file *filp)
        dev_dbg(&nvavp->nvhost_dev->dev, "%s: ++\n", __func__);
 
        filp->private_data = NULL;
-       nvhost_module_idle(nvavp->nvhost_dev->host->dev);
+       nvhost_module_idle(nvhost_get_host(nvavp->nvhost_dev)->dev);
 
        mutex_lock(&nvavp->open_lock);
 
@@ -1124,7 +1124,7 @@ static int tegra_nvavp_probe(struct nvhost_device *ndev)
 
        memset(nvavp, 0, sizeof(*nvavp));
 
-       nvavp->nvhost_syncpt = &ndev->host->syncpt;
+       nvavp->nvhost_syncpt = &nvhost_get_host(ndev)->syncpt;
        if (!nvavp->nvhost_syncpt) {
                dev_err(&ndev->dev, "cannot get syncpt handle\n");
                ret = -ENOENT;
index 7bbf103..951e8ca 100644 (file)
@@ -1283,7 +1283,7 @@ u32 tegra_dc_incr_syncpt_max(struct tegra_dc *dc, int i)
        u32 max;
 
        mutex_lock(&dc->lock);
-       max = nvhost_syncpt_incr_max(&dc->ndev->host->syncpt,
+       max = nvhost_syncpt_incr_max(&nvhost_get_host(dc->ndev)->syncpt,
                dc->syncpt[i].id, ((dc->enabled) ? 1 : 0));
        dc->syncpt[i].max = max;
        mutex_unlock(&dc->lock);
@@ -1297,7 +1297,8 @@ void tegra_dc_incr_syncpt_min(struct tegra_dc *dc, int i, u32 val)
        if ( dc->enabled )
                while (dc->syncpt[i].min < val) {
                        dc->syncpt[i].min++;
-                       nvhost_syncpt_cpu_incr(&dc->ndev->host->syncpt,
+                       nvhost_syncpt_cpu_incr(
+                                       &nvhost_get_host(dc->ndev)->syncpt,
                                        dc->syncpt[i].id);
                }
        mutex_unlock(&dc->lock);
@@ -2125,7 +2126,7 @@ static irqreturn_t tegra_dc_irq(int irq, void *ptr)
        unsigned long underflow_mask;
        u32 val;
 
-       if (!nvhost_module_powered(dc->ndev->host->dev)) {
+       if (!nvhost_module_powered(nvhost_get_host(dc->ndev)->dev)) {
                WARN(1, "IRQ when DC not powered!\n");
                tegra_dc_io_start(dc);
                status = tegra_dc_readl(dc, DC_CMD_INT_STATUS);
@@ -2333,7 +2334,8 @@ static void tegra_dc_init(struct tegra_dc *dc)
                dc->syncpt[i].id = syncpt;
 
                dc->syncpt[i].min = dc->syncpt[i].max =
-                       nvhost_syncpt_read(&dc->ndev->host->syncpt, syncpt);
+                       nvhost_syncpt_read(&nvhost_get_host(dc->ndev)->syncpt,
+                                       syncpt);
        }
 
        print_mode(dc, &dc->mode, __func__);
@@ -2480,7 +2482,8 @@ static void _tegra_dc_controller_disable(struct tegra_dc *dc)
                /* flush any pending syncpt waits */
                while (dc->syncpt[i].min < dc->syncpt[i].max) {
                        dc->syncpt[i].min++;
-                       nvhost_syncpt_cpu_incr(&dc->ndev->host->syncpt,
+                       nvhost_syncpt_cpu_incr(
+                               &nvhost_get_host(dc->ndev)->syncpt,
                                dc->syncpt[i].id);
                }
        }
index e516bfd..2a01a83 100644 (file)
@@ -143,25 +143,25 @@ struct tegra_dc {
 
 static inline void tegra_dc_io_start(struct tegra_dc *dc)
 {
-       nvhost_module_busy(dc->ndev->host->dev);
+       nvhost_module_busy(nvhost_get_host(dc->ndev)->dev);
 }
 
 static inline void tegra_dc_io_end(struct tegra_dc *dc)
 {
-       nvhost_module_idle(dc->ndev->host->dev);
+       nvhost_module_idle(nvhost_get_host(dc->ndev)->dev);
 }
 
 static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
                                           unsigned long reg)
 {
-       BUG_ON(!nvhost_module_powered(dc->ndev->host->dev));
+       BUG_ON(!nvhost_module_powered(nvhost_get_host(dc->ndev)->dev));
        return readl(dc->base + reg * 4);
 }
 
 static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long val,
                                   unsigned long reg)
 {
-       BUG_ON(!nvhost_module_powered(dc->ndev->host->dev));
+       BUG_ON(!nvhost_module_powered(nvhost_get_host(dc->ndev)->dev));
        writel(val, dc->base + reg * 4);
 }
 
index 5c12034..8290275 100644 (file)
@@ -303,14 +303,15 @@ static int tegra_dsi_syncpt(struct tegra_dc_dsi_data *dsi)
        ret = 0;
 
        dsi->syncpt_val = nvhost_syncpt_read(
-                       &dsi->dc->ndev->host->syncpt, dsi->syncpt_id);
+                       &nvhost_get_host(dsi->dc->ndev)->syncpt,
+                       dsi->syncpt_id);
 
        val = DSI_INCR_SYNCPT_COND(OP_DONE) |
                DSI_INCR_SYNCPT_INDX(dsi->syncpt_id);
        tegra_dsi_writel(dsi, val, DSI_INCR_SYNCPT);
 
        /* TODO: Use interrupt rather than polling */
-       ret = nvhost_syncpt_wait(&dsi->dc->ndev->host->syncpt,
+       ret = nvhost_syncpt_wait(&nvhost_get_host(dsi->dc->ndev)->syncpt,
                dsi->syncpt_id, dsi->syncpt_val + 1);
        if (ret < 0) {
                dev_err(&dsi->dc->ndev->dev, "DSI sync point failure\n");
@@ -1742,14 +1743,15 @@ static int tegra_dsi_bta(struct tegra_dc_dsi_data *dsi)
 #if DSI_USE_SYNC_POINTS
        /* FIXME: Workaround for nvhost_syncpt_read */
        dsi->syncpt_val = nvhost_syncpt_update_min(
-                       &dsi->dc->ndev->host->syncpt, dsi->syncpt_id);
+                       &nvhost_get_host(dsi->dc->ndev)->syncpt,
+                       dsi->syncpt_id);
 
        val = DSI_INCR_SYNCPT_COND(OP_DONE) |
                DSI_INCR_SYNCPT_INDX(dsi->syncpt_id);
        tegra_dsi_writel(dsi, val, DSI_INCR_SYNCPT);
 
        /* TODO: Use interrupt rather than polling */
-       err = nvhost_syncpt_wait(&dsi->dc->ndev->host->syncpt,
+       err = nvhost_syncpt_wait(&nvhost_get_host(dsi->dc->ndev)->syncpt,
                dsi->syncpt_id, dsi->syncpt_val + 1);
        if (err < 0)
                dev_err(&dsi->dc->ndev->dev,
index 2148c0b..ca4ca53 100644 (file)
@@ -224,10 +224,11 @@ static int tegra_dc_ext_set_windowattr(struct tegra_dc_ext *ext,
        win->stride_uv = flip_win->attr.stride_uv;
 
        if ((s32)flip_win->attr.pre_syncpt_id >= 0) {
-               nvhost_syncpt_wait_timeout(&ext->dc->ndev->host->syncpt,
-                                          flip_win->attr.pre_syncpt_id,
-                                          flip_win->attr.pre_syncpt_val,
-                                          msecs_to_jiffies(500), NULL);
+               nvhost_syncpt_wait_timeout(
+                               &nvhost_get_host(ext->dc->ndev)->syncpt,
+                               flip_win->attr.pre_syncpt_id,
+                               flip_win->attr.pre_syncpt_val,
+                               msecs_to_jiffies(500), NULL);
        }
 
 
index d93e446..8234d0f 100644 (file)
@@ -77,8 +77,6 @@ static int nvhost_drv_probe(struct device *_dev)
        struct nvhost_driver *drv = to_nvhost_driver(_dev->driver);
        struct nvhost_device *dev = to_nvhost_device(_dev);
 
-       dev->host = nvhost;
-
        return drv->probe(dev);
 }
 
@@ -131,8 +129,6 @@ int nvhost_device_register(struct nvhost_device *dev)
        if (!dev->dev.parent && nvhost && nvhost->dev != dev)
                dev->dev.parent = &nvhost->dev->dev;
 
-       /*  Give pointer to host1x */
-       dev->host = nvhost;
        dev->dev.bus = &nvhost_bus_type;
 
        if (dev->id != -1)
@@ -545,7 +541,6 @@ static int set_parent(struct device *dev, void *data)
        struct nvhost_master *host = data;
        if (!dev->parent && ndev != host->dev)
                dev->parent = &host->dev->dev;
-       ndev->host = host;
        return 0;
 }
 
index c7b1ebf..ea50244 100644 (file)
@@ -162,7 +162,8 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
                        goto fail;
        }
        priv->priority = NVHOST_PRIORITY_MEDIUM;
-       priv->clientid = atomic_add_return(1, &ch->dev->host->clientid);
+       priv->clientid = atomic_add_return(1,
+                       &nvhost_get_host(ch->dev)->clientid);
 
        priv->job = nvhost_job_alloc(ch, priv->hwctx, &priv->hdr,
                        NULL, priv->priority, priv->clientid);
@@ -738,14 +739,14 @@ static const struct file_operations nvhost_ctrlops = {
 
 static void power_on_host(struct nvhost_device *dev)
 {
-       struct nvhost_master *host = dev->host;
+       struct nvhost_master *host = nvhost_get_drvdata(dev);
        nvhost_intr_start(&host->intr, clk_get_rate(dev->clk[0]));
        nvhost_syncpt_reset(&host->syncpt);
 }
 
 static int power_off_host(struct nvhost_device *dev)
 {
-       struct nvhost_master *host = dev->host;
+       struct nvhost_master *host = nvhost_get_drvdata(dev);
        nvhost_syncpt_save(&host->syncpt);
        nvhost_intr_stop(&host->intr);
        return 0;
@@ -953,6 +954,9 @@ static int __devinit nvhost_probe(struct platform_device *pdev)
        host->dev = &hostdev;
        nvhost_bus_add_host(host);
 
+       /*  Give pointer to host1x via driver */
+       nvhost_set_drvdata(&hostdev, host);
+
        for (i = 0; i < host->nb_channels; i++) {
                struct nvhost_channel *ch = &host->channels[i];
                BUG_ON(!host_channel_op(host).init);
index 709d4ec..9e02ace 100644 (file)
@@ -77,7 +77,7 @@ void nvhost_3dctx_restore_end(u32 *ptr)
 struct nvhost_hwctx *nvhost_3dctx_alloc_common(struct nvhost_channel *ch,
                                        bool map_restore)
 {
-       struct nvmap_client *nvmap = ch->dev->host->nvmap;
+       struct nvmap_client *nvmap = nvhost_get_host(ch->dev)->nvmap;
        struct nvhost_hwctx *ctx;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -130,7 +130,7 @@ void nvhost_3dctx_get(struct nvhost_hwctx *ctx)
 void nvhost_3dctx_free(struct kref *ref)
 {
        struct nvhost_hwctx *ctx = container_of(ref, struct nvhost_hwctx, ref);
-       struct nvmap_client *nvmap = ctx->channel->dev->host->nvmap;
+       struct nvmap_client *nvmap = nvhost_get_host(ctx->channel->dev)->nvmap;
 
        if (ctx->restore_virt) {
                nvmap_munmap(ctx->restore, ctx->restore_virt);
index 24d7e6d..c576cf7 100644 (file)
@@ -340,7 +340,8 @@ static void ctx3d_save_service(struct nvhost_hwctx *ctx)
                        ARRAY_SIZE(ctxsave_regs_3d_global));
 
        wmb();
-       nvhost_syncpt_cpu_incr(&ctx->channel->dev->host->syncpt, NVSYNCPT_3D);
+       nvhost_syncpt_cpu_incr(&nvhost_get_host(ctx->channel->dev)->syncpt,
+                       NVSYNCPT_3D);
 }
 
 int __init nvhost_gr3d_t20_ctxhandler_init(struct nvhost_hwctx_handler *h)
@@ -350,7 +351,7 @@ int __init nvhost_gr3d_t20_ctxhandler_init(struct nvhost_hwctx_handler *h)
        u32 *save_ptr;
 
        ch = container_of(h, struct nvhost_channel, ctxhandler);
-       nvmap = ch->dev->host->nvmap;
+       nvmap = nvhost_get_host(ch->dev)->nvmap;
 
        setup_save(NULL);
 
index 1fde326..3f6a4d3 100644 (file)
@@ -385,7 +385,7 @@ int __init nvhost_gr3d_t30_ctxhandler_init(struct nvhost_hwctx_handler *h)
        u32 *save_ptr;
 
        ch = container_of(h, struct nvhost_channel, ctxhandler);
-       nvmap = ch->dev->host->nvmap;
+       nvmap = nvhost_get_host(ch->dev)->nvmap;
 
        register_sets = tegra_gpu_register_sets();
        BUG_ON(register_sets == 0 || register_sets > 2);
index 18aa2da..7d34f5d 100644 (file)
@@ -52,7 +52,7 @@ int host1x_channel_submit(struct nvhost_job *job)
 {
        struct nvhost_hwctx *hwctx_to_save = NULL;
        struct nvhost_channel *channel = job->ch;
-       struct nvhost_syncpt *sp = &job->ch->dev->host->syncpt;
+       struct nvhost_syncpt *sp = &nvhost_get_host(job->ch->dev)->syncpt;
        u32 user_syncpt_incrs = job->syncpt_incrs;
        bool need_restore = false;
        u32 syncval;
@@ -162,7 +162,7 @@ int host1x_channel_submit(struct nvhost_job *job)
        /* gather restore buffer */
        if (need_restore) {
                nvhost_cdma_push_gather(&channel->cdma,
-                       channel->dev->host->nvmap,
+                       nvhost_get_host(channel->dev)->nvmap,
                        nvmap_ref_to_handle(channel->cur_ctx->restore),
                        nvhost_opcode_gather(channel->cur_ctx->restore_size),
                        channel->cur_ctx->restore_phys);
@@ -222,7 +222,8 @@ int host1x_channel_submit(struct nvhost_job *job)
         * if necessary, and to release the restore buffer)
         */
        if (hwctx_to_save) {
-               err = nvhost_intr_add_action(&channel->dev->host->intr,
+               err = nvhost_intr_add_action(
+                       &nvhost_get_host(channel->dev)->intr,
                        job->syncpt_id,
                        syncval - job->syncpt_incrs
                                + hwctx_to_save->save_thresh,
@@ -235,7 +236,8 @@ int host1x_channel_submit(struct nvhost_job *job)
 
        if (need_restore) {
                BUG_ON(!ctxrestore_waiter);
-               err = nvhost_intr_add_action(&channel->dev->host->intr,
+               err = nvhost_intr_add_action(
+                       &nvhost_get_host(channel->dev)->intr,
                        job->syncpt_id,
                        syncval - user_syncpt_incrs,
                        NVHOST_INTR_ACTION_CTXRESTORE, channel->cur_ctx,
@@ -246,8 +248,8 @@ int host1x_channel_submit(struct nvhost_job *job)
        }
 
        /* schedule a submit complete interrupt */
-       err = nvhost_intr_add_action(&channel->dev->host->intr, job->syncpt_id,
-                       syncval,
+       err = nvhost_intr_add_action(&nvhost_get_host(channel->dev)->intr,
+                       job->syncpt_id, syncval,
                        NVHOST_INTR_ACTION_SUBMIT_COMPLETE, channel,
                        completed_waiter,
                        NULL);
@@ -293,7 +295,7 @@ int host1x_channel_read_3d_reg(
 
        job = nvhost_job_alloc(channel, hwctx,
                        NULL,
-                       channel->dev->host->nvmap, 0, 0);
+                       nvhost_get_host(channel->dev)->nvmap, 0, 0);
        if (!job) {
                err = -ENOMEM;
                goto done;
@@ -324,7 +326,7 @@ int host1x_channel_read_3d_reg(
                }
        }
 
-       syncval = nvhost_syncpt_incr_max(&channel->dev->host->syncpt,
+       syncval = nvhost_syncpt_incr_max(&nvhost_get_host(channel->dev)->syncpt,
                NVSYNCPT_3D, syncpt_incrs);
 
        job->syncpt_id = NVSYNCPT_3D;
@@ -390,7 +392,8 @@ int host1x_channel_read_3d_reg(
         * if necessary, and to release the restore buffer)
         */
        if (hwctx_to_save) {
-               err = nvhost_intr_add_action(&channel->dev->host->intr,
+               err = nvhost_intr_add_action(
+                       &nvhost_get_host(channel->dev)->intr,
                        NVSYNCPT_3D,
                        syncval - syncpt_incrs + hwctx_to_save->save_incrs - 1,
                        NVHOST_INTR_ACTION_CTXSAVE, hwctx_to_save,
@@ -401,27 +404,28 @@ int host1x_channel_read_3d_reg(
        }
 
        /* Wait for FIFO to be ready */
-       err = nvhost_intr_add_action(&channel->dev->host->intr, NVSYNCPT_3D,
-                       syncval - 2,
+       err = nvhost_intr_add_action(&nvhost_get_host(channel->dev)->intr,
+                       NVSYNCPT_3D, syncval - 2,
                        NVHOST_INTR_ACTION_WAKEUP, &wq,
                        read_waiter,
                        &ref);
        read_waiter = NULL;
        WARN(err, "Failed to set wakeup interrupt");
        wait_event(wq,
-               nvhost_syncpt_min_cmp(&channel->dev->host->syncpt,
+               nvhost_syncpt_min_cmp(&nvhost_get_host(channel->dev)->syncpt,
                                NVSYNCPT_3D, syncval - 2));
-       nvhost_intr_put_ref(&channel->dev->host->intr, ref);
+       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);
 
        /* Indicate we've read the value */
-       nvhost_syncpt_cpu_incr(&channel->dev->host->syncpt, NVSYNCPT_3D);
+       nvhost_syncpt_cpu_incr(&nvhost_get_host(channel->dev)->syncpt,
+                       NVSYNCPT_3D);
 
        /* Schedule a submit complete interrupt */
-       err = nvhost_intr_add_action(&channel->dev->host->intr,
+       err = nvhost_intr_add_action(&nvhost_get_host(channel->dev)->intr,
                        NVSYNCPT_3D, syncval,
                        NVHOST_INTR_ACTION_SUBMIT_COMPLETE, channel,
                        completed_waiter, NULL);
@@ -510,7 +514,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
 
        job = nvhost_job_alloc(ch, hwctx_to_save,
                        NULL,
-                       ch->dev->host->nvmap, 0, 0);
+                       nvhost_get_host(ch->dev)->nvmap, 0, 0);
        if (IS_ERR_OR_NULL(job)) {
                err = PTR_ERR(job);
                mutex_unlock(&ch->submitlock);
@@ -522,7 +526,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
        ch->cur_ctx = NULL;
 
        syncpt_incrs = hwctx_to_save->save_incrs;
-       syncpt_val = nvhost_syncpt_incr_max(&ch->dev->host->syncpt,
+       syncpt_val = nvhost_syncpt_incr_max(&nvhost_get_host(ch->dev)->syncpt,
                                        syncpt_id, syncpt_incrs);
 
        job->syncpt_id = syncpt_id;
@@ -540,7 +544,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
        nvhost_job_put(job);
        job = NULL;
 
-       err = nvhost_intr_add_action(&ch->dev->host->intr, syncpt_id,
+       err = nvhost_intr_add_action(&nvhost_get_host(ch->dev)->intr, syncpt_id,
                        syncpt_val - syncpt_incrs + hwctx_to_save->save_thresh,
                        NVHOST_INTR_ACTION_CTXSAVE, hwctx_to_save,
                        ctx_waiter,
@@ -548,7 +552,7 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
        ctx_waiter = NULL;
        WARN(err, "Failed to set context save interrupt");
 
-       err = nvhost_intr_add_action(&ch->dev->host->intr,
+       err = nvhost_intr_add_action(&nvhost_get_host(ch->dev)->intr,
                        syncpt_id, syncpt_val,
                        NVHOST_INTR_ACTION_WAKEUP, &wq,
                        wakeup_waiter,
@@ -556,10 +560,10 @@ int host1x_save_context(struct nvhost_device *dev, u32 syncpt_id)
        wakeup_waiter = NULL;
        WARN(err, "Failed to set wakeup interrupt");
        wait_event(wq,
-               nvhost_syncpt_min_cmp(&ch->dev->host->syncpt,
+               nvhost_syncpt_min_cmp(&nvhost_get_host(ch->dev)->syncpt,
                                syncpt_id, syncpt_val));
 
-       nvhost_intr_put_ref(&ch->dev->host->intr, ref);
+       nvhost_intr_put_ref(&nvhost_get_host(ch->dev)->intr, ref);
 
        nvhost_cdma_update(&ch->cdma);
 
index 5d49722..471702e 100644 (file)
@@ -439,7 +439,7 @@ static u32 *save_ram(u32 *ptr, unsigned int *pending,
 
 static struct nvhost_hwctx *ctxmpe_alloc(struct nvhost_channel *ch)
 {
-       struct nvmap_client *nvmap = ch->dev->host->nvmap;
+       struct nvmap_client *nvmap = nvhost_get_host(ch->dev)->nvmap;
        struct nvhost_hwctx *ctx;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -482,7 +482,7 @@ static void ctxmpe_get(struct nvhost_hwctx *ctx)
 static void ctxmpe_free(struct kref *ref)
 {
        struct nvhost_hwctx *ctx = container_of(ref, struct nvhost_hwctx, ref);
-       struct nvmap_client *nvmap = ctx->channel->dev->host->nvmap;
+       struct nvmap_client *nvmap = nvhost_get_host(ctx->channel->dev)->nvmap;
 
        if (ctx->restore_virt)
                nvmap_munmap(ctx->restore, ctx->restore_virt);
@@ -522,7 +522,8 @@ static void ctxmpe_save_service(struct nvhost_hwctx *ctx)
                IRFR_RAM_SIZE, IRFR_RAM_READ_CMD, IRFR_RAM_READ_DATA);
 
        wmb();
-       nvhost_syncpt_cpu_incr(&ctx->channel->dev->host->syncpt, NVSYNCPT_MPE);
+       nvhost_syncpt_cpu_incr(&nvhost_get_host(ctx->channel->dev)->syncpt,
+                       NVSYNCPT_MPE);
 }
 
 int __init nvhost_mpe_ctxhandler_init(struct nvhost_hwctx_handler *h)
@@ -532,7 +533,7 @@ int __init nvhost_mpe_ctxhandler_init(struct nvhost_hwctx_handler *h)
        u32 *save_ptr;
 
        ch = container_of(h, struct nvhost_channel, ctxhandler);
-       nvmap = ch->dev->host->nvmap;
+       nvmap = nvhost_get_host(ch->dev)->nvmap;
 
        setup_save(NULL);
 
index 7a0108a..8d44d87 100644 (file)
@@ -441,15 +441,10 @@ static void debug_not_idle(struct nvhost_master *host)
 int nvhost_module_suspend(struct nvhost_device *dev, bool system_suspend)
 {
        int ret;
-       struct nvhost_master *host;
+       struct nvhost_master *host = nvhost_get_host(dev);
 
-       if (system_suspend) {
-               host = dev->host;
-               if (!is_module_idle(dev))
-                       debug_not_idle(host);
-       } else {
-               host = dev->host;
-       }
+       if (system_suspend && !is_module_idle(dev))
+               debug_not_idle(host);
 
        ret = wait_event_timeout(dev->idle_wq, is_module_idle(dev),
                        ACM_SUSPEND_WAIT_FOR_IDLE_TIMEOUT);
index 39142ca..a5ef8da 100644 (file)
@@ -108,7 +108,7 @@ struct nvhost_cdma {
 };
 
 #define cdma_to_channel(cdma) container_of(cdma, struct nvhost_channel, cdma)
-#define cdma_to_dev(cdma) ((cdma_to_channel(cdma))->dev->host)
+#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)
index f6c22ca..251fa94 100644 (file)
@@ -72,8 +72,8 @@ 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) (ch->dev->host->op.cdma)
-#define channel_op(ch) (ch->dev->host->op.channel)
+#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,
index 6b3c9e3..7039fb0 100644 (file)
@@ -52,7 +52,6 @@ struct nvhost_device {
        u32             num_resources;  /* Number of resources following */
        struct resource *resource;      /* Resources (IOMEM in particular) */
 
-       struct nvhost_master *host;     /* Access to host1x resources */
        u32             syncpts;        /* Bitfield of sync points used */
        u32             waitbases;      /* Bit field of wait bases */
        u32             modulemutexes;  /* Bit field of module mutexes */
@@ -125,6 +124,8 @@ extern int nvhost_get_irq_byname(struct nvhost_device *, const char *);
 
 #define nvhost_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
 #define nvhost_set_drvdata(_dev, data) dev_set_drvdata(&(_dev)->dev, (data))
+#define nvhost_get_host(_dev) ((struct nvhost_master *) \
+               dev_get_drvdata((_dev)->dev.parent))
 
 int nvhost_bus_add_host(struct nvhost_master *host);