diff --git a/sound/soc/apple/macaudio.c b/sound/soc/apple/macaudio.c index 42e29c4c1ec5a..823f0abad53eb 100644 --- a/sound/soc/apple/macaudio.c +++ b/sound/soc/apple/macaudio.c @@ -379,6 +379,12 @@ struct macaudio_snd_data { struct snd_kcontrol *speaker_sample_rate_kctl; struct mutex volume_lock_mutex; + /* + * The volume lock's own mark of a system sleep. Set in + * macaudio_vlimit_pm() under volume_lock_mutex, once the volumes are + * kept, and cleared there: pm_quiesced is set earlier, without it. + */ + bool pm_vlimit_quiesced; /* * A CAP_SYS_ADMIN process wrote "Speaker Volume Unlock" to "Speaker * Protection Interface" since the card bound, and no write of "Speaker @@ -846,9 +852,11 @@ static void macaudio_vlimit_update(struct macaudio_snd_data *ma) * half a second on J616s), and a playback stream left running then plays * out its stale buffer and stops on an xrun into the still unmuted amps. * Lock the volumes before the freeze instead of when the frozen daemon's - * lease runs out. + * lease runs out. Not on pm_quiesced itself: the streams stop between + * that and macaudio_vlimit_pm(), and macaudio_vlimit_update_work() run + * for such a stop would clip the volumes before they are kept. */ - if (ma->pm_quiesced) { + if (ma->pm_vlimit_quiesced) { reason = "System suspend"; unlock = false; } @@ -871,7 +879,7 @@ static void macaudio_vlimit_update(struct macaudio_snd_data *ma) } else { dev_info(ma->card.dev, "Speaker volumes locked: %s\n", reason); /* The system-sleep lock is the kernel's own, not a lease the daemon lost */ - if (!ma->pm_quiesced) + if (!ma->pm_vlimit_quiesced) ma->speaker_volume_was_locked = true; } @@ -913,6 +921,7 @@ static void macaudio_vlimit_pm(struct macaudio_snd_data *ma, bool quiesce) ma->speaker_lock_remain = 0; macaudio_pm_volumes_save(ma); } + ma->pm_vlimit_quiesced = quiesce; macaudio_vlimit_update(ma); mutex_unlock(&ma->volume_lock_mutex); up_read(&ma->card.snd_card->controls_rwsem); @@ -4217,8 +4226,13 @@ static int macaudio_slk_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v return -ETIMEDOUT; } - /* Between suspend-prepare and the freeze: the lease starts again after the resume */ - if (ma->pm_quiesced) { + /* + * Between the sleep's volume lock and the freeze: the lease starts again + * after the resume. By the lock's own mark: a ping refused from + * pm_quiesced on would leave the lease's timer running unrenewed until + * macaudio_vlimit_pm() cancels it. + */ + if (ma->pm_vlimit_quiesced) { mutex_unlock(&ma->volume_lock_mutex); return 0; }