Skip to content

ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers#1697

Merged
bardliao merged 1 commit intothesofproject:release/sof-v5.0from
bardliao:pr-for-sof-v5.0
Jan 14, 2020
Merged

ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers#1697
bardliao merged 1 commit intothesofproject:release/sof-v5.0from
bardliao:pr-for-sof-v5.0

Conversation

@bardliao
Copy link
Collaborator

In case system has multiple HDA controllers, it can happen that
same HDA codec driver is used for codecs of multiple controllers.
In this case, SOF may fail to probe the HDA driver and SOF
initialization fails.

SOF HDA code currently relies that a call to request_module() will
also run device matching logic to attach driver to the codec instance.
However if driver for another HDA controller was already loaded and it
already loaded the HDA codec driver, this breaks current logic in SOF.
In this case the request_module() SOF does becomes a no-op and HDA
Codec driver is not attached to the codec instance sitting on the HDA
bus SOF is controlling. Typical scenario would be a system with both
external and internal GPUs, with driver of the external GPU loaded
first.

Fix this by adding similar logic as is used in legacy HDA driver
where an explicit device_attach() call is done after request_module().

Also add logic to propagate errors reported by device_attach() back
to caller. This also works in the case where drivers are not built
as modules.

Signed-off-by: Kai Vehmanen kai.vehmanen@linux.intel.com

The PR it to back port #1679 to sof-v5.0 branch. There are some conflicts when I tried to cherry-pick the commits from #1679 to release/sof-v5.0 branch. So, create this PR to make sure I didn't make mistake. @ClarexZhou Could you retest #1672 with release/sof-v5.0 + this PR?

In case system has multiple HDA controllers, it can happen that
same HDA codec driver is used for codecs of multiple controllers.
In this case, SOF may fail to probe the HDA driver and SOF
initialization fails.

SOF HDA code currently relies that a call to request_module() will
also run device matching logic to attach driver to the codec instance.
However if driver for another HDA controller was already loaded and it
already loaded the HDA codec driver, this breaks current logic in SOF.
In this case the request_module() SOF does becomes a no-op and HDA
Codec driver is not attached to the codec instance sitting on the HDA
bus SOF is controlling. Typical scenario would be a system with both
external and internal GPUs, with driver of the external GPU loaded
first.

Fix this by adding similar logic as is used in legacy HDA driver
where an explicit device_attach() call is done after request_module().

Also add logic to propagate errors reported by device_attach() back
to caller. This also works in the case where drivers are not built
as modules.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@bardliao bardliao requested review from kv2019i and plbossart January 13, 2020 06:17
@ClarexZhou
Copy link

Issue #1672 is fixed with this PR#1697

@ClarexZhou
Copy link

@kv2019i , error still seen if rmmod sof_pci_dev then modprobe sof_pci_dev again.
modprobeSOFafterRemove.txt

 [  228.255503] sof-audio-pci 0000:00:1f.3: warning: No matching ASoC machine driver found
[  228.255508] sof-audio-pci 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100
[  228.255735] sof-audio-pci 0000:00:1f.3: use msi interrupt mode
[  228.255904] sof-audio-pci 0000:00:1f.3: Linked as a consumer to 0000:00:02.0
[  228.255917] sof-audio-pci 0000:00:1f.3: bound 0000:00:02.0 (ops vgt_balloon_space [i915])
[  228.263161] sof-audio-pci 0000:00:1f.3: hda codecs found, mask 5
[  228.263164] sof-audio-pci 0000:00:1f.3: using HDA machine driver skl_hda_dsp_generic now
[  228.268831] HDMI HDA Codec ehdaudio1D2: Max dais supported: 3
[  228.272411] sof-audio-pci 0000:00:1f.3: unexpected ipc interrupt raised!
[  228.272413] sof-audio-pci 0000:00:1f.3: error: no reply expected, received 0x0
[  228.390470] sof-audio-pci 0000:00:1f.3: Firmware info: version 1:1:0-0f736
[  228.390478] sof-audio-pci 0000:00:1f.3: Firmware: ABI 3:7:0 Kernel ABI 3:6:0
[  228.390481] sof-audio-pci 0000:00:1f.3: warn: FW ABI is more recent than kernel
[  228.390810] sof-audio-pci 0000:00:1f.3: firmware boot complete
[  228.391559] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link iDisp1
[  228.391568] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link iDisp2
[  228.391573] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link iDisp3
[  228.391577] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link Analog Playback and Capture
[  228.391580] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link Digital Playback and Capture
[  228.391583] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link dmic01
[  228.391586] skl_hda_dsp_generic skl_hda_dsp_generic: info: override FE DAI link dmic16k
[  228.391594] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: CODEC DAI intel-hdmi-hifi1 not registered

