AsahiLinux / asahi-audio

Userspace audio for Asahi Linux
MIT License
128 stars 12 forks source link

ALSA PCM preallocation failures #4

Closed mxw39 closed 1 year ago

mxw39 commented 2 years ago

Thanks for the great work on asahi-audio!

My machine (j316) sees occasional failures playing back audio and it seems to relate to ALSA and memory allocation. When I get ALSA pcmC0D0p,0:: cannot preallocate for size 3145728 in the kernel messages the audio stack will not play anything. Rebooting does not solve the problem deterministically but can work from time to time.

Can you point me to the right place to start debugging?


Some relevant lines from the kernel message attached.

$ dmesg | grep -E 'snd|ALSA' -B2 -A2
[    0.102655] Key type fscrypt-provisioning registered
[    0.102760] Key type encrypted registered
[    0.386256] ALSA device list:
[    0.386258]   No soundcards found.
[    0.386325] Freeing unused kernel memory: 960K
--
[    1.653343] hub 6-0:1.0: USB hub found
[    1.653346] hub 6-0:1.0: 1 port detected
[    1.705670] snd-soc-apple-macaudio sound: visiting control Left Woofer 1 Speaker Volume, have match 0
[    1.705675] snd-soc-apple-macaudio sound: visiting control Left Woofer 1 Amp Gain Volume, have match 0
[    1.763059] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4387c2-pcie for chip BCM4387/7
[    1.764486] brcmfmac 0000:01:00.0: Direct firmware load for brcm/brcmfmac4387c2-pcie.apple,madagascar-TPHN-u-4.7-X0.bin failed with error -2
--
[    1.764794] brcmfmac 0000:01:00.0: Direct firmware load for brcm/brcmfmac4387c2-pcie.apple,madagascar-TPHN.bin failed with error -2
[    1.764830] brcmfmac 0000:01:00.0: Direct firmware load for brcm/brcmfmac4387c2-pcie.apple,madagascar-X0.bin failed with error -2
[    1.797676] snd-soc-apple-macaudio sound: visiting control Right Woofer 1 Speaker Volume, have match 0
[    1.797683] snd-soc-apple-macaudio sound: visiting control Right Woofer 1 Amp Gain Volume, have match 0
[    1.891677] snd-soc-apple-macaudio sound: visiting control Left Tweeter Speaker Volume, have match 0
[    1.891681] snd-soc-apple-macaudio sound: visiting control Left Tweeter Amp Gain Volume, have match 0
[    1.983674] snd-soc-apple-macaudio sound: visiting control Right Tweeter Speaker Volume, have match 0
[    1.983680] snd-soc-apple-macaudio sound: visiting control Right Tweeter Amp Gain Volume, have match 0
[    2.044102] EXT4-fs (nvme0n1p7): re-mounted. Quota mode: none.
[    2.073551] Adding 15625200k swap on /dev/nvme0n1p6.  Priority:-2 extents:1 across:15625200k SSFS
[    2.074963] Adding 33554416k swap on /var/32G-swapfile.  Priority:-3 extents:224 across:363413504k SSFS
[    2.096682] snd-soc-apple-macaudio sound: visiting control Left Woofer 2 Speaker Volume, have match 0
[    2.096687] snd-soc-apple-macaudio sound: visiting control Left Woofer 2 Amp Gain Volume, have match 0
[    2.212667] snd-soc-apple-macaudio sound: visiting control Right Woofer 2 Speaker Volume, have match 0
[    2.212674] snd-soc-apple-macaudio sound: visiting control Right Woofer 2 Amp Gain Volume, have match 0
[    2.212692] tas2764 1-0038: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.216665] tas2764 2-003b: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.220671] tas2764 1-003a: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.223668] tas2764 2-003d: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.226695] tas2764 1-0039: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.229672] tas2764 2-003c: ASoC: error at snd_soc_dai_set_tdm_slot on tas2764 ASI1: -22
[    2.354331] elogind-daemon[2018]: New seat seat0.
[    2.417695] ALSA pcmC0D0p,0:: cannot preallocate for size 3145728
[    2.417744] snd-soc-apple-macaudio sound: N cpus to M codecs link is not supported yet
[    2.417763] snd-soc-apple-macaudio sound: visiting control Left Woofer 1 ASI1 Sel, have match 1
[    2.417778] snd-soc-apple-macaudio sound: visiting control Left Woofer 1 ISENSE Switch, have match 0
[    2.417797] snd-soc-apple-macaudio sound: visiting control Left Woofer 1 VSENSE Switch, have match 0
[    2.417810] snd-soc-apple-macaudio sound: visiting control Right Woofer 1 ASI1 Sel, have match 1
[    2.417820] snd-soc-apple-macaudio sound: visiting control Right Woofer 1 ISENSE Switch, have match 0
[    2.417832] snd-soc-apple-macaudio sound: visiting control Right Woofer 1 VSENSE Switch, have match 0
[    2.417843] snd-soc-apple-macaudio sound: visiting control Left Tweeter ASI1 Sel, have match 1
[    2.417853] snd-soc-apple-macaudio sound: visiting control Left Tweeter ISENSE Switch, have match 0
[    2.417866] snd-soc-apple-macaudio sound: visiting control Left Tweeter VSENSE Switch, have match 0
[    2.417877] snd-soc-apple-macaudio sound: visiting control Right Tweeter ASI1 Sel, have match 1
[    2.417889] snd-soc-apple-macaudio sound: visiting control Right Tweeter ISENSE Switch, have match 0
[    2.417903] snd-soc-apple-macaudio sound: visiting control Right Tweeter VSENSE Switch, have match 0
[    2.417916] snd-soc-apple-macaudio sound: visiting control Left Woofer 2 ASI1 Sel, have match 1
[    2.417929] snd-soc-apple-macaudio sound: visiting control Left Woofer 2 ISENSE Switch, have match 0
[    2.417940] snd-soc-apple-macaudio sound: visiting control Left Woofer 2 VSENSE Switch, have match 0
[    2.417952] snd-soc-apple-macaudio sound: visiting control Right Woofer 2 ASI1 Sel, have match 1
[    2.417962] snd-soc-apple-macaudio sound: visiting control Right Woofer 2 ISENSE Switch, have match 0
[    2.417974] snd-soc-apple-macaudio sound: visiting control Right Woofer 2 VSENSE Switch, have match 0
[    2.440689] snd-soc-apple-macaudio sound: set 'Left Woofer 1 ASI1 Sel' to 'Left'
[    2.443685] snd-soc-apple-macaudio sound: set 'Right Woofer 1 ASI1 Sel' to 'Left'
[    2.446680] snd-soc-apple-macaudio sound: set 'Left Tweeter ASI1 Sel' to 'Left'
[    2.449684] snd-soc-apple-macaudio sound: set 'Right Tweeter ASI1 Sel' to 'Left'
[    2.452680] snd-soc-apple-macaudio sound: set 'Left Woofer 2 ASI1 Sel' to 'Left'
[    2.455683] snd-soc-apple-macaudio sound: set 'Right Woofer 2 ASI1 Sel' to 'Left'
[    2.455934] input: MacBook Pro J314/6 integrated a Headphones as /devices/platform/sound/sound/card0/input5
[    2.540381] bpfilter: Loaded bpfilter_umh pid 2332
chadmed commented 2 years ago

I tried debugging this a little while ago to no avail. Since I don't have a j316s, I can't really give you any specific pointers for things to try. Being a kernel problem it's kind of outside of my remit anyway. I would assume that there's a timing bug where the driver is trying to configure the hardware before it's ready to go or something.

mxw39 commented 2 years ago

I would assume that there's a timing bug where the driver is trying to configure the hardware before it's ready to go or something.

Thanks! This is helpful info anyway. I can poke at the kernel side.