optimize the padding of nops for gfx9 gfx12 and
Subsystems (2)
cover optimize the padding of nops for gfx9 gfx12 and
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
*** BLURB HERE ***
Sunil Khatri (3):
drm/amdgpu: optimize the padding for gfx12
drm/amdgpu: optimize the padding for gfx9
drm/amdgpu: optimize the padding for gfx_v9_4_3
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 22 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 24 +++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 20 +++++++++++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 drm/amdgpu: optimize the padding for gfx12
Adding NOP packets one by one in the ring
does not use the CP efficiently.
Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +20 -2
@@ -5005,6 +5005,24 @@ static void gfx_v12_0_emit_mem_sync(struct amdgpu_ring *ring)amdgpu_ring_write (ring, gcr_cntl);/* GCR_CNTL */ } +static void gfx_v12_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) { +amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop); +} +static void gfx_v12_ip_print (void *handle,struct drm_printer *p) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -5186,7 +5204,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_gfx = { .emit_hdp_flush = gfx_v12_0_ring_emit_hdp_flush, .test_ring = gfx_v12_0_ring_test_ring, .test_ib = gfx_v12_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v12_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_cntxcntl = gfx_v12_0_ring_emit_cntxcntl, .init_cond_exec = gfx_v12_0_ring_emit_init_cond_exec,
@@ -5224,7 +5242,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_compute = { .emit_hdp_flush = gfx_v12_0_ring_emit_hdp_flush, .test_ring = gfx_v12_0_ring_test_ring, .test_ib = gfx_v12_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v12_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v12_0_ring_emit_wreg, .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait,
Signature · 1 line
2.34.1
Re: [PATCH v1 1/3] drm/amdgpu: optimize the padding for gfx12
Quoted 33 lines · Sunil Khatri
Adding NOP packets one by one in the ring
does not use the CP efficiently.Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.Cc Christian König <[email protected]>Cc Pierre-Eric Pelloux-Prayer <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Marek Olšák <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +6
-0@@ -5005,6 +5005,24 @@ static void gfx_v12_0_emit_mem_sync(struct amdgpu_ring *ring)amdgpu_ring_write (ring, gcr_cntl);/* GCR_CNTL */ } +static void gfx_v12_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) {
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static void gfx_v12_0_emit_mem_sync(struct amdgpu_ring *ring) · line 5023
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +10
-0+amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop);
This loop should be removed. I explained the reason in the gfx10 commit.
Marek
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4
-3+} +static void gfx_v12_ip_print (void *handle,struct drm_printer *p) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -5186,7 +5204,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_gfx = { .emit_hdp_flush = gfx_v12_0_ring_emit_hdp_flush, .test_ring = gfx_v12_0_ring_test_ring, .test_ib = gfx_v12_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v12_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_cntxcntl = gfx_v12_0_ring_emit_cntxcntl, .init_cond_exec = gfx_v12_0_ring_emit_init_cond_exec,@@ -5224,7 +5242,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_compute = { .emit_hdp_flush = gfx_v12_0_ring_emit_hdp_flush, .test_ring = gfx_v12_0_ring_test_ring, .test_ib = gfx_v12_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v12_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v12_0_ring_emit_wreg, .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait, --2.34.1
PATCH 2/3 drm/amdgpu: optimize the padding for gfx9
In reply to Sunil KhatriAdding NOP packets one by one in the ring
does not use the CP efficiently.
Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +21 -3
@@ -7100,6 +7100,24 @@ static void gfx_v9_0_emit_wave_limit(struct amdgpu_ring *ring, bool enable) } } +static void gfx_v9_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) { +amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop); +} +static void gfx_v9_ip_print (void *handle,struct drm_printer *p) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -7240,7 +7258,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = { .emit_gds_switch = gfx_v9_0_ring_emit_gds_switch, .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_switch_buffer = gfx_v9_ring_emit_sb, .emit_cntxcntl = gfx_v9_ring_emit_cntxcntl,
@@ -7294,7 +7312,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_sw_ring_funcs_gfx = { .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, .test_ib = gfx_v9_0_ring_test_ib, - .insert_nop = amdgpu_sw_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_switch_buffer = gfx_v9_ring_emit_sb, .emit_cntxcntl = gfx_v9_ring_emit_cntxcntl,
@@ -7338,7 +7356,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = { .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, .test_ib = gfx_v9_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v9_0_ring_emit_wreg, .emit_reg_wait = gfx_v9_0_ring_emit_reg_wait,
Signature · 1 line
2.34.1
Re: [PATCH v1 2/3] drm/amdgpu: optimize the padding for gfx9
Quoted 33 lines · Sunil Khatri
Adding NOP packets one by one in the ring
does not use the CP efficiently.Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.Cc Christian König <[email protected]>Cc Pierre-Eric Pelloux-Prayer <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Marek Olšák <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -7100,6 +7100,24 @@ static void gfx_v9_0_emit_wave_limit(struct amdgpu_ring *ring, bool enable) } } +static void gfx_v9_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static void gfx_v9_0_emit_wave_limit(struct amdgpu_ring *ring, bool enable) · line 7118
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10
-0+amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop);
This loop should be removed. I explained the reason in the gfx10 commit.
Marek
Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5
-4+} +static void gfx_v9_ip_print (void *handle,struct drm_printer *p) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -7240,7 +7258,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = { .emit_gds_switch = gfx_v9_0_ring_emit_gds_switch, .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_switch_buffer = gfx_v9_ring_emit_sb, .emit_cntxcntl = gfx_v9_ring_emit_cntxcntl,@@ -7294,7 +7312,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_sw_ring_funcs_gfx = { .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, .test_ib = gfx_v9_0_ring_test_ib, - .insert_nop = amdgpu_sw_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_switch_buffer = gfx_v9_ring_emit_sb, .emit_cntxcntl = gfx_v9_ring_emit_cntxcntl,@@ -7338,7 +7356,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = { .emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush, .test_ring = gfx_v9_0_ring_test_ring, .test_ib = gfx_v9_0_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v9_0_ring_emit_wreg, .emit_reg_wait = gfx_v9_0_ring_emit_reg_wait, --2.34.1
PATCH 3/3 drm/amdgpu: optimize the padding for gfx_v9_4_3
In reply to Sunil KhatriAdding NOP packets one by one in the ring
does not use the CP efficiently.
Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +19 -1
@@ -4178,6 +4178,24 @@ static void gfx_v9_4_3_enable_watchdog_timer(struct amdgpu_device *adev)amdgpu_gfx_ras_error_func (adev,NULL , gfx_v9_4_3_inst_enable_watchdog_timer); } +static void gfx_v9_4_3_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) { +amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop); +} +static const struct amd_ip_funcs gfx_v9_4_3_ip_funcs = { .name ="gfx_v9_4_3" , .early_init = gfx_v9_4_3_early_init,
@@ -4227,7 +4245,7 @@ static const struct amdgpu_ring_funcs gfx_v9_4_3_ring_funcs_compute = { .emit_hdp_flush = gfx_v9_4_3_ring_emit_hdp_flush, .test_ring = gfx_v9_4_3_ring_test_ring, .test_ib = gfx_v9_4_3_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_4_3_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v9_4_3_ring_emit_wreg, .emit_reg_wait = gfx_v9_4_3_ring_emit_reg_wait,
Signature · 1 line
2.34.1
Re: [PATCH v1 3/3] drm/amdgpu: optimize the padding for gfx_v9_4_3
Quoted 33 lines · Sunil Khatri
Adding NOP packets one by one in the ring
does not use the CP efficiently.Solution:
Use CP optimization while adding NOP packet's so PFP can discard NOP packets based on information of count from the Header instead of fetching all NOP packets one by one.Cc Christian König <[email protected]>Cc Pierre-Eric Pelloux-Prayer <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Marek Olšák <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +6
-0@@ -4178,6 +4178,24 @@ static void gfx_v9_4_3_enable_watchdog_timer(struct amdgpu_device *adev)amdgpu_gfx_ras_error_func (adev,NULL , gfx_v9_4_3_inst_enable_watchdog_timer); } +static void gfx_v9_4_3_ring_insert_nop (struct amdgpu_ring *ring,uint32_t num_nop) +{ +int i; + +/* Header itself is a NOP packet */ +if (num_nop ==1 ) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static void gfx_v9_4_3_enable_watchdog_timer(struct amdgpu_device *adev) · line 4196
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +10
-0+amdgpu_ring_write (ring, ring->funcs->nop); +return ; + } + +/* Max HW optimization till 0x3ffe, followed by remaining one NOP at a time*/ +amdgpu_ring_write (ring,PACKET3 (PACKET3_NOP ,min (num_nop -2 ,0x3ffe ))); + +/* Header is at index 0, followed by num_nops - 1 NOP packet's */ +for (i =1 ; i < num_nop; i++) +amdgpu_ring_write (ring, ring->funcs->nop);
This loop should be removed. I explained the reason in the gfx10 commit.
Marek
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +3
-2+} +static const struct amd_ip_funcs gfx_v9_4_3_ip_funcs = { .name ="gfx_v9_4_3" , .early_init = gfx_v9_4_3_early_init,@@ -4227,7 +4245,7 @@ static const struct amdgpu_ring_funcs gfx_v9_4_3_ring_funcs_compute = { .emit_hdp_flush = gfx_v9_4_3_ring_emit_hdp_flush, .test_ring = gfx_v9_4_3_ring_test_ring, .test_ib = gfx_v9_4_3_ring_test_ib, - .insert_nop = amdgpu_ring_insert_nop, + .insert_nop = gfx_v9_4_3_ring_insert_nop, .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v9_4_3_ring_emit_wreg, .emit_reg_wait = gfx_v9_4_3_ring_emit_reg_wait, --2.34.1
Am 31.07.24 um 15:12 schrieb Sunil Khatri:
Quoted 5 lines
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit*** BLURB HERE ***
Quoted 11 lines
Sunil Khatri (3):
drm/amdgpu: optimize the padding for gfx12 drm/amdgpu: optimize the padding for gfx9 drm/amdgpu: optimize the padding forgfx_v9_4_3drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 22 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 24 +++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 20 +++++++++++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-)