Skip to contentSkip to conversation

drm/amdgpu: implement RAS interrupt handler for poison creation

PATCH In review Tao Zhou 3 participants 9 messages Apr 20, 2022

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/3 drm/amdgpu: implement RAS interrupt handler for poison creation

Prepare for the implementation of poison consumption handler.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 62 ++++++++++++++-----------
 1 file changed, 35 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +35 -27
index 4bbed76b79c8..2d066cff70ea 100644
@@ -1515,12 +1515,44 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	struct ras_ih_data *data = &obj->ih_data;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	int ret;
+
+	if (!data->cb)
+		return;
+
+	if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
+	    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+		dev_info(obj->adev->dev,
+			"Poison is created, no user action is needed.\n");
+	else {
+		/* Let IP handle its data, maybe we need get the output
+		 * from the callback to update the error type/count, etc
+		 */
+		ret = data->cb(obj->adev, &err_data, entry);
+		/* ue will trigger an interrupt, and in that case
+		 * we need do a reset to recovery the whole system.
+		 * But leave IP do that recovery, here we just dispatch
+		 * the error.
+		 */
+		if (ret == AMDGPU_RAS_SUCCESS) {
+			/* these counts could be left as 0 if
+			 * some blocks do not count error number
+			 */
+			obj->err_data.ue_count += err_data.ue_count;
+			obj->err_data.ce_count += err_data.ce_count;
+		}
+	}
+}
+
 static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 {
 	struct ras_ih_data *data = &obj->ih_data;
 	struct amdgpu_iv_entry entry;
-	int ret;
-	struct ras_err_data err_data = {0, 0, 0, NULL};
 
 	while (data->rptr != data->wptr) {
 		rmb();
@@ -1531,31 +1563,7 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 		data->rptr = (data->aligned_element_size +
 				data->rptr) % data->ring_size;
 
-		if (data->cb) {
-			if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
-			    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
-				dev_info(obj->adev->dev,
-						"Poison is created, no user action is needed.\n");
-			else {
-				/* Let IP handle its data, maybe we need get the output
-				 * from the callback to udpate the error type/count, etc
-				 */
-				memset(&err_data, 0, sizeof(err_data));
-				ret = data->cb(obj->adev, &err_data, &entry);
-				/* ue will trigger an interrupt, and in that case
-				 * we need do a reset to recovery the whole system.
-				 * But leave IP do that recovery, here we just dispatch
-				 * the error.
-				 */
-				if (ret == AMDGPU_RAS_SUCCESS) {
-					/* these counts could be left as 0 if
-					 * some blocks do not count error number
-					 */
-					obj->err_data.ue_count += err_data.ue_count;
-					obj->err_data.ce_count += err_data.ce_count;
-				}
-			}
-		}
+		ras_interrupt_poison_creation_handler(obj, &entry);
 	}
 }
 
Signature · 1 line
2.35.1
author
#1 lore raw

PATCH 2/3 drm/amdgpu: add RAS poison consumption handler

Add support for general RAS poison consumption handler.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 43 ++++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
 2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +42 -1
