#985928 linux-image-5.10.0-5-rt-arm64: vc4.ko brings unusable&unstable ALSA sinks

Package:
src:linux
Source:
linux
Submitter:
Ryutaroh Matsumoto
Date:
2021-03-28 23:21:03 UTC
Severity:
normal
Tags:
#985928#5
Date:
2021-03-26 09:01:09 UTC
From:
To:
Dear Maintainer,

Copied from http://lists.infradead.org/pipermail/linux-rpi-kernel/2021-March/008071.html


This is again an issue regarding on vc4.ko.
This is observed both on the plain upstream kernel 5.10.24 and
the latest Raspberry Pi OS kernel 5.10.17.

With vc4.ko, ALSA devices vc4-hdmi-[01] are brought as the bottom of this email.
aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=vc4hdmi[01]
gives no effect/sound (even on Raspberry Pi OS).
In addition, touching vc-hdmi-[01] ALSA devices cause lots of kernel error messages

bcm2835_audio bcm2835_audio: vchi message timeout
vc4_hdmi fef05700.hdmi: ASoC: error at snd_soc_dai_startup on fef05700.hdmi: -19

Touching vc4-hdmi-[01] too many times makes the kernel unstable,
and shutting down often needs several minutes.

/usr/bin/pulseaudio in its default setting touches all available  ALSA sinks
and causes the above inconvenience.

I mainly use HDMI audio output, and

plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions

is sufficient for my audio playing. For pulseaudio, I am using
load-module module-alsa-sink device=hw:2,1
and commenting out
#load-module module-udev-detect
#load-module module-detect

I wonder what is intended use of vc4-hdmi-[01] ALSA sinks,
which seems only bringing inconvenience and unstability...

The Debian package versions are as follows:
# dpkg-query -W | egrep linux-image\|firmware
bluez-firmware	1.2-4
firmware-brcm80211	20210315-1
firmware-linux-free	20200122-1
firmware-misc-nonfree	20210315-1
linux-image-5.10.0-5-rt-arm64	5.10.24-1
linux-image-rt-arm64	5.10.24-1
raspi-firmware	1.20210111+ds-2


# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM vc4-hdmi-hifi-0 [MAI PCM vc4-hdmi-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM vc4-hdmi-hifi-0 [MAI PCM vc4-hdmi-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 2: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default Audio Device
sysdefault
    Default Audio Device
iec958
    IEC958 (S/PDIF) Digital Audio Output
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Hardware device with all software conversions
default:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
front:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Front output / input
iec958:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
    Direct sample mixing device
usbstream:CARD=vc4hdmi0
    vc4-hdmi-0
    USB Stream Output
hw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Hardware device with all software conversions
default:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
front:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Front output / input
iec958:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM vc4-hdmi-hifi-0
    Direct sample mixing device
usbstream:CARD=vc4hdmi1
    vc4-hdmi-1
    USB Stream Output
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
default:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
usbstream:CARD=ALSA
    bcm2835 ALSA
    USB Stream Output

Best regards, Ryutaroh Matsumoto

#985928#12
Date:
2021-03-27 00:59:02 UTC
From:
To:
From: Ryutaroh Matsumoto <ryutaroh@ict.e.titech.ac.jp>
Subject: vc4.ko brings unusable&unstable ALSA sinks
Date: Fri, 26 Mar 2021 17:15:40 +0900 (JST)

In my last email, a pointed reproducing procedure should have been given:

0. Assume an RPi4B and a high resolution HDMI display.
1. Install pulseaudio on a sensible distro with the upstream kernel and systemd,
    e.g.  https://raspi.debian.net
2. Make a non-root user and login as that user.
3. Run the following script by the non-root user:
#!/bin/sh
set -x
while true; do
  systemctl --user status pulseaudio
  pacmd list-sinks
  pacmd exit
  systemctl --user restart pulseaudio
done

Then every command in the above script gets stuck or fails.

