diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2015-03-06 09:33:43 -0500 |
---|---|---|
committer | Terje Bergstrom <tbergstrom@nvidia.com> | 2015-06-09 14:13:43 -0400 |
commit | 6085c90f499c642bc41a646b0efbdfe60e096c74 (patch) | |
tree | 0eaab99b228ce162ec3a44d0f8138b441f5a64f4 /drivers/gpu/nvgpu/vgpu | |
parent | a41e5c41cadaa3d030a1f75b09328b8b1a440b69 (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/vgpu')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 68a31eca..23ff8677 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | |||
@@ -283,6 +283,9 @@ static int vgpu_init_fifo_setup_sw(struct gk20a *g) | |||
283 | 283 | ||
284 | init_runlist(g, f); | 284 | init_runlist(g, f); |
285 | 285 | ||
286 | INIT_LIST_HEAD(&f->free_chs); | ||
287 | mutex_init(&f->free_chs_mutex); | ||
288 | |||
286 | for (chid = 0; chid < f->num_channels; chid++) { | 289 | for (chid = 0; chid < f->num_channels; chid++) { |
287 | f->channel[chid].userd_cpu_va = | 290 | f->channel[chid].userd_cpu_va = |
288 | f->userd.cpu_va + chid * f->userd_entry_size; | 291 | f->userd.cpu_va + chid * f->userd_entry_size; |
@@ -294,7 +297,6 @@ static int vgpu_init_fifo_setup_sw(struct gk20a *g) | |||
294 | 297 | ||
295 | gk20a_init_channel_support(g, chid); | 298 | gk20a_init_channel_support(g, chid); |
296 | } | 299 | } |
297 | mutex_init(&f->ch_inuse_mutex); | ||
298 | 300 | ||
299 | f->deferred_reset_pending = false; | 301 | f->deferred_reset_pending = false; |
300 | mutex_init(&f->deferred_reset_mutex); | 302 | mutex_init(&f->deferred_reset_mutex); |