@bardliao
Copy link
Collaborator Author

@kv2019i , error still seen if rmmod sof_pci_dev then modprobe sof_pci_dev again.

@ClarexZhou Will this issue be seen on sof-dev branch, too?

* handle ret==0 (no driver bound) as an error, but pass
* other return codes without modification
*/
if (ret == 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think checkpatch suggests to use if (!ret) in such cases

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh I had that in the original version, but as the return value is a more complex enumeration (both positive and negative values have specific meanings), I wanted to highlight zero on purpose.
Original review to sof-dev is at: #1679

@ClarexZhou
Copy link

Error not seen on sof-dev, Nvidia hdmi isn't loaded on sof-dev.

@ClarexZhou
Copy link

Can't use kmod scripts for module reload on sof-v5.0. Because snd_hda_codec_hdmi and snd_hda_intel is always in used 1 and not listed which module is using.

ubuntu@ubuntu-G3-3500:~/scripts/kmod_scripts$ sudo ./sof_remove.sh 
Removing sof_pci_dev
skipping sof_acpi_dev, not loaded
skipping snd_sof_pci, not loaded
skipping snd_sof_acpi, not loaded
Removing snd_sof_intel_byt
skipping snd_sof_intel_bdw, not loaded
Removing snd_sof_intel_hda_common
Removing snd_sof_intel_hda
Removing snd_sof_intel_ipc
Removing snd_sof_xtensa_dsp
Removing snd_soc_acpi_intel_match
skipping snd_soc_sof_rt5682, not loaded
skipping snd_soc_sst_bdw_rt5677_mach, not loaded
skipping snd_soc_sst_broadwell, not loaded
skipping snd_soc_sst_bxt_da7219_max98357a, not loaded
skipping snd_soc_sst_bxt_pcm512x, not loaded
skipping snd_soc_sst_bxt_rt298, not loaded
skipping snd_soc_sst_bxt_wm8804, not loaded
skipping snd_soc_sst_byt_cht_da7213, not loaded
skipping snd_soc_sst_byt_cht_es8316, not loaded
skipping snd_soc_sst_bytcr_rt5640, not loaded
skipping snd_soc_sst_bytcr_rt5651, not loaded
skipping snd_soc_sst_cht_bsw_max98090_ti, not loaded
skipping snd_soc_sst_cht_bsw_nau8824, not loaded
skipping snd_soc_sst_cht_bsw_rt5645, not loaded
skipping snd_soc_sst_cht_bsw_rt5672, not loaded
skipping snd_soc_sst_glk_rt5682_max98357a, not loaded
Removing snd_soc_skl_hda_dsp
skipping snd_soc_sdw_rt700, not loaded
skipping snd_soc_sdw_rt711_rt1308_rt715, not loaded
Removing snd_sof
skipping snd_sof_nocodec, not loaded
skipping snd_soc_da7213, not loaded
skipping snd_soc_da7219, not loaded
skipping snd_soc_pcm512x_i2c, not loaded
skipping snd_soc_pcm512x, not loaded
skipping snd_soc_rt274, not loaded
skipping snd_soc_rt286, not loaded
skipping snd_soc_rt298, not loaded
skipping snd_soc_rt700, not loaded
skipping snd_soc_rt711, not loaded
skipping snd_soc_rt1308_sdw, not loaded
skipping snd_soc_rt715, not loaded
skipping snd_soc_rt5640, not loaded
skipping snd_soc_rt5645, not loaded
skipping snd_soc_rt5651, not loaded
skipping snd_soc_rt5670, not loaded
skipping snd_soc_rt5677_spi, not loaded
skipping snd_soc_rt5677, not loaded
skipping snd_soc_rt5682, not loaded
skipping snd_soc_rl6231, not loaded
skipping snd_soc_rl6347a, not loaded
skipping snd_soc_wm8804_i2c, not loaded
skipping snd_soc_wm8804, not loaded
skipping snd_soc_max98090, not loaded
skipping snd_soc_ts3a227e, not loaded
skipping snd_soc_max98357a, not loaded
Removing snd_soc_hdac_hda
Removing snd_soc_hdac_hdmi
Removing snd_soc_dmic
Removing snd_hda_codec_realtek
Removing snd_hda_codec_generic
Removing snd_soc_acpi
Removing snd_hda_ext_core
skipping soundwire_intel_init, not loaded
skipping soundwire_intel, not loaded
skipping soundwire_cadence, not loaded
skipping regmap_sdw, not loaded
skipping soundwire_generic_allocation, not loaded
skipping soundwire_bus, not loaded
Removing snd_soc_core
Removing snd_hda_intel
rmmod: ERROR: Module snd_hda_intel is in use
Removing snd_hda_codec_hdmi
rmmod: ERROR: Module snd_hda_codec_hdmi is in use
Removing snd_hda_codec
rmmod: ERROR: Module snd_hda_codec is in use by: snd_hda_codec_hdmi snd_hda_intel
Removing snd_hda_core
rmmod: ERROR: Module snd_hda_core is in use by: snd_hda_codec_hdmi snd_hda_intel snd_hda_codec
Removing snd_hwdep
rmmod: ERROR: Module snd_hwdep is in use by: snd_hda_codec
Removing snd_pcm
rmmod: ERROR: Module snd_pcm is in use by: snd_hda_codec_hdmi snd_hda_intel snd_hda_codec snd_hda_core
ubuntu@ubuntu-G3-3500:~/scripts/kmod_scripts$ lsmod
Module                  Size  Used by
wmi_bmof               16384  0
snd_hda_codec_hdmi     61440  1
x86_pkg_temp_thermal    20480  0
intel_powerclamp       20480  0
snd_hda_intel          40960  1
snd_hda_codec         126976  2 snd_hda_codec_hdmi,snd_hda_intel
snd_hwdep              16384  1 snd_hda_codec
snd_hda_core           81920  3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
snd_pcm               114688  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
iwlmvm                331776  0
snd_seq_midi           20480  0
snd_seq_midi_event     16384  1 snd_seq_midi
snd_rawmidi            32768  1 snd_seq_midi
snd_seq                77824  2 snd_seq_midi,snd_seq_midi_event
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer              36864  2 snd_seq,snd_pcm
snd                    77824  11 snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_pcm,snd_rawmidi
soundcore              16384  1 snd
iwlwifi               278528  1 iwlmvm
processor_thermal_device    20480  0
intel_soc_dts_iosf     20480  1 processor_thermal_device
wmi                    28672  1 wmi_bmof
int3403_thermal        16384  0
int340x_thermal_zone    16384  2 int3403_thermal,processor_thermal_device
int3400_thermal        20480  0
acpi_thermal_rel       16384  1 int3400_thermal
nvidia_uvm            856064  0
efivarfs               16384  1
nvidia_drm             40960  4
nvidia_modeset       1093632  6 nvidia_drm
nvidia              20267008  276 nvidia_uvm,nvidia_modeset
i915                 1691648  2
i2c_algo_bit           16384  1 i915
drm_kms_helper        159744  2 nvidia_drm,i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
xhci_pci               20480  0
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
xhci_hcd              249856  1 xhci_pci
drm                   401408  8 drm_kms_helper,nvidia_drm,i915
i2c_hid                32768  0


@bardliao
Copy link
Collaborator Author

Can't use kmod scripts for module reload on sof-v5.0. Because snd_hda_codec_hdmi and snd_hda_intel is always in used 1 and not listed which module is using.

@ClarexZhou Is this a regression by this PR?

@kv2019i
Copy link
Collaborator

kv2019i commented Jan 13, 2020

@ClarexZhou It seems something else goes wrong in the case you get a failure:

[ 199.457051] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5
[ 202.464039] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5
...
[ 202.550758] WARNING: CPU: 2 PID: 3402 at fs/kernfs/dir.c:1504 kernfs_remove_by_name_ns+0x7f/0x90
[...]
[ 203.468056] BUG: unable to handle kernel paging request at ffff8e7843a30048
[...]
[ 203.468104] RIP: 0010:sof_hda_readw+0x0/0x10 [snd_sof_intel_hda_common]

... this is pretty bad and explains why the module unload fails. Probably good to file a separate bug about this.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumig the problem Claire raised is not a regression caused by this patch, then ok to merge this patch.

@lyakh
Copy link
Collaborator

lyakh commented Jan 13, 2020

As discussed with @kv2019i, it seems, that the actual problem would be in the hda bus implementation. As far as I understand, we are dealing here with the registration of a new HDA bus instance, upon which no bus scan is initiated. And that seems to be wrong. Compare to USB, PCI. If you hot-plus a card with a new internal USB bus on it, i assume it will be scanned automatically as soon as the bus instance is registered. Shouldn't the same happen here? Obviously, such a fix would be way out of scope of this PR, which aims to provide a fix for a specific problem.

@ClarexZhou
Copy link

Can't use kmod scripts for module reload on sof-v5.0. Because snd_hda_codec_hdmi and snd_hda_intel is always in used 1 and not listed which module is using.

@ClarexZhou Is this a regression by this PR?

This isn't regression from this PR. Should be there when NVidia HDMI is in use. Nvidia HDMI is using snd_hda_intel. Don't know how to unload this now.

@bardliao
Copy link
Collaborator Author

I will merge it since the original PR has merged into topic/sof-dev branch and there is no regression to sof-v5.0 branch.

@bardliao bardliao merged commit fb3a8e4 into thesofproject:release/sof-v5.0 Jan 14, 2020
bardliao pushed a commit to bardliao/linux that referenced this pull request Mar 5, 2025
idpf_rx_rsc() uses skb_transport_offset(skb) while the transport header
is not set yet.

This triggers the following warning for CONFIG_DEBUG_NET=y builds.

DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb))

