gpu: nvgpu: refactor teardown to support unbind

This change refactors the teardown in remove to ensure that it is
possible to unload the driver while leaving fds open. This is achieved
by making sure that the SW state is kept alive till all fds are closed
and by checking that subsequent calls to ioctls after the teardown fail.

Normally, this would be achieved ny calls into gk20a_busy(), but in
kickoff we dont call into that to reduce latency, so we need to check
the driver status directly, and also in some of the functions
as we need to make sure the ioctl does not dereference the device or
platform struct

bug 200277762
JIRA: EVLR-1023

Change-Id: I163e47a08c29d4d5b3ab79f0eb531ef234f40bde
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1320219
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Shreshtha Sahu <ssahu@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
This commit is contained in:
David Nieto
2017-03-13 20:23:03 -07:00
committed by mobile promotions
parent b48186488d
commit e0f2afe5eb
10 changed files with 91 additions and 61 deletions

View File

@@ -393,6 +393,11 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
}
disable_irq(g->irq_stall);
/*
* is_fmodel needs to be in gk20a struct for deferred teardown
*/
g->is_fmodel = platform->is_fmodel;
err = nvgpu_pci_init_support(pdev);
if (err)
return err;
@@ -426,7 +431,6 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
struct gk20a *g = get_gk20a(&pdev->dev);
gk20a_dbg(gpu_dbg_shutdown, "Removing nvgpu driver!\n");
gk20a_driver_start_unload(g);
if (g->irqs_enabled)
disable_irq(g->irq_stall);
@@ -445,7 +449,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
* 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_driver_start_unload(g);
gk20a_dbg(gpu_dbg_shutdown, "Driver idle.\n");
#ifdef CONFIG_ARCH_TEGRA_18x_SOC
@@ -455,9 +459,6 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
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);