Skip to content

Commit 5331745

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

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "soc15.h"
2828
#include "soc15d.h"
2929
#include "jpeg_v2_0.h"
30+
#include "jpeg_v4_0.h"
3031

3132
#include "vcn/vcn_4_0_0_offset.h"
3233
#include "vcn/vcn_4_0_0_sh_mask.h"
@@ -38,6 +39,7 @@ static void jpeg_v4_0_set_dec_ring_funcs(struct amdgpu_device *adev);
3839
static void jpeg_v4_0_set_irq_funcs(struct amdgpu_device *adev);
3940
static int jpeg_v4_0_set_powergating_state(void *handle,
4041
enum amd_powergating_state state);
42+
static void jpeg_v4_0_set_ras_funcs(struct amdgpu_device *adev);
4143

4244
/**
4345
* jpeg_v4_0_early_init - set function pointers
@@ -55,6 +57,7 @@ static int jpeg_v4_0_early_init(void *handle)
5557

5658
jpeg_v4_0_set_dec_ring_funcs(adev);
5759
jpeg_v4_0_set_irq_funcs(adev);
60+
jpeg_v4_0_set_ras_funcs(adev);
5861

5962
return 0;
6063
}
@@ -607,3 +610,63 @@ const struct amdgpu_ip_block_version jpeg_v4_0_ip_block = {
607610
.rev = 0,
608611
.funcs = &jpeg_v4_0_ip_funcs,
609612
};
613+
614+
static uint32_t jpeg_v4_0_query_poison_by_instance(struct amdgpu_device *adev,
615+
uint32_t instance, uint32_t sub_block)
616+
{
617+
uint32_t poison_stat = 0, reg_value = 0;
618+
619+
switch (sub_block) {
620+
case AMDGPU_JPEG_V4_0_JPEG0:
621+
reg_value = RREG32_SOC15(JPEG, instance, regUVD_RAS_JPEG0_STATUS);
622+
poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_JPEG0_STATUS, POISONED_PF);
623+
break;
624+
case AMDGPU_JPEG_V4_0_JPEG1:
625+
reg_value = RREG32_SOC15(JPEG, instance, regUVD_RAS_JPEG1_STATUS);
626+
poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_JPEG1_STATUS, POISONED_PF);
627+
break;
628+
default:
629+
break;
630+
}
631+
632+
if (poison_stat)
633+
dev_info(adev->dev, "Poison detected in JPEG%d sub_block%d\n",
634+
instance, sub_block);
635+
636+
return poison_stat;
637+
}
638+
639+
static bool jpeg_v4_0_query_ras_poison_status(struct amdgpu_device *adev)
640+
{
641+
uint32_t inst = 0, sub = 0, poison_stat = 0;
642+
643+
for (inst = 0; inst < adev->jpeg.num_jpeg_inst; inst++)
644+
for (sub = 0; sub < AMDGPU_JPEG_V4_0_MAX_SUB_BLOCK; sub++)
645+
poison_stat +=
646+
jpeg_v4_0_query_poison_by_instance(adev, inst, sub);
647+
648+
return !!poison_stat;
649+
}
650+
651+
const struct amdgpu_ras_block_hw_ops jpeg_v4_0_ras_hw_ops = {
652+
.query_poison_status = jpeg_v4_0_query_ras_poison_status,
653+
};
654+
655+
static struct amdgpu_jpeg_ras jpeg_v4_0_ras = {
656+
.ras_block = {
657+
.hw_ops = &jpeg_v4_0_ras_hw_ops,
658+
},
659+
};
660+
661+
static void jpeg_v4_0_set_ras_funcs(struct amdgpu_device *adev)
662+
{
663+
switch (adev->ip_versions[JPEG_HWIP][0]) {
664+
case IP_VERSION(4, 0, 0):
665+
adev->jpeg.ras = &jpeg_v4_0_ras;
666+
break;
667+
default:
668+
break;
669+
}
670+
671+
jpeg_set_ras_funcs(adev);
672+
}

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

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

27+
enum amdgpu_jpeg_v4_0_sub_block {
28+
AMDGPU_JPEG_V4_0_JPEG0 = 0,
29+
AMDGPU_JPEG_V4_0_JPEG1,
30+
31+
AMDGPU_JPEG_V4_0_MAX_SUB_BLOCK,
32+
};
33+
2734
extern const struct amdgpu_ip_block_version jpeg_v4_0_ip_block;
2835

2936
#endif /* __JPEG_V4_0_H__ */

0 commit comments

Comments
 (0)