]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: gk20a: Use public host APIs
authorArto Merilainen <amerilainen@nvidia.com>
Thu, 13 Mar 2014 07:39:26 +0000 (09:39 +0200)
committerArto Merilainen <amerilainen@nvidia.com>
Tue, 25 Mar 2014 12:40:00 +0000 (05:40 -0700)
This patch modifies the gk20a driver to use public nvhost APIs.

Change-Id: Ide150d5b69189c30fbdbabc9e3071d2f68aea483
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/381422
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/gk20a/channel_gk20a.c
drivers/video/tegra/host/gk20a/channel_sync_gk20a.c
drivers/video/tegra/host/gk20a/platform_gk20a_tegra.c

index 74625a69067701871b38527f8447418efe10dab3..3c9900dd8b2e47914765d5fe9afb8251773462a1 100644 (file)
@@ -19,6 +19,7 @@
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <linux/nvhost.h>
 #include <linux/list.h>
 #include <linux/delay.h>
 #include <linux/highmem.h> /* need for nvmap.h*/
@@ -28,7 +29,6 @@
 #include <linux/anon_inodes.h>
 #include <linux/dma-buf.h>
 
-#include "dev.h"
 #include "debug_gk20a.h"
 
 #include "gk20a.h"
@@ -39,7 +39,6 @@
 #include "hw_pbdma_gk20a.h"
 #include "hw_ccsr_gk20a.h"
 #include "hw_ltc_gk20a.h"
-#include "chip_support.h"
 
 #define NVMAP_HANDLE_PARAM_SIZE 1
 
@@ -70,12 +69,6 @@ static int channel_gk20a_update_runlist(struct channel_gk20a *c,
                                        bool add);
 static void gk20a_free_error_notifiers(struct channel_gk20a *ch);
 
