Skip to content
Snippets Groups Projects
Commit 390518a2 authored by Sebastian Krzyszkowiak's avatar Sebastian Krzyszkowiak
Browse files

defaults: Improve reliability of bluetooth-brcmfmac against system suspend


hciattach isn't aware that the card gets reset at system suspend, requiring
full reinitialization, so it needs to be restarted. Unfortunately,
I haven't found a way to describe such relation using systemd unit
relations alone that wouldn't break things, so a system-sleep hook
is added to stop the service before going into suspend.

The service itself is also tweaked to better handle errors and to make
it restartable (previously it would require the card to be reset before
hciattach could work again).

Signed-off-by: default avatarSebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
parent e35c617b
No related branches found
No related tags found
1 merge request!334defaults: Improve reliability of bluetooth-brcmfmac against system suspend
Pipeline #80760 passed
......@@ -3,10 +3,12 @@ Description=Bluetooth attachment for brcmfmac driver
After=sys-bus-sdio-drivers-brcmfmac-mmc1:0001:1.device
BindsTo=sys-bus-sdio-drivers-brcmfmac-mmc1:0001:1.device
ConditionPathExists=/etc/firmware/brcm/BCM4362A2.hcd
StopWhenUnneeded=true
[Install]
WantedBy=sys-bus-sdio-drivers-brcmfmac-mmc1:0001:1.device
RequiredBy=sys-bus-sdio-drivers-brcmfmac-mmc1:0001:1.device
[Service]
Type=forking
ExecStart=/usr/bin/hciattach -s 115200 /dev/ttymxc3 bcm43xx 1500000
ExecStart=sh -c '/usr/bin/hciattach -s 115200 /dev/ttymxc3 bcm43xx 1500000 || /usr/bin/hciattach -s 1500000 /dev/ttymxc3 bcm43xx 1500000'
Restart=on-abort
......@@ -56,6 +56,9 @@ default/systemd/systemd-localed.service.d/* lib/systemd/system/systemd-localed.s
# enable zram
default/systemd/zram-generator.conf.d/* lib/systemd/zram-generator.conf.d/
# suspend hooks
default/systemd/system-sleep/* lib/systemd/system-sleep/
# initramfs modules
default/initramfs-tools/modules.d/* usr/share/initramfs-tools/modules.d/
......
#!/bin/sh
# Stop hciattach before system suspend to not interfere with
# freshly reset card after resume.
#
# No need to start it back here as it gets restarted automatically
# because of RequiredBy relation in its systemd unit.
case "${1}/${2}" in
hibernate|suspend|pre*)
systemctl stop bluetooth-brcmfmac.service
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment