-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rockchip/64: fix pl330 cyclic dma transfers #7695
base: main
Are you sure you want to change the base?
rockchip/64: fix pl330 cyclic dma transfers #7695
Conversation
I move this to draft, there seems more involved into and I want to dig deeper... |
Ok some updates about this. I can confirm the pl330 driver in mainline kernel handles the cyclic/periodic dma transfers in a non optimal way; from what I could understand, the periodic transfers of buffers can be handled by the DMA controller itself if instructed to do so, but currently they are managed when IRQ triggers by the kernel. The kernel has to handle the IRQ and "rearm" the DMA controller to repeat the transfer and, under heavy load, this takes a bit of time that causes the audio to click, pop and buzz. Also it is less efficient because it makes the IRQ handling by the kernel longer. Latest rockchip vendor kernel (hosted on Radxa github), contains some enhancements and features (I see scatter/gather and interleaved transfers) to pl330 driver, since the DMA controller itself is actually a microcontroller on its own; more than that, the driver works perfectly as a drop-in replacement in the mainline kernel. The |
49714eb
to
40214ec
Compare
40214ec
to
1807020
Compare
Update: after some checks and online research, I found that several patches were already supplied to the kernel mailing lists and have never been accepted or are waiting in line. I provide a set of 5 patches:
Tests have been made on all the board mentioned in the main comment so far; all the boards boots fine and dmesg are clean. To give an idea of the problem and the solution, these two are the recordings from the analog output of an Orange PI 4 LTS boards. This is the recording with the patch applied and kernel 6.12: And this is the recording with vanilla pl330 driver and kernel 6.6 (fresh official debian minimal image): Tests were run with I remove the draft status for the Pull Request, this applies to rockchip and rockchip64 families and for both current and edge kernels. Current 6.12 kernel was tested, edge wasn't. |
Description
PL330 DMA controller driver in mainline kernel is suboptimal; according to this patch, the driver can be modified to make it more efficient and stable.
This inefficiency causes ALL rockchip SoCs I tested (rk3228, rk3308, rk3328 and rk3399) to produce pops and clicks when playing through I²S (ie: analog or HDMI) or SPDIF outputs even with modest load on memory subsystem, but the DMA controller also serves UART, SPI bus, CAN bus, PWMs, and some other device... so possibly the DMA issues of the mainline driver can affect several other areas, sound is just the most evident one.
In my case, I can steadily reproduce the problem on all the mentioned SoCs this way:
aplay
,ogg123
or whatever. The issue appears more prominent if at high samplerates (>= 96khz)mbw
, tying the process to a core which is not the same core handling DMA controller interruptsAn example:
This PR takes the patch above and applies to kernel 6.12 (current) and 6.13 (edge) for both rockchip and rockchip64 families.
After the patch, the issue is much more reduced, but not totally cancelled yet, because if you add a third
iperf3
process to the mix, the clicks and pops still appears (at least on rk3308):Nonetheless, this is a first step that will address the common scenario with "regular" workloads and is probably a good idea to bring in this fix until I progress in completely fixing the issue. As a note, the rockchip vendor 4.4 kernel on rk3308 does not show any issue.
I don't know if rk356x and rk3588 also are affected, but since they use pl330 DMA controllers as well, I guess the issues can appear there too. Other possibly affected SoC may be some Samsung Exynos SoCs.
SPDIF
maxburst
parameter is also increased from4
to8
words, as it is in the vendor kernel.GitHub issue reference:
Jira reference number AR-2584
How Has This Been Tested?
ogg123
+mbw
has been done to verify there were no artifacts in analog and SPDIF audioChecklist:
Please delete options that are not relevant.