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 <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2393565
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
This commit is contained in:
Tejal Kudav
2020-08-03 09:11:51 +00:00
committed by Alex Waterman
parent 2012a6b558
commit 87a8e8980a

View File

@@ -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");
}