Skip to contentSkip to conversation

drm/amdgpu:BUG if gpu_reste and asic_reset from VF

PATCH In review Monk Liu 4 participants 18 messages Feb 4, 2017 – Feb 7, 2017 11 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 5/21 drm/amdgpu:BUG if gpu_reste and asic_reset from VF

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -8
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 {
 	int i, r;
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_request_full_gpu(adev, false);
-
 	/* ungate SMC block first */
 	r = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC,
 					 AMD_CG_STATE_UNGATE);
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 		}
 	}
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_release_full_gpu(adev, false);
-
 	return 0;
 }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
 	int resched;
 	bool need_full_reset;
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
+	BUG_ON(amdgpu_sriov_vf(adev));
 
 	if (!amdgpu_check_soft_reset(adev)) {
 		DRM_INFO("No hardware hang detected. Did some blocks stall?\n");
drivers/gpu/drm/amd/amdgpu/vi.c +2 -0
index 7810030..557994c 100644
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
 {
 	int r;
 
+	BUG_ON(amdgpu_sriov_vf(adev));
+
 	amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
 	r = vi_gpu_pci_config_reset(adev);
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): 1486204499-4344-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 6/21 drm/amdgpu:cg & pg are not applied on VF

Change-Id I93a4e97f1d24a289ab20c2a62371f3e303322587
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 9 +++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/vi.c        | 6 ++++++
 4 files changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +9 -0
index cc223ae..837d57b 100644
@@ -5833,6 +5833,9 @@ static int gfx_v8_0_set_powergating_state(void *handle,
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	bool enable = (state == AMD_PG_STATE_GATE) ? true : false;
 
+	if (amdgpu_sriov_vf(adev))
+		return 0;
+
 	switch (adev->asic_type) {
 	case CHIP_CARRIZO:
 	case CHIP_STONEY:
@@ -5890,6 +5893,9 @@ static void gfx_v8_0_get_clockgating_state(void *handle, u32 *flags)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int data;
 
+	if (amdgpu_sriov_vf(adev))
+		*flags = 0;
+
 	/* AMD_CG_SUPPORT_GFX_MGCG */
 	data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE);
 	if (!(data & RLC_CGTT_MGCG_OVERRIDE__CPF_MASK))
@@ -6403,6 +6409,9 @@ static int gfx_v8_0_set_clockgating_state(void *handle,
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	if (amdgpu_sriov_vf(adev))
+		return 0;
+
 	switch (adev->asic_type) {
 	case CHIP_FIJI:
 	case CHIP_CARRIZO:
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +6 -0
index a564e89..61a506e 100644
@@ -1427,6 +1427,9 @@ static int gmc_v8_0_set_clockgating_state(void *handle,
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	if (amdgpu_sriov_vf(adev))
+		return 0;
+
 	switch (adev->asic_type) {
 	case CHIP_FIJI:
 		fiji_update_mc_medium_grain_clock_gating(adev,
@@ -1451,6 +1454,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int data;
 
+	if (amdgpu_sriov_vf(adev))
+		*flags = 0;
+
 	/* AMD_CG_SUPPORT_MC_MGCG */
 	data = RREG32(mmMC_HUB_MISC_HUB_CG);
 	if (data & MC_HUB_MISC_HUB_CG__ENABLE_MASK)
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +6 -0
index efcdf82..280d4ba 100644
@@ -1512,6 +1512,9 @@ static int sdma_v3_0_set_clockgating_state(void *handle,
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	if (amdgpu_sriov_vf(adev))
+		return 0;
+
 	switch (adev->asic_type) {
 	case CHIP_FIJI:
 	case CHIP_CARRIZO:
@@ -1538,6 +1541,9 @@ static void sdma_v3_0_get_clockgating_state(void *handle, u32 *flags)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int data;
 
+	if (amdgpu_sriov_vf(adev))
+		*flags = 0;
+
 	/* AMD_CG_SUPPORT_SDMA_MGCG */
 	data = RREG32(mmSDMA0_CLK_CTRL + sdma_offsets[0]);
 	if (!(data & SDMA0_CLK_CTRL__SOFT_OVERRIDE0_MASK))
drivers/gpu/drm/amd/amdgpu/vi.c +6 -0
index 557994c..c880749 100644
@@ -1390,6 +1390,9 @@ static int vi_common_set_clockgating_state(void *handle,
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	if (amdgpu_sriov_vf(adev))
+		return 0;
+
 	switch (adev->asic_type) {
 	case CHIP_FIJI:
 		vi_update_bif_medium_grain_light_sleep(adev,
@@ -1434,6 +1437,9 @@ static void vi_common_get_clockgating_state(void *handle, u32 *flags)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int data;
 
+	if (amdgpu_sriov_vf(adev))
+		*flags = 0;
+
 	/* AMD_CG_SUPPORT_BIF_LS */
 	data = RREG32_PCIE(ixPCIE_CNTL2);
 	if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 7/21 drm/amdgpu:fix gart table vram pin

In reply to a message not in the archive

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
 	uint64_t gpu_addr;
 	int r;
 
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
 	r = amdgpu_bo_reserve(adev->gart.robj, false);
 	if (unlikely(r != 0))
 		return 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): 1486204499-4344-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#5 lore raw

答复: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

anyone to review those patches ?

they are for SRIOV case mainly, and they are prepare for later TDR feature (GPU-reset on SR-IOV)

________________________________
发件人: Monk Liu <[email protected]>
发送时间: 2017年2月4日 18:34:59
收件人: [email protected]
抄送: Liu, Monk
主题: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
         uint64_t gpu_addr;
         int r;
 
+       if (adev->gart.table_addr) {
+               /* it's a resume call, gart already pin */
+               return 0;
+       }
+
         r = amdgpu_bo_reserve(adev->gart.robj, false);
         if (unlikely(r != 0))
                 return r;

--
2.7.4

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

#6 lore raw

Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

In reply to a message not in the archive

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 14 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
  	uint64_t gpu_addr;

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
  	int r;
 
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
  	r = amdgpu_bo_reserve(adev->gart.robj, false);
  	if (unlikely(r != 0))
  		return 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): 893f62a7-a049-1d81-c7c1-fc7396a6815f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#8 lore raw

RE: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 15 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
  	uint64_t gpu_addr;

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
  	int r;
 
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
  	r = amdgpu_bo_reserve(adev->gart.robj, false);
  	if (unlikely(r != 0))
  		return 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): DM5PR12MB1610A748EDDB1618D255C6B284400-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#10 lore raw

Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Hui? We shouldn't need to call this function from a GPU reset, do we really do so?

But even if we call it from GPU reset we certainly should have called the matching unpin function before.

Otherwise we certainly won't be able to resume from the next suspend after a GPU reset.

Regards,
Christian.

Am 06.02.2017 um 15:25 schrieb Liu, Monk:

Quoted 39 lines

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 17 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
   1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
   	uint64_t gpu_addr;
   	int r;
 
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
   	r = amdgpu_bo_reserve(adev->gart.robj, false);
   	if (unlikely(r != 0))
   		return 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): 66c2159f-0405-c092-0a23-b16830b24544-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#12 lore raw

RE: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

I recall why I made this patch

When testing SRIOV gpu reset feature, I it will always waiting and not return if without this patch, with more look into it:

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend(), so the gart table BO won't get unpin, which lead to driver infinite wait loop if we pin it again in resume.

For bare-metal case, gpu_reset will call amdgpu_suspend so the gart bo will unpin.

BTW:
GPU_SRIOV_RESET is invoked after HYPERVISOR call VF_FLR on this vf device, so all IP blocks's suspend routine is not needed at all.

What about:

Quoted 4 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	if (adev->gart.table_addr && amdgpu_sriov_vf(adev)) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 10:31 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Hui? We shouldn't need to call this function from a GPU reset, do we really do so?

But even if we call it from GPU reset we certainly should have called the matching unpin function before.

Otherwise we certainly won't be able to resume from the next suspend after a GPU reset.

Regards,
Christian.

Am 06.02.2017 um 15:25 schrieb Liu, Monk:

Quoted 40 lines

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 17 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
   1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
   	uint64_t gpu_addr;
   	int r;
 
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
   	r = amdgpu_bo_reserve(adev->gart.robj, false);
   	if (unlikely(r != 0))
   		return 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): DM5PR12MB16102D278FFDFE33EC1B669F84400-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#14 lore raw

Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Quoted 1 line

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend()

That's most likely not a good idea.

Suspend and resume should always be paired, otherwise you run into exactly those problems and the GART is most likely only the tip of the iceberg here.

For example you also mess up the reference counting for buffer containing the UVD and VCE firmware (ok that won't affect SRIOV for now).

Maybe you just want to call hw_init() instead of a resume here?

Regards,
Christian.

Am 06.02.2017 um 16:55 schrieb Liu, Monk:

Quoted 89 lines

I recall why I made this patch

When testing SRIOV gpu reset feature, I it will always waiting and not return if without this patch, with more look into it:

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend(), so the gart table BO won't get unpin, which lead to driver infinite wait loop if we pin it again in resume.

For bare-metal case, gpu_reset will call amdgpu_suspend so the gart bo will unpin.

BTW:
GPU_SRIOV_RESET is invoked after HYPERVISOR call VF_FLR on this vf device, so all IP blocks's suspend routine is not needed at all.

What about:

Quoted 4 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	if (adev->gart.table_addr && amdgpu_sriov_vf(adev)) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 10:31 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Hui? We shouldn't need to call this function from a GPU reset, do we really do so?

But even if we call it from GPU reset we certainly should have called the matching unpin function before.

Otherwise we certainly won't be able to resume from the next suspend after a GPU reset.

Regards,
Christian.

Am 06.02.2017 um 15:25 schrieb Liu, Monk:

Quoted 40 lines

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 17 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
    1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
    	uint64_t gpu_addr;
    	int r;
 
Quoted 12 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
+	if (adev->gart.table_addr) {
+		/* it's a resume call, gart already pin */
+		return 0;
+	}
+
    	r = amdgpu_bo_reserve(adev->gart.robj, false);
    	if (unlikely(r != 0))
    		return r;

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

Quoted 4 lines

_______________________________________________
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): d77348d2-c966-5ce4-4dbf-0e56d44639ef-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#16 lore raw

答复: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

no, we already make it work, and suspend is totally nonsense for SRIOV,

because when guest side need a GPU reset, hypervisor will do VF flr, so after vf flr amdgpu_suspen() is redundant at all.

those 20 patches serial is verified on KVM/XEN platform, it can recover back from guest hang.

________________________________
发件人: Christian König <[email protected]> 发送时间: 2017年2月7日 19:12:04
收件人: Liu, Monk; [email protected] 主题: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Quoted 1 line

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend()

That's most likely not a good idea.

Suspend and resume should always be paired, otherwise you run into exactly those problems and the GART is most likely only the tip of the iceberg here.

For example you also mess up the reference counting for buffer containing the UVD and VCE firmware (ok that won't affect SRIOV for now).

Maybe you just want to call hw_init() instead of a resume here?

Regards,
Christian.

Am 06.02.2017 um 16:55 schrieb Liu, Monk:

Quoted 89 lines

I recall why I made this patch

When testing SRIOV gpu reset feature, I it will always waiting and not return if without this patch, with more look into it:

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend(), so the gart table BO won't get unpin, which lead to driver infinite wait loop if we pin it again in resume.

For bare-metal case, gpu_reset will call amdgpu_suspend so the gart bo will unpin.

BTW:
GPU_SRIOV_RESET is invoked after HYPERVISOR call VF_FLR on this vf device, so all IP blocks's suspend routine is not needed at all.

What about:

Quoted 4 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+   if (adev->gart.table_addr && amdgpu_sriov_vf(adev)) {
+           /* it's a resume call, gart already pin */
+           return 0;
+   }

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 10:31 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Hui? We shouldn't need to call this function from a GPU reset, do we really do so?

But even if we call it from GPU reset we certainly should have called the matching unpin function before.

Otherwise we certainly won't be able to resume from the next suspend after a GPU reset.

Regards,
Christian.

Am 06.02.2017 um 15:25 schrieb Liu, Monk:

Quoted 40 lines

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 17 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
    1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
     uint64_t gpu_addr;
     int r;
 
Quoted 12 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
+   if (adev->gart.table_addr) {
+           /* it's a resume call, gart already pin */
+           return 0;
+   }
+
     r = amdgpu_bo_reserve(adev->gart.robj, false);
     if (unlikely(r != 0))
             return r;

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

Quoted 4 lines

_______________________________________________
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

author
#17 lore raw

答复: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

In reply to a message not in the archive

this patch is dropped, we can call gart_vram_pin even the bo is already pinned, the internal of pin function will check that, thanks

________________________________
发件人: Christian König <[email protected]> 发送时间: 2017年2月7日 19:12:04
收件人: Liu, Monk; [email protected] 主题: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Quoted 1 line

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend()

That's most likely not a good idea.

Suspend and resume should always be paired, otherwise you run into exactly those problems and the GART is most likely only the tip of the iceberg here.

For example you also mess up the reference counting for buffer containing the UVD and VCE firmware (ok that won't affect SRIOV for now).

Maybe you just want to call hw_init() instead of a resume here?

Regards,
Christian.

Am 06.02.2017 um 16:55 schrieb Liu, Monk:

Quoted 89 lines

I recall why I made this patch

When testing SRIOV gpu reset feature, I it will always waiting and not return if without this patch, with more look into it:

Because gpu_srio_reset (will send patch for this routine later) doesn't call amdgpu_suspend(), so the gart table BO won't get unpin, which lead to driver infinite wait loop if we pin it again in resume.

For bare-metal case, gpu_reset will call amdgpu_suspend so the gart bo will unpin.

BTW:
GPU_SRIOV_RESET is invoked after HYPERVISOR call VF_FLR on this vf device, so all IP blocks's suspend routine is not needed at all.

What about:

Quoted 4 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+   if (adev->gart.table_addr && amdgpu_sriov_vf(adev)) {
+           /* it's a resume call, gart already pin */
+           return 0;
+   }

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 10:31 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

Hui? We shouldn't need to call this function from a GPU reset, do we really do so?

But even if we call it from GPU reset we certainly should have called the matching unpin function before.

Otherwise we certainly won't be able to resume from the next suspend after a GPU reset.

Regards,
Christian.

Am 06.02.2017 um 15:25 schrieb Liu, Monk:

Quoted 40 lines

Emmmm looks like I missed the part of S3 function

But if this is from a GPU reset , we also shouldn't continue run this function otherwise GPU reset will fail (SRIOV reset test)

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:14 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 07/21] drm/amdgpu:fix gart table vram pin

A bug NAK on this! amdgpu_gart_table_vram_unpin() must be called during suspend.

Otherwise the GART table can be corrupted and we run into a whole bunch of problems.

We could add a "BUG_ON(adev->gart.table_addr != NULL);" here to double check that, but just ignoring that something went horrible wrong is clearly the wrong approach.

Regards,
Christian.

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 17 lines

if this call is from resume, shouldn't enter pin logic at all

Change-Id I40a5cdc2a716c4c20d2812fd74ece4ea284b6765
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 5 +++++
    1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 964d2a9..5e907f7 100644
@@ -151,6 +151,11 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
     uint64_t gpu_addr;
     int r;
 
Quoted 12 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev) · line 161

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +5 -0
+   if (adev->gart.table_addr) {
+           /* it's a resume call, gart already pin */
+           return 0;
+   }
+
     r = amdgpu_bo_reserve(adev->gart.robj, false);
     if (unlikely(r != 0))
             return r;

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

Quoted 4 lines

_______________________________________________
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

#18 lore raw
In reply to a message not in the archive

Have you tried the patch for unloading driver?

Ps: the index of patch make people confused, I think there are 21 patches in the series.

Thanks!
Xiangliang Yu

Quoted 76 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Saturday, February 04, 2017 6:35 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -3
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 {
 	int i, r;
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_request_full_gpu(adev, false);
-
 	/* ungate SMC block first */
 	r = amdgpu_set_clockgating_state(adev,
 AMD_IP_BLOCK_TYPE_SMC,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -5
 					 AMD_CG_STATE_UNGATE);
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 		}
 	}
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_release_full_gpu(adev, false);
-
 	return 0;
 }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device
 *adev)
 	int resched;
 	bool need_full_reset;
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
+	BUG_ON(amdgpu_sriov_vf(adev));
 
 	if (!amdgpu_check_soft_reset(adev)) {

DRM_INFO("No hardware hang detected. Did some blocks
stall?\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 7810030..557994c 100644

drivers/gpu/drm/amd/amdgpu/vi.c +2 -1
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
 {
 	int r;
 
+	BUG_ON(amdgpu_sriov_vf(adev));
+
 	amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
 	r = vi_gpu_pci_config_reset(adev);
--

2.7.4

Quoted 4 lines

_______________________________________________
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): CY4PR12MB170174B63E76E5C9579972C0EB400-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author
#20 lore raw

yeah, there are 21 patches totally, but no need to expose all in one time

________________________________
发件人: Yu, Xiangliang
发送时间: 2017年2月6日 10:38:23
收件人: Liu, Monk; [email protected]
抄送: Liu, Monk
主题: RE: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

Have you tried the patch for unloading driver?

Ps: the index of patch make people confused, I think there are 21 patches in the series.

Thanks!
Xiangliang Yu

Quoted 76 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Saturday, February 04, 2017 6:35 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -3
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 {
       int i, r;
 
-     if (amdgpu_sriov_vf(adev))
-             amdgpu_virt_request_full_gpu(adev, false);
-
       /* ungate SMC block first */
       r = amdgpu_set_clockgating_state(adev,
 AMD_IP_BLOCK_TYPE_SMC,
                                        AMD_CG_STATE_UNGATE);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -5
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
               }
       }
 
-     if (amdgpu_sriov_vf(adev))
-             amdgpu_virt_release_full_gpu(adev, false);
-
       return 0;
 }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device
 *adev)
       int resched;
       bool need_full_reset;
 
-     if (amdgpu_sriov_vf(adev))
-             return 0;
+     BUG_ON(amdgpu_sriov_vf(adev));
 
       if (!amdgpu_check_soft_reset(adev)) {

DRM_INFO("No hardware hang detected. Did some blocks
stall?\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 7810030..557994c 100644

drivers/gpu/drm/amd/amdgpu/vi.c +2 -1
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
 {
       int r;
 
+     BUG_ON(amdgpu_sriov_vf(adev));
+
       amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
       r = vi_gpu_pci_config_reset(adev);
--

2.7.4

Quoted 4 lines

_______________________________________________
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): DM5PR12MB161064CEDD39A5236FB04F5B84400-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author
#22 lore raw

thanks for the catch, without those full access protection reboot is failed, I'll remove it and adjust later patches for TDR

BR Monk

________________________________
发件人: Liu, Monk
发送时间: 2017年2月6日 10:39:08
收件人: Yu, Xiangliang; [email protected]
主题: 答复: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

yeah, there are 21 patches totally, but no need to expose all in one time

________________________________
发件人: Yu, Xiangliang
发送时间: 2017年2月6日 10:38:23
收件人: Liu, Monk; [email protected]
抄送: Liu, Monk
主题: RE: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

Have you tried the patch for unloading driver?

Ps: the index of patch make people confused, I think there are 21 patches in the series.

Thanks!
Xiangliang Yu

Quoted 76 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Saturday, February 04, 2017 6:35 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -3
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
 {
       int i, r;
 
-     if (amdgpu_sriov_vf(adev))
-             amdgpu_virt_request_full_gpu(adev, false);
-
       /* ungate SMC block first */
       r = amdgpu_set_clockgating_state(adev,
 AMD_IP_BLOCK_TYPE_SMC,
                                        AMD_CG_STATE_UNGATE);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -5
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
               }
       }
 
-     if (amdgpu_sriov_vf(adev))
-             amdgpu_virt_release_full_gpu(adev, false);
-
       return 0;
 }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device
 *adev)
       int resched;
       bool need_full_reset;
 
-     if (amdgpu_sriov_vf(adev))
-             return 0;
+     BUG_ON(amdgpu_sriov_vf(adev));
 
       if (!amdgpu_check_soft_reset(adev)) {

DRM_INFO("No hardware hang detected. Did some blocks
stall?\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 7810030..557994c 100644

drivers/gpu/drm/amd/amdgpu/vi.c +2 -1
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
 {
       int r;
 
+     BUG_ON(amdgpu_sriov_vf(adev));
+
       amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
       r = vi_gpu_pci_config_reset(adev);
--

2.7.4

Quoted 4 lines

_______________________________________________
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

#23 lore raw
In reply to a message not in the archive
Quoted 1 line · Monk

yeah, there are 21 patches totally, but no need to expose all in one time

Then please edit the numbers in the mail subjects accordingly in the future. :)

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): fb82eeea-c305-3a96-b9c0-25a155a9fe8c-otUistvHUpPR7s880joybQ@public.gmane.org

author
#25 lore raw

I'll re-send the patch serials later, couple patches once

BR Monk

________________________________
发件人: amd-gfx <[email protected]> 代表 Michel Dänzer <[email protected]> 发送时间: 2017年2月6日 11:07:08
收件人: Liu, Monk; Yu, Xiangliang
抄送: [email protected]
主题: Re: 答复: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

Quoted 1 line · Monk

yeah, there are 21 patches totally, but no need to expose all in one time

Then please edit the numbers in the mail subjects accordingly in the future. :)

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
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

#26 lore raw
In reply to a message not in the archive

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 10 lines

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666

Mhm, isn't a BUG_ON() a bit hard here? I mean that usually terminates the current process if not the brings down the whole system.

Maybe just adding a WARN() to the "if (amdgpu_sriov_vf(adev)) return 0;" is more appropriate.

Regards,
Christian.

Quoted 44 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
  drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
  2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -8
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
  {
  	int i, r;
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_request_full_gpu(adev, false);
-
  	/* ungate SMC block first */
  	r = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC,
  					 AMD_CG_STATE_UNGATE);
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
  		}
  	}
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_release_full_gpu(adev, false);
-
  	return 0;
  }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
  	int resched;
  	bool need_full_reset;
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
+	BUG_ON(amdgpu_sriov_vf(adev));
 
  	if (!amdgpu_check_soft_reset(adev)) {
  		DRM_INFO("No hardware hang detected. Did some blocks stall?\n");
drivers/gpu/drm/amd/amdgpu/vi.c +0 -0
index 7810030..557994c 100644

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2 -0
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
  {
  	int r;
 
+	BUG_ON(amdgpu_sriov_vf(adev));
+
  	amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
  	r = vi_gpu_pci_config_reset(adev);

_______________________________________________
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): a6fa8d06-ec8f-08c1-0e22-00555a68d7bf-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#28 lore raw

Actually I have more patches for gpu_reset feature for SRIOV case, but I didn't send out them, so this patch can be skipped.

I'll cleanup all those patches more and send out for review later

BR Monk

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, February 06, 2017 4:24 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 05/21] drm/amdgpu:BUG if gpu_reste and asic_reset from VF

