summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2015-03-06 09:33:43 -0500
committerTerje Bergstrom <tbergstrom@nvidia.com>2015-06-09 14:13:43 -0400
commit6085c90f499c642bc41a646b0efbdfe60e096c74 (patch)
tree0eaab99b228ce162ec3a44d0f8138b441f5a64f4 /drivers/gpu/nvgpu/gk20a/debug_gk20a.c
parenta41e5c41cadaa3d030a1f75b09328b8b1a440b69 (diff)
gpu: nvgpu: add per-channel refcounting
Add reference counting for channels, and wait for reference count to get to 0 in gk20a_channel_free() before actually freeing the channel. Also, change free channel tracking a bit by employing a list of free channels, which simplifies the procedure of finding available channels with reference counting. Each use of a channel must have a reference taken before use or held by the caller. Taking a reference of a wild channel pointer may fail, if the channel is either not opened or in a process of being closed. Also, add safeguards for protecting accidental use of closed channels, specifically, by setting ch->g = NULL in channel free. This will make it obvious if freed channel is attempted to be used. The last user of a channel might be the deferred interrupt handler, so wait for deferred interrupts to be processed twice in the channel free procedure: once for providing last notifications to the channel and once to make sure there are no stale pointers left after referencing to the channel has been denied. Finally, fix some races in channel and TSG force reset IOCTL path, by pausing the channel scheduler in gk20a_fifo_recover_ch() and gk20a_fifo_recover_tsg(), while the affected engines have been identified, the appropriate MMU faults triggered, and the MMU faults handled. In this case, make sure that the MMU fault does not attempt to query the hardware about the failing channel or TSG ids. This should make channel recovery more safe also in the regular (i.e., not in the interrupt handler) context. Bug 1530226 Bug 1597493 Bug 1625901 Bug 200076344 Bug 200071810 Change-Id: Ib274876908e18219c64ea41e50ca443df81d957b Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Signed-off-by: Sami Kiminki <skiminki@nvidia.com> Reviewed-on: http://git-master/r/448463 (cherry picked from commit 3f03aeae64ef2af4829e06f5f63062e8ebd21353) Reviewed-on: http://git-master/r/755147 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/debug_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/debug_gk20a.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
index 0f1c31dd..bda0dab0 100644
--- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
@@ -36,6 +36,7 @@ static struct platform_device *gk20a_device;
36 36
37struct ch_state { 37struct ch_state {
38 int pid; 38 int pid;
39 int refs;
39 u8 inst_block[0]; 40 u8 inst_block[0];
40}; 41};
41 42
@@ -118,9 +119,10 @@ static void gk20a_debug_show_channel(struct gk20a *g,
118 syncpointa = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointa_w()); 119 syncpointa = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointa_w());
119 syncpointb = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointb_w()); 120 syncpointb = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointb_w());
120 121
121 gk20a_debug_output(o, "%d-%s, pid %d: ", hw_chid, 122 gk20a_debug_output(o, "%d-%s, pid %d, refs: %d: ", hw_chid,
122 g->dev->name, 123 g->dev->name,
123 ch_state->pid); 124 ch_state->pid,
125 ch_state->refs);
124 gk20a_debug_output(o, "%s in use %s %s\n", 126 gk20a_debug_output(o, "%s in use %s %s\n",
125 ccsr_channel_enable_v(channel) ? "" : "not", 127 ccsr_channel_enable_v(channel) ? "" : "not",
126 ccsr_chan_status_str[status], 128 ccsr_chan_status_str[status],
@@ -231,16 +233,30 @@ void gk20a_debug_show_dump(struct gk20a *g, struct gk20a_debug_output *o)
231 } 233 }
232 234
233 for (chid = 0; chid < f->num_channels; chid++) { 235 for (chid = 0; chid < f->num_channels; chid++) {
234 if (f->channel[chid].in_use) 236 struct channel_gk20a *ch = &f->channel[chid];
235 ch_state[chid] = kmalloc(sizeof(struct ch_state) + ram_in_alloc_size_v(), GFP_KERNEL); 237 if (gk20a_channel_get(ch)) {
238 ch_state[chid] =
239 kmalloc(sizeof(struct ch_state) +
240 ram_in_alloc_size_v(), GFP_KERNEL);
241 /* ref taken stays to below loop with
242 * successful allocs */
243 if (!ch_state[chid])
244 gk20a_channel_put(ch);
245 }
236 } 246 }
237 247
238 for (chid = 0; chid < f->num_channels; chid++) { 248 for (chid = 0; chid < f->num_channels; chid++) {
239 if (ch_state[chid] && f->channel[chid].inst_block.cpu_va) { 249 struct channel_gk20a *ch = &f->channel[chid];
240 ch_state[chid]->pid = f->channel[chid].pid; 250 if (ch_state[chid]) {
241 memcpy(&ch_state[chid]->inst_block[0], 251 if (ch->inst_block.cpu_va) {
242 f->channel[chid].inst_block.cpu_va, 252 ch_state[chid]->pid = ch->pid;
243 ram_in_alloc_size_v()); 253 ch_state[chid]->refs =
254 atomic_read(&ch->ref_count);
255 memcpy(&ch_state[chid]->inst_block[0],
256 ch->inst_block.cpu_va,
257 ram_in_alloc_size_v());
258 }
259 gk20a_channel_put(ch);
244 } 260 }
245 } 261 }
246 for (chid = 0; chid < f->num_channels; chid++) { 262 for (chid = 0; chid < f->num_channels; chid++) {