aboutsummaryrefslogtreecommitdiffstats
path: root/runlist.c
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2021-09-23 12:49:27 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2021-09-23 12:49:27 -0400
commit0596e479ffcca43957f8d32127cea5527460b983 (patch)
tree2ea671a4df3def4a72ac3edbce645ff661150cb7 /runlist.c
parenta7564070dcdf75de4f848af936e3d76ed01833e1 (diff)
Add APIs to enable/disable a channel and switch to or preempt a specific TSG
Adds: - /proc/preempt_tsg which takes a TSG ID - /proc/disable_channel which takes a channel ID - /proc/enable_channel which takes a channel ID - /proc/switch_to_tsg which takes a TSG ID Also significantly expands documentation and structs available in nvdebug.h.
Diffstat (limited to 'runlist.c')
-rw-r--r--runlist.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/runlist.c b/runlist.c
index 8dfa1c7..03528af 100644
--- a/runlist.c
+++ b/runlist.c
@@ -109,3 +109,28 @@ int get_runlist_iter(struct runlist_iter *rl_iter) {
109 printk(KERN_INFO "[nvdebug] tsg_length: %d\n", head.tsg_length); 109 printk(KERN_INFO "[nvdebug] tsg_length: %d\n", head.tsg_length);
110 printk(KERN_INFO "[nvdebug] tsgid: %d\n", head.tsgid); */ 110 printk(KERN_INFO "[nvdebug] tsgid: %d\n", head.tsgid); */
111} 111}
112
113int preempt_tsg(uint32_t tsg_id) {
114 struct gk20a *g = get_live_gk20a();
115 runlist_info_t rl_info;
116 pfifo_preempt_t pfifo_preempt;
117 runlist_disable_t rl_disable;
118 if (!g)
119 return -EIO;
120 rl_info.raw = nvdebug_readl(g, NV_PFIFO_RUNLIST);
121 pfifo_preempt.id = tsg_id;
122 pfifo_preempt.is_pending = 0;
123 pfifo_preempt.type = PREEMPT_TYPE_TSG;
124 // There may be a bug (?) that requires us to disable scheduling before preempting
125 rl_disable.raw = nvdebug_readl(g, NV_PFIFO_SCHED_DISABLE);
126 rl_disable.raw |= BIT(rl_info.id); // Disable runlist rl_info.id
127 nvdebug_writel(g, NV_PFIFO_SCHED_DISABLE, rl_disable.raw);
128 // Actually trigger the preemption
129 nvdebug_writel(g, NV_PFIFO_PREEMPT, pfifo_preempt.raw);
130 // Renable scheduling
131 rl_disable.raw &= ~BIT(rl_info.id); // Enable runlist rl_info.id
132 nvdebug_writel(g, NV_PFIFO_SCHED_DISABLE, rl_disable.raw);
133
134 printk(KERN_INFO "[nvdebug] TSG %d preempted (runlist %d)\n", tsg_id, rl_info.id);
135 return 0;
136}