Skip to contentSkip to conversation

drm/amdgpu: support RAS error inject for SRIOV

PATCH In review Tao Zhou 3 participants 4 messages Aug 31, 2022 – Sep 1, 2022

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/2 drm/amdgpu: support RAS error inject for SRIOV

In SRIOV, RAS error injection request will be sent to PF via mailbox, the injection input information should also be transferred to PF.

Generally, the error injection is operated on PF side directly, but for RAS poison test, since workload is launched on VF side, VF has to tell PF about the injection information.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 26 ++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c    | 24 ++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h    |  9 ++++++++
 4 files changed, 53 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +18 -8
index ab9ba5a9c33d..498642eb5fb7 100644
@@ -1103,15 +1103,25 @@ int amdgpu_ras_error_inject(struct amdgpu_device *adev,
 							  block_info.address);
 	}
 
-	if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev, info);
+	if (!amdgpu_sriov_vf(adev)) {
+		if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops->ras_error_inject(adev, info);
+		} else {
+			/* If defined special ras_error_inject(e.g: xgmi), implement special ras_error_inject */
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops->ras_error_inject(adev, &block_info);
+			else  /*If not defined .ras_error_inject, use default ras_error_inject*/
+				ret = psp_ras_trigger_error(&adev->psp, &block_info);
+		}
 	} else {
-		/* If defined special ras_error_inject(e.g: xgmi), implement special ras_error_inject */
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev, &block_info);
-		else  /*If not defined .ras_error_inject, use default ras_error_inject*/
-			ret = psp_ras_trigger_error(&adev->psp, &block_info);
+		if (adev->virt.ops && adev->virt.ops->ras_trigger_error) {
+			adev->virt.ops->ras_trigger_error(adev, &block_info);
+			ret = 0;
+		} else {
+			dev_warn(adev->dev,
+				"No ras_trigger_error interface in SRIOV!\n");
+		}
 	}
 
 	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
index 239f232f9c02..4534e6f70a4b 100644
@@ -84,6 +84,8 @@ struct amdgpu_virt_ops {
 	int (*reset_gpu)(struct amdgpu_device *adev);
 	int (*wait_reset)(struct amdgpu_device *adev);
 	void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1, u32 data2, u32 data3);
+	void (*ras_trigger_error)(struct amdgpu_device *adev,
+				struct ta_ras_trigger_error_input *info);
 };
 
 /*
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +24 -0
index a2f04b249132..3b4c5162a237 100644
@@ -33,6 +33,7 @@
 #include "mxgpu_ai.h"
 
 #include "amdgpu_reset.h"
+#include "ta_ras_if.h"
 
 static void xgpu_ai_mailbox_send_ack(struct amdgpu_device *adev)
 {
@@ -405,6 +406,28 @@ static int xgpu_ai_request_init_data(struct amdgpu_device *adev)
 	return xgpu_ai_send_access_requests(adev, IDH_REQ_GPU_INIT_DATA);
 }
 
+void amdgpu_virt_ras_trigger_error(struct amdgpu_device *adev,
+               struct ta_ras_trigger_error_input *info)
+{
+       uint32_t addr_lo, addr_hi, data1 = 0;
+
+       addr_lo = lower_32_bits(info->address);
+       addr_hi = upper_32_bits(info->address);
+
+       /* block id : bits[0:4], inject_error_type : bits[5:8]
+        * sub_block_index : bits[9:17], value : bits[18:19]
+        */
+       data1 = info->block_id & RAS_BLOCK_ID_MASK;
+       data1 |= (info->inject_error_type & RAS_INJECT_ERROR_TYPE_MASK) <<
+			RAS_INJECT_ERROR_TYPE_SHIFT;
+       data1 |= (info->sub_block_index & RAS_SUB_BLOCK_INDEX_MASK) <<
+			RAS_SUB_BLOCK_INDEX_SHIFT;
+       data1 |= (info->value & RAS_VALUE_MASK) << RAS_VALUE_SHIFT;
+
+       xgpu_ai_mailbox_trans_msg(adev, IDH_RAS_ERROR_INJECT, data1,
+				addr_lo, addr_hi);
+}
+
 const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.req_full_gpu	= xgpu_ai_request_full_gpu_access,
 	.rel_full_gpu	= xgpu_ai_release_full_gpu_access,
@@ -412,4 +435,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.wait_reset = NULL,
 	.trans_msg = xgpu_ai_mailbox_trans_msg,
 	.req_init_data  = xgpu_ai_request_init_data,
