Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0321606A322 for ; Fri, 4 Dec 2026 16:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z66joWV5 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B51211308C; Fri, 4 Dec 2026 16:41:39 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E3EC113094 for ; Fri, 4 Dec 2026 16:41:33 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id CDED9600EF; Fri, 4 Dec 2026 16:41:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76CA51F000C2; Fri, 4 Dec 2026 16:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796402492; bh=hqErvplFs0u4lUYZ/fDpNzJgQqnii8Swd/CHgamYDHo=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Z66joWV5y/iAPsJjeiVD4eDudHIU2egjIARMj4uEptYOG8DfYRgjODGLh1nNyRkKB Tjq9g1sJ5dgkPROZc4/8c9X6Z/Q3PQ3eHQKT6GumWiyrmCUW4EneNoYkHYe8mko5yM K8za8kLzqioY7lP4oV1nx7zMU/Xb6G053dQGBs5pzbghckQA1wDmkByyg2gLEUP1RC sTYoP1EockFUP3uVLRwMl0hoIwWZ20+iWhNVVNa0C1VcKrhtHsl1unro3GuaAVAOgc hiiDVT+xjZxA91ky8j5jwqSenJOtRfT+R/UGogZ13uGXMVWQ4ixtNQTgiHc+gFbzWH 6VYXwvUt+r/gA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 8/9] drm/amdgpu: enable uni-mes for gfx13 To: "Frank Min" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261204142408.988734-8-Frank.Min@amd.com> References: <20261204142408.988734-1-Frank.Min@amd.com> <20261204142408.988734-8-Frank.Min@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:41:32 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 9 potential issues to consider: - [High] drm/amdgpu: GFX13 MES enabled with no-op suspend_gang/resume_gang stubs - [High] drm/amdgpu: mes_v13_0_submit_pkt_and_poll_completion() returns 0 on errors - [High] drm/amdgpu: mes_v13_0_remove_hw_queue() omits queue_type and reset flag - [Medium] drm/amdgpu: GFX13 uni-mes routes legacy KQs and resets to KIQ pipe - [Medium] drm/amdgpu: amdgpu_mes_queue_reset_by_mes_supported() omits GC 13.x - [Medium] drm/amdgpu: missing MODULE_FIRMWARE declarations for GC 13.0.4 MES firmware - [Medium] drm/amdgpu: literal 0 write clears regCP_MQD_CONTROL in mes_v13_0_queue_init_register() - [Medium] drm/amdgpu: mes_v13_0_set_hw_resources_1() gated on 0x4b and unchecked - [Low] drm/amdgpu: commit message omits unconditional enable_mes and enable_mes_kiq -- commit bfe01128f1efb4aa22fc5a9f7950763067c635fd Author: Frank Min > drm/amdgpu: enable uni-mes for gfx13 > > Enable uni-mes for gfx13. > > Signed-off-by: Frank Min [Severity: Low] The subject and body only mention enabling uni-mes, but this patch also unconditionally enables adev->enable_mes and adev->enable_mes_kiq for both GC 13.0.1 and GC 13.0.4 even when amdgpu.uni_mes=3D0 is set. Could the commit message describe all three changes and explain why GFX13 is ready for MES enablement? > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/= drm/amd/amdgpu/amdgpu_discovery.c > index 5997946fb1171..292245f167e07 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > @@ -3407,10 +3407,10 @@ static int amdgpu_discovery_set_mes_ip_blocks(str= uct amdgpu_device *adev) > case IP_VERSION(13, 0, 1): > case IP_VERSION(13, 0, 4): > amdgpu_device_ip_block_add(adev, &mes_v13_0_ip_block); > - adev->enable_mes =3D false; > - adev->enable_mes_kiq =3D false; > + adev->enable_mes =3D true; [Severity: High] Can GFX13 enable MES before mes_v13_0_suspend_gang() and mes_v13_0_resume_gang() are implemented? Both callbacks in drivers/gpu/drm/amd/amdgpu/mes_v13_0.c are empty stubs returning 0 without submitting a packet or signaling the suspend fence. During user queue preemption (such as S0ix suspend or enforce_isolation switches), mes_userq_preempt() zeroes *fence_ptr, calls suspend_gang(), and busy-waits in a udelay(1) loop for 2.1 seconds per queue before failing with -ETIMEDOUT, marking healthy queues hung while leaving them active on hardware. In addition, amdgpu_mes_suspend_resume_all_supported() returns true for GC 13.x, so amdgpu_gfx_reset_mes_compute() treats the stub 0 return from amdgpu_mes_suspend() as all gangs suspended and skips amdgpu_mes_detect_and_reset_hung_queues(). [Severity: High] Does mes_v13_0_submit_pkt_and_poll_completion() silently return 0 on MES command failures? Per MES_API_STATUS in drivers/gpu/drm/amd/include/mes_v13_api_def.h, MES v13 reports API rejections by writing 0 to the lower 32 bits and a non-zero error code to the upper 32 bits. Testing !*status_ptr across all 64 bits instead of !lower_32_bits(*status_ptr) treats rejected commands as success. Similarly, when amdgpu_fence_wait_polling() times out waiting for ring space, it returns 0, and jumping to error_undo returns 0 without submitting the packet instead of -ETIMEDOUT. If mes_v13_0_remove_hw_queue() falsely succeeds on either error, amdgpu_userq_destroy() skips GPU reset and frees the queue BOs while the queue may still be active on hardware, risking DMA use-after-free. [Severity: High] Does mes_v13_0_remove_hw_queue() leave mes_remove_queue_pkt.queue_type at 0 (MES_QUEUE_TYPE_GFX) for compute and SDMA queues? With adev->enable_mes enabled, KFD and userq tear down compute and SDMA queues through this function, but it only populates doorbell_offset and gang_context_addr. As seen in commit 89db46e455ab ("drm/amdgpu,amdkfd: correct setting MES queue type"), sending REMOVE_QUEUE with the wrong queue type makes MES search the wrong queue class, causing unmap hangs or leaving the queue active after its memory is freed. It also ignores input->remove_queue_after_reset, breaking post-reset cleanup in reset_queue_mes(). [Severity: Medium] Should amdgpu_mes_queue_reset_by_mes_supported() in drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c also handle GC 13.x? It currently only checks GC 11.x, 12.0, and 12.1, so it returns false on GFX13 even though gfx_v13_0 advertises per-queue compute reset. When a KFD compute queue hangs, reset_queues_mes() fails with -ENOTRECOVERABLE and escalates to a full GPU reset. > + adev->enable_mes_kiq =3D true; [Severity: Medium] Now that adev->enable_mes_kiq is enabled, does mes_v13_0_queue_init_register() wipe regCP_MQD_CONTROL? drivers/gpu/drm/amd/amdgpu/mes_v13_0.c:mes_v13_0_queue_init_register() { ... data =3D RREG32_SOC15(GC, 0, regCP_MQD_CONTROL); data =3D REG_SET_FIELD(data, CP_MQD_CONTROL, VMID, 0); WREG32_SOC15(GC, 0, regCP_MQD_CONTROL, 0); ... } Writing literal 0 instead of data clears PRIV_STATE and the other control fields during MES KIQ HQD setup on every init, resume, and reset. > if (amdgpu_uni_mes) > - adev->enable_uni_mes =3D false; > + adev->enable_uni_mes =3D true; [Severity: Medium] Should mes_v13_0_map_legacy_queue(), mes_v13_0_unmap_legacy_queue(), and mes_v13_0_reset_hw_queue() use AMDGPU_MES_SCHED_PIPE for non-MES legacy kernel queues when enable_uni_mes is set? All three functions in drivers/gpu/drm/amd/amdgpu/mes_v13_0.c currently send legacy kernel queues and is_kq resets to AMDGPU_MES_KIQ_PIPE. As fixed for GFX12 in commit 5ec4cc917083 ("drm/amdgpu/mes_v12_0: use mes schedule pipe for legacy queues on unified MES"), pipe 0 MES only tracks queues on the schedule pipe, leaving legacy kernel queues (when booted with amdgpu.user_queue=3D0 or 1) inconsistent across suspend/resume and resets. [Severity: Medium] Are MODULE_FIRMWARE declarations missing for GC 13.0.4 MES firmware? drivers/gpu/drm/amd/amdgpu/mes_v13_0.c only declares MODULE_FIRMWARE for gc_13_0_1, whereas enabling MES on IP_VERSION(13, 0, 4) makes amdgpu_mes_init_microcode() require amdgpu/gc_13_0_4_uni_mes.bin (or gc_13_0_4_mes.bin and gc_13_0_4_mes1.bin with amdgpu.uni_mes=3D0). Initramfs builders using modinfo will omit them, causing probe to fail with -ENODEV during early boot. [Severity: Medium] Should mes_v13_0_hw_init() call mes_v13_0_set_hw_resources_1() unconditionally and check its return value in both mes_v13_0_hw_init() and mes_v13_0_kiq_hw_init()? On GFX13, mes_v13_0_set_hw_resources_1() is the only place sdma_hqd_mask is sent to MES, yet mes_v13_0_hw_init() gates it on sched_version >=3D 0x4b (a GFX12 check from commit 0180e0a5dd5c ("drm/amdgpu/mes: add compatibility checks for set_hw_resource_1")) while mes_v13_0_kiq_hw_init() calls it unconditionally. On GFX13 firmware with a version below 0x4b, this leaves sdma_hqd_mask zeroed and breaks MES SDMA user-queue scheduling. Both callers also discard the int return value of mes_v13_0_set_hw_resources_1(), allowing MES initialization to succeed even if the packet submission or completion fails. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204142408.9887= 34-1-Frank.Min@amd.com?part=3D8