[PATCH v6 0/2] ASoC: SOF: Fix deadlock when shutdown a frozen userspace

From: Ricardo Ribalda
Date: Wed Nov 30 2022 - 10:48:00 EST


Since: 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown")
we wait for all the workloads to be completed during shutdown. This was done to
avoid a stall once the device is started again.

Unfortunately this has the side effect of stalling kexec(), if the userspace
is frozen. Let's handle that case.

To: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
To: Liam Girdwood <lgirdwood@xxxxxxxxx>
To: Peter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
To: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
To: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
To: Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>
To: Daniel Baluta <daniel.baluta@xxxxxxx>
To: Mark Brown <broonie@xxxxxxxxxx>
To: Jaroslav Kysela <perex@xxxxxxxx>
To: Takashi Iwai <tiwai@xxxxxxxx>
To: Eric Biederman <ebiederm@xxxxxxxxxxxx>
To: Chromeos Kdump <chromeos-kdump@xxxxxxxxxx>
To: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Cc: sound-open-firmware@xxxxxxxxxxxxxxxx
Cc: alsa-devel@xxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: kexec@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
Changes in v6:
- Check if we are in kexec with the userspace frozen.
- Link to v5: https://lore.kernel.org/r/20221127-snd-freeze-v5-0-4ededeb08ba0@xxxxxxxxxxxx

Changes in v5:
- Edit subject prefix.
- Link to v4: https://lore.kernel.org/r/20221127-snd-freeze-v4-0-51ca64b7f2ab@xxxxxxxxxxxx

Changes in v4:
- Do not call snd_sof_machine_unregister from shutdown.
- Link to v3: https://lore.kernel.org/r/20221127-snd-freeze-v3-0-a2eda731ca14@xxxxxxxxxxxx

Changes in v3:
- Wrap pm_freezing in a function.
- Link to v2: https://lore.kernel.org/r/20221127-snd-freeze-v2-0-d8a425ea9663@xxxxxxxxxxxx

Changes in v2:
- Only use pm_freezing if CONFIG_FREEZER .
- Link to v1: https://lore.kernel.org/r/20221127-snd-freeze-v1-0-57461a366ec2@xxxxxxxxxxxx

---
Ricardo Ribalda (2):
kexec: Introduce kexec_with_frozen_processes
ASoC: SOF: Fix deadlock when shutdown a frozen userspace

include/linux/kexec.h | 3 +++
kernel/kexec_core.c | 5 +++++
sound/soc/sof/core.c | 4 +++-
3 files changed, 11 insertions(+), 1 deletion(-)
---
base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221127-snd-freeze-1ee143228326

Best regards,
--
Ricardo Ribalda <ribalda@xxxxxxxxxxxx>