Am 04.02.2017 um 11:34 schrieb Monk Liu:

Quoted 9 lines

for SRIOV vf, Guest couldn't really access PCI registers so gpu_reset() and asic_reset should be avoided.

for suspend it could run for SRIOV because cg/pg routine already modified for SRIOV vf case, besides we should remove the req/rel gpu access around it because the req/rel should be used by invoker.

Change-Id I678d3f2ce202458c1d1d404970fa47421766b666

Mhm, isn't a BUG_ON() a bit hard here? I mean that usually terminates the current process if not the brings down the whole system.

Maybe just adding a WARN() to the "if (amdgpu_sriov_vf(adev)) return 0;" is more appropriate.

Regards,
Christian.

Quoted 45 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +--------
  drivers/gpu/drm/amd/amdgpu/vi.c            | 2 ++
  2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -8
index 6106cd6..173df73 100644
@@ -1566,9 +1566,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
  {
  	int i, r;
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_request_full_gpu(adev, false);
-
  	/* ungate SMC block first */
  	r = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC,
  					 AMD_CG_STATE_UNGATE);
@@ -1597,9 +1594,6 @@ int amdgpu_suspend(struct amdgpu_device *adev)
  		}
  	}
 
-	if (amdgpu_sriov_vf(adev))
-		amdgpu_virt_release_full_gpu(adev, false);
-
  	return 0;
  }
 
@@ -2356,8 +2350,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
  	int resched;
  	bool need_full_reset;
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
+	BUG_ON(amdgpu_sriov_vf(adev));
 
  	if (!amdgpu_check_soft_reset(adev)) {
  		DRM_INFO("No hardware hang detected. Did some blocks stall?\n"); 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/vi.c index 7810030..557994c 100644

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2 -0
@@ -739,6 +739,8 @@ static int vi_asic_reset(struct amdgpu_device *adev)
  {
  	int r;
 
+	BUG_ON(amdgpu_sriov_vf(adev));
+
  	amdgpu_atombios_scratch_regs_engine_hung(adev, true);
 
  	r = vi_gpu_pci_config_reset(adev);

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