diff options
author | David Nieto <dmartineznie@nvidia.com> | 2017-09-18 23:31:28 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-09-22 18:44:25 -0400 |
commit | 7134e9e852116f86745cd23312bbfba34100bf6d (patch) | |
tree | 763a9db89290450a37ad19d7f57acfa66ce33526 /drivers/gpu/nvgpu/gk20a/channel_gk20a.c | |
parent | f6fcecfc6f437a6d24aa113f75e43cb6dbbd5e0f (diff) |
gpu: nvgpu: prevent crash during unbind
This change solves crashes during bind that were introduced in the driver
during the OS unification refactoring due to lack of coverage of the remove()
function.
The fixes during remove are:
(1) Prevent NULL dereference on GPUs with secure boot
(2) Prevent NULL dereferences when fecs_trace is not enabled
(3) Added PRAMIN blocker during driver removal if HW is no longer accesible
(4) Prevent double free of debugfs nodes as they are handled on the
debugfs_remove_recursive() call
(5) quiesce() can now be called without checking is HW accesible flag is set
(6) added function to free irq so no IRQ association is left on the driver after
it is removed
(7) prevent NULL dereference on nvgpu_thread_stop() if the thread is already
stopped
JIRA: EVLR-1739
Change-Id: I787d38f202d5267a6b34815f23e1bc88110e8455
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1563005
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 0b8422a6..ea69d7cb 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c | |||
@@ -465,21 +465,30 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) | |||
465 | 465 | ||
466 | trace_gk20a_free_channel(ch->chid); | 466 | trace_gk20a_free_channel(ch->chid); |
467 | 467 | ||
468 | /* abort channel and remove from runlist */ | 468 | /* |
469 | if (gk20a_is_channel_marked_as_tsg(ch)) { | 469 | * Disable channel/TSG and unbind here. This should not be executed if |
470 | err = g->ops.fifo.tsg_unbind_channel(ch); | 470 | * HW access is not available during shutdown/removal path as it will |
471 | if (err) | 471 | * trigger a timeout |
472 | nvgpu_err(g, "failed to unbind channel %d from TSG", ch->chid); | 472 | */ |
473 | /* | 473 | if (!nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) { |
474 | * Channel is not a part of TSG this point onwards | 474 | /* abort channel and remove from runlist */ |
475 | * So stash its status and use it whenever necessary | 475 | if (gk20a_is_channel_marked_as_tsg(ch)) { |
476 | * e.g. while releasing gr_ctx in g->ops.gr.free_channel_ctx() | 476 | err = g->ops.fifo.tsg_unbind_channel(ch); |
477 | */ | 477 | if (err) |
478 | was_tsg = true; | 478 | nvgpu_err(g, |
479 | } else { | 479 | "failed to unbind channel %d from TSG", |
480 | gk20a_disable_channel(ch); | 480 | ch->chid); |
481 | /* | ||
482 | * Channel is not a part of TSG this point onwards | ||
483 | * So stash its status and use it whenever necessary | ||
484 | * e.g. while releasing gr_ctx in | ||
485 | * g->ops.gr.free_channel_ctx() | ||
486 | */ | ||
487 | was_tsg = true; | ||
488 | } else { | ||
489 | gk20a_disable_channel(ch); | ||
490 | } | ||
481 | } | 491 | } |
482 | |||
483 | /* wait until there's only our ref to the channel */ | 492 | /* wait until there's only our ref to the channel */ |
484 | if (!force) | 493 | if (!force) |
485 | gk20a_wait_until_counter_is_N( | 494 | gk20a_wait_until_counter_is_N( |