From 0ad7f1d9aa18d959abf3cba6ca4e532fc9246a31 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Thu, 25 May 2017 17:41:38 +0530 Subject: gpu: nvgpu: use nvgpu specific nvhost APIs Remove use of linux specifix header files and and use nvgpu specific header file instead This is needed to remove all Linux dependencies from nvgpu driver Replace all nvhost_*() calls by nvgpu_nvhost_*() calls from new nvgpu library Remove platform device pointer host1x_dev from struct gk20a and add struct nvgpu_nvhost_dev instead Jira NVGPU-29 Change-Id: Ia7af70602cfc16f9ccc380752538c05a9cbb8a67 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1489726 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani --- drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | 1 - drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 44 +++++++++++----------- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 1 - drivers/gpu/nvgpu/gk20a/fence_gk20a.c | 32 ++++++---------- drivers/gpu/nvgpu/gk20a/fence_gk20a.h | 4 +- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 6 +-- drivers/gpu/nvgpu/gk20a/gk20a.h | 1 - drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 18 ++++----- drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c | 30 +++------------ .../gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c | 44 ++++++++-------------- .../gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c | 31 ++++++--------- 11 files changed, 78 insertions(+), 134 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c index 25805ea0..d530fff6 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index 07157dc9..3d313ce8 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "channel_sync_gk20a.h" #include "gk20a.h" @@ -35,12 +36,11 @@ #endif #ifdef CONFIG_TEGRA_GK20A_NVHOST -#include struct gk20a_channel_syncpt { struct gk20a_channel_sync ops; struct channel_gk20a *c; - struct platform_device *host1x_pdev; + struct nvgpu_nvhost_dev *nvhost_dev; u32 id; struct nvgpu_mem syncpt_buf; }; @@ -54,12 +54,12 @@ static int gk20a_channel_syncpt_wait_syncpt(struct gk20a_channel_sync *s, struct channel_gk20a *c = sp->c; int err = 0; - if (!nvhost_syncpt_is_valid_pt_ext(sp->host1x_pdev, id)) { + if (!nvgpu_nvhost_syncpt_is_valid_pt_ext(sp->nvhost_dev, id)) { nvgpu_warn(c->g, "invalid wait id in gpfifo submit, elided"); return 0; } - if (nvhost_syncpt_is_expired_ext(sp->host1x_pdev, id, thresh)) + if (nvgpu_nvhost_syncpt_is_expired_ext(sp->nvhost_dev, id, thresh)) return 0; err = gk20a_channel_alloc_priv_cmdbuf(c, @@ -94,7 +94,7 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, int err = 0; u32 wait_cmd_size = 0; - sync_fence = nvhost_sync_fdget(fd); + sync_fence = nvgpu_nvhost_sync_fdget(fd); if (!sync_fence) return -EINVAL; @@ -105,9 +105,9 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, for (i = 0; i < sync_fence->num_fences; i++) { pt = sync_pt_from_fence(sync_fence->cbs[i].sync_pt); #endif - wait_id = nvhost_sync_pt_id(pt); - if (!wait_id || !nvhost_syncpt_is_valid_pt_ext(sp->host1x_pdev, - wait_id)) { + wait_id = nvgpu_nvhost_sync_pt_id(pt); + if (!wait_id || !nvgpu_nvhost_syncpt_is_valid_pt_ext( + sp->nvhost_dev, wait_id)) { sync_fence_put(sync_fence); return -EINVAL; } @@ -117,7 +117,7 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, } #endif - num_wait_cmds = nvhost_sync_num_pts(sync_fence); + num_wait_cmds = nvgpu_nvhost_sync_num_pts(sync_fence); if (num_wait_cmds == 0) { sync_fence_put(sync_fence); return 0; @@ -141,10 +141,10 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, struct fence *f = sync_fence->cbs[i].sync_pt; struct sync_pt *pt = sync_pt_from_fence(f); #endif - u32 wait_id = nvhost_sync_pt_id(pt); - u32 wait_value = nvhost_sync_pt_thresh(pt); + u32 wait_id = nvgpu_nvhost_sync_pt_id(pt); + u32 wait_value = nvgpu_nvhost_sync_pt_thresh(pt); - if (nvhost_syncpt_is_expired_ext(sp->host1x_pdev, + if (nvgpu_nvhost_syncpt_is_expired_ext(sp->nvhost_dev, wait_id, wait_value)) { nvgpu_memset(c->g, wait_cmd->mem, (wait_cmd->off + i * wait_cmd_size) * sizeof(u32), @@ -206,7 +206,7 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, c->g->ops.fifo.add_syncpt_incr_cmd(c->g, wfi_cmd, incr_cmd, sp->id, sp->syncpt_buf.gpu_va); - thresh = nvhost_syncpt_incr_max_ext(sp->host1x_pdev, sp->id, 2); + thresh = nvgpu_nvhost_syncpt_incr_max_ext(sp->nvhost_dev, sp->id, 2); if (register_irq) { struct channel_gk20a *referenced = gk20a_channel_get(c); @@ -217,8 +217,8 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, /* note: channel_put() is in * gk20a_channel_syncpt_update() */ - err = nvhost_intr_register_notifier( - sp->host1x_pdev, + err = nvgpu_nvhost_intr_register_notifier( + sp->nvhost_dev, sp->id, thresh, gk20a_channel_syncpt_update, c); if (err) @@ -234,7 +234,7 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, } } - err = gk20a_fence_from_syncpt(fence, sp->host1x_pdev, sp->id, thresh, + err = gk20a_fence_from_syncpt(fence, sp->nvhost_dev, sp->id, thresh, wfi_cmd, need_sync_fence); if (err) goto clean_up_priv_cmd; @@ -290,7 +290,7 @@ static 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_ext(sp->host1x_pdev, sp->id); + nvgpu_nvhost_syncpt_set_min_eq_max_ext(sp->nvhost_dev, sp->id); } static void gk20a_channel_syncpt_signal_timeline( @@ -314,8 +314,8 @@ static void gk20a_channel_syncpt_destroy(struct gk20a_channel_sync *s) sp->c->g->ops.fifo.free_syncpt_buf(sp->c, &sp->syncpt_buf); - nvhost_syncpt_set_min_eq_max_ext(sp->host1x_pdev, sp->id); - nvhost_syncpt_put_ref_ext(sp->host1x_pdev, sp->id); + nvgpu_nvhost_syncpt_set_min_eq_max_ext(sp->nvhost_dev, sp->id); + nvgpu_nvhost_syncpt_put_ref_ext(sp->nvhost_dev, sp->id); nvgpu_kfree(sp->c->g, sp); } @@ -330,12 +330,12 @@ gk20a_channel_syncpt_create(struct channel_gk20a *c) return NULL; sp->c = c; - sp->host1x_pdev = c->g->host1x_dev; + sp->nvhost_dev = c->g->nvhost_dev; snprintf(syncpt_name, sizeof(syncpt_name), "%s_%d", c->g->name, c->hw_chid); - sp->id = nvhost_get_syncpt_host_managed(sp->host1x_pdev, + sp->id = nvgpu_nvhost_get_syncpt_host_managed(sp->nvhost_dev, c->hw_chid, syncpt_name); if (!sp->id) { nvgpu_kfree(c->g, sp); @@ -346,7 +346,7 @@ gk20a_channel_syncpt_create(struct channel_gk20a *c) sp->c->g->ops.fifo.alloc_syncpt_buf(sp->c, sp->id, &sp->syncpt_buf); - nvhost_syncpt_set_min_eq_max_ext(sp->host1x_pdev, sp->id); + nvgpu_nvhost_syncpt_set_min_eq_max_ext(sp->nvhost_dev, sp->id); atomic_set(&sp->ops.refcount, 0); sp->ops.wait_syncpt = gk20a_channel_syncpt_wait_syncpt; diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 4bfa041e..f018ef89 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c index 7c5d33c7..5392e77c 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "gk20a.h" #include "channel_gk20a.h" @@ -30,11 +31,6 @@ #include "../drivers/staging/android/sync.h" #endif -#ifdef CONFIG_TEGRA_GK20A_NVHOST -#include -#include -#endif - struct gk20a_fence_ops { int (*wait)(struct gk20a_fence *, long timeout); bool (*is_expired)(struct gk20a_fence *); @@ -268,8 +264,8 @@ int gk20a_fence_from_semaphore( static int gk20a_syncpt_fence_wait(struct gk20a_fence *f, long timeout) { - return nvhost_syncpt_wait_timeout_ext( - f->host1x_pdev, f->syncpt_id, f->syncpt_value, + return nvgpu_nvhost_syncpt_wait_timeout_ext( + f->nvhost_dev, f->syncpt_id, f->syncpt_value, (u32)timeout, NULL, NULL); } @@ -281,13 +277,14 @@ static bool gk20a_syncpt_fence_is_expired(struct gk20a_fence *f) * syncpt value to be updated. For this case, we force a read * of the value from HW, and then check for expiration. */ - if (!nvhost_syncpt_is_expired_ext(f->host1x_pdev, f->syncpt_id, + if (!nvgpu_nvhost_syncpt_is_expired_ext(f->nvhost_dev, f->syncpt_id, f->syncpt_value)) { u32 val; - if (!nvhost_syncpt_read_ext_check(f->host1x_pdev, + if (!nvgpu_nvhost_syncpt_read_ext_check(f->nvhost_dev, f->syncpt_id, &val)) { - return nvhost_syncpt_is_expired_ext(f->host1x_pdev, + return nvgpu_nvhost_syncpt_is_expired_ext( + f->nvhost_dev, f->syncpt_id, f->syncpt_value); } } @@ -302,7 +299,7 @@ static const struct gk20a_fence_ops gk20a_syncpt_fence_ops = { int gk20a_fence_from_syncpt( struct gk20a_fence *fence_out, - struct platform_device *host1x_pdev, + struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 value, bool wfi, bool need_sync_fence) { @@ -310,14 +307,9 @@ int gk20a_fence_from_syncpt( struct sync_fence *sync_fence = NULL; #ifdef CONFIG_SYNC - struct nvhost_ctrl_sync_fence_info pt = { - .id = id, - .thresh = value - }; - if (need_sync_fence) { - sync_fence = nvhost_sync_create_fence(host1x_pdev, &pt, 1, - "fence"); + sync_fence = nvgpu_nvhost_sync_create_fence(nvhost_dev, + id, value, 1, "fence"); if (IS_ERR(sync_fence)) return -1; } @@ -331,7 +323,7 @@ int gk20a_fence_from_syncpt( #endif return -EINVAL; } - f->host1x_pdev = host1x_pdev; + f->nvhost_dev = nvhost_dev; f->syncpt_id = id; f->syncpt_value = value; @@ -344,7 +336,7 @@ int gk20a_fence_from_syncpt( #else int gk20a_fence_from_syncpt( struct gk20a_fence *fence_out, - struct platform_device *host1x_pdev, + struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 value, bool wfi, bool need_sync_fence) { diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h index c479f359..140f5488 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h @@ -43,7 +43,7 @@ struct gk20a_fence { struct nvgpu_cond *semaphore_wq; /* Valid for fences created from syncpoints: */ - struct platform_device *host1x_pdev; + struct nvgpu_nvhost_dev *nvhost_dev; u32 syncpt_id; u32 syncpt_value; @@ -62,7 +62,7 @@ int gk20a_fence_from_semaphore( int gk20a_fence_from_syncpt( struct gk20a_fence *fence_out, - struct platform_device *host1x_pdev, + struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 value, bool wfi, bool need_sync_fence); diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index 7eb28f2f..4b0667c5 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -18,9 +18,6 @@ */ #include -#ifdef CONFIG_TEGRA_GK20A_NVHOST -#include -#endif #include #include @@ -32,6 +29,7 @@ #include #include #include +#include #include "gk20a.h" #include "ctxsw_trace_gk20a.h" @@ -3537,7 +3535,7 @@ void gk20a_dump_channel_status_ramfc(struct gk20a *g, gk20a_debug_output(o, "%s on syncpt %u (%s) val %u\n", (status == 3 || status == 8) ? "Waiting" : "Waited", pbdma_syncpointb_syncpt_index_v(syncpointb), - nvhost_syncpt_get_name(g->host1x_dev, + nvgpu_nvhost_syncpt_get_name(g->nvhost_dev, pbdma_syncpointb_syncpt_index_v(syncpointb)), pbdma_syncpointa_payload_v(syncpointa)); #endif diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 8691c73d..b4884af1 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -981,7 +981,6 @@ struct nvgpu_bios { struct gk20a { struct device *dev; - struct platform_device *host1x_dev; struct nvgpu_nvhost_dev *nvhost_dev; /* diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 1065968b..4a79a142 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c @@ -28,6 +28,7 @@ #endif #include +#include #include "gk20a.h" #include "gk20a/platform_gk20a.h" @@ -889,8 +890,6 @@ static DEVICE_ATTR(max_timeslice_us, ROOTRW, max_timeslice_us_read, void gk20a_remove_sysfs(struct device *dev) { - struct gk20a *g = get_gk20a(dev); - device_remove_file(dev, &dev_attr_elcg_enable); device_remove_file(dev, &dev_attr_blcg_enable); device_remove_file(dev, &dev_attr_slcg_enable); @@ -917,9 +916,9 @@ void gk20a_remove_sysfs(struct device *dev) device_remove_file(dev, &dev_attr_min_timeslice_us); device_remove_file(dev, &dev_attr_max_timeslice_us); - if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { - sysfs_remove_link(&g->host1x_dev->dev.kobj, dev_name(dev)); - } +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_nvhost_remove_symlink(get_gk20a(dev)); +#endif if (strcmp(dev_name(dev), "gpu.0")) { struct kobject *kobj = &dev->kobj; @@ -931,7 +930,6 @@ void gk20a_remove_sysfs(struct device *dev) void gk20a_create_sysfs(struct device *dev) { - struct gk20a *g = gk20a_from_dev(dev); int error = 0; error |= device_create_file(dev, &dev_attr_elcg_enable); @@ -960,11 +958,9 @@ void gk20a_create_sysfs(struct device *dev) error |= device_create_file(dev, &dev_attr_min_timeslice_us); error |= device_create_file(dev, &dev_attr_max_timeslice_us); - if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { - error |= sysfs_create_link(&g->host1x_dev->dev.kobj, - &dev->kobj, - dev_name(dev)); - } +#ifdef CONFIG_TEGRA_GK20A_NVHOST + error |= nvgpu_nvhost_create_symlink(get_gk20a(dev)); +#endif if (strcmp(dev_name(dev), "gpu.0")) { struct kobject *kobj = &dev->kobj; diff --git a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c index 049d394e..e33fc29f 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c +++ b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c @@ -13,38 +13,20 @@ * more details. */ -#include - #include "gk20a.h" #include "hal_gk20a.h" #include "platform_gk20a.h" +#include + static int gk20a_tegra_probe(struct device *dev) { +#ifdef CONFIG_TEGRA_GK20A_NVHOST struct gk20a_platform *platform = dev_get_drvdata(dev); - struct device_node *np = dev->of_node; - const __be32 *host1x_ptr; - struct platform_device *host1x_pdev = NULL; - - host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); - if (host1x_ptr) { - struct device_node *host1x_node = - of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); - - host1x_pdev = of_find_device_by_node(host1x_node); - if (!host1x_pdev) { - dev_warn(dev, "host1x device not available"); - return -EPROBE_DEFER; - } - - } else { - host1x_pdev = to_platform_device(dev->parent); - dev_warn(dev, "host1x reference not found. assuming host1x to be parent"); - } - - platform->g->host1x_dev = host1x_pdev; - + return nvgpu_get_nvhost_dev(platform->g); +#else return 0; +#endif } struct gk20a_platform vgpu_tegra_platform = { diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c index 8a83f7d0..f55ea6d2 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c @@ -15,9 +15,6 @@ #include #include -#ifdef CONFIG_TEGRA_GK20A_NVHOST -#include -#endif #include #include #include @@ -48,6 +45,7 @@ #include #include #include +#include #include @@ -721,8 +719,8 @@ void gk20a_tegra_debug_dump(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - nvhost_debug_dump_device(g->host1x_dev); + if (g->nvhost_dev) + nvgpu_nvhost_debug_dump_device(g->nvhost_dev); #endif } @@ -732,8 +730,8 @@ int gk20a_tegra_busy(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - return nvhost_module_busy_ext(g->host1x_dev); + if (g->nvhost_dev) + return nvgpu_nvhost_module_busy_ext(g->nvhost_dev); #endif return 0; } @@ -744,8 +742,8 @@ void gk20a_tegra_idle(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - nvhost_module_idle_ext(g->host1x_dev); + if (g->nvhost_dev) + nvgpu_nvhost_module_idle_ext(g->nvhost_dev); #endif } @@ -864,8 +862,6 @@ static int gk20a_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); struct device_node *np = dev->of_node; - const __be32 *host1x_ptr; - struct platform_device *host1x_pdev = NULL; bool joint_xpu_rail = false; int ret; @@ -887,23 +883,11 @@ static int gk20a_tegra_probe(struct device *dev) } #endif - host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); - if (host1x_ptr) { - struct device_node *host1x_node = - of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); - - host1x_pdev = of_find_device_by_node(host1x_node); - if (!host1x_pdev) { - dev_warn(dev, "host1x device not available"); - return -EPROBE_DEFER; - } - - } else { - host1x_pdev = to_platform_device(dev->parent); - dev_warn(dev, "host1x reference not found. assuming host1x to be parent"); - } - - platform->g->host1x_dev = host1x_pdev; +#ifdef CONFIG_TEGRA_GK20A_NVHOST + ret = nvgpu_get_nvhost_dev(platform->g); + if (ret) + return ret; +#endif #ifdef CONFIG_OF joint_xpu_rail = of_property_read_bool(of_chosen, @@ -967,6 +951,10 @@ static int gk20a_tegra_remove(struct device *dev) /* deinitialise tegra specific scaling quirks */ gk20a_tegra_scale_exit(dev); +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_free_nvhost_dev(get_gk20a(dev)); +#endif + return 0; } diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c index 8b530fac..235473d3 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include "clk.h" @@ -130,26 +130,14 @@ static void gp10b_tegra_scale_exit(struct device *dev) static int gp10b_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); - struct gk20a *g = platform->g; - struct device_node *np = dev->of_node; - struct device_node *host1x_node; - struct platform_device *host1x_pdev; - const __be32 *host1x_ptr; - - host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); - if (!host1x_ptr) { - nvgpu_err(g, "host1x device not available"); - return -ENOSYS; - } +#ifdef CONFIG_TEGRA_GK20A_NVHOST + int ret; - host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); - host1x_pdev = of_find_device_by_node(host1x_node); - if (!host1x_pdev) { - nvgpu_err(g, "host1x device not available"); - return -ENOSYS; - } + ret = nvgpu_get_nvhost_dev(platform->g); + if (ret) + return ret; +#endif - platform->g->host1x_dev = host1x_pdev; platform->bypass_smmu = !device_is_iommuable(dev); platform->disable_bigpage = platform->bypass_smmu; @@ -190,8 +178,11 @@ int gp10b_tegra_remove(struct device *dev) /* deinitialise tegra specific scaling quirks */ gp10b_tegra_scale_exit(dev); - return 0; +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_free_nvhost_dev(get_gk20a(dev)); +#endif + return 0; } static bool gp10b_tegra_is_railgated(struct device *dev) -- cgit v1.2.2