summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 64be9398..cd104580 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -76,6 +76,8 @@ u32 gk20a_dbg_mask = GK20A_DEFAULT_DBG_MASK;
76u32 gk20a_dbg_ftrace; 76u32 gk20a_dbg_ftrace;
77#endif 77#endif
78 78
79#define GK20A_WAIT_FOR_IDLE_MS 2000
80
79static int gk20a_pm_finalize_poweron(struct device *dev); 81static int gk20a_pm_finalize_poweron(struct device *dev);
80static int gk20a_pm_prepare_poweroff(struct device *dev); 82static int gk20a_pm_prepare_poweroff(struct device *dev);
81 83
@@ -1736,9 +1738,10 @@ int gk20a_do_idle(void)
1736 NULL, "gk20a.0")); 1738 NULL, "gk20a.0"));
1737 struct gk20a *g = get_gk20a(pdev); 1739 struct gk20a *g = get_gk20a(pdev);
1738 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); 1740 struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev);
1739 struct fifo_gk20a *f = &g->fifo; 1741 unsigned long timeout = jiffies +
1740 unsigned long timeout = jiffies + msecs_to_jiffies(200); 1742 msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS);
1741 int chid, ref_cnt; 1743 int ref_cnt;
1744 bool is_railgated;
1742 1745
1743 if (!platform->can_railgate) 1746 if (!platform->can_railgate)
1744 return -ENOSYS; 1747 return -ENOSYS;
@@ -1759,12 +1762,8 @@ int gk20a_do_idle(void)
1759 /* check and wait until GPU is idle (with a timeout) */ 1762 /* check and wait until GPU is idle (with a timeout) */
1760 pm_runtime_barrier(&pdev->dev); 1763 pm_runtime_barrier(&pdev->dev);
1761 1764
1762 for (chid = 0; chid < f->num_channels; chid++)
1763 if (gk20a_wait_channel_idle(&f->channel[chid]))
1764 goto fail;
1765
1766 do { 1765 do {
1767 mdelay(1); 1766 msleep(1);
1768 ref_cnt = atomic_read(&pdev->dev.power.usage_count); 1767 ref_cnt = atomic_read(&pdev->dev.power.usage_count);
1769 } while (ref_cnt != 1 && time_before(jiffies, timeout)); 1768 } while (ref_cnt != 1 && time_before(jiffies, timeout));
1770 1769
@@ -1778,19 +1777,20 @@ int gk20a_do_idle(void)
1778 pm_runtime_put_sync(&pdev->dev); 1777 pm_runtime_put_sync(&pdev->dev);
1779 1778
1780 /* add sufficient delay to allow GPU to rail gate */ 1779 /* add sufficient delay to allow GPU to rail gate */
1781 mdelay(platform->railgate_delay); 1780 msleep(platform->railgate_delay);
1782 1781
1783 if (platform->is_railgated(pdev)) 1782 timeout = jiffies + msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS);
1784 return 0; 1783
1785 else { 1784 /* check in loop if GPU is railgated or not */
1786 /* wait for some more time */ 1785 do {
1787 mdelay(100); 1786 msleep(1);
1788 if (platform->is_railgated(pdev)) 1787 is_railgated = platform->is_railgated(pdev);
1789 return 0; 1788 } while (!is_railgated && time_before(jiffies, timeout));
1790 }
1791 1789
1792 /* GPU is not rail gated by now, return error */ 1790 if (is_railgated)
1793 goto fail_timeout; 1791 return 0;
1792 else
1793 goto fail_timeout;
1794 1794
1795fail: 1795fail:
1796 pm_runtime_put_noidle(&pdev->dev); 1796 pm_runtime_put_noidle(&pdev->dev);