Skip to content

Commit 681a22f

Browse files
committed
habanalabs: allow to wait on CS without sleep
The user sometimes wants to check if a CS has completed to clean resources. In that case, the user doesn't want to sleep but just to check if the CS has finished and continue with his code. Add a new definition to the API of the wait on CS. The new definition says that if the timeout is 0, the driver won't sleep at all but return immediately after checking if the CS has finished. Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
1 parent 230b9b7 commit 681a22f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/misc/habanalabs/common/command_submission.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,11 @@ static long _hl_cs_wait_ioctl(struct hl_device *hdev,
11801180
"Can't wait on CS %llu because current CS is at seq %llu\n",
11811181
seq, ctx->cs_sequence);
11821182
} else if (fence) {
1183-
rc = wait_for_completion_interruptible_timeout(
1184-
&fence->completion, timeout);
1183+
if (!timeout_us)
1184+
rc = completion_done(&fence->completion);
1185+
else
1186+
rc = wait_for_completion_interruptible_timeout(
1187+
&fence->completion, timeout);
11851188

11861189
if (fence->error == -ETIMEDOUT)
11871190
rc = -ETIMEDOUT;

‎include/uapi/misc/habanalabs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,9 @@ struct hl_debug_args {
914914
* inside the kernel until the CS has finished or until the user-requested
915915
* timeout has expired.
916916
*
917+
* If the timeout value is 0, the driver won't sleep at all. It will check
918+
* the status of the CS and return immediately
919+
*
917920
* The return value of the IOCTL is a standard Linux error code. The possible
918921
* values are:
919922
*

0 commit comments

Comments
 (0)