Skip to contentSkip to conversation

drm/amdgpu: trigger flr_work if reading pf2vf data failed

PATCH In review Zhigang Luo 3 participants 3 messages Mar 14, 2024 – Mar 17, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: trigger flr_work if reading pf2vf data failed

if reading pf2vf data failed 5 times continuously, it means something is wrong. Need to trigger flr_work to recover the issue.

also use dev_err to print the error message to get which device has issue and add warning message if waiting IDH_FLR_NOTIFICATION_CMPL timeout.

Change-Id Ia7ce934d0c3068ad3934715c14bbffdfcbafc4c2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c   | 29 ++++++++++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c      |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c      |  2 ++
 5 files changed, 39 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -5
index 1e9454e6e4cb..9bb04a56d020 100644
@@ -143,6 +143,8 @@ const char *amdgpu_asic_name[] = {
 	"LAST",
 };
 
+static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev);
+
 /**
  * DOC: pcie_replay_count
  *
@@ -4972,6 +4974,8 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
 retry:
 	amdgpu_amdkfd_pre_reset(adev);
 
+	amdgpu_device_stop_pending_resets(adev);
+
 	if (from_hypervisor)
 		r = amdgpu_virt_request_full_gpu(adev, true);
 	else
@@ -5689,11 +5693,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 			tmp_adev->asic_reset_res = r;
 		}
 
-		/*
-		 * Drop all pending non scheduler resets. Scheduler resets
-		 * were already dropped during drm_sched_stop
-		 */
-		amdgpu_device_stop_pending_resets(tmp_adev);
+		if (!amdgpu_sriov_vf(tmp_adev))
+			/*
+			* Drop all pending non scheduler resets. Scheduler resets
+			* were already dropped during drm_sched_stop
+			*/
+			amdgpu_device_stop_pending_resets(tmp_adev);
 	}
 
 	/* Actual ASIC resets if needed.*/
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +24 -5
index 7a4eae36778a..4e8364a46d4e 100644
@@ -32,6 +32,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ras.h"
+#include "amdgpu_reset.h"
 #include "vi.h"
 #include "soc15.h"
 #include "nv.h"
@@ -424,7 +425,7 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 		return -EINVAL;
 
 	if (pf2vf_info->size > 1024) {
-		DRM_ERROR("invalid pf2vf message size\n");
+		dev_err(adev->dev, "invalid pf2vf message size: 0x%x\n", pf2vf_info->size);
 		return -EINVAL;
 	}
 
@@ -435,7 +436,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
 			adev->virt.fw_reserve.checksum_key, checksum);
 		if (checksum != checkval) {
-			DRM_ERROR("invalid pf2vf message\n");
+			dev_err(adev->dev,
+				"invalid pf2vf message: header checksum=0x%x calculated checksum=0x%x\n",
+				checksum, checkval);
 			return -EINVAL;
 		}
 
@@ -449,7 +452,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
 			0, checksum);
 		if (checksum != checkval) {
-			DRM_ERROR("invalid pf2vf message\n");
+			dev_err(adev->dev,
+				"invalid pf2vf message: header checksum=0x%x calculated checksum=0x%x\n",
+				checksum, checkval);
 			return -EINVAL;
 		}
 
@@ -485,7 +490,7 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
 		break;
 	default:
-		DRM_ERROR("invalid pf2vf version\n");
+		dev_err(adev->dev, "invalid pf2vf version: 0x%x\n", pf2vf_info->version);
 		return -EINVAL;
 	}
 
@@ -584,8 +589,21 @@ static void amdgpu_virt_update_vf2pf_work_item(struct work_struct *work)
 	int ret;
 
 	ret = amdgpu_virt_read_pf2vf_data(adev);
-	if (ret)
+	if (ret) {
+		adev->virt.vf2pf_update_retry_cnt++;
+		if ((adev->virt.vf2pf_update_retry_cnt >= 5) &&
+		    amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) {
+			if (amdgpu_reset_domain_schedule(adev->reset_domain,
+							  &adev->virt.flr_work))
+				return;
+			else
+				dev_err(adev->dev, "Failed to queue work! at %s", __func__);
+		}
+
 		goto out;
+	}
+
+	adev->virt.vf2pf_update_retry_cnt = 0;
 	amdgpu_virt_write_vf2pf_data(adev);
 
 out:
