Skip to contentSkip to conversation

drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

PATCH In review wentalou 4 participants 7 messages Apr 1, 2019 – Apr 2, 2019 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

wentalou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -1
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
 		tmo = msecs_to_jiffies(8000);
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
 	mutex_unlock(&adev->shadow_list_lock);
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when single shadow in list */
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
 		DRM_ERROR("recover vram bo from shadow failed\n");
 		return -EIO;
 	}
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): 1554109125-21890-1-git-send-email-Wentao.Lou-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 58 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}
Quoted 7 lines

--
2.7.4

_______________________________________________
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): BN7PR12MB26445D172F6617137A8F905C8F560-Zx/IyJUqfGKoYeSiBV3SvgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#4 lore raw

Yeah, agree that is much closer to a correct solution.

But even better would be to correctly update the timeout as well, e.g:

tmo = dma_fence_wait_timeout(fence, false, tmo);
dma_fence_put(fence);
fence = next;
if (tmo == 0)
    r = -ETIMEDOUT;
    break
} else if (tmo < 0) {
    r = tmo;
    break;
}

That we restart the timeout for each wait looks like a rather problematic bug to me as well.

Christian.

Am 02.04.19 um 06:03 schrieb Deng, Emily:

Quoted 74 lines

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 61 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}

--
2.7.4

Quoted 8 lines
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

_______________________________________________
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): 03f69f82-1352-8e4e-bd3b-21e5c031ec09-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw

Hi Christian,

If " tmo = dma_fence_wait_timeout(fence, false, tmo); " was executed inside list_for_each_entry, the value of tmo might be changed. But " tmo = dma_fence_wait_timeout(fence, false, tmo); " might be called after exiting the loop of list_for_each_entry. It might pass a different value of tmo into dma_fence_wait_timeout.

BR,
Wentao

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, April 2, 2019 3:01 PM
To: Deng, Emily <[email protected]>; Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Yeah, agree that is much closer to a correct solution.

But even better would be to correctly update the timeout as well, e.g:

tmo = dma_fence_wait_timeout(fence, false, tmo); dma_fence_put(fence); fence = next; if (tmo == 0)
    r = -ETIMEDOUT;
    break
} else if (tmo < 0) {
    r = tmo;
    break;
}

That we restart the timeout for each wait looks like a rather problematic bug to me as well.

Christian.

Am 02.04.19 um 06:03 schrieb Deng, Emily:

Quoted 75 lines

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 62 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}

--
2.7.4

Quoted 8 lines
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

_______________________________________________
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): MN2PR12MB3280B0482A8DCD4D6499D42F83560-rweVpJHSKToYX/[email protected]

#8 lore raw

Yeah, exactly that's what should happen here.

The value of tmo SHOULD be changed, otherwise we wait tmo jiffies on each loop.

Christian.

Am 02.04.19 um 09:29 schrieb Lou, Wentao:

Quoted 28 lines

Hi Christian,

If " tmo = dma_fence_wait_timeout(fence, false, tmo); " was executed inside list_for_each_entry, the value of tmo might be changed. But " tmo = dma_fence_wait_timeout(fence, false, tmo); " might be called after exiting the loop of list_for_each_entry. It might pass a different value of tmo into dma_fence_wait_timeout.

BR,
Wentao

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, April 2, 2019 3:01 PM
To: Deng, Emily <[email protected]>; Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Yeah, agree that is much closer to a correct solution.

But even better would be to correctly update the timeout as well, e.g:

tmo = dma_fence_wait_timeout(fence, false, tmo); dma_fence_put(fence); fence = next; if (tmo == 0)
    r = -ETIMEDOUT;
    break
} else if (tmo < 0) {
    r = tmo;
    break;
}

Quoted 88 lines

That we restart the timeout for each wait looks like a rather problematic bug to me as well.

Christian.

Am 02.04.19 um 06:03 schrieb Deng, Emily:

Quoted 83 lines

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 59 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}
Quoted 7 lines

--
2.7.4

_______________________________________________
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

_______________________________________________
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): d358855c-c37c-7623-cd24-86f4cb2be16f-5C7GfCeVMHo@public.gmane.org

#10 lore raw

Thanks Christian.
You mean msecs_to_jiffies(8000) should be time to complete whole loop, not each loop. Just sent out another patch for review.
Thanks.

BR,
Wentao

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, April 2, 2019 3:39 PM
To: Lou, Wentao <[email protected]>; Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Yeah, exactly that's what should happen here.

The value of tmo SHOULD be changed, otherwise we wait tmo jiffies on each loop.

Christian.

Am 02.04.19 um 09:29 schrieb Lou, Wentao:

Quoted 30 lines

Hi Christian,

If " tmo = dma_fence_wait_timeout(fence, false, tmo); " was executed inside list_for_each_entry, the value of tmo might be changed. But " tmo = dma_fence_wait_timeout(fence, false, tmo); " might be called after exiting the loop of list_for_each_entry. It might pass a different value of tmo into dma_fence_wait_timeout.

