Skip to content
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

staging: bcm2835-audio: Add missing MODULE_ALIAS #3681

Merged
merged 1 commit into from
Jun 24, 2020
Merged

staging: bcm2835-audio: Add missing MODULE_ALIAS #3681

merged 1 commit into from
Jun 24, 2020

Conversation

gentoo-root
Copy link
Contributor

After changes introduced by #3448, bcm2835-audio doesn't have modalias platform:bcm2835_audio anymore, but it's added as a platform device child of VCHIQ. It leads to a situation where snd_bcm2825 module is not probed on boot, even with dtparam=audio=on. The issue is fixed by this commit.

Commit 8353fe6 ("Revert "staging: bcm2835-audio: Drop DT
dependency"") reverts the upstream change and makes bcm2835-audio use
device tree again, however, it also removes the MODULE_ALIAS for the
platform device. This MODULE_ALIAS is needed, because VCHIQ registers
bcm2835-audio as a child platform device since commit 25c7597
("staging: vchiq_arm: Register a platform device for audio"), and this
mechanism is adopted also in the downstream kernel.

This commit puts back that MODULE_ALIAS to make bcm2835-audio
autoprobing work again. The rest of VCHIQ children have their
MODULE_ALIASes in place.

Fixes: 8353fe6 ("Revert "staging: bcm2835-audio: Drop DT dependency"")
Signed-off-by: Maxim Mikityanskiy <[email protected]>
@popcornmix
Copy link
Collaborator

@pelwell any objections?

@pelwell
Copy link
Contributor

pelwell commented Jun 23, 2020

I don't object to the alias being added again, but I'd like to understand why the driver is being loaded and probed in our builds via the DT MODALIAS ("MODALIAS=of:Nbcm2835_audioT(null)Cbrcm,bcm2835-audio") and not in @gentoo-root's. I've tested rpi-5.7.y in 32-bit and 64-bit configurations, and both work as expected.

@gentoo-root
Copy link
Contributor Author

the driver is being loaded and probed in our builds

That's weird.

If it's the matter of configuration, then it may be more correct to change (def)config, rather than add the upstream modalias.

Let's try to figure out what's the difference between our setups. I'm on 64-bit rpi-5.7.y, bcmrpi3_defconfig plus a few extra options that should not be relevant:

# Filesystems
CONFIG_SQUASHFS=y
CONFIG_BTRFS_FS=y
CONFIG_OVERLAY_FS=y

# wireless-regdb keys
CONFIG_CFG80211_CERTIFICATION_ONUS=y
CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=n
CONFIG_CFG80211_EXTRA_REGDB_KEYDIR="$WIRELESS_REGDB_CERTDIR"
CONFIG_CRYPTO_RSA=y
CONFIG_CRYPTO_SHA256=y

# Required by systemd
CONFIG_BPF_SYSCALL=y
CONFIG_CGROUP_BPF=y

# ARM64
CONFIG_CRYPTO_SHA256_ARM64=y
CONFIG_CRYPTO_SHA512_ARM64=m

# Bluetooth: device tree registration
CONFIG_SERIAL_DEV_BUS=y
CONFIG_SERIAL_DEV_CTRL_TTYPORT=y

If I remember correctly, it worked for me long ago on 5.0.y, but back then there weren't those upstream commits that make audio a platform device, so it makes sense.

I guess platform_uevent is the function that constructs the modalias for our audio driver. Now, here we register the audio as a platform device, and afterwards we assign of_node, so platform_device_register_full, which eventually calls device_add will not see of_node and will generate a uevent with modalias = platform:bcm2835_audio.

Now if I add some debugging to platform_uevent and to udev:

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b27d0f6c1..d1194d247 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1077,15 +1077,20 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
 
        /* Some devices have extra OF data and an OF-style MODALIAS */
        rc = of_device_uevent_modalias(dev, env);
-       if (rc != -ENODEV)
+       if (rc != -ENODEV) {
+               pr_info("%s: OF %px %s\n", __func__, dev, pdev->name);
                return rc;
+       }
 
        rc = acpi_device_uevent_modalias(dev, env);
-       if (rc != -ENODEV)
+       if (rc != -ENODEV) {
+               pr_info("%s: ACPI %px %s\n", __func__, dev, pdev->name);
                return rc;
+       }
 
        add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
                        pdev->name);
+       pr_info("%s: platform %px %s\n", __func__, dev, pdev->name);
        return 0;
 }
 
