From: sashiko-bot@kernel.org
To: "Felix Kuehling" <felix.kuehling@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/amdkfd: fix doorbell allocation race creating duplicate allocations
Date: Wed, 14 Oct 2026 15:44:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-171485@kernel.org> (raw)
In-Reply-To: <20261014153246.538155-1-felix.kuehling@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/amdkfd: Incomplete fix leaves lockless double-checked locking race
--
commit f4e452c37b6ce531530ab68a693284bf20a378b1
Author: Henry Martin <bsdhenrymartin@gmail.com>
drm/amdkfd: fix doorbell allocation race creating duplicate allocations
The patch introduces a per-process-device mutex to serialize the allocation
of doorbells in kfd_alloc_process_doorbells(). It removes the lockless check
in kfd_get_process_doorbells() so that all synchronization is handled internally
by the allocator.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c b/drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c
> index fdcf7f2d1b5b4..6af268a031f22 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c
> @@ -239,11 +239,9 @@ phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd)
> struct amdgpu_device *adev = pdd->dev->adev;
> uint32_t first_db_index;
>
> - if (!pdd->qpd.proc_doorbells) {
> - if (kfd_alloc_process_doorbells(pdd->dev->kfd, pdd))
> - /* phys_addr_t 0 is error */
> - return 0;
> - }
> + if (kfd_alloc_process_doorbells(pdd->dev->kfd, pdd))
> + /* phys_addr_t 0 is error */
> + return 0;
[Severity: High]
Are the lockless checks in kfd_ioctl_create_queue() and criu_restore_devices()
intentionally left in drivers/gpu/drm/amd/amdkfd/kfd_chardev.c?
While this lockless check was correctly removed here, identical lockless
checks (if (!pdd->qpd.proc_doorbells)) remain in the other two call sites
mentioned in the commit message.
Concurrently, a thread calling kfd_mmap() will allocate the doorbell structures
under doorbell_mutex. A racing thread in kfd_ioctl_create_queue() will read
proc_doorbells locklessly. Without memory barriers like smp_load_acquire(),
this thread can observe a non-NULL proc_doorbells pointer but fail to see the
fully initialized qpd->doorbell_bitmap, or see the BO before it is fully pinned
by amdgpu_bo_create().
Can this lead to a NULL pointer dereference in operations like
find_first_zero_bit() on doorbell_bitmap, or hardware access with an unpinned
BO?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014153246.538155-1-felix.kuehling@amd.com?part=1
next prev parent reply other threads:[~2026-10-14 15:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 10:18 [PATCH] amdkfd: fix doorbell allocation race creating duplicate allocations Henry Martin
2026-10-09 10:28 ` sashiko-bot
2026-10-09 15:00 ` Kuehling, Felix
2026-10-09 15:33 ` Kuehling, Felix
2026-10-10 2:55 ` henry martin
2026-10-10 3:02 ` [PATCH v2] " Henry Martin
2026-10-10 3:15 ` sashiko-bot
2026-10-13 17:39 ` Felix Kuehling
2026-10-14 3:02 ` henry martin
2026-10-14 15:32 ` [PATCH v3] drm/amdkfd: " Felix Kuehling
2026-10-14 15:44 ` sashiko-bot [this message]
2026-10-14 15:49 ` [PATCH v4] " Felix Kuehling
2026-10-14 16:08 ` sashiko-bot
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-171485@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=felix.kuehling@amd.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.