summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os
diff options
context:
space:
mode:
authorNitin Kumbhar <nkumbhar@nvidia.com>2018-06-11 06:01:33 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-26 03:06:07 -0400
commitb4b1fb97bd095fa0de72550b04dc414b0194903e (patch)
treeefef55fc52463a4278b3d01f0eaf165d3c677657 /drivers/gpu/nvgpu/os
parentd80e8168755da80987a654b910a5ce1f6f273223 (diff)
gpu: nvgpu: shutdown nvlink in driver remove
During driver remove, if nvlink is set up, gracefully shut it down so that it can be enumerated again. Bug 1987855 Change-Id: Ibd83a5e29364b22264e689aa879569a9cccf0f79 Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1746073 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-rw-r--r--drivers/gpu/nvgpu/os/linux/nvlink.c26
-rw-r--r--drivers/gpu/nvgpu/os/linux/nvlink.h22
-rw-r--r--drivers/gpu/nvgpu/os/linux/pci.c8
3 files changed, 53 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/nvlink.c b/drivers/gpu/nvgpu/os/linux/nvlink.c
index c93514c0..0db483d6 100644
--- a/drivers/gpu/nvgpu/os/linux/nvlink.c
+++ b/drivers/gpu/nvgpu/os/linux/nvlink.c
@@ -14,6 +14,10 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#ifdef CONFIG_TEGRA_NVLINK
18#include <linux/platform/tegra/tegra-nvlink.h>
19#endif
20
17#include <gk20a/gk20a.h> 21#include <gk20a/gk20a.h>
18#include <nvgpu/nvlink.h> 22#include <nvgpu/nvlink.h>
19#include <nvgpu/enabled.h> 23#include <nvgpu/enabled.h>
@@ -104,3 +108,25 @@ void nvgpu_mss_nvlink_init_credits(struct gk20a *g)
104 val = readl_relaxed(soc4 + 4); 108 val = readl_relaxed(soc4 + 4);
105 writel_relaxed(val, soc4 + 4); 109 writel_relaxed(val, soc4 + 4);
106} 110}
111
112int nvgpu_nvlink_deinit(struct gk20a *g)
113{
114#ifdef CONFIG_TEGRA_NVLINK
115 struct nvlink_device *ndev = g->nvlink.priv;
116 int err;
117
118 if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_NVLINK))
119 return -ENODEV;
120
121 err = nvlink_shutdown(ndev);
122 if (err) {
123 nvgpu_err(g, "failed to shut down nvlink");
124 return err;
125 }
126
127 nvgpu_nvlink_remove(g);
128
129 return 0;
130#endif
131 return -ENODEV;
132}
diff --git a/drivers/gpu/nvgpu/os/linux/nvlink.h b/drivers/gpu/nvgpu/os/linux/nvlink.h
new file mode 100644
index 00000000..4dc54f6f
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/nvlink.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef NVGPU_OS_LINUX_NVLINK_H
18
19struct gk20a;
20int nvgpu_nvlink_deinit(struct gk20a *g);
21
22#endif
diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c
index 41fb69a0..ee4bcf8c 100644
--- a/drivers/gpu/nvgpu/os/linux/pci.c
+++ b/drivers/gpu/nvgpu/os/linux/pci.c
@@ -26,7 +26,9 @@
26#include <nvgpu/enabled.h> 26#include <nvgpu/enabled.h>
27#include <nvgpu/nvlink.h> 27#include <nvgpu/nvlink.h>
28#include <nvgpu/soc.h> 28#include <nvgpu/soc.h>
29#include <nvgpu/sim.h>
29 30
31#include "nvlink.h"
30#include "gk20a/gk20a.h" 32#include "gk20a/gk20a.h"
31#include "clk/clk.h" 33#include "clk/clk.h"
32#include "clk/clk_mclk.h" 34#include "clk/clk_mclk.h"
@@ -35,12 +37,10 @@
35#include "sysfs.h" 37#include "sysfs.h"
36#include "os_linux.h" 38#include "os_linux.h"
37#include "platform_gk20a.h" 39#include "platform_gk20a.h"
38#include <nvgpu/sim.h>
39 40
40#include "pci.h" 41#include "pci.h"
41#include "pci_usermode.h" 42#include "pci_usermode.h"
42 43
43#include "os_linux.h"
44#include "driver_common.h" 44#include "driver_common.h"
45 45
46#define PCI_INTERFACE_NAME "card-%s%%s" 46#define PCI_INTERFACE_NAME "card-%s%%s"
@@ -828,9 +828,11 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
828 if (gk20a_gpu_is_virtual(dev)) 828 if (gk20a_gpu_is_virtual(dev))
829 return; 829 return;
830 830
831 nvgpu_nvlink_remove(g); 831 err = nvgpu_nvlink_deinit(g);
832 WARN(err, "gpu failed to remove nvlink");
832 833
833 gk20a_driver_start_unload(g); 834 gk20a_driver_start_unload(g);
835
834 err = nvgpu_quiesce(g); 836 err = nvgpu_quiesce(g);
835 /* TODO: handle failure to idle */ 837 /* TODO: handle failure to idle */
836 WARN(err, "gpu failed to idle during driver removal"); 838 WARN(err, "gpu failed to idle during driver removal");