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