OpenCloudOS-Kernel/sound/soc/intel/boards
Tomasz Figa 9fe9efd692
ASoC: Intel: kbl_rt5663_max98927: Fix kabylake_ssp_fixup function
This is a copy of commit 5c5f1baee8 ("ASoC: Intel:
kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function") applied to
the kbl_rt5663_max98927 board file.

Original explanation of the change:

kabylake_ssp_fixup function uses snd_soc_dpcm to identify the
codecs DAIs. The HW parameters are changed based on the codec DAI of the
stream. The earlier approach to get snd_soc_dpcm was using container_of()
macro on snd_pcm_hw_params.

The structures have been modified over time and snd_soc_dpcm does not have
snd_pcm_hw_params as a reference but as a copy. This causes the current
driver to crash when used.

This patch changes the way snd_soc_dpcm is extracted. snd_soc_pcm_runtime
holds 2 dpcm instances (one for playback and one for capture). 2 codecs
on the SSP are dmic (capture) and speakers (playback). Based on the
stream direction, snd_soc_dpcm is extracted from snd_soc_pcm_runtime.

Fixes a boot crash on a HP Chromebook x2:

[   16.582225] BUG: kernel NULL pointer dereference, address: 0000000000000050
[   16.582231] #PF: supervisor read access in kernel mode
[   16.582233] #PF: error_code(0x0000) - not-present page
[   16.582234] PGD 0 P4D 0
[   16.582238] Oops: 0000 [#1] PREEMPT SMP PTI
[   16.582241] CPU: 0 PID: 1980 Comm: cras Tainted: G         C        5.4.58 #1
[   16.582243] Hardware name: HP Soraka/Soraka, BIOS Google_Soraka.10431.75.0 08/30/2018
[   16.582247] RIP: 0010:kabylake_ssp_fixup+0x19/0xbb [snd_soc_kbl_rt5663_max98927]
[   16.582250] Code: c6 6f c5 80 c0 44 89 f2 31 c0 e8 3e c9 4c d6 eb de 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 53 48 89 f3 48 8b 46 c8 48 8b 4e d0 <48> 8b 49 10 4c 8b 78 10 4c 8b 31 4c 89 f7 48 c7 c6 4b c2 80 c0 e8
[   16.582252] RSP: 0000:ffffaf7e81e0b958 EFLAGS: 00010282
[   16.582254] RAX: ffffffff96f13e0d RBX: ffffaf7e81e0ba00 RCX: 0000000000000040
[   16.582256] RDX: ffffaf7e81e0ba00 RSI: ffffaf7e81e0ba00 RDI: ffffa3b208558028
[   16.582258] RBP: ffffaf7e81e0b970 R08: ffffa3b203b54160 R09: ffffaf7e81e0ba00
[   16.582259] R10: 0000000000000000 R11: ffffffffc080b345 R12: ffffa3b209fb6e00
[   16.582261] R13: ffffa3b1b1a47838 R14: ffffa3b1e6197f28 R15: ffffaf7e81e0ba00
[   16.582263] FS:  00007eb3f25aaf80(0000) GS:ffffa3b236a00000(0000) knlGS:0000000000000000
[   16.582265] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   16.582267] CR2: 0000000000000050 CR3: 0000000246bc8006 CR4: 00000000003606f0
[   16.582269] Call Trace:
[   16.582275]  snd_soc_link_be_hw_params_fixup+0x21/0x68
[   16.582278]  snd_soc_dai_hw_params+0x25/0x94
[   16.582282]  soc_pcm_hw_params+0x2d8/0x583
[   16.582288]  dpcm_be_dai_hw_params+0x172/0x29e
[   16.582291]  dpcm_fe_dai_hw_params+0x9f/0x12f
[   16.582295]  snd_pcm_hw_params+0x137/0x41c
[   16.582298]  snd_pcm_hw_params_user+0x3c/0x71
[   16.582301]  snd_pcm_common_ioctl+0x2c6/0x565
[   16.582304]  snd_pcm_ioctl+0x32/0x36
[   16.582307]  do_vfs_ioctl+0x506/0x783
[   16.582311]  ksys_ioctl+0x58/0x83
[   16.582313]  __x64_sys_ioctl+0x1a/0x1e
[   16.582316]  do_syscall_64+0x54/0x7e
[   16.582319]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   16.582322] RIP: 0033:0x7eb3f1886157
[   16.582324] Code: 8a 66 90 48 8b 05 11 dd 2b 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e1 dc 2b 00 f7 d8 64 89 01 48
[   16.582326] RSP: 002b:00007ffff7559818 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   16.582329] RAX: ffffffffffffffda RBX: 00005acc9188b140 RCX: 00007eb3f1886157
[   16.582330] RDX: 00007ffff7559940 RSI: 00000000c2604111 RDI: 000000000000001e
[   16.582332] RBP: 00007ffff7559840 R08: 0000000000000004 R09: 0000000000000000
[   16.582333] R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000bb80
[   16.582335] R13: 00005acc91702e80 R14: 00007ffff7559940 R15: 00005acc91702e80
[   16.582337] Modules linked in: rfcomm cmac algif_hash algif_skcipher af_alg uinput hid_google_hammer snd_soc_kbl_rt5663_max98927 snd_soc_hdac_hdmi snd_soc_dmic snd_soc_skl_ssp_clk snd_soc_skl snd_soc_sst_ipc snd_soc_sst_dsp snd_soc_hdac_hda snd_soc_acpi_intel_match snd_soc_acpi snd_hda_ext_core snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core ipu3_cio2 ipu3_imgu(C) videobuf2_v4l2 videobuf2_common videobuf2_dma_sg videobuf2_memops snd_soc_rt5663 snd_soc_max98927 snd_soc_rl6231 ov5670 ov13858 acpi_als v4l2_fwnode dw9714 fuse xt_MASQUERADE iio_trig_sysfs cros_ec_light_prox cros_ec_sensors cros_ec_sensors_core cros_ec_sensors_ring industrialio_triggered_buffer kfifo_buf industrialio cros_ec_sensorhub cdc_ether usbnet btusb btrtl btintel btbcm bluetooth ecdh_generic ecc lzo_rle lzo_compress iwlmvm zram iwl7000_mac80211 r8152 mii iwlwifi cfg80211 joydev
[   16.584243] gsmi: Log Shutdown Reason 0x03
[   16.584246] CR2: 0000000000000050
[   16.584248] ---[ end trace c8511d090c11edff ]---

