diff options
author | Oded Gabbay <oded.gabbay@gmail.com> | 2019-05-04 16:36:06 +0200 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2019-05-04 16:36:06 +0200 |
commit | 19734970c98b075e0159bf494d4287820522cc80 (patch) | |
tree | ee22af5b4a7e997c6577769c82f172c76ab62ed6 /drivers/misc/habanalabs/habanalabs_drv.c | |
parent | habanalabs: minor documentation and prints fixes (diff) | |
download | linux-19734970c98b075e0159bf494d4287820522cc80.tar.xz linux-19734970c98b075e0159bf494d4287820522cc80.zip |
habanalabs: force user to set device debug mode
This patch adds the implementation of the HL_DEBUG_OP_SET_MODE opcode in
the DEBUG IOCTL.
It forces the user who wants to debug the device to set the device into
debug mode before he can configure the debug engines. The patch also makes
sure to disable debug mode upon user releasing FD, in case the user forgot
to disable debug mode.
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/misc/habanalabs/habanalabs_drv.c')
-rw-r--r-- | drivers/misc/habanalabs/habanalabs_drv.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/habanalabs_drv.c b/drivers/misc/habanalabs/habanalabs_drv.c index d8b47bb4729c..42a8c0b7279a 100644 --- a/drivers/misc/habanalabs/habanalabs_drv.c +++ b/drivers/misc/habanalabs/habanalabs_drv.c @@ -105,6 +105,14 @@ int hl_device_open(struct inode *inode, struct file *filp) return -EPERM; } + if (hdev->in_debug) { + dev_err_ratelimited(hdev->dev, + "Can't open %s because it is being debugged by another user\n", + dev_name(hdev->dev)); + mutex_unlock(&hdev->fd_open_cnt_lock); + return -EPERM; + } + if (atomic_read(&hdev->fd_open_cnt)) { dev_info_ratelimited(hdev->dev, "Can't open %s because another user is working on it\n", |