summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2014-09-08 08:47:15 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:11:13 -0400
commit3ef352a05a027231d9cb88b63f465e6a0da89759 (patch)
tree3cc8d14d6a8f3fd35aedaf3b8e14071902736a7a /drivers/gpu/nvgpu/gk20a
parent545fadee0a7de14b087af40c98281e8653d2e312 (diff)
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 <dnibade@nvidia.com> Reviewed-on: http://git-master/r/496508 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: Ken Adams <kadams@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c55
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c4
3 files changed, 46 insertions, 15 deletions
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;
84 84
85#define GK20A_WAIT_FOR_IDLE_MS 2000 85#define GK20A_WAIT_FOR_IDLE_MS 2000
86 86
87static struct gk20a *gk20a_handle;
88
89static int gk20a_pm_finalize_poweron(struct device *dev); 87static int gk20a_pm_finalize_poweron(struct device *dev);
90static int gk20a_pm_prepare_poweroff(struct device *dev); 88static int gk20a_pm_prepare_poweroff(struct device *dev);
91 89
@@ -1455,7 +1453,6 @@ static int gk20a_probe(struct platform_device *dev)
1455 1453
1456 set_gk20a(dev, gk20a); 1454 set_gk20a(dev, gk20a);
1457 gk20a->dev = dev; 1455 gk20a->dev = dev;
1458 gk20a_handle = gk20a;
1459 1456
1460 gk20a->irq_stall = platform_get_irq(dev, 0); 1457 gk20a->irq_stall = platform_get_irq(dev, 0);
1461 gk20a->irq_nonstall = platform_get_irq(dev, 1); 1458 gk20a->irq_nonstall = platform_get_irq(dev, 1);
@@ -1611,7 +1608,6 @@ static int __exit gk20a_remove(struct platform_device *dev)
1611 1608
1612 gk20a_user_deinit(dev); 1609 gk20a_user_deinit(dev);
1613 1610
1614 gk20a_handle = NULL;
1615 set_gk20a(dev, 0); 1611 set_gk20a(dev, 0);
1616#ifdef CONFIG_DEBUG_FS 1612#ifdef CONFIG_DEBUG_FS
1617 debugfs_remove(g->debugfs_ltc_enabled); 1613 debugfs_remove(g->debugfs_ltc_enabled);
@@ -1754,14 +1750,13 @@ void gk20a_reset(struct gk20a *g, u32 units)
1754 1750
1755#ifdef CONFIG_PM_RUNTIME 1751#ifdef CONFIG_PM_RUNTIME
1756/** 1752/**
1757 * gk20a_do_idle() - force the GPU to idle and railgate 1753 * __gk20a_do_idle() - force the GPU to idle and railgate
1758 * 1754 *
1759 * In success, this call MUST be balanced by caller with gk20a_do_unidle() 1755 * In success, this call MUST be balanced by caller with __gk20a_do_unidle()
1760 */ 1756 */
1761int gk20a_do_idle(void) 1757int __gk20a_do_idle(struct platform_device *pdev)
1762{ 1758{
1763 struct gk20a *g = gk20a_handle; 1759 struct gk20a *g = get_gk20a(pdev);
1764 struct platform_device *pdev = g->dev;
1765 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); 1760 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev);
1766 unsigned long timeout = jiffies + 1761 unsigned long timeout = jiffies +
1767 msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS); 1762 msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS);
@@ -1837,12 +1832,30 @@ fail_timeout:
1837} 1832}
1838 1833
1839/** 1834/**
1840 * gk20a_do_unidle() - unblock all the tasks blocked by gk20a_do_idle() 1835 * gk20a_do_idle() - wrap up for __gk20a_do_idle() to be called
1836 * from outside of GPU driver
1837 *
1838 * In success, this call MUST be balanced by caller with gk20a_do_unidle()
1841 */ 1839 */
1842int gk20a_do_unidle(void) 1840int gk20a_do_idle(void)
1841{
1842 struct device_node *node =
1843 of_find_matching_node(NULL, tegra_gk20a_of_match);
1844 struct platform_device *pdev = of_find_device_by_node(node);
1845
1846 int ret = __gk20a_do_idle(pdev);
1847
1848 of_node_put(node);
1849
1850 return ret;
1851}
1852
1853/**
1854 * __gk20a_do_unidle() - unblock all the tasks blocked by __gk20a_do_idle()
1855 */
1856int __gk20a_do_unidle(struct platform_device *pdev)
1843{ 1857{
1844 struct gk20a *g = gk20a_handle; 1858 struct gk20a *g = get_gk20a(pdev);
1845 struct platform_device *pdev = g->dev;
1846 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); 1859 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev);
1847 1860
1848 if (g->forced_reset) { 1861 if (g->forced_reset) {
@@ -1860,6 +1873,22 @@ int gk20a_do_unidle(void)
1860 1873
1861 return 0; 1874 return 0;
1862} 1875}
1876
1877/**
1878 * gk20a_do_unidle() - wrap up for __gk20a_do_unidle()
1879 */
1880int gk20a_do_unidle(void)
1881{
1882 struct device_node *node =
1883 of_find_matching_node(NULL, tegra_gk20a_of_match);
1884 struct platform_device *pdev = of_find_device_by_node(node);
1885
1886 int ret = __gk20a_do_unidle(pdev);
1887
1888 of_node_put(node);
1889
1890 return ret;
1891}
1863#endif 1892#endif
1864 1893
1865int gk20a_init_gpu_characteristics(struct gk20a *g) 1894int 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);
712void gk20a_reset(struct gk20a *g, u32 units); 712void gk20a_reset(struct gk20a *g, u32 units);
713int gk20a_get_client(struct gk20a *g); 713int gk20a_get_client(struct gk20a *g);
714void gk20a_put_client(struct gk20a *g); 714void gk20a_put_client(struct gk20a *g);
715int __gk20a_do_idle(struct platform_device *pdev);
716int __gk20a_do_unidle(struct platform_device *pdev);
715 717
716const struct firmware * 718const struct firmware *
717gk20a_request_firmware(struct gk20a *g, const char *fw_name); 719gk20a_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,
543 if (g->forced_idle) 543 if (g->forced_idle)
544 return count; /* do nothing */ 544 return count; /* do nothing */
545 else { 545 else {
546 err = gk20a_do_idle(); 546 err = __gk20a_do_idle(ndev);
547 if (!err) { 547 if (!err) {
548 g->forced_idle = 1; 548 g->forced_idle = 1;
549 dev_info(device, "gpu is idle : %d\n", 549 dev_info(device, "gpu is idle : %d\n",
@@ -554,7 +554,7 @@ static ssize_t force_idle_store(struct device *device,
554 if (!g->forced_idle) 554 if (!g->forced_idle)
555 return count; /* do nothing */ 555 return count; /* do nothing */
556 else { 556 else {
557 err = gk20a_do_unidle(); 557 err = __gk20a_do_unidle(ndev);
558 if (!err) { 558 if (!err) {
559 g->forced_idle = 0; 559 g->forced_idle = 0;
560 dev_info(device, "gpu is idle : %d\n", 560 dev_info(device, "gpu is idle : %d\n",