From: Vinod Koul <vkoul@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org,
jank@cadence.com, srinivas.kandagatla@linaro.org,
slawomir.blauciak@intel.com,
Bard liao <yung-chuan.liao@linux.intel.com>,
Rander Wang <rander.wang@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Hui Wang <hui.wang@canonical.com>,
Sanyog Kale <sanyog.r.kale@intel.com>
Subject: Re: [PATCH] soundwire: stream: only change state if needed
Date: Fri, 20 Mar 2020 19:45:28 +0530 [thread overview]
Message-ID: <20200320141528.GI4885@vkoul-mobl> (raw)
In-Reply-To: <20200317105142.4998-1-pierre-louis.bossart@linux.intel.com>
On 17-03-20, 05:51, Pierre-Louis Bossart wrote:
> In a multi-cpu DAI context, the stream routines may be called from
> multiple DAI callbacks. Make sure the stream state only changes for
> the first call, and don't return error messages if the target state is
> already reached.
For stream-apis we have documented explicitly in Documentation/driver-api/soundwire/stream.rst
"Bus implements below API for allocate a stream which needs to be called once
per stream. From ASoC DPCM framework, this stream state maybe linked to
.startup() operation.
.. code-block:: c
int sdw_alloc_stream(char * stream_name); "
This is documented for all stream-apis.
This can be resolved by moving the calling of these APIs from
master-dais/slave-dais to machine-dais. They are unique in the card.
>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
> drivers/soundwire/stream.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 1b43d03c79ea..3319121cd706 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1572,6 +1572,7 @@ int sdw_prepare_stream(struct sdw_stream_runtime *stream)
> sdw_acquire_bus_lock(stream);
>
> if (stream->state == SDW_STREAM_PREPARED) {
> + /* nothing to do */
> ret = 0;
> goto state_err;
> }
> @@ -1661,6 +1662,12 @@ int sdw_enable_stream(struct sdw_stream_runtime *stream)
>
> sdw_acquire_bus_lock(stream);
>
> + if (stream->state == SDW_STREAM_ENABLED) {
> + /* nothing to do */
> + ret = 0;
> + goto state_err;
> + }
> +
> if (stream->state != SDW_STREAM_PREPARED &&
> stream->state != SDW_STREAM_DISABLED) {
> pr_err("%s: %s: inconsistent state state %d\n",
> @@ -1744,6 +1751,12 @@ int sdw_disable_stream(struct sdw_stream_runtime *stream)
>
> sdw_acquire_bus_lock(stream);
>
> + if (stream->state == SDW_STREAM_DISABLED) {
> + /* nothing to do */
> + ret = 0;
> + goto state_err;
> + }
> +
> if (stream->state != SDW_STREAM_ENABLED) {
> pr_err("%s: %s: inconsistent state state %d\n",
> __func__, stream->name, stream->state);
> @@ -1809,6 +1822,12 @@ int sdw_deprepare_stream(struct sdw_stream_runtime *stream)
>
> sdw_acquire_bus_lock(stream);
>
> + if (stream->state == SDW_STREAM_DEPREPARED) {
> + /* nothing to do */
> + ret = 0;
> + goto state_err;
> + }
> +
> if (stream->state != SDW_STREAM_PREPARED &&
> stream->state != SDW_STREAM_DISABLED) {
> pr_err("%s: %s: inconsistent state state %d\n",
> --
> 2.20.1
--
~Vinod
next prev parent reply other threads:[~2020-03-20 14:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 10:51 [PATCH] soundwire: stream: only change state if needed Pierre-Louis Bossart
2020-03-17 11:53 ` Srinivas Kandagatla
2020-03-17 12:22 ` Pierre-Louis Bossart
2020-03-17 12:43 ` Srinivas Kandagatla
2020-03-17 13:04 ` Srinivas Kandagatla
2020-03-17 13:19 ` Pierre-Louis Bossart
2020-03-17 15:07 ` Srinivas Kandagatla
2020-03-17 15:31 ` Pierre-Louis Bossart
2020-03-20 14:15 ` Vinod Koul [this message]
2020-03-20 14:33 ` Pierre-Louis Bossart
2020-03-23 12:46 ` Vinod Koul
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=20200320141528.GI4885@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hui.wang@canonical.com \
--cc=jank@cadence.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=slawomir.blauciak@intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--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