# /etc/udev/udev.conf
udev_log=debug
# /etc/udev/rules.d/00-debug.rules
ACTION=="add", ENV{MODALIAS}=="?*", RUN+="/usr/bin/logger -t udevdebug ADD modalias $env{MODALIAS}"
ACTION=="change", ENV{MODALIAS}=="?*", RUN+="/usr/bin/logger -t udevdebug CHANGE modalias $env{MODALIAS}"

I see that platform_uevent is actually called twice (second time it returns the OF modalias), but udev sees only one event:

# journalctl -a -o short-monotonic -b | grep -e 'udevdebug.*audio' -e 'platform_uevent.*audio' -e bcm2835_audio
[   15.507063] localhost kernel: platform_uevent: platform ffffff8015cc0010 bcm2835_audio
[   17.840336] localhost kernel: platform_uevent: OF ffffff8015cc0010 bcm2835_audio
[   17.920540] localhost systemd-udevd[169]: bcm2835_audio: Device (SEQNUM=1219, ACTION=add) is queued
[   17.920959] localhost systemd-udevd[169]: bcm2835_audio: sd-device-monitor: Passed 201 byte to netlink monitor
[   17.942534] localhost systemd-udevd[177]: bcm2835_audio: Processing device (SEQNUM=1219, ACTION=add)
[   18.046822] localhost systemd-udevd[177]: bcm2835_audio: RUN '/usr/bin/logger -t udevdebug ADD modalias $env{MODALIAS}' /etc/udev/rules.d
/00-debug.rules:1
[   18.047339] localhost systemd-udevd[177]: bcm2835_audio: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:14
[   18.057247] localhost udevdebug[259]: ADD modalias platform:bcm2835_audio
[   18.136504] localhost systemd-udevd[177]: bcm2835_audio: No entry found from hwdb.
[   18.137063] localhost systemd-udevd[177]: bcm2835_audio: IMPORT builtin 'hwdb' fails: No data available
[   18.137692] localhost systemd-udevd[177]: bcm2835_audio: RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
[   18.138299] localhost systemd-udevd[177]: Starting '/usr/bin/logger -t udevdebug ADD modalias platform:bcm2835_audio'
[   18.147093] localhost systemd-udevd[177]: Process '/usr/bin/logger -t udevdebug ADD modalias platform:bcm2835_audio' succeeded.
[   18.147506] localhost systemd-udevd[177]: Loading module: platform:bcm2835_audio
[   18.147909] localhost systemd-udevd[177]: Failed to find module 'platform:bcm2835_audio'
[   18.148380] localhost systemd-udevd[177]: bcm2835_audio: Device (SEQNUM=1219, ACTION=add) processed
[   18.148800] localhost systemd-udevd[177]: bcm2835_audio: sd-device-monitor: Passed 201 byte to netlink monitor

If you could get similar udev logs, that would be wonderful. It would help us find out what events udev reacts to on your system and compare to mine.

It might also happen that you have some hacks in udev rules and scripts like this. I don't have any udev rules from Raspbian on my system — only the standard set shipped with udev. Choosing between such modprobe hack and the proper modalias in the kernel, the latter looks more correct.

@pelwell
Copy link
Contributor

pelwell commented Jun 24, 2020

This is the result on my system. Note that I extended the platform_uevent logging to also display the name of the calling process when the device is bcm2835_audio.

[    1.500942] raspberrypi kernel: platform_uevent: platform ffffff80f5fba810 bcm2835_audio
[    1.503244] raspberrypi kernel: [ Process swapper/0 ]
[    5.872694] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    5.872706] raspberrypi kernel: [ Process udevadm ]
[    6.092646] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    6.092655] raspberrypi kernel: [ Process udevadm ]
[    7.460721] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    7.460734] raspberrypi kernel: [ Process systemd-udevd ]
[    7.549204] raspberrypi systemd-udevd[151]: bcm2835_audio: Device (SEQNUM=1202, ACTION=add) is queued
[    7.549817] raspberrypi udevdebug[220]: ADD modalias of:Nbcm2835_audioT(null)Cbrcm,bcm2835-audio
[    7.632701] raspberrypi kernel: bcm2835_audio bcm2835_audio: card created with 4 channels
[    7.637260] raspberrypi kernel: bcm2835_audio bcm2835_audio: card created with 4 channels
[    7.637409] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    7.637419] raspberrypi kernel: [ Process systemd-udevd ]
[    7.637433] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    7.637445] raspberrypi kernel: [ Process systemd-journal ]
[    7.639081] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    7.639094] raspberrypi kernel: [ Process systemd-journal ]
[    7.646465] raspberrypi systemd-udevd[151]: bcm2835_audio: sd-device-monitor: Passed 357 byte to netlink monitor
[    7.661399] raspberrypi systemd-udevd[161]: bcm2835_audio: Processing device (SEQNUM=1202, ACTION=add)
[    7.663915] raspberrypi systemd-udevd[161]: bcm2835_audio: RUN '/usr/bin/logger -t udevdebug ADD modalias $env{MODALIAS}' /etc/udev/rules.d/00-debug.rules:1
[    7.666072] raspberrypi systemd-udevd[161]: bcm2835_audio: IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:14
[    7.667401] raspberrypi systemd-udevd[161]: bcm2835_audio: No entry found from hwdb.
[    7.668175] raspberrypi systemd-udevd[161]: bcm2835_audio: IMPORT builtin 'hwdb' fails: No data available
[    7.668715] raspberrypi systemd-udevd[161]: bcm2835_audio: RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
[    7.670503] raspberrypi systemd-udevd[161]: Starting '/usr/bin/logger -t udevdebug ADD modalias of:Nbcm2835_audioT(null)Cbrcm,bcm2835-audio'
[    7.774044] raspberrypi systemd-udevd[161]: Process '/usr/bin/logger -t udevdebug ADD modalias of:Nbcm2835_audioT(null)Cbrcm,bcm2835-audio' succeeded.
[    7.775828] raspberrypi systemd-udevd[161]: Loading module: of:Nbcm2835_audioT(null)Cbrcm,bcm2835-audio
[    7.840529] raspberrypi systemd-udevd[161]: bcm2835_audio: Device (SEQNUM=1202, ACTION=add) processed
[    7.842911] raspberrypi systemd-udevd[161]: bcm2835_audio: sd-device-monitor: Passed 357 byte to netlink monitor
[    9.652029] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    9.652046] raspberrypi kernel: [ Process systemd-udevd ]
[    9.659270] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[    9.659287] raspberrypi kernel: [ Process systemd-udevd ]
[   10.036868] raspberrypi systemd-udevd[151]: bcm2835_audio: Device (SEQNUM=1454, ACTION=bind) is queued
[   10.037387] raspberrypi systemd-udevd[151]: bcm2835_audio: Device (SEQNUM=1455, ACTION=add) is queued
[   10.038322] raspberrypi systemd-udevd[151]: bcm2835_audio: sd-device-monitor: Passed 150 byte to netlink monitor
[   10.039248] raspberrypi systemd-udevd[157]: bcm2835_audio: Processing device (SEQNUM=1455, ACTION=add)
[   10.043720] raspberrypi systemd-udevd[157]: bcm2835_audio: Device (SEQNUM=1455, ACTION=add) processed
[   10.044362] raspberrypi systemd-udevd[157]: bcm2835_audio: sd-device-monitor: Passed 150 byte to netlink monitor
[   10.044938] raspberrypi systemd-udevd[174]: card0: sd-device: Created db file '/run/udev/data/+sound:card0' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0'
[   10.076778] raspberrypi systemd-udevd[166]: card1: sd-device: Created db file '/run/udev/data/+sound:card1' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card1'
[   10.128201] raspberrypi systemd-udevd[174]: controlC0: LINK 'snd/by-path/platform-bcm2835_audio' /lib/udev/rules.d/60-persistent-alsa.rules:12
[   10.157251] raspberrypi systemd-udevd[157]: pcmC0D0p: sd-device: Created db file '/run/udev/data/c116:16' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0/pcmC0D0p'
[   10.158522] raspberrypi systemd-udevd[174]: controlC0: ATTR '/sys/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0/controlC0/../uevent' writing 'change' /lib/udev/rules.d/78-sound-card.rules:5
[   10.171827] raspberrypi systemd-udevd[166]: pcmC1D0p: sd-device: Created db file '/run/udev/data/c116:48' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card1/pcmC1D0p'
[   10.173427] raspberrypi systemd-udevd[174]: controlC0: Creating symlink '/dev/snd/by-path/platform-bcm2835_audio' to '../controlC0'
[   10.173695] raspberrypi systemd-udevd[174]: controlC0: sd-device: Created db file '/run/udev/data/c116:0' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0/controlC0'
[   10.176111] raspberrypi systemd-udevd[157]: controlC1: LINK 'snd/by-path/platform-bcm2835_audio' /lib/udev/rules.d/60-persistent-alsa.rules:12
[   10.179278] raspberrypi systemd-udevd[157]: controlC1: ATTR '/sys/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card1/controlC1/../uevent' writing 'change' /lib/udev/rules.d/78-sound-card.rules:5
[   10.271878] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[   10.271886] raspberrypi kernel: [ Process systemd-udevd ]
[   10.265574] raspberrypi systemd-udevd[157]: controlC1: Found 'c116:0' claiming '/run/udev/links/\x2fsnd\x2fby-path\x2fplatform-bcm2835_audio'
[   10.266708] raspberrypi systemd-udevd[157]: controlC1: Atomically replace '/dev/snd/by-path/platform-bcm2835_audio'
[   10.267828] raspberrypi systemd-udevd[157]: controlC1: sd-device: Created db file '/run/udev/data/c116:32' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card1/controlC1'
[   10.274773] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[   10.274780] raspberrypi kernel: [ Process systemd-udevd ]
[   10.282801] raspberrypi kernel: platform_uevent: OF ffffff80f5f86e00 bcm2835_audio
[   10.282809] raspberrypi kernel: [ Process systemd-udevd ]
[   10.341001] raspberrypi systemd-udevd[157]: bcm2835_audio: Processing device (SEQNUM=1454, ACTION=bind)
[   10.341347] raspberrypi systemd-udevd[157]: bcm2835_audio: IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:14
[   10.341558] raspberrypi systemd-udevd[157]: bcm2835_audio: No entry found from hwdb.
[   10.341762] raspberrypi systemd-udevd[157]: bcm2835_audio: IMPORT builtin 'hwdb' fails: No data available
[   10.341968] raspberrypi systemd-udevd[157]: bcm2835_audio: Device (SEQNUM=1454, ACTION=bind) processed
[   10.342158] raspberrypi systemd-udevd[157]: bcm2835_audio: sd-device-monitor: Passed 367 byte to netlink monitor
[   10.342344] raspberrypi systemd-udevd[151]: bcm2835_audio: sd-device-monitor: Passed 366 byte to netlink monitor
[   10.343865] raspberrypi systemd-udevd[157]: card0: sd-device: Created db file '/run/udev/data/+sound:card0' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0'
[   10.350514] raspberrypi systemd-udevd[155]: card1: sd-device: Created db file '/run/udev/data/+sound:card1' for '/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card1'

