Skip to content

Commit 3292055

Browse files
ofirbittogabbay
authored andcommitted
habanalabs: Correct handling when failing to enqueue CB
The fence release flow is different if the CS was never submitted. In that case, we don't have an hw_sob object attached that we need to "put". While if the CS was aborted, we do need to "put" the hw_sob. Signed-off-by: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 647e835 commit 3292055

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/misc/habanalabs/command_submission.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ static void hl_fence_release(struct dma_fence *fence)
6262
container_of(fence, struct hl_cs_compl, base_fence);
6363
struct hl_device *hdev = hl_cs_cmpl->hdev;
6464

65+
/* EBUSY means the CS was never submitted and hence we don't have
66+
* an attached hw_sob object that we should handle here
67+
*/
68+
if (fence->error == -EBUSY)
69+
goto free;
70+
6571
if ((hl_cs_cmpl->type == CS_TYPE_SIGNAL) ||
6672
(hl_cs_cmpl->type == CS_TYPE_WAIT)) {
6773

@@ -92,6 +98,7 @@ static void hl_fence_release(struct dma_fence *fence)
9298
kref_put(&hl_cs_cmpl->hw_sob->kref, hl_sob_reset);
9399
}
94100

101+
free:
95102
kfree_rcu(hl_cs_cmpl, base_fence.rcu);
96103
}
97104

@@ -328,10 +335,16 @@ static void cs_do_release(struct kref *ref)
328335

329336
hl_ctx_put(cs->ctx);
330337

338+
/* We need to mark an error for not submitted because in that case
339+
* the dma fence release flow is different. Mainly, we don't need
340+
* to handle hw_sob for signal/wait
341+
*/
331342
if (cs->timedout)
332343
dma_fence_set_error(cs->fence, -ETIMEDOUT);
333344
else if (cs->aborted)
334345
dma_fence_set_error(cs->fence, -EIO);
346+
else if (!cs->submitted)
347+
dma_fence_set_error(cs->fence, -EBUSY);
335348

336349
dma_fence_signal(cs->fence);
337350
dma_fence_put(cs->fence);

0 commit comments

Comments
 (0)