drm/amdgpu: move tmz init into early_init()
Subsystems (2)
Alex Deucher
maintainerPATCH 1/2 drm/amdgpu: move tmz init into early_init()
We will need the tmz status in early init for gfx11 in the next patch.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
@@ -2116,6 +2116,9 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP )amdgpu_psp_init_fw_variant (adev); +/* Enable TMZ based on IP_VERSION */ +amdgpu_gmc_tmz_set (adev); + total = true;for (i =0 ; i < adev->num_ip_blocks; i++) { ip_block = &adev->ip_blocks[i];
@@ -4058,9 +4061,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,return r; } -/* Enable TMZ based on IP_VERSION */ -amdgpu_gmc_tmz_set (adev); -if (amdgpu_sriov_vf (adev) &&amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (10 ,3 ,0 ))/* VF MMIO access (except mailbox range) from CPU
Signature · 1 line
2.56.1
Alex Deucher
maintainerPATCH 2/2 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.
v2: add check for num_pipe as well
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10 -4
@@ -1692,7 +1692,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)case IP_VERSION (11 ,7 ,0 ):case IP_VERSION (11 ,7 ,1 ): adev->gfx.me.num_me =1 ; -if (adev->gfx.rs64_enable) +if (adev->gfx.rs64_enable || + adev->gmc.tmz_enabled) adev->gfx.me.num_pipe_per_me =1 ;else adev->gfx.me.num_pipe_per_me =2 ;
@@ -5334,10 +5335,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 reviewRe: [PATCH 2/2] drm/amdgpu/gfx11: don't enable gfx on pipe1 with tmz
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/amdgpu/gfx11: NULL pointer…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [High] drm/amdgpu/gfx11: NULL pointer dereference in amdgpu_ring_init() [1]
--
commit 0a934348cc9c64c8c23b8255a5b64447ad24179d
Author: Alex Deucher <[email protected]>
drm/amdgpu/gfx11: don't enable gfx on pipe1 with tmz
This commit limits GFX11 devices to a single GFX pipe and ring when TMZ is enabled, as the firmware does not support TMZ on pipe 1.
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block) · line 1697
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -1690,7 +1690,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)case IP_VERSION (11 ,7 ,0 ):case IP_VERSION (11 ,7 ,1 ): adev->gfx.me.num_me =1 ; -if (adev->gfx.rs64_enable) +if (adev->gfx.rs64_enable || + adev->gmc.tmz_enabled) adev->gfx.me.num_pipe_per_me =1 ;else adev->gfx.me.num_pipe_per_me =2 ;
[Severity: High]
This problem wasn't introduced by this patch, but should this condition also check adev->gfx.disable_kq [1]?
When amdgpu.user_queue=2 sets adev->gfx.disable_kq, gfx_v11_0_early_init() sets adev->gfx.num_gfx_rings = 1, so gfx_v11_0_set_ring_funcs() only populates adev->gfx.gfx_ring[0].funcs and leaves gfx_ring[1].funcs NULL.
If adev->gfx.me.num_pipe_per_me is set to 2 here, gfx_v11_0_me_init() -> amdgpu_gfx_graphics_queue_acquire() enables queues on both pipes and overwrites adev->gfx.num_gfx_rings to 2. gfx_v11_0_sw_init() then calls gfx_v11_0_gfx_ring_init() for gfx_ring[1], causing amdgpu_ring_init() to dereference the NULL ring->funcs pointer.
[1] https://sashiko.dev/#/bug/linux-cb8251e2-db73-484e-81c4-7d48aaa6e13f
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2