@@ -606,6 +624,7 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev)
 	adev->virt.fw_reserve.p_pf2vf = NULL;
 	adev->virt.fw_reserve.p_vf2pf = NULL;
 	adev->virt.vf2pf_update_interval_ms = 0;
+	adev->virt.vf2pf_update_retry_cnt = 0;
 
 	if (adev->mman.fw_vram_usage_va && adev->mman.drv_vram_usage_va) {
 		DRM_WARN("Currently fw_vram and drv_vram should not have values at the same time!");
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -0
index 3f59b7b5523f..eedf5d44bf00 100644
@@ -257,6 +257,7 @@ struct amdgpu_virt {
 	/* vf2pf message */
 	struct delayed_work vf2pf_work;
 	uint32_t vf2pf_update_interval_ms;
+	int vf2pf_update_retry_cnt;
 
 	/* multimedia bandwidth config */
 	bool     is_mm_bw_enabled;
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -0
index a2bd2c3b1ef9..0c7275bca8f7 100644
@@ -276,6 +276,8 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
 		timeout -= 10;
 	} while (timeout > 1);
 
+	dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL timeout\n");
+
 flr_done:
 	atomic_set(&adev->reset_domain->in_gpu_reset, 0);
 	up_write(&adev->reset_domain->sem);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -0
index 77f5b55decf9..ee9aa2815d5a 100644
@@ -309,6 +309,8 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
 		timeout -= 10;
 	} while (timeout > 1);
 
+	dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL timeout\n");
+
 flr_done:
 	atomic_set(&adev->reset_domain->in_gpu_reset, 0);
 	up_write(&adev->reset_domain->sem);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 46 lines · Zhigang Luo

if reading pf2vf data failed 5 times continuously, it means something is wrong. Need to trigger flr_work to recover the issue.

also use dev_err to print the error message to get which device has issue and add warning message if waiting IDH_FLR_NOTIFICATION_CMPL timeout.

Change-Id Ia7ce934d0c3068ad3934715c14bbffdfcbafc4c2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c   | 29 ++++++++++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c      |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c      |  2 ++
 5 files changed, 39 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -3
index 1e9454e6e4cb..9bb04a56d020 100644
@@ -143,6 +143,8 @@ const char *amdgpu_asic_name[] = {
 	"LAST",
 };
 
+static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev);
+
 /**
  * DOC: pcie_replay_count
  *
@@ -4972,6 +4974,8 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
 retry:
 	amdgpu_amdkfd_pre_reset(adev);
 
+	amdgpu_device_stop_pending_resets(adev);
+
 	if (from_hypervisor)
 		r = amdgpu_virt_request_full_gpu(adev, true);
 	else
@@ -5689,11 +5693,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 			tmp_adev->asic_reset_res = r;
 		}
 
-		/*
-		 * Drop all pending non scheduler resets. Scheduler resets
-		 * were already dropped during drm_sched_stop

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_gpu_recover(struct amdgpu_device *adev, · line 5703

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -2
-		 */
-		amdgpu_device_stop_pending_resets(tmp_adev);
+		if (!amdgpu_sriov_vf(tmp_adev))
+			/*
+			* Drop all pending non scheduler resets. Scheduler resets
+			* were already dropped during drm_sched_stop
+			*/
+			amdgpu_device_stop_pending_resets(tmp_adev);
 	}
 

For better consistency - you may make this path common for both VF and bare metal. Call this right before "skip_hw_reset" after a successful reset. All pending reset jobs submitted may be cancelled at that point once a succesful reset of the device/hive is completed.

Thanks,
Lijo

