Skip to contentSkip to conversation

drm/amdgpu: add RAS poison creation handler (v2)

PATCH In review Tao Zhou 2 participants 6 messages Apr 20, 2022 – Apr 22, 2022

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/3 drm/amdgpu: add RAS poison creation handler (v2)

Prepare for the implementation of poison consumption handler.

v2: separate umc handler from poison creation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 70 ++++++++++++++++---------
 1 file changed, 44 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +44 -26
index 4bbed76b79c8..22477f76913a 100644
@@ -1515,12 +1515,45 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void amdgpu_ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+				struct amdgpu_iv_entry *entry)
+{
+	dev_info(obj->adev->dev,
+		"Poison is created, no user action is needed.\n");
+}
+
+static void amdgpu_ras_interrupt_umc_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;
+
+	/* 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,30 +1564,15 @@ 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;
-				}
-			}
+		if (amdgpu_ras_is_poison_mode_supported(obj->adev)) {
+			if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+				amdgpu_ras_interrupt_poison_creation_handler(obj, &entry);
+		} else {
+			if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+				amdgpu_ras_interrupt_umc_handler(obj, &entry);
+			else
+				dev_warn(obj->adev->dev,
+					"No RAS interrupt handler for non-UMC block with poison disabled.\n");
 		}
 	}
 }
Signature · 1 line
2.35.1
author
#1 lore raw

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

Add support for general RAS poison consumption handler.

v2: remove callback function for poison consumption.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 34 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  1 +
 2 files changed, 35 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +34 -0
index 22477f76913a..ad3b8560b2ca 100644
@@ -1515,6 +1515,38 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void amdgpu_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 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);
+
+	/* both query_poison_status and handle_poison_consumption are optional */
+	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 amdgpu_ras_interrupt_poison_creation_handler(struct ras_manager *obj,
 				struct amdgpu_iv_entry *entry)
 {
@@ -1567,6 +1599,8 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 		if (amdgpu_ras_is_poison_mode_supported(obj->adev)) {
 			if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
 				amdgpu_ras_interrupt_poison_creation_handler(obj, &entry);
+			else
+				amdgpu_ras_interrupt_poison_consumption_handler(obj, &entry);
 		} else {
 			if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
 				amdgpu_ras_interrupt_umc_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
author
#2 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 ad3b8560b2ca..eaf7fd0bd5d7 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 amdgpu_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
#3 lore raw
In reply to Tao Zhou

[AMD Official Use Only]

Hi Tao,

I was thinking more aggressive change - current amdgpu_ras_interrupt_handler only serves as umc poison (poison mode) or uncorrectable error handler (fue mode).

We can still keep it as a unified entry point, but how about check ip block first, then if it is umc, then check poison mode to decide poison creation handling or legacy uncorrectable error handling.

As discussed before, we'll optimize the poison creation handling later. so keeping poison_creation_handler and legacy umc ue handler in separated functions seems right direction to me.

Thoughts?

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Wednesday, April 20, 2022 19:30
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

Prepare for the implementation of poison consumption handler.

v2: separate umc handler from poison creation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 70 ++++++++++++++++---------
 1 file changed, 44 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +44 -26
index 4bbed76b79c8..22477f76913a 100644
@@ -1515,12 +1515,45 @@ static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void amdgpu_ras_interrupt_poison_creation_handler(struct ras_manager *obj,
+                               struct amdgpu_iv_entry *entry)
+{
+       dev_info(obj->adev->dev,
+               "Poison is created, no user action is needed.\n"); }
+
+static void amdgpu_ras_interrupt_umc_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;
+
+       /* 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,30 +1564,15 @@ 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;
-                               }
-                       }
+               if (amdgpu_ras_is_poison_mode_supported(obj->adev)) {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_poison_creation_handler(obj, &entry);
+               } else {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_umc_handler(obj, &entry);
+                       else
+                               dev_warn(obj->adev->dev,
+                                       "No RAS interrupt handler for non-UMC block with poison
+disabled.\n");
                }
        }

}
--
2.35.1

author
#4 lore raw

[AMD Official Use Only]

Hi Hawking,

The logic in my patch is:

if (poison)
if (umc)
poison_creation_handler
else
poison_consumption_handler
else
if (umc)
umc_handler
else
not supported

I think your suggestion is:

if (umc)
if (poison)
poison_creation_handler
else
umc_handler
else
if (poiosn)
poison_consumption_handler
else
not supported

Either way is OK for me, I don't think one approach is better than another.

Regards,
Tao

Quoted 147 lines

-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, April 21, 2022 10:54 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

[AMD Official Use Only]

Hi Tao,

I was thinking more aggressive change - current amdgpu_ras_interrupt_handler only serves as umc poison (poison mode) or uncorrectable error handler (fue mode).

We can still keep it as a unified entry point, but how about check ip block first, then if it is umc, then check poison mode to decide poison creation handling or legacy uncorrectable error handling.

As discussed before, we'll optimize the poison creation handling later. so keeping poison_creation_handler and legacy umc ue handler in separated functions seems right direction to me.

Thoughts?

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Wednesday, April 20, 2022 19:30
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

Prepare for the implementation of poison consumption handler.

v2: separate umc handler from poison creation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 70 ++++++++++++++++---------
 1 file changed, 44 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +42 -27
index 4bbed76b79c8..22477f76913a 100644
@@ -1515,12 +1515,45 @@ static int amdgpu_ras_fs_fini(struct
 amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void amdgpu_ras_interrupt_poison_creation_handler(struct
 ras_manager *obj,
+                               struct amdgpu_iv_entry *entry) {
+       dev_info(obj->adev->dev,
+               "Poison is created, no user action is needed.\n"); }
+
+static void amdgpu_ras_interrupt_umc_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;
+
+       /* 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,30 +1564,15 @@ 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;
-                               }
-                       }
+               if (amdgpu_ras_is_poison_mode_supported(obj->adev)) {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_poison_creation_handler(obj, &entry);
+               } else {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_umc_handler(obj, &entry);
+                       else
+                               dev_warn(obj->adev->dev,
+                                       "No RAS interrupt handler for
+non-UMC block with poison disabled.\n");
                }
        }
 }
--

2.35.1

Reviewed-by
#5 lore raw

Hi Tao,

I'm thinking of checking ip block first because we might want to leverage this interrupt handler as a common entry for other RAS interrupt as well. In such case, it looks more clearer if we check the ip block first.

I agree with you either way looks good.

You can have my RB for pushing the patches - We are always on the way to improve code quality.

The series is

Regards,
Hawking

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, April 22, 2022 12:04
To: Zhang, Hawking <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

[AMD Official Use Only]

Hi Hawking,

The logic in my patch is:

if (poison)
if (umc)
poison_creation_handler
else
poison_consumption_handler
else
if (umc)
umc_handler
else
not supported

I think your suggestion is:

if (umc)
if (poison)
poison_creation_handler
else
umc_handler
else
if (poiosn)
poison_consumption_handler
else
not supported

Either way is OK for me, I don't think one approach is better than another.

Regards,
Tao

Quoted 150 lines

-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, April 21, 2022 10:54 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

[AMD Official Use Only]

Hi Tao,

I was thinking more aggressive change - current amdgpu_ras_interrupt_handler only serves as umc poison (poison mode) or uncorrectable error handler (fue mode).

We can still keep it as a unified entry point, but how about check ip block first, then if it is umc, then check poison mode to decide poison creation handling or legacy uncorrectable error handling.

As discussed before, we'll optimize the poison creation handling later. so keeping poison_creation_handler and legacy umc ue handler in separated functions seems right direction to me.

Thoughts?

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Wednesday, April 20, 2022 19:30
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Ziya, Mohammad zafar <[email protected]>; Chai, Thomas <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: add RAS poison creation handler (v2)

Prepare for the implementation of poison consumption handler.

v2: separate umc handler from poison creation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 70 
++++++++++++++++---------
 1 file changed, 44 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +32 -2
index 4bbed76b79c8..22477f76913a 100644
@@ -1515,12 +1515,45 @@ static int amdgpu_ras_fs_fini(struct 
 amdgpu_device *adev)
 /* ras fs end */
 
 /* ih begin */
+static void amdgpu_ras_interrupt_poison_creation_handler(struct
 ras_manager *obj,
+                               struct amdgpu_iv_entry *entry) {
+       dev_info(obj->adev->dev,
+               "Poison is created, no user action is needed.\n"); }
+
+static void amdgpu_ras_interrupt_umc_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;
+
+       /* 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,30 +1564,15 @@ static void 

amdgpu_ras_interrupt_handler(struct
ras_manager *obj)

                data->rptr = (data->aligned_element_size +
                                data->rptr) % data->ring_size;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -25
-               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;
-                               }
-                       }
+               if (amdgpu_ras_is_poison_mode_supported(obj->adev)) {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_poison_creation_handler(obj, &entry);
+               } else {
+                       if (obj->head.block == AMDGPU_RAS_BLOCK__UMC)
+                               amdgpu_ras_interrupt_umc_handler(obj, &entry);
+                       else
+                               dev_warn(obj->adev->dev,
+                                       "No RAS interrupt handler for 
+non-UMC block with poison disabled.\n");
                }
        }
 }
--

2.35.1