diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 0cc9564b..735bf90b 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 | ||
173 | static 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 | |||
172 | static inline void sim_writel(struct gk20a *g, u32 r, u32 v) | 186 | static 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); |
@@ -881,6 +895,10 @@ static int gk20a_pm_finalize_poweron(struct device *dev) | |||
881 | goto done; | 895 | goto done; |
882 | } | 896 | } |
883 | 897 | ||
898 | err = gk20a_ctxsw_trace_init(g); | ||
899 | if (err) | ||
900 | gk20a_warn(dev, "could not initialize ctxsw tracing"); | ||
901 | |||
884 | /* Restore the debug setting */ | 902 | /* Restore the debug setting */ |
885 | g->ops.mm.set_debug_mode(g, g->mmu_debug_ctrl); | 903 | g->ops.mm.set_debug_mode(g, g->mmu_debug_ctrl); |
886 | 904 | ||
@@ -1009,6 +1027,11 @@ void gk20a_user_deinit(struct platform_device *dev) | |||
1009 | cdev_del(&g->tsg.cdev); | 1027 | cdev_del(&g->tsg.cdev); |
1010 | } | 1028 | } |
1011 | 1029 | ||
1030 | if (g->ctxsw.node) { | ||
1031 | device_destroy(g->class, g->ctxsw.cdev.dev); | ||
1032 | cdev_del(&g->ctxsw.cdev); | ||
1033 | } | ||
1034 | |||
1012 | if (g->cdev_region) | 1035 | if (g->cdev_region) |
1013 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | 1036 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); |
1014 | 1037 | ||
@@ -1074,6 +1097,15 @@ int gk20a_user_init(struct platform_device *dev) | |||
1074 | if (err) | 1097 | if (err) |
1075 | goto fail; | 1098 | goto fail; |
1076 | 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 | |||
1077 | return 0; | 1109 | return 0; |
1078 | fail: | 1110 | fail: |
1079 | gk20a_user_deinit(dev); | 1111 | gk20a_user_deinit(dev); |
@@ -1554,6 +1586,8 @@ static int __exit gk20a_remove(struct platform_device *dev) | |||
1554 | if (platform->has_cde) | 1586 | if (platform->has_cde) |
1555 | gk20a_cde_destroy(g); | 1587 | gk20a_cde_destroy(g); |
1556 | 1588 | ||
1589 | gk20a_ctxsw_trace_cleanup(g); | ||
1590 | |||
1557 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) | 1591 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) |
1558 | gk20a_scale_exit(dev); | 1592 | gk20a_scale_exit(dev); |
1559 | 1593 | ||
@@ -2091,6 +2125,19 @@ gk20a_request_firmware(struct gk20a *g, const char *fw_name) | |||
2091 | return fw; | 2125 | return fw; |
2092 | } | 2126 | } |
2093 | 2127 | ||
2128 | |||
2129 | u64 gk20a_read_ptimer(struct gk20a *g) | ||
2130 | { | ||
2131 | u32 time_hi0 = gk20a_readl(g, timer_time_1_r()); | ||
2132 | u32 time_lo = gk20a_readl(g, timer_time_0_r()); | ||
2133 | u32 time_hi1 = gk20a_readl(g, timer_time_1_r()); | ||
2134 | u32 time_hi = (time_lo & (1L << 31)) ? time_hi0 : time_hi1; | ||
2135 | u64 time = ((u64)time_hi << 32) | time_lo; | ||
2136 | |||
2137 | return time; | ||
2138 | } | ||
2139 | |||
2140 | |||
2094 | MODULE_LICENSE("GPL v2"); | 2141 | MODULE_LICENSE("GPL v2"); |
2095 | module_init(gk20a_init); | 2142 | module_init(gk20a_init); |
2096 | module_exit(gk20a_exit); | 2143 | module_exit(gk20a_exit); |