Created attachment 306856 [details] acpidump Hi folks, I am running Fedora 40 with kernel 6.11.0-0.rc6.348.vanilla.fc40.x86_64 on Lenovo ThinkBook 13x G4 that has c3541l amplifier and get distorted sound from time to time that mostly goes away on its own after stop / play cycle. I also noticed that the issue is easier to trigger when I am running a bunch of tests in my app that uses ALSA, the distortion appears after a few snd_pcm_prepare/snd_pcm_start cycles regardless of the hardware configuration passed (gtest scenarios for my app). Re-init the hardware (snd_pcm_drain/drop->snd_pcm_prepare->snd_pcm_start) usually fixes the issue until next time. I see that there were some sync difficulties with mdsync_up_seq in cs35l41,described in commit 77bf613f0bf08c021309cdb5f84b5f630b829261, so I wonder if you folks familiar with the hardware can see any potential race condition/edge case in the synchronization mechanism? There were previously errors related to firmware failing to load about the time when the distortion was happening but those are now gone in 6.11rc6: https://github.com/craigcabrey/thinkbook-13x-gen4-enablement/issues/9 Thanks!
Hi, Can you provide the set of steps that you say is able to trigger this issue? Also, can you attach a full dmesg log - from boot to when you hit the issue? Thanks, Stefan
Created attachment 306866 [details] bug_repro.cpp A code snippet to reproduce the issue, distortion happens usually ~round 5 and 6 of the playback.
Created attachment 306867 [details] dmesg.txt
I have attached a short snippet (well, as short as it could be with ALSA) to reproduce the problem. The actual scenario is whenever you repeatedly do the following after setting up ALSA device: 1. snd_pcm_prepare 2. Play fragment (write data with writei or use mmap - doesn't matter) 3. snd_pcm_drain / snd_pcm_drop, then repeat from step 1. Full close / open and re-init of the hardware doesn't have the issue. The repro rate on the test code is ~2/10.
Hi, Is it possible for you to make an audio recording or video when this issue is reproduced? I noticed that your script generates a full scale sine wave, have you tested this at a lower scale? Do you see this issue with different frequencies? Are you running this at full volume, and do you see differences if you change the volume? Thanks, Stefan
Please find the recordings for both the test code attached to the ticket and music fragment played (seeking triggers snd_pcm_prepeare / snd_pcm_start cycle, without format change). https://www.dropbox.com/scl/fo/gvx28987cw6cqcscqfoiv/AMpEekbmVznS_6Dt7DSGjjE?rlkey=y91q9ar6aam3e0xlojzmq3ni6&st=bnim1ggo&dl=0 I use the full scale 440Hz sine wave just for the testing purposes (on the video it was reduced to a half), the issue happens with more complex signal too (i.e. speech or music), i.g. when watching youtube, for example. Reducing the amplitude of the signal doesn't make any difference. I must note, that when playing through pipewire-alsa layer the issue appears significantly less often, however, even in this case I managed to catch it a few times, although did not record. I am not quite sure what this distortion is but it sounds like DSP has some weird gain settings randomly. The overall volume doesn't increase at these moments but some of the frequencies are clearly too loud. Just to note, the issue equally happens when listening through the headphones plugged into the 3.5mm port on side of the laptop which (mechanically) turns of the laptop speakers but doesn't happen when connecting bluetooth headphones.
Hm... Interesting. When facing the issue in the headphones disconnecting them from the port makes the sound clear in the speakers, plugging the headphones back in brings back the distortion. Can't reproduce it when tried the second time. I wonder if that could be the laptop defect as well, I've found a few similar reports with Lenovo laptops but those were inconclusive of the root-cause of the issue. ``` g++ bug_repro.cpp -lasound -o bug_repro ```
Looks like a few similar issues in SOF were discussed and marked as fixes as late as March this year. The scenario described is exactly what I am experiencing. https://github.com/thesofproject/sof/issues/8986
Opened a new issue: https://github.com/thesofproject/sof/issues/9502
The fix has been merged last month. Checked that the issue is not happening anymore Fedora 41 release. https://github.com/thesofproject/linux/pull/5197