Skip to contentSkip to conversation

drm/amdgpu: introduce vram lost paramter for reset function

PATCH In review Monk Liu 4 participants 10 messages Aug 23, 2019 – Aug 24, 2019 8 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: introduce vram lost paramter for reset function

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
 drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
 drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
 drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
 drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
 7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -2
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
 	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
 			     u32 sh_num, u32 reg_offset, u32 *value);
 	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
 	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
 	/* get the reference clock */
 	u32 (*get_xclk)(struct amdgpu_device *adev);
@@ -1136,7 +1136,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
  * ASICs macro.
  */
 #define amdgpu_asic_set_vga_state(adev, state) (adev)->asic_funcs->set_vga_state((adev), (state))
-#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))
+#define amdgpu_asic_reset(adev, lost) (adev)->asic_funcs->reset((adev), (lost))
 #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
 #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
 #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d))
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -5
index 02b3e7d..8668cb8 100644
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
 	struct amdgpu_device *adev =
 		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
 	if (adev->asic_reset_res)
 		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
 			 adev->asic_reset_res, adev->ddev->unique);
@@ -2751,7 +2751,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	 *  E.g., driver was not cleanly unloaded previously, etc.
 	 */
 	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
 		if (r) {
 			dev_err(adev->dev, "asic reset on init failed\n");
 			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
 	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
 		if (r)
 			DRM_ERROR("amdgpu asic reset failed\n");
 	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
 					r = -EALREADY;
 			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
 			if (r) {
 				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s",
@@ -3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 				if (r)
 					goto out;
 
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
 				if (vram_lost) {
 					DRM_INFO("VRAM is lost due to GPU reset!\n");
 					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +1 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
  * to reset them.
  * Returns 0 for success.
  */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool *vramlost)
 {
 	int r;
 
drivers/gpu/drm/amd/amdgpu/nv.c +7 -3
index a3d99f2..53de7a6 100644
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
 		return AMD_RESET_METHOD_MODE1;
 }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
 {
 
 	/* FIXME: it doesn't work since vega10 */
@@ -315,10 +315,14 @@ static int nv_asic_reset(struct amdgpu_device *adev)
 	int ret = 0;
 	struct smu_context *smu = &adev->smu;
 
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
 		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
 		ret = nv_asic_mode1_reset(adev);
+	}
 
 	return ret;
 }
drivers/gpu/drm/amd/amdgpu/si.c +1 -1
index 9043614..f324099 100644
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
 }
 
 //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
 {
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/soc15.c +3 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
 		return AMD_RESET_METHOD_MODE1;
 }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool *vramlost)
 {
 	switch (soc15_asic_reset_method(adev)) {
 		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
 			return soc15_asic_baco_reset(adev);
 		case AMD_RESET_METHOD_MODE2:
 			return soc15_mode2_reset(adev);
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
index 56c882b..8eceb00 100644
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
  * to reset them.
  * Returns 0 for success.
  */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
 {
 	int r;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1566531249-1396-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 164 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
  drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
  drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
  drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
  drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
  drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
  7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -2
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
  	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
  			     u32 sh_num, u32 reg_offset, u32 *value);
  	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
  	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
  	/* get the reference clock */
  	u32 (*get_xclk)(struct amdgpu_device *adev);
@@ -1136,7 +1136,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
   * ASICs macro.
   */
  #define amdgpu_asic_set_vga_state(adev, state) (adev)->asic_funcs->set_vga_state((adev), (state))
-#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))
+#define amdgpu_asic_reset(adev, lost) (adev)->asic_funcs->reset((adev), (lost))
  #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
  #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
  #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d))
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -5
index 02b3e7d..8668cb8 100644
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
  	struct amdgpu_device *adev =
  		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
  	if (adev->asic_reset_res)
  		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
  			 adev->asic_reset_res, adev->ddev->unique);
@@ -2751,7 +2751,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  	 *  E.g., driver was not cleanly unloaded previously, etc.
  	 */
  	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
  		if (r) {
  			dev_err(adev->dev, "asic reset on init failed\n");
  			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
  		pci_disable_device(dev->pdev);
  		pci_set_power_state(dev->pdev, PCI_D3hot);
  	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
  		if (r)
  			DRM_ERROR("amdgpu asic reset failed\n");
  	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
  				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
  					r = -EALREADY;
  			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
  			if (r) {
  				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s",
@@ -3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
  				if (r)
  					goto out;
 
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
  				if (vram_lost) {
  					DRM_INFO("VRAM is lost due to GPU reset!\n");
  					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +1 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
   * to reset them.
   * Returns 0 for success.
   */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	int r;
 
drivers/gpu/drm/amd/amdgpu/nv.c +7 -3
index a3d99f2..53de7a6 100644
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
  		return AMD_RESET_METHOD_MODE1;
  }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
 
  	/* FIXME: it doesn't work since vega10 */
@@ -315,10 +315,14 @@ static int nv_asic_reset(struct amdgpu_device *adev)
  	int ret = 0;
  	struct smu_context *smu = &adev->smu;
 
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
  		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
  		ret = nv_asic_mode1_reset(adev);
+	}
 
  	return ret;
  }
drivers/gpu/drm/amd/amdgpu/si.c +1 -1
index 9043614..f324099 100644
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
  }
 
  //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/soc15.c +3 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
  		return AMD_RESET_METHOD_MODE1;
  }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	switch (soc15_asic_reset_method(adev)) {
  		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
  			return soc15_asic_baco_reset(adev);
  		case AMD_RESET_METHOD_MODE2:
  			return soc15_mode2_reset(adev);
drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
   * to reset them.
   * Returns 0 for success.
   */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	int r;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 15d22497-cf4d-0d15-236c-5bc2b65eb656-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate
_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 172 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
  drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
  drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
  drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
  drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
  drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
  7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
  	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
  			     u32 sh_num, u32 reg_offset, u32 *value);
  	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
  	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
  	/* get the reference clock */
  	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7 @@ 

int emu_soc_asic_init(struct amdgpu_device *adev);
* ASICs macro.
*/
#define amdgpu_asic_set_vga_state(adev, state)
(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost) 
+(adev)->asic_funcs->reset((adev), (lost))
  #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
  #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
  #define amdgpu_asic_set_uvd_clocks(adev, v, d) 

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
  	struct amdgpu_device *adev =
  		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
  	if (adev->asic_reset_res)
  		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
  			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7 @@ 

int amdgpu_device_init(struct amdgpu_device *adev,
* E.g., driver was not cleanly unloaded previously, etc. */
if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -5
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
  		if (r) {
  			dev_err(adev->dev, "asic reset on init failed\n");
  			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
  		pci_disable_device(dev->pdev);
  		pci_set_power_state(dev->pdev, PCI_D3hot);
  	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
  		if (r)
  			DRM_ERROR("amdgpu asic reset failed\n");
  	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
  				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
  					r = -EALREADY;
  			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
  			if (r) {
  				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s", @@ 
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
  				if (r)
  					goto out;
 
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
  				if (vram_lost) {
  					DRM_INFO("VRAM is lost due to GPU reset!\n");
  					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +1 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
   * to reset them.
   * Returns 0 for success.
   */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	int r;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
  		return AMD_RESET_METHOD_MODE1;
  }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
 
  	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@ 

static int nv_asic_reset(struct amdgpu_device *adev)
int ret = 0;
struct smu_context *smu = &adev->smu;

drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
  		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
  		ret = nv_asic_mode1_reset(adev);
+	}
 
  	return ret;
  }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
  }
 
  //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
  		return AMD_RESET_METHOD_MODE1;
  }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool 