Quoted 122 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
 	/* Actual ASIC resets if needed.*/
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +24 -5
index 7a4eae36778a..4e8364a46d4e 100644
@@ -32,6 +32,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ras.h"
+#include "amdgpu_reset.h"
 #include "vi.h"
 #include "soc15.h"
 #include "nv.h"
@@ -424,7 +425,7 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 		return -EINVAL;
 
 	if (pf2vf_info->size > 1024) {
-		DRM_ERROR("invalid pf2vf message size\n");
+		dev_err(adev->dev, "invalid pf2vf message size: 0x%x\n", pf2vf_info->size);
 		return -EINVAL;
 	}
 
@@ -435,7 +436,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
 			adev->virt.fw_reserve.checksum_key, checksum);
 		if (checksum != checkval) {
-			DRM_ERROR("invalid pf2vf message\n");
+			dev_err(adev->dev,
+				"invalid pf2vf message: header checksum=0x%x calculated checksum=0x%x\n",
+				checksum, checkval);
 			return -EINVAL;
 		}
 
@@ -449,7 +452,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
 			0, checksum);
 		if (checksum != checkval) {
-			DRM_ERROR("invalid pf2vf message\n");
+			dev_err(adev->dev,
+				"invalid pf2vf message: header checksum=0x%x calculated checksum=0x%x\n",
+				checksum, checkval);
 			return -EINVAL;
 		}
 
@@ -485,7 +490,7 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)
 			((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
 		break;
 	default:
-		DRM_ERROR("invalid pf2vf version\n");
+		dev_err(adev->dev, "invalid pf2vf version: 0x%x\n", pf2vf_info->version);
 		return -EINVAL;
 	}
 
@@ -584,8 +589,21 @@ static void amdgpu_virt_update_vf2pf_work_item(struct work_struct *work)
 	int ret;
 
 	ret = amdgpu_virt_read_pf2vf_data(adev);
-	if (ret)
+	if (ret) {
+		adev->virt.vf2pf_update_retry_cnt++;
+		if ((adev->virt.vf2pf_update_retry_cnt >= 5) &&
+		    amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) {
+			if (amdgpu_reset_domain_schedule(adev->reset_domain,
+							  &adev->virt.flr_work))
+				return;
+			else
+				dev_err(adev->dev, "Failed to queue work! at %s", __func__);
+		}
+
 		goto out;
+	}
+
+	adev->virt.vf2pf_update_retry_cnt = 0;
 	amdgpu_virt_write_vf2pf_data(adev);
 
 out:
@@ -606,6 +624,7 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev)
 	adev->virt.fw_reserve.p_pf2vf = NULL;
 	adev->virt.fw_reserve.p_vf2pf = NULL;
 	adev->virt.vf2pf_update_interval_ms = 0;
+	adev->virt.vf2pf_update_retry_cnt = 0;
 
 	if (adev->mman.fw_vram_usage_va && adev->mman.drv_vram_usage_va) {
 		DRM_WARN("Currently fw_vram and drv_vram should not have values at the same time!");
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -0
index 3f59b7b5523f..eedf5d44bf00 100644
@@ -257,6 +257,7 @@ struct amdgpu_virt {
 	/* vf2pf message */
 	struct delayed_work vf2pf_work;
 	uint32_t vf2pf_update_interval_ms;
+	int vf2pf_update_retry_cnt;
 
 	/* multimedia bandwidth config */
 	bool     is_mm_bw_enabled;
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -0
index a2bd2c3b1ef9..0c7275bca8f7 100644
@@ -276,6 +276,8 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
 		timeout -= 10;
 	} while (timeout > 1);
 
+	dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL timeout\n");
+
 flr_done:
 	atomic_set(&adev->reset_domain->in_gpu_reset, 0);
 	up_write(&adev->reset_domain->sem);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -0
index 77f5b55decf9..ee9aa2815d5a 100644
@@ -309,6 +309,8 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
 		timeout -= 10;
 	} while (timeout > 1);
 
+	dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL timeout\n");
+
 flr_done:
 	atomic_set(&adev->reset_domain->in_gpu_reset, 0);
 	up_write(&adev->reset_domain->sem);
#2 lore raw