-static inline
-struct nvhost_master *host_from_gk20a_channel(struct channel_gk20a *ch)
-{
-       return nvhost_get_host(ch->g->dev);
-}
-
 static struct channel_gk20a *acquire_unused_channel(struct fifo_gk20a *f)
 {
        struct channel_gk20a *ch = NULL;
index 4a31f0d38eed24cd6170937d5ce891acdcb00a9b..9f9c3ba7ac71cdcc42f3261b79a3576f626473e5 100644 (file)
@@ -15,6 +15,8 @@
  * more details.
  */
 
+#include <linux/gk20a.h>
+
 #include "channel_sync_gk20a.h"
 #include "gk20a.h"
 
 #endif
 
 #ifdef CONFIG_TEGRA_GK20A
-#include "nvhost_sync.h"
-#include "nvhost_syncpt.h"
+#include <linux/nvhost.h>
 #endif
 
 #ifdef CONFIG_TEGRA_GK20A
 
 struct gk20a_channel_syncpt {
        struct gk20a_channel_sync ops;
-       struct nvhost_syncpt *sp;
        struct channel_gk20a *c;
+       struct platform_device *host1x_pdev;
        u32 id;
 };
 
@@ -56,9 +57,9 @@ int gk20a_channel_syncpt_wait_cpu(struct gk20a_channel_sync *s,
                container_of(s, struct gk20a_channel_syncpt, ops);
        if (!fence->valid)
                return 0;
-       return nvhost_syncpt_wait_timeout(
-                       sp->sp, sp->id, fence->thresh,
-                       timeout, NULL, NULL, false);
+       return nvhost_syncpt_wait_timeout_ext(
+                       sp->host1x_pdev, sp->id, fence->thresh,
+                       timeout, NULL, NULL);
 }
 
 bool gk20a_channel_syncpt_is_expired(struct gk20a_channel_sync *s,
@@ -68,7 +69,8 @@ bool gk20a_channel_syncpt_is_expired(struct gk20a_channel_sync *s,
                container_of(s, struct gk20a_channel_syncpt, ops);
        if (!fence->valid)
                return true;
-       return nvhost_syncpt_is_expired(sp->sp, sp->id, fence->thresh);
+       return nvhost_syncpt_is_expired_ext(sp->host1x_pdev, sp->id,
+                       fence->thresh);
 }
 
 int gk20a_channel_syncpt_wait_syncpt(struct gk20a_channel_sync *s, u32 id,
@@ -78,13 +80,13 @@ int gk20a_channel_syncpt_wait_syncpt(struct gk20a_channel_sync *s, u32 id,
                container_of(s, struct gk20a_channel_syncpt, ops);
        struct priv_cmd_entry *wait_cmd = NULL;
 
-       if (id >= nvhost_syncpt_nb_pts(sp->sp)) {
+       if (id >= nvhost_syncpt_nb_pts_ext(sp->host1x_pdev)) {
                dev_warn(dev_from_gk20a(sp->c->g),
                                "invalid wait id in gpfifo submit, elided");
                return 0;
        }
 
-       if (nvhost_syncpt_is_expired(sp->sp, id, thresh))
+       if (nvhost_syncpt_is_expired_ext(sp->host1x_pdev, id, thresh))
                return 0;
 
        gk20a_channel_alloc_priv_cmdbuf(sp->c, 4, &wait_cmd);
@@ -131,7 +133,8 @@ int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
                u32 wait_id = nvhost_sync_pt_id(pt);
                u32 wait_value = nvhost_sync_pt_thresh(pt);
 
-               if (nvhost_syncpt_is_expired(sp->sp, wait_id, wait_value)) {
+               if (nvhost_syncpt_is_expired_ext(sp->host1x_pdev,
+                               wait_id, wait_value)) {
                        wait_cmd->ptr[i * 4 + 0] = 0;
                        wait_cmd->ptr[i * 4 + 1] = 0;
                        wait_cmd->ptr[i * 4 + 2] = 0;
@@ -151,6 +154,12 @@ int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
 #endif
 }
 
+static void gk20a_channel_syncpt_update(void *priv, int nr_completed)
+{
+       struct channel_gk20a *ch20a = priv;
+       gk20a_channel_update(ch20a, nr_completed);
+}
+
 static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
                                       bool gfx_class, bool wfi_cmd,
                                       struct priv_cmd_entry **entry,
@@ -160,22 +169,15 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
        int incr_cmd_size;
        int j = 0;
        int err;
-       void *completed_waiter;
        struct priv_cmd_entry *incr_cmd = NULL;
        struct gk20a_channel_syncpt *sp =
                container_of(s, struct gk20a_channel_syncpt, ops);
        struct channel_gk20a *c = sp->c;
 
-       completed_waiter = nvhost_intr_alloc_waiter();
-       if (!completed_waiter)
-               return -ENOMEM;
-
        /* nvhost action_gpfifo_submit_complete releases this ref. */
        err = gk20a_channel_busy(c->g->dev);
-       if (err) {
-               kfree(completed_waiter);
+       if (err)
                return err;
-       }
 
        incr_cmd_size = 4;
        if (wfi_cmd)
@@ -184,7 +186,6 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
        gk20a_channel_alloc_priv_cmdbuf(c, incr_cmd_size, &incr_cmd);
        if (incr_cmd == NULL) {
                gk20a_channel_idle(c->g->dev);
-               kfree(completed_waiter);
                gk20a_err(dev_from_gk20a(c->g),
                                "not enough priv cmd buffer space");
                return -EAGAIN;
@@ -217,22 +218,16 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
        }
        WARN_ON(j != incr_cmd_size);
 
-       thresh = nvhost_syncpt_incr_max(sp->sp, sp->id, 1);
+       thresh = nvhost_syncpt_incr_max_ext(sp->host1x_pdev, sp->id, 1);
 
-       err = nvhost_intr_add_action(
-               &nvhost_get_host(c->g->dev)->intr,
-               sp->id, thresh,
-               NVHOST_INTR_ACTION_GPFIFO_SUBMIT_COMPLETE,
-               c,
-               completed_waiter,
-               NULL);
+       err = nvhost_intr_register_notifier(sp->host1x_pdev, sp->id, thresh,
+                       gk20a_channel_syncpt_update, c);
 
        /* Adding interrupt action should never fail. A proper error handling
         * here would require us to decrement the syncpt max back to its
         * original value. */
        if (WARN(err, "failed to set submit complete interrupt")) {
                gk20a_channel_idle(c->g->dev);
-               kfree(completed_waiter);
                err = 0; /* Ignore this error. */
        }
 
@@ -301,7 +296,8 @@ int gk20a_channel_syncpt_incr_user_fd(struct gk20a_channel_sync *s,
                                                    &pt.id, &pt.thresh);
        if (err)
                return err;
-       return nvhost_sync_create_fence_fd(sp->c->g->dev, &pt, 1, "fence", fd);
+       return nvhost_sync_create_fence_fd(sp->host1x_pdev, &pt, 1,
+                                          "fence", fd);
 #else
        return -ENODEV;
 #endif
@@ -311,7 +307,7 @@ void gk20a_channel_syncpt_set_min_eq_max(struct gk20a_channel_sync *s)
 {
        struct gk20a_channel_syncpt *sp =
                container_of(s, struct gk20a_channel_syncpt, ops);
-       nvhost_syncpt_set_min_eq_max(sp->sp, sp->id);
+       nvhost_syncpt_set_min_eq_max_ext(sp->host1x_pdev, sp->id);
 }
 
 static void gk20a_channel_syncpt_destroy(struct gk20a_channel_sync *s)
@@ -331,9 +327,9 @@ gk20a_channel_syncpt_create(struct channel_gk20a *c)
        if (!sp)
                return NULL;
 
-       sp->sp = &nvhost_get_host(c->g->dev)->syncpt;
        sp->c = c;
-       sp->id = nvhost_get_syncpt_host_managed(c->g->dev, c->hw_chid);
+       sp->host1x_pdev = to_platform_device(c->g->dev->dev.parent);
+       sp->id = nvhost_get_syncpt_host_managed(sp->host1x_pdev, c->hw_chid);
 
        sp->ops.wait_cpu                = gk20a_channel_syncpt_wait_cpu;
        sp->ops.is_expired              = gk20a_channel_syncpt_is_expired;
index cdf5c4668b8a10caeb9bd918a620b048e995b5e7..ed149c8fc3c23610a87c7bff3b0ec969e600065f 100644 (file)
@@ -111,8 +111,9 @@ static int gk20a_tegra_channel_busy(struct platform_device *dev)
         * OS-Idle-Display-ON case
         * - The code below fixes this use-case
         */
-       if (nvhost_get_parent(dev))
-               ret = nvhost_module_busy(nvhost_get_parent(dev));
+       if (to_platform_device(dev->dev.parent))
+               ret = nvhost_module_busy_ext(
+                       to_platform_device(dev->dev.parent));
 
        return ret;
 }
@@ -120,8 +121,8 @@ static int gk20a_tegra_channel_busy(struct platform_device *dev)
 static void gk20a_tegra_channel_idle(struct platform_device *dev)
 {
        /* Explicitly turn off the host1x clocks */
-       if (nvhost_get_parent(dev))
-               nvhost_module_idle(nvhost_get_parent(dev));
+       if (to_platform_device(dev->dev.parent))
+               nvhost_module_idle_ext(to_platform_device(dev->dev.parent));
 }
 
 #ifdef CONFIG_TEGRA_NVMAP