diff options
author | Ofir Bitton <obitton@habana.ai> | 2022-02-28 15:08:20 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-22 20:57:34 +0200 |
commit | 4c3b9f6e3bd0480474666f9e016ff57ea0c5ecaa (patch) | |
tree | deb41501e3bac1d60d44810b0f1fcc3487c1d553 /drivers/misc/habanalabs/common/habanalabs_drv.c | |
parent | habanalabs: add user API to get valid DRAM page sizes (diff) | |
download | linux-4c3b9f6e3bd0480474666f9e016ff57ea0c5ecaa.tar.xz linux-4c3b9f6e3bd0480474666f9e016ff57ea0c5ecaa.zip |
habanalabs: add new return code to device fd open
In order to be more informative during device open, we are adding a
new return code -EAGAIN that indicates device is still going through
resource reclaiming and hence it cannot be used yet.
Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r-- | drivers/misc/habanalabs/common/habanalabs_drv.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/misc/habanalabs/common/habanalabs_drv.c b/drivers/misc/habanalabs/common/habanalabs_drv.c index ca404ed9d9a7..e870c32a0733 100644 --- a/drivers/misc/habanalabs/common/habanalabs_drv.c +++ b/drivers/misc/habanalabs/common/habanalabs_drv.c @@ -150,7 +150,20 @@ int hl_device_open(struct inode *inode, struct file *filp) dev_err_ratelimited(hdev->dev, "Can't open %s because it is %s\n", dev_name(hdev->dev), hdev->status[status]); - rc = -EPERM; + + if (status == HL_DEVICE_STATUS_IN_RESET) + rc = -EAGAIN; + else + rc = -EPERM; + + goto out_err; + } + + if (hdev->compute_ctx_in_release) { + dev_dbg_ratelimited(hdev->dev, + "Can't open %s because another user is still releasing it\n", + dev_name(hdev->dev)); + rc = -EAGAIN; goto out_err; } |