--- a/include/sound/pcm.h 2022-03-30 11:08:46.127742500 +0800 +++ b/include/sound/pcm.h 2022-03-30 11:15:41.379069200 +0800 @@ -401,6 +401,7 @@ struct snd_pcm_runtime { wait_queue_head_t tsleep; /* transfer sleep */ struct fasync_struct *fasync; bool stop_operating; /* sync_stop will be called */ + bool trylock; /* trylock buffer_mutex */ struct mutex buffer_mutex; /* protect for buffer changes */ /* -- private section -- */ --- a/sound/core/oss/pcm_oss.c 2022-03-30 11:12:58.710516400 +0800 +++ b/sound/core/oss/pcm_oss.c 2022-03-30 11:33:01.405363200 +0800 @@ -1105,15 +1105,20 @@ static int snd_pcm_oss_change_params(str bool trylock) { struct snd_pcm_runtime *runtime = substream->runtime; + bool save = false; int err; if (trylock) { if (!(mutex_trylock(&runtime->oss.params_lock))) return -EAGAIN; + save = runtime->trylock; + runtime->trylock = true; } else if (mutex_lock_interruptible(&runtime->oss.params_lock)) return -ERESTARTSYS; err = snd_pcm_oss_change_params_locked(substream); + if (trylock) + runtime->trylock = save; mutex_unlock(&runtime->oss.params_lock); return err; } --- a/sound/core/pcm_native.c 2022-03-30 11:10:49.587363300 +0800 +++ b/sound/core/pcm_native.c 2022-03-30 11:37:40.650919000 +0800 @@ -702,7 +702,12 @@ static int snd_pcm_hw_params(struct snd_ if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; - mutex_lock(&runtime->buffer_mutex); + if (runtime->trylock) { + if (!mutex_trylock(&runtime->buffer_mutex)) + return -EAGAIN; + } else { + mutex_lock(&runtime->buffer_mutex); + } snd_pcm_stream_lock_irq(substream); switch (runtime->status->state) { case SNDRV_PCM_STATE_OPEN: