drm/amdgpu: Clean up GFX v9.4.3 IP version checks
Subsystems (2)
PATCH 1/2 drm/amdgpu: Clean up GFX v9.4.3 IP version checks
Remove unnecessary IP version checks for GFX 9.4.3 and similar variants. Wrap checks inside meaningful function.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 68 ++++++------------------ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c | 22 ++++---- 2 files changed, 29 insertions(+), 61 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +16 -52
@@ -942,21 +942,12 @@ static int gfx_v9_4_3_gpu_early_init(struct amdgpu_device *adev) adev->gfx.funcs = &gfx_v9_4_3_gfx_funcs; adev->gfx.ras = &gfx_v9_4_3_ras; -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): - adev->gfx.config.max_hw_contexts =8 ; - adev->gfx.config.sc_prim_fifo_size_frontend =0x20 ; - adev->gfx.config.sc_prim_fifo_size_backend =0x100 ; - adev->gfx.config.sc_hiz_tile_fifo_size =0x30 ; - adev->gfx.config.sc_earlyz_tile_fifo_size =0x4C0 ; - gb_addr_config =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regGB_ADDR_CONFIG); -break ; -default : -BUG (); -break ; - } + adev->gfx.config.max_hw_contexts =8 ; + adev->gfx.config.sc_prim_fifo_size_frontend =0x20 ; + adev->gfx.config.sc_prim_fifo_size_backend =0x100 ; + adev->gfx.config.sc_hiz_tile_fifo_size =0x30 ; + adev->gfx.config.sc_earlyz_tile_fifo_size =0x4C0 ; + gb_addr_config =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regGB_ADDR_CONFIG); adev->gfx.config.gb_addr_config = gb_addr_config;
@@ -2795,16 +2786,10 @@ static int gfx_v9_4_3_set_clockgating_state(struct amdgpu_ip_block *ip_block,return 0 ; num_xcc =NUM_XCC (adev->gfx.xcc_mask); -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -for (i =0 ; i < num_xcc; i++) -gfx_v9_4_3_xcc_update_gfx_clock_gating ( - adev, state ==AMD_CG_STATE_GATE , i); -break ; -default : -break ; - } +for (i =0 ; i < num_xcc; i++) +gfx_v9_4_3_xcc_update_gfx_clock_gating ( + adev, state ==AMD_CG_STATE_GATE , i); +return 0 ; }
@@ -4867,34 +4852,13 @@ static void gfx_v9_4_3_set_rlc_funcs(struct amdgpu_device *adev)static void gfx_v9_4_3_set_gds_init (struct amdgpu_device *adev) { -/* init asci gds info */ -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): -/* 9.4.3 removed all the GDS internal memory, -* only support GWS opcode in kernel, like barrier -* semaphore.etc */ - adev->gds.gds_size =0 ; -break ; -default : - adev->gds.gds_size =0x10000 ; -break ; - } - -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): -/* deprecated for 9.4.3, no usage at all */ - adev->gds.gds_compute_max_wave_id =0 ; -break ; -default : -/* this really depends on the chip */ - adev->gds.gds_compute_max_wave_id =0x7ff ; -break ; - } +/* 9.4.3 variants removed all the GDS internal memory, +* only support GWS opcode in kernel, like barrier +* semaphore.etc */ +/* init asic gds info */ + adev->gds.gds_size =0 ; + adev->gds.gds_compute_max_wave_id =0 ; adev->gds.gws_size =64 ; adev->gds.oa_size =16 ; }
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c +13 -9
@@ -313,6 +313,16 @@ gfxhub_v1_2_xcc_disable_identity_aperture(struct amdgpu_device *adev, } } +static inline bool +gfxhub_v1_2_per_process_xnack_support (struct amdgpu_device *adev) +{ +/* +* TODO: Check if this function is really needed, so far only 9.4.3 +* variants use GFXHUB 1.2 +*/ +return !!adev->aid_mask; +} +static void gfxhub_v1_2_xcc_setup_vmid_config (struct amdgpu_device *adev,uint32_t xcc_mask) {
@@ -355,7 +365,7 @@ static void gfxhub_v1_2_xcc_setup_vmid_config(struct amdgpu_device *adev,PAGE_TABLE_BLOCK_SIZE , block_size);/* Send no-retry XNACK on fault to suppress VM fault storm. -* On 9.4.2 and 9.4.3, XNACK can be enabled in +* On 9.4.3 variants, XNACK can be enabled in * the SQ per-process. * Retry faults need to be enabled for that to work. */
@@ -363,14 +373,8 @@ static void gfxhub_v1_2_xcc_setup_vmid_config(struct amdgpu_device *adev, tmp,VM_CONTEXT1_CNTL ,RETRY_PERMISSION_OR_INVALID_PAGE_FAULT , !adev->gmc.noretry || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == - IP_VERSION(9, 5, 0)); +gfxhub_v1_2_per_process_xnack_support ( + adev));WREG32_SOC15_OFFSET (GC ,GET_INST (GC , j), regVM_CONTEXT1_CNTL, i * hub->ctx_distance, tmp); WREG32_SOC15_OFFSET(GC, GET_INST(GC, j),
Signature · 1 line
2.25.1
PATCH 2/2 drm/amdgpu: Clean up IP version checks in gmcv9.0
Clean up some IP version checks in gmcv9.0
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 49 ++++++++++----------------- 1 file changed, 17 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +17 -32
@@ -411,6 +411,11 @@ static const uint32_t ecc_umc_mcumc_ctrl_mask_addrs[] = { (0x001d43e0 + 0x00001800), }; +static inline bool gmc_v9_0_is_multi_chiplet (struct amdgpu_device *adev) +{ +return !!adev->aid_mask; +} + static int gmc_v9_0_ecc_interrupt_state(struct amdgpu_device *adev, struct amdgpu_irq_src *src, unsigned int type,
@@ -647,9 +652,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, addr, entry->client_id, soc15_ih_clientid_name[entry->client_id]); -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +if (gmc_v9_0_is_multi_chiplet (adev))dev_err (adev->dev," cookie node_id %d fault from die %s%d%s\n" , node_id, node_id %4 ==3 ?"RSV" :"AID" , node_id /4 , node_id %4 ==1 ?".XCD0" : node_id %4 ==2 ?".XCD1" :"" );
@@ -798,9 +801,7 @@ static bool gmc_v9_0_use_invalidate_semaphore(struct amdgpu_device *adev, uint32_t vmhub) {if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +gmc_v9_0_is_multi_chiplet (adev))return false; return ((vmhub == AMDGPU_MMHUB0(0) ||
@@ -1278,9 +1279,8 @@ static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev,/* Only GFX 9.4.3 APUs associate GPUs with NUMA nodes. Local system * memory can use more efficient MTYPEs. */ -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) !=IP_VERSION (9 ,4 ,3 ) && -amdgpu_ip_version (adev,GC_HWIP ,0 ) !=IP_VERSION (9 ,4 ,4 ) && -amdgpu_ip_version (adev,GC_HWIP ,0 ) !=IP_VERSION (9 ,5 ,0 )) +if (!(adev->flags &AMD_IS_APU ) || +amdgpu_ip_version (adev,GC_HWIP ,0 ) !=IP_VERSION (9 ,4 ,3 ))return ;/* Only direct-mapped memory allows us to determine the NUMA node from
@@ -1555,9 +1555,7 @@ static void gmc_v9_0_set_mmhub_ras_funcs(struct amdgpu_device *adev)static void gmc_v9_0_set_gfxhub_funcs (struct amdgpu_device *adev) { -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +if (gmc_v9_0_is_multi_chiplet (adev)) adev->gfxhub.funcs = &gfxhub_v1_2_funcs;else adev->gfxhub.funcs = &gfxhub_v1_0_funcs;
@@ -1634,9 +1632,7 @@ static int gmc_v9_0_early_init(struct amdgpu_ip_block *ip_block)*/ if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) ||amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,1 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +gmc_v9_0_is_multi_chiplet (adev)) adev->gmc.xgmi.supported = true;if (amdgpu_ip_version (adev,XGMI_HWIP ,0 ) ==IP_VERSION (6 ,1 ,0 )) {
@@ -1645,8 +1641,7 @@ static int gmc_v9_0_early_init(struct amdgpu_ip_block *ip_block) adev->smuio.funcs->is_host_gpu_xgmi_supported (adev); } -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 )) { +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 )) {enum amdgpu_pkg_type pkg_type = adev->smuio.funcs->get_pkg_type (adev);/* On GFXIP 9.4.3. APU, there is no physical VRAM domain present
@@ -2087,9 +2082,7 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)spin_lock_init (&adev->gmc.invalidate_lock); -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) { +if (gmc_v9_0_is_multi_chiplet (adev)) {gmc_v9_4_3_init_vram_info (adev); }else if (!adev->bios) {if (adev->flags &AMD_IS_APU ) {
@@ -2239,9 +2232,7 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)amdgpu_gmc_get_vbios_allocations (adev); -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) { +if (gmc_v9_0_is_multi_chiplet (adev)) { r =gmc_v9_0_init_mem_ranges (adev);if (r)return r;
@@ -2270,9 +2261,7 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block) adev->vm_manager.first_kfd_vmid = (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,1 ) ||amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) ? +gmc_v9_0_is_multi_chiplet (adev)) ?3 :8 ;
@@ -2284,9 +2273,7 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)if (r)return r; -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +if (gmc_v9_0_is_multi_chiplet (adev))amdgpu_gmc_sysfs_init (adev);return 0 ;
@@ -2296,9 +2283,7 @@ static int gmc_v9_0_sw_fini(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) +if (gmc_v9_0_is_multi_chiplet (adev))amdgpu_gmc_sysfs_fini (adev);amdgpu_gmc_ras_fini (adev);
Signature · 1 line
2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Series is
Thanks & Regards
Asad
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 28, 2025 1:22 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Clean up GFX v9.4.3 IP version checks
Remove unnecessary IP version checks for GFX 9.4.3 and similar variants. Wrap checks inside meaningful function.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 68 ++++++------------------ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c | 22 ++++---- 2 files changed, 29 insertions(+), 61 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +16 -52
@@ -942,21 +942,12 @@ static int gfx_v9_4_3_gpu_early_init(struct amdgpu_device *adev) adev->gfx.funcs = &gfx_v9_4_3_gfx_funcs; adev->gfx.ras = &gfx_v9_4_3_ras; -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): - adev->gfx.config.max_hw_contexts =8 ; - adev->gfx.config.sc_prim_fifo_size_frontend =0x20 ; - adev->gfx.config.sc_prim_fifo_size_backend =0x100 ; - adev->gfx.config.sc_hiz_tile_fifo_size =0x30 ; - adev->gfx.config.sc_earlyz_tile_fifo_size =0x4C0 ; - gb_addr_config =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regGB_ADDR_CONFIG); -break ; -default : -BUG (); -break ; - } + adev->gfx.config.max_hw_contexts =8 ; + adev->gfx.config.sc_prim_fifo_size_frontend =0x20 ; + adev->gfx.config.sc_prim_fifo_size_backend =0x100 ; + adev->gfx.config.sc_hiz_tile_fifo_size =0x30 ; + adev->gfx.config.sc_earlyz_tile_fifo_size =0x4C0 ; + gb_addr_config =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regGB_ADDR_CONFIG); adev->gfx.config.gb_addr_config = gb_addr_config;
@@ -2795,16 +2786,10 @@ static int gfx_v9_4_3_set_clockgating_state(struct amdgpu_ip_block *ip_block,return 0 ; num_xcc =NUM_XCC (adev->gfx.xcc_mask); -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -for (i =0 ; i < num_xcc; i++) -gfx_v9_4_3_xcc_update_gfx_clock_gating ( - adev, state ==AMD_CG_STATE_GATE , i); -break ; -default : -break ; - } +for (i =0 ; i < num_xcc; i++) +gfx_v9_4_3_xcc_update_gfx_clock_gating ( + adev, state ==AMD_CG_STATE_GATE , i); +return 0 ; }
@@ -4867,34 +4852,13 @@ static void gfx_v9_4_3_set_rlc_funcs(struct amdgpu_device *adev)static void gfx_v9_4_3_set_gds_init (struct amdgpu_device *adev) { -/* init asci gds info */ -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): -/* 9.4.3 removed all the GDS internal memory, -* only support GWS opcode in kernel, like barrier -* semaphore.etc */ - adev->gds.gds_size =0 ; -break ; -default : - adev->gds.gds_size =0x10000 ; -break ; - } - -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { -case IP_VERSION (9 ,4 ,3 ): -case IP_VERSION (9 ,4 ,4 ): -case IP_VERSION (9 ,5 ,0 ): -/* deprecated for 9.4.3, no usage at all */ - adev->gds.gds_compute_max_wave_id =0 ; -break ; -default : -/* this really depends on the chip */ - adev->gds.gds_compute_max_wave_id =0x7ff ; -break ; - } +/* 9.4.3 variants removed all the GDS internal memory, +* only support GWS opcode in kernel, like barrier +* semaphore.etc */ +/* init asic gds info */ + adev->gds.gds_size =0 ; + adev->gds.gds_compute_max_wave_id =0 ; adev->gds.gws_size =64 ; adev->gds.oa_size =16 ; }
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c +12 -9
@@ -313,6 +313,16 @@ gfxhub_v1_2_xcc_disable_identity_aperture(struct amdgpu_device *adev, } } +static inline bool +gfxhub_v1_2_per_process_xnack_support (struct amdgpu_device *adev) { +/* +* TODO: Check if this function is really needed, so far only 9.4.3 +* variants use GFXHUB 1.2 +*/ +return !!adev->aid_mask; +} +static void gfxhub_v1_2_xcc_setup_vmid_config (struct amdgpu_device *adev,uint32_t xcc_mask) {
@@ -355,7 +365,7 @@ static void gfxhub_v1_2_xcc_setup_vmid_config(struct amdgpu_device *adev,PAGE_TABLE_BLOCK_SIZE , block_size);/* Send no-retry XNACK on fault to suppress VM fault storm. -* On 9.4.2 and 9.4.3, XNACK can be enabled in +* On 9.4.3 variants, XNACK can be enabled in * the SQ per-process. * Retry faults need to be enabled for that to work. */
@@ -363,14 +373,8 @@ static void gfxhub_v1_2_xcc_setup_vmid_config(struct amdgpu_device *adev, tmp,VM_CONTEXT1_CNTL ,RETRY_PERMISSION_OR_INVALID_PAGE_FAULT , !adev->gmc.noretry || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,3 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,4 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == - IP_VERSION(9, 5, 0)); +gfxhub_v1_2_per_process_xnack_support ( + adev));WREG32_SOC15_OFFSET (GC ,GET_INST (GC , j), regVM_CONTEXT1_CNTL, i * hub->ctx_distance, tmp); WREG32_SOC15_OFFSET(GC, GET_INST(GC, j),
--
2.25.1