gpu: nvgpu: Handle driver shutdown more gracefully

Handle possible asynchronous GPU driver shutdown more gracefully.
This occurs when the GPU disappears from the PCI bus, for example,
if it overheats or detects an over current event.

Also add a preprocessor check to make sure that the

  gk20a_channel_cancel_pending_sema_waits()

is always defined. In some builds CONFIG_SYNC is disabled but the
gk20a_remove_support() code does not check for this.

Bug 1816516
Bug 1807277

Change-Id: I932e312291c5c6a6ac5e13525ce8ca56a1be3652
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1250028
(cherry picked from commit 337810f8c478238a38d8553c1492622d5fa9aafa)
Reviewed-on: http://git-master/r/1274476
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Alex Waterman
2016-11-08 11:31:05 -08:00
committed by mobile promotions
parent 9e2f7d98d4
commit c116522b10
4 changed files with 34 additions and 2 deletions

View File

@@ -356,10 +356,25 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
struct gk20a_platform *platform = gk20a_get_platform(&pdev->dev);
struct gk20a *g = get_gk20a(&pdev->dev);
if (g->remove_support)
g->remove_support(g->dev);
gk20a_dbg(gpu_dbg_shutdown, "Removing nvgpu driver!\n");
gk20a_driver_start_unload(g);
disable_irq(g->irq_stall);
devm_free_irq(&pdev->dev, g->irq_stall, g);
gk20a_dbg(gpu_dbg_shutdown, "IRQs disabled.\n");
/*
* Wait for the driver to finish up all the IOCTLs it's working on
* before cleaning up the driver's data structures.
*/
gk20a_wait_for_idle(&pdev->dev);
gk20a_dbg(gpu_dbg_shutdown, "Driver idle.\n");
gk20a_user_deinit(g->dev, &nvgpu_pci_class);
gk20a_dbg(gpu_dbg_shutdown, "User de-init done.\b");
if (g->remove_support)
g->remove_support(g->dev);
debugfs_remove_recursive(platform->debugfs);
debugfs_remove_recursive(platform->debugfs_alias);
@@ -368,6 +383,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
if (platform->remove)
platform->remove(g->dev);
gk20a_dbg(gpu_dbg_shutdown, "Platform remove done.\b");
kfree(g);
}