+	.ras_trigger_error = amdgpu_virt_ras_trigger_error,
 };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +9 -0
index fa7e13e0459e..0841d6632328 100644
@@ -29,6 +29,14 @@
 #define AI_MAILBOX_POLL_FLR_TIMEDOUT	10000
 #define AI_MAILBOX_POLL_MSG_REP_MAX	11
 
+#define RAS_BLOCK_ID_MASK 0x1f
+#define RAS_INJECT_ERROR_TYPE_MASK 0xf
+#define RAS_INJECT_ERROR_TYPE_SHIFT 5
+#define RAS_SUB_BLOCK_INDEX_MASK 0x1ff
+#define RAS_SUB_BLOCK_INDEX_SHIFT 9
+#define RAS_VALUE_MASK 0x3
+#define RAS_VALUE_SHIFT 18
+
 enum idh_request {
 	IDH_REQ_GPU_INIT_ACCESS = 1,
 	IDH_REL_GPU_INIT_ACCESS,
@@ -39,6 +47,7 @@ enum idh_request {
 
 	IDH_LOG_VF_ERROR       = 200,
 	IDH_READY_TO_RESET 	= 201,
+	IDH_RAS_ERROR_INJECT = 202,
 };
 
 enum idh_event {
Signature · 1 line
2.35.1
author
#1 lore raw

PATCH 2/2 drm/amdgpu: inform PF if VF receives RAS poison interrupt

PF will do page retirement and reset VF in SRIOV.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c  | 18 +++++++++++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  1 +
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c    |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h    |  1 +
 4 files changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +13 -5
index aad3c8b4c810..b603ab3bd138 100644
@@ -123,12 +123,20 @@ int amdgpu_umc_poison_handler(struct amdgpu_device *adev,
 	};
 	struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);
 
-	ret =
-		amdgpu_umc_do_page_retirement(adev, ras_error_status, NULL, reset);
+	if (!amdgpu_sriov_vf(adev)) {
+		ret = amdgpu_umc_do_page_retirement(adev,
+				ras_error_status, NULL, reset);
 
-	if (ret == AMDGPU_RAS_SUCCESS && obj) {
-		obj->err_data.ue_count += err_data->ue_count;
-		obj->err_data.ce_count += err_data->ce_count;
+		if (ret == AMDGPU_RAS_SUCCESS && obj) {
+			obj->err_data.ue_count += err_data->ue_count;
+			obj->err_data.ce_count += err_data->ce_count;
+		}
+	} else {
+		if (adev->virt.ops && adev->virt.ops->ras_poison_handler)
+			adev->virt.ops->ras_poison_handler(adev);
+		else
+			dev_warn(adev->dev,
+				"No ras_poison_handler interface in SRIOV!\n");
 	}
 
 	return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -0
index 4534e6f70a4b..41d03ef417d0 100644
@@ -86,6 +86,7 @@ struct amdgpu_virt_ops {
 	void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1, u32 data2, u32 data3);
 	void (*ras_trigger_error)(struct amdgpu_device *adev,
 				struct ta_ras_trigger_error_input *info);
+	void (*ras_poison_handler)(struct amdgpu_device *adev);
 };
 
 /*
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +6 -0
index 3b4c5162a237..7545d7c0f524 100644
@@ -428,6 +428,11 @@ void amdgpu_virt_ras_trigger_error(struct amdgpu_device *adev,
 				addr_lo, addr_hi);
 }
 
+void amdgpu_virt_ras_poison_handler(struct amdgpu_device *adev)
+{
+       xgpu_ai_send_access_requests(adev, IDH_RAS_POISON);
+}
+
 const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.req_full_gpu	= xgpu_ai_request_full_gpu_access,
 	.rel_full_gpu	= xgpu_ai_release_full_gpu_access,
@@ -436,4 +441,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.trans_msg = xgpu_ai_mailbox_trans_msg,
 	.req_init_data  = xgpu_ai_request_init_data,
 	.ras_trigger_error = amdgpu_virt_ras_trigger_error,
+	.ras_poison_handler = amdgpu_virt_ras_poison_handler,
 };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +1 -0
index 0841d6632328..869dff6daddd 100644
@@ -48,6 +48,7 @@ enum idh_request {
 	IDH_LOG_VF_ERROR       = 200,
 	IDH_READY_TO_RESET 	= 201,
 	IDH_RAS_ERROR_INJECT = 202,
+	IDH_RAS_POISON		= 203,
 };
 
 enum idh_event {
Signature · 1 line
2.35.1
#2 lore raw
In reply to Tao Zhou

[AMD Official Use Only - General]

The series is fine for me, these patches also need to be reviewed by the virtualization group.

Regards,
Stanley

Quoted 171 lines

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, August 31, 2022 4:39 PM
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Liu, Monk <[email protected]>; Skvortsov, Victor <[email protected]>; Chang, HaiJun <[email protected]>; Chander, Vignesh <[email protected]>; Wan, Gavin <[email protected]>; Liu, Shaoyun <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: support RAS error inject for SRIOV

In SRIOV, RAS error injection request will be sent to PF via mailbox, the injection input information should also be transferred to PF.

Generally, the error injection is operated on PF side directly, but for RAS poison test, since workload is launched on VF side, VF has to tell PF about the injection information.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 26 ++++++++++++++++------
--  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c    | 24
++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h    |  9 ++++++++
 4 files changed, 53 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -3
index ab9ba5a9c33d..498642eb5fb7 100644
@@ -1103,15 +1103,25 @@ int amdgpu_ras_error_inject(struct
 amdgpu_device *adev,
 							  block_info.address);
 	}
 
-	if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev,
 info);
+	if (!amdgpu_sriov_vf(adev)) {
+		if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops-
 >ras_error_inject(adev, info);
+		} else {
+			/* If defined special ras_error_inject(e.g: xgmi),

implement special ras_error_inject */

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops-
Quoted 1 line

ras_error_inject(adev, &block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+			else  /*If not defined .ras_error_inject, use default

ras_error_inject*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+				ret = psp_ras_trigger_error(&adev->psp,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+		}
 	} else {
-		/* If defined special ras_error_inject(e.g: xgmi), implement

special ras_error_inject */

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-		else  /*If not defined .ras_error_inject, use default

ras_error_inject*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-			ret = psp_ras_trigger_error(&adev->psp,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		if (adev->virt.ops && adev->virt.ops->ras_trigger_error) {
+			adev->virt.ops->ras_trigger_error(adev, &block_info);
+			ret = 0;
+		} else {
+			dev_warn(adev->dev,
+				"No ras_trigger_error interface in SRIOV!\n");
+		}
 	}
 
 	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
index 239f232f9c02..4534e6f70a4b 100644
@@ -84,6 +84,8 @@ struct amdgpu_virt_ops {
 	int (*reset_gpu)(struct amdgpu_device *adev);
 	int (*wait_reset)(struct amdgpu_device *adev);
 	void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1,
 u32 data2, u32 data3);
+	void (*ras_trigger_error)(struct amdgpu_device *adev,
+				struct ta_ras_trigger_error_input *info);
 };
 

/*

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +1 -0
index a2f04b249132..3b4c5162a237 100644
@@ -33,6 +33,7 @@
 #include "mxgpu_ai.h"
 
 #include "amdgpu_reset.h"
+#include "ta_ras_if.h"
 
 static void xgpu_ai_mailbox_send_ack(struct amdgpu_device *adev)  { @@ -

405,6 +406,28 @@ static int xgpu_ai_request_init_data(struct amdgpu_device *adev)
return xgpu_ai_send_access_requests(adev,
IDH_REQ_GPU_INIT_DATA); }

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +12 -0
+void amdgpu_virt_ras_trigger_error(struct amdgpu_device *adev,
+               struct ta_ras_trigger_error_input *info) {
+       uint32_t addr_lo, addr_hi, data1 = 0;
+
+       addr_lo = lower_32_bits(info->address);
+       addr_hi = upper_32_bits(info->address);
+
+       /* block id : bits[0:4], inject_error_type : bits[5:8]
+        * sub_block_index : bits[9:17], value : bits[18:19]
+        */
+       data1 = info->block_id & RAS_BLOCK_ID_MASK;
+       data1 |= (info->inject_error_type & RAS_INJECT_ERROR_TYPE_MASK)

<<

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +10 -0
+			RAS_INJECT_ERROR_TYPE_SHIFT;
+       data1 |= (info->sub_block_index & RAS_SUB_BLOCK_INDEX_MASK) <<
+			RAS_SUB_BLOCK_INDEX_SHIFT;
+       data1 |= (info->value & RAS_VALUE_MASK) << RAS_VALUE_SHIFT;
+
+       xgpu_ai_mailbox_trans_msg(adev, IDH_RAS_ERROR_INJECT, data1,
+				addr_lo, addr_hi);
+}
+
 const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.req_full_gpu	= xgpu_ai_request_full_gpu_access,
 	.rel_full_gpu	= xgpu_ai_release_full_gpu_access,
@@ -412,4 +435,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.wait_reset = NULL,
 	.trans_msg = xgpu_ai_mailbox_trans_msg,
 	.req_init_data  = xgpu_ai_request_init_data,
+	.ras_trigger_error = amdgpu_virt_ras_trigger_error,
 };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +9 -1