Suggested-by: Łukasz Majczak <lmajczak@google.com>
Fixes: 2e5894d737 ("ASoC: pcm: Add support for DAI multicodec")
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20201014141624.4143453-1-tfiga@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-14 20:29:53 +01:00
..
Kconfig ASoC: Intel: Remove rt5640 support for baytrail solution 2020-10-06 15:12:20 +01:00
Makefile ASoC: Intel: Remove rt5640 support for baytrail solution 2020-10-06 15:12:20 +01:00
bdw-rt5650.c ASoC: Intel: bdw-rt5650: Mark FE DAIs as nonatomic 2020-10-05 18:18:41 +01:00
bdw-rt5677.c ASoC: Intel: bdw-rt5677: Mark FE DAIs as nonatomic 2020-10-05 18:18:42 +01:00
broadwell.c ASoC: Intel: broadwell: Mark FE DAIs as nonatomic 2020-10-05 18:18:43 +01:00
bxt_da7219_max98357a.c ASoC: Intel: bxt-da7219-max98357a: return -EINVAL on unrecognized speaker amplifier 2020-07-02 17:18:50 +01:00
bxt_rt298.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
bytcht_cx2072x.c ASoC: Intel: bytcht_cx2072x: simplify return handling 2020-08-17 15:42:59 +01:00
bytcht_da7213.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
bytcht_es8316.c Linux 5.9-rc5 2020-10-06 16:19:24 +01:00
bytcht_nocodec.c ASoC: intel: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer 2020-03-27 14:44:38 +00:00
bytcr_rt5640.c ASoC: Intel: Make atom components independent of sst-dsp 2020-10-06 15:12:27 +01:00
bytcr_rt5651.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cht_bsw_max98090_ti.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
cht_bsw_nau8824.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
cht_bsw_rt5645.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
cht_bsw_rt5672.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
cml_rt1011_rt5682.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
ehl_rt5660.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
glk_rt5682_max98357a.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
haswell.c ASoC: Intel: haswell: Mark FE DAIs as nonatomic 2020-10-05 18:18:44 +01:00
hda_dsp_common.c ASoC: Intel: hda_dsp_common: use static function in conditional block 2020-09-23 18:47:59 +01:00
hda_dsp_common.h ASoC: Intel: hda_dsp_common: use static function in conditional block 2020-09-23 18:47:59 +01:00
kbl_da7219_max98357a.c ASoC: SOF/Intel: clarify SPDX license with GPL-2.0-only 2020-05-01 17:45:24 +01:00
kbl_da7219_max98927.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
kbl_rt5660.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
kbl_rt5663_max98927.c ASoC: Intel: kbl_rt5663_max98927: Fix kabylake_ssp_fixup function 2020-10-14 20:29:53 +01:00
kbl_rt5663_rt5514_max98927.c Merge series "ASoC: meson: tdm fixes" from Jerome Brunet <jbrunet@baylibre.com>: 2020-07-30 21:00:36 +01:00
skl_hda_dsp_common.c ASoC: SOF/Intel: clarify SPDX license with GPL-2.0-only 2020-05-01 17:45:24 +01:00
skl_hda_dsp_common.h ASoC: intel/skl/hda - fix probe regression on systems without i915 2020-07-22 13:34:24 +01:00
skl_hda_dsp_generic.c ASoC: Intel: skl_hda_dsp_generic: Fix NULLptr dereference in autosuspend delay 2020-08-19 12:12:53 +01:00
skl_nau88l25_max98357a.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
skl_nau88l25_ssm4567.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
skl_rt286.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
sof_da7219_max98373.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
sof_maxim_common.c ASoC: Intel: tgl_max98373: fix a runtime pm issue in multi-thread case 2020-08-24 20:15:14 +01:00
sof_maxim_common.h ASoC: Intel: sof_sdw: Add MAX98373 support 2020-06-26 16:10:59 +01:00
sof_pcm512x.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00
sof_rt5682.c ASoC: SOF: Intel: Use DMI oem string search for tgl_max98373_rt5682 2020-09-11 15:52:19 +01:00
sof_sdw.c ASoC: Intel: sof_sdw: add version_id to avoid rt714/rt715 confusion 2020-10-05 14:40:22 +01:00
sof_sdw_common.h ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps 2020-09-23 18:13:17 +01:00
sof_sdw_dmic.c ASoC: Intel: sof_sdw: clean-up inclusion of header files 2020-08-24 13:41:36 +01:00
sof_sdw_hdmi.c ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded 2020-07-20 16:08:22 +01:00
sof_sdw_max98373.c ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps 2020-09-23 18:13:17 +01:00
sof_sdw_rt700.c ASoC: Intel: sof_sdw_rt700: add codec prefix 2020-09-23 18:13:15 +01:00
sof_sdw_rt711.c ASoC: Intel: sof_sdw: clean-up inclusion of header files 2020-08-24 13:41:36 +01:00
sof_sdw_rt711_sdca.c ASoC: intel: sof_sdw: add rt711 rt1316 rt714 SDCA codec support. 2020-08-24 13:41:35 +01:00
sof_sdw_rt715.c ASoC: SOF/Intel: clarify SPDX license with GPL-2.0-only 2020-05-01 17:45:24 +01:00
sof_sdw_rt715_sdca.c ASoC: intel: sof_sdw: add rt711 rt1316 rt714 SDCA codec support. 2020-08-24 13:41:35 +01:00
sof_sdw_rt1308.c ASoC: Intel: sof_sdw_rt1308: add extra check on init 2020-10-05 14:40:19 +01:00
sof_sdw_rt1316.c ASoC: Intel: sof_sdw_rt1316: add missing component string 2020-10-05 14:40:20 +01:00
sof_sdw_rt5682.c ASoC: Intel: sof_sdw: clean-up inclusion of header files 2020-08-24 13:41:36 +01:00
sof_wm8804.c ASoC: intel/boards: use asoc_substream_to_rtd() 2020-07-27 14:00:22 +01:00