Message ID | 20240223114626.1052784-3-cezary.rojewski@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | ALSA/ASoC: Conditionally skip i915 init and cleanups | expand |
On Fri, 23 Feb 2024 18:09:59 +0100, Cezary Rojewski wrote: > > On 2024-02-23 3:44 PM, Takashi Iwai wrote: > > On Fri, 23 Feb 2024 12:46:24 +0100, > > Cezary Rojewski wrote: > >> > >> If i915 does not support given platform but the hardware i.e.: HDAudio > >> codec is still there, the codec-probing procedure will succeed for such > >> device but the follow up initialization will always end up with -ENODEV. > >> > >> While bus could filter out address '2' which Intel's HDMI/DP codecs > >> always enumerate on, more robust approach is to check for i915 presence > >> before registering display codecs. > >> > >> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> > >> --- > >> sound/soc/codecs/hda.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c > >> index d2117e36ddd1..d9e7cd8aada2 100644 > >> --- a/sound/soc/codecs/hda.c > >> +++ b/sound/soc/codecs/hda.c > >> @@ -350,6 +350,11 @@ static int hda_hdev_attach(struct hdac_device *hdev) > >> struct hda_codec *codec = dev_to_hda_codec(&hdev->dev); > >> struct snd_soc_component_driver *comp_drv; > >> + if (hda_codec_is_display(codec) && > >> !hdev->bus->audio_component) { > >> + dev_dbg(&hdev->dev, "no i915, skip registration for 0x%08x\n", hdev->vendor_id); > >> + return 0; > > > > Should we return success here, or would it better with -ENODEV? > > IIUC, the code path is from the early hda_codec_driver_probe() hook, > > so returning an error can work. > > Good suggestion. Indeed attach() is called by probe() which treats > -ENODEV just fine. > > There is a consequence to that though. Logs from LKF show: > > snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_hdmi hdaudioB0D2: no > i915, skip registration for 0x80862811 > snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_generic hdaudioB0D2: > no i915, skip registration for 0x80862811 > snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_generic hdaudioB0D2: > no i915, skip registration for 0x80862811 > snd_hda_codec:snd_hda_codec_configure: hdaudio hdaudioB0D2: Unable to > bind the codec > snd_soc_avs 0000:00:1f.3: failed to config codec -19 > snd_soc_avs 0000:00:1f.3: Codec #2 probe error; disabling it... Yeah the latter two are basically fallbacks, and I guess we can disable them for ASoC case? An additional patch like below. thanks, Takashi --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -279,6 +279,10 @@ static int codec_bind_generic(struct hda_codec *codec) if (codec->probe_id) return -ENODEV; + /* no generic fallback for ASoC binding */ + if (codec->bus->core.ext_ops) + return -ENODEV; + if (is_likely_hdmi_codec(codec)) { codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; request_codec_module(codec);
On 2024-02-26 12:09 PM, Takashi Iwai wrote: > On Fri, 23 Feb 2024 18:09:59 +0100, > Cezary Rojewski wrote: >> >> On 2024-02-23 3:44 PM, Takashi Iwai wrote: >>> On Fri, 23 Feb 2024 12:46:24 +0100, >>> Cezary Rojewski wrote: >>>> >>>> If i915 does not support given platform but the hardware i.e.: HDAudio >>>> codec is still there, the codec-probing procedure will succeed for such >>>> device but the follow up initialization will always end up with -ENODEV. >>>> >>>> While bus could filter out address '2' which Intel's HDMI/DP codecs >>>> always enumerate on, more robust approach is to check for i915 presence >>>> before registering display codecs. >>>> >>>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> >>>> --- >>>> sound/soc/codecs/hda.c | 5 +++++ >>>> 1 file changed, 5 insertions(+) >>>> >>>> diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c >>>> index d2117e36ddd1..d9e7cd8aada2 100644 >>>> --- a/sound/soc/codecs/hda.c >>>> +++ b/sound/soc/codecs/hda.c >>>> @@ -350,6 +350,11 @@ static int hda_hdev_attach(struct hdac_device *hdev) >>>> struct hda_codec *codec = dev_to_hda_codec(&hdev->dev); >>>> struct snd_soc_component_driver *comp_drv; >>>> + if (hda_codec_is_display(codec) && >>>> !hdev->bus->audio_component) { >>>> + dev_dbg(&hdev->dev, "no i915, skip registration for 0x%08x\n", hdev->vendor_id); >>>> + return 0; >>> >>> Should we return success here, or would it better with -ENODEV? >>> IIUC, the code path is from the early hda_codec_driver_probe() hook, >>> so returning an error can work. >> >> Good suggestion. Indeed attach() is called by probe() which treats >> -ENODEV just fine. >> >> There is a consequence to that though. Logs from LKF show: >> >> snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_hdmi hdaudioB0D2: no >> i915, skip registration for 0x80862811 >> snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_generic hdaudioB0D2: >> no i915, skip registration for 0x80862811 >> snd_soc_hda_codec:hda_hdev_attach: snd_hda_codec_generic hdaudioB0D2: >> no i915, skip registration for 0x80862811 >> snd_hda_codec:snd_hda_codec_configure: hdaudio hdaudioB0D2: Unable to >> bind the codec >> snd_soc_avs 0000:00:1f.3: failed to config codec -19 >> snd_soc_avs 0000:00:1f.3: Codec #2 probe error; disabling it... > > Yeah the latter two are basically fallbacks, and I guess we can > disable them for ASoC case? An additional patch like below. Thanks for feedback, Takashi. One of the design philosophies for the avs-driver is to avoid any 'if (bus->ext_ops)' statements if possible. This is to keep runtime flow of snd_hda_intel and its DSP equivalent as close as possible. What I propose is: address the problem directly in the avs-driver by ignoring codecs for which probe_codec() returns -ENODEV. The TLDR of my previous message is: we do not want to do any kind of recovery e.g.: HDAudio controller reset if there is no supporting driver for given codec. Will sent a separate patch as part of v3. > --- a/sound/pci/hda/hda_bind.c > +++ b/sound/pci/hda/hda_bind.c > @@ -279,6 +279,10 @@ static int codec_bind_generic(struct hda_codec *codec) > if (codec->probe_id) > return -ENODEV; > > + /* no generic fallback for ASoC binding */ > + if (codec->bus->core.ext_ops) > + return -ENODEV; > + > if (is_likely_hdmi_codec(codec)) { > codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; > request_codec_module(codec);
diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c index d2117e36ddd1..d9e7cd8aada2 100644 --- a/sound/soc/codecs/hda.c +++ b/sound/soc/codecs/hda.c @@ -350,6 +350,11 @@ static int hda_hdev_attach(struct hdac_device *hdev) struct hda_codec *codec = dev_to_hda_codec(&hdev->dev); struct snd_soc_component_driver *comp_drv; + if (hda_codec_is_display(codec) && !hdev->bus->audio_component) { + dev_dbg(&hdev->dev, "no i915, skip registration for 0x%08x\n", hdev->vendor_id); + return 0; + } + comp_drv = devm_kzalloc(&hdev->dev, sizeof(*comp_drv), GFP_KERNEL); if (!comp_drv) return -ENOMEM;
If i915 does not support given platform but the hardware i.e.: HDAudio codec is still there, the codec-probing procedure will succeed for such device but the follow up initialization will always end up with -ENODEV. While bus could filter out address '2' which Intel's HDMI/DP codecs always enumerate on, more robust approach is to check for i915 presence before registering display codecs. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> --- sound/soc/codecs/hda.c | 5 +++++ 1 file changed, 5 insertions(+)