From: sashiko-bot@kernel.org
To: "Alex Deucher" <alexander.deucher@amd.com>,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges
Date: Tue, 17 Nov 2026 20:01:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-219544@kernel.org> (raw)
In-Reply-To: <20261117192304.809813-1-alexander.deucher@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/amdgpu: wrong unit multipliers in amdgpu_info_ioctl()
doorbell range
- [Medium] drm/amdgpu: unsplit GFX and COMPUTE ranges in
amdgpu_info_ioctl()
--
commit e3f1d2882f95267baaa962bef8149a9b40b07bea
Author: Alex Deucher <alexander.deucher@amd.com>
drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges
This commit adds the AMDGPU_INFO_UQ_DOORBELL_RANGE query to
amdgpu_info_ioctl() so userspace can query the per-IP doorbell byte offset
and size.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8e7e522a89e42..acc4d0a1ca14f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -1452,6 +1452,26 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
> return -EINVAL;
> }
> }
> + case AMDGPU_INFO_UQ_DOORBELL_RANGE: {
> + struct drm_amdgpu_info_doorbell_range db_range = {};
> +
> + switch (info->query_hw_ip.type) {
> + case AMDGPU_HW_IP_GFX:
> + case AMDGPU_HW_IP_COMPUTE:
> + db_range.offset_bytes = adev->doorbell_index.kiq * 4;
> + db_range.size_bytes = (adev->doorbell_index.sdma_engine[0] -
> + adev->doorbell_index.kiq) * 4;
[Severity: Medium]
Should AMDGPU_HW_IP_GFX and AMDGPU_HW_IP_COMPUTE report separate doorbell
ranges instead of the combined [kiq, sdma_engine[0]) range?
On GFX11 and GFX12, gfx_v11_0_cp_set_doorbell_range() and
gfx_v12_0_cp_set_doorbell_range() program separate ranges for graphics and
compute:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_cp_set_doorbell_range() {
/* set graphics engine doorbell range */
WREG32_SOC15(GC, 0, regCP_RB_DOORBELL_RANGE_LOWER,
(adev->doorbell_index.gfx_ring0 * 2) << 2);
WREG32_SOC15(GC, 0, regCP_RB_DOORBELL_RANGE_UPPER,
(adev->doorbell_index.gfx_userqueue_end * 2) << 2);
/* set compute engine doorbell range */
WREG32_SOC15(GC, 0, regCP_MEC_DOORBELL_RANGE_LOWER,
(adev->doorbell_index.kiq * 2) << 2);
WREG32_SOC15(GC, 0, regCP_MEC_DOORBELL_RANGE_UPPER,
(adev->doorbell_index.userqueue_end * 2) << 2);
}
Reporting [kiq, sdma_engine[0]) for both IPs lets userspace place graphics
userqueue doorbells inside the compute range (starting at kiq rather than
gfx_ring0) and compute doorbells inside the graphics range, which breaks CP
doorbell filtering and firmware workload detection.
> + return copy_to_user(out, &db_range,
> + min((size_t)size, sizeof(db_range))) ? -EFAULT : 0;
> + case AMDGPU_HW_IP_DMA:
> + db_range.offset_bytes = adev->doorbell_index.sdma_engine[0] * 4;
> + db_range.size_bytes = adev->doorbell_index.sdma_doorbell_range * adev->sdma.num_instances;
[Severity: High]
Are the unit multipliers for db_range.offset_bytes and db_range.size_bytes
off by a factor of two for the qword indices and missing the dword-to-byte
conversion for sdma_doorbell_range?
In struct amdgpu_doorbell_index (drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h),
doorbell_index fields such as kiq and sdma_engine[0] are 64-bit qword
indices (8 bytes each) on Vega10 and later, whereas sdma_doorbell_range is
a per-engine size in 32-bit dwords (4 bytes each):
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c:sdma_v6_0_sw_init() {
...
ring->doorbell_index =
(adev->doorbell_index.sdma_engine[i] << 1); // get DWORD offset
...
}
Multiplying kiq and sdma_engine[0] by 4 instead of 8 (or << 3) returns half
the actual byte offset and size, placing AMDGPU_HW_IP_DMA doorbells at byte
offset 1024 inside the CP doorbell aperture instead of 2048 at the NBIO
SDMA aperture. In addition, adev->doorbell_index.sdma_doorbell_range *
adev->sdma.num_instances is not multiplied by 4, so db_range.size_bytes
is returned in dwords rather than bytes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117192304.809813-1-alexander.deucher@amd.com?part=1
next prev parent reply other threads:[~2026-11-17 20:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 19:23 [PATCH] drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges Alex Deucher
2026-11-17 20:01 ` sashiko-bot [this message]
2026-11-18 9:35 ` Pierre-Eric Pelloux-Prayer
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-219544@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox