Introduce a helper functions to get the CSB buffer
Subsystems (4)
v2 cover Introduce a helper functions to get the CSB buffer
This patchset was inspired from the below series:
https://lore.kernel.org/amd-gfx/[email protected]/
In the above series, there is a bug fix in many functions named gfx_vX_0_get_csb_buffer (where X ranges from 6 to 11). After closely looking at those functions, it became clear that most of the code could be shared from gfx6 to gfx11. Aside from the code duplication removal, this also improves maintainability since a bug fix in a shared function can be propagated to all ASICs.
Alex provided some feedback, and from that, I modified this new version to:
1. Create a dedicated function for the preamble start.
2. Create a function to parse the cs data.
3. Create a helper for finishing the preamble.
4. Replace the duplicated part from gfx6 to 11.
For the GFX update, I created one commit for each to ensure this series is bisectable.
Thanks
Rodrigo Siqueira (9):
drm/amdgpu/gfx: Introduce helpers for CSB manipulation drm/amdgpu/gfx: Use CSB helpers in gfx_v11_0_get_csb_buffer drm/amdgpu/gfx: Use CSB helpers in gfx_v10_0_get_csb_buffer drm/amdgpu/gfx: Use CSB helpers in gfx_v9_0_get_csb_buffer drm/amdgpu/gfx: Use CSB helpers in gfx_v8_0_get_csb_buffer drm/amdgpu/gfx: Use CSB helpers in gfx_v7_0_get_csb_buffer drm/amdgpu/gfx: Clean up gfx_v7_0_get_csb_buffer drm/amdgpu/gfx: Use CSB helpers in gfx_v6_0_get_csb_buffer drm/amdgpu: Add CSB documentation
Documentation/gpu/amdgpu/amdgpu-glossary.rst | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 69 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 14 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 34 ++-------- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 34 ++-------- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 29 ++------ drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 39 ++--------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 34 ++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 32 ++------- 10 files changed, 116 insertions(+), 175 deletions(-)
Signature · 1 line
2.49.0
PATCH v2 1/9 drm/amdgpu/gfx: Introduce helpers for CSB manipulation
From GFX6 to GFX11, there is a function for getting the CSB buffer to be put into the hardware. Three common parts are duplicated in all of these GFX functions:
1. Prepare the CSB preamble.
2. Parser the CS data.
3. End the CSB preamble.
This commit creates helpers to be used from GFX6 to GFX11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 69 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ 2 files changed, 72 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +69 -0
@@ -33,6 +33,7 @@#include "amdgpu_reset.h" #include "amdgpu_xcp.h" #include "amdgpu_xgmi.h" +#include "nvd.h" /* delay 0.1 second to enable gfx off feature */ #define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(100)
@@ -2241,6 +2242,74 @@ void amdgpu_gfx_profile_ring_end_use(struct amdgpu_ring *ring)schedule_delayed_work (&ring->adev->gfx.idle_work,GFX_PROFILE_IDLE_TIMEOUT ); } +/** +* amdgpu_gfx_csb_preamble_start - Set CSB preamble start +* +* @buffer: This is an output variable that gets the PACKET3 preamble setup. +* +* Return: +* return the latest index. +*/ +u32 amdgpu_gfx_csb_preamble_start (volatile u32 *buffer) +{ +u32 count =0 ; + + buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); + buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); + + buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); + buffer[count++] =cpu_to_le32 (0x80000000 ); + buffer[count++] =cpu_to_le32 (0x80000000 ); + +return count; +} + +/** +* amdgpu_gfx_csb_data_parser - Parser CS data +* +* @adev: amdgpu_device pointer used to get the CS data and other gfx info. +* @buffer: This is an output variable that gets the PACKET3 preamble end. +* @count: Index to start set the preemble end. +* +* Return: +* return the latest index. +*/ +u32 amdgpu_gfx_csb_data_parser (struct amdgpu_device *adev,volatile u32 *buffer,u32 count) +{ +const struct cs_section_def *sect =NULL ; +const struct cs_extent_def *ext =NULL ; +u32 i; + +for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { +for (ext = sect->section; ext->extent !=NULL ; ++ext) { +if (sect->id ==SECT_CONTEXT ) { + buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); + buffer[count++] =cpu_to_le32 (ext->reg_index -PACKET3_SET_CONTEXT_REG_START ); + +for (i =0 ; i < ext->reg_count; i++) + buffer[count++] =cpu_to_le32 (ext->extent[i]); + } + } + } + +return count; +} + +/** +* amdgpu_gfx_csb_preamble_end - Set CSB preamble end +* +* @buffer: This is an output variable that gets the PACKET3 preamble end. +* @count: Index to start set the preemble end. +*/ +void amdgpu_gfx_csb_preamble_end (volatile u32 *buffer,u32 count) +{ + buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); + buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); + + buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); + buffer[count++] =cpu_to_le32 (0 ); +} +/* * debugfs for to enable/disable gfx job submission to specific core. */
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3 -0
@@ -598,6 +598,9 @@ void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring *ring);void amdgpu_gfx_profile_idle_work_handler (struct work_struct *work);void amdgpu_gfx_profile_ring_begin_use (struct amdgpu_ring *ring);void amdgpu_gfx_profile_ring_end_use (struct amdgpu_ring *ring); +u32 amdgpu_gfx_csb_preamble_start (volatile u32 *buffer); +u32 amdgpu_gfx_csb_data_parser (struct amdgpu_device *adev,volatile u32 *buffer,u32 count); +void amdgpu_gfx_csb_preamble_end (volatile u32 *buffer,u32 count);void amdgpu_debugfs_gfx_sched_mask_init (struct amdgpu_device *adev);void amdgpu_debugfs_compute_sched_mask_init (struct amdgpu_device *adev);
Signature · 1 line
2.49.0
PATCH v2 2/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v11_0_get_csb_buffer
In reply to Rodrigo SiqueiraPart of the code in gfx_v11_0_get_csb_buffer can be removed in favor of some GFX CSB helpers. This commit removes the duplicated part for the GFX 11 CSB function.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 34 ++++---------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -29
@@ -848,9 +848,7 @@ static u32 gfx_v11_0_get_csb_size(struct amdgpu_device *adev)static void gfx_v11_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;int ctx_reg_offset;if (adev->gfx.rlc.cs_data ==NULL )
@@ -858,37 +856,15 @@ static void gfx_v11_0_get_csb_buffer(struct amdgpu_device *adev,if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index - -PACKET3_SET_CONTEXT_REG_START ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); - ctx_reg_offset = -SOC15_REG_OFFSET (GC ,0 , regPA_SC_TILE_STEERING_OVERRIDE) -PACKET3_SET_CONTEXT_REG_START ; + ctx_reg_offset =SOC15_REG_OFFSET (GC ,0 , regPA_SC_TILE_STEERING_OVERRIDE) -PACKET3_SET_CONTEXT_REG_START ; buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG ,1 )); buffer[count++] =cpu_to_le32 (ctx_reg_offset); buffer[count++] =cpu_to_le32 (adev->gfx.config.pa_sc_tile_steering_override); - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); +amdgpu_gfx_csb_preamble_end (buffer, count); }static void gfx_v11_0_rlc_fini (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 3/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v10_0_get_csb_buffer
In reply to Rodrigo SiqueiraRemove duplicate code by using CSB helpers.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 34 ++++---------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +5 -29
@@ -4325,9 +4325,7 @@ static u32 gfx_v10_0_get_csb_size(struct amdgpu_device *adev)static void gfx_v10_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;int ctx_reg_offset;if (adev->gfx.rlc.cs_data ==NULL )
@@ -4335,37 +4333,15 @@ static void gfx_v10_0_get_csb_buffer(struct amdgpu_device *adev,if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index - -PACKET3_SET_CONTEXT_REG_START ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); - ctx_reg_offset = -SOC15_REG_OFFSET (GC ,0 , mmPA_SC_TILE_STEERING_OVERRIDE) -PACKET3_SET_CONTEXT_REG_START ; + ctx_reg_offset =SOC15_REG_OFFSET (GC ,0 , mmPA_SC_TILE_STEERING_OVERRIDE) -PACKET3_SET_CONTEXT_REG_START ; buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG ,1 )); buffer[count++] =cpu_to_le32 (ctx_reg_offset); buffer[count++] =cpu_to_le32 (adev->gfx.config.pa_sc_tile_steering_override); - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); +amdgpu_gfx_csb_preamble_end (buffer, count); }static void gfx_v10_0_rlc_fini (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 4/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v9_0_get_csb_buffer
In reply to Rodrigo SiqueiraEliminate code duplication in gfx_v9_0_get_csb_buffer by using CSB helpers.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 32 ++++----------------------- 1 file changed, 4 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -28
@@ -1651,40 +1651,16 @@ static u32 gfx_v9_0_get_csb_size(struct amdgpu_device *adev)static void gfx_v9_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;if (adev->gfx.rlc.cs_data ==NULL )return ;if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index - -PACKET3_SET_CONTEXT_REG_START ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); +amdgpu_gfx_csb_preamble_end (buffer, count); }static void gfx_v9_0_init_always_on_cu_mask (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 5/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v8_0_get_csb_buffer
In reply to Rodrigo SiqueiraRemove code duplication from gfx_v8_0_get_csb_buffer by using CSB helpers.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 34 ++++----------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +5 -29
@@ -1223,46 +1223,22 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)static void gfx_v8_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;if (adev->gfx.rlc.cs_data ==NULL )return ;if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index - -PACKET3_SET_CONTEXT_REG_START ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG ,2 )); - buffer[count++] =cpu_to_le32 (mmPA_SC_RASTER_CONFIG - -PACKET3_SET_CONTEXT_REG_START ); + buffer[count++] =cpu_to_le32 (mmPA_SC_RASTER_CONFIG -PACKET3_SET_CONTEXT_REG_START ); buffer[count++] =cpu_to_le32 (adev->gfx.config.rb_config[0 ][0 ].raster_config); buffer[count++] =cpu_to_le32 (adev->gfx.config.rb_config[0 ][0 ].raster_config_1); - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); +amdgpu_gfx_csb_preamble_end (buffer, count); }static int gfx_v8_0_cp_jump_table_num (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 6/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v7_0_get_csb_buffer
In reply to Rodrigo SiqueiraUse CSB helpers to remove code duplication from gfx_v7_0_get_csb_buffer.
--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 30 ++++----------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +4 -26
@@ -3885,33 +3885,15 @@ static u32 gfx_v7_0_get_csb_size(struct amdgpu_device *adev)static void gfx_v7_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;if (adev->gfx.rlc.cs_data ==NULL )return ;if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index -PACKET3_SET_CONTEXT_REG_START ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG ,2 )); buffer[count++] =cpu_to_le32 (mmPA_SC_RASTER_CONFIG -PACKET3_SET_CONTEXT_REG_START );
@@ -3939,11 +3921,7 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev,break ; } - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); +amdgpu_gfx_csb_preamble_end (buffer, count); }static void gfx_v7_0_init_pg (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 7/9 drm/amdgpu/gfx: Clean up gfx_v7_0_get_csb_buffer
In reply to Rodrigo SiqueiraCHIP_KAVERI, CHIP_KABINI, and CHIP_MULLINS have the same buffer manipulation as the default option in the switch case. Remove those specific manipulations and rely on the default behavior for them.
--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
@@ -3902,15 +3902,6 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (0x16000012 ); buffer[count++] =cpu_to_le32 (0x00000000 );break ; -case CHIP_KAVERI : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ; -case CHIP_KABINI : -case CHIP_MULLINS : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ;case CHIP_HAWAII : buffer[count++] =cpu_to_le32 (0x3a00161a ); buffer[count++] =cpu_to_le32 (0x0000002e );
Signature · 1 line
2.49.0
Re: [PATCH v2 7/9] drm/amdgpu/gfx: Clean up gfx_v7_0_get_csb_buffer
Quoted 17 lines · Rodrigo Siqueira
CHIP_KAVERI,CHIP_KABINI, andCHIP_MULLINShave the same buffer manipulation as the default option in the switch case. Remove those specific manipulations and rely on the default behavior for them.Signed-off-by Rodrigo Siqueira <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 9 --------- 1 file changed, 9 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-0@@ -3902,15 +3902,6 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (0x16000012 ); buffer[count++] =cpu_to_le32 (0x00000000 );
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, · line 3913
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-9break ; -case CHIP_KAVERI : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ; -case CHIP_KABINI : -case CHIP_MULLINS : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ;
These should be fixed rather than removed. Actually, all of these should be fixed up for all chips. We should use the values calculated by the driver similar to what we do in gfx_v8. E.g.,
buffer[count++] =
cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config);
buffer[count++] =cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config_1);
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-1case CHIP_HAWAII : buffer[count++] =cpu_to_le32 (0x3a00161a ); buffer[count++] =cpu_to_le32 (0x0000002e ); --2.49.0
Re: [PATCH v2 7/9] drm/amdgpu/gfx: Clean up gfx_v7_0_get_csb_buffer
Quoted 32 lines · Alex Deucher
Quoted 17 lines · Rodrigo Siqueira
CHIP_KAVERI,CHIP_KABINI, andCHIP_MULLINShave the same buffer manipulation as the default option in the switch case. Remove those specific manipulations and rely on the default behavior for them.Signed-off-by Rodrigo Siqueira <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 9 --------- 1 file changed, 9 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-0@@ -3902,15 +3902,6 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (0x16000012 ); buffer[count++] =cpu_to_le32 (0x00000000 );drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, · line 3913
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-9break ; -case CHIP_KAVERI : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ; -case CHIP_KABINI : -case CHIP_MULLINS : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ;These should be fixed rather than removed. Actually, all of these should be fixed up for all chips. We should use the values calculated by the driver similar to what we do in
gfx_v8. E.g.,
Quoted 5 lines
buffer[count++] = cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config); buffer[count++] =
cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config_1);
ok, I checked the code sequence, and fwiu gfx_v7_0_setup_rb() -> gfx_v7_0_raster_config() is called before gfx_v7_0_get_csb_buffer(). gfx_v7_0_raster_config() has the setup for all of the ASICs in this part. I also have a HAWAII and confirmed that using raster_config directly had the same value as the one hardcoded in this part. Anyway, I'll send a v3 with this fix.
When I was looking into the code, it was not clear to me these things:
1. What is this config RB? Why is there a field for User RB? Also, what RB stands for?
2. Why there is raster_config and raster_config_1? Is raster_config_1 some sort of fallback?
Thanks
Quoted 8 lines
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-1case CHIP_HAWAII : buffer[count++] =cpu_to_le32 (0x3a00161a ); buffer[count++] =cpu_to_le32 (0x0000002e ); --2.49.0
Signature · 1 line
Rodrigo Siqueira
Re: [PATCH v2 7/9] drm/amdgpu/gfx: Clean up gfx_v7_0_get_csb_buffer
Quoted 47 lines · Rodrigo Siqueira
Quoted 32 lines · Alex Deucher
Quoted 17 lines · Rodrigo Siqueira
CHIP_KAVERI,CHIP_KABINI, andCHIP_MULLINShave the same buffer manipulation as the default option in the switch case. Remove those specific manipulations and rely on the default behavior for them.Signed-off-by Rodrigo Siqueira <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 9 --------- 1 file changed, 9 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-0@@ -3902,15 +3902,6 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (0x16000012 ); buffer[count++] =cpu_to_le32 (0x00000000 );drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, · line 3913
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-9break ; -case CHIP_KAVERI : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ; -case CHIP_KABINI : -case CHIP_MULLINS : - buffer[count++] =cpu_to_le32 (0x00000000 );/* XXX */ - buffer[count++] =cpu_to_le32 (0x00000000 ); -break ;These should be fixed rather than removed. Actually, all of these should be fixed up for all chips. We should use the values calculated by the driver similar to what we do in
gfx_v8. E.g.,Quoted 5 lines
buffer[count++] = cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config); buffer[count++] =
cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config_1);ok, I checked the code sequence, and fwiu
gfx_v7_0_setup_rb()->gfx_v7_0_raster_config()is called beforegfx_v7_0_get_csb_buffer().
gfx_v7_0_raster_config()has the setup for all of the ASICs in this
part. I also have a HAWAII and confirmed that usingraster_configdirectly had the same value as the one hardcoded in this part. Anyway, I'll send a v3 with this fix.
Quoted 4 lines
When I was looking into the code, it was not clear to me these things:
1. What is this config RB? Why is there a field for User RB? Also, what RB stands for?
RB = Render Backends. These are the render backends (color and depth buffer handling) on the 3D engine (also called ROPs by a lot of people). Bad RBs are fused off and there is a harvest register the driver reads to determine which RB(s) are fused off so that the driver can configure the hardware state so that nothing gets sent to them. There are also user harvest registers that the driver can program to disable additional RBs, etc. for testing purposes.
Quoted 2 lines
2. Why there is
raster_configandraster_config_1? Israster_config_1some sort of fallback?
The configuration just happens to require two registers to hold all of the state.
Alex
Quoted 14 lines
Thanks
Quoted 8 lines
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0
-1case CHIP_HAWAII : buffer[count++] =cpu_to_le32 (0x3a00161a ); buffer[count++] =cpu_to_le32 (0x0000002e ); --2.49.0
--
Rodrigo Siqueira
PATCH v2 8/9 drm/amdgpu/gfx: Use CSB helpers in gfx_v6_0_get_csb_buffer
In reply to Rodrigo SiqueiraRemove duplications from gfx_v6_0_get_csb_buffer by using CSB helpers.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 29 ++++----------------------- 1 file changed, 4 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +4 -25
@@ -2858,42 +2858,21 @@ static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev)static void gfx_v6_0_get_csb_buffer (struct amdgpu_device *adev,volatile u32 *buffer) { -u32 count =0 , i; -const struct cs_section_def *sect =NULL ; -const struct cs_extent_def *ext =NULL ; +u32 count =0 ;if (adev->gfx.rlc.cs_data ==NULL )return ;if (buffer ==NULL )return ; - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ); - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); - buffer[count++] =cpu_to_le32 (0x80000000 ); - buffer[count++] =cpu_to_le32 (0x80000000 ); - -for (sect = adev->gfx.rlc.cs_data; sect->section !=NULL ; ++sect) { -for (ext = sect->section; ext->extent !=NULL ; ++ext) { -if (sect->id ==SECT_CONTEXT ) { - buffer[count++] = -cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG , ext->reg_count)); - buffer[count++] =cpu_to_le32 (ext->reg_index -0xa000 ); -for (i =0 ; i < ext->reg_count; i++) - buffer[count++] =cpu_to_le32 (ext->extent[i]); - } - } - } + count =amdgpu_gfx_csb_preamble_start (buffer); + count =amdgpu_gfx_csb_data_parser (adev, buffer, count); buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_SET_CONTEXT_REG ,1 )); buffer[count++] =cpu_to_le32 (mmPA_SC_RASTER_CONFIG -PACKET3_SET_CONTEXT_REG_START ); buffer[count++] =cpu_to_le32 (adev->gfx.config.rb_config[0 ][0 ].raster_config); - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_PREAMBLE_CNTL ,0 )); - buffer[count++] =cpu_to_le32 (PACKET3_PREAMBLE_END_CLEAR_STATE ); - - buffer[count++] =cpu_to_le32 (PACKET3 (PACKET3_CLEAR_STATE ,0 )); - buffer[count++] =cpu_to_le32 (0 ); +amdgpu_gfx_csb_preamble_end (buffer, count); }static void gfx_v6_0_init_pg (struct amdgpu_device *adev)
Signature · 1 line
2.49.0
PATCH v2 9/9 drm/amdgpu: Add CSB documentation
In reply to Rodrigo SiqueiraAdd a description for the get_csb_buffer callback and an entry for CSB in the glossary.
--- Documentation/gpu/amdgpu/amdgpu-glossary.rst | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+)
Documentation/gpu/amdgpu/amdgpu-glossary.rst +3 -0
@@ -33,6 +33,9 @@ we have a dedicated glossary for Display Core at CS Command Submission + CSB + Clear State Indirect Buffer + CU Compute Unit
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +14 -0
@@ -237,6 +237,20 @@ struct amdgpu_rlc_funcs {void (*unset_safe_mode)(struct amdgpu_device *adev,int xcc_id);int (*init)(struct amdgpu_device *adev);u32 (*get_csb_size)(struct amdgpu_device *adev); + +/** +* @get_csb_buffer: Get the clear state to be put into the hardware. +* +* The parameter adev is used to get the CS data and other gfx info, +* and buffer is the RLC CS pointer +* +* Sometimes, the user space puts a request to clear the state in the +* command buffer; this function provides the clear state that gets put +* into the hardware. Note that the driver programs Clear State +* Indirect Buffer (CSB) explicitly when it sets up the kernel rings, +* and it also provides a pointer to it which is used by the firmware +* to load the clear state in some cases. +*/ void (*get_csb_buffer)(struct amdgpu_device *adev,volatile u32 *buffer);int (*get_cp_table_num)(struct amdgpu_device *adev);int (*resume)(struct amdgpu_device *adev);
Signature · 1 line
2.49.0