summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
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/fifo_gk20a.h
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/fifo_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
index dd320ae1..fdf843d2 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * GK20A graphics fifo (gr host) 4 * GK20A graphics fifo (gr host)
5 * 5 *
6 * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved. 6 * Copyright (c) 2011-2015, NVIDIA CORPORATION. All rights reserved.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License, 9 * under the terms and conditions of the GNU General Public License,
@@ -106,7 +106,9 @@ struct fifo_gk20a {
106 u32 userd_entry_size; 106 u32 userd_entry_size;
107 107
108 struct channel_gk20a *channel; 108 struct channel_gk20a *channel;
109 struct mutex ch_inuse_mutex; /* protect unused chid look up */ 109 /* zero-kref'd channels here */
110 struct list_head free_chs;
111 struct mutex free_chs_mutex;
110 112
111 struct tsg_gk20a *tsg; 113 struct tsg_gk20a *tsg;
112 struct mutex tsg_inuse_mutex; 114 struct mutex tsg_inuse_mutex;
@@ -130,7 +132,7 @@ struct fifo_gk20a {
130 132
131 } intr; 133 } intr;
132 134
133 u32 mmu_fault_engines; 135 u32 deferred_fault_engines;
134 bool deferred_reset_pending; 136 bool deferred_reset_pending;
135 struct mutex deferred_reset_mutex; 137 struct mutex deferred_reset_mutex;
136}; 138};
@@ -157,7 +159,12 @@ int gk20a_fifo_update_runlist(struct gk20a *g, u32 engine_id, u32 hw_chid,
157int gk20a_fifo_suspend(struct gk20a *g); 159int gk20a_fifo_suspend(struct gk20a *g);
158 160
159bool gk20a_fifo_mmu_fault_pending(struct gk20a *g); 161bool gk20a_fifo_mmu_fault_pending(struct gk20a *g);
160void gk20a_fifo_recover(struct gk20a *g, u32 engine_ids, bool verbose); 162
163void gk20a_fifo_recover(struct gk20a *g,
164 u32 engine_ids, /* if zero, will be queried from HW */
165 u32 hw_id, /* if ~0, will be queried from HW */
166 bool hw_id_is_tsg, /* ignored if hw_id == ~0 */
167 bool verbose);
161void gk20a_fifo_recover_ch(struct gk20a *g, u32 hw_chid, bool verbose); 168void gk20a_fifo_recover_ch(struct gk20a *g, u32 hw_chid, bool verbose);
162void gk20a_fifo_recover_tsg(struct gk20a *g, u32 tsgid, bool verbose); 169void gk20a_fifo_recover_tsg(struct gk20a *g, u32 tsgid, bool verbose);
163int gk20a_fifo_force_reset_ch(struct channel_gk20a *ch, bool verbose); 170int gk20a_fifo_force_reset_ch(struct channel_gk20a *ch, bool verbose);