From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "Nc, Shreyas" <shreyas.nc@intel.com>
Cc: Patches Audio <patches.audio@intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"vkoul@kernel.org" <vkoul@kernel.org>,
"Kale, Sanyog R" <sanyog.r.kale@intel.com>
Subject: Re: [PATCH v4 4/7] soundwire: Handle multiple master instances in a stream
Date: Tue, 3 Jul 2018 13:59:26 -0500 [thread overview]
Message-ID: <dbde119d-5533-4872-5b8e-559d05322dfa@linux.intel.com> (raw)
In-Reply-To: <78E8B3DDF116FF4CB089A311DDEB1B345204E483@BGSMSX103.gar.corp.intel.com>
On 07/03/2018 11:03 AM, Nc, Shreyas wrote:
>>>>> + struct sdw_master_runtime *m_rt, *_m_rt;
>>>>> +
>>>>> mutex_lock(&bus->bus_lock);
>>>>> - sdw_release_master_stream(stream);
>>>>> - sdw_master_port_release(bus, stream->m_rt);
>>>>> - stream->state = SDW_STREAM_RELEASED;
>>>>> - kfree(stream->m_rt);
>>>>> - stream->m_rt = NULL;
>>>>> + list_for_each_entry_safe(m_rt, _m_rt,
>>>>> + &stream->master_list, stream_node) {
>>>>> +
>>>>> + if (m_rt->bus != bus)
>>>>> + continue;
>>>>> +
>>>>> + sdw_master_port_release(bus, m_rt);
>>>>> + sdw_release_master_stream(m_rt, stream);
>>>>> + }
>>>>> +
>>>>> + if (list_empty(&stream->master_list))
>>>>> + stream->state = SDW_STREAM_RELEASED;
>>>> When a master is removed, there is an explicit test to make sure the
>>>> stream state changes when there are no masters left in the list, but...
>>>>
>>>>> mutex_unlock(&bus->bus_lock);
>>>>> @@ -1127,7 +1169,7 @@ int sdw_stream_add_master(struct sdw_bus
>> *bus,
>>>>> stream->state = SDW_STREAM_CONFIGURED;
>>>> ... it's not symmetrical for the add_master case. The stream state
>>>> changes on the first added master. In addition the stream state
>>>> changes both when a slave is added and a master is added.
>>>> Is this intentional or not - and are there side effects resulting
>>>> from this inconsistency?
>>>>
>>> For remove_master, we already know the number of Masters in the stream
>>> and hence we change the state to RELEASED only when there are no
>>> Masters left in stream.
>>>
>>> But, in the add_master case, we have no idea on how many master
>>> instances are part of the stream and hence how many times add_master
>> would be called.
>>> So, we change the stream state to CONFIGURED when the first Master is
>> added.
>>> I can add a comment if that helps :)
>> I get the point, but you currently change the state for the first slave that's
>> added, so there is an inconsistency here (even before we add the multi-master
>> support).
> When we add a slave, we check if there is an existing m_rt for that bus instance
> and if It does not exist we create a m_rt for that master instance, add the slave
> runtime and change the state to CONFIGURED. So technically we still change
> the state after adding the first m_rt.
If you made no assumption on the order in which slaves and masters are
added then you need this assignment to CONFIGURED twice. But if you know
the slaves are added first then the second assignment is irrelevant.
It's hard to memorize really since there are parts where you assume
things are triggered by external events and others where there is no
assumption on API use...
>
>> If I wanted to split hair I'd also note it's almost like the state is CONFIGURING
>> rather than CONFIGURED if you don't really control when all configurations are
>> complete at the bus level and depend on external transitions (e.g. DAPM/ALSA
>> initiated) to go in PREPARED mode.
>>
>>> Yes, it is added intentionally (or rather because we could not think
>>> of any other suitable way) and we dont see any side effects. Anything
>>> that you could think of?
>> We should check what happens if the stream is removed before being enabled,
>> or all cases of testing stream->state.
> While releasing the stream we unconditionally clean up things without checking
> stream state. So, we should be fine that way. But, I can check these :)
A quick check for stream->state gives me this:
stream->state = SDW_STREAM_CONFIGURED;
>>> so here it's a success case but we fallback to an error case...
stream_error:
sdw_release_master_stream(m_rt, stream);
error:
mutex_unlock(&bus->bus_lock);
return ret;
You are probably missing a
stream->state = SDW_STREAM_CONFIGURED;
goto error; //<<< Add this
as done for the slave?
Wondering how this ever worked, you may want to triple-check the regular
stream management before adding the multi-master stuff?
>
> --Shreyas
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2018-07-03 18:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 10:58 [PATCH v4 0/7] soundwire: Add multi link support Shreyas NC
2018-06-25 10:58 ` [PATCH v4 1/7] Documentation: soundwire: Add documentation for multi link Shreyas NC
2018-06-25 10:58 ` [PATCH v4 2/7] soundwire: Initialize completion for defer messages Shreyas NC
2018-06-25 10:58 ` [PATCH v4 3/7] soundwire: Add support to lock across bus instances Shreyas NC
2018-06-25 12:38 ` Takashi Iwai
2018-06-26 8:22 ` Shreyas NC
2018-06-26 8:34 ` Takashi Iwai
2018-06-26 9:23 ` Shreyas NC
2018-06-26 9:46 ` Takashi Iwai
2018-06-26 9:59 ` Shreyas NC
2018-06-26 10:16 ` Takashi Iwai
2018-06-26 10:22 ` Shreyas NC
2018-06-26 10:38 ` Takashi Iwai
2018-06-25 10:58 ` [PATCH v4 4/7] soundwire: Handle multiple master instances in a stream Shreyas NC
2018-07-02 20:22 ` Pierre-Louis Bossart
2018-07-03 1:13 ` Shreyas NC
2018-07-03 15:03 ` Pierre-Louis Bossart
2018-07-03 16:03 ` Nc, Shreyas
2018-07-03 18:59 ` Pierre-Louis Bossart [this message]
2018-07-04 0:17 ` Nc, Shreyas
2018-07-04 4:24 ` Vinod
2018-06-25 10:58 ` [PATCH v4 5/7] soundwire: keep track of Masters " Shreyas NC
2018-06-25 10:58 ` [PATCH v4 6/7] soundwire: Add support for multi link bank switch Shreyas NC
2018-06-25 10:59 ` [PATCH v4 7/7] soundwire: intel: Add pre/post bank switch ops Shreyas NC
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=dbde119d-5533-4872-5b8e-559d05322dfa@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=gregkh@linuxfoundation.org \
--cc=patches.audio@intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=shreyas.nc@intel.com \
--cc=vkoul@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).