+*vramlost)
  {
  	switch (soc15_asic_reset_method(adev)) {
  		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
  			return soc15_asic_baco_reset(adev);
  		case AMD_RESET_METHOD_MODE2:
  			return soc15_mode2_reset(adev);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
   * to reset them.
   * Returns 0 for success.
   */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
  {
  	int r;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB393366D270445A63B053DA3184A40-rweVpJHSKTq/[email protected]

#6 lore raw

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 204 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate
_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 171 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
   drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
   drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
   drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
   drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
   drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
   7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
   	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
   			     u32 sh_num, u32 reg_offset, u32 *value);
   	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
   	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
   	/* get the reference clock */
   	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7 @@

int emu_soc_asic_init(struct amdgpu_device *adev);
* ASICs macro.
*/
#define amdgpu_asic_set_vga_state(adev, state)
(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost)
+(adev)->asic_funcs->reset((adev), (lost))
   #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
   #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
   #define amdgpu_asic_set_uvd_clocks(adev, v, d)

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
   	struct amdgpu_device *adev =
   		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
   	if (adev->asic_reset_res)
   		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
   			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7 @@

int amdgpu_device_init(struct amdgpu_device *adev,
* E.g., driver was not cleanly unloaded previously, etc. */
if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -5
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
   		if (r) {
   			dev_err(adev->dev, "asic reset on init failed\n");
   			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
   		pci_disable_device(dev->pdev);
   		pci_set_power_state(dev->pdev, PCI_D3hot);
   	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
   		if (r)
   			DRM_ERROR("amdgpu asic reset failed\n");
   	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
   				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
   					r = -EALREADY;
   			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
   			if (r) {
   				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s", @@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
   				if (r)
   					goto out;
 
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
   				if (vram_lost) {
   					DRM_INFO("VRAM is lost due to GPU reset!\n");
   					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +1 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
    * to reset them.
    * Returns 0 for success.
    */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
   	int r;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
   		return AMD_RESET_METHOD_MODE1;
   }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
 
   	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@

static int nv_asic_reset(struct amdgpu_device *adev)

   	int ret = 0;
   	struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
   		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
   		ret = nv_asic_mode1_reset(adev);
+	}
 
   	return ret;
   }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
   }
 
   //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
   	return 0;
   }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
   		return AMD_RESET_METHOD_MODE1;
   }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
   {
   	switch (soc15_asic_reset_method(adev)) {
   		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
   			return soc15_asic_baco_reset(adev);
   		case AMD_RESET_METHOD_MODE2:
   			return soc15_mode2_reset(adev);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
    * to reset them.
    * Returns 0 for success.
    */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
   	int r;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 82e98a1b-a624-1e54-aae7-1a6ff9dda7f2-5C7GfCeVMHo@public.gmane.org

author
#8 lore raw
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
   				if (vram_lost) {
   					DRM_INFO("VRAM is lost due to GPU reset!\n");
   					atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially
Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?
_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 208 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 173 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
   drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
   drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
   drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
   drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
   drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
   7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
   	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
   			     u32 sh_num, u32 reg_offset, u32 *value);
   	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
   	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
   	/* get the reference clock */
   	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7 

@@ int emu_soc_asic_init(struct amdgpu_device *adev);
* ASICs macro.
*/
#define amdgpu_asic_set_vga_state(adev, state)
(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost) 
+(adev)->asic_funcs->reset((adev), (lost))
   #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
   #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
   #define amdgpu_asic_set_uvd_clocks(adev, v, d) 

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
   	struct amdgpu_device *adev =
   		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
   	if (adev->asic_reset_res)
   		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
   			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7 

@@ int amdgpu_device_init(struct amdgpu_device *adev,
* E.g., driver was not cleanly unloaded previously, etc. */
if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
   		if (r) {
   			dev_err(adev->dev, "asic reset on init failed\n");
   			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
   		pci_disable_device(dev->pdev);
   		pci_set_power_state(dev->pdev, PCI_D3hot);
   	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
   		if (r)
   			DRM_ERROR("amdgpu asic reset failed\n");
   	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
   				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
   					r = -EALREADY;
   			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
   			if (r) {
   				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s", 

@@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
if (r)
goto out;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
   				if (vram_lost) {
   					DRM_INFO("VRAM is lost due to GPU reset!\n");
   					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
    * to reset them.
    * Returns 0 for success.
    */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool 
+*vramlost)
   {
   	int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
   		return AMD_RESET_METHOD_MODE1;
   }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
 
   	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@ 

static int nv_asic_reset(struct amdgpu_device *adev)

   	int ret = 0;
   	struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
   		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
   		ret = nv_asic_mode1_reset(adev);
+	}
 
   	return ret;
   }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
   }
 
   //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
   	return 0;
   }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
   		return AMD_RESET_METHOD_MODE1;
   }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
   {
   	switch (soc15_asic_reset_method(adev)) {
   		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
   			return soc15_asic_baco_reset(adev);
   		case AMD_RESET_METHOD_MODE2:
   			return soc15_mode2_reset(adev); diff --git 

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
    * to reset them.
    * Returns 0 for success.
    */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
   {
   	int r;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB393324F969E3F29F76A0DA8384A40-rweVpJHSKTq/[email protected]

#10 lore raw

Am 23.08.19 um 10:57 schrieb Liu, Monk:

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
    				if (vram_lost) {
    					DRM_INFO("VRAM is lost due to GPU reset!\n");
    					atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially
Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Yeah, but would increment it twice be a problem? I don't think so.

Quoted 1 line

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

Christian.

Quoted 225 lines

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 208 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 173 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
    drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
    drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
    drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
    drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
    drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
    7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
    	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
    			     u32 sh_num, u32 reg_offset, u32 *value);
    	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
    	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
    	/* get the reference clock */
    	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7
@@ int emu_soc_asic_init(struct amdgpu_device *adev);
     * ASICs macro.
     */
    #define amdgpu_asic_set_vga_state(adev, state)

(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost)
+(adev)->asic_funcs->reset((adev), (lost))
    #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
    #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
    #define amdgpu_asic_set_uvd_clocks(adev, v, d)

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
    	struct amdgpu_device *adev =
    		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
    	if (adev->asic_reset_res)
    		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
    			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7

@@ int amdgpu_device_init(struct amdgpu_device *adev,

    	 *  E.g., driver was not cleanly unloaded previously, etc.
    	 */
    	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
    		if (r) {
    			dev_err(adev->dev, "asic reset on init failed\n");
    			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
    		pci_disable_device(dev->pdev);
    		pci_set_power_state(dev->pdev, PCI_D3hot);
    	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
    		if (r)
    			DRM_ERROR("amdgpu asic reset failed\n");
    	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
    				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
    					r = -EALREADY;
    			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
    			if (r) {
    				DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s",

@@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

    				if (r)
    					goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
    				if (vram_lost) {
    					DRM_INFO("VRAM is lost due to GPU reset!\n");
    					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
     * to reset them.
     * Returns 0 for success.
     */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
    	int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
    		return AMD_RESET_METHOD_MODE1;
    }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
 
    	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@

static int nv_asic_reset(struct amdgpu_device *adev)

    	int ret = 0;
    	struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
    		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
    		ret = nv_asic_mode1_reset(adev);
+	}
 
    	return ret;
    }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
    }
 
    //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
    	return 0;
    }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
    		return AMD_RESET_METHOD_MODE1;
    }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
    	switch (soc15_asic_reset_method(adev)) {
    		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
    			return soc15_asic_baco_reset(adev);
    		case AMD_RESET_METHOD_MODE2:
    			return soc15_mode2_reset(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
     * to reset them.
     * Returns 0 for success.
     */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
    	int r;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 3920ef0e-857a-44ff-085e-e121c39e0420-5C7GfCeVMHo@public.gmane.org

#12 lore raw

for mode1 and BACO, I think we can assume vram is lost because the UMC gets reset in that case. Some of the data may still look valid, but it's not necessarily reliable. For mode2, vram should be fine because the UMC doesn't get reset.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 8:47 AM
To: Liu, Monk <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 10:57 schrieb Liu, Monk:

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
                             if (vram_lost) {
                                     DRM_INFO("VRAM is lost due to GPU reset!\n");
                                     atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially
Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Yeah, but would increment it twice be a problem? I don't think so.

Quoted 1 line

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

Christian.

Quoted 225 lines

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 208 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for
reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 173 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
    drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
    drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
    drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
    drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
    drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
    7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
     int (*read_register)(struct amdgpu_device *adev, u32 se_num,
                          u32 sh_num, u32 reg_offset, u32 *value);
     void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-   int (*reset)(struct amdgpu_device *adev);
+   int (*reset)(struct amdgpu_device *adev, bool *lost);
     enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
     /* get the reference clock */
     u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7
@@ int emu_soc_asic_init(struct amdgpu_device *adev);
     * ASICs macro.
     */
    #define amdgpu_asic_set_vga_state(adev, state)

(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost)
+(adev)->asic_funcs->reset((adev), (lost))
    #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
    #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
    #define amdgpu_asic_set_uvd_clocks(adev, v, d)

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
     struct amdgpu_device *adev =
             container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-   adev->asic_reset_res =  amdgpu_asic_reset(adev);
+   adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
     if (adev->asic_reset_res)
             DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
                      adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7

@@ int amdgpu_device_init(struct amdgpu_device *adev,

      *  E.g., driver was not cleanly unloaded previously, etc.
      */
     if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
-           r = amdgpu_asic_reset(adev);
+           r = amdgpu_asic_reset(adev, NULL);
             if (r) {
                     dev_err(adev->dev, "asic reset on init failed\n");
                     goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
             pci_disable_device(dev->pdev);
             pci_set_power_state(dev->pdev, PCI_D3hot);
     } else {
-           r = amdgpu_asic_reset(adev);
+           r = amdgpu_asic_reset(adev, NULL);
             if (r)
                     DRM_ERROR("amdgpu asic reset failed\n");
     }
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
                             if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
                                     r = -EALREADY;
                     } else
-                           r = amdgpu_asic_reset(tmp_adev);
+                           r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
                     if (r) {
                             DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s",

@@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

                             if (r)
                                     goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-                           vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+                           if (!vram_lost)
+                                   vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
                             if (vram_lost) {
                                     DRM_INFO("VRAM is lost due to GPU reset!\n");
                                     atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
     * to reset them.
     * Returns 0 for success.
     */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
     int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
             return AMD_RESET_METHOD_MODE1;
    }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
 
     /* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@

static int nv_asic_reset(struct amdgpu_device *adev)

     int ret = 0;
     struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-   if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+   if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+           if (vramlost)
+                   *vramlost = true;
             ret = smu_baco_reset(smu);
-   else
+   }
+   else {
             ret = nv_asic_mode1_reset(adev);
+   }
 
     return ret;
    }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
    }
 
    //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
     return 0;
    }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
             return AMD_RESET_METHOD_MODE1;
    }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
     switch (soc15_asic_reset_method(adev)) {
             case AMD_RESET_METHOD_BACO:
+                   if (vramlost)
+                           *vramlost = true;
                     return soc15_asic_baco_reset(adev);
             case AMD_RESET_METHOD_MODE2:
                     return soc15_mode2_reset(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
     * to reset them.
     * Returns 0 for success.
     */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
     int r;
 

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1809D6CB333C3A473C71F2FCF7A40-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author
#14 lore raw

Thanks Alex

That sounds correct to me, mode1 rest once do clear the vram data on vega10

_____________________________________
Monk Liu|GPU Virtualization Team |AMD
[sig-cloud-gpu]

From: Deucher, Alexander <[email protected]>
Sent: Friday, August 23, 2019 10:34 PM
To: Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

for mode1 and BACO, I think we can assume vram is lost because the UMC gets reset in that case. Some of the data may still look valid, but it's not necessarily reliable. For mode2, vram should be fine because the UMC doesn't get reset.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Koenig, Christian <[email protected]<mailto:[email protected]>>
Sent: Friday, August 23, 2019 8:47 AM
To: Liu, Monk <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <amd-gfx-PD4FTy7X32lzq7FAFJ/[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 10:57 schrieb Liu, Monk:

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
                             if (vram_lost) {
                                     DRM_INFO("VRAM is lost due to GPU reset!\n");
                                     atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially
Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Yeah, but would increment it twice be a problem? I don't think so.

Quoted 1 line

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

Christian.

Quoted 225 lines

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]<mailto:[email protected]>>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 208 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]<mailto:[email protected]>>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for
reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 173 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
    drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
    drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
    drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
    drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
    drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
    7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
     int (*read_register)(struct amdgpu_device *adev, u32 se_num,
                          u32 sh_num, u32 reg_offset, u32 *value);
     void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-   int (*reset)(struct amdgpu_device *adev);
+   int (*reset)(struct amdgpu_device *adev, bool *lost);
     enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
     /* get the reference clock */
     u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7
@@ int emu_soc_asic_init(struct amdgpu_device *adev);
     * ASICs macro.
     */
    #define amdgpu_asic_set_vga_state(adev, state)

(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost)
+(adev)->asic_funcs->reset((adev), (lost))
    #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
    #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
    #define amdgpu_asic_set_uvd_clocks(adev, v, d)

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
     struct amdgpu_device *adev =
             container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-   adev->asic_reset_res =  amdgpu_asic_reset(adev);
+   adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
     if (adev->asic_reset_res)
             DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
                      adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 +2751,7

@@ int amdgpu_device_init(struct amdgpu_device *adev,

      *  E.g., driver was not cleanly unloaded previously, etc.
      */
     if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
-           r = amdgpu_asic_reset(adev);
+           r = amdgpu_asic_reset(adev, NULL);
             if (r) {
                     dev_err(adev->dev, "asic reset on init failed\n");
                     goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
             pci_disable_device(dev->pdev);
             pci_set_power_state(dev->pdev, PCI_D3hot);
     } else {
-           r = amdgpu_asic_reset(adev);
+           r = amdgpu_asic_reset(adev, NULL);
             if (r)
                     DRM_ERROR("amdgpu asic reset failed\n");
     }
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
                             if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
                                     r = -EALREADY;
                     } else
-                           r = amdgpu_asic_reset(tmp_adev);
+                           r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
                     if (r) {
                             DRM_ERROR("ASIC reset failed with error, %d for drm dev, %s",

@@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

                             if (r)
                                     goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-                           vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+                           if (!vram_lost)
+                                   vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
                             if (vram_lost) {
                                     DRM_INFO("VRAM is lost due to GPU reset!\n");
                                     atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
     * to reset them.
     * Returns 0 for success.
     */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
     int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +1 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
             return AMD_RESET_METHOD_MODE1;
    }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
 
     /* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@

static int nv_asic_reset(struct amdgpu_device *adev)

     int ret = 0;
     struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-   if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+   if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+           if (vramlost)
+                   *vramlost = true;
             ret = smu_baco_reset(smu);
-   else
+   }
+   else {
             ret = nv_asic_mode1_reset(adev);
+   }
 
     return ret;
    }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +1 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
    }
 
    //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
     return 0;
    }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
             return AMD_RESET_METHOD_MODE1;
    }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
     switch (soc15_asic_reset_method(adev)) {
             case AMD_RESET_METHOD_BACO:
+                   if (vramlost)
+                           *vramlost = true;
                     return soc15_asic_baco_reset(adev);
             case AMD_RESET_METHOD_MODE2:
                     return soc15_mode2_reset(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
     * to reset them.
     * Returns 0 for success.
     */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool *vramlost)
    {
     int r;
 

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#15 lore raw
In reply to a message not in the archive
Quoted 1 line
Quoted 1 line

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

The reason is with BACO reset I found VRAM lost in high address e.g. 15~16 G (for 16 G vega10), amdgpu_device_check_vram_lost only checks the very ahead visible part

Quoted 1 line
Quoted 1 line

Yeah, but would increment it twice be a problem? I don't think so.

So your suggestion is we increase the counter in BACO reset , and no need to introduce the new "bool *" parameter, right ?
_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 8:47 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 10:57 schrieb Liu, Monk:

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
    				if (vram_lost) {
    					DRM_INFO("VRAM is lost due to GPU reset!\n");
    					atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Yeah, but would increment it twice be a problem? I don't think so.

Quoted 1 line

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

Christian.

Quoted 229 lines

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 211 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 176 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
    drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
    drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
    drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
    drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
    drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
    7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
    	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
    			     u32 sh_num, u32 reg_offset, u32 *value);
    	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
    	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
    	/* get the reference clock */
    	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7 
@@ int emu_soc_asic_init(struct amdgpu_device *adev);
     * ASICs macro.
     */
    #define amdgpu_asic_set_vga_state(adev, state) 

(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost) 
+(adev)->asic_funcs->reset((adev), (lost))
    #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
    #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
    #define amdgpu_asic_set_uvd_clocks(adev, v, d) 

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -4
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
    	struct amdgpu_device *adev =
    		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
    	if (adev->asic_reset_res)
    		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
    			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7 
+2751,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
    	 *  E.g., driver was not cleanly unloaded previously, etc.
    	 */
    	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
    		if (r) {
    			dev_err(adev->dev, "asic reset on init failed\n");
    			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
    		pci_disable_device(dev->pdev);
    		pci_set_power_state(dev->pdev, PCI_D3hot);
    	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
    		if (r)
    			DRM_ERROR("amdgpu asic reset failed\n");
    	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
    				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
    					r = -EALREADY;
    			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
    			if (r) {
    				DRM_ERROR("ASIC reset failed with error, %d for drm dev, 

%s", @@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

    				if (r)
    					goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
    				if (vram_lost) {
    					DRM_INFO("VRAM is lost due to GPU reset!\n");
    					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
     * to reset them.
     * Returns 0 for success.
     */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
    	int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +2 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
    		return AMD_RESET_METHOD_MODE1;
    }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool 
+*vramlost)
    {
 
    	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@ 

static int nv_asic_reset(struct amdgpu_device *adev)

    	int ret = 0;
    	struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
    		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
    		ret = nv_asic_mode1_reset(adev);
+	}
 
    	return ret;
    }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +2 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
    }
 
    //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool 
+*vramlost)
    {
    	return 0;
    }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
    		return AMD_RESET_METHOD_MODE1;
    }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
    {
    	switch (soc15_asic_reset_method(adev)) {
    		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
    			return soc15_asic_baco_reset(adev);
    		case AMD_RESET_METHOD_MODE2:
    			return soc15_mode2_reset(adev); diff --git 

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
     * to reset them.
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2 -1
     * Returns 0 for success.
     */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool 
+*vramlost)
    {
    	int r;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3933AC07ADDAEE39DD64608A84A40-rweVpJHSKTq/[email protected]

#17 lore raw
Quoted 1 line

So your suggestion is we increase the counter in BACO reset , and no need to introduce the new "bool *" parameter, right ?

Correct, yes.

Cleanest way looks like adding some helper function like amdgpu_device_vram_lost(adev) which is called by the BACO reset code.

Christian.

Am 23.08.19 um 16:35 schrieb Liu, Monk:

Quoted 264 lines
Quoted 1 line
Quoted 1 line

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

The reason is with BACO reset I found VRAM lost in high address e.g. 15~16 G (for 16 G vega10), amdgpu_device_check_vram_lost only checks the very ahead visible part

Quoted 1 line
Quoted 1 line

Yeah, but would increment it twice be a problem? I don't think so.

So your suggestion is we increase the counter in BACO reset , and no need to introduce the new "bool *" parameter, right ?
_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 8:47 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 10:57 schrieb Liu, Monk:

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
     				if (vram_lost) {
     					DRM_INFO("VRAM is lost due to GPU reset!\n");
     					atomic_inc(&tmp_adev->vram_lost_counter);

Above is the original logic, if we increment the counter in BACO reset routine, we would potentially Have another counter increasement if by coincidence the "amdgpu_device_check_vram_lost" successfully detected the vram lost (although right now it didn't ..)

Yeah, but would increment it twice be a problem? I don't think so.

Quoted 1 line

Do you mean we remove the amdgpu_device_check_vram_lost(tmp_adev) in device_recovery() routine ?

Please no, that thing certainly proved to be useful. Maybe we could investigate why it failed to auto detect the lost VRAM.

Christian.

Quoted 233 lines

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, August 23, 2019 4:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

I thought in the BACO reset function.

The top level reset function doesn't do much more than increment the vram_lost_counter either.

Christian.

Am 23.08.19 um 10:32 schrieb Liu, Monk:

Quoted 215 lines
Quoted 1 line
Quoted 1 line

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

In where ? if you mean in amdgpu_device_recover routine I won't do that since the reset() can do any kind of reset like:
1) PF FLR
2) mode1/2 reset
3) magic reset through config space
4) BACO reset

PF FLR won't cause VRAM lost, mode_1/2 is not clear to me, only BACO reset is definitely a vram lost reset

If you increase the counter in general function that will be not accurate _____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, August 23, 2019 4:27 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: introduce vram lost paramter for reset function

Am 23.08.19 um 05:34 schrieb Monk Liu:

Quoted 6 lines

for SOC15/vega10 the BACO reset would introduce vram lost in the high end address range and current kmd's vram lost checking cannot catch it since it only check visible frame buffer

TODO:
to confirm if mode1/2 reset would introduce vram lost

Looks good in general, but I would make the value mandatory or maybe use a special return code instead.

On the other hand wouldn't it be simpler to just increment vram_lost_counter?

Christian.

Quoted 180 lines
---
     drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
     drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++-----
     drivers/gpu/drm/amd/amdgpu/cik.c           |  2 +-
     drivers/gpu/drm/amd/amdgpu/nv.c            | 10 +++++++---
     drivers/gpu/drm/amd/amdgpu/si.c            |  2 +-
     drivers/gpu/drm/amd/amdgpu/soc15.c         |  4 +++-
     drivers/gpu/drm/amd/amdgpu/vi.c            |  2 +-
     7 files changed, 22 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index f6ae565..1fe3756 100644
@@ -552,7 +552,7 @@ struct amdgpu_asic_funcs {
     	int (*read_register)(struct amdgpu_device *adev, u32 se_num,
     			     u32 sh_num, u32 reg_offset, u32 *value);
     	void (*set_vga_state)(struct amdgpu_device *adev, bool state);
-	int (*reset)(struct amdgpu_device *adev);
+	int (*reset)(struct amdgpu_device *adev, bool *lost);
     	enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);
     	/* get the reference clock */
     	u32 (*get_xclk)(struct amdgpu_device *adev); @@ -1136,7 +1136,7
@@ int emu_soc_asic_init(struct amdgpu_device *adev);
      * ASICs macro.
      */
     #define amdgpu_asic_set_vga_state(adev, state)

(adev)->asic_funcs->set_vga_state((adev), (state)) -#define amdgpu_asic_reset(adev) (adev)->asic_funcs->reset((adev))

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+#define amdgpu_asic_reset(adev, lost)
+(adev)->asic_funcs->reset((adev), (lost))
     #define amdgpu_asic_reset_method(adev) (adev)->asic_funcs->reset_method((adev))
     #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev))
     #define amdgpu_asic_set_uvd_clocks(adev, v, d)

(adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02b3e7d..8668cb8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -4
@@ -2546,7 +2546,7 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
     	struct amdgpu_device *adev =
     		container_of(__work, struct amdgpu_device, xgmi_reset_work);
 
-	adev->asic_reset_res =  amdgpu_asic_reset(adev);
+	adev->asic_reset_res =  amdgpu_asic_reset(adev, NULL);
     	if (adev->asic_reset_res)
     		DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
     			 adev->asic_reset_res, adev->ddev->unique); @@ -2751,7
+2751,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
     	 *  E.g., driver was not cleanly unloaded previously, etc.
     	 */
     	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
     		if (r) {
     			dev_err(adev->dev, "asic reset on init failed\n");
     			goto failed;
@@ -3084,7 +3084,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
     		pci_disable_device(dev->pdev);
     		pci_set_power_state(dev->pdev, PCI_D3hot);
     	} else {
-		r = amdgpu_asic_reset(adev);
+		r = amdgpu_asic_reset(adev, NULL);
     		if (r)
     			DRM_ERROR("amdgpu asic reset failed\n");
     	}
@@ -3604,7 +3604,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
     				if (!queue_work(system_highpri_wq, &tmp_adev->xgmi_reset_work))
     					r = -EALREADY;
     			} else
-				r = amdgpu_asic_reset(tmp_adev);
+				r = amdgpu_asic_reset(tmp_adev, &vram_lost);
 
     			if (r) {
     				DRM_ERROR("ASIC reset failed with error, %d for drm dev,

%s", @@
-3645,7 +3645,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

     				if (r)
     					goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
-				vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+				if (!vram_lost)
+					vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
+
     				if (vram_lost) {
     					DRM_INFO("VRAM is lost due to GPU reset!\n");
     					atomic_inc(&tmp_adev->vram_lost_counter);
drivers/gpu/drm/amd/amdgpu/cik.c +2 -1
index 7b63d7a..0f25b82 100644
@@ -1277,7 +1277,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
      * to reset them.
      * Returns 0 for success.
      */
-static int cik_asic_reset(struct amdgpu_device *adev)
+static int cik_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
     {
     	int r;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/nv.c index a3d99f2..53de7a6 100644

drivers/gpu/drm/amd/amdgpu/nv.c +2 -1
@@ -301,7 +301,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
     		return AMD_RESET_METHOD_MODE1;
     }
 
-static int nv_asic_reset(struct amdgpu_device *adev)
+static int nv_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
     {
 
     	/* FIXME: it doesn't work since vega10 */ @@ -315,10 +315,14 @@

static int nv_asic_reset(struct amdgpu_device *adev)

     	int ret = 0;
     	struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/amdgpu/nv.c +6 -2
-	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
+	if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+		if (vramlost)
+			*vramlost = true;
     		ret = smu_baco_reset(smu);
-	else
+	}
+	else {
     		ret = nv_asic_mode1_reset(adev);
+	}
 
     	return ret;
     }
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/si.c index 9043614..f324099 100644

drivers/gpu/drm/amd/amdgpu/si.c +2 -1
@@ -1180,7 +1180,7 @@ static bool si_read_bios_from_rom(struct amdgpu_device *adev,
     }
 
     //xxx: not implemented
-static int si_asic_reset(struct amdgpu_device *adev)
+static int si_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
     {
     	return 0;
     }
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -1
index fe2212df..12b2966 100644
@@ -553,10 +553,12 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
     		return AMD_RESET_METHOD_MODE1;
     }
 
-static int soc15_asic_reset(struct amdgpu_device *adev)
+static int soc15_asic_reset(struct amdgpu_device *adev, bool
+*vramlost)
     {
     	switch (soc15_asic_reset_method(adev)) {
     		case AMD_RESET_METHOD_BACO:
+			if (vramlost)
+				*vramlost = true;
     			return soc15_asic_baco_reset(adev);
     		case AMD_RESET_METHOD_MODE2:
     			return soc15_mode2_reset(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 56c882b..8eceb00 100644

drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
@@ -696,7 +696,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
      * to reset them.
      * Returns 0 for success.
      */
-static int vi_asic_reset(struct amdgpu_device *adev)
+static int vi_asic_reset(struct amdgpu_device *adev, bool
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/vi.c static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) · line 702

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1 -0
+*vramlost)
     {
     	int r;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx