drm/amdgpu/gfx11: don't enable gfx on pipe1 with tmz
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/gfx11: don't enable gfx on pipe1 with tmz
FW doesn't support tmz on pipe one. Only use pipe 0 if tmz is enabled.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +8 -3
@@ -5334,10 +5334,15 @@ static int gfx_v11_0_early_init(struct amdgpu_ip_block *ip_block) adev->gfx.num_compute_rings =0 ; }else {/* rs64 only supports one gfx pipe */ -if (adev->gfx.rs64_enable) +if (adev->gfx.rs64_enable) { adev->gfx.num_gfx_rings =1 ; -else - adev->gfx.num_gfx_rings =GFX11_NUM_GFX_RINGS ; + }else { +/* FW doesn't support TMZ on gfx pipe1 */ +if (adev->gmc.tmz_enabled) + adev->gfx.num_gfx_rings =1 ; +else + adev->gfx.num_gfx_rings =GFX11_NUM_GFX_RINGS ; + } adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev),AMDGPU_MAX_COMPUTE_RINGS ); }
Signature · 1 line
2.56.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/amdgpu/gfx11: gfx_v11_0_early_init() reads tmz_enabled before init - [High] drm/amdgpu/gfx11…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] drm/amdgpu/gfx11: gfx_v11_0_early_init() reads tmz_enabled before init
- [High] drm/amdgpu/gfx11: gfx_v11_0_sw_init() enables pipe1 with TMZ and crashes
--
commit 3a6ea4e2362ddd6d94fcfcb16809c1b42fa126ef
Author: Alex Deucher <[email protected]>
drm/amdgpu/gfx11: don't enable gfx on pipe1 with tmz
This commit limits adev->gfx.num_gfx_rings to 1 in gfx_v11_0_early_init() when Trusted Memory Zone (TMZ) is enabled, because GFX11 firmware does not support TMZ on GFX pipe 1.
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-3@@ -5302,10 +5302,15 @@ static int gfx_v11_0_early_init(struct amdgpu_ip_block *ip_block) adev->gfx.num_compute_rings =0 ; }else {/* rs64 only supports one gfx pipe */ -if (adev->gfx.rs64_enable) +if (adev->gfx.rs64_enable) { adev->gfx.num_gfx_rings =1 ; -else - adev->gfx.num_gfx_rings =GFX11_NUM_GFX_RINGS ;
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_early_init(struct amdgpu_ip_block *ip_block) · line 5316
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +7
-0+ }else { +/* FW doesn't support TMZ on gfx pipe1 */ +if (adev->gmc.tmz_enabled) + adev->gfx.num_gfx_rings =1 ; +else + adev->gfx.num_gfx_rings =GFX11_NUM_GFX_RINGS ; + } adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev),AMDGPU_MAX_COMPUTE_RINGS ); }
[Severity: High]
Is adev->gmc.tmz_enabled already initialized when gfx_v11_0_early_init() runs?
In amdgpu_device_init(), amdgpu_device_ip_early_init() runs before amdgpu_gmc_tmz_set():
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:amdgpu_device_init() {
...
/* early init functions */
r = amdgpu_device_ip_early_init(adev);
if (r)
return r;
...
/* Enable TMZ based on IP_VERSION */
amdgpu_gmc_tmz_set(adev);
...
}Because adev->gmc.tmz_enabled is still false during early_init, adev->gfx.num_gfx_rings is always set to GFX11_NUM_GFX_RINGS (2) and GFX pipe 1 remains enabled when TMZ is active.
[Severity: High]
Should gfx_v11_0_sw_init() also check adev->gmc.tmz_enabled when setting adev->gfx.me.num_pipe_per_me?
Commit fec62b5e1425 ("drm/amdgpu/gfx11: enable gfx pipe1 hardware support") enabled pipe 1 in both gfx_v11_0_early_init() and gfx_v11_0_sw_init():
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_sw_init() {
...
if (adev->gfx.rs64_enable)
adev->gfx.me.num_pipe_per_me = 1;
else
adev->gfx.me.num_pipe_per_me = 2;
...
}When num_gfx_rings is 1 in gfx_v11_0_early_init(), gfx_v11_0_set_ring_funcs() only initializes adev->gfx.gfx_ring[0].funcs and leaves gfx_ring[1].funcs NULL. If gfx_v11_0_sw_init() still sets num_pipe_per_me to 2, gfx_v11_0_me_init() -> amdgpu_gfx_graphics_queue_acquire() acquires a queue on pipe 1 and resets num_gfx_rings to 2, and the ring initialization loop in gfx_v11_0_sw_init() then calls gfx_v11_0_gfx_ring_init() -> amdgpu_ring_init() on gfx_ring[1], causing a NULL pointer dereference on ring->funcs->type.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1