drm/amdgpu: Remove redundant pmfw backdoor loading
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Remove redundant pmfw backdoor loading
From: Hawking Zhang <[email protected]>
PMFW is integrated into ifwi for gfx 12_1 adapter, making PMFW backdoor loading unnecessary.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -15
@@ -2559,21 +2559,6 @@ static int gfx_v12_1_hw_init(struct amdgpu_ip_block *ip_block)if (r)return r; -if ((adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT || - adev->firmware.load_type ==AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO ) && - (amdgpu_dpm ==1 )) { -/** -* For gfx 12, rlc firmware loading relies on smu firmware is -* loaded firstly, so in direct type, it has to load smc ucode -* here before rlc. -*/ -if (!(adev->flags &AMD_IS_APU )) { - r =amdgpu_pm_load_smu_firmware (adev,NULL ); -if (r) -return r; - } - } -gfx_v12_1_init_golden_registers (adev);gfx_v12_1_constants_init (adev);
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdkfd: disable shader message vgpr deallocation on gc 12.1
From: Jonathan Kim <[email protected]>
Shader messages to deallocate VGPRs prior to shader end can prevent the trap handler from saving context, making debugging and core dumps unreliable.
VGPR deallocations for performance gain is negligible. GC 12.1 will NOP shader VGPR deallocation messages via HW settings on driver boot.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +5 -0
@@ -1362,6 +1362,11 @@ static void gfx_v12_1_xcc_init_compute_vmid(struct amdgpu_device *adev, data =RREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regSPI_GDBG_PER_VMID_CNTL); data =REG_SET_FIELD (data,SPI_GDBG_PER_VMID_CNTL ,TRAP_EN ,1 );WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regSPI_GDBG_PER_VMID_CNTL, data); + +/* Disable VGPR deallocation instruction for each KFD vmid. */ + data =RREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regSQ_DEBUG); + data =REG_SET_FIELD (data,SQ_DEBUG ,DISABLE_VGPR_DEALLOC ,1 ); +WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regSQ_DEBUG, data); }soc_v1_0_grbm_select (adev,0 ,0 ,0 ,0 ,GET_INST (GC , xcc_id));mutex_unlock (&adev->srbm_mutex);
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: enable unmap doorbell handle for gfx v12_1
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Enable unmapped doorbell handling for gfx v12_1.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +1 -1
@@ -1228,7 +1228,7 @@ static int mes_v12_1_mqd_init(struct amdgpu_ring *ring)* doorbell handling. This is a reserved CP internal register can * not be accesss by others */ -//mqd->cp_hqd_gfx_control = BIT(15); + mqd->cp_hqd_gfx_control =BIT (15 );return 0 ; }
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: revision doorbel range for gfx v12_1
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Revision doorbell range on muti-XCC mode for gfx v12_1. Clean up doorbell range set for graphics engine.
V2: Remove doorbell range set from gfx_v12_1_xcc_kiq_init_register.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -16
@@ -1998,17 +1998,15 @@ static void gfx_v12_1_xcc_kiq_setting(struct amdgpu_ring *ring,static void gfx_v12_1_xcc_cp_set_doorbell_range (struct amdgpu_device *adev,int xcc_id) { -/* set graphics engine doorbell range */ -WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_RB_DOORBELL_RANGE_LOWER, - (adev->doorbell_index.gfx_ring0 *2 ) <<2 ); -WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_RB_DOORBELL_RANGE_UPPER, - (adev->doorbell_index.gfx_userqueue_end *2 ) <<2 ); -/* set compute engine doorbell range */ WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_MEC_DOORBELL_RANGE_LOWER, - (adev->doorbell_index.kiq *2 ) <<2 ); + ((adev->doorbell_index.kiq + + xcc_id * adev->doorbell_index.xcc_doorbell_range) * +2 ) <<2 );WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_MEC_DOORBELL_RANGE_UPPER, - (adev->doorbell_index.userqueue_end *2 ) <<2 ); + ((adev->doorbell_index.userqueue_end + + xcc_id * adev->doorbell_index.xcc_doorbell_range) * +2 ) <<2 ); } static int gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,
@@ -2218,14 +2216,6 @@ static int gfx_v12_1_xcc_kiq_init_register(struct amdgpu_ring *ring,WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_HQD_PQ_WPTR_POLL_ADDR_HI, mqd->cp_hqd_pq_wptr_poll_addr_hi); -/* enable the doorbell if requested */ -if (ring->use_doorbell) { -WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_MEC_DOORBELL_RANGE_LOWER, - (adev->doorbell_index.kiq *2 ) <<2 ); -WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_MEC_DOORBELL_RANGE_UPPER, - (adev->doorbell_index.userqueue_end *2 ) <<2 ); - } -WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control);
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: disable graphics doorbell range for gfx v12_1
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Disable doorbell range for graphics engine on gfx v12_1.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +4 -0
@@ -1998,6 +1998,10 @@ static void gfx_v12_1_xcc_kiq_setting(struct amdgpu_ring *ring,static void gfx_v12_1_xcc_cp_set_doorbell_range (struct amdgpu_device *adev,int xcc_id) { +/* disable gfx engine doorbell range */ +WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_RB_DOORBELL_RANGE_LOWER,0 ); +WREG32_SOC15 (GC ,GET_INST (GC , xcc_id), regCP_RB_DOORBELL_RANGE_UPPER,0 ); +/* set compute engine doorbell range */ WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_MEC_DOORBELL_RANGE_LOWER, ((adev->doorbell_index.kiq +
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Add switch_compute_partition callback for imu v12_1
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
To enable switching compute partition mode
v2: cleanup (Alex)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/imu_v12_1.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h +2 -0
@@ -37,6 +37,8 @@ struct amdgpu_imu_funcs {void (*program_rlc_ram)(struct amdgpu_device *adev);int (*wait_for_reset_status)(struct amdgpu_device *adev);int (*get_xccs_per_xcp)(struct amdgpu_device *adev); +int (*switch_compute_partition)(struct amdgpu_device *adev, +int num_xccs_per_xcp); };struct imu_rlc_ram_golden {
drivers/gpu/drm/amd/amdgpu/imu_v12_1.c +19 -0
@@ -143,8 +143,27 @@ static int imu_v12_1_get_xccs_per_xcp(struct amdgpu_device *adev)return REG_GET_FIELD (reg_data,GFX_IMU_PARTITION_SWITCH ,TOTAL_XCCS_IN_XCP ); } +static int imu_v12_1_switch_compute_partition (struct amdgpu_device *adev, +int num_xccs_per_xcp) +{ +int ret; + +if (adev->psp.funcs) { + ret =psp_spatial_partition (&adev->psp, +NUM_XCC (adev->gfx.xcc_mask) / + num_xccs_per_xcp); +if (ret) +return ret; + } + + adev->gfx.num_xcc_per_xcp = num_xccs_per_xcp; + +return 0 ; +} +const struct amdgpu_imu_funcs gfx_v12_1_imu_funcs = { .init_microcode = imu_v12_1_init_microcode, .load_microcode = imu_v12_1_load_microcode, .get_xccs_per_xcp = imu_v12_1_get_xccs_per_xcp, + .switch_compute_partition = imu_v12_1_switch_compute_partition, };
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Export gfx_v12_1_xcp_func
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
To be used by soc v1_0 xcp manager
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.h +2 -0
@@ -26,4 +26,6 @@extern const struct amdgpu_ip_block_version gfx_v12_1_ip_block; +extern struct amdgpu_xcp_ip_funcs gfx_v12_1_xcp_funcs; +#endif
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Remove redundant check for async_gfx_ring
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
Remove the redundant check for async_gfx_ring, as it is not required for gfx v12_1
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -3
@@ -2390,9 +2390,7 @@ static int gfx_v12_1_xcc_cp_resume(struct amdgpu_device *adev,gfx_v12_1_xcc_cp_set_doorbell_range (adev, xcc_id); -if (amdgpu_async_gfx_ring) { -gfx_v12_1_xcc_cp_compute_enable (adev, true, xcc_id); - } +gfx_v12_1_xcc_cp_compute_enable (adev, true, xcc_id);if (adev->enable_mes_kiq && adev->mes.kiq_hw_init) r =amdgpu_mes_kiq_hw_init (adev, xcc_id);
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Add get_xccs_per_xcp callback for imu v12_1
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
To enable querying the total number of xccs in the xcp
--- drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h | 1 + drivers/gpu/drm/amd/amdgpu/imu_v12_1.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h +1 -0
@@ -36,6 +36,7 @@ struct amdgpu_imu_funcs {int (*start_imu)(struct amdgpu_device *adev);void (*program_rlc_ram)(struct amdgpu_device *adev);int (*wait_for_reset_status)(struct amdgpu_device *adev); +int (*get_xccs_per_xcp)(struct amdgpu_device *adev); };struct imu_rlc_ram_golden {
drivers/gpu/drm/amd/amdgpu/imu_v12_1.c +11 -0
@@ -133,7 +133,18 @@ static int imu_v12_1_load_microcode(struct amdgpu_device *adev)return 0 ; } +static int imu_v12_1_get_xccs_per_xcp (struct amdgpu_device *adev) +{ +u32 reg_data; + +/* the register data is expected to be the same on all instances */ + reg_data =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regGFX_IMU_PARTITION_SWITCH); + +return REG_GET_FIELD (reg_data,GFX_IMU_PARTITION_SWITCH ,TOTAL_XCCS_IN_XCP ); +} +const struct amdgpu_imu_funcs gfx_v12_1_imu_funcs = { .init_microcode = imu_v12_1_init_microcode, .load_microcode = imu_v12_1_load_microcode, + .get_xccs_per_xcp = imu_v12_1_get_xccs_per_xcp, };
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: update sdma configuration for soc v1_0
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Update SDMA instances/masks according to xcc num for multi-xcc models on soc v1.0.
--- drivers/gpu/drm/amd/amdgpu/soc_v1_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc_v1_0.c +4 -0
@@ -771,6 +771,10 @@ int soc_v1_0_init_soc_config(struct amdgpu_device *adev)/*TODO: init soc config */ adev->sdma.num_inst_per_xcc =2 ; + adev->sdma.num_instances = +NUM_XCC (adev->gfx.xcc_mask) * adev->sdma.num_inst_per_xcc; + adev->sdma.sdma_mask = +GENMASK (adev->sdma.num_instances -1 ,0 ); ret =soc_v1_0_xcp_mgr_init (adev);if (ret)
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Export sdma_v7_1_xcp_funcs
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
To be used by soc v1_0 xcp manager
--- drivers/gpu/drm/amd/amdgpu/sdma_v7_1.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/sdma_v7_1.h +1 -0
@@ -26,5 +26,6 @@extern const struct amd_ip_funcs sdma_v7_1_ip_funcs;extern const struct amdgpu_ip_block_version sdma_v7_1_ip_block; +extern struct amdgpu_xcp_ip_funcs sdma_v7_1_xcp_funcs;#endif /* __SDMA_V7_1_H__ */
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Add soc_v1_0_xcp_funcs
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
Implement xcp mgr callbacks for soc v1_0
--- drivers/gpu/drm/amd/amdgpu/soc_v1_0.c | 411 ++++++++++++++++++++++++++ 1 file changed, 411 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc_v1_0.c +411 -0
@@ -25,6 +25,10 @@#include "soc15_common.h" #include "soc_v1_0.h" #include "amdgpu_ip.h" +#include "amdgpu_imu.h" +#include "gfxhub_v12_1.h" +#include "sdma_v7_1.h" +#include "gfx_v12_1.h" #include "gc/gc_12_1_0_offset.h" #include "gc/gc_12_1_0_sh_mask.h"
@@ -336,6 +340,413 @@ const struct amdgpu_ip_block_version soc_v1_0_common_ip_block = { .funcs = &soc_v1_0_common_ip_funcs, }; +static enum amdgpu_gfx_partition __soc_v1_0_calc_xcp_mode (struct amdgpu_xcp_mgr *xcp_mgr) +{ +struct amdgpu_device *adev = xcp_mgr->adev; +int num_xcc, num_xcc_per_xcp =0 , mode =0 ; + + num_xcc =NUM_XCC (xcp_mgr->adev->gfx.xcc_mask); +if (adev->gfx.imu.funcs && + adev->gfx.imu.funcs->get_xccs_per_xcp) + num_xcc_per_xcp = adev->gfx.imu.funcs->get_xccs_per_xcp (adev); +if ((num_xcc_per_xcp) && (num_xcc % num_xcc_per_xcp ==0 )) + mode = num_xcc / num_xcc_per_xcp; + +if (num_xcc_per_xcp ==1 ) +return AMDGPU_CPX_PARTITION_MODE ; + +switch (mode) { +case 1 : +return AMDGPU_SPX_PARTITION_MODE ; +case 2 : +return AMDGPU_DPX_PARTITION_MODE ; +case 3 : +return AMDGPU_TPX_PARTITION_MODE ; +case 4 : +return AMDGPU_QPX_PARTITION_MODE ; +default : +return AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ; + } + +return AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ; +} + +static int soc_v1_0_query_partition_mode (struct amdgpu_xcp_mgr *xcp_mgr) +{ +enum amdgpu_gfx_partition derv_mode, mode; +struct amdgpu_device *adev = xcp_mgr->adev; + + mode =AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ; + derv_mode =__soc_v1_0_calc_xcp_mode (xcp_mgr); + +if (amdgpu_sriov_vf (adev)) +return derv_mode; + +if (adev->nbio.funcs && + adev->nbio.funcs->get_compute_partition_mode) { + mode = adev->nbio.funcs->get_compute_partition_mode (adev); +if (mode != derv_mode) +dev_warn (adev->dev, +"Mismatch in compute partition mode - reported : %d derived : %d" , + mode, derv_mode); + } + +return mode; +} + +static int __soc_v1_0_get_xcc_per_xcp (struct amdgpu_xcp_mgr *xcp_mgr,int mode) +{ +int num_xcc, num_xcc_per_xcp =0 ; + + num_xcc =NUM_XCC (xcp_mgr->adev->gfx.xcc_mask); + +switch (mode) { +case AMDGPU_SPX_PARTITION_MODE : + num_xcc_per_xcp = num_xcc; +break ; +case AMDGPU_DPX_PARTITION_MODE : + num_xcc_per_xcp = num_xcc /2 ; +break ; +case AMDGPU_TPX_PARTITION_MODE : + num_xcc_per_xcp = num_xcc /3 ; +break ; +case AMDGPU_QPX_PARTITION_MODE : + num_xcc_per_xcp = num_xcc /4 ; +break ; +case AMDGPU_CPX_PARTITION_MODE : + num_xcc_per_xcp =1 ; +break ; + } + +return num_xcc_per_xcp; +} + +static int __soc_v1_0_get_xcp_ip_info (struct amdgpu_xcp_mgr *xcp_mgr,int xcp_id, +enum AMDGPU_XCP_IP_BLOCK ip_id, +struct amdgpu_xcp_ip *ip) +{ +struct amdgpu_device *adev = xcp_mgr->adev; +int num_sdma, num_vcn, num_shared_vcn, num_xcp; +int num_xcc_xcp, num_sdma_xcp, num_vcn_xcp; + + num_sdma = adev->sdma.num_instances; + num_vcn = adev->vcn.num_vcn_inst; + num_shared_vcn =1 ; + + num_xcc_xcp = adev->gfx.num_xcc_per_xcp; + num_xcp =NUM_XCC (adev->gfx.xcc_mask) / num_xcc_xcp; + +switch (xcp_mgr->mode) { +case AMDGPU_SPX_PARTITION_MODE : +case AMDGPU_DPX_PARTITION_MODE : +case AMDGPU_TPX_PARTITION_MODE : +case AMDGPU_QPX_PARTITION_MODE : +case AMDGPU_CPX_PARTITION_MODE : + num_sdma_xcp =DIV_ROUND_UP (num_sdma, num_xcp); + num_vcn_xcp =DIV_ROUND_UP (num_vcn, num_xcp); +break ; +default : +return -EINVAL ; + } + +if (num_vcn && num_xcp > num_vcn) + num_shared_vcn = num_xcp / num_vcn; + +switch (ip_id) { +case AMDGPU_XCP_GFXHUB : + ip->inst_mask =XCP_INST_MASK (num_xcc_xcp, xcp_id); + ip->ip_funcs = &gfxhub_v12_1_xcp_funcs; +break ; +case AMDGPU_XCP_GFX : + ip->inst_mask =XCP_INST_MASK (num_xcc_xcp, xcp_id); + ip->ip_funcs = &gfx_v12_1_xcp_funcs; +break ; +case AMDGPU_XCP_SDMA : + ip->inst_mask =XCP_INST_MASK (num_sdma_xcp, xcp_id); + ip->ip_funcs = &sdma_v7_1_xcp_funcs; +break ; +case AMDGPU_XCP_VCN : + ip->inst_mask = +XCP_INST_MASK (num_vcn_xcp, xcp_id / num_shared_vcn); +/* TODO : Assign IP funcs */ +break ; +default : +return -EINVAL ; + } + + ip->ip_id = ip_id; + +return 0 ; +} + +static int soc_v1_0_get_xcp_res_info (struct amdgpu_xcp_mgr *xcp_mgr, +int mode, +struct amdgpu_xcp_cfg *xcp_cfg) +{ +struct amdgpu_device *adev = xcp_mgr->adev; +int max_res[AMDGPU_XCP_RES_MAX ] = {}; +bool res_lt_xcp; +int num_xcp, i; +u16 nps_modes; + +if (!(xcp_mgr->supp_xcp_modes &BIT (mode))) +return -EINVAL ; + + max_res[AMDGPU_XCP_RES_XCC ] =NUM_XCC (adev->gfx.xcc_mask); + max_res[AMDGPU_XCP_RES_DMA ] = adev->sdma.num_instances; + max_res[AMDGPU_XCP_RES_DEC ] = adev->vcn.num_vcn_inst; + max_res[AMDGPU_XCP_RES_JPEG ] = adev->jpeg.num_jpeg_inst; + +switch (mode) { +case AMDGPU_SPX_PARTITION_MODE : + num_xcp =1 ; + nps_modes =BIT (AMDGPU_NPS1_PARTITION_MODE ); +break ; +case AMDGPU_DPX_PARTITION_MODE : + num_xcp =2 ; + nps_modes =BIT (AMDGPU_NPS1_PARTITION_MODE ); +break ; +case AMDGPU_TPX_PARTITION_MODE : + num_xcp =3 ; + nps_modes =BIT (AMDGPU_NPS1_PARTITION_MODE ) | +BIT (AMDGPU_NPS4_PARTITION_MODE ); +break ; +case AMDGPU_QPX_PARTITION_MODE : + num_xcp =4 ; + nps_modes =BIT (AMDGPU_NPS1_PARTITION_MODE ) | +BIT (AMDGPU_NPS4_PARTITION_MODE ); +break ; +case AMDGPU_CPX_PARTITION_MODE : + num_xcp =NUM_XCC (adev->gfx.xcc_mask); + nps_modes =BIT (AMDGPU_NPS1_PARTITION_MODE ) | +BIT (AMDGPU_NPS4_PARTITION_MODE ); +break ; +default : +return -EINVAL ; + } + + xcp_cfg->compatible_nps_modes = + (adev->gmc.supported_nps_modes & nps_modes); + xcp_cfg->num_res =ARRAY_SIZE (max_res); + +for (i =0 ; i < xcp_cfg->num_res; i++) { + res_lt_xcp = max_res[i] < num_xcp; + xcp_cfg->xcp_res[i].id = i; + xcp_cfg->xcp_res[i].num_inst = + res_lt_xcp ?1 : max_res[i] / num_xcp; + xcp_cfg->xcp_res[i].num_inst = + i ==AMDGPU_XCP_RES_JPEG ? + xcp_cfg->xcp_res[i].num_inst * + adev->jpeg.num_jpeg_rings : xcp_cfg->xcp_res[i].num_inst; + xcp_cfg->xcp_res[i].num_shared = + res_lt_xcp ? num_xcp / max_res[i] :1 ; + } + +return 0 ; +} + +static enum amdgpu_gfx_partition __soc_v1_0_get_auto_mode (struct amdgpu_xcp_mgr *xcp_mgr) +{ +struct amdgpu_device *adev = xcp_mgr->adev; +int num_xcc; + + num_xcc =NUM_XCC (xcp_mgr->adev->gfx.xcc_mask); + +if (adev->gmc.num_mem_partitions ==1 ) +return AMDGPU_SPX_PARTITION_MODE ; + +if (adev->gmc.num_mem_partitions == num_xcc) +return AMDGPU_CPX_PARTITION_MODE ; + +if (adev->gmc.num_mem_partitions ==2 ) +return AMDGPU_DPX_PARTITION_MODE ; + +return AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ; +} + +static bool __soc_v1_0_is_valid_mode (struct amdgpu_xcp_mgr *xcp_mgr, +enum amdgpu_gfx_partition mode) +{ +struct amdgpu_device *adev = xcp_mgr->adev; +int num_xcc, num_xccs_per_xcp; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +switch (mode) { +case AMDGPU_SPX_PARTITION_MODE : +return adev->gmc.num_mem_partitions ==1 && num_xcc >0 ; +case AMDGPU_DPX_PARTITION_MODE : +return adev->gmc.num_mem_partitions <=2 && (num_xcc %4 ) ==0 ; +case AMDGPU_TPX_PARTITION_MODE : +return (adev->gmc.num_mem_partitions ==1 || + adev->gmc.num_mem_partitions ==3 ) && + ((num_xcc %3 ) ==0 ); +case AMDGPU_QPX_PARTITION_MODE : + num_xccs_per_xcp = num_xcc /4 ; +return (adev->gmc.num_mem_partitions ==1 || + adev->gmc.num_mem_partitions ==4 ) && + (num_xccs_per_xcp >=2 ); +case AMDGPU_CPX_PARTITION_MODE : +/* (num_xcc > 1) because 1 XCC is considered SPX, not CPX. +* (num_xcc % adev->gmc.num_mem_partitions) == 0 because +* num_compute_partitions can't be less than num_mem_partitions +*/ +return ((num_xcc >1 ) && + (num_xcc % adev->gmc.num_mem_partitions) ==0 ); +default : +return false; + } + +return false; +} + +static void __soc_v1_0_update_available_partition_mode (struct amdgpu_xcp_mgr *xcp_mgr) +{ +int mode; + + xcp_mgr->avail_xcp_modes =0 ; + +for_each_inst (mode, xcp_mgr->supp_xcp_modes) { +if (__soc_v1_0_is_valid_mode (xcp_mgr, mode)) + xcp_mgr->avail_xcp_modes |=BIT (mode); + } +} + +static int soc_v1_0_switch_partition_mode (struct amdgpu_xcp_mgr *xcp_mgr, +int mode,int *num_xcps) +{ +int num_xcc_per_xcp, num_xcc, ret; +struct amdgpu_device *adev; +u32 flags =0 ; + + adev = xcp_mgr->adev; + num_xcc =NUM_XCC (adev->gfx.xcc_mask); + +if (mode ==AMDGPU_AUTO_COMPUTE_PARTITION_MODE ) { + mode =__soc_v1_0_get_auto_mode (xcp_mgr); +if (mode ==AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ) { +dev_err (adev->dev, +"Invalid config, no compatible compute partition mode found, available memory partitions: %d" , + adev->gmc.num_mem_partitions); +return -EINVAL ; + } + }else if (!__soc_v1_0_is_valid_mode (xcp_mgr, mode)) { +dev_err (adev->dev, +"Invalid compute partition mode requested, requested: %s, available memory partitions: %d" , +amdgpu_gfx_compute_mode_desc (mode), adev->gmc.num_mem_partitions); +return -EINVAL ; + } + +if (adev->kfd.init_complete && !amdgpu_in_reset (adev)) + flags |=AMDGPU_XCP_OPS_KFD ; + +if (flags &AMDGPU_XCP_OPS_KFD ) { + ret =amdgpu_amdkfd_check_and_lock_kfd (adev); +if (ret) + goto out; + } + + ret =amdgpu_xcp_pre_partition_switch (xcp_mgr, flags); +if (ret) + goto unlock; + + num_xcc_per_xcp =__soc_v1_0_get_xcc_per_xcp (xcp_mgr, mode); +if (adev->gfx.imu.funcs && + adev->gfx.imu.funcs->switch_compute_partition) + adev->gfx.imu.funcs->switch_compute_partition (xcp_mgr->adev, num_xcc_per_xcp); + +/* Init info about new xcps */ + *num_xcps = num_xcc / num_xcc_per_xcp; +amdgpu_xcp_init (xcp_mgr, *num_xcps, mode); + + ret =amdgpu_xcp_post_partition_switch (xcp_mgr, flags); +if (!ret) +__soc_v1_0_update_available_partition_mode (xcp_mgr); +unlock: +if (flags &AMDGPU_XCP_OPS_KFD ) +amdgpu_amdkfd_unlock_kfd (adev); +out: +return ret; +} + +#ifdef HAVE_ACPI_DEV_GET_FIRST_MATCH_DEV +static int __soc_v1_0_get_xcp_mem_id (struct amdgpu_device *adev, +int xcc_id,uint8_t *mem_id) +{ +/* memory/spatial modes validation check is already done */ + *mem_id = xcc_id / adev->gfx.num_xcc_per_xcp; + *mem_id /= adev->xcp_mgr->num_xcp_per_mem_partition; + +return 0 ; +} + +static int soc_v1_0_get_xcp_mem_id (struct amdgpu_xcp_mgr *xcp_mgr, +struct amdgpu_xcp *xcp,uint8_t *mem_id) +{ +struct amdgpu_numa_info numa_info; +struct amdgpu_device *adev; +uint32_t xcc_mask; +int r, i, xcc_id; + + adev = xcp_mgr->adev; +/* TODO: BIOS is not returning the right info now +* Check on this later +*/ +/* +if (adev->gmc.gmc_funcs->query_mem_partition_mode) +mode = adev->gmc.gmc_funcs->query_mem_partition_mode(adev); +*/ +if (adev->gmc.num_mem_partitions ==1 ) { +/* Only one range */ + *mem_id =0 ; +return 0 ; + } + + r =amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +if (r || !xcc_mask) +return -EINVAL ; + + xcc_id =ffs (xcc_mask) -1 ; +if (!adev->gmc.is_app_apu) +return __soc_v1_0_get_xcp_mem_id (adev, xcc_id, mem_id); + + r =amdgpu_acpi_get_mem_info (adev, xcc_id, &numa_info); + +if (r) +return r; + + r = -EINVAL ; +for (i =0 ; i < adev->gmc.num_mem_partitions; ++i) { +if (adev->gmc.mem_partitions[i].numa.node == numa_info.nid) { + *mem_id = i; + r =0 ; +break ; + } + } + +return r; +} +#endif + +static int soc_v1_0_get_xcp_ip_details (struct amdgpu_xcp_mgr *xcp_mgr,int xcp_id, +enum AMDGPU_XCP_IP_BLOCK ip_id, +struct amdgpu_xcp_ip *ip) +{ +if (!ip) +return -EINVAL ; + +return __soc_v1_0_get_xcp_ip_info (xcp_mgr, xcp_id, ip_id, ip); +} + +struct amdgpu_xcp_mgr_funcs soc_v1_0_xcp_funcs = { + .switch_partition_mode = &soc_v1_0_switch_partition_mode, + .query_partition_mode = &soc_v1_0_query_partition_mode, + .get_ip_details = &soc_v1_0_get_xcp_ip_details, + .get_xcp_res_info = &soc_v1_0_get_xcp_res_info, +#ifdef HAVE_ACPI_DEV_GET_FIRST_MATCH_DEV + .get_xcp_mem_id = &soc_v1_0_get_xcp_mem_id, +#endif +}; +int soc_v1_0_init_soc_config (struct amdgpu_device *adev) { adev->sdma.num_inst_per_xcc =2 ;
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Initialize xcp manager for soc v1_0
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
Initialize xcp manager for soc v1_0
--- drivers/gpu/drm/amd/amdgpu/soc_v1_0.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc_v1_0.c +25 -0
@@ -747,10 +747,35 @@ struct amdgpu_xcp_mgr_funcs soc_v1_0_xcp_funcs = {#endif }; +static int soc_v1_0_xcp_mgr_init (struct amdgpu_device *adev) +{ +int ret; + +if (amdgpu_sriov_vf (adev)) + soc_v1_0_xcp_funcs.switch_partition_mode =NULL ; + + ret =amdgpu_xcp_mgr_init (adev,AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE , +1 , &soc_v1_0_xcp_funcs); +if (ret) +return ret; + +amdgpu_xcp_update_supported_modes (adev->xcp_mgr); +/* TODO: Default memory node affinity init */ + +return ret; +} +int soc_v1_0_init_soc_config (struct amdgpu_device *adev) { +int ret; + +/*TODO: init soc config */ adev->sdma.num_inst_per_xcc =2 ; + ret =soc_v1_0_xcp_mgr_init (adev); +if (ret) +return ret; +amdgpu_ip_map_init (adev);return 0 ;
Signature · 1 line
2.51.1