Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: amdgpu_info_ioctl() returns combined GFX/compute
  doorbell range
--

commit 81484698f4a74ac4cd4b7b1d2435342b60989454
Author: Alex Deucher <[email protected]>

drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges

This commit adds the AMDGPU_INFO_UQ_DOORBELL_RANGE subquery to
amdgpu_info_ioctl() so userspace can query the per-page doorbell byte offset
and size for GFX, compute, and SDMA user queues.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8e7e522a89e42..23858589dd15c 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 << 3;
> +                     db_range.size_bytes = 
> (adev->doorbell_index.sdma_engine[0] -
> +                                            adev->doorbell_index.kiq) << 3;

[Severity: High]
Should AMDGPU_HW_IP_GFX and AMDGPU_HW_IP_COMPUTE return separate doorbell
sub-ranges instead of the combined [kiq, sdma_engine[0]) range?

On GFX11 and GFX12, the CP doorbell range registers partition each doorbell
page into disjoint ranges for compute (kiq..userqueue_end) and graphics
(gfx_ring0..gfx_userqueue_end):

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);
}

As noted in fd0ed91ae8a2 ("drm/amdgpu: correct cp doorbell range"), hardware
and firmware rely on these ranges to distinguish GFX and compute doorbell
activity for power-saving states.  Returning the combined range for both IP
types causes userspace to allocate GFX doorbells inside the MEC compute
range and compute doorbells inside the CP_RB graphics range.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to