summaryrefslogtreecommitdiffstats
path: root/drivers/misc/habanalabs/memory.c
diff options
context:
space:
mode:
authorOded Gabbay2019-04-06 14:41:35 +0200
committerOded Gabbay2019-04-06 14:41:35 +0200
commit3f5398cfbf051dc1850b4f64fbe5267cbd699ce0 (patch)
treeff654ad945202a88870b42a13da865d8397a36d9 /drivers/misc/habanalabs/memory.c
parenthabanalabs: all FD must be closed before removing device (diff)
downloadkernel-qcow2-linux-3f5398cfbf051dc1850b4f64fbe5267cbd699ce0.tar.gz
kernel-qcow2-linux-3f5398cfbf051dc1850b4f64fbe5267cbd699ce0.tar.xz
kernel-qcow2-linux-3f5398cfbf051dc1850b4f64fbe5267cbd699ce0.zip
habanalabs: improve IOCTLs behavior when disabled or reset
This patch makes some improvement in how IOCTLs behave when the device is disabled or under reset. The new code checks, at the start of every IOCTL, if the device is disabled or in reset. If so, it prints an appropriate kernel message and returns -EBUSY to user-space. In addition, the code modifies the location of where the hard_reset_pending flag is being set or cleared: 1. It is now cleared immediately after the reset *tear-down* flow is finished but before the re-initialization flow begins. 2. It is being set in the remove function of the device, to make the behavior the same with the hard-reset flow There are two exceptions to the disable or in reset check: 1. The HL_INFO_DEVICE_STATUS opcode in the INFO IOCTL. This opcode allows the user to inquire about the status of the device, whether it is operational, in reset or malfunction (disabled). If the driver will block this IOCTL, the user won't be able to retrieve the status in case of malfunction or in reset. 2. The WAIT_FOR_CS IOCTL. This IOCTL allows the user to inquire about the status of a CS. We want to allow the user to continue to do so, even if we started a soft-reset process because it will allow the user to get the correct error code for each CS he submitted. Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/misc/habanalabs/memory.c')
-rw-r--r--drivers/misc/habanalabs/memory.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/misc/habanalabs/memory.c b/drivers/misc/habanalabs/memory.c
index 05919f913300..43ef3ad8438a 100644
--- a/drivers/misc/habanalabs/memory.c
+++ b/drivers/misc/habanalabs/memory.c
@@ -1159,7 +1159,8 @@ int hl_mem_ioctl(struct hl_fpriv *hpriv, void *data)
if (hl_device_disabled_or_in_reset(hdev)) {
dev_warn_ratelimited(hdev->dev,
- "Device is disabled or in reset. Can't execute memory IOCTL\n");
+ "Device is %s. Can't execute MEMORY IOCTL\n",
+ atomic_read(&hdev->in_reset) ? "in_reset" : "disabled");
return -EBUSY;
}