[alsa-devel] [PATCH 26/29] ALSA: oxfw: Add support AMDTP in-stream
Takashi Sakamoto
o-takashi at sakamocchi.jp
Thu Nov 20 11:32:54 CET 2014
Hi Clemens,
On Nov 17 2014 06:21, Clemens Ladisch wrote:
> Takashi Sakamoto wrote:
>> +++ b/sound/firewire/oxfw/oxfw-stream.c
>> +int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw,
>> + struct amdtp_stream *stream,
>> + unsigned int rate, unsigned int pcm_channels)
>> +{
>> ...
>> + if (atomic_read(substreams) == 0)
>> + goto end;
>> +
>> mutex_lock(&oxfw->mutex);
>
> What happens if hw_free is called between the calls to atomic_read() and
> mutex_lock()?
In the worst case, the codes after the mutex_lock() manage to start
duplex streams with released resources, then it causes kernel panic.
This is a bug. I should have move atmic_read() to the critical section...
> And why are the substreams counters atomic?
> Can't they just be normal variables accessed from inside the mutex?
Just for my convinience. I didn't want to write many
mutex_lock()/mutex_unlock() because wrong coding of them causes-dead
lock, then push them inner stream.c. This idea is good except for
reference couters, so I added atomic_t.
An attached patch achieves your idea over my patchset. Handling
reference counter is easy to understand (because it's arithmetric
operation) but I don't like much mutex_lock()/mutex_unlock().
Can I request you to explain about the advantages of your idea?
Regards
Takashi Sakamoto
o-takashi at sakamocchi.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dice-use-mutex-only-instead-of-atomic_t-to-handle-cr.patch
Type: text/x-diff
Size: 9067 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20141120/ef1e8b9c/attachment.bin>
More information about the Alsa-devel
mailing list