index 2d066cff70ea..4bd3c25be809 100644
@@ -1515,6 +1515,44 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void ras_interrupt_poison_consumption_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	bool poison_stat = true, need_reset = true;
+	struct amdgpu_device *adev = obj->adev;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct ras_ih_data *data = &obj->ih_data;
+	struct amdgpu_ras_block_object *block_obj =
+		amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+
+	if (!adev->gmc.xgmi.connected_to_cpu)
+		amdgpu_umc_poison_handler(adev, &err_data, false);
+
+	/* Two ways for RAS block's poison consumption implementation:
+	 * 1. define IH callback, or
+	 * 2. implement query and consumption interfaces.
+	 */
+	if (data->cb) {
+		need_reset = !!data->cb(obj->adev, &err_data, entry);
+	} else if (block_obj && block_obj->hw_ops) {
+		if (block_obj->hw_ops->query_poison_status) {
+			poison_stat = block_obj->hw_ops->query_poison_status(adev);
+			if (!poison_stat)
+				dev_info(adev->dev, "No RAS poison status in %s poison IH.\n",
+						block_obj->ras_comm.name);
+		}
+
+		if (poison_stat && block_obj->hw_ops->handle_poison_consumption) {
+			poison_stat = block_obj->hw_ops->handle_poison_consumption(adev);
+			need_reset = poison_stat;
+		}
+	}
+
+	/* gpu reset is fallback for all failed cases */
+	if (need_reset)
+		amdgpu_ras_reset_gpu(adev);
+}
+
 static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
 				struct amdgpu_iv_entry *entry)
 {
@@ -1563,7 +1601,10 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 		data->rptr = (data->aligned_element_size +
 				data->rptr) % data->ring_size;
 
-		ras_interrupt_poison_creation_handler(obj, &entry);
+		if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+			ras_interrupt_poison_creation_handler(obj, &entry);
+		else
+			ras_interrupt_poison_consumption_handler(obj, &entry);
 	}
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index 606df8869b89..c4b61785ab5c 100644
@@ -509,6 +509,7 @@ struct amdgpu_ras_block_hw_ops {
 	void (*reset_ras_error_count)(struct amdgpu_device *adev);
 	void (*reset_ras_error_status)(struct amdgpu_device *adev);
 	bool (*query_poison_status)(struct amdgpu_device *adev);
+	bool (*handle_poison_consumption)(struct amdgpu_device *adev);
 };
 
 /* work flow
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH 2/3] drm/amdgpu: add RAS poison consumption handler

Quoted 23 lines · Tao Zhou

Add support for general RAS poison consumption handler.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 43 ++++++++++++++++++++++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
  2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
index 2d066cff70ea..4bd3c25be809 100644
@@ -1515,6 +1515,44 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
  /* ras fs end */
 
  /* ih begin */
+static void ras_interrupt_poison_consumption_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	bool poison_stat = true, need_reset = true;
+	struct amdgpu_device *adev = obj->adev;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct ras_ih_data *data = &obj->ih_data;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1534

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+	struct amdgpu_ras_block_object *block_obj =
+		amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+
+	if (!adev->gmc.xgmi.connected_to_cpu)
+		amdgpu_umc_poison_handler(adev, &err_data, false);
+
+	/* Two ways for RAS block's poison consumption implementation:
+	 * 1. define IH callback, or
+	 * 2. implement query and consumption interfaces.
+	 */

This doesn't look appropriate. Better to have one standard way. What if an IP has call back implemented to handle errors in non-poison mode?

Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +21 -0
+	if (data->cb) {
+		need_reset = !!data->cb(obj->adev, &err_data, entry);
+	} else if (block_obj && block_obj->hw_ops) {
+		if (block_obj->hw_ops->query_poison_status) {
+			poison_stat = block_obj->hw_ops->query_poison_status(adev);
+			if (!poison_stat)
+				dev_info(adev->dev, "No RAS poison status in %s poison IH.\n",
+						block_obj->ras_comm.name);
+		}
+
+		if (poison_stat && block_obj->hw_ops->handle_poison_consumption) {
+			poison_stat = block_obj->hw_ops->handle_poison_consumption(adev);
+			need_reset = poison_stat;
+		}
+	}
+
+	/* gpu reset is fallback for all failed cases */
+	if (need_reset)
+		amdgpu_ras_reset_gpu(adev);
+}
+
  static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
  				struct amdgpu_iv_entry *entry)
  {

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj) · line 1607

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -1
@@ -1563,7 +1601,10 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
  		data->rptr = (data->aligned_element_size +
  				data->rptr) % data->ring_size;
 
-		ras_interrupt_poison_creation_handler(obj, &entry);
+		if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+			ras_interrupt_poison_creation_handler(obj, &entry);
+		else
+			ras_interrupt_poison_consumption_handler(obj, &entry);

Same problem - poison mode is implicitly assumed. Poison consumption is relevant only in poison mode.

