summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
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
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')
-rw-r--r--drivers/gpu/nvgpu/common/nvlink.c11
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c1
-rw-r--r--drivers/gpu/nvgpu/gv100/nvlink_gv100.c5
-rw-r--r--drivers/gpu/nvgpu/gv100/nvlink_gv100.h1
-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
8 files changed, 72 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/common/nvlink.c b/drivers/gpu/nvgpu/common/nvlink.c
index 6bfc154c..b13e5942 100644
--- a/drivers/gpu/nvgpu/common/nvlink.c
+++ b/drivers/gpu/nvgpu/common/nvlink.c
@@ -92,6 +92,16 @@ static int nvgpu_nvlink_interface_init(struct nvlink_device *ndev)
92 return err; 92 return err;
93} 93}
94 94
95static int nvgpu_nvlink_interface_disable(struct nvlink_device *ndev)
96{
97 int err = 0;
98 struct gk20a *g = (struct gk20a *) ndev->priv;
99
100 if (g->ops.nvlink.interface_disable)
101 err = g->ops.nvlink.interface_disable(g);
102 return err;
103}
104
95static int nvgpu_nvlink_shutdown(struct nvlink_device *ndev) 105static int nvgpu_nvlink_shutdown(struct nvlink_device *ndev)
96{ 106{
97 int err; 107 int err;
@@ -401,6 +411,7 @@ static int nvgpu_nvlink_init_ops(struct gk20a *g)
401 ndev->dev_ops.dev_early_init = nvgpu_nvlink_early_init; 411 ndev->dev_ops.dev_early_init = nvgpu_nvlink_early_init;
402 ndev->dev_ops.dev_interface_init = nvgpu_nvlink_interface_init; 412 ndev->dev_ops.dev_interface_init = nvgpu_nvlink_interface_init;
403 ndev->dev_ops.dev_reg_init = nvgpu_nvlink_reg_init; 413 ndev->dev_ops.dev_reg_init = nvgpu_nvlink_reg_init;
414 ndev->dev_ops.dev_interface_disable = nvgpu_nvlink_interface_disable;
404 ndev->dev_ops.dev_shutdown = nvgpu_nvlink_shutdown; 415 ndev->dev_ops.dev_shutdown = nvgpu_nvlink_shutdown;
405 416
406 /* Fill in the link struct */ 417 /* Fill in the link struct */
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 4fe93e3b..0df111c8 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -1267,6 +1267,7 @@ struct gpu_ops {
1267 int (*set_sublink_mode)(struct gk20a *g, u32 link_id, 1267 int (*set_sublink_mode)(struct gk20a *g, u32 link_id,
1268 bool is_rx_sublink, u32 mode); 1268 bool is_rx_sublink, u32 mode);
1269 int (*interface_init)(struct gk20a *g); 1269 int (*interface_init)(struct gk20a *g);
1270 int (*interface_disable)(struct gk20a *g);
1270 int (*reg_init)(struct gk20a *g); 1271 int (*reg_init)(struct gk20a *g);
1271 int (*shutdown)(struct gk20a *g); 1272 int (*shutdown)(struct gk20a *g);
1272 int (*early_init)(struct gk20a *g); 1273 int (*early_init)(struct gk20a *g);
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index 6ebf1675..6339110e 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -896,6 +896,7 @@ static const struct gpu_ops gv100_ops = {
896 .get_rx_sublink_state = gv100_nvlink_link_get_rx_sublink_state, 896 .get_rx_sublink_state = gv100_nvlink_link_get_rx_sublink_state,
897 .set_sublink_mode = gv100_nvlink_link_set_sublink_mode, 897 .set_sublink_mode = gv100_nvlink_link_set_sublink_mode,
898 .interface_init = gv100_nvlink_interface_init, 898 .interface_init = gv100_nvlink_interface_init,
899 .interface_disable = gv100_nvlink_interface_disable,
899 .reg_init = gv100_nvlink_reg_init, 900 .reg_init = gv100_nvlink_reg_init,
900 .shutdown = gv100_nvlink_shutdown, 901 .shutdown = gv100_nvlink_shutdown,
901 .early_init = gv100_nvlink_early_init, 902 .early_init = gv100_nvlink_early_init,
diff --git a/drivers/gpu/nvgpu/gv100/nvlink_gv100.c b/drivers/gpu/nvgpu/gv100/nvlink_gv100.c
index c328dd70..41c2cd2b 100644
--- a/drivers/gpu/nvgpu/gv100/nvlink_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/nvlink_gv100.c
@@ -2269,6 +2269,11 @@ int gv100_nvlink_interface_init(struct gk20a *g)
2269 return 0; 2269 return 0;
2270} 2270}
2271 2271
2272int gv100_nvlink_interface_disable(struct gk20a *g)
2273{
2274 return 0;
2275}
2276
2272int gv100_nvlink_reg_init(struct gk20a *g) 2277int gv100_nvlink_reg_init(struct gk20a *g)
2273{ 2278{
2274 u32 i = 0; 2279 u32 i = 0;
diff --git a/drivers/gpu/nvgpu/gv100/nvlink_gv100.h b/drivers/gpu/nvgpu/gv100/nvlink_gv100.h
index 6310af28..75595bca 100644
--- a/drivers/gpu/nvgpu/gv100/nvlink_gv100.h
+++ b/drivers/gpu/nvgpu/gv100/nvlink_gv100.h
@@ -50,6 +50,7 @@ u32 gv100_nvlink_link_get_rx_sublink_state(struct gk20a *g, u32 link_id);
50int gv100_nvlink_link_set_sublink_mode(struct gk20a *g, u32 link_id, 50int gv100_nvlink_link_set_sublink_mode(struct gk20a *g, u32 link_id,
51 bool is_rx_sublink, u32 mode); 51 bool is_rx_sublink, u32 mode);
52int gv100_nvlink_interface_init(struct gk20a *g); 52int gv100_nvlink_interface_init(struct gk20a *g);
53int gv100_nvlink_interface_disable(struct gk20a *g);
53int gv100_nvlink_reg_init(struct gk20a *g); 54int gv100_nvlink_reg_init(struct gk20a *g);
54int gv100_nvlink_shutdown(struct gk20a *g); 55int gv100_nvlink_shutdown(struct gk20a *g);
55int gv100_nvlink_early_init(struct gk20a *g); 56int gv100_nvlink_early_init(struct gk20a *g);
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");