diff options
author | Vaibhav Agarwal <vaibhav.agarwal@linaro.org> | 2016-01-28 18:45:40 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-02-03 08:46:54 +0300 |
commit | 3994e0b139c709047cdeb44b6c28cfb39f89f3f2 (patch) | |
tree | 6cd7caf1fd59c104d0c0431adb80ef657d0eb973 /drivers/staging/greybus/audio_codec.h | |
parent | 796fad441cb248c1eac88bfb3a5929bb1a10fabb (diff) | |
download | linux-3994e0b139c709047cdeb44b6c28cfb39f89f3f2.tar.xz |
greybus: audio: use variable 'is_connected' to maintain module state
there is race condition between _disconnect() request &
stop_trigger() in case of abrupt module removal.
And sometimes this can lead to deadlock while acquiring
codec_info->lock.
To avoid such situation, atomic variable is used to maintain
codec connected state.
During dai operations (trigger, shutdown, etc.), 'is_connected'
variable is validated to avoid unnecessary lock acquire in
case module already removed.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/audio_codec.h')
-rw-r--r-- | drivers/staging/greybus/audio_codec.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h index 56110913b70e..4c19bd884488 100644 --- a/drivers/staging/greybus/audio_codec.h +++ b/drivers/staging/greybus/audio_codec.h @@ -108,6 +108,15 @@ struct gbaudio_codec_info { int manager_id; char name[NAME_SIZE]; + /* + * there can be a rece condition between gb_audio_disconnect() + * and dai->trigger from above ASoC layer. + * To avoid any deadlock over codec_info->lock, atomic variable + * is used. + */ + atomic_t is_connected; + struct mutex lock; + /* soc related data */ struct snd_soc_codec *codec; struct device *dev; @@ -139,7 +148,6 @@ struct gbaudio_codec_info { struct list_head widget_list; struct list_head codec_ctl_list; struct list_head widget_ctl_list; - struct mutex lock; }; struct gbaudio_dai *gbaudio_find_dai(struct gbaudio_codec_info *gbcodec, |