I also prepared an SD card image that can reproduce the reported symptom
on RPi4B 8GB at http://153.240.174.134:64193/tmp/sdimage8GB.img.xz
(268,112,012 bytes).

Best regards, Ryutaroh

#985928#17
Date:
2021-03-28 00:48:59 UTC
From:
To:
Hi all,

From: Stefan Wahren <stefan.wahren@i2se.com>
Subject: Re: Sound issues with the 5.10.x kernel (alsa)
Date: Mon, 8 Feb 2021 13:22:56 +0100

I think the root cause of this issue is that both vc4.ko and snd_bcm2835.ko
try to provide ALSA sinks to HDMI audio outputs from RPi.
Why do the two drivers provide the same functionality for the same device?
It seems nonsense.
There must be some coordination between vc4.ko and snd_bcm2835.ko
on who provides ALSA sinks of RPi HDMI output.

The non-coordination that both drivers provide different ALSA sinks of the same
device already causes another symptom as
http://lists.infradead.org/pipermail/linux-rpi-kernel/2021-March/008077.html

Best regards, Ryutaroh Matsumoto

#985928#22
Date:
2021-03-28 05:58:13 UTC
From:
To:
Giving "enable_hdmi=0" to snd_bcm2835.ko does not improve the situation,
while module_blacklisting snd_bcm2835 suppresses all the symptoms reported.
snd_bcm2835.ko in 5.10.24 seems having a bug ignoring "enable_hdmi=0".

Best regards, Ryutaroh

#985928#27
Date:
2021-03-28 09:29:12 UTC
From:
To:
Hi,

Am 28.03.21 um 07:58 schrieb Ryutaroh Matsumoto:
i assume you set this option in the config.txt? This shouldn't have any
affect for the mainline kernel / DT.

#985928#32
Date:
2021-03-28 23:13:25 UTC
From:
To:
Hi Stefan, thank you for your response.

I am aware of that...
I did "snd_bcm2835 enable_hdmi=0" in /etc/modules.
"modinfo snd_bcm2835" shows as below. Doesn't it indicate snd_bcm2835 having
an option enable_hdmi???

It seems that the contention of grabbing HDMI audio output between vc4.ko
and snd_bcm2835.ko can be addressed if snd_bcm2835.ko honors the
option enable_hdmi with its default =0, but currently enable_hdmi seems
having no effect in behavior of snd_bcm2835...

# modinfo snd_bcm2835
filename:       /lib/modules/5.10.0-5-rt-arm64/kernel/drivers/staging/vc04_services/bcm2835-audio/snd-bcm2835.ko
alias:          platform:bcm2835_audio
license:        GPL
description:    Alsa driver for BCM2835 chip
author:         Dom Cobley
depends:        snd-pcm,vchiq,snd
staging:        Y
intree:         Y
name:           snd_bcm2835
vermagic:       5.10.0-5-rt-arm64 SMP preempt_rt mod_unload modversions aarch64
sig_id:         PKCS#7
signer:         Debian Secure Boot CA
sig_key:        4B:6E:F5:AB:CA:66:98:25:17:8E:05:2C:84:66:7C:CB:C0:53:1F:8C
sig_hashalgo:   sha256
signature:      omitted, too long.
parm:           force_bulk:Force use of vchiq bulk for audio (bool)
parm:           enable_hdmi:Enables HDMI virtual audio device (bool)
parm:           enable_headphones:Enables Headphones virtual audio device (bool)
parm:           enable_compat_alsa:Enables ALSA compatibility virtual audio device (bool)
parm:           num_channels:Number of audio channels (default: 8) (int)

Best regards, Ryutaroh

#985928#37
Date:
2021-03-28 23:17:36 UTC
From:
To:
I include my config.txt on RPi4B for reference...
arm_64bit=1
enable_uart=1
upstream_kernel=1
kernel=vmlinuz-5.10.0-5-rt-arm64
initramfs initrd.img-5.10.0-5-rt-arm64
disable_fw_kms_setup=1
disable_overscan=1
hdmi_enable_4kp60=1

Best regards, Ryutaroh Matsumoto