Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Curtis Malainey <cujomalainey@chromium.org>
Cc: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>,
	Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [alsa-devel] [PATCH] ASoC: core: only flush inited work during free
Date: Thu, 28 Nov 2019 07:39:30 +0100
Message-ID: <s5hlfs0ld25.wl-tiwai@suse.de> (raw)
In-Reply-To: <20191128011358.39234-1-cujomalainey@chromium.org>

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 <cujomalainey@chromium.org>

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
like:

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

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


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  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:
  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=s5hlfs0ld25.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cujomalainey@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.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

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 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/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git