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>
This commit is contained in:
Nitin Kumbhar
2018-06-11 15:31:33 +05:30
committed by mobile promotions
parent d80e816875
commit b4b1fb97bd
8 changed files with 72 additions and 3 deletions

View File

@@ -14,6 +14,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef CONFIG_TEGRA_NVLINK
#include <linux/platform/tegra/tegra-nvlink.h>
#endif
#include <gk20a/gk20a.h>
#include <nvgpu/nvlink.h>
#include <nvgpu/enabled.h>
@@ -104,3 +108,25 @@ void nvgpu_mss_nvlink_init_credits(struct gk20a *g)
val = readl_relaxed(soc4 + 4);
writel_relaxed(val, soc4 + 4);
}
int nvgpu_nvlink_deinit(struct gk20a *g)
{
#ifdef CONFIG_TEGRA_NVLINK
struct nvlink_device *ndev = g->nvlink.priv;
int err;
if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_NVLINK))
return -ENODEV;
err = nvlink_shutdown(ndev);
if (err) {
nvgpu_err(g, "failed to shut down nvlink");
return err;
}
nvgpu_nvlink_remove(g);
return 0;
#endif
return -ENODEV;
}