index fa7e13e0459e..0841d6632328 100644
@@ -29,6 +29,14 @@
 #define AI_MAILBOX_POLL_FLR_TIMEDOUT	10000
 #define AI_MAILBOX_POLL_MSG_REP_MAX	11
 
+#define RAS_BLOCK_ID_MASK 0x1f
+#define RAS_INJECT_ERROR_TYPE_MASK 0xf
+#define RAS_INJECT_ERROR_TYPE_SHIFT 5
+#define RAS_SUB_BLOCK_INDEX_MASK 0x1ff
+#define RAS_SUB_BLOCK_INDEX_SHIFT 9
+#define RAS_VALUE_MASK 0x3
+#define RAS_VALUE_SHIFT 18
+
 enum idh_request {
 	IDH_REQ_GPU_INIT_ACCESS = 1,
 	IDH_REL_GPU_INIT_ACCESS,
@@ -39,6 +47,7 @@ enum idh_request {
 
 	IDH_LOG_VF_ERROR       = 200,
 	IDH_READY_TO_RESET 	= 201,
+	IDH_RAS_ERROR_INJECT = 202,
 };
 
 enum idh_event {
--

2.35.1

#3 lore raw

+ Andy and Jerry,

Hi Tao & Stanley,

As security concern, we cannot define such PF-VF mailbox message for ECC or RAS error injection. As Vignesh said, we might need to test script to communicate between host and guest.

Thanks,
HaiJun

-----Original Message-----
From: Yang, Stanley <[email protected]>
Sent: Thursday, September 1, 2022 10:24 AM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Liu, Monk <[email protected]>; Skvortsov, Victor <[email protected]>; Chang, HaiJun <[email protected]>; Chander, Vignesh <[email protected]>; Wan, Gavin <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: support RAS error inject for SRIOV

[AMD Official Use Only - General]

The series is fine for me, these patches also need to be reviewed by the virtualization group.

Regards,
Stanley

Quoted 171 lines

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, August 31, 2022 4:39 PM
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Liu, Monk <[email protected]>; Skvortsov, Victor <[email protected]>; Chang, HaiJun <[email protected]>; Chander, Vignesh <[email protected]>; Wan, Gavin <[email protected]>; Liu, Shaoyun <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: support RAS error inject for SRIOV

In SRIOV, RAS error injection request will be sent to PF via mailbox, the injection input information should also be transferred to PF.

Generally, the error injection is operated on PF side directly, but for RAS poison test, since workload is launched on VF side, VF has to tell PF about the injection information.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 26 ++++++++++++++++------
--  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c    | 24
++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h    |  9 ++++++++
 4 files changed, 53 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -3
index ab9ba5a9c33d..498642eb5fb7 100644
@@ -1103,15 +1103,25 @@ int amdgpu_ras_error_inject(struct 
 amdgpu_device *adev,
 							  block_info.address);
 	}
 
-	if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev,
 info);
