drm/amdgpu: add wave limit functionality for gfx8, 9
Subsystems (2)
RFC PATCH v2 1/2 drm/amdgpu: add wave limit functionality for gfx8, 9
Wave limiting can be use to load balance high priority compute jobs along with gfx jobs. When enabled, this will reserve ~75% of waves for compute jobs.
v2: Use amdgpu_ring_emit_wreg() in gfx8.
Updated comments.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -197,6 +197,7 @@ struct amdgpu_ring_funcs {void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid);int (*preempt_ib)(struct amdgpu_ring *ring);void (*emit_mem_sync)(struct amdgpu_ring *ring); +void (*emit_wave_limit)(struct amdgpu_ring *ring,bool enable); };struct amdgpu_ring {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +17 -0
@@ -29,6 +29,7 @@#include "amdgpu.h" #include "amdgpu_gfx.h" +#include "amdgpu_ring.h" #include "vi.h" #include "vi_structs.h" #include "vid.h"
@@ -6847,6 +6848,21 @@ static void gfx_v8_0_emit_mem_sync_compute(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0x0000000A );/* poll interval */ } +#define mmSPI_WCL_PIPE_PERCENT_GFX_DEFAULT 0x07ffffff +static void gfx_v8_0_emit_wave_limit (struct amdgpu_ring *ring,bool enable) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t val; + + +/* mmSPI_WCL_PIPE_PERCENT_GFX is 7 bit multiplier register to limit +* number of gfx waves. Setting 5 bit will make sure gfx only gets +* around 25% of gpu resources. +*/ + val = enable ?0x1f : mmSPI_WCL_PIPE_PERCENT_GFX_DEFAULT; +amdgpu_ring_emit_wreg (ring, mmSPI_WCL_PIPE_PERCENT_GFX, val); +} +static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { .name ="gfx_v8_0" , .early_init = gfx_v8_0_early_init,
@@ -6944,6 +6960,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v8_0_ring_emit_wreg, .emit_mem_sync = gfx_v8_0_emit_mem_sync_compute, + .emit_wave_limit = gfx_v8_0_emit_wave_limit, };static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_kiq = {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +18 -0
@@ -52,6 +52,7 @@#include "asic_reg/pwr/pwr_10_0_offset.h" #include "asic_reg/pwr/pwr_10_0_sh_mask.h" +#include "asic_reg/gc/gc_9_0_default.h" #define GFX9_NUM_GFX_RINGS 1#define GFX9_MEC_HPD_SIZE 4096
@@ -6670,6 +6671,22 @@ static void gfx_v9_0_emit_mem_sync(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0x0000000A );/* POLL_INTERVAL */ } +static void gfx_v9_0_emit_wave_limit (struct amdgpu_ring *ring,bool enable) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t val; + + +/* mmSPI_WCL_PIPE_PERCENT_GFX is 7 bit multiplier register to limit +* number of gfx waves. Setting 5 bit will make sure gfx only gets +* around 25% of gpu resources. +*/ + val = enable ?0x1f : mmSPI_WCL_PIPE_PERCENT_GFX_DEFAULT; +amdgpu_ring_emit_wreg (ring, +SOC15_REG_OFFSET (GC ,0 , mmSPI_WCL_PIPE_PERCENT_GFX), + val); +} +static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { .name ="gfx_v9_0" , .early_init = gfx_v9_0_early_init,
@@ -6775,6 +6792,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = { .emit_reg_wait = gfx_v9_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait, .emit_mem_sync = gfx_v9_0_emit_mem_sync, + .emit_wave_limit = gfx_v9_0_emit_wave_limit, };static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_kiq = {
--
2.30.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RFC PATCH 2/2 drm/amdgpu: enable gfx wave limiting for high priority compute jobs
Enable gfx wave limiting for gfx jobs before pushing high priority compute jobs so that high priority compute jobs gets more resources to finish early.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +9 -0
@@ -195,6 +195,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if ((ib->flags &AMDGPU_IB_FLAG_EMIT_MEM_SYNC ) && ring->funcs->emit_mem_sync) ring->funcs->emit_mem_sync (ring); +if (ring->funcs->emit_wave_limit && job && + job->base.s_priority >=DRM_SCHED_PRIORITY_HIGH ) + ring->funcs->emit_wave_limit (ring, true); +if (ring->funcs->insert_start) ring->funcs->insert_start (ring);
@@ -295,6 +299,11 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, ring->current_ctx = fence_ctx;if (vm && ring->funcs->emit_switch_buffer)amdgpu_ring_emit_switch_buffer (ring); + +if (ring->funcs->emit_wave_limit && job && + job->base.s_priority >=DRM_SCHED_PRIORITY_HIGH ) + ring->funcs->emit_wave_limit (ring, false); +amdgpu_ring_commit (ring);return 0 ; }
--
2.30.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx