Alsa-Devel Archive on
 help / color / Atom feed
From: Takashi Iwai <>
To: Curtis Malainey <>
Cc:, Mark Brown <>,
	Takashi Iwai <>,
	Liam Girdwood <>
Subject: Re: [alsa-devel] [PATCH] ASoC: core: only flush inited work during free
Date: Thu, 28 Nov 2019 07:39:30 +0100
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, 28 Nov 2019 02:13:58 +0100,
Curtis Malainey wrote:
> There are many paths to soc_free_pcm_runtime which can both have and
> have not yet inited the workqueue yet. When we flush the queue when we
> have not yet inited the queue we cause warnings to be printed.
> An example is soc_cleanup_card_resources which is called by
> snd_soc_bind_card which has multiple failure points before and after
> soc_link_init -> soc_new_pcm which is where the queue is inited.
> Signed-off-by: Curtis Malainey <>

This patch itself isn't wrong, but there is a generic problem in the
current code in general.  Many fields in snd_soc_pcm_runtime object,
not only delayed_work, are initialized too late where
soc_free_pcm_runtime() may be called beforehand.  For example,
rtd->component_list is initialized after the error path of
rtd->codec_dais kmalloc, although soc_free_pcm_runtime() has a loop
over the link.

That said, at least the things like the linked list head and the work
struct must be initialized right after the allocation before any use
of the object.

For this delayed_work, the situation is a bit complex, though.
Usually the work is set up to point to a fixed function, but in the
case of ASoC, it seems serving for different purposes depending on the
component type.  I guess the cleaner way would be a redirect call

static void rtd_delayed_work(struct work_struct *work)
	struct snd_soc_pcm_runtime *rtd =
		container_of(work, struct snd_soc_pcm_runtime,;
	if (rtd->delayed_work_fn)

static struct snd_soc_pcm_runtime *soc_new_pcm_runtime()
	INIT_DELAYED_WORK(&rtd->delayed_work, rtd_delayed_work);


Alsa-devel mailing list

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28  1:13 Curtis Malainey
2019-11-28  6:39 ` Takashi Iwai [this message]
2019-11-28 13:49   ` Mark Brown
2019-11-28 16:23     ` Curtis Malainey
2019-11-28 17:28       ` Mark Brown
2019-12-02 22:50         ` Curtis Malainey
2019-12-09 18:59 ` [alsa-devel] Applied "ASoC: core: only flush inited work during free" to the asoc tree Mark Brown

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Alsa-Devel Archive on

Archives are clonable:
	git clone --mirror alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ \
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone