cc93: standby-actions: rework the programming of resume actions
There are some cases in which the loading of the Wi-Fi modules may be problematic due to timing conditions: - when a suspend operation in progress is aborted - when Bluetooth is disabled The Wi-Fi needs some time for the system to be ready before loading the modules. This commit: - Stops the Bluetooth before bringing down the Wi-Fi on suspend - Starts the Bluetooth (or adds a small delay) before bringing up the Wi-Fi on resume - Reworks the way the resume operations are programmed, to do them in reverse order (first load the Wi-Fi modules, then bring the interfaces up (if required). It does so by appending/prepending actions into a variable and dumping the contents finally to a temp file. Signed-off-by: Hector Palacios <hector.palacios@digi.com>
This commit is contained in:
parent
75bd0d887b
commit
ff22903a81
|
|
@ -16,7 +16,8 @@
|
|||
#
|
||||
#===============================================================================
|
||||
|
||||
RESUME_ACTIONS="/tmp/resume_actions"
|
||||
RESUME_FILE="/tmp/resume_actions"
|
||||
RESUME_ACTIONS=""
|
||||
|
||||
wifi_actions_needed() {
|
||||
[ -d "/proc/device-tree/wireless" ] && [ ! -e "/sys/firmware/devicetree/base/soc@0/bus@42800000/mmc@428b0000/keep-power-in-suspend" ]
|
||||
|
|
@ -27,39 +28,61 @@ bt_actions_needed() {
|
|||
}
|
||||
|
||||
if [ "${1}" = "pre" ]; then
|
||||
rm -f "${RESUME_ACTIONS}"
|
||||
rm -f "${RESUME_FILE}"
|
||||
|
||||
# Stop NetworkManager before suspend
|
||||
systemctl stop NetworkManager
|
||||
|
||||
if bt_actions_needed; then
|
||||
# bluetooth service relies on bluetooth-init service so
|
||||
# stop it unconditionally
|
||||
systemctl stop bluetooth-init
|
||||
systemctl stop bluetooth
|
||||
# Program the resume actions to start the services
|
||||
RESUME_ACTIONS_BT="systemctl start bluetooth-init; systemctl start bluetooth;"
|
||||
fi
|
||||
|
||||
if wifi_actions_needed; then
|
||||
RESUME_ACTIONS_WIFI=""
|
||||
for iface in wlan0 uap0 wfd0; do
|
||||
if grep -qs ${iface} /var/run/ifstate; then
|
||||
ifdown ${iface} && echo "ifup ${iface}" >> "${RESUME_ACTIONS}"
|
||||
# Bring the interface down
|
||||
ifdown ${iface}
|
||||
# Program the resume action to bring it up
|
||||
# (prepend to use reverse order)
|
||||
RESUME_ACTIONS_WIFI="ifup ${iface};${RESUME_ACTIONS_WIFI}"
|
||||
fi
|
||||
done
|
||||
|
||||
{
|
||||
echo "sleep 0.5"
|
||||
echo "/etc/udev/scripts/load_iw612.sh"
|
||||
} >> "${RESUME_ACTIONS}"
|
||||
# Unload Wi-Fi modules
|
||||
modprobe -r moal
|
||||
# Program the resume action to reload the modules
|
||||
# (prepend to use reverse order)
|
||||
RESUME_ACTIONS_WIFI="/etc/udev/scripts/load_iw612.sh;${RESUME_ACTIONS_WIFI}"
|
||||
fi
|
||||
|
||||
if bt_actions_needed; then
|
||||
# bluetooth service relies on bluetooth-init service, so stop/start it unconditionally
|
||||
{
|
||||
echo "systemctl start bluetooth-init"
|
||||
echo "systemctl start bluetooth"
|
||||
} >> "${RESUME_ACTIONS}"
|
||||
systemctl stop bluetooth-init
|
||||
systemctl stop bluetooth
|
||||
# Compound resume actions (enable BT first, or else add a sleep, to give
|
||||
# some time to the system to be ready to load the Wi-Fi)
|
||||
if [ -n "${RESUME_ACTIONS_BT}" ]; then
|
||||
RESUME_ACTIONS="${RESUME_ACTIONS_BT}"
|
||||
fi
|
||||
if [ -n "${RESUME_ACTIONS_WIFI}" ]; then
|
||||
if [ ! -n "${RESUME_ACTIONS_BT}" ]; then
|
||||
RESUME_ACTIONS="sleep 0.5;"
|
||||
fi
|
||||
RESUME_ACTIONS="${RESUME_ACTIONS}${RESUME_ACTIONS_WIFI}"
|
||||
fi
|
||||
|
||||
if [ -n "${RESUME_ACTIONS}" ]; then
|
||||
# Create temp file with resume actions
|
||||
echo "${RESUME_ACTIONS}" > "${RESUME_FILE}"
|
||||
chmod +x "${RESUME_FILE}"
|
||||
fi
|
||||
elif [ "${1}" = "post" ]; then
|
||||
if [ -f ${RESUME_ACTIONS} ]; then
|
||||
chmod +x "${RESUME_ACTIONS}"
|
||||
eval "${RESUME_ACTIONS}"
|
||||
rm -f "${RESUME_ACTIONS}"
|
||||
if [ -f "${RESUME_FILE}" ]; then
|
||||
eval "${RESUME_FILE}"
|
||||
# Clean-up
|
||||
rm -f "${RESUME_FILE}"
|
||||
fi
|
||||
|
||||
# Resume NetworkManager after suspend
|
||||
|
|
|
|||
Loading…
Reference in New Issue