Thanks,
Lijo

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
  	}
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index 606df8869b89..c4b61785ab5c 100644
@@ -509,6 +509,7 @@ struct amdgpu_ras_block_hw_ops {
  	void (*reset_ras_error_count)(struct amdgpu_device *adev);
  	void (*reset_ras_error_status)(struct amdgpu_device *adev);
  	bool (*query_poison_status)(struct amdgpu_device *adev);
+	bool (*handle_poison_consumption)(struct amdgpu_device *adev);
  };
 
  /* work flow
author
#3 lore raw

RE: [PATCH 2/3] drm/amdgpu: add RAS poison consumption handler

[AMD Official Use Only]

Quoted 44 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, April 20, 2022 12:33 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH 2/3] drm/amdgpu: add RAS poison consumption handler

Quoted 5 lines · Tao Zhou

Add support for general RAS poison consumption handler.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 43

++++++++++++++++++++++++-

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct

Quoted 9 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
  2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 2d066cff70ea..4bd3c25be809 100644
@@ -1515,6 +1515,44 @@ static int amdgpu_ras_fs_fini(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
  /* ras fs end */
 
  /* ih begin */
+static void ras_interrupt_poison_consumption_handler(struct ras_manager

*obj,

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +11 -0
+				struct amdgpu_iv_entry *entry)
+{
+	bool poison_stat = true, need_reset = true;
+	struct amdgpu_device *adev = obj->adev;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct ras_ih_data *data = &obj->ih_data;
+	struct amdgpu_ras_block_object *block_obj =
+		amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+
+	if (!adev->gmc.xgmi.connected_to_cpu)
+		amdgpu_umc_poison_handler(adev, &err_data, false);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1534

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+
+	/* Two ways for RAS block's poison consumption implementation:
+	 * 1. define IH callback, or
+	 * 2. implement query and consumption interfaces.
+	 */

This doesn't look appropriate. Better to have one standard way. What if an IP has call back implemented to handle errors in non-poison mode?

[Tao] approach 2 is standard way, but some RAS blocks may have different requirements for RAS consumption handler in the future, a callback function is more convenient for this situation.

Quoted 41 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+	if (data->cb) {
+		need_reset = !!data->cb(obj->adev, &err_data, entry);
+	} else if (block_obj && block_obj->hw_ops) {
+		if (block_obj->hw_ops->query_poison_status) {
+			poison_stat = block_obj->hw_ops-
 query_poison_status(adev);
+			if (!poison_stat)
+				dev_info(adev->dev, "No RAS poison status

in %s poison IH.\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +14 -0
+						block_obj->ras_comm.name);
+		}
+
+		if (poison_stat && block_obj->hw_ops-
 handle_poison_consumption) {
+			poison_stat = block_obj->hw_ops-
 handle_poison_consumption(adev);
+			need_reset = poison_stat;
+		}
+	}
+
+	/* gpu reset is fallback for all failed cases */
+	if (need_reset)
+		amdgpu_ras_reset_gpu(adev);
+}
+

static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
struct amdgpu_iv_entry *entry)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
@@ -1563,7 +1601,10 @@ static void amdgpu_ras_interrupt_handler(struct

ras_manager *obj)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -1
  		data->rptr = (data->aligned_element_size +
  				data->rptr) % data->ring_size;
 
-		ras_interrupt_poison_creation_handler(obj, &entry);
+		if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+			ras_interrupt_poison_creation_handler(obj, &entry);
+		else
+			ras_interrupt_poison_consumption_handler(obj,

&entry);

Quoted 2 lines

Same problem - poison mode is implicitly assumed. Poison consumption is relevant only in poison mode.

[Tao] will fix it.

Quoted 21 lines

Thanks,
Lijo

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
  	}
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index 606df8869b89..c4b61785ab5c 100644
@@ -509,6 +509,7 @@ struct amdgpu_ras_block_hw_ops {
  	void (*reset_ras_error_count)(struct amdgpu_device *adev);
  	void (*reset_ras_error_status)(struct amdgpu_device *adev);
  	bool (*query_poison_status)(struct amdgpu_device *adev);
+	bool (*handle_poison_consumption)(struct amdgpu_device *adev);
  };
 
  /* work flow
#4 lore raw

Re: [PATCH 2/3] drm/amdgpu: add RAS poison consumption handler

Quoted 57 lines · Tao

[AMD Official Use Only]

Quoted 44 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, April 20, 2022 12:33 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH 2/3] drm/amdgpu: add RAS poison consumption handler

Quoted 5 lines · Tao Zhou

Add support for general RAS poison consumption handler.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 43

++++++++++++++++++++++++-

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct

Quoted 9 lines
   drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
   2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 2d066cff70ea..4bd3c25be809 100644
@@ -1515,6 +1515,44 @@ static int amdgpu_ras_fs_fini(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
   /* ras fs end */
 
   /* ih begin */
