Skip to content

Commit 907fec2

Browse files
vskvortsalexdeucher
authored andcommitted
drm/amdgpu: VF Query RAS Caps from Host if supported
If VF RAS Capability support is enabled, guest is able to retrieve the real RAS support from the host. Signed-off-by: Victor Skvortsov <[email protected]> Reviewed-by: Zhigang Luo <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 9928509 commit 907fec2

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,11 @@ static void amdgpu_ras_check_supported(struct amdgpu_device *adev)
34533453
if (!amdgpu_ras_asic_supported(adev))
34543454
return;
34553455

3456+
if (amdgpu_sriov_vf(adev)) {
3457+
if (amdgpu_virt_get_ras_capability(adev))
3458+
goto init_ras_enabled_flag;
3459+
}
3460+
34563461
/* query ras capability from psp */
34573462
if (amdgpu_psp_get_ras_capability(&adev->psp))
34583463
goto init_ras_enabled_flag;

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
523523

524524
adev->unique_id =
525525
((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
526+
adev->virt.ras_en_caps.all = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->ras_en_caps.all;
526527
break;
527528
default:
528529
dev_err(adev->dev, "invalid pf2vf version: 0x%x\n", pf2vf_info->version);
@@ -1144,3 +1145,55 @@ bool amdgpu_sriov_xnack_support(struct amdgpu_device *adev)
11441145

11451146
return xnack_mode;
11461147
}
1148+
1149+
bool amdgpu_virt_get_ras_capability(struct amdgpu_device *adev)
1150+
{
1151+
struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
1152+
1153+
if (!amdgpu_sriov_ras_caps_en(adev))
1154+
return false;
1155+
1156+
if (adev->virt.ras_en_caps.bits.block_umc)
1157+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__UMC);
1158+
if (adev->virt.ras_en_caps.bits.block_sdma)
1159+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__SDMA);
1160+
if (adev->virt.ras_en_caps.bits.block_gfx)
1161+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__GFX);
1162+
if (adev->virt.ras_en_caps.bits.block_mmhub)
1163+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__MMHUB);
1164+
if (adev->virt.ras_en_caps.bits.block_athub)
1165+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__ATHUB);
1166+
if (adev->virt.ras_en_caps.bits.block_pcie_bif)
1167+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__PCIE_BIF);
1168+
if (adev->virt.ras_en_caps.bits.block_hdp)
1169+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__HDP);
1170+
if (adev->virt.ras_en_caps.bits.block_xgmi_wafl)
1171+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__XGMI_WAFL);
1172+
if (adev->virt.ras_en_caps.bits.block_df)
1173+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__DF);
1174+
if (adev->virt.ras_en_caps.bits.block_smn)
1175+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__SMN);
1176+
if (adev->virt.ras_en_caps.bits.block_sem)
1177+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__SEM);
1178+
if (adev->virt.ras_en_caps.bits.block_mp0)
1179+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__MP0);
1180+
if (adev->virt.ras_en_caps.bits.block_mp1)
1181+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__MP1);
1182+
if (adev->virt.ras_en_caps.bits.block_fuse)
1183+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__FUSE);
1184+
if (adev->virt.ras_en_caps.bits.block_mca)
1185+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__MCA);
1186+
if (adev->virt.ras_en_caps.bits.block_vcn)
1187+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__VCN);
1188+
if (adev->virt.ras_en_caps.bits.block_jpeg)
1189+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__JPEG);
1190+
if (adev->virt.ras_en_caps.bits.block_ih)
1191+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__IH);
1192+
if (adev->virt.ras_en_caps.bits.block_mpio)
1193+
adev->ras_hw_enabled |= BIT(AMDGPU_RAS_BLOCK__MPIO);
1194+
1195+
if (adev->virt.ras_en_caps.bits.poison_propogation_mode)
1196+
con->poison_supported = true; /* Poison is handled by host */
1197+
1198+
return true;
1199+
}

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ enum AMDGIM_FEATURE_FLAG {
137137
AMDGIM_FEATURE_VCN_RB_DECOUPLE = (1 << 7),
138138
/* MES info */
139139
AMDGIM_FEATURE_MES_INFO_ENABLE = (1 << 8),
140+
AMDGIM_FEATURE_RAS_CAPS = (1 << 9),
140141
};
141142

142143
enum AMDGIM_REG_ACCESS_FLAG {
@@ -277,6 +278,8 @@ struct amdgpu_virt {
277278
uint32_t autoload_ucode_id;
278279

279280
struct mutex rlcg_reg_lock;
281+
282+
union amd_sriov_ras_caps ras_en_caps;
280283
};
281284

282285
struct amdgpu_video_codec_info;
@@ -321,6 +324,9 @@ struct amdgpu_video_codec_info;
321324
#define amdgpu_sriov_vf_mmio_access_protection(adev) \
322325
((adev)->virt.caps & AMDGPU_VF_MMIO_ACCESS_PROTECT)
323326

327+
#define amdgpu_sriov_ras_caps_en(adev) \
328+
((adev)->virt.gim_feature & AMDGIM_FEATURE_RAS_CAPS)
329+
324330
static inline bool is_virtual_machine(void)
325331
{
326332
#if defined(CONFIG_X86)
@@ -384,4 +390,5 @@ bool amdgpu_virt_get_rlcg_reg_access_flag(struct amdgpu_device *adev,
384390
u32 acc_flags, u32 hwip,
385391
bool write, u32 *rlcg_flag);
386392
u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v, u32 flag, u32 xcc_id);
393+
bool amdgpu_virt_get_ras_capability(struct amdgpu_device *adev);
387394
#endif

0 commit comments

Comments
 (0)