FAILED: patch "[PATCH] ASoC: hdac_hda: Restore the codec device type on unbind" failed to apply to 6.1-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 08a44bde821d4fe22c0b6e63da04b3c59ac243a8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 08a44bde821d4fe22c0b6e63da04b3c59ac243a8 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <[email protected]>
Date: Tue, 27 Oct 2026 10:38:39 +0200
Subject: [PATCH] ASoC: hdac_hda: Restore the codec device type on unbind
hdac_hda_codec_probe() changes the type of the codec device to HDA_DEV_ASOC to prevent snd_hda_codec_unregister() from unregistering the device when the card is freed.
The type is never restored, and hda_bus_match() requires the device and driver types to be equal. After unbinding the codec driver via sysfs the HDA_DEV_LEGACY codec drivers no longer match the device and bind fails with -ENODEV.
Restore HDA_DEV_LEGACY with a device managed action registered before the component, so it runs after the component and the card are gone.
--- sound/soc/codecs/hdac_hda.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/codecs/hdac_hda.c +12 -0
@@ -617,6 +617,13 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = { .endianness = 1, }; +static void hdac_hda_restore_dev_type (void *data) +{ +struct hdac_device *hdev = data; + + hdev->type =HDA_DEV_LEGACY ; +} +static int hdac_hda_dev_probe (struct hdac_device *hdev) {struct hdac_hda_priv *hda_pvt;
@@ -634,6 +641,11 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev) hda_pvt->need_display_power = true;dev_set_drvdata (&hdev->dev, hda_pvt); +/* Allow the legacy codec driver to match again after unbind */ + ret =devm_add_action (&hdev->dev, hdac_hda_restore_dev_type, hdev); +if (ret) +return ret; +/* hold the ref while we probe */ hlink =snd_hdac_ext_bus_get_hlink_by_name (hdev->bus,dev_name (&hdev->dev));if (!hlink) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/5 ASoC: SOF: Intel: remove option to disable the common_hdmi handling
From: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 834c69d3b849625d5c5bb81a3425fc8deef5f16d ]
We've been using the same option for quite some time now, it's time to remove the kernel parameter to disable the common HDaudio codec handling.
Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind")
--- sound/soc/sof/intel/hda-codec.c | 12 +++--------- sound/soc/sof/intel/hda.c | 10 ++-------- sound/soc/sof/intel/hda.h | 6 ++---- 3 files changed, 7 insertions(+), 21 deletions(-)
sound/soc/sof/intel/hda-codec.c +3 -9
@@ -133,8 +133,7 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i }/* probe individual codec */ -static int hda_codec_probe (struct snd_sof_dev *sdev,int address, -bool hda_codec_use_common_hdmi) +static int hda_codec_probe (struct snd_sof_dev *sdev,int address) {#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv;
@@ -164,10 +163,6 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,if (!hda_priv)return -ENOMEM ; -/* only probe ASoC codec drivers for HDAC-HDMI */ -if (!hda_codec_use_common_hdmi && (resp &0xFFFF0000 ) ==IDISP_VID_INTEL ) - type =HDA_DEV_ASOC ; - codec =hda_codec_device_init (&hbus->core, address, type); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )
@@ -215,8 +210,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, }/* Codec initialization */ -void hda_codec_probe_bus (struct snd_sof_dev *sdev, -bool hda_codec_use_common_hdmi) +void hda_codec_probe_bus (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);int i, ret;
@@ -227,7 +221,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev,if (!(bus->codec_mask & (1 << i)))continue ; - ret =hda_codec_probe (sdev, i, hda_codec_use_common_hdmi); + ret =hda_codec_probe (sdev, i);if (ret <0 ) {dev_warn (bus->dev,"codec #%d probe error, ret: %d\n" , i, ret);
sound/soc/sof/intel/hda.c +2 -8
@@ -388,12 +388,6 @@ static int mclk_id_override = -1;module_param_named (mclk_id, mclk_id_override, int,0444 );MODULE_PARM_DESC (mclk_id,"SOF SSP mclk_id" ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -static bool hda_codec_use_common_hdmi =IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ); -module_param_named (use_common_hdmi, hda_codec_use_common_hdmi, bool,0444 ); -MODULE_PARM_DESC (use_common_hdmi,"SOF HDA use common HDMI codec driver" ); -#endif -static const struct hda_dsp_msg_code hda_dsp_rom_fw_error_texts[] = { {HDA_DSP_ROM_CSE_ERROR ,"error: cse error" }, {HDA_DSP_ROM_CSE_WRONG_RESPONSE ,"error: cse wrong response" },
@@ -924,7 +918,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)snd_hdac_ext_bus_get_ml_capabilities (bus);/* create codec instances */ -hda_codec_probe_bus (sdev, hda_codec_use_common_hdmi); +hda_codec_probe_bus (sdev);if (!HDA_IDISP_CODEC (bus->codec_mask))hda_codec_i915_display_power (sdev, false);
@@ -1340,7 +1334,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,if (*mach) { mach_params = &(*mach)->mach_params; mach_params->codec_mask = bus->codec_mask; - mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; + mach_params->common_hdmi_codec_drv = true; } }#else
sound/soc/sof/intel/hda.h +2 -4
@@ -705,8 +705,7 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev);/* * HDA Codec operations. */ -void hda_codec_probe_bus (struct snd_sof_dev *sdev, -bool hda_codec_use_common_hdmi); +void hda_codec_probe_bus (struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev);
@@ -722,8 +721,7 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev);#else -static inline void hda_codec_i915_display_power (struct snd_sof_dev *sdev, -bool enable) { } +static inline void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable) { }static inline int hda_codec_i915_init (struct snd_sof_dev *sdev) {return 0 ; }static inline int hda_codec_i915_exit (struct snd_sof_dev *sdev) {return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/5 ASoC: SOF: Intel: remove all dependencies on SND_SOC_HDAC_HDMI
From: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 2c6c809cc00b71b3195d76a69d603cc761716ab7 ]
remove all dependencies on SND_SOC_HDAC_HDMI and
clean-up ifdefs. The machine driver still supports this configuration used by the Skylake driver.
Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind")
--- sound/soc/sof/intel/hda-codec.c | 3 +-- sound/soc/sof/intel/hda.h | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda-codec.c +1 -2
@@ -231,8 +231,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); -#if IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ -IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable) {
sound/soc/sof/intel/hda.h +1 -3
@@ -711,9 +711,7 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev);#endif /* CONFIG_SND_SOC_SOF_HDA */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) && \ - (IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ -IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI )) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable);int hda_codec_i915_init (struct snd_sof_dev *sdev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/5 ASoC: SOF: Intel: hda-codec: simplify SND_SOC_SOF_HDA_AUDIO_CODEC handling
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit dc1d964a44dd9eb236f4e98b7b1eaa776093ca8b ]
Now that we have removed the dependency on SND_SOC_HDAC_HDMI, we can simplify the code and make the code conditional on a single #ifdef.
Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind")
--- sound/soc/sof/intel/hda-codec.c | 37 +++++++++++---------------------- sound/soc/sof/intel/hda.h | 10 +++++++-- 2 files changed, 20 insertions(+), 27 deletions(-)
sound/soc/sof/intel/hda-codec.c +12 -25
@@ -16,13 +16,12 @@#include <sound/sof.h> #include "../ops.h" #include "hda.h" +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )#include "../../codecs/hdac_hda.h" -#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #define CODEC_PROBE_RETRIES 3 -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )#define IDISP_VID_INTEL 0x80860000/* load the legacy HDA codec driver */
@@ -88,6 +87,7 @@ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable)snd_hdac_chip_updatew (bus,WAKEEN ,STATESTS_INT_MASK , mask); } +EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC );/* check jack status after resuming from suspend mode */ void hda_codec_jack_check (struct snd_sof_dev *sdev)
@@ -103,11 +103,6 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev)if (codec->jacktbl.used)pm_request_resume (&codec->core.dev); } -#else -void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) {} -void hda_codec_jack_check (struct snd_sof_dev *sdev) {} -#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ -EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC );EXPORT_SYMBOL_NS (hda_codec_jack_check,SND_SOC_SOF_HDA_AUDIO_CODEC );#if IS_ENABLED (CONFIG_SND_HDA_GENERIC )
@@ -135,10 +130,7 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i/* probe individual codec */ static int hda_codec_probe (struct snd_sof_dev *sdev,int address) { -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv; -int type =HDA_DEV_LEGACY ; -#endif struct hda_bus *hbus =sof_to_hbus (sdev);struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
@@ -158,12 +150,11 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)dev_dbg (sdev->dev,"HDA codec #%d probed OK: response: %x\n" , address, resp); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) hda_priv =devm_kzalloc (sdev->dev,sizeof (*hda_priv),GFP_KERNEL );if (!hda_priv)return -ENOMEM ; - codec =hda_codec_device_init (&hbus->core, address, type); + codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_LEGACY ); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )return ret;
@@ -186,25 +177,19 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)else codec->probe_id =0 ; -if (type ==HDA_DEV_LEGACY ) { - ret =hda_codec_load_module (codec); -/* -* handle ret==0 (no driver bound) as an error, but pass -* other return codes without modification -*/ -if (ret ==0 ) - ret = -ENOENT ; - } + ret =hda_codec_load_module (codec); +/* +* handle ret==0 (no driver bound) as an error, but pass +* other return codes without modification +*/ +if (ret ==0 ) + ret = -ENOENT ; out:if (ret <0 ) {snd_hdac_device_unregister (&codec->core);put_device (&codec->core.dev); } -#else - codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_ASOC ); - ret =PTR_ERR_OR_ZERO (codec); -#endif return ret; }
@@ -231,6 +216,8 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable)
sound/soc/sof/intel/hda.h +8 -2
@@ -701,7 +701,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);*/ void sof_hda_bus_init (struct hdac_bus *bus,struct device *dev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )/* * HDA Codec operations. */
@@ -709,7 +709,13 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev); -#endif /* CONFIG_SND_SOC_SOF_HDA */ +#else + +static inline void hda_codec_probe_bus (struct snd_sof_dev *sdev) { } +static inline void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) { } +static inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { } + +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/5 ASoC: hdac_hda: Allocate the private data at codec driver bind
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 7d357eae973a1e1933f81f55aa1b3b4e3064570f ]
The SOF HDA code allocates struct hdac_hda_priv and stores it as drvdata of the codec device before the codec driver is bound. The driver core clears drvdata on unbind, so after unbinding the codec driver via sysfs a subsequent bind dereferences a NULL pointer in hdac_hda_dev_probe().
All information in the private data can be derived from the codec device itself, so allocate and set it up in hdac_hda_dev_probe() as a device managed resource, which is released on unbind.
Remove the allocation from SOF, keeping the check for iDisp codecs without display audio component.
Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind")
--- sound/soc/codecs/hdac_hda.c | 12 +++++++++++- sound/soc/sof/intel/hda-codec.c | 22 ++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-)
sound/soc/codecs/hdac_hda.c +11 -1
@@ -606,10 +606,20 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = {static int hdac_hda_dev_probe (struct hdac_device *hdev) { -struct hdac_hda_priv *hda_pvt =dev_get_drvdata (&hdev->dev); +struct hdac_hda_priv *hda_pvt;struct hdac_ext_link *hlink;int ret; + hda_pvt =devm_kzalloc (&hdev->dev,sizeof (*hda_pvt),GFP_KERNEL ); +if (!hda_pvt) +return -ENOMEM ; + + hda_pvt->codec =dev_to_hda_codec (&hdev->dev); +/* Intel iDisp (HDMI/DP) codec */ +if (((hdev->vendor_id >>16 ) &0xFFFF ) ==0x8086 ) + hda_pvt->need_display_power = true; +dev_set_drvdata (&hdev->dev, hda_pvt); +/* hold the ref while we probe */ hlink =snd_hdac_ext_bus_get_link (hdev->bus,dev_name (&hdev->dev));if (!hlink) {
sound/soc/sof/intel/hda-codec.c +4 -18
@@ -18,8 +18,6 @@#include "hda.h" #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) -#include "../../codecs/hdac_hda.h" -#define CODEC_PROBE_RETRIES 3#define IDISP_VID_INTEL 0x80860000
@@ -130,7 +128,6 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i/* probe individual codec */ static int hda_codec_probe (struct snd_sof_dev *sdev,int address) { -struct hdac_hda_priv *hda_priv;struct hda_bus *hbus =sof_to_hbus (sdev);struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
@@ -150,26 +147,15 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)dev_dbg (sdev->dev,"HDA codec #%d probed OK: response: %x\n" , address, resp); - hda_priv =devm_kzalloc (sdev->dev,sizeof (*hda_priv),GFP_KERNEL ); -if (!hda_priv) -return -ENOMEM ; - codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_LEGACY ); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )return ret; - hda_priv->codec = codec; -dev_set_drvdata (&codec->core.dev, hda_priv); - -if ((resp &0xFFFF0000 ) ==IDISP_VID_INTEL ) { -if (!hbus->core.audio_component) { -dev_dbg (sdev->dev, -"iDisp hw present but no driver\n" ); - ret = -ENOENT ; - goto out; - } - hda_priv->need_display_power = true; +if ((resp &0xFFFF0000 ) ==IDISP_VID_INTEL && !hbus->core.audio_component) { +dev_dbg (sdev->dev,"iDisp hw present but no driver\n" ); + ret = -ENOENT ; + goto out; }if (is_generic_config (hbus))
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 5/5 ASoC: hdac_hda: Restore the codec device type on unbind
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 08a44bde821d4fe22c0b6e63da04b3c59ac243a8 ]
hdac_hda_codec_probe() changes the type of the codec device to HDA_DEV_ASOC to prevent snd_hda_codec_unregister() from unregistering the device when the card is freed.
The type is never restored, and hda_bus_match() requires the device and driver types to be equal. After unbinding the codec driver via sysfs the HDA_DEV_LEGACY codec drivers no longer match the device and bind fails with -ENODEV.
Restore HDA_DEV_LEGACY with a device managed action registered before the component, so it runs after the component and the card are gone.
--- sound/soc/codecs/hdac_hda.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/codecs/hdac_hda.c +12 -0
@@ -604,6 +604,13 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = { .endianness = 1, }; +static void hdac_hda_restore_dev_type (void *data) +{ +struct hdac_device *hdev = data; + + hdev->type =HDA_DEV_LEGACY ; +} +static int hdac_hda_dev_probe (struct hdac_device *hdev) {struct hdac_hda_priv *hda_pvt;
@@ -620,6 +627,11 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev) hda_pvt->need_display_power = true;dev_set_drvdata (&hdev->dev, hda_pvt); +/* Allow the legacy codec driver to match again after unbind */ + ret =devm_add_action (&hdev->dev, hdac_hda_restore_dev_type, hdev); +if (ret) +return ret; +/* hold the ref while we probe */ hlink =snd_hdac_ext_bus_get_link (hdev->bus,dev_name (&hdev->dev));if (!hlink) {
Signature · 1 line
2.53.0