+static void ras_interrupt_poison_consumption_handler(struct ras_manager

*obj,

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +11 -0
+				struct amdgpu_iv_entry *entry)
+{
+	bool poison_stat = true, need_reset = true;
+	struct amdgpu_device *adev = obj->adev;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct ras_ih_data *data = &obj->ih_data;
+	struct amdgpu_ras_block_object *block_obj =
+		amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+
+	if (!adev->gmc.xgmi.connected_to_cpu)
+		amdgpu_umc_poison_handler(adev, &err_data, false);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1534

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+
+	/* Two ways for RAS block's poison consumption implementation:
+	 * 1. define IH callback, or
+	 * 2. implement query and consumption interfaces.
+	 */

This doesn't look appropriate. Better to have one standard way. What if an IP has call back implemented to handle errors in non-poison mode?

Quoted 2 lines

[Tao] approach 2 is standard way, but some RAS blocks may have different requirements for RAS consumption handler in the future, a callback function is more convenient for this situation.

Since it's a future outlook, why can't we enforce 2? i.e., any IP will need to implement consumption handler for poison consumption interrupts.

Thanks,
Lijo

Quoted 67 lines
Quoted 41 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+	if (data->cb) {
+		need_reset = !!data->cb(obj->adev, &err_data, entry);
+	} else if (block_obj && block_obj->hw_ops) {
+		if (block_obj->hw_ops->query_poison_status) {
+			poison_stat = block_obj->hw_ops-
 query_poison_status(adev);
+			if (!poison_stat)
+				dev_info(adev->dev, "No RAS poison status

in %s poison IH.\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +14 -0
+						block_obj->ras_comm.name);
+		}
+
+		if (poison_stat && block_obj->hw_ops-
 handle_poison_consumption) {
+			poison_stat = block_obj->hw_ops-
 handle_poison_consumption(adev);
+			need_reset = poison_stat;
+		}
+	}
+
+	/* gpu reset is fallback for all failed cases */
+	if (need_reset)
+		amdgpu_ras_reset_gpu(adev);
+}
+

static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
struct amdgpu_iv_entry *entry)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
@@ -1563,7 +1601,10 @@ static void amdgpu_ras_interrupt_handler(struct

ras_manager *obj)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -1
   		data->rptr = (data->aligned_element_size +
   				data->rptr) % data->ring_size;
 
-		ras_interrupt_poison_creation_handler(obj, &entry);
+		if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+			ras_interrupt_poison_creation_handler(obj, &entry);
+		else
+			ras_interrupt_poison_consumption_handler(obj,

&entry);

Quoted 2 lines

Same problem - poison mode is implicitly assumed. Poison consumption is relevant only in poison mode.

[Tao] will fix it.

Quoted 21 lines

Thanks,
Lijo

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
   	}
   }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index 606df8869b89..c4b61785ab5c 100644
@@ -509,6 +509,7 @@ struct amdgpu_ras_block_hw_ops {
   	void (*reset_ras_error_count)(struct amdgpu_device *adev);
   	void (*reset_ras_error_status)(struct amdgpu_device *adev);
   	bool (*query_poison_status)(struct amdgpu_device *adev);
+	bool (*handle_poison_consumption)(struct amdgpu_device *adev);
   };
 
   /* work flow
author
#5 lore raw

PATCH 3/3 drm/amdgpu: add RAS fatal error interrupt handler

In reply to Tao Zhou

The fatal error handler is independent from general ras interrupt handler since there is no related IH ring.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 15 +--------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 20 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
 3 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +1 -14
index ea3e8c66211f..b4cf8717f554 100644
@@ -193,20 +193,7 @@ static irqreturn_t amdgpu_irq_handler(int irq, void *arg)
 	if (ret == IRQ_HANDLED)
 		pm_runtime_mark_last_busy(dev->dev);
 
-	/* For the hardware that cannot enable bif ring for both ras_controller_irq
-         * and ras_err_evnet_athub_irq ih cookies, the driver has to poll status
-	 * register to check whether the interrupt is triggered or not, and properly
-	 * ack the interrupt if it is there
-	 */
-	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__PCIE_BIF)) {
-		if (adev->nbio.ras &&
-		    adev->nbio.ras->handle_ras_controller_intr_no_bifring)
-			adev->nbio.ras->handle_ras_controller_intr_no_bifring(adev);
-
-		if (adev->nbio.ras &&
-		    adev->nbio.ras->handle_ras_err_event_athub_intr_no_bifring)
-			adev->nbio.ras->handle_ras_err_event_athub_intr_no_bifring(adev);
-	}
+	amdgpu_ras_interrupt_fatal_error_handler(adev);
 
 	return ret;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +20 -0
