Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions sound/soc/apple/macaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down