linux-stable/sound/hda
Kai Vehmanen 840c7109c7 ALSA: hda: avoid write to STATESTS if controller is in reset
[ Upstream commit b37a15188e ]

The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
before performing controller reset. This code dates back to an old
bugfix in commit e8a7f136f5 ("[ALSA] hda-intel - Improve HD-audio
codec probing robustness"). Originally the code was added to
azx_reset().

The code was moved around in commit a41d122449 ("ALSA: hda - Embed bus
into controller object") and ended up to snd_hdac_bus_reset_link() and
called primarily via snd_hdac_bus_init_chip().

The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
called when controller is not in reset. In this case, STATESTS can be
cleared. This can be useful e.g. when forcing a controller reset to retry
codec probe. A normal non-power-on reset will not clear the bits.

However, this old logic is problematic when controller is already in
reset. The HDA specification states that controller must be taken out of
reset before writing to registers other than GCTL.CRST (1.0a spec,
3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
if the controller is already in reset per the HDA specification mentioned.

This has been harmless on older hardware. On newer generation of Intel
PCIe based HDA controllers, if configured to report issues, this write
will emit an unsupported request error. If ACPI Platform Error Interface
(APEI) is enabled in kernel, this will end up to kernel log.

Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
the function is called when controller is not in reset. Otherwise
clearing the bits is not possible and should be skipped.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-10-27 09:51:41 +02:00
..
ext ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link() 2020-11-18 18:27:53 +01:00
array.c ALSA: hda: Fix krealloc() with __GFP_ZERO usage 2016-08-03 15:17:22 +02:00
hda_bus_type.c ALSA: hda - Advertise MODALIAS in uevent 2015-10-20 10:15:53 +02:00
hdac_bus.c ALSA: hda: Fix potential race in unsol event handler 2020-10-01 13:12:44 +02:00
hdac_controller.c ALSA: hda: avoid write to STATESTS if controller is in reset 2021-10-27 09:51:41 +02:00
hdac_device.c ALSA: hda: fix a runtime pm issue in SOF when integrated GPU is disabled 2020-09-23 10:46:27 +02:00
hdac_i915.c ALSA: hda: Drop useless WARN_ON() 2018-01-02 20:31:04 +01:00
hdac_regmap.c ALSA: hdac_regmap - fix the register access for runtime PM 2016-06-17 14:01:06 +02:00
hdac_stream.c ALSA: hda - Avoid tricky macros 2017-04-03 08:42:43 +02:00
hdac_sysfs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hdmi_chmap.c ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs 2020-02-28 16:35:51 +01:00
Kconfig ALSA: HDAC: move SND_HDA_PREALLOC_SIZE to core 2015-06-16 17:40:38 +02:00
local.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.c
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00