drm/amdgpu/gfx9: manually control gfxoff for CS on RV
Subsystems (2)
Alex Deucher
maintainerPATCH 1/3 drm/amdgpu/gfx9: manually control gfxoff for CS on RV
When mesa started using compute queues more often we started seeing additional hangs with compute queues. Disabling gfxoff seems to mitigate that. Manually control gfxoff and gfx pg with command submissions to avoid any issues related to gfxoff. KFD already does the same thing for these chips.
v2: limit to compute
v3: limit to APUs
v4: limit to Raven/PCO
v5: only update the compute ring_funcs
v6: Disable GFX PG
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 36 +++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +34 -2
@@ -7440,6 +7440,38 @@ static void gfx_v9_0_ring_emit_cleaner_shader(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0 );/* RESERVED field, programmed to zero */ } +static void gfx_v9_0_ring_begin_use_compute (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +struct amdgpu_ip_block *gfx_block = +amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); + +/* Raven and PCO APUs seem to have stability issues +* with compute and gfxoff and gfx pg. Disable gfx pg during +* submission and allow again afterwards. +*/ +if (gfx_block &&amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,1 ,0 )) +gfx_v9_0_set_powergating_state (gfx_block,AMD_PG_STATE_UNGATE ); + +amdgpu_gfx_enforce_isolation_ring_begin_use (ring); +} + +static void gfx_v9_0_ring_end_use_compute (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +struct amdgpu_ip_block *gfx_block = +amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); + +amdgpu_gfx_enforce_isolation_ring_end_use (ring); + +/* Raven and PCO APUs seem to have stability issues +* with compute and gfxoff and gfx pg. Disable gfx pg during +* submission and allow again afterwards. +*/ +if (gfx_block &&amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,1 ,0 )) +gfx_v9_0_set_powergating_state (gfx_block,AMD_PG_STATE_GATE ); +} +static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { .name ="gfx_v9_0" , .early_init = gfx_v9_0_early_init,
@@ -7616,8 +7648,8 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = { .emit_wave_limit = gfx_v9_0_emit_wave_limit, .reset = gfx_v9_0_reset_kcq, .emit_cleaner_shader = gfx_v9_0_ring_emit_cleaner_shader, - .begin_use = amdgpu_gfx_enforce_isolation_ring_begin_use, - .end_use = amdgpu_gfx_enforce_isolation_ring_end_use, + .begin_use = gfx_v9_0_ring_begin_use_compute, + .end_use = gfx_v9_0_ring_end_use_compute, };static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_kiq = {
Signature · 1 line
2.48.1
Alex Deucher
maintainerPATCH 2/3 drm/amdgpu/gfx: add amdgpu_gfx_off_ctrl_immediate()
Same as amdgpu_gfx_off_ctrl(), but without the delay for gfxoff disallow.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 53 +++++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + 2 files changed, 41 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +40 -13
@@ -771,18 +771,8 @@ int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id)return r; } -/* amdgpu_gfx_off_ctrl - Handle gfx off feature enable/disable -* -* @adev: amdgpu_device pointer -* @bool enable true: enable gfx off feature, false: disable gfx off feature -* -* 1. gfx off feature will be enabled by gfx ip after gfx cg gp enabled. -* 2. other client can send request to disable gfx off feature, the request should be honored. -* 3. other client can cancel their request of disable gfx off feature -* 4. other client should not send request to enable gfx off feature before disable gfx off feature. -*/ - -void amdgpu_gfx_off_ctrl (struct amdgpu_device *adev,bool enable) +static void amdgpu_gfx_do_off_ctrl (struct amdgpu_device *adev,bool enable, +bool no_delay) {unsigned long delay =GFX_OFF_DELAY_ENABLE ;
@@ -804,7 +794,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)if (adev->gfx.gfx_off_req_count ==0 && !adev->gfx.gfx_off_state) {/* If going to s2idle, no need to wait */ -if (adev->in_s0ix) { +if (no_delay) {if (!amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , true,0 )) adev->gfx.gfx_off_state = true;
@@ -836,6 +826,43 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)mutex_unlock (&adev->gfx.gfx_off_mutex); } +/* amdgpu_gfx_off_ctrl - Handle gfx off feature enable/disable +* +* @adev: amdgpu_device pointer +* @bool enable true: enable gfx off feature, false: disable gfx off feature +* +* 1. gfx off feature will be enabled by gfx ip after gfx cg pg enabled. +* 2. other client can send request to disable gfx off feature, the request should be honored. +* 3. other client can cancel their request of disable gfx off feature +* 4. other client should not send request to enable gfx off feature before disable gfx off feature. +* +* gfx off allow will be delayed by GFX_OFF_DELAY_ENABLE ms. +*/ +void amdgpu_gfx_off_ctrl (struct amdgpu_device *adev,bool enable) +{ +/* If going to s2idle, no need to wait */ +bool no_delay = adev->in_s0ix ? true : false; + +amdgpu_gfx_do_off_ctrl (adev, enable, no_delay); +} + +/* amdgpu_gfx_off_ctrl_immediate - Handle gfx off feature enable/disable +* +* @adev: amdgpu_device pointer +* @bool enable true: enable gfx off feature, false: disable gfx off feature +* +* 1. gfx off feature will be enabled by gfx ip after gfx cg pg enabled. +* 2. other client can send request to disable gfx off feature, the request should be honored. +* 3. other client can cancel their request of disable gfx off feature +* 4. other client should not send request to enable gfx off feature before disable gfx off feature. +* +* gfx off allow will be issued immediately. +*/ +void amdgpu_gfx_off_ctrl_immediate (struct amdgpu_device *adev,bool enable) +{ +amdgpu_gfx_do_off_ctrl (adev, enable, true); +} +int amdgpu_set_gfx_off_residency (struct amdgpu_device *adev,bool value) {int r =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -554,6 +554,7 @@ int amdgpu_gfx_me_queue_to_bit(struct amdgpu_device *adev, int me,bool amdgpu_gfx_is_me_queue_enabled (struct amdgpu_device *adev,int me,int pipe,int queue);void amdgpu_gfx_off_ctrl (struct amdgpu_device *adev,bool enable); +void amdgpu_gfx_off_ctrl_immediate (struct amdgpu_device *adev,bool enable);int amdgpu_get_gfx_off_status (struct amdgpu_device *adev,uint32_t *value);int amdgpu_gfx_ras_late_init (struct amdgpu_device *adev,struct ras_common_if *ras_block);void amdgpu_gfx_ras_fini (struct amdgpu_device *adev);
Signature · 1 line
2.48.1
Alex Deucher
maintainerPATCH 3/3 drm/amdgpu/gfx9: use amdgpu_gfx_off_ctrl_immediate() for PG
In reply to Alex DeucherUse amdgpu_gfx_off_ctrl_immediate() when powergating. There's no need for the delay in gfx off allow. The powergating is dynamically disabled/enabled as for RV/PCO on compute queues and allowing gfx off again as soon the job is submitted improves power savings.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -3
@@ -5244,7 +5244,7 @@ static int gfx_v9_0_set_powergating_state(struct amdgpu_ip_block *ip_block,case IP_VERSION (9 ,1 ,0 ):case IP_VERSION (9 ,3 ,0 ):if (!enable) -amdgpu_gfx_off_ctrl (adev, false); +amdgpu_gfx_off_ctrl_immediate (adev, false);if (adev->pg_flags &AMD_PG_SUPPORT_RLC_SMU_HS ) {gfx_v9_0_enable_sck_slow_down_on_power_up (adev, true);
@@ -5266,10 +5266,10 @@ static int gfx_v9_0_set_powergating_state(struct amdgpu_ip_block *ip_block,gfx_v9_0_update_gfx_mg_power_gating (adev, enable);if (enable) -amdgpu_gfx_off_ctrl (adev, true); +amdgpu_gfx_off_ctrl_immediate (adev, true);break ;case IP_VERSION (9 ,2 ,1 ): -amdgpu_gfx_off_ctrl (adev, enable); +amdgpu_gfx_off_ctrl_immediate (adev, enable);break ;default :break ;
Signature · 1 line
2.48.1