[   69.261620] WARNING: CPU: 7 PID: 0 at ./include/linux/skbuff.h:3020 idpf_vport_splitq_napi_poll (include/linux/skbuff.h:3020) idpf
[   69.261629] Modules linked in: vfat fat dummy bridge intel_uncore_frequency_tpmi intel_uncore_frequency_common intel_vsec_tpmi idpf intel_vsec cdc_ncm cdc_eem cdc_ether usbnet mii xhci_pci xhci_hcd ehci_pci ehci_hcd libeth
[   69.261644] CPU: 7 UID: 0 PID: 0 Comm: swapper/7 Tainted: G S      W          6.14.0-smp-DEV thesofproject#1697
[   69.261648] Tainted: [S]=CPU_OUT_OF_SPEC, [W]=WARN
[   69.261650] RIP: 0010:idpf_vport_splitq_napi_poll (include/linux/skbuff.h:3020) idpf
[   69.261677] ? __warn (kernel/panic.c:242 kernel/panic.c:748)
[   69.261682] ? idpf_vport_splitq_napi_poll (include/linux/skbuff.h:3020) idpf
[   69.261687] ? report_bug (lib/bug.c:?)
[   69.261690] ? handle_bug (arch/x86/kernel/traps.c:285)
[   69.261694] ? exc_invalid_op (arch/x86/kernel/traps.c:309)
[   69.261697] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:621)
[   69.261700] ? __pfx_idpf_vport_splitq_napi_poll (drivers/net/ethernet/intel/idpf/idpf_txrx.c:4011) idpf
[   69.261704] ? idpf_vport_splitq_napi_poll (include/linux/skbuff.h:3020) idpf
[   69.261708] ? idpf_vport_splitq_napi_poll (drivers/net/ethernet/intel/idpf/idpf_txrx.c:3072) idpf
[   69.261712] __napi_poll (net/core/dev.c:7194)
[   69.261716] net_rx_action (net/core/dev.c:7265)
[   69.261718] ? __qdisc_run (net/sched/sch_generic.c:293)
[   69.261721] ? sched_clock (arch/x86/include/asm/preempt.h:84 arch/x86/kernel/tsc.c:288)
[   69.261726] handle_softirqs (kernel/softirq.c:561)

Fixes: 3a8845a ("idpf: add RX splitq napi poll support")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alan Brady <alan.brady@intel.com>
Cc: Joshua Hay <joshua.a.hay@intel.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://patch.msgid.link/20250226221253.1927782-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants