All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/habanalabs: Fix timestamp record release on reset
Date: Sat, 05 Dec 2026 06:58:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-251170@kernel.org> (raw)
In-Reply-To: <20261205063651.2523441-1-praneethb2002@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] accel/habanalabs: inaccurate comment citing
  unregister_timestamp_node()
--

commit 456b437299ee89a714b14ad80b2c00f226137c89
Author: Praneeth Balasubramanian <praneethb2002@gmail.com>

accel/habanalabs: Fix timestamp record release on reset

This commit updates wake_pending_user_interrupt_threads() to unlink each
pending timestamp record, clear ts_reg_info.in_use, and save the buffer
pointers before dropping ts_list_lock to release the timestamp and CQ
buffer references.

> diff --git a/drivers/accel/habanalabs/common/command_submission.c b/drivers/accel/habanalabs/common/command_submission.c
> index 8a3febc2089ed..8bff77bf42f89 100644
> --- a/drivers/accel/habanalabs/common/command_submission.c
> +++ b/drivers/accel/habanalabs/common/command_submission.c

[ ... ]

> @@ -1108,10 +1110,24 @@ wake_pending_user_interrupt_threads(struct hl_user_interrupt *interrupt)
>  	spin_unlock_irqrestore(&interrupt->wait_list_lock, flags);
>  
>  	spin_lock_irqsave(&interrupt->ts_list_lock, flags);
> -	list_for_each_entry_safe(pend, temp, &interrupt->ts_list_head, list_node) {
> +	while (!list_empty(&interrupt->ts_list_head)) {
> +		pend = list_first_entry(&interrupt->ts_list_head,
> +					struct hl_user_pending_interrupt, list_node);
> +		buf = pend->ts_reg_info.buf;
> +		cq_cb = pend->ts_reg_info.cq_cb;
>  		list_del(&pend->list_node);
> -		hl_mmap_mem_buf_put(pend->ts_reg_info.buf);
> -		hl_cb_put(pend->ts_reg_info.cq_cb);
> +		pend->ts_reg_info.in_use = false;
> +		spin_unlock_irqrestore(&interrupt->ts_list_lock, flags);
> +
> +		/*
> +		 * As in unregister_timestamp_node(), put the references without
> +		 * the lock: the release may sleep, and it may free the buffer
> +		 * that holds pend.
> +		 */

[Severity: Low]
Are this comment and the commit message accurate in saying
unregister_timestamp_node() snapshots the pointers and drops ts_list_lock
before putting the references?

In unregister_timestamp_node(), ts_list_lock is only dropped when
need_lock is true (ts_get_and_handle_kernel_record() calls it with
need_lock == false), and the buffer pointers are read directly from
record rather than saved under the lock:

drivers/accel/habanalabs/common/command_submission.c:unregister_timestamp_node() {
	...
	if (need_lock)
		spin_unlock_irqrestore(&interrupt->ts_list_lock, flags);

	/* Put refcounts that were taken when we registered the event */
	if (ts_rec_found) {
		hl_mmap_mem_buf_put(record->ts_reg_info.buf);
		hl_cb_put(record->ts_reg_info.cq_cb);
	}
}

Describing why wake_pending_user_interrupt_threads() drops the lock and
saves the pointers without citing unregister_timestamp_node() as a
precedent would avoid obscuring that discrepancy.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205063651.2523441-1-praneethb2002@gmail.com?part=1

      reply	other threads:[~2026-12-05  6:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:36 [PATCH] accel/habanalabs: Fix timestamp record release on reset Praneeth Balasubramanian
2026-12-05  6:58 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-251170@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=praneethb2002@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.