What you see is the initial platform alias, then 11 OF aliases, apparently triggered as the result of udevadm, systemd-udevd and systemd-journal running. Reverting the logging changes doesn't reduce this count.

Adding the platform alias doesn't change where the probe occurs for me, but it is clearly the right thing to do in general.

@pelwell pelwell merged commit 0551425 into raspberrypi:rpi-5.7.y Jun 24, 2020
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Jun 26, 2020
kernel: brcmfmac: Prefer a ccode from OTP over nvram file

kernel: staging: bcm2835-audio: Add missing MODULE_ALIAS
See: raspberrypi/linux#3681

kernel: IRS1125 sensor driver updates
See: raspberrypi/linux#3544

kernel: Revert downstream SPI patches
See: raspberrypi/linux#3687

kernel: PCI: brcmstb: Add DT property to control L1SS

firmware: hdmi: Set HD_CTL_WHOLSMP and HD_CTL_CHALIGN_SET
See: https://forum.kodi.tv/showthread.php?tid=354589

firmware: arm_ldconfig: Honour the kernel8 text offset
See: #1415

firmware: jpeghw: Skip repeated 0xFF padding bytes between markers
See: RPi-Distro/vlc#8

filesystem: Add support for SD cards with GPT partition table
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Jun 26, 2020
kernel: brcmfmac: Prefer a ccode from OTP over nvram file

kernel: staging: bcm2835-audio: Add missing MODULE_ALIAS
See: raspberrypi/linux#3681

kernel: IRS1125 sensor driver updates
See: raspberrypi/linux#3544

kernel: Revert downstream SPI patches
See: raspberrypi/linux#3687

kernel: PCI: brcmstb: Add DT property to control L1SS

firmware: hdmi: Set HD_CTL_WHOLSMP and HD_CTL_CHALIGN_SET
See: https://forum.kodi.tv/showthread.php?tid=354589

firmware: arm_ldconfig: Honour the kernel8 text offset
See: raspberrypi/firmware#1415

firmware: jpeghw: Skip repeated 0xFF padding bytes between markers
See: RPi-Distro/vlc#8

filesystem: Add support for SD cards with GPT partition table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants