From 469308becaff326da02fcf791e803e812e1cf9f8 Mon Sep 17 00:00:00 2001 From: David Nieto Date: Mon, 13 Feb 2017 11:22:59 -0800 Subject: gpu: nvgpu: fix arbiter teardown on PCI The driver is not properly tearing down the arbiter on the PCI driver unload. This change makes sure that the workqueues are drained before tearing down the driver bug 200277762 JIRA: EVLR-1023 Change-Id: If98fd00e27949ba1569dd26e2af02b75897231a7 Signed-off-by: David Nieto Reviewed-on: http://git-master/r/1320147 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 5a4a2251..753623fa 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c @@ -39,6 +39,7 @@ struct gk20a_ctrl_priv { struct device *dev; + struct gk20a *g; #ifdef CONFIG_ARCH_TEGRA_18x_SOC struct nvgpu_clk_session *clk_session; #endif @@ -58,35 +59,42 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) priv = kzalloc(sizeof(struct gk20a_ctrl_priv), GFP_KERNEL); if (!priv) return -ENOMEM; - filp->private_data = priv; priv->dev = g->dev; + /* + * We dont close the arbiter fd's after driver teardown to support + * GPU_LOST events, so we store g here, instead of dereferencing the + * dev structure on teardown + */ + priv->g = g; if (!g->gr.sw_ready) { err = gk20a_busy(g->dev); if (err) return err; - gk20a_idle(g->dev); } #ifdef CONFIG_ARCH_TEGRA_18x_SOC err = nvgpu_clk_arb_init_session(g, &priv->clk_session); + if (err) + return err; #endif + return err; } - int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) { struct gk20a_ctrl_priv *priv = filp->private_data; + struct gk20a *g = priv->g; gk20a_dbg_fn(""); #ifdef CONFIG_ARCH_TEGRA_18x_SOC if (priv->clk_session) - nvgpu_clk_arb_release_session(gk20a_from_dev(priv->dev), - priv->clk_session); + nvgpu_clk_arb_release_session(g, priv->clk_session); #endif + kfree(priv); return 0; -- cgit v1.2.2