BR,
Wentao

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, April 2, 2019 3:01 PM
To: Deng, Emily <[email protected]>; Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Yeah, agree that is much closer to a correct solution.

But even better would be to correctly update the timeout as well, e.g:

tmo = dma_fence_wait_timeout(fence, false, tmo); dma_fence_put(fence); fence = next; if (tmo == 0)
    r = -ETIMEDOUT;
    break
} else if (tmo < 0) {
    r = tmo;
    break;
}

Quoted 88 lines

That we restart the timeout for each wait looks like a rather problematic bug to me as well.

Christian.

Am 02.04.19 um 06:03 schrieb Deng, Emily:

Quoted 83 lines

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 59 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct 
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}
Quoted 7 lines

--
2.7.4

_______________________________________________
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

_______________________________________________
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): MN2PR12MB328037EF2991597695B6FB9F83560-rweVpJHSKToYX/[email protected]

#12 lore raw

Am 02.04.19 um 11:23 schrieb Lou, Wentao:

Quoted 2 lines

Thanks Christian.
You mean msecs_to_jiffies(8000) should be time to complete whole loop, not each loop.

Yeah, a normal desktop system can easily have more than 10000 BOs in that list.

So the total timeout could be more than a day, which is a bit long :)

Quoted 1 line

Just sent out another patch for review.

Going to take a look.

Regards,
Christian.

Quoted 12 lines

Thanks.

BR,
Wentao

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, April 2, 2019 3:39 PM
To: Lou, Wentao <[email protected]>; Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Quoted 125 lines

Yeah, exactly that's what should happen here.

The value of tmo SHOULD be changed, otherwise we wait tmo jiffies on each loop.

Christian.

Am 02.04.19 um 09:29 schrieb Lou, Wentao:

Quoted 118 lines

Hi Christian,

If " tmo = dma_fence_wait_timeout(fence, false, tmo); " was executed inside list_for_each_entry, the value of tmo might be changed. But " tmo = dma_fence_wait_timeout(fence, false, tmo); " might be called after exiting the loop of list_for_each_entry. It might pass a different value of tmo into dma_fence_wait_timeout.

BR,
Wentao

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, April 2, 2019 3:01 PM
To: Deng, Emily <[email protected]>; Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

Yeah, agree that is much closer to a correct solution.

But even better would be to correctly update the timeout as well, e.g:

tmo = dma_fence_wait_timeout(fence, false, tmo); dma_fence_put(fence); fence = next; if (tmo == 0)
    r = -ETIMEDOUT;
    break

} else if (tmo < 0) {
       r = tmo;
       break;
}

That we restart the timeout for each wait looks like a rather problematic bug to me as well.

Christian.

Am 02.04.19 um 06:03 schrieb Deng, Emily:

Quoted 83 lines

Maybe it will be better to add follow check, and change “if (r <= 0 || tmo <= 0) " to "if (r <0 || tmo <= 0)".

	r = dma_fence_wait_timeout(f, false, timeout);
	if (r == 0) {
		r = -ETIMEDOUT;
		break;
	} else if (r < 0) {
		break;
	}

Best wishes
Emily Deng

Quoted 59 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of wentalou
Sent: Monday, April 1, 2019 4:59 PM
To: [email protected]
Cc: Lou, Wentao <[email protected]>
Subject: [PATCH] drm/amdgpu: amdgpu_device_recover_vram always failed if only one node in shadow_list

amdgpu_bo_restore_shadow would assign zero to r if succeeded. r would remain zero if there is only one node in shadow_list. current code would always return failure when r <= 0.

Change-Id Iae6880e7c78b71fde6a6754c69665c2e312a80a5

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index c4c61e9..5cf21a4 100644
@@ -3171,6 +3171,7 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 	struct dma_fence *fence = NULL, *next = NULL;
 	struct amdgpu_bo *shadow;
 	long r = 1, tmo;
+	bool single_shadow = false;
 
 	if (amdgpu_sriov_runtime(adev))
		tmo = msecs_to_jiffies(8000);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3194,10 +3195,12 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 			r = dma_fence_wait_timeout(fence, false, tmo);
 			dma_fence_put(fence);
 			fence = next;
+			single_shadow = false;
 			if (r <= 0)
 				break;
 		} else {
 			fence = next;
+			single_shadow = true;
 		}
 	}
	mutex_unlock(&adev->shadow_list_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3206,7 +3209,8 @@ static int amdgpu_device_recover_vram(struct
 amdgpu_device *adev)
 		tmo = dma_fence_wait_timeout(fence, false, tmo);
 	dma_fence_put(fence);
 
-	if (r <= 0 || tmo <= 0) {
+	/* r would be zero even if amdgpu_bo_restore_shadow succeeded when

single shadow in list */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+	if (r < 0 || (r == 0 && !single_shadow) || tmo <= 0) {
		DRM_ERROR("recover vram bo from shadow failed\n");
		return -EIO;
	}
Quoted 7 lines

--
2.7.4

_______________________________________________
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

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