From 3ef352a05a027231d9cb88b63f465e6a0da89759 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Mon, 8 Sep 2014 18:17:15 +0530 Subject: gpu: nvgpu: remove gk20a_handle Remove static variable gk20a_handle used to store pointer to struct gk20a Use below device tree APIs to get pointer to platform_device and then struct gk20a device_node = of_find_matching_node() platform_device = of_find_device_by_node(device_node) Also, use two versions of do_idle()/do_unidle() APIs - one will receive void (to be used from outside GPU driver) and another will receive platform_device (to be used within GPU driver where it is available) Change-Id: I9f2c7610646c5fbcd3d99a1b03dc0364201272a8 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/496508 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom Reviewed-by: Ken Adams GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/gk20a/gk20a.c | 55 ++++++++++++++++++++++++++--------- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 ++ drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 4 +-- 3 files changed, 46 insertions(+), 15 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 0caef967..2ed7b737 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -84,8 +84,6 @@ u32 gk20a_dbg_ftrace; #define GK20A_WAIT_FOR_IDLE_MS 2000 -static struct gk20a *gk20a_handle; - static int gk20a_pm_finalize_poweron(struct device *dev); static int gk20a_pm_prepare_poweroff(struct device *dev); @@ -1455,7 +1453,6 @@ static int gk20a_probe(struct platform_device *dev) set_gk20a(dev, gk20a); gk20a->dev = dev; - gk20a_handle = gk20a; gk20a->irq_stall = platform_get_irq(dev, 0); gk20a->irq_nonstall = platform_get_irq(dev, 1); @@ -1611,7 +1608,6 @@ static int __exit gk20a_remove(struct platform_device *dev) gk20a_user_deinit(dev); - gk20a_handle = NULL; set_gk20a(dev, 0); #ifdef CONFIG_DEBUG_FS debugfs_remove(g->debugfs_ltc_enabled); @@ -1754,14 +1750,13 @@ void gk20a_reset(struct gk20a *g, u32 units) #ifdef CONFIG_PM_RUNTIME /** - * gk20a_do_idle() - force the GPU to idle and railgate + * __gk20a_do_idle() - force the GPU to idle and railgate * - * In success, this call MUST be balanced by caller with gk20a_do_unidle() + * In success, this call MUST be balanced by caller with __gk20a_do_unidle() */ -int gk20a_do_idle(void) +int __gk20a_do_idle(struct platform_device *pdev) { - struct gk20a *g = gk20a_handle; - struct platform_device *pdev = g->dev; + struct gk20a *g = get_gk20a(pdev); struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); unsigned long timeout = jiffies + msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS); @@ -1837,12 +1832,30 @@ fail_timeout: } /** - * gk20a_do_unidle() - unblock all the tasks blocked by gk20a_do_idle() + * gk20a_do_idle() - wrap up for __gk20a_do_idle() to be called + * from outside of GPU driver + * + * In success, this call MUST be balanced by caller with gk20a_do_unidle() */ -int gk20a_do_unidle(void) +int gk20a_do_idle(void) +{ + struct device_node *node = + of_find_matching_node(NULL, tegra_gk20a_of_match); + struct platform_device *pdev = of_find_device_by_node(node); + + int ret = __gk20a_do_idle(pdev); + + of_node_put(node); + + return ret; +} + +/** + * __gk20a_do_unidle() - unblock all the tasks blocked by __gk20a_do_idle() + */ +int __gk20a_do_unidle(struct platform_device *pdev) { - struct gk20a *g = gk20a_handle; - struct platform_device *pdev = g->dev; + struct gk20a *g = get_gk20a(pdev); struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); if (g->forced_reset) { @@ -1860,6 +1873,22 @@ int gk20a_do_unidle(void) return 0; } + +/** + * gk20a_do_unidle() - wrap up for __gk20a_do_unidle() + */ +int gk20a_do_unidle(void) +{ + struct device_node *node = + of_find_matching_node(NULL, tegra_gk20a_of_match); + struct platform_device *pdev = of_find_device_by_node(node); + + int ret = __gk20a_do_unidle(pdev); + + of_node_put(node); + + return ret; +} #endif int gk20a_init_gpu_characteristics(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index b6d73343..83c4e147 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -712,6 +712,8 @@ void gk20a_enable(struct gk20a *g, u32 units); void gk20a_reset(struct gk20a *g, u32 units); int gk20a_get_client(struct gk20a *g); void gk20a_put_client(struct gk20a *g); +int __gk20a_do_idle(struct platform_device *pdev); +int __gk20a_do_unidle(struct platform_device *pdev); const struct firmware * gk20a_request_firmware(struct gk20a *g, const char *fw_name); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 687147ed..b23a1406 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c @@ -543,7 +543,7 @@ static ssize_t force_idle_store(struct device *device, if (g->forced_idle) return count; /* do nothing */ else { - err = gk20a_do_idle(); + err = __gk20a_do_idle(ndev); if (!err) { g->forced_idle = 1; dev_info(device, "gpu is idle : %d\n", @@ -554,7 +554,7 @@ static ssize_t force_idle_store(struct device *device, if (!g->forced_idle) return count; /* do nothing */ else { - err = gk20a_do_unidle(); + err = __gk20a_do_unidle(ndev); if (!err) { g->forced_idle = 0; dev_info(device, "gpu is idle : %d\n", -- cgit v1.2.2