index 4bd3c25be809..a93024f72255 100644
@@ -1515,6 +1515,26 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+
+/* For the hardware that cannot enable bif ring for both ras_controller_irq
+ * and ras_err_evnet_athub_irq ih cookies, the driver has to poll status
+ * register to check whether the interrupt is triggered or not, and properly
+ * ack the interrupt if it is there
+ */
+void amdgpu_ras_interrupt_fatal_error_handler(struct amdgpu_device *adev)
+{
+	if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__PCIE_BIF))
+		return;
+
+	if (adev->nbio.ras &&
+	    adev->nbio.ras->handle_ras_controller_intr_no_bifring)
+		adev->nbio.ras->handle_ras_controller_intr_no_bifring(adev);
+
+	if (adev->nbio.ras &&
+	    adev->nbio.ras->handle_ras_err_event_athub_intr_no_bifring)
+		adev->nbio.ras->handle_ras_err_event_athub_intr_no_bifring(adev);
+}
+
 static void ras_interrupt_poison_consumption_handler(struct ras_manager *obj,
 				struct amdgpu_iv_entry *entry)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index c4b61785ab5c..b9a6fac2b8b2 100644
@@ -683,4 +683,5 @@ int amdgpu_ras_set_context(struct amdgpu_device *adev, struct amdgpu_ras *ras_co
 
 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 				struct amdgpu_ras_block_object *ras_block_obj);
+void amdgpu_ras_interrupt_fatal_error_handler(struct amdgpu_device *adev);
 #endif
Signature · 1 line
2.35.1
#6 lore raw
In reply to Tao Zhou
Quoted 20 lines · Tao Zhou

Prepare for the implementation of poison consumption handler.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 62 ++++++++++++++-----------
  1 file changed, 35 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
index 4bbed76b79c8..2d066cff70ea 100644
@@ -1515,12 +1515,44 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
  /* ras fs end */
 
  /* ih begin */
+static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	struct ras_ih_data *data = &obj->ih_data;
+	struct ras_err_data err_data = {0, 0, 0, NULL};

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1532

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+	int ret;
+
+	if (!data->cb)
+		return;
+
+	if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
+	    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+		dev_info(obj->adev->dev,
+			"Poison is created, no user action is needed.\n");
+	else {

It is confusing to handle RAS interrupts under poison_creation_handler in non-poison mode.

Thanks,
Lijo

Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +20 -27
+		/* Let IP handle its data, maybe we need get the output
+		 * from the callback to update the error type/count, etc
+		 */
+		ret = data->cb(obj->adev, &err_data, entry);
+		/* ue will trigger an interrupt, and in that case
+		 * we need do a reset to recovery the whole system.
+		 * But leave IP do that recovery, here we just dispatch
+		 * the error.
+		 */
+		if (ret == AMDGPU_RAS_SUCCESS) {
+			/* these counts could be left as 0 if
+			 * some blocks do not count error number
+			 */
+			obj->err_data.ue_count += err_data.ue_count;
+			obj->err_data.ce_count += err_data.ce_count;
+		}
+	}
+}
+
  static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
  {
  	struct ras_ih_data *data = &obj->ih_data;
  	struct amdgpu_iv_entry entry;
-	int ret;
-	struct ras_err_data err_data = {0, 0, 0, NULL};
 
  	while (data->rptr != data->wptr) {
  		rmb();
@@ -1531,31 +1563,7 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
  		data->rptr = (data->aligned_element_size +
  				data->rptr) % data->ring_size;
 
-		if (data->cb) {
-			if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
-			    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
-				dev_info(obj->adev->dev,
-						"Poison is created, no user action is needed.\n");
-			else {
-				/* Let IP handle its data, maybe we need get the output
-				 * from the callback to udpate the error type/count, etc
-				 */
-				memset(&err_data, 0, sizeof(err_data));
-				ret = data->cb(obj->adev, &err_data, &entry);
-				/* ue will trigger an interrupt, and in that case
-				 * we need do a reset to recovery the whole system.
-				 * But leave IP do that recovery, here we just dispatch
-				 * the error.
-				 */
-				if (ret == AMDGPU_RAS_SUCCESS) {
-					/* these counts could be left as 0 if
-					 * some blocks do not count error number
-					 */
-					obj->err_data.ue_count += err_data.ue_count;
-					obj->err_data.ce_count += err_data.ce_count;
-				}
-			}
-		}
+		ras_interrupt_poison_creation_handler(obj, &entry);
  	}
  }
 
