diff options
author | Oded Gabbay | 2019-02-16 00:39:20 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-02-18 09:46:45 +0100 |
commit | f8c8c7d5f1b0ea85fe6b4fe2dc63d72774a29184 (patch) | |
tree | c04933e9efcdcf80b3f57ddd22bb31d17c76eacb /drivers/misc/habanalabs/habanalabs_drv.c | |
parent | d91389bc839d724cd8df7ca308dde97beca9b0c5 (diff) |
habanalabs: add device reset support
This patch adds support for doing various on-the-fly reset of Goya.
The driver supports two types of resets:
1. soft-reset
2. hard-reset
Soft-reset is done when the device detects a timeout of a command
submission that was given to the device. The soft-reset process only resets
the engines that are relevant for the submission of compute jobs, i.e. the
DMA channels, the TPCs and the MME. The purpose is to bring the device as
fast as possible to a working state.
Hard-reset is done in several cases:
1. After soft-reset is done but the device is not responding
2. When fatal errors occur inside the device, e.g. ECC error
3. When the driver is removed
Hard-reset performs a reset of the entire chip except for the PCI
controller and the PLLs. It is a much longer process then soft-reset but it
helps to recover the device without the need to reboot the Host.
After hard-reset, the driver will restore the max power attribute and in
case of manual power management, the frequencies that were set.
This patch also adds two entries to the sysfs, which allows the root user
to initiate a soft or hard reset.
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/habanalabs/habanalabs_drv.c')
-rw-r--r-- | drivers/misc/habanalabs/habanalabs_drv.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/misc/habanalabs/habanalabs_drv.c b/drivers/misc/habanalabs/habanalabs_drv.c index 4f3d68395b98..b0bf77af1e40 100644 --- a/drivers/misc/habanalabs/habanalabs_drv.c +++ b/drivers/misc/habanalabs/habanalabs_drv.c @@ -84,9 +84,9 @@ int hl_device_open(struct inode *inode, struct file *filp) mutex_lock(&hdev->fd_open_cnt_lock); - if (hdev->disabled) { + if (hl_device_disabled_or_in_reset(hdev)) { dev_err_ratelimited(hdev->dev, - "Can't open %s because it is disabled\n", + "Can't open %s because it is disabled or in reset\n", dev_name(hdev->dev)); mutex_unlock(&hdev->fd_open_cnt_lock); return -EPERM; @@ -179,6 +179,7 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev, hdev->cpu_queues_enable = 1; hdev->fw_loading = 1; hdev->pldm = 0; + hdev->heartbeat = 1; /* If CPU is disabled, no point in loading FW */ if (!hdev->cpu_enable) @@ -188,6 +189,10 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev, if (!hdev->fw_loading) hdev->cpu_queues_enable = 0; + /* If CPU queues not enabled, no way to do heartbeat */ + if (!hdev->cpu_queues_enable) + hdev->heartbeat = 0; + hdev->disabled = true; hdev->pdev = pdev; /* can be NULL in case of simulator device */ |