summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c73
1 files changed, 60 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 6a5986a7..b8753a21 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -60,6 +60,7 @@
60#include "hw_gr_gk20a.h" 60#include "hw_gr_gk20a.h"
61#include "hw_fb_gk20a.h" 61#include "hw_fb_gk20a.h"
62#include "gk20a_scale.h" 62#include "gk20a_scale.h"
63#include "ctxsw_trace_gk20a.h"
63#include "dbg_gpu_gk20a.h" 64#include "dbg_gpu_gk20a.h"
64#include "gk20a_allocator.h" 65#include "gk20a_allocator.h"
65#include "hal.h" 66#include "hal.h"
@@ -80,7 +81,7 @@
80/* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */ 81/* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */
81#define INTERFACE_NAME "nvhost%s-gpu" 82#define INTERFACE_NAME "nvhost%s-gpu"
82 83
83#define GK20A_NUM_CDEVS 6 84#define GK20A_NUM_CDEVS 7
84 85
85#define EMC3D_DEFAULT_RATIO 750 86#define EMC3D_DEFAULT_RATIO 750
86 87
@@ -169,6 +170,19 @@ static const struct file_operations gk20a_tsg_ops = {
169 .unlocked_ioctl = gk20a_tsg_dev_ioctl, 170 .unlocked_ioctl = gk20a_tsg_dev_ioctl,
170}; 171};
171 172
173static const struct file_operations gk20a_ctxsw_ops = {
174 .owner = THIS_MODULE,
175 .release = gk20a_ctxsw_dev_release,
176 .open = gk20a_ctxsw_dev_open,
177#ifdef CONFIG_COMPAT
178 .compat_ioctl = gk20a_ctxsw_dev_ioctl,
179#endif
180 .unlocked_ioctl = gk20a_ctxsw_dev_ioctl,
181 .poll = gk20a_ctxsw_dev_poll,
182 .read = gk20a_ctxsw_dev_read,
183 .mmap = gk20a_ctxsw_dev_mmap,
184};
185
172static inline void sim_writel(struct gk20a *g, u32 r, u32 v) 186static inline void sim_writel(struct gk20a *g, u32 r, u32 v)
173{ 187{
174 writel(v, g->sim.regs+r); 188 writel(v, g->sim.regs+r);
@@ -672,9 +686,6 @@ static int gk20a_init_support(struct platform_device *dev)
672 mutex_init(&g->ch_wdt_lock); 686 mutex_init(&g->ch_wdt_lock);
673 mutex_init(&g->poweroff_lock); 687 mutex_init(&g->poweroff_lock);
674 688
675 mutex_init(&g->interleave_lock);
676 g->num_interleaved_channels = 0;
677
678 g->remove_support = gk20a_remove_support; 689 g->remove_support = gk20a_remove_support;
679 return 0; 690 return 0;
680 691
@@ -884,6 +895,10 @@ static int gk20a_pm_finalize_poweron(struct device *dev)
884 goto done; 895 goto done;
885 } 896 }
886 897
898 err = gk20a_ctxsw_trace_init(g);
899 if (err)
900 gk20a_warn(dev, "could not initialize ctxsw tracing");
901
887 /* Restore the debug setting */ 902 /* Restore the debug setting */
888 g->ops.mm.set_debug_mode(g, g->mmu_debug_ctrl); 903 g->ops.mm.set_debug_mode(g, g->mmu_debug_ctrl);
889 904
@@ -1012,6 +1027,11 @@ void gk20a_user_deinit(struct platform_device *dev)
1012 cdev_del(&g->tsg.cdev); 1027 cdev_del(&g->tsg.cdev);
1013 } 1028 }
1014 1029
1030 if (g->ctxsw.node) {
1031 device_destroy(g->class, g->ctxsw.cdev.dev);
1032 cdev_del(&g->ctxsw.cdev);
1033 }
1034
1015 if (g->cdev_region) 1035 if (g->cdev_region)
1016 unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); 1036 unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS);
1017 1037
@@ -1077,6 +1097,15 @@ int gk20a_user_init(struct platform_device *dev)
1077 if (err) 1097 if (err)
1078 goto fail; 1098 goto fail;
1079 1099
1100#ifdef CONFIG_GK20A_CTXSW_TRACE
1101 err = gk20a_create_device(dev, devno++, "-ctxsw",
1102 &g->ctxsw.cdev, &g->ctxsw.node,
1103 &gk20a_ctxsw_ops);
1104 if (err)
1105 goto fail;
1106#endif
1107
1108
1080 return 0; 1109 return 0;
1081fail: 1110fail:
1082 gk20a_user_deinit(dev); 1111 gk20a_user_deinit(dev);
@@ -1400,9 +1429,11 @@ static int gk20a_probe(struct platform_device *dev)
1400 1429
1401 spin_lock_init(&gk20a->mc_enable_lock); 1430 spin_lock_init(&gk20a->mc_enable_lock);
1402 1431
1432#ifdef CONFIG_RESET_CONTROLLER
1403 platform->reset_control = devm_reset_control_get(&dev->dev, NULL); 1433 platform->reset_control = devm_reset_control_get(&dev->dev, NULL);
1404 if (IS_ERR(platform->reset_control)) 1434 if (IS_ERR(platform->reset_control))
1405 platform->reset_control = NULL; 1435 platform->reset_control = NULL;
1436#endif
1406 1437
1407 gk20a_debug_init(dev); 1438 gk20a_debug_init(dev);
1408 1439
@@ -1439,14 +1470,11 @@ static int gk20a_probe(struct platform_device *dev)
1439 if (tegra_platform_is_silicon()) 1470 if (tegra_platform_is_silicon())
1440 gk20a->timeouts_enabled = true; 1471 gk20a->timeouts_enabled = true;
1441 1472
1442 gk20a->interleave_high_priority = true; 1473 gk20a->runlist_interleave = true;
1443 1474
1444 gk20a->timeslice_low_priority_us = 1300; 1475 gk20a->timeslice_low_priority_us = 1300;
1445 gk20a->timeslice_medium_priority_us = 2600; 1476 gk20a->timeslice_medium_priority_us = 2600;
1446 if (gk20a->interleave_high_priority) 1477 gk20a->timeslice_high_priority_us = 5200;
1447 gk20a->timeslice_high_priority_us = 3000;
1448 else
1449 gk20a->timeslice_high_priority_us = 5200;
1450 1478
1451 /* Set up initial power settings. For non-slicon platforms, disable * 1479 /* Set up initial power settings. For non-slicon platforms, disable *
1452 * power features and for silicon platforms, read from platform data */ 1480 * power features and for silicon platforms, read from platform data */
@@ -1527,16 +1555,17 @@ static int gk20a_probe(struct platform_device *dev)
1527 platform->debugfs, 1555 platform->debugfs,
1528 &gk20a->timeslice_high_priority_us); 1556 &gk20a->timeslice_high_priority_us);
1529 1557
1530 gk20a->debugfs_interleave_high_priority = 1558 gk20a->debugfs_runlist_interleave =
1531 debugfs_create_bool("interleave_high_priority", 1559 debugfs_create_bool("runlist_interleave",
1532 S_IRUGO|S_IWUSR, 1560 S_IRUGO|S_IWUSR,
1533 platform->debugfs, 1561 platform->debugfs,
1534 &gk20a->interleave_high_priority); 1562 &gk20a->runlist_interleave);
1535 1563
1536 gr_gk20a_debugfs_init(gk20a); 1564 gr_gk20a_debugfs_init(gk20a);
1537 gk20a_pmu_debugfs_init(dev); 1565 gk20a_pmu_debugfs_init(dev);
1538 gk20a_cde_debugfs_init(dev); 1566 gk20a_cde_debugfs_init(dev);
1539 gk20a_alloc_debugfs_init(dev); 1567 gk20a_alloc_debugfs_init(dev);
1568 gk20a_mm_debugfs_init(dev);
1540#endif 1569#endif
1541 1570
1542 gk20a_init_gr(gk20a); 1571 gk20a_init_gr(gk20a);
@@ -1558,6 +1587,8 @@ static int __exit gk20a_remove(struct platform_device *dev)
1558 if (platform->has_cde) 1587 if (platform->has_cde)
1559 gk20a_cde_destroy(g); 1588 gk20a_cde_destroy(g);
1560 1589
1590 gk20a_ctxsw_trace_cleanup(g);
1591
1561 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) 1592 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ))
1562 gk20a_scale_exit(dev); 1593 gk20a_scale_exit(dev);
1563 1594
@@ -1774,7 +1805,10 @@ void gk20a_enable(struct gk20a *g, u32 units)
1774void gk20a_reset(struct gk20a *g, u32 units) 1805void gk20a_reset(struct gk20a *g, u32 units)
1775{ 1806{
1776 gk20a_disable(g, units); 1807 gk20a_disable(g, units);
1777 udelay(20); 1808 if (units & mc_enable_ce2_enabled_f())
1809 udelay(500);
1810 else
1811 udelay(20);
1778 gk20a_enable(g, units); 1812 gk20a_enable(g, units);
1779} 1813}
1780 1814
@@ -2095,6 +2129,19 @@ gk20a_request_firmware(struct gk20a *g, const char *fw_name)
2095 return fw; 2129 return fw;
2096} 2130}
2097 2131
2132
2133u64 gk20a_read_ptimer(struct gk20a *g)
2134{
2135 u32 time_hi0 = gk20a_readl(g, timer_time_1_r());
2136 u32 time_lo = gk20a_readl(g, timer_time_0_r());
2137 u32 time_hi1 = gk20a_readl(g, timer_time_1_r());
2138 u32 time_hi = (time_lo & (1L << 31)) ? time_hi0 : time_hi1;
2139 u64 time = ((u64)time_hi << 32) | time_lo;
2140
2141 return time;
2142}
2143
2144
2098MODULE_LICENSE("GPL v2"); 2145MODULE_LICENSE("GPL v2");
2099module_init(gk20a_init); 2146module_init(gk20a_init);
2100module_exit(gk20a_exit); 2147module_exit(gk20a_exit);