Skip to content

Commit 377d022

Browse files
Tao Zhoualexdeucher
authored andcommitted
drm/amdgpu: add RAS query support for VCN 4.0
Initialize VCN RAS structure and add RAS status query function. Signed-off-by: Tao Zhou <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 214c764 commit 377d022

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "soc15_hw_ip.h"
3232
#include "vcn_v2_0.h"
3333
#include "mmsch_v4_0.h"
34+
#include "vcn_v4_0.h"
3435

3536
#include "vcn/vcn_4_0_0_offset.h"
3637
#include "vcn/vcn_4_0_0_sh_mask.h"
@@ -64,6 +65,7 @@ static int vcn_v4_0_set_powergating_state(void *handle,
6465
static int vcn_v4_0_pause_dpg_mode(struct amdgpu_device *adev,
6566
int inst_idx, struct dpg_pause_state *new_state);
6667
static void vcn_v4_0_unified_ring_set_wptr(struct amdgpu_ring *ring);
68+
static void vcn_v4_0_set_ras_funcs(struct amdgpu_device *adev);
6769

6870
/**
6971
* vcn_v4_0_early_init - set function pointers
@@ -84,6 +86,7 @@ static int vcn_v4_0_early_init(void *handle)
8486

8587
vcn_v4_0_set_unified_ring_funcs(adev);
8688
vcn_v4_0_set_irq_funcs(adev);
89+
vcn_v4_0_set_ras_funcs(adev);
8790

8891
return 0;
8992
}
@@ -2001,3 +2004,60 @@ const struct amdgpu_ip_block_version vcn_v4_0_ip_block =
20012004
.rev = 0,
20022005
.funcs = &vcn_v4_0_ip_funcs,
20032006
};
2007+
2008+
static uint32_t vcn_v4_0_query_poison_by_instance(struct amdgpu_device *adev,
2009+
uint32_t instance, uint32_t sub_block)
2010+
{
2011+
uint32_t poison_stat = 0, reg_value = 0;
2012+
2013+
switch (sub_block) {
2014+
case AMDGPU_VCN_V4_0_VCPU_VCODEC:
2015+
reg_value = RREG32_SOC15(VCN, instance, regUVD_RAS_VCPU_VCODEC_STATUS);
2016+
poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_VCPU_VCODEC_STATUS, POISONED_PF);
2017+
break;
2018+
default:
2019+
break;
2020+
}
2021+
2022+
if (poison_stat)
2023+
dev_info(adev->dev, "Poison detected in VCN%d, sub_block%d\n",
2024+
instance, sub_block);
2025+
2026+
return poison_stat;
2027+
}
2028+
2029+
static bool vcn_v4_0_query_ras_poison_status(struct amdgpu_device *adev)
2030+
{
2031+
uint32_t inst, sub;
2032+
uint32_t poison_stat = 0;
2033+
2034+
for (inst = 0; inst < adev->vcn.num_vcn_inst; inst++)
2035+
for (sub = 0; sub < AMDGPU_VCN_V4_0_MAX_SUB_BLOCK; sub++)
2036+
poison_stat +=
2037+
vcn_v4_0_query_poison_by_instance(adev, inst, sub);
2038+
2039+
return !!poison_stat;
2040+
}
2041+
2042+
const struct amdgpu_ras_block_hw_ops vcn_v4_0_ras_hw_ops = {
2043+
.query_poison_status = vcn_v4_0_query_ras_poison_status,
2044+
};
2045+
2046+
static struct amdgpu_vcn_ras vcn_v4_0_ras = {
2047+
.ras_block = {
2048+
.hw_ops = &vcn_v4_0_ras_hw_ops,
2049+
},
2050+
};
2051+
2052+
static void vcn_v4_0_set_ras_funcs(struct amdgpu_device *adev)
2053+
{
2054+
switch (adev->ip_versions[VCN_HWIP][0]) {
2055+
case IP_VERSION(4, 0, 0):
2056+
adev->vcn.ras = &vcn_v4_0_ras;
2057+
break;
2058+
default:
2059+
break;
2060+
}
2061+
2062+
amdgpu_vcn_set_ras_funcs(adev);
2063+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#ifndef __VCN_V4_0_H__
2525
#define __VCN_V4_0_H__
2626

27+
enum amdgpu_vcn_v4_0_sub_block {
28+
AMDGPU_VCN_V4_0_VCPU_VCODEC = 0,
29+
30+
AMDGPU_VCN_V4_0_MAX_SUB_BLOCK,
31+
};
32+
2733
extern const struct amdgpu_ip_block_version vcn_v4_0_ip_block;
2834

2935
#endif /* __VCN_V4_0_H__ */

0 commit comments

Comments
 (0)