Skip to content

Commit 053caa2

Browse files
committed
habanalabs: remove unnecessary device status check
Checking if the device is operational when entering the function to wait for user interrupt is not something that is useful or necessary. It is not done in any other wait_for_cs ioctl path. If the device becomes non-operational during the wait, the reset function will make sure the process wait is interrupted. Instead, move the check to the beginning of hl_wait_ioctl(). It will block any attempt to wait on CS or user interrupt once the device is already marked as non-operational. Signed-off-by: Oded Gabbay <[email protected]>
1 parent 176d23a commit 053caa2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/misc/habanalabs/common/command_submission.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,10 +2741,6 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
27412741
interrupt = &hdev->user_interrupt[interrupt_offset];
27422742

27432743
spin_lock_irqsave(&interrupt->wait_list_lock, flags);
2744-
if (!hl_device_operational(hdev, NULL)) {
2745-
rc = -EPERM;
2746-
goto unlock_and_free_fence;
2747-
}
27482744

27492745
if (copy_from_user(&completion_value, u64_to_user_ptr(user_address),
27502746
4)) {
@@ -2891,6 +2887,12 @@ int hl_wait_ioctl(struct hl_fpriv *hpriv, void *data)
28912887
u32 flags = args->in.flags;
28922888
int rc;
28932889

2890+
/* If the device is not operational, no point in waiting for any command submission or
2891+
* user interrupt
2892+
*/
2893+
if (!hl_device_operational(hpriv->hdev, NULL))
2894+
return -EPERM;
2895+
28942896
if (flags & HL_WAIT_CS_FLAGS_INTERRUPT)
28952897
rc = hl_interrupt_wait_ioctl(hpriv, data);
28962898
else if (flags & HL_WAIT_CS_FLAGS_MULTI_CS)

0 commit comments

Comments
 (0)