All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
	ranjani.sridharan@linux.intel.com, digetx@gmail.com,
	pierre-louis.bossart@linux.intel.com
Subject: Re: [PATCH] ASoC: soc-pcm: Revert "call snd_soc_component_open/close() once"
Date: 28 Feb 2020 09:46:51 +0900	[thread overview]
Message-ID: <874kvb7d38.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2002271110010.2957@eliteleevi.tm.intel.com>


Hi Kai

Thank you for feedback

> thanks for the longer explanation. It's true we have a lot of code with 
> for_each_xxx() loops, and loop logic where errors can occur. It seems the 
> most common approach is to store the index and use for_each_xxx_rollback() 
> macros to clean up in case error happens. This does lead to the problem of 
> essentially duplicated logic e.g. for soc_pcm_close() and error handling 
> of snd_pcm_open().

Thank you for understanding my headache.
My opinion is that complex duplicated code never bring luck to us.

> And yeah, it's also a bit error prone as the logic is 
> not exactly the same. E.g. I'm not convinced this is quite right in 
> soc_pcm_open():
> 
> »       for_each_rtd_codec_dai(rtd, i, codec_dai) {                                                                                                                                                          
> »       »       ret = snd_soc_dai_startup(codec_dai, substream);                                                                                                                                             
> »       »       if (ret < 0) {                                                                                                                                                                               
> »       »       »       dev_err(codec_dai->dev,                                                                                                                                                              
> »       »       »       »       "ASoC: can't open codec %s: %d\n",                                                                                                                                           
> »       »       »       »       codec_dai->name, ret);                                                                                                                                                       
> »       »       »       goto config_err;                                                                                                                                                                     
> »       »       }                                             
> ...
> config_err:                                                                                                                                                                                                  
> »       for_each_rtd_codec_dai(rtd, i, codec_dai)                                                                                                                                                            
> »       »       snd_soc_dai_shutdown(codec_dai, substream);                                                                                                                                                  
> »       i = rtd->num_cpus;

Yeah indeed.
I think this is just one of the BUG.
I guess we can find similar issue everywhere.

> Having a single cleanup path would be easier, but I think in the end it 
> comes down to how cleanly you can track the opened state. It seems biggest 
> issue is how to cleanly track the component-substream pairs. Ideally we'd 
> have a dedicated state object to represent an opened component-substream 
> pair, but that's not how the APIs are defined now. But something to that
> effect is needed.

Yeah, I can understand your concern, but not 100% yet.
In my understanding, counting start vs stop is not enough but not so bad.
If my understanding was correct, your concern is
counting only is not enough, because wrong component-substream pair
can be used, like this ?

	start(substream-A); <=
	start(substream-B);
	start(substream-C);

	stop(substream-Z);  <=
	stop(substream-B);
	stop(substream-C);

But I wonder is it really happen ?
If there is clear such case, yes, we need to consider
component-substream pair list, somehow.

If you are worry about some kind of BUG, I guess we need to solve
is such bug, not error handling method.
But how about step-by-step approach (I like it :) ?
At first, add counting method as 1st step. Indeed it is not enough,
but we can cleanup error handling.
If we found/noticed above not-enough-case,
start to consider about component-substream pair list ?

Thank you for your help !!
Best regards
---
Kuninori Morimoto

  reply	other threads:[~2020-02-28  0:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 18:26 [PATCH] ASoC: soc-pcm: Revert "call snd_soc_component_open/close() once" Kai Vehmanen
2020-02-19 18:53 ` Kai Vehmanen
2020-02-19 19:27   ` Pierre-Louis Bossart
2020-02-19 19:37 ` Dmitry Osipenko
2020-02-20  0:42 ` Kuninori Morimoto
2020-02-20  0:59   ` [PATCH][RFC] ASoC: soc-component: count snd_soc_component_open/close() Kuninori Morimoto
2020-02-20  1:25     ` Sridharan, Ranjani
2020-02-20  1:41       ` Kuninori Morimoto
2020-02-20  1:57         ` Sridharan, Ranjani
2020-02-20  3:01           ` Kuninori Morimoto
2020-02-20  9:33   ` [PATCH] ASoC: soc-pcm: Revert "call snd_soc_component_open/close() once" Kai Vehmanen
2020-02-21  1:13     ` Kuninori Morimoto
2020-02-21 11:09       ` Kai Vehmanen
2020-02-25  0:41         ` Kuninori Morimoto
2020-02-26  0:55           ` Kuninori Morimoto
2020-02-26 17:36             ` Mark Brown
2020-02-27  0:11               ` Kuninori Morimoto
2020-02-27  9:41             ` Kai Vehmanen
2020-02-28  0:46               ` Kuninori Morimoto [this message]
2020-02-28  6:27                 ` Kuninori Morimoto
2020-02-28  7:57                   ` Kuninori Morimoto
2020-02-28 12:23                     ` Kai Vehmanen
2020-03-02  0:29                       ` Kuninori Morimoto
2020-03-02 18:22                         ` Kai Vehmanen
2020-03-03  0:43                           ` Kuninori Morimoto
2020-03-03 19:48                             ` Kai Vehmanen
2020-03-04  0:11                               ` Kuninori Morimoto

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=874kvb7d38.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=digetx@gmail.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.