drm/amdgpu: Fix SHMEM alignment mode for GFX 12.1.0
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Fix SHMEM alignment mode for GFX 12.1.0
From: Mukul Joshi <[email protected]>
Alignment mode in SHMEM config register is only a single bit value on GFX 12.1.0 instead of 2 bits in previous asics. Add a new enum and use the correct value of SHMEM alignment mode when programming the SHMEM config register.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c | 2 +- drivers/gpu/drm/amd/include/soc_v1_0_enum.h | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -1
@@ -52,9 +52,10 @@MODULE_FIRMWARE ("amdgpu/gc_12_1_0_mec.bin" );MODULE_FIRMWARE ("amdgpu/gc_12_1_0_rlc.bin" ); +#define SH_MEM_ALIGNMENT_MODE_UNALIGNED_GFX12_1_0 0x00000001#define DEFAULT_SH_MEM_CONFIG \ ((SH_MEM_ADDRESS_MODE_64 << SH_MEM_CONFIG__ADDRESS_MODE__SHIFT) | \ - (SH_MEM_ALIGNMENT_MODE_UNALIGNED << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \ + (SH_MEM_ALIGNMENT_MODE_UNALIGNED_GFX12_1_0 << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \ (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT))static void gfx_v12_1_xcc_disable_gpa_mode (struct amdgpu_device *adev,int xcc_id);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c +1 -1
@@ -24,7 +24,7 @@#include "kfd_device_queue_manager.h" #include "gc/gc_12_1_0_sh_mask.h" -#include "soc24_enum.h" +#include "soc_v1_0_enum.h" static int update_qpd_v12_1 (struct device_queue_manager *dqm,struct qcm_process_device *qpd);
drivers/gpu/drm/amd/include/soc_v1_0_enum.h +5 -0
@@ -30,4 +30,9 @@ typedef enum MTYPE {MTYPE_UC =0x00000003 , } MTYPE; +typedef enum SH_MEM_ALIGNMENT_MODE { +SH_MEM_ALIGNMENT_MODE_DWORD =0x00000000 , +SH_MEM_ALIGNMENT_MODE_UNALIGNED =0x00000001 , +}SH_MEM_ALIGNMENT_MODE ; +#endif
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: update sh mem base offsets for gfx 12.1
From: Alex Sierra <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +4 -4
@@ -1339,8 +1339,8 @@ static void gfx_v12_1_setup_rb(struct amdgpu_device *adev) adev->gfx.config.num_rbs =hweight32 (active_rb_bitmap); } -#define LDS_APP_BASE 0x1 -#define SCRATCH_APP_BASE 0x2 +#define LDS_APP_BASE 0x2000 +#define SCRATCH_APP_BASE 0x4static void gfx_v12_1_xcc_init_compute_vmid (struct amdgpu_device *adev,int xcc_id)
@@ -1356,7 +1356,7 @@ static void gfx_v12_1_xcc_init_compute_vmid(struct amdgpu_device *adev,* GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB) */ sh_mem_bases = (LDS_APP_BASE <<SH_MEM_BASES__SHARED_BASE__SHIFT ) | -SCRATCH_APP_BASE ; + (SCRATCH_APP_BASE <<SH_MEM_BASES__PRIVATE_BASE__SHIFT );mutex_lock (&adev->srbm_mutex);for (i = adev->vm_manager.first_kfd_vmid; i <AMDGPU_NUM_VMID ; i++) {
@@ -1399,7 +1399,7 @@ static void gfx_v12_1_xcc_constants_init(struct amdgpu_device *adev, regSH_MEM_CONFIG, DEFAULT_SH_MEM_CONFIG);if (i !=0 ) { tmp =REG_SET_FIELD (0 ,SH_MEM_BASES ,PRIVATE_BASE , - (adev->gmc.private_aperture_start >>48 )); + (adev->gmc.private_aperture_start >>58 )); tmp =REG_SET_FIELD (tmp,SH_MEM_BASES ,SHARED_BASE , (adev->gmc.shared_aperture_start >>48 ));WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regSH_MEM_BASES, tmp);
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Setup MTYPEs for GFX 12.1.0
In reply to Alex DeucherFrom: Mukul Joshi <[email protected]>
For GFX 12.1.0, setup correct MTYPE for a BO depending on its current location relative to the mapping GPU.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 62 ++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 15 +++++++ 2 files changed, 74 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +59 -3
@@ -265,6 +265,62 @@ static void gmc_v12_1_get_vm_pde(struct amdgpu_device *adev, int level, } } +#if 0 +static void gmc_v12_1_get_coherence_flags (struct amdgpu_device *adev, +struct amdgpu_bo *bo, +uint64_t *flags) +{ +struct amdgpu_device *bo_adev =amdgpu_ttm_adev (bo->tbo.bdev); +bool is_vram = bo->tbo.resource && + bo->tbo.resource->mem_type ==TTM_PL_VRAM ; +bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT | +AMDGPU_GEM_CREATE_EXT_COHERENT ); +bool ext_coherent = bo->flags &AMDGPU_GEM_CREATE_EXT_COHERENT ; +uint32_t gc_ip_version =amdgpu_ip_version (adev,GC_HWIP ,0 ); +bool uncached = bo->flags &AMDGPU_GEM_CREATE_UNCACHED ; +unsigned int mtype, mtype_local; +bool snoop = false; +bool is_local; + +switch (gc_ip_version) { +case IP_VERSION (12 ,1 ,0 ): + mtype_local =MTYPE_RW ; +if (amdgpu_mtype_local ==1 ) { +DRM_INFO_ONCE ("Using MTYPE_NC for local memory\n" ); + mtype_local =MTYPE_NC ; + }else if (amdgpu_mtype_local ==2 ) { +DRM_INFO_ONCE ("MTYPE_CC not supported, using MTYPE_RW instead for local memory\n" ); + }else { +DRM_INFO_ONCE ("Using MTYPE_RW for local memory\n" ); + } + + is_local = (is_vram && adev == bo_adev); + snoop = true; +if (uncached) { + mtype =MTYPE_UC ; + }else if (ext_coherent) { + mtype = is_local ? mtype_local :MTYPE_UC ; + }else { +if (is_local) + mtype = mtype_local; +else + mtype =MTYPE_NC ; + } +break ; +default : +if (uncached || coherent) + mtype =MTYPE_UC ; +else + mtype =MTYPE_NC ; + } + +if (mtype !=MTYPE_NC ) + *flags =AMDGPU_PTE_MTYPE_GFX12 (*flags, mtype); + + *flags |= snoop ?AMDGPU_PTE_SNOOPED :0 ; +} +#endif + static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_bo *bo,
@@ -306,11 +362,11 @@ static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev, AMDGPU_GEM_CREATE_UNCACHED)) *flags =AMDGPU_PTE_MTYPE_NV10 (*flags,MTYPE_UC ); -if (bo && bo->flags &AMDGPU_GEM_CREATE_UNCACHED ) - *flags =AMDGPU_PTE_MTYPE_GFX12 (*flags,MTYPE_UC ); -if (adev->have_atomics_support) *flags |=AMDGPU_PTE_BUS_ATOMICS ; + +if (bo && bo->flags &AMDGPU_GEM_CREATE_UNCACHED ) + *flags =AMDGPU_PTE_MTYPE_GFX12 (*flags,MTYPE_UC ); }static const struct amdgpu_gmc_funcs gmc_v12_1_gmc_funcs = {
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +15 -0
@@ -1287,6 +1287,21 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm,case IP_VERSION (12 ,0 ,1 ): mapping_flags |=AMDGPU_VM_MTYPE_NC ;break ; +case IP_VERSION (12 ,1 ,0 ): + snoop = true; +if (domain ==SVM_RANGE_VRAM_DOMAIN ) { +/* local HBM */ +if (bo_node->adev == node->adev) + mapping_flags |=AMDGPU_VM_MTYPE_RW ; +/* Remote GPU memory */ +else + mapping_flags |= ext_coherent ?AMDGPU_VM_MTYPE_UC : +AMDGPU_VM_MTYPE_NC ; +/* system memory accessed by the dGPU */ + }else { + mapping_flags |= ext_coherent ?AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_NC ; + } +break ;default : mapping_flags |= coherent ?AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_NC ;
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Revert retry based thrashing prevention on GFX 12.1.0
In reply to Alex DeucherFrom: Mukul Joshi <[email protected]>
Revert the change to enable retry based thrashing prevention on GFX 12.1.0 for now as its causing data mismatch and slowness issues with multiple HIP tests.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -11
@@ -2512,17 +2512,6 @@ static void gfx_v12_1_init_golden_registers(struct amdgpu_device *adev) {uint32_t val; -/* Setup the TCP Thrashing control register */ - val =RREG32_SOC15 (GC ,0 , regTCP_UTCL0_THRASHING_CTRL); - - val =REG_SET_FIELD (val,TCP_UTCL0_THRASHING_CTRL ,THRASHING_EN ,0x2 ); - val =REG_SET_FIELD (val,TCP_UTCL0_THRASHING_CTRL , -RETRY_FRAGMENT_THRESHOLD_DOWN_EN ,0x0 ); - val =REG_SET_FIELD (val,TCP_UTCL0_THRASHING_CTRL , -RETRY_FRAGMENT_THRESHOLD_UP_EN ,0x0 ); - -WREG32_SOC15 (GC ,0 , regTCP_UTCL0_THRASHING_CTRL, val); -/* Set the TCP UTCL0 register to enable atomics */ val =RREG32_SOC15 (GC ,0 , regTCP_UTCL0_CNTL1); val =REG_SET_FIELD (val,TCP_UTCL0_CNTL1 ,ATOMIC_REQUESTER_EN ,0x1 );
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: add xcc info for compute ring name
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Add XCC id info for compute ring name on gfx version 12.1.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -1
@@ -747,7 +747,8 @@ static int gfx_v12_1_compute_ring_init(struct amdgpu_device *adev, int ring_id, (ring_id + xcc_id * adev->gfx.num_compute_rings) *GFX12_MEC_HPD_SIZE ; ring->vm_hub =AMDGPU_GFXHUB (xcc_id); -sprintf (ring->name,"comp_%d.%d.%d" , ring->me, ring->pipe, ring->queue); +sprintf (ring->name,"comp_%d.%d.%d.%d" , + ring->xcc_id, ring->me, ring->pipe, ring->queue); irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ((ring->me -1 ) * adev->gfx.mec.num_pipe_per_mec)
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Init single mes instance if xcc_mask is unset
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
Configure a single mes instance if the xcc_mask remains uninitialized.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -2
@@ -92,9 +92,9 @@ static void amdgpu_mes_doorbell_free(struct amdgpu_device *adev)int amdgpu_mes_init (struct amdgpu_device *adev) {int i, r, num_pipes; -int num_xcc =NUM_XCC (adev->gfx.xcc_mask);u32 total_vmid_mask, reserved_vmid_mask;u32 queue_mask, reserved_queue_mask; +int num_xcc = adev->gfx.xcc_mask ?NUM_XCC (adev->gfx.xcc_mask) :1 ; adev->mes.adev = adev;
@@ -245,7 +245,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev)void amdgpu_mes_fini (struct amdgpu_device *adev) { -int i, num_xcc =NUM_XCC (adev->gfx.xcc_mask); +int i; +int num_xcc = adev->gfx.xcc_mask ?NUM_XCC (adev->gfx.xcc_mask) :1 ; amdgpu_bo_free_kernel(&adev->mes.event_log_gpu_obj, &adev->mes.event_log_gpu_addr,
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: set gfxhub according xcc_mask for gfx 12_1
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Set GFXHUB accodring to xcc_mask for gfx version 12_1.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +11 -1
@@ -805,7 +805,6 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) {case IP_VERSION (12 ,0 ,0 ):case IP_VERSION (12 ,0 ,1 ): -case IP_VERSION (12 ,1 ,0 ):set_bit (AMDGPU_GFXHUB (0 ), adev->vmhubs_mask);set_bit (AMDGPU_MMHUB0 (0 ), adev->vmhubs_mask);/*
@@ -815,6 +814,17 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)*/ amdgpu_vm_adjust_size (adev,256 *1024 ,9 ,3 ,48 );break ; +case IP_VERSION (12 ,1 ,0 ): +bitmap_set (adev->vmhubs_mask,AMDGPU_GFXHUB (0 ), +NUM_XCC (adev->gfx.xcc_mask)); +set_bit (AMDGPU_MMHUB0 (0 ), adev->vmhubs_mask); +/* +* To fulfill 4-level page support, +* vm size is 256TB (48bit), maximum size, +* block size 512 (9bit) +*/ +amdgpu_vm_adjust_size (adev,256 *1024 ,9 ,3 ,48 ); +break ;default :break ; }
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/gmc12: set MMHUBs based on aid_mask
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Update number of mmhub and mid_mask via reuse aid_mask.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -1
@@ -788,6 +788,7 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block) {int r, vram_width =0 , vram_type =0 , vram_vendor =0 ;struct amdgpu_device *adev = ip_block->adev; +int i; adev->mmhub.funcs->init (adev);
@@ -817,7 +818,8 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)case IP_VERSION (12 ,1 ,0 ):bitmap_set (adev->vmhubs_mask,AMDGPU_GFXHUB (0 ),NUM_XCC (adev->gfx.xcc_mask)); -set_bit (AMDGPU_MMHUB0 (0 ), adev->vmhubs_mask); +for (i =0 ; i <hweight32 (adev->aid_mask); i++) +set_bit (AMDGPU_MMHUB0 (i), adev->vmhubs_mask);/* * To fulfill 4-level page support, * vm size is 256TB (48bit), maximum size,
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: add imu support for gc 12_1
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Add IMU support for gc version 12.1.0.
Only support imu fw loading for imu 12.1.0.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 49 +++------ drivers/gpu/drm/amd/amdgpu/imu_v12_1.c | 139 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/imu_v12_1.h | 30 ++++++ 4 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/imu_v12_1.c create mode 100644 drivers/gpu/drm/amd/amdgpu/imu_v12_1.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
@@ -159,7 +159,8 @@ amdgpu-y += \ imu_v11_0_3.o \ gfx_v12_0.o \ gfx_v12_1.o \ - imu_v12_0.o + imu_v12_0.o \ + imu_v12_1.o # add async DMA block amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +15 -34
90 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/imu_v12_1.c new file +139 -0
139 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/imu_v12_1.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright 2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __IMU_V12_1_H__ +#define __IMU_V12_1_H__ + +extern const struct amdgpu_imu_funcs gfx_v12_1_imu_funcs; + +#endif +
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: fix mes code error for muti-xcc
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Fix some code error for muti-xcc on mes v12_1.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +3 -2
@@ -37,6 +37,7 @@ MODULE_FIRMWARE("amdgpu/gc_12_1_0_mes1.bin");MODULE_FIRMWARE ("amdgpu/gc_12_1_0_uni_mes.bin" );static int mes_v12_1_hw_init (struct amdgpu_ip_block *ip_block); +static int mes_v12_1_xcc_hw_init (struct amdgpu_ip_block *ip_block,int xcc_id);static int mes_v12_1_hw_fini (struct amdgpu_ip_block *ip_block);static int mes_v12_1_kiq_hw_init (struct amdgpu_device *adev,uint32_t xcc_id);static int mes_v12_1_kiq_hw_fini (struct amdgpu_device *adev,uint32_t xcc_id);
@@ -684,7 +685,7 @@ static int mes_v12_1_set_hw_resources(struct amdgpu_mes *mes,for (i =0 ; i <5 ; i++) { mes_set_hw_res_pkt.gc_base[i] = - adev->reg_offset[GC_HWIP ][GET_INST (GC , xcc_id)][i]; + adev->reg_offset[GC_HWIP ][0 ][i]; mes_set_hw_res_pkt.mmhub_base[i] = adev->reg_offset[MMHUB_HWIP ][0 ][i]; mes_set_hw_res_pkt.osssys_base[i] =
@@ -1684,7 +1685,7 @@ static int mes_v12_1_kiq_hw_init(struct amdgpu_device *adev, uint32_t xcc_id) }if (adev->mes.enable_legacy_queue_map) { - r =mes_v12_1_hw_init (ip_block); + r =mes_v12_1_xcc_hw_init (ip_block, xcc_id);if (r) goto failure; }
Signature · 1 line
2.51.1