[AMD Official Use Only - General]

Quoted 146 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Friday, March 15, 2024 6:47 AM
To: Luo, Zhigang <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Saye, Sashank <[email protected]>; Chan, Hing Pong <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: trigger flr_work if reading pf2vf data failed

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 7 lines · Zhigang Luo

if reading pf2vf data failed 5 times continuously, it means something is wrong. Need to trigger flr_work to recover the issue.

also use dev_err to print the error message to get which device has issue and add warning message if waiting IDH_FLR_NOTIFICATION_CMPL timeout.

Quoted 5 lines
Change-Id Ia7ce934d0c3068ad3934715c14bbffdfcbafc4c2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c   | 29 ++++++++++++++++++-

---

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_gpu_recover(struct

Quoted 31 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c      |  2 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c      |  2 ++
 5 files changed, 39 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index 1e9454e6e4cb..9bb04a56d020 100644
@@ -143,6 +143,8 @@ const char *amdgpu_asic_name[] = {
      "LAST",
 };
 
+static inline void amdgpu_device_stop_pending_resets(struct
+amdgpu_device *adev);
+
 /**
  * DOC: pcie_replay_count
  *
@@ -4972,6 +4974,8 @@ static int amdgpu_device_reset_sriov(struct
 amdgpu_device *adev,
 retry:
      amdgpu_amdkfd_pre_reset(adev);
 
+     amdgpu_device_stop_pending_resets(adev);
+
      if (from_hypervisor)
              r = amdgpu_virt_request_full_gpu(adev, true);

else

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -5689,11 +5693,12 @@ int amdgpu_device_gpu_recover(struct

amdgpu_device *adev,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -3
                      tmp_adev->asic_reset_res = r;
              }
 
-             /*
-              * Drop all pending non scheduler resets. Scheduler resets
-              * were already dropped during drm_sched_stop

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_gpu_recover(struct amdgpu_device *adev, · line 5703

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -2
-              */
-             amdgpu_device_stop_pending_resets(tmp_adev);
+             if (!amdgpu_sriov_vf(tmp_adev))
+                     /*
+                     * Drop all pending non scheduler resets. Scheduler resets
+                     * were already dropped during drm_sched_stop
+                     */
+                     amdgpu_device_stop_pending_resets(tmp_adev);
      }
 

