Skip to content

Commit 0165994

Browse files
Farah-kassabriogabbay
authored andcommitted
accel/habanalabs: fix bug in timestamp interrupt handling
There is a potential race between user thread seeking to re-use a timestamp record with new interrupt id, while this record is still in the middle of interrupt handling and it is about to be freed. Imagine the driver set the record in_use to 0 and only then fill the free_node information. This might lead to unpleasant scenario where the new registration thread detects the record as free to use, and change the cq buff address. That will cause the free_node to get the wrong buffer address to put refcount to. Signed-off-by: farah kassabri <fkassabri@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
1 parent d89d329 commit 0165994

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • drivers/accel/habanalabs/common

drivers/accel/habanalabs/common/irq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ static int handle_registration_node(struct hl_device *hdev, struct hl_user_pendi
259259
dev_dbg(hdev->dev, "Irq handle: Timestamp record (%p) ts cb address (%p), interrupt_id: %u\n",
260260
pend, pend->ts_reg_info.timestamp_kernel_addr, interrupt_id);
261261

262-
/* Mark kernel CB node as free */
263-
pend->ts_reg_info.in_use = false;
264262
list_del(&pend->wait_list_node);
265263

266264
/* Putting the refcount for ts_buff and cq_cb objects will be handled
@@ -270,6 +268,9 @@ static int handle_registration_node(struct hl_device *hdev, struct hl_user_pendi
270268
free_node->cq_cb = pend->ts_reg_info.cq_cb;
271269
list_add(&free_node->free_objects_node, *free_list);
272270

271+
/* Mark TS record as free */
272+
pend->ts_reg_info.in_use = false;
273+
273274
return 0;
274275
}
275276

0 commit comments

Comments
 (0)