* [PATCH] drm/radeon: retry UVD v1 init on failure after resume
@ 2026-10-12 19:43 О К
2026-10-13 13:57 ` Alex Deucher
0 siblings, 1 reply; 5+ messages in thread
From: О К @ 2026-10-12 19:43 UTC (permalink / raw)
To: dri-devel
From: ukrainer8 <ukrainer8@users.noreply.github.com>
Subject: [PATCH] drm/radeon: retry UVD v1 init on failure after resume
On Evergreen/Redwood (and likely other UVD v1/v2 hardware), resume from
suspend intermittently fails the UVD ring test:
radeon 0000:01:00.0: [drm] *ERROR* radeon: ring 5 test failed (0xCAFEDEAD)
radeon 0000:01:00.0: failed initializing UVD (-22).
Cold boot always succeeds; resume succeeds only in about half of the cycles
(42 measured suspend/resume cycles on a Radeon HD 5650M: OK counts per
6-cycle run were 2, 3, 5, 6, 1, 5, 3). Once the ring test fails, UVD stays
dead for the rest of the session and hardware video decode silently falls
back to CPU.
The resume path runs the same full asic startup as cold boot
(evergreen_resume() -> evergreen_startup()), so the difference is the
hardware state at entry, not a skipped call. The single 100 ms ring-test
window right after VCPU boot simply races the hardware coming out of
D3 + ASIC reset.
Retry the init sequence instead of giving up: on failure of clock setup,
VCPU start or the ring test, fully stop UVD, let it settle for 20 ms and
try again (up to 3 attempts). Each retry logs the failing step and the
attempt number, which also makes future reports of this failure mode
self-diagnosing.
On the same machine the patched driver went 6/6 OK, with the log showing
the ring test failing on attempts 1-2 and succeeding on attempt 3 — i.e.
the retry caught exactly the failure the stock driver used to declare
fatal.
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1867
Link: https://bugs.launchpad.net/bugs/1865130
Tested-by: ukrainer8 <ukrainer8@users.noreply.github.com> # Radeon
HD 5650M, kernel 7.0.0
Signed-off-by: ukrainer8 <ukrainer8@users.noreply.github.com>
---
drivers/gpu/drm/radeon/uvd_v1_0.c | <diffstat>
--- a/drivers/gpu/drm/radeon/uvd_v1_0.c
+++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
@@ -158,24 +158,45 @@
{
struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
uint32_t tmp;
- int r;
+ int r, retry;
- /* raise clocks while booting up the VCPU */
- if (rdev->family < CHIP_RV740)
- radeon_set_uvd_clocks(rdev, 10000, 10000);
- else
- radeon_set_uvd_clocks(rdev, 53300, 40000);
+ /* after resume the first ring test can race with the hardware; retry */
+ for (retry = 0; retry < 3; retry++) {
+ /* raise clocks while booting up the VCPU */
+ if (rdev->family < CHIP_RV740)
+ r = radeon_set_uvd_clocks(rdev, 10000, 10000);
+ else
+ r = radeon_set_uvd_clocks(rdev, 53300, 40000);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: raising UVD clocks failed (%d), attempt %d\n",
+ r, retry + 1);
- r = uvd_v1_0_start(rdev);
- if (r)
- goto done;
+ if (!r) {
+ r = uvd_v1_0_start(rdev);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: starting UVD failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
- ring->ready = true;
- r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
- if (r) {
- ring->ready = false;
- goto done;
+ if (!r) {
+ ring->ready = true;
+ r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
+ if (r) {
+ ring->ready = false;
+ drm_warn(&rdev->ddev, "radeon: UVD ring test failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
+ }
+
+ if (!r)
+ break;
+
+ uvd_v1_0_stop(rdev);
+ if (retry < 2)
+ mdelay(20);
}
+ if (r)
+ goto done;
r = radeon_ring_lock(rdev, ring, 10);
if (r) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/radeon: retry UVD v1 init on failure after resume
2026-10-12 19:43 О К
@ 2026-10-13 13:57 ` Alex Deucher
0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2026-10-13 13:57 UTC (permalink / raw)
To: О К; +Cc: dri-devel
On Tue, Oct 13, 2026 at 4:16 AM О К <kolomiiec@gmail.com> wrote:
>
> From: ukrainer8 <ukrainer8@users.noreply.github.com>
> Subject: [PATCH] drm/radeon: retry UVD v1 init on failure after resume
>
> On Evergreen/Redwood (and likely other UVD v1/v2 hardware), resume from
> suspend intermittently fails the UVD ring test:
>
> radeon 0000:01:00.0: [drm] *ERROR* radeon: ring 5 test failed (0xCAFEDEAD)
> radeon 0000:01:00.0: failed initializing UVD (-22).
>
> Cold boot always succeeds; resume succeeds only in about half of the cycles
> (42 measured suspend/resume cycles on a Radeon HD 5650M: OK counts per
> 6-cycle run were 2, 3, 5, 6, 1, 5, 3). Once the ring test fails, UVD stays
> dead for the rest of the session and hardware video decode silently falls
> back to CPU.
>
> The resume path runs the same full asic startup as cold boot
> (evergreen_resume() -> evergreen_startup()), so the difference is the
> hardware state at entry, not a skipped call. The single 100 ms ring-test
> window right after VCPU boot simply races the hardware coming out of
> D3 + ASIC reset.
>
> Retry the init sequence instead of giving up: on failure of clock setup,
> VCPU start or the ring test, fully stop UVD, let it settle for 20 ms and
> try again (up to 3 attempts). Each retry logs the failing step and the
> attempt number, which also makes future reports of this failure mode
> self-diagnosing.
>
> On the same machine the patched driver went 6/6 OK, with the log showing
> the ring test failing on attempts 1-2 and succeeding on attempt 3 — i.e.
> the retry caught exactly the failure the stock driver used to declare
> fatal.
>
> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1867
> Link: https://bugs.launchpad.net/bugs/1865130
> Tested-by: ukrainer8 <ukrainer8@users.noreply.github.com> # Radeon
> HD 5650M, kernel 7.0.0
> Signed-off-by: ukrainer8 <ukrainer8@users.noreply.github.com>
> ---
> drivers/gpu/drm/radeon/uvd_v1_0.c | <diffstat>
> --- a/drivers/gpu/drm/radeon/uvd_v1_0.c
> +++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
> @@ -158,24 +158,45 @@
> {
> struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
> uint32_t tmp;
> - int r;
> + int r, retry;
>
> - /* raise clocks while booting up the VCPU */
> - if (rdev->family < CHIP_RV740)
> - radeon_set_uvd_clocks(rdev, 10000, 10000);
> - else
> - radeon_set_uvd_clocks(rdev, 53300, 40000);
> + /* after resume the first ring test can race with the hardware; retry */
> + for (retry = 0; retry < 3; retry++) {
> + /* raise clocks while booting up the VCPU */
> + if (rdev->family < CHIP_RV740)
> + r = radeon_set_uvd_clocks(rdev, 10000, 10000);
> + else
> + r = radeon_set_uvd_clocks(rdev, 53300, 40000);
> + if (r)
> + drm_warn(&rdev->ddev, "radeon: raising UVD clocks failed (%d), attempt %d\n",
> + r, retry + 1);
>
> - r = uvd_v1_0_start(rdev);
> - if (r)
> - goto done;
> + if (!r) {
> + r = uvd_v1_0_start(rdev);
> + if (r)
> + drm_warn(&rdev->ddev, "radeon: starting UVD failed (%d), attempt %d\n",
> + r, retry + 1);
> + }
>
> - ring->ready = true;
> - r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
> - if (r) {
> - ring->ready = false;
> - goto done;
> + if (!r) {
> + ring->ready = true;
> + r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
> + if (r) {
> + ring->ready = false;
> + drm_warn(&rdev->ddev, "radeon: UVD ring test failed (%d), attempt %d\n",
> + r, retry + 1);
> + }
> + }
> +
> + if (!r)
> + break;
> +
> + uvd_v1_0_stop(rdev);
> + if (retry < 2)
> + mdelay(20);
> }
> + if (r)
> + goto done;
Your mailer seems to have mangled this patch. Can you try and send it
again, ideally using git-send-email?
Thanks!
Alex
>
> r = radeon_ring_lock(rdev, ring, 10);
> if (r) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] drm/radeon: retry UVD v1 init on failure after resume
@ 2026-10-13 17:39 ukrainer8
0 siblings, 0 replies; 5+ messages in thread
From: ukrainer8 @ 2026-10-13 17:39 UTC (permalink / raw)
To: dri-devel
From: ukrainer8 <kolomiiec@gmail.com>
On Evergreen/Redwood (and likely other UVD v1/v2 hardware), resume from
suspend intermittently fails the UVD ring test:
radeon 0000:01:00.0: [drm] *ERROR* radeon: ring 5 test failed (0xCAFEDEAD)
radeon 0000:01:00.0: failed initializing UVD (-22).
Cold boot always succeeds; resume succeeds only in about half of the cycles
(42 measured suspend/resume cycles on a Radeon HD 5650M: OK counts per
6-cycle run were 2, 3, 5, 6, 1, 5, 3). Once the ring test fails, UVD stays
dead for the rest of the session and hardware video decode silently falls
back to CPU.
The resume path runs the same full asic startup as cold boot
(evergreen_resume() -> evergreen_startup()), so the difference is the
hardware state at entry, not a skipped call. The single 100 ms ring-test
window right after VCPU boot simply races the hardware coming out of
D3 + ASIC reset.
Retry the init sequence instead of giving up: on failure of clock setup,
VCPU start or the ring test, fully stop UVD, let it settle for 20 ms and
try again (up to 3 attempts). Each retry logs the failing step and the
attempt number, which also makes future reports of this failure mode
self-diagnosing.
On the same machine the patched driver went 6/6 OK, with the log showing
the ring test failing on attempts 1-2 and succeeding on attempt 3 — i.e.
the retry caught exactly the failure the stock driver used to declare
fatal.
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1867
Link: https://bugs.launchpad.net/bugs/1865130
Tested-by: ukrainer8 <ukrainer8@users.noreply.github.com> # Radeon HD 5650M, kernel 7.0.0
Signed-off-by: ukrainer8 <ukrainer8@users.noreply.github.com>
---
Resent with git-send-email; the previous copy was mangled by my mailer
(pointed out by Alex Deucher). Same patch, no code changes.
drivers/gpu/drm/radeon/uvd_v1_0.c | <diffstat>
--- a/drivers/gpu/drm/radeon/uvd_v1_0.c
+++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
@@ -158,24 +158,45 @@
{
struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
uint32_t tmp;
- int r;
+ int r, retry;
- /* raise clocks while booting up the VCPU */
- if (rdev->family < CHIP_RV740)
- radeon_set_uvd_clocks(rdev, 10000, 10000);
- else
- radeon_set_uvd_clocks(rdev, 53300, 40000);
+ /* after resume the first ring test can race with the hardware; retry */
+ for (retry = 0; retry < 3; retry++) {
+ /* raise clocks while booting up the VCPU */
+ if (rdev->family < CHIP_RV740)
+ r = radeon_set_uvd_clocks(rdev, 10000, 10000);
+ else
+ r = radeon_set_uvd_clocks(rdev, 53300, 40000);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: raising UVD clocks failed (%d), attempt %d\n",
+ r, retry + 1);
- r = uvd_v1_0_start(rdev);
- if (r)
- goto done;
+ if (!r) {
+ r = uvd_v1_0_start(rdev);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: starting UVD failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
- ring->ready = true;
- r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
- if (r) {
- ring->ready = false;
- goto done;
+ if (!r) {
+ ring->ready = true;
+ r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
+ if (r) {
+ ring->ready = false;
+ drm_warn(&rdev->ddev, "radeon: UVD ring test failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
+ }
+
+ if (!r)
+ break;
+
+ uvd_v1_0_stop(rdev);
+ if (retry < 2)
+ mdelay(20);
}
+ if (r)
+ goto done;
r = radeon_ring_lock(rdev, ring, 10);
if (r) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] drm/radeon: retry UVD v1 init on failure after resume
@ 2026-10-13 17:57 ukrainer8
2026-10-15 8:11 ` sashiko-bot
0 siblings, 1 reply; 5+ messages in thread
From: ukrainer8 @ 2026-10-13 17:57 UTC (permalink / raw)
To: dri-devel
On Evergreen/Redwood (and likely other UVD v1/v2 hardware), resume from
suspend intermittently fails the UVD ring test:
radeon 0000:01:00.0: [drm] *ERROR* radeon: ring 5 test failed (0xCAFEDEAD)
radeon 0000:01:00.0: failed initializing UVD (-22).
Cold boot always succeeds; resume succeeds only in about half of the cycles
(42 measured suspend/resume cycles on a Radeon HD 5650M: OK counts per
6-cycle run were 2, 3, 5, 6, 1, 5, 3). Once the ring test fails, UVD stays
dead for the rest of the session and hardware video decode silently falls
back to CPU.
The resume path runs the same full asic startup as cold boot
(evergreen_resume() -> evergreen_startup()), so the difference is the
hardware state at entry, not a skipped call. The single 100 ms ring-test
window right after VCPU boot simply races the hardware coming out of
D3 + ASIC reset.
Retry the init sequence instead of giving up: on failure of clock setup,
VCPU start or the ring test, fully stop UVD, let it settle for 20 ms and
try again (up to 3 attempts). Each retry logs the failing step and the
attempt number, which also makes future reports of this failure mode
self-diagnosing.
On the same machine the patched driver went 6/6 OK, with the log showing
the ring test failing on attempts 1-2 and succeeding on attempt 3 — i.e.
the retry caught exactly the failure the stock driver used to declare
fatal.
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1867
Link: https://bugs.launchpad.net/bugs/1865130
Tested-by: ukrainer8 <ukrainer8@users.noreply.github.com> # Radeon HD 5650M, kernel 7.0.0
Signed-off-by: ukrainer8 <ukrainer8@users.noreply.github.com>
---
Resent with git-send-email; the previous copy was mangled by my mailer
(pointed out by Alex Deucher). Same patch, no code changes.
drivers/gpu/drm/radeon/uvd_v1_0.c | <diffstat>
--- a/drivers/gpu/drm/radeon/uvd_v1_0.c
+++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
@@ -158,24 +158,45 @@
{
struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
uint32_t tmp;
- int r;
+ int r, retry;
- /* raise clocks while booting up the VCPU */
- if (rdev->family < CHIP_RV740)
- radeon_set_uvd_clocks(rdev, 10000, 10000);
- else
- radeon_set_uvd_clocks(rdev, 53300, 40000);
+ /* after resume the first ring test can race with the hardware; retry */
+ for (retry = 0; retry < 3; retry++) {
+ /* raise clocks while booting up the VCPU */
+ if (rdev->family < CHIP_RV740)
+ r = radeon_set_uvd_clocks(rdev, 10000, 10000);
+ else
+ r = radeon_set_uvd_clocks(rdev, 53300, 40000);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: raising UVD clocks failed (%d), attempt %d\n",
+ r, retry + 1);
- r = uvd_v1_0_start(rdev);
- if (r)
- goto done;
+ if (!r) {
+ r = uvd_v1_0_start(rdev);
+ if (r)
+ drm_warn(&rdev->ddev, "radeon: starting UVD failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
- ring->ready = true;
- r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
- if (r) {
- ring->ready = false;
- goto done;
+ if (!r) {
+ ring->ready = true;
+ r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
+ if (r) {
+ ring->ready = false;
+ drm_warn(&rdev->ddev, "radeon: UVD ring test failed (%d), attempt %d\n",
+ r, retry + 1);
+ }
+ }
+
+ if (!r)
+ break;
+
+ uvd_v1_0_stop(rdev);
+ if (retry < 2)
+ mdelay(20);
}
+ if (r)
+ goto done;
r = radeon_ring_lock(rdev, ring, 10);
if (r) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/radeon: retry UVD v1 init on failure after resume
2026-10-13 17:57 [PATCH] drm/radeon: retry UVD v1 init on failure after resume ukrainer8
@ 2026-10-15 8:11 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-15 8:11 UTC (permalink / raw)
To: ukrainer8, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/radeon: system hang due to unclocked UVD register access on clock setup failure
--
commit 9840a4a45eacb2033c0f3f3ceb29f75910196145
Author: ukrainer8 <kolomiiec@gmail.com>
Subject: drm/radeon: retry UVD v1 init on failure after resume
This commit introduces a retry loop for UVD v1 initialization during resume,
as the ring test can sometimes fail due to racing with hardware. On failure,
it stops UVD, waits 20ms, and retries the initialization steps up to 3 times.
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1867
Link: https://bugs.launchpad.net/bugs/1865130
> --- a/drivers/gpu/drm/radeon/uvd_v1_0.c
> +++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
> @@ -158,24 +158,45 @@ int uvd_v1_0_init(struct radeon_device *rdev)
> {
> struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
> uint32_t tmp;
> - int r;
> + int r, retry;
> +
> + /* after resume the first ring test can race with the hardware; retry */
> + for (retry = 0; retry < 3; retry++) {
> + /* raise clocks while booting up the VCPU */
> + if (rdev->family < CHIP_RV740)
> + r = radeon_set_uvd_clocks(rdev, 10000, 10000);
> + else
> + r = radeon_set_uvd_clocks(rdev, 53300, 40000);
> + if (r)
> + drm_warn(&rdev->ddev, "radeon: raising UVD clocks failed (%d), attempt %d\n",
> + r, retry + 1);
[ ... ]
> + if (!r)
> + break;
>
> - ring->ready = true;
> - r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
> - if (r) {
> - ring->ready = false;
> - goto done;
> + uvd_v1_0_stop(rdev);
^^^^^^^^^^^^^^^^^^^
[Severity: High]
Is it safe to call uvd_v1_0_stop() when radeon_set_uvd_clocks() fails?
If clock setup fails, r is non-zero, and the loop bypasses the break
condition to unconditionally call uvd_v1_0_stop().
This function performs MMIO writes to UVD registers like UVD_RBC_RB_CNTL:
drivers/gpu/drm/radeon/uvd_v1_0.c:uvd_v1_0_stop() {
/* force RBC into idle state */
WREG32(UVD_RBC_RB_CNTL, 0x11010101);
...
}
Accessing these registers when the UVD IP block is unclocked can cause a PCI
bus master abort and lead to a hard system hang. Should there be a check to
ensure clocks are successfully raised before attempting to stop the hardware?
> + if (retry < 2)
> + mdelay(20);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013175753.37344-1-kolomiiec@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-15 8:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 17:57 [PATCH] drm/radeon: retry UVD v1 init on failure after resume ukrainer8
2026-10-15 8:11 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-10-13 17:39 ukrainer8
2026-10-12 19:43 О К
2026-10-13 13:57 ` Alex Deucher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.