ALSA: control: Take power_ref lock primarily
authorTakashi Iwai <tiwai@suse.de>
Mon, 29 Jul 2024 16:06:58 +0000 (18:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 30 Jul 2024 05:46:00 +0000 (07:46 +0200)
commitfcc62b19104a67b9a2941513771e09389b75bd95
treef8af9f065235beaaeae04aa9cabe9942d84ae969
parent3bb668264db5c68a02b557b3052644181bb4f4be
ALSA: control: Take power_ref lock primarily

The code path for kcontrol accesses have often nested locks of both
card's controls_rwsem and power_ref, and applies in that order.
However, what could take much longer is the latter, power_ref; it
waits for the power state of the device, and it pretty much depends on
the user's action.

This patch swaps the locking order of those locks to a more natural
way, namely, power_ref -> controls_rwsem, in order to shorten the time
of possible nested locks.  For consistency, power_ref is taken always
in the top-level caller side (that is, *_user() functions and the
ioctl handler itself).

Link: https://patch.msgid.link/20240729160659.4516-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control.c