video: tegra: host: fixup gk20a device references
Ken Adams [Sat, 29 Jun 2013 22:23:41 +0000 (18:23 -0400)]
Check on pdata instead of checking for platform device
to determine if the module is gk20a.  We can get a different
platform device if DT is enabled.

Bug 1316106

Change-Id: I277a464e16ebbcada975d0363733088df91784bf
Signed-off-by: Ken Adams <kadams@nvidia.com>
Reviewed-on: http://git-master/r/243700
Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Tested-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-by: Chao Xu <cxu@nvidia.com>

drivers/video/tegra/host/gk20a/gk20a.c
drivers/video/tegra/host/gk20a/gk20a.h
drivers/video/tegra/host/t124/as_t124.c
drivers/video/tegra/host/t124/cdma_t124.c
drivers/video/tegra/host/t124/debug_t124.c
drivers/video/tegra/host/t124/t124.c

index 7f10a63..da468dd 100644 (file)
@@ -97,7 +97,7 @@ static const struct file_operations gk20a_ctrl_ops = {
        .unlocked_ioctl = gk20a_ctrl_dev_ioctl,
 };
 
-static struct nvhost_device_data tegra_gk20a_info = {
+struct nvhost_device_data tegra_gk20a_info = {
        /* the following are set by the platform (e.g. t124) support
        .syncpts       = BIT(NVSYNCPT_3D),
        .waitbases     = BIT(NVWAITBASE_3D),
index 2a70df3..7250e09 100644 (file)
@@ -47,6 +47,12 @@ struct sim_gk20a;
 #include "../../../../../../arch/arm/mach-tegra/iomap.h"
 
 extern struct platform_device tegra_gk20a_device;
+extern struct nvhost_device_data tegra_gk20a_info;
+
+static inline bool is_gk20a_module(struct platform_device *dev)
+{
+       return &tegra_gk20a_info == nvhost_get_devdata(dev);
+}
 
 struct cooling_device_gk20a {
        struct thermal_cooling_device *gk20a_cooling_dev;
index 39ed6bf..b0bbc47 100644 (file)
@@ -26,8 +26,9 @@
 
 static int t124_as_init(struct nvhost_master *host, struct nvhost_as *as)
 {
+       struct nvhost_device_data *pdata = nvhost_get_devdata(as->ch->dev);
 #if defined(CONFIG_TEGRA_GK20A)
-       if (as->ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(as->ch->dev))
                as->ops = &gk20a_as_moduleops;
 #endif
        return 0;
index 06ad71b..de14291 100644 (file)
 
 #include "host1x/host1x_cdma.c"
 
+static inline bool is_cdma_gk20a_module(struct nvhost_cdma *cdma)
+{
+       return is_gk20a_module(cdma_to_channel(cdma)->dev);
+}
+
 static void t124_push_buffer_reset(struct push_buffer *pb)
 {
 #if defined(CONFIG_TEGRA_GK20A)
@@ -39,7 +44,7 @@ static void t124_push_buffer_reset(struct push_buffer *pb)
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_push_buffer_reset(pb);
        else
 #endif
@@ -57,7 +62,7 @@ static int t124_push_buffer_init(struct push_buffer *pb)
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                return gk20a_push_buffer_init(pb);
        else
 #endif
@@ -75,7 +80,7 @@ static void t124_push_buffer_destroy(struct push_buffer *pb)
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_push_buffer_destroy(pb);
        else
 #endif
@@ -96,7 +101,7 @@ static void t124_push_buffer_push_to(struct push_buffer *pb,
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_push_buffer_push_to(pb, client, handle, op1, op2);
        else
 #endif
@@ -115,7 +120,7 @@ static void t124_push_buffer_pop_from(struct push_buffer *pb, unsigned int slots
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_push_buffer_pop_from(pb, slots);
        else
 #endif
@@ -133,7 +138,7 @@ static u32 t124_push_buffer_space(struct push_buffer *pb)
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                return gk20a_push_buffer_space(pb);
        else
 #endif
@@ -148,7 +153,7 @@ static u32 t124_push_buffer_putptr(struct push_buffer *pb)
 
        nvhost_dbg_fn("");
 
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                return gk20a_push_buffer_putptr(pb);
        else
 #endif
@@ -171,7 +176,7 @@ static int t124_cdma_timeout_init(struct nvhost_cdma *cdma,
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                return -EINVAL; /*XXX gk20a_cdma_timeout_init(cdma, syncpt_id);*/
        else
 #endif
@@ -182,7 +187,7 @@ static void t124_cdma_timeout_destroy(struct nvhost_cdma *cdma)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                return; /*XXX gk20a_cdma_timeout_destroy(cdma);*/
        else
 #endif
@@ -194,7 +199,7 @@ void t124_cdma_timeout_teardown_begin(struct nvhost_cdma *cdma)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                return; /*XXX gk20a_cdma_teardown_begin(cdma);*/
        else
 #endif
@@ -206,7 +211,7 @@ void t124_cdma_timeout_teardown_end(struct nvhost_cdma *cdma, u32 getptr)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                return; /*XXX gk20a_cdma_teardown_end(cdma, getptr);*/
        else
 #endif
@@ -221,7 +226,7 @@ static void t124_cdma_start(struct nvhost_cdma *cdma)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                gk20a_cdma_start(cdma);
        else
 #endif
@@ -236,7 +241,7 @@ static void t124_cdma_kick(struct nvhost_cdma *cdma)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                gk20a_cdma_kick(cdma);
        else
 #endif
@@ -248,7 +253,7 @@ static void t124_cdma_stop(struct nvhost_cdma *cdma)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (cdma_to_channel(cdma)->dev == &tegra_gk20a_device)
+       if (is_cdma_gk20a_module(cdma))
                gk20a_cdma_stop(cdma);
        else
 #endif
index bbb65d6..59b5808 100644 (file)
@@ -40,7 +40,7 @@ static void t124_debug_show_channel_cdma(struct nvhost_master *m,
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_debug_show_channel_cdma(m, ch, o, chid);
        else
 #endif
@@ -53,7 +53,7 @@ void t124_debug_show_channel_fifo(struct nvhost_master *m,
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(ch->dev))
                gk20a_debug_show_channel_fifo(m, ch, o, chid);
        else
 #endif
index c9e6cf2..dd3e23d 100644 (file)
@@ -376,7 +376,7 @@ static int t124_channel_submit(struct nvhost_job *job)
        nvhost_dbg_fn("");
 
 #if defined(CONFIG_TEGRA_GK20A)
-       if (job->ch->dev == &tegra_gk20a_device)
+       if (is_gk20a_module(job->ch->dev))
                return -ENODEV; /* makes no sense/shouldn't happen */
        else
 #endif
@@ -508,7 +508,7 @@ int nvhost_init_t124_channel_support(struct nvhost_master *host,
                }
 #endif
 #if defined(CONFIG_TEGRA_GK20A)
-               if (dev == &tegra_gk20a_device) {
+               if (is_gk20a_module(dev)) {
                        pdata->syncpts[0]       = NVSYNCPT_3D;
                        pdata->waitbases[0]     = NVWAITBASE_3D;
                        pdata->modulemutexes[0] = NVMODMUTEX_3D;