diff options
author | Dalit Ben Zoor <dbenzoor@habana.ai> | 2019-03-24 09:15:44 +0100 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2019-03-24 09:15:44 +0100 |
commit | aa957088b4e846146b230e431dd9dad59e907f9a (patch) | |
tree | 26f0a463b800b7945a86eb0230cef65c8129e722 /drivers/misc/habanalabs/device.c | |
parent | habanalabs: allow user to modify TPC clock relaxation value (diff) | |
download | linux-aa957088b4e846146b230e431dd9dad59e907f9a.tar.xz linux-aa957088b4e846146b230e431dd9dad59e907f9a.zip |
habanalabs: add device status option to INFO IOCTL
This patch adds a new opcode to INFO IOCTL that returns the device status.
This will allow users to query the device status in order to avoid sending
command submissions while device is in reset.
Signed-off-by: Dalit Ben Zoor <dbenzoor@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/misc/habanalabs/device.c')
-rw-r--r-- | drivers/misc/habanalabs/device.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index c51d1062d0bc..e3797f582436 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c @@ -10,6 +10,7 @@ #include <linux/pci.h> #include <linux/sched/signal.h> #include <linux/hwmon.h> +#include <uapi/misc/habanalabs.h> #define HL_PLDM_PENDING_RESET_PER_SEC (HL_PENDING_RESET_PER_SEC * 10) @@ -21,6 +22,20 @@ bool hl_device_disabled_or_in_reset(struct hl_device *hdev) return false; } +enum hl_device_status hl_device_status(struct hl_device *hdev) +{ + enum hl_device_status status; + + if (hdev->disabled) + status = HL_DEVICE_STATUS_MALFUNCTION; + else if (atomic_read(&hdev->in_reset)) + status = HL_DEVICE_STATUS_IN_RESET; + else + status = HL_DEVICE_STATUS_OPERATIONAL; + + return status; +}; + static void hpriv_release(struct kref *ref) { struct hl_fpriv *hpriv; |