author
#7 lore raw

[AMD Official Use Only]

Quoted 40 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, April 20, 2022 12:10 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: implement RAS interrupt handler for poison creation

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct

Quoted 13 lines · Tao Zhou

Prepare for the implementation of poison consumption handler.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 62 ++++++++++++++-----------
  1 file changed, 35 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 4bbed76b79c8..2d066cff70ea 100644
@@ -1515,12 +1515,44 @@ static int amdgpu_ras_fs_fini(struct

amdgpu_device *adev)

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
  /* ras fs end */
 
  /* ih begin */
+static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	struct ras_ih_data *data = &obj->ih_data;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	int ret;
+
+	if (!data->cb)
+		return;
+
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1532

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+	if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
+	    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+		dev_info(obj->adev->dev,
+			"Poison is created, no user action is needed.\n");
+	else {

It is confusing to handle RAS interrupts under poison_creation_handler in non- poison mode.

[Tao] will split it into ras_interrupt_poison_creation_handler and ras_interrupt_umc_handler.

Quoted 76 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +19 -2
+		/* Let IP handle its data, maybe we need get the output
+		 * from the callback to update the error type/count, etc
+		 */
+		ret = data->cb(obj->adev, &err_data, entry);
+		/* ue will trigger an interrupt, and in that case
+		 * we need do a reset to recovery the whole system.
+		 * But leave IP do that recovery, here we just dispatch
+		 * the error.
+		 */
+		if (ret == AMDGPU_RAS_SUCCESS) {
+			/* these counts could be left as 0 if
+			 * some blocks do not count error number
+			 */
+			obj->err_data.ue_count += err_data.ue_count;
+			obj->err_data.ce_count += err_data.ce_count;
+		}
+	}
+}
+
  static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
  {
  	struct ras_ih_data *data = &obj->ih_data;
  	struct amdgpu_iv_entry entry;
-	int ret;
-	struct ras_err_data err_data = {0, 0, 0, NULL};
 
  	while (data->rptr != data->wptr) {
  		rmb();
@@ -1531,31 +1563,7 @@ static void amdgpu_ras_interrupt_handler(struct

ras_manager *obj)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
  		data->rptr = (data->aligned_element_size +
  				data->rptr) % data->ring_size;
 
-		if (data->cb) {
-			if (amdgpu_ras_is_poison_mode_supported(obj->adev)

&&

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
-			    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
-				dev_info(obj->adev->dev,
-						"Poison is created, no user

action is needed.\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct · line 1540

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-			else {
-				/* Let IP handle its data, maybe we need get

the output

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct · line 1541

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-				 * from the callback to udpate the error

type/count, etc

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -5
-				 */
-				memset(&err_data, 0, sizeof(err_data));
-				ret = data->cb(obj->adev, &err_data, &entry);
-				/* ue will trigger an interrupt, and in that case
-				 * we need do a reset to recovery the whole

system.

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct · line 1547

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-				 * But leave IP do that recovery, here we just

dispatch

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -5
-				 * the error.
-				 */
-				if (ret == AMDGPU_RAS_SUCCESS) {
-					/* these counts could be left as 0 if
-					 * some blocks do not count error

number

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct · line 1554

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-					 */
-					obj->err_data.ue_count +=

err_data.ue_count;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct · line 1555

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-					obj->err_data.ce_count +=

err_data.ce_count;

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -3
-				}
-			}
-		}
+		ras_interrupt_poison_creation_handler(obj, &entry);
  	}
  }
 
#8 lore raw

Please also keep the naming style consistent by using "amdgpu_ras" prefix

Regards,
Hawking

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, April 20, 2022 14:17
To: Lazar, Lijo <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: implement RAS interrupt handler for poison creation

[AMD Official Use Only]

Quoted 40 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, April 20, 2022 12:10 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: implement RAS interrupt handler for poison creation

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct

Quoted 13 lines · Tao Zhou

Prepare for the implementation of poison consumption handler.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 62 ++++++++++++++-----------
  1 file changed, 35 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 4bbed76b79c8..2d066cff70ea 100644
@@ -1515,12 +1515,44 @@ static int amdgpu_ras_fs_fini(struct

amdgpu_device *adev)

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
  /* ras fs end */
 
  /* ih begin */
+static void ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	struct ras_ih_data *data = &obj->ih_data;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	int ret;
+
+	if (!data->cb)
+		return;
+
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) · line 1532

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+	if (amdgpu_ras_is_poison_mode_supported(obj->adev) &&
+	    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+		dev_info(obj->adev->dev,
+			"Poison is created, no user action is needed.\n");
+	else {

It is confusing to handle RAS interrupts under poison_creation_handler in non- poison mode.

[Tao] will split it into ras_interrupt_poison_creation_handler and ras_interrupt_umc_handler.

Quoted 77 lines

Thanks,
Lijo

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +19 -2
+		/* Let IP handle its data, maybe we need get the output
+		 * from the callback to update the error type/count, etc
+		 */
+		ret = data->cb(obj->adev, &err_data, entry);
+		/* ue will trigger an interrupt, and in that case
+		 * we need do a reset to recovery the whole system.
+		 * But leave IP do that recovery, here we just dispatch
+		 * the error.
+		 */
+		if (ret == AMDGPU_RAS_SUCCESS) {
+			/* these counts could be left as 0 if
+			 * some blocks do not count error number
+			 */
+			obj->err_data.ue_count += err_data.ue_count;
+			obj->err_data.ce_count += err_data.ce_count;
+		}
+	}
+}
+
  static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
  {
  	struct ras_ih_data *data = &obj->ih_data;
  	struct amdgpu_iv_entry entry;
-	int ret;
-	struct ras_err_data err_data = {0, 0, 0, NULL};
 
  	while (data->rptr != data->wptr) {
  		rmb();
@@ -1531,31 +1563,7 @@ static void 
Quoted 1 line

amdgpu_ras_interrupt_handler(struct

ras_manager *obj)

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

Quoted 5 lines

data->rptr = (data->aligned_element_size +
data->rptr) % data->ring_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-		if (data->cb) {
-			if (amdgpu_ras_is_poison_mode_supported(obj->adev)

&&

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
-			    obj->head.block == AMDGPU_RAS_BLOCK__UMC)
-				dev_info(obj->adev->dev,
-						"Poison is created, no user

action is needed.\n");

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

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-			else {
-				/* Let IP handle its data, maybe we need get

the output

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

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-				 * from the callback to udpate the error

type/count, etc

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -5
-				 */
-				memset(&err_data, 0, sizeof(err_data));
-				ret = data->cb(obj->adev, &err_data, &entry);
-				/* ue will trigger an interrupt, and in that case
-				 * we need do a reset to recovery the whole

system.

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

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-				 * But leave IP do that recovery, here we just

dispatch

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -5
-				 * the error.
-				 */
-				if (ret == AMDGPU_RAS_SUCCESS) {
-					/* these counts could be left as 0 if
-					 * some blocks do not count error

number

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

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-					 */
-					obj->err_data.ue_count +=

err_data.ue_count;

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

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-					obj->err_data.ce_count +=

err_data.ce_count;

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -3
-				}
-			}
-		}
+		ras_interrupt_poison_creation_handler(obj, &entry);
  	}
  }