From: Takashi Iwai <tiwai@suse.de>
To: Oliver Neukum <oneukum@suse.com>
Cc: Ricardo Ribalda <ribalda@chromium.org>,
Juergen Gross <jgross@suse.com>, Mark Brown <broonie@kernel.org>,
Chromeos Kdump <chromeos-kdump@google.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Len Brown <len.brown@intel.com>, Ard Biesheuvel <ardb@kernel.org>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Nicholas Piggin <npiggin@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Eric Biederman <ebiederm@xmission.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Jaroslav Kysela <perex@perex.cz>,
Joel Fernandes <joel@joelfernandes.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Pavel Machek <pavel@ucw.cz>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Steven Rostedt <rostedt@goodmis.org>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Ingo Molnar <mingo@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Dexuan Cui <decui@microsoft.com>, Takashi Iwai <tiwai@suse.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
x86@kernel.org, kexec@lists.infradead.org,
alsa-devel@alsa-project.org, stable@vger.kernel.org,
sound-open-firmware@alsa-project.org,
linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org,
linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v8 3/3] ASoC: SOF: Fix deadlock when shutdown a frozen userspace
Date: Thu, 01 Dec 2022 14:38:33 +0100 [thread overview]
Message-ID: <87v8mvmeg6.wl-tiwai@suse.de> (raw)
In-Reply-To: <d3730d1d-6f92-700a-06c4-0e0a35e270b0@suse.com>
On Thu, 01 Dec 2022 14:22:12 +0100,
Oliver Neukum wrote:
>
> On 01.12.22 14:03, Ricardo Ribalda wrote:
>
> Hi,
>
> > This patchset does not modify this behaviour. It simply fixes the
> > stall for kexec().
> >
> > The patch that introduced the stall:
> > 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers
> > in .shutdown")
>
> That patch is problematic. I would go as far as saying that
> it needs to be reverted.
... or fixed.
> > was sent as a generalised version of:
> > https://github.com/thesofproject/linux/pull/3388
> >
> > AFAIK, we would need a similar patch for every single board.... which
> > I am not sure it is doable in a reasonable timeframe.
> >
> > On the meantime this seems like a decent compromises. Yes, a
> > miss-behaving userspace can still stall during suspend, but that was
> > not introduced in this patch.
>
> Well, I mean if you know what wrong then I'd say at least return to
> a sanely broken state.
>
> The whole approach is wrong. You need to be able to deal with user
> space talking to removed devices by returning an error and keeping
> the resources association with the open file allocated until
> user space calls close()
As I already mentioned in another thread, if the user-space action has
to be cut off, we just need to call snd_card_disconnect() instead
without sync. A quick hack would be like below (totally untested and
might be wrong, though).
In anyway, Ricardo, please stop spinning too frequently; v8 in a few
days is way too much, and now the recipient list became unmanageable.
Let's give people some time to review and consider a better solution
at first.
thanks,
Takashi
-- 8< --
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -475,7 +475,7 @@ EXPORT_SYMBOL(snd_sof_device_remove);
int snd_sof_device_shutdown(struct device *dev)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
- struct snd_sof_pdata *pdata = sdev->pdata;
+ struct snd_soc_component *component;
if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
cancel_work_sync(&sdev->probe_work);
@@ -484,9 +484,9 @@ int snd_sof_device_shutdown(struct device *dev)
* make sure clients and machine driver(s) are unregistered to force
* all userspace devices to be closed prior to the DSP shutdown sequence
*/
- sof_unregister_clients(sdev);
-
- snd_sof_machine_unregister(sdev, pdata);
+ component = snd_soc_lookup_component(sdev->dev, NULL);
+ if (component && component->card && component->card->snd_card)
+ snd_card_disconnect(component->card->snd_card);
if (sdev->fw_state == SOF_FW_BOOT_COMPLETE)
return snd_sof_shutdown(sdev);
prev parent reply other threads:[~2022-12-01 13:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 11:08 [PATCH v8 0/3] ASoC: SOF: Fix deadlock when shutdown a frozen userspace Ricardo Ribalda
2022-12-01 11:08 ` [PATCH v8 1/3] kexec: Refactor kexec_in_progress into a function Ricardo Ribalda
2022-12-01 11:08 ` [PATCH v8 2/3] freezer: refactor pm_freezing " Ricardo Ribalda
2022-12-02 17:47 ` Rafael J. Wysocki
2022-12-05 12:05 ` Ricardo Ribalda
2022-12-01 11:08 ` [PATCH v8 3/3] ASoC: SOF: Fix deadlock when shutdown a frozen userspace Ricardo Ribalda
2022-12-01 12:28 ` Oliver Neukum
2022-12-01 13:03 ` Ricardo Ribalda
2022-12-01 13:22 ` Oliver Neukum
2022-12-01 13:34 ` Ricardo Ribalda
2022-12-09 11:53 ` Kai Vehmanen
2022-12-01 13:38 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v8mvmeg6.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=ardb@kernel.org \
--cc=bhelgaas@google.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=broonie@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=chromeos-kdump@google.com \
--cc=daniel.baluta@nxp.com \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=ebiederm@xmission.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=joel@joelfernandes.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=kexec@lists.infradead.org \
--cc=kys@microsoft.com \
--cc=len.brown@intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=oneukum@suse.com \
--cc=pavel@ucw.cz \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rafael@kernel.org \
--cc=ranjani.sridharan@linux.intel.com \
--cc=ribalda@chromium.org \
--cc=rostedt@goodmis.org \
--cc=sound-open-firmware@alsa-project.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tiwai@suse.com \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).