linux-stable/sound/hda
Takashi Iwai 9034455704 ALSA: hda: Fix unhandled register update during auto-suspend period
commit 81302b1c7c upstream.

It's reported that the recording started right after the driver probe
doesn't work properly, and it turned out that this is related with the
codec auto-suspend.  Namely, after the probe phase, the usage count
goes zero, and the auto-suspend is programmed, but the codec is kept
still active until the auto-suspend expiration.  When an application
(e.g. alsactl) updates the mixer values at this moment, the values are
cached but not actually written.  Then, starting arecord thereafter
also results in the silence because of the missing unmute.

The root cause is the handling of "lazy update" mode; when a mixer
value is updated *after* the suspend, it should update only the cache
and exits.  At the resume, the cached value is written to the device,
in turn.  The problem is that the current code misinterprets the state
of auto-suspend as if it were already suspended.

Although we can add the check of the actual device state after
pm_runtime_get_if_in_use() for catching the missing state, this won't
suffice; the second call of regmap_update_bits_check() will skip
writing the register because the cache has been already updated by the
first call.  So we'd need fixes in two different places.

OTOH, a simpler fix is to replace pm_runtime_get_if_in_use() with
pm_runtime_get_if_active() (with ign_usage_count=true).  This change
implies that the driver takes the pm refcount if the device is still
in ACTIVE state and continues the processing.  A small caveat is that
this will leave the auto-suspend timer.  But, since the timer callback
itself checks the device state and aborts gracefully when it's active,
this won't be any substantial problem.

Long story short: we address the missing register-write problem just
by replacing the pm_runtime_*() call in snd_hda_keep_power_up().

Fixes: fc4f000bf8 ("ALSA: hda - Fix unexpected resume through regmap code path")
Reported-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Closes: https://lore.kernel.org/r/a7478636-af11-92ab-731c-9b13c582a70d@linux.intel.com
Suggested-by: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230518113520.15213-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-30 14:17:21 +01:00
..
ext ALSA: hda: Allow for compress stream to hdac_ext_stream assignment 2022-12-05 14:05:18 +00:00
Kconfig
Makefile
array.c
hda_bus_type.c driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
hdac_bus.c ALSA: hda: Skip event processing for unregistered codecs 2022-07-15 16:26:50 +02:00
hdac_component.c
hdac_controller.c ALSA: hda: Interrupt servicing and BDL setup for compress streams 2022-12-05 14:05:20 +00:00
hdac_device.c ALSA: hda: Fix unhandled register update during auto-suspend period 2023-05-30 14:17:21 +01:00
hdac_i915.c ALSA: hda: Fix discovery of i915 graphics PCI device 2022-06-21 14:05:12 +02:00
hdac_regmap.c
hdac_stream.c ALSA: hda: remove redundant variable in snd_hdac_stream_start() 2023-02-10 10:06:50 +01:00
hdac_sysfs.c ALSA: hda: make kobj_type structure constant 2023-02-11 09:37:42 +01:00
hdmi_chmap.c ALSA: hda: Replace runtime->status->state reference to runtime->state 2022-09-27 08:47:33 +02:00
intel-dsp-config.c ALSA: hda: intel-dsp-config: add MTL PCI id 2023-03-08 06:37:19 +01:00
intel-nhlt.c ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask() 2022-09-20 12:25:03 +01:00
intel-sdw-acpi.c ALSA: Replace acpi_bus_get_device() 2022-02-01 08:08:08 +01:00
local.h
trace.c
trace.h tracing: ALSA: hda: Remove string manipulation out of the fast path 2022-07-04 14:31:19 +02:00