linux-stable/sound
Takashi Sakamoto 5bbb1ab5bd ALSA: control: use counting semaphore as write lock for ELEM_WRITE operation
In ALSA control interface, applications can execute two types of request
for value of members on each element; ELEM_READ and ELEM_WRITE. In ALSA
control core, these two requests are handled within read lock of a
counting semaphore, therefore several processes can run to execute these
two requests at the same time. This has an issue because ELEM_WRITE
requests have an effect to change state of the target element. Concurrent
access should be controlled for each of ELEM_READ/ELEM_WRITE case.

This commit uses the counting semaphore as write lock for ELEM_WRITE
requests, while use it as read lock for ELEM_READ requests. The state of
a target element is maintained exclusively between ELEM_WRITE/ELEM_READ
operations.

There's a concern. If the counting semaphore is acquired for read lock
in implementations of 'struct snd_kcontrol.put()' in each driver, this
commit shall cause dead lock. As of v4.13-rc5, 'snd-mixer-oss.ko',
'snd-emu10k1.ko' and 'snd-soc-sst-atom-hifi2-platform.ko' includes codes
for read locks, but these are not in a call graph from
'struct snd_kcontrol.put(). Therefore, this commit is safe.

In current implementation, the same solution is applied for the other
operations to element; e.g. ELEM_LOCK and ELEM_UNLOCK. There's another
discussion about an overhead to maintain concurrent access to an element
during operating the other elements on the same card instance, because the
lock primitive is originally implemented to maintain a list of elements on
the card instance. There's a substantial difference between
per-element-list lock and per-element lock.

Here, let me investigate another idea to add per-element lock to maintain
the concurrent accesses with inquiry/change requests to an element. It's
not so frequent for applications to operate members on elements, while
adding a new lock primitive to structure increases memory footprint for
all of element sets somehow. Experimentally, inquiry operation is more
frequent than change operation and usage of counting semaphore for the
inquiry operation brings no blocking to the other inquiry operations. Thus
the overhead is not so critical for usual applications. For the above
reasons, in this commit, the per-element lock is not introduced.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-08-20 09:39:55 +02:00
..
aoa ALSA: aoa: constify snd_pcm_ops structures 2017-08-19 11:02:12 +02:00
arm ALSA: arm: constify snd_pcm_ops structures 2017-08-19 11:02:13 +02:00
atmel ALSA: atmel: constify snd_pcm_ops structures 2017-08-19 11:02:14 +02:00
core ALSA: control: use counting semaphore as write lock for ELEM_WRITE operation 2017-08-20 09:39:55 +02:00
drivers ALSA: drivers: constify snd_pcm_ops structures 2017-08-19 11:02:15 +02:00
firewire ALSA: firewire: constify snd_pcm_ops structures 2017-08-19 11:02:17 +02:00
hda ALSA: hda: constify pci_device_id. 2017-07-18 20:01:21 +02:00
i2c ALSA: ak411x: Use array instead of offsetof() 2017-05-17 07:13:03 +02:00
isa ALSA: isa: make snd_pcm_hardware const 2017-08-17 12:44:11 +02:00
mips ALSA: mips: constify snd_pcm_ops structures 2017-08-19 11:02:18 +02:00
oss Annotate hardware config module parameters in sound/oss/ 2017-04-20 12:02:32 +01:00
parisc ALSA: parisc: constify snd_pcm_ops structures 2017-08-19 11:02:19 +02:00
pci ALSA: pci: make snd_pcm_hardware const 2017-08-17 12:44:16 +02:00
pcmcia ALSA: pcmcia: constify snd_pcm_ops structures 2017-08-19 11:02:21 +02:00
ppc ALSA: ppc: constify snd_pcm_ops structures 2017-08-19 11:02:22 +02:00
sh ALSA: sh: constify snd_pcm_ops structures 2017-08-19 11:02:23 +02:00
soc Merge remote-tracking branches 'asoc/fix/rt5663', 'asoc/fix/rt5665', 'asoc/fix/samsung', 'asoc/fix/sgtl5000' and 'asoc/fix/sh' into asoc-linus 2017-08-01 15:17:11 +01:00
sparc ALSA: sparc: constify snd_pcm_ops structures 2017-08-19 11:02:24 +02:00
spi ALSA: spi: constify snd_pcm_ops structures 2017-08-19 11:02:26 +02:00
synth ALSA: emux: Delete two error messages for a failed memory allocation in snd_emux_create_port() 2017-08-10 17:55:13 +02:00
usb ALSA: usb: constify snd_pcm_ops structures 2017-08-19 11:02:27 +02:00
x86 main drm pull for v4.13 2017-07-09 18:48:37 -07:00
ac97_bus.c
Kconfig ALSA: synth: Select snd-emux-synth explicitly 2017-06-09 22:10:06 +02:00
last.c
Makefile ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T 2017-01-25 14:23:46 +01:00
sound_core.c