For better consistency - you may make this path common for both VF and bare metal. Call this right before "skip_hw_reset" after a successful reset. All pending reset jobs submitted may be cancelled at that point once a succesful reset of the device/hive is completed.

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static int amdgpu_virt_read_pf2vf_data(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
      /* Actual ASIC resets if needed.*/ diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 7a4eae36778a..4e8364a46d4e 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -0
@@ -32,6 +32,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ras.h"
+#include "amdgpu_reset.h"
 #include "vi.h"
 #include "soc15.h"
 #include "nv.h"
@@ -424,7 +425,7 @@ static int amdgpu_virt_read_pf2vf_data(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static int amdgpu_virt_read_pf2vf_data(struct

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
              return -EINVAL;
 
      if (pf2vf_info->size > 1024) {
-             DRM_ERROR("invalid pf2vf message size\n");
+             dev_err(adev->dev, "invalid pf2vf message size: 0x%x\n",
+ pf2vf_info->size);
              return -EINVAL;
      }
@@ -435,7 +436,9 @@ static int amdgpu_virt_read_pf2vf_data(struct

amdgpu_device *adev)

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
                      adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
                      adev->virt.fw_reserve.checksum_key, checksum);
              if (checksum != checkval) {
-                     DRM_ERROR("invalid pf2vf message\n");
+                     dev_err(adev->dev,
+                             "invalid pf2vf message: header checksum=0x%x calculated

checksum=0x%x\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static int amdgpu_virt_read_pf2vf_data(struct

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -0
+                             checksum, checkval);
                      return -EINVAL;
              }
 
@@ -449,7 +452,9 @@ static int amdgpu_virt_read_pf2vf_data(struct

amdgpu_device *adev)

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
                      adev->virt.fw_reserve.p_pf2vf, pf2vf_info->size,
                      0, checksum);
              if (checksum != checkval) {
-                     DRM_ERROR("invalid pf2vf message\n");
+                     dev_err(adev->dev,
+                             "invalid pf2vf message: header checksum=0x%x calculated

checksum=0x%x\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static int amdgpu_virt_read_pf2vf_data(struct

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -0
+                             checksum, checkval);
                      return -EINVAL;
              }
 
@@ -485,7 +490,7 @@ static int amdgpu_virt_read_pf2vf_data(struct

amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
                      ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
              break;
      default:
-             DRM_ERROR("invalid pf2vf version\n");
+             dev_err(adev->dev, "invalid pf2vf version: 0x%x\n",
+ pf2vf_info->version);
              return -EINVAL;
      }
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static void

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -0
@@ -584,8 +589,21 @@ static void

amdgpu_virt_update_vf2pf_work_item(struct work_struct *work)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
      int ret;
 
      ret = amdgpu_virt_read_pf2vf_data(adev);
-     if (ret)
+     if (ret) {
+             adev->virt.vf2pf_update_retry_cnt++;

Can we also add a debug print with retry_cnt value each time it's incremented?

Thanks,
Victor

Quoted 73 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static void amdgpu_virt_update_vf2pf_work_item(struct work_struct *work)

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +7 -0
+             if ((adev->virt.vf2pf_update_retry_cnt >= 5) &&
+                 amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) {
+                     if (amdgpu_reset_domain_schedule(adev->reset_domain,
+                                                       &adev->virt.flr_work))
+                             return;
+                     else
+                             dev_err(adev->dev, "Failed to queue work! at %s",

__func__);

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c void amdgpu_virt_init_data_exchange(struct

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5 -0
+             }
+
              goto out;
+     }
+
+     adev->virt.vf2pf_update_retry_cnt = 0;
      amdgpu_virt_write_vf2pf_data(adev);
 
 out:
@@ -606,6 +624,7 @@ void amdgpu_virt_init_data_exchange(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c static void xgpu_ai_mailbox_flr_work(struct

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -0
      adev->virt.fw_reserve.p_pf2vf = NULL;
      adev->virt.fw_reserve.p_vf2pf = NULL;
      adev->virt.vf2pf_update_interval_ms = 0;
+     adev->virt.vf2pf_update_retry_cnt = 0;
 
      if (adev->mman.fw_vram_usage_va && adev-
 mman.drv_vram_usage_va) {

DRM_WARN("Currently fw_vram and drv_vram should not have
values at the same time!"); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index 3f59b7b5523f..eedf5d44bf00 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -0
@@ -257,6 +257,7 @@ struct amdgpu_virt {
      /* vf2pf message */
      struct delayed_work vf2pf_work;
      uint32_t vf2pf_update_interval_ms;
+     int vf2pf_update_retry_cnt;
 
      /* multimedia bandwidth config */
      bool     is_mm_bw_enabled;
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +0 -0
index a2bd2c3b1ef9..0c7275bca8f7 100644
@@ -276,6 +276,8 @@ static void xgpu_ai_mailbox_flr_work(struct

work_struct *work)

drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c static void xgpu_nv_mailbox_flr_work(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +3 -0
              timeout -= 10;
      } while (timeout > 1);
 
+     dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL
+ timeout\n");
+
 flr_done:
      atomic_set(&adev->reset_domain->in_gpu_reset, 0);
      up_write(&adev->reset_domain->sem);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +0 -0
index 77f5b55decf9..ee9aa2815d5a 100644
@@ -309,6 +309,8 @@ static void xgpu_nv_mailbox_flr_work(struct

work_struct *work)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +3 -0
              timeout -= 10;
      } while (timeout > 1);
 
+     dev_warn(adev->dev, "waiting IDH_FLR_NOTIFICATION_CMPL
+ timeout\n");
+
 flr_done:
      atomic_set(&adev->reset_domain->in_gpu_reset, 0);
      up_write(&adev->reset_domain->sem);