+	if (!amdgpu_sriov_vf(adev)) {
+		if (info->head.block == AMDGPU_RAS_BLOCK__GFX) {
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops-
 >ras_error_inject(adev, info);
+		} else {
+			/* If defined special ras_error_inject(e.g: xgmi),

implement special ras_error_inject */

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+			if (block_obj->hw_ops->ras_error_inject)
+				ret = block_obj->hw_ops-
Quoted 1 line

ras_error_inject(adev, &block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+			else  /*If not defined .ras_error_inject, use default

ras_error_inject*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+				ret = psp_ras_trigger_error(&adev->psp,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+		}
 	} else {
-		/* If defined special ras_error_inject(e.g: xgmi), implement

special ras_error_inject */

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-		if (block_obj->hw_ops->ras_error_inject)
-			ret = block_obj->hw_ops->ras_error_inject(adev,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-		else  /*If not defined .ras_error_inject, use default

ras_error_inject*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-			ret = psp_ras_trigger_error(&adev->psp,

&block_info);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		if (adev->virt.ops && adev->virt.ops->ras_trigger_error) {
+			adev->virt.ops->ras_trigger_error(adev, &block_info);
+			ret = 0;
+		} else {
+			dev_warn(adev->dev,
+				"No ras_trigger_error interface in SRIOV!\n");
+		}
 	}
 
 	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
index 239f232f9c02..4534e6f70a4b 100644
@@ -84,6 +84,8 @@ struct amdgpu_virt_ops {
 	int (*reset_gpu)(struct amdgpu_device *adev);
 	int (*wait_reset)(struct amdgpu_device *adev);
 	void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1,
 u32 data2, u32 data3);
+	void (*ras_trigger_error)(struct amdgpu_device *adev,
+				struct ta_ras_trigger_error_input *info);
 };
 

/*

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +1 -0
index a2f04b249132..3b4c5162a237 100644
@@ -33,6 +33,7 @@
 #include "mxgpu_ai.h"
 
 #include "amdgpu_reset.h"
+#include "ta_ras_if.h"
 
 static void xgpu_ai_mailbox_send_ack(struct amdgpu_device *adev)  { 

@@ -
405,6 +406,28 @@ static int xgpu_ai_request_init_data(struct amdgpu_device *adev)
return xgpu_ai_send_access_requests(adev,
IDH_REQ_GPU_INIT_DATA); }

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +13 -0
+void amdgpu_virt_ras_trigger_error(struct amdgpu_device *adev,
+               struct ta_ras_trigger_error_input *info) {
+       uint32_t addr_lo, addr_hi, data1 = 0;
+
+       addr_lo = lower_32_bits(info->address);
+       addr_hi = upper_32_bits(info->address);
+
+       /* block id : bits[0:4], inject_error_type : bits[5:8]
+        * sub_block_index : bits[9:17], value : bits[18:19]
+        */
+       data1 = info->block_id & RAS_BLOCK_ID_MASK;
+       data1 |= (info->inject_error_type & 
+ RAS_INJECT_ERROR_TYPE_MASK)

<<

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +10 -0
+			RAS_INJECT_ERROR_TYPE_SHIFT;
+       data1 |= (info->sub_block_index & RAS_SUB_BLOCK_INDEX_MASK) <<
+			RAS_SUB_BLOCK_INDEX_SHIFT;
+       data1 |= (info->value & RAS_VALUE_MASK) << RAS_VALUE_SHIFT;
+
+       xgpu_ai_mailbox_trans_msg(adev, IDH_RAS_ERROR_INJECT, data1,
+				addr_lo, addr_hi);
+}
+
 const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.req_full_gpu	= xgpu_ai_request_full_gpu_access,
 	.rel_full_gpu	= xgpu_ai_release_full_gpu_access,
@@ -412,4 +435,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = {
 	.wait_reset = NULL,
 	.trans_msg = xgpu_ai_mailbox_trans_msg,
 	.req_init_data  = xgpu_ai_request_init_data,
+	.ras_trigger_error = amdgpu_virt_ras_trigger_error,
 };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +7 -1
index fa7e13e0459e..0841d6632328 100644
@@ -29,6 +29,14 @@
 #define AI_MAILBOX_POLL_FLR_TIMEDOUT	10000
 #define AI_MAILBOX_POLL_MSG_REP_MAX	11
 
+#define RAS_BLOCK_ID_MASK 0x1f
+#define RAS_INJECT_ERROR_TYPE_MASK 0xf #define 
+RAS_INJECT_ERROR_TYPE_SHIFT 5 #define RAS_SUB_BLOCK_INDEX_MASK 0x1ff 
+#define RAS_SUB_BLOCK_INDEX_SHIFT 9 #define RAS_VALUE_MASK 0x3 
+#define RAS_VALUE_SHIFT 18
+
 enum idh_request {
 	IDH_REQ_GPU_INIT_ACCESS = 1,
 	IDH_REL_GPU_INIT_ACCESS,
@@ -39,6 +47,7 @@ enum idh_request {
 
 	IDH_LOG_VF_ERROR       = 200,
 	IDH_READY_TO_RESET 	= 201,
+	IDH_RAS_ERROR_INJECT = 202,
 };
 
 enum idh_event {
--

2.35.1