From 87a8e8980abf30f85908ecbfd6d22ef6fa9f42d7 Mon Sep 17 00:00:00 2001 From: Tejal Kudav Date: Mon, 3 Aug 2020 09:11:51 +0000 Subject: [PATCH] gpu: nvgpu: Correct dGPU shutdown path Currently, we just deinitialize the nvlink in the shutdown path. This alone is not sufficient and can lead to someone trying to use dGPU while being shutdown. Avoid triggers to dGPU usage by - 1. Set NVGPU_DRIVER_IS_DYING to let users know that the driver is currently in the process of dying. 2. Disable IRQs 3. Prepare for poweroff using nvgpu_prepare_poweroff 4. Stop CPU from accessing GPU registers 5. Set GPU state to POWEROFF Bug 200601517 JIRA NVGPU-5991 Change-Id: Ie185516618678bb893bcc3c3dcb514701483ecf2 Signed-off-by: Tejal Kudav Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2393565 Tested-by: mobile promotions Reviewed-by: mobile promotions Reviewed-by: automaticguardword --- drivers/gpu/nvgpu/os/linux/pci.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index 5046d93f5..57474439f 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -794,14 +794,24 @@ void nvgpu_pci_shutdown(struct pci_dev *pdev) return; } + gk20a_driver_start_unload(g); + + if (nvgpu_is_enabled(g, NVGPU_SUPPORT_DGPU_THERMAL_ALERT) && + nvgpu_platform_is_silicon(g)) { + nvgpu_thermal_deinit(g); + } + if (is_nvgpu_gpu_state_valid(g)) { err = nvgpu_nvlink_deinit(g); /* ENODEV is a legal error if there is no NVLINK */ if (err != -ENODEV) { WARN(err, "gpu failed to remove nvlink"); } - } else - nvgpu_err(g, "skipped nvlink deinit"); + err = nvgpu_quiesce(g); + WARN(err, "gpu failed to idle during shutdown"); + } else { + nvgpu_err(g, "skipped nvlink deinit and HW quiesce"); + } nvgpu_info(g, "shut down complete"); }