drm/radeon: fix VCE1 encoding on SI by handling the VCE interrupt
Subsystems (2)
cover drm/radeon: fix VCE1 encoding on SI by handling the VCE interrupt
Hardware H.264 encoding with the VCE block on SI GPUs (radeon driver) hangs the GPU after a few dozen frames. I hit it with the KDE Plasma RDP server, which encodes through VAAPI, and reproduced it with a plain "ffmpeg -vaapi_device ... -c:v h264_vaapi" test on a Radeon HD 8870M (Cape Verde).
The VCE1 code never enables the VCE trap interrupt and the SI (and Trinity) interrupt handlers do not process it, unlike the CIK code and amdgpu. Patch 1 adds the handlers, patch 2 enables the interrupt.
Results on Debian 6.12.113 (see patch 2 for numbers): hang before, none after, and 34 fps instead of ~4 fps for the workaround that avoids the hang. The KDE RDP server (KRDP) itself, driven by a local FreeRDP client, now encodes on the VCE ring for several minutes (about 40 fences per second on ring 6 in the radeon_fence_emit tracepoint) with a clean kernel log.
Two caveats:
- I have not worked out why the missing interrupt turns into ring lockups instead of only added latency. What I know is that the hang needs the VCE ring to wait on a hardware semaphore (disabling only the waiting side, or both sides, of radeon_vce_semaphore_emit() avoids it) and that handling the interrupt makes it go away with the semaphores left enabled. If someone knows why, I would be glad to improve the commit message.
- The Trinity/Richland change is compile tested only.
The series was developed and tested on Debian's 6.12.113 with the radeon module built out of tree. It applies cleanly on drm-next (fad06cf), where drivers/gpu/drm/radeon builds without warnings (W=1, allmodconfig) both after patch 1 and with the whole series.
Matheus Tagliari (2):
drm/radeon: process the VCE interrupt on SI and Trinity drm/radeon/vce1: enable the VCE trap interrupt
drivers/gpu/drm/radeon/evergreen.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/si.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/sid.h | 2 ++ drivers/gpu/drm/radeon/vce_v1_0.c | 4 ++++ 4 files changed, 34 insertions(+)
base-commit: fad06cfaf385787b9ffa2f73f049d42dbe1de57f
Signature · 1 line
2.47.3
PATCH 1/2 drm/radeon: process the VCE interrupt on SI and Trinity
radeon_vce_fence_emit() ends every VCE fence with VCE_CMD_TRAP, which raises the VCE trap interrupt (IH src_id 167). cik_irq_process() handles it by calling radeon_fence_process() for the matching VCE ring, but si_irq_process() and evergreen_irq_process(), which serve the other ASICs with VCE1 (SI and Trinity/Richland), have no case for it.
Add the same handling. The trap interrupt is not enabled on these ASICs yet, so this does not change behaviour on its own; the next patch enables it.
The SI part was tested together with the next patch. The Trinity part mirrors the CIK and SI code and has not been tested on Trinity/Richland hardware.
--- drivers/gpu/drm/radeon/evergreen.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/si.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+)
drivers/gpu/drm/radeon/evergreen.c +14 -0
@@ -4847,6 +4847,20 @@ int evergreen_irq_process(struct radeon_device *rdev)drm_dbg (ddev,"IH: UVD int: 0x%08x\n" , src_data);radeon_fence_process (rdev,R600_RING_TYPE_UVD_INDEX );break ; +case 167 :/* VCE */ +drm_dbg (ddev,"IH: VCE int: 0x%08x\n" , src_data); +switch (src_data) { +case 0 : +radeon_fence_process (rdev,TN_RING_TYPE_VCE1_INDEX ); +break ; +case 1 : +radeon_fence_process (rdev,TN_RING_TYPE_VCE2_INDEX ); +break ; +default : +drm_err (ddev,"Unhandled interrupt: %d %d\n" , src_id, src_data); +break ; + } +break ;case 146 :case 147 : addr =RREG32 (VM_CONTEXT1_PROTECTION_FAULT_ADDR );
drivers/gpu/drm/radeon/si.c +14 -0
@@ -6347,6 +6347,20 @@ int si_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: UVD int: 0x%08x\n" , src_data);radeon_fence_process (rdev,R600_RING_TYPE_UVD_INDEX );break ; +case 167 :/* VCE */ +DRM_DEBUG ("IH: VCE int: 0x%08x\n" , src_data); +switch (src_data) { +case 0 : +radeon_fence_process (rdev,TN_RING_TYPE_VCE1_INDEX ); +break ; +case 1 : +radeon_fence_process (rdev,TN_RING_TYPE_VCE2_INDEX ); +break ; +default : +DRM_ERROR ("Unhandled interrupt: %d %d\n" , src_id, src_data); +break ; + } +break ;case 146 :case 147 : addr =RREG32 (VM_CONTEXT1_PROTECTION_FAULT_ADDR );
Signature · 1 line
2.47.3
PATCH 2/2 drm/radeon/vce1: enable the VCE trap interrupt
In reply to Matheus Tagliarivce_v2_0 sets VCE_SYS_INT_TRAP_INTERRUPT_EN in VCE_SYS_INT_EN so that the VCE_CMD_TRAP emitted after each fence raises an interrupt. The VCE1 code, used by SI and Trinity/Richland, never does, and amdgpu's vce_v1_0 does (mmVCE_SYS_INT_EN, 0x8340, i.e. byte offset 0x20d00 on SI). VCE fences are therefore never processed from the interrupt handler and are only noticed when a fence wait times out.
Enable the trap interrupt at the end of vce_v1_0_start().
Observed on a Radeon HD 8870M (Cape Verde, 1002:6821) with VCE firmware 50.0.1, Mesa 25.0.7 radeonsi and ffmpeg h264_vaapi on Debian 6.12.113:
- Stock driver: the encode hangs after a few dozen frames ("ring 0 stalled", "ring 3 stalled", "GPU lockup"), and the reset does not recover ("failed VCE resume (-22)", "ring 0 test failed").
- With the hardware ring semaphores of the VCE ring disabled as a workaround, the hang is gone but encoding runs at 3.9 fps (~256 ms per frame), consistent with fences being noticed only by timeouts.
- With this series: 640x360 for 1800 frames, 1280x720 for 900 frames and 1920x1080 for 600 frames, all in real time with no decode errors, and 191 fps at 720p / 91 fps at 1080p unthrottled. Four runtime suspend/resume cycles with an encode in between also worked. No lockup, reset, WARNING or error in the kernel log, with DPM and runtime PM enabled.
Trinity/Richland shares this code and is covered by the previous patch, but I have no such hardware to test.
--- drivers/gpu/drm/radeon/sid.h | 2 ++ drivers/gpu/drm/radeon/vce_v1_0.c | 4 ++++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/radeon/sid.h +2 -0
@@ -1878,6 +1878,8 @@#define DMA_PACKET_NOP 0xf#define VCE_STATUS 0x20004 +#define VCE_SYS_INT_EN 0x20d00 +#define VCE_SYS_INT_TRAP_INTERRUPT_EN (1 << 3)#define VCE_VCPU_CNTL 0x20014#define VCE_CLK_EN (1 << 0)#define VCE_VCPU_CACHE_OFFSET0 0x20024
drivers/gpu/drm/radeon/vce_v1_0.c +4 -0
@@ -350,6 +350,10 @@ int vce_v1_0_start(struct radeon_device *rdev)return r; } +/* enable the trap interrupt so that VCE fences are processed */ +WREG32_P (VCE_SYS_INT_EN ,VCE_SYS_INT_TRAP_INTERRUPT_EN , + ~VCE_SYS_INT_TRAP_INTERRUPT_EN ); +return 0 ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH 2/2] drm/radeon/vce1: enable the VCE trap interrupt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] drm/radeon: vce_v1_0_start() writes VCE1 VCE_SYS_INT_EN offset on VCE2 --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/radeon: vce_v1_0_start() writes VCE1 VCE_SYS_INT_EN offset on VCE2 --
commit 081ec1fcedbbac29c36bb9a81a87f74e67af09fd
Author: Matheus Tagliari <[email protected]>
drm/radeon/vce1: enable the VCE trap interrupt
This commit defines VCE_SYS_INT_EN and VCE_SYS_INT_TRAP_INTERRUPT_EN in sid.h and enables the trap interrupt at the end of vce_v1_0_start() so VCE fences are processed by the interrupt handler.
Quoted 18 lines
drivers/gpu/drm/radeon/sid.h +2
-0@@ -1878,6 +1878,8 @@#define DMA_PACKET_NOP 0xf#define VCE_STATUS 0x20004 +#define VCE_SYS_INT_EN 0x20d00 +#define VCE_SYS_INT_TRAP_INTERRUPT_EN (1 << 3)#define VCE_VCPU_CNTL 0x20014#define VCE_CLK_EN (1 << 0)#define VCE_VCPU_CACHE_OFFSET0 0x20024drivers/gpu/drm/radeon/vce_v1_0.c +0
-0
drivers/gpu/drm/radeon/vce_v1_0.c int vce_v1_0_start(struct radeon_device *rdev) · line 355
Quoted 6 lines
drivers/gpu/drm/radeon/vce_v1_0.c +3
-0@@ -350,6 +350,10 @@ int vce_v1_0_start(struct radeon_device *rdev)return r; } +/* enable the trap interrupt so that VCE fences are processed */ +WREG32_P (VCE_SYS_INT_EN ,VCE_SYS_INT_TRAP_INTERRUPT_EN , + ~VCE_SYS_INT_TRAP_INTERRUPT_EN );
[Severity: High]
Does writing VCE_SYS_INT_EN unconditionally in vce_v1_0_start() access the wrong MMIO register offset on CIK (VCE 2.0) hardware?
In drm/radeon, VCE 2.0 reuses vce_v1_0_init() and vce_v1_0_start() during startup, resume, and dynamic powergating transitions:
drivers/gpu/drm/radeon/cik.c:cik_vce_resume() {
...
r = vce_v1_0_init(rdev);
}drivers/gpu/drm/radeon/kv_dpm.c:kv_dpm_powergate_vce() {
...
if (pi->caps_vce_pg) {
kv_notify_message_to_smu(rdev, PPSMC_MSG_VCEPowerON);
vce_v2_0_resume(rdev);
vce_v1_0_start(rdev);
}
}Because drivers/gpu/drm/radeon/vce_v1_0.c includes sid.h, VCE_SYS_INT_EN evaluates to the VCE 1.0 byte offset 0x20d00 here. On VCE 2.0, however, VCE_SYS_INT_EN is at byte offset 0x21300 in drivers/gpu/drm/radeon/cikd.h (where offset 0x20d00 falls within the VCE 2.0 UENC register range), and VCE 2.0 already enables VCE_SYS_INT_TRAP_INTERRUPT_EN at 0x21300 inside vce_v2_0_resume() in drivers/gpu/drm/radeon/vce_v2_0.c:
drivers/gpu/drm/radeon/vce_v2_0.c:vce_v2_0_resume() {
...
WREG32_P(VCE_LMI_CTRL2, 0x0, ~0x100);
WREG32_P(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN,
~VCE_SYS_INT_TRAP_INTERRUPT_EN);
vce_v2_0_init_cg(rdev);
}Should this register write be placed in vce_v1_0_resume() (matching vce_v2_0_resume()), or guarded so it is only executed on VCE 1.0 hardware?
Quoted 4 lines
drivers/gpu/drm/radeon/vce_v1_0.c +1
-0+return 0 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/2] drm/radeon/vce1: enable the VCE trap interrupt
Quoted 2 lines
Does writing
VCE_SYS_INT_ENunconditionally invce_v1_0_start()access the wrong MMIO register offset on CIK (VCE 2.0) hardware?
Thanks, that is right. vce_v1_0_start() is also reached on CIK through vce_v1_0_init() (cik.c) and kv_dpm, where VCE_SYS_INT_EN lives at a different offset (cikd.h) and is already enabled by vce_v2_0_resume(). v1 would have written the VCE1 offset on VCE2 hardware.
I have a v2 ready that only does the write for family < CHIP_BONAIRE. I will wait a bit for further comments before sending it.
Re: [PATCH 2/2] drm/radeon/vce1: enable the VCE trap interrupt
In reply to [email protected]Quoted 14 lines
Quoted 3 lines
Does writing
VCE_SYS_INT_ENunconditionally invce_v1_0_start()accessthe
Quoted 1 line
wrong MMIO register offset on CIK (VCE 2.0) hardware?
Thanks, that is right.
vce_v1_0_start()is also reached on CIK throughvce_v1_0_init()(cik.c) andkv_dpm, whereVCE_SYS_INT_ENlives at a different offset (cikd.h) and is already enabled byvce_v2_0_resume(). v1 would have written the VCE1 offset on VCE2 hardware.I have a v2 ready that only does the write for family <
CHIP_BONAIRE. I will wait a bit for further comments before sending it.
Christian König
maintainer[Adding Timur on CC]
Quoted 9 lines · Matheus Tagliari
Hardware H.264 encoding with the VCE block on SI GPUs (radeon driver) hangs the GPU after a few dozen frames. I hit it with the KDE Plasma RDP server, which encodes through VAAPI, and reproduced it with a plain "ffmpeg -vaapi_device ... -c:v
h264_vaapi" test on a Radeon HD 8870M (Cape Verde).The VCE1 code never enables the VCE trap interrupt and the SI (and Trinity) interrupt handlers do not process it, unlike the CIK code and amdgpu. Patch 1 adds the handlers, patch 2 enables the interrupt.
Oh, I do remember that I intentionally never enabled interrupts for VCE on radeon. But I honestly absolutely doesn't remember why (that was ~12-13 years ago!).
Timur hammered out most (all?) of the UVD/VCE bugs on SI, CIK and partially Polaris hardware as well for amdgpu and we are strongly considering just dropping SI/CIK support for radeon.
The fence handling on radeon should work completely without interrupts since those have been rather flaky on really old HW.
So no idea why that actually crashes for you if the interrupt is not enabled, my educated guess is that enabling interrupts actually doesn't fix the crash but makes it less likely because of timing change.
Would it be possible to just switch over to amdgpu instead? Or is there any support still missing there?
Regards,
Christian.
Quoted 39 lines
Results on Debian 6.12.113 (see patch 2 for numbers): hang before, none after, and 34 fps instead of ~4 fps for the workaround that avoids the hang. The KDE RDP server (KRDP) itself, driven by a local FreeRDP client, now encodes on the VCE ring for several minutes (about 40 fences per second on ring 6 in the
radeon_fence_emittracepoint) with a clean kernel log.Two caveats:
- I have not worked out why the missing interrupt turns into ring lockups instead of only added latency. What I know is that the hang needs the VCE ring to wait on a hardware semaphore (disabling only the waiting side, or both sides, of
radeon_vce_semaphore_emit()avoids it) and that handling the interrupt makes it go away with the semaphores left enabled. If someone knows why, I would be glad to improve the commit message.
- The Trinity/Richland change is compile tested only.The series was developed and tested on Debian's 6.12.113 with the radeon module built out of tree. It applies cleanly on drm-next (fad06cf), where
drivers/gpu/drm/radeonbuilds without warnings (W=1, allmodconfig) both after patch 1 and with the whole series.Matheus Tagliari (2):
drm/radeon: process the VCE interrupt on SI and Trinity drm/radeon/vce1: enable the VCE trap interruptdrivers/gpu/drm/radeon/evergreen.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/si.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/sid.h | 2 ++ drivers/gpu/drm/radeon/vce_v1_0.c | 4 ++++ 4 files changed, 34 insertions(+)base-commit:
fad06cfaf385787b9ffa2f73f049d42dbe1de57f--
2.47.3
Quoted 16 lines · Christian König
[Adding Timur on CC]
Quoted 9 lines · Matheus Tagliari
Hardware H.264 encoding with the VCE block on SI GPUs (radeon driver) hangs the GPU after a few dozen frames. I hit it with the KDE Plasma RDP server, which encodes through VAAPI, and reproduced it with a plain "ffmpeg -vaapi_device ... -c:v
h264_vaapi" test on a Radeon HD 8870M (Cape Verde).The VCE1 code never enables the VCE trap interrupt and the SI (and Trinity) interrupt handlers do not process it, unlike the CIK code and amdgpu. Patch 1 adds the handlers, patch 2 enables the interrupt.
Oh, I do remember that I intentionally never enabled interrupts for VCE on radeon. But I honestly absolutely doesn't remember why (that was ~12-13 years ago!).
Quoted 7 lines
Timur hammered out most (all?) of the UVD/VCE bugs on SI, CIK and partially Polaris hardware as well for amdgpu and we are strongly considering just dropping SI/CIK support for radeon.
The fence handling on radeon should work completely without interrupts since those have been rather flaky on really old HW.
So no idea why that actually crashes for you if the interrupt is not enabled, my educated guess is that enabling interrupts actually doesn't fix the crash but makes it less likely because of timing change.
Would it be possible to just switch over to amdgpu instead? Or is there any support still missing there?
VCE1 was also on some older APUs that are radeon only.
Alex
Quoted 44 lines
Regards,
Christian.Quoted 39 lines
Results on Debian 6.12.113 (see patch 2 for numbers): hang before, none after, and 34 fps instead of ~4 fps for the workaround that avoids the hang. The KDE RDP server (KRDP) itself, driven by a local FreeRDP client, now encodes on the VCE ring for several minutes (about 40 fences per second on ring 6 in the
radeon_fence_emittracepoint) with a clean kernel log.Two caveats:
- I have not worked out why the missing interrupt turns into ring lockups instead of only added latency. What I know is that the hang needs the VCE ring to wait on a hardware semaphore (disabling only the waiting side, or both sides, of
radeon_vce_semaphore_emit()avoids it) and that handling the interrupt makes it go away with the semaphores left enabled. If someone knows why, I would be glad to improve the commit message.
- The Trinity/Richland change is compile tested only.The series was developed and tested on Debian's 6.12.113 with the radeon module built out of tree. It applies cleanly on drm-next (fad06cf), where
drivers/gpu/drm/radeonbuilds without warnings (W=1, allmodconfig) both after patch 1 and with the whole series.Matheus Tagliari (2):
drm/radeon: process the VCE interrupt on SI and Trinity drm/radeon/vce1: enable the VCE trap interruptdrivers/gpu/drm/radeon/evergreen.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/si.c | 14 ++++++++++++++ drivers/gpu/drm/radeon/sid.h | 2 ++ drivers/gpu/drm/radeon/vce_v1_0.c | 4 ++++ 4 files changed, 34 insertions(+)base-commit:
fad06cfaf385787b9ffa2f73f049d42dbe1de57f--
2.47.3
Quoted 9 lines · Christian König
The fence handling on radeon should work completely without interrupts since those have been rather flaky on really old HW.
So no idea why that actually crashes for you if the interrupt is not enabled, my educated guess is that enabling interrupts actually doesn't fix the crash but makes it less likely because of timing change.
Would it be possible to just switch over to amdgpu instead? Or is there any support still missing there?
Thanks for taking a look.
On the interrupt: I agree I have not shown why the hang happens, and a timing change is entirely possible. What I can say is limited to this:
- stock radeon: every encode hung within about 100 frames (many runs);
- with the VCE ring semaphores disabled: no hang, but fences are only noticed by the wait timeout, about 4 fps (~256 ms per frame);
- with the interrupt enabled and handled, semaphores left on: no hang in roughly ten minutes of total encode time (up to 1080p, plus several minutes of KDE's RDP server).
That is correlation, not a root cause. If it helps I can test enabling VCE_SYS_INT_EN without processing the fences from the handler, and run a long soak test with two concurrent encodes.
One difference that may be relevant: on CIK radeon does enable and process the VCE interrupt (vce_v2_0_resume() sets VCE_SYS_INT_EN and cik_irq_process() handles src_id 167). Only VCE1 (SI and Trinity) never did.
On amdgpu: it works for me, I found nothing missing for this use. I tested it on 7.2.9 and on Debian's 6.12.113 with the amdgpu VCE1 series
backported: h264_vaapi encodes up to 1080p with DPM and runtime PM enabled, no hangs.
The reason I looked at radeon at all is the distribution situation. Debian 13 stable ships 6.12, where SI is driven by radeon by default and amdgpu has no VCE1 support (that needs a newer kernel, which Debian only offers through backports). So anyone on the stable kernel who uses VAAPI encoding on an SI card, here through KDE's RDP server, ends up with a wedged GPU.
Since you are considering dropping SI/CIK from radeon, I do not want to push a change you don't want. If radeon keeps SI for the 6.x kernels, what would you prefer?
a) this series;
b) disable the VCE semaphores like uvd_v1_0 did in 013ead48a843 (works
here, but slow);
c) leave radeon alone and just document VCE encoding on SI with radeon as a known issue that amdgpu's VCE1 support in newer kernels supersedes (even a one-line warning pointing to amdgpu.si_support=1 would help people on 6.x).
I am fine with any of them, and if it is (c) please feel free to ignore the series. A v2 of patch 2 that fixes the CIK register issue found by the automated review is ready in case you want (a).
Regards,
Matheus
Christian König
maintainerQuoted 51 lines · Matheus Tagliari
Quoted 9 lines · Christian König
The fence handling on radeon should work completely without interrupts since those have been rather flaky on really old HW.
So no idea why that actually crashes for you if the interrupt is not enabled, my educated guess is that enabling interrupts actually doesn't fix the crash but makes it less likely because of timing change.
Would it be possible to just switch over to amdgpu instead? Or is there any support still missing there?
Thanks for taking a look.
On the interrupt: I agree I have not shown why the hang happens, and a timing change is entirely possible. What I can say is limited to this:
- stock radeon: every encode hung within about 100 frames (many runs);
- with the VCE ring semaphores disabled: no hang, but fences are only noticed by the wait timeout, about 4 fps (~256 ms per frame);
- with the interrupt enabled and handled, semaphores left on: no hang in roughly ten minutes of total encode time (up to 1080p, plus several minutes of KDE's RDP server).That is correlation, not a root cause. If it helps I can test enabling
VCE_SYS_INT_ENwithout processing the fences from the handler, and run a long soak test with two concurrent encodes.One difference that may be relevant: on CIK radeon does enable and process the VCE interrupt (
vce_v2_0_resume()setsVCE_SYS_INT_ENandcik_irq_process()handlessrc_id167). Only VCE1 (SI and Trinity) never did.On amdgpu: it works for me, I found nothing missing for this use. I tested it on 7.2.9 and on Debian's 6.12.113 with the amdgpu VCE1 series
backported:h264_vaapiencodes up to 1080p with DPM and runtime PM enabled, no hangs.The reason I looked at radeon at all is the distribution situation. Debian 13 stable ships 6.12, where SI is driven by radeon by default and amdgpu has no VCE1 support (that needs a newer kernel, which Debian only offers through backports). So anyone on the stable kernel who uses VAAPI encoding on an SI card, here through KDE's RDP server, ends up with a wedged GPU.
Since you are considering dropping SI/CIK from radeon, I do not want to push a change you don't want. If radeon keeps SI for the 6.x kernels, what would you prefer?
a) this series;
b) disable the VCE semaphores likeuvd_v1_0did in013ead48a843(workshere, but slow);
Quoted 8 lines
c) leave radeon alone and just document VCE encoding on SI with radeon as a known issue that amdgpu's VCE1 support in newer kernels supersedes (even a one-line warning pointing to amdgpu.si_support=1 would help people on 6.x).
I am fine with any of them, and if it is (c) please feel free to ignore the series. A v2 of patch 2 that fixes the CIK register issue found by the automated review is ready in case you want (a).
Yeah as Alex pointed out trinity is not supported by amdgpu and never will.
On the other hand that APU was the first one with VCE and I widely remember how buggy that HW was. So it is probably a wonder that this works in the first place.
I would say we take the patch and see. If anybody starts screaming we will probably just revert it immediately.
Problem is more than I have no time at all to wrap my head around that code again. @Timur can you do me a favor and take a look?
The radeon VCE code is basically the ancestor of the amdgpu VCE code.
Regards,
Christian.
Quoted 3 lines
Regards,
Matheus
Quoted 73 lines · On 2026. október 22., csütörtök 4:00:53 középső államokbeli zónaidő Christian…
Quoted 58 lines · Matheus Tagliari
Quoted 9 lines · Christian König
The fence handling on radeon should work completely without interrupts since those have been rather flaky on really old HW.
So no idea why that actually crashes for you if the interrupt is not enabled, my educated guess is that enabling interrupts actually doesn't fix the crash but makes it less likely because of timing change.
Would it be possible to just switch over to amdgpu instead? Or is there any support still missing there?
Thanks for taking a look.
On the interrupt: I agree I have not shown why the hang happens, and a
timing change is entirely possible. What I can say is limited to this:
- stock radeon: every encode hung within about 100 frames (many runs);
- with the VCE ring semaphores disabled: no hang, but fences are onlynoticed by the wait timeout, about 4 fps (~256 ms per frame);- with the interrupt enabled and handled, semaphores left on: no hang
in roughly ten minutes of total encode time (up to 1080p, plus several minutes of KDE's RDP server).
That is correlation, not a root cause. If it helps I can test enabling
VCE_SYS_INT_ENwithout processing the fences from the handler, and run a long soak test with two concurrent encodes.One difference that may be relevant: on CIK radeon does enable and process the VCE interrupt (
vce_v2_0_resume()setsVCE_SYS_INT_ENandcik_irq_process()handlessrc_id167). Only VCE1 (SI and Trinity) never did.On amdgpu: it works for me, I found nothing missing for this use. I tested it on 7.2.9 and on Debian's 6.12.113 with the amdgpu VCE1 series
backported:h264_vaapiencodes up to 1080p with DPM and runtime PM enabled, no hangs.The reason I looked at radeon at all is the distribution situation. Debian 13 stable ships 6.12, where SI is driven by radeon by default and amdgpu has no VCE1 support (that needs a newer kernel, which Debian only offers through backports). So anyone on the stable kernel who uses VAAPI encoding on an SI card, here through KDE's RDP server, ends up with a wedged GPU.
Since you are considering dropping SI/CIK from radeon, I do not want to push a change you don't want. If radeon keeps SI for the 6.x kernels, what would you prefer?
a) this series;
b) disable the VCE semaphores likeuvd_v1_0did in013ead48a843(workshere, but slow);c) leave radeon alone and just document VCE encoding on SI with radeon
Quoted 7 lines
as a known issue that amdgpu's VCE1 support in newer kernels supersedes (even a one-line warning pointing to amdgpu.si_support=1 would help people on 6.x).
I am fine with any of them, and if it is (c) please feel free to ignore the series. A v2 of patch 2 that fixes the CIK register issue found by the automated review is ready in case you want (a).
Yeah as Alex pointed out trinity is not supported by amdgpu and never will.
On the other hand that APU was the first one with VCE and I widely remember how buggy that HW was. So it is probably a wonder that this works in the first place.
Quoted 5 lines
I would say we take the patch and see. If anybody starts screaming we will probably just revert it immediately.
Problem is more than I have no time at all to wrap my head around that code again. @Timur can you do me a favor and take a look?
Hi,
I skimmed the series and it looks OK to me, though I don't have the energy to actually test the radeon KMD. My 20 cents say we should apply the series and see what happens. It won't impact any users who are already using amdgpu, but hopefully if we backport the series it will help users who are stuck on old distros like Matheus says, or old pre-GCN APUs.
Best regards,
Timur