summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-06-14 11:37:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-06-14 11:37:06 -0400
commitbcb46a0e0e5c79291ffbc1e4b5d1d3d119e0f984 (patch)
treeaa8377f39f70c46ede21f8b3696815eb273d2934
parentc11fb13a117e5a6736481c779cb971249ed96016 (diff)
parent17d304604a88cf20c8dfd2c95d3decb9c4f8bca4 (diff)
Merge tag 'sound-5.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "It might feel like deja vu to receive a bulk of changes at rc5, and it happens again; we've got a collection of fixes for ASoC. Most of fixes are targeted for the newly merged SOF (Sound Open Firmware) stuff and the relevant fixes for Intel platforms. Other than that, there are a few regression fixes for the recent ASoC core changes and HD-audio quirk, as well as a couple of FireWire fixes and for other ASoC codecs" * tag 'sound-5.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (54 commits) Revert "ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops" ALSA: ice1712: Check correct return value to snd_i2c_sendbytes (EWS/DMX 6Fire) ALSA: oxfw: allow PCM capture for Stanton SCS.1m ALSA: firewire-motu: fix destruction of data for isochronous resources ASoC: Intel: sst: fix kmalloc call with wrong flags ASoC: core: Fix deadlock in snd_soc_instantiate_card() SoC: rt274: Fix internal jack assignment in set_jack callback ALSA: hdac: fix memory release for SST and SOF drivers ASoC: SOF: Intel: hda: use the defined ppcap functions ASoC: core: move DAI pre-links initiation to snd_soc_instantiate_card ASoC: Intel: cht_bsw_rt5672: fix kernel oops with platform_name override ASoC: Intel: cht_bsw_nau8824: fix kernel oops with platform_name override ASoC: Intel: bytcht_es8316: fix kernel oops with platform_name override ASoC: Intel: cht_bsw_max98090: fix kernel oops with platform_name override ASoC: sun4i-i2s: Add offset to RX channel select ASoC: sun4i-i2s: Fix sun8i tx channel offset mask ASoC: max98090: remove 24-bit format support if RJ is 0 ASoC: da7219: Fix build error without CONFIG_I2C ASoC: SOF: Intel: hda: Fix COMPILE_TEST build error ASoC: SOF: fix DSP oops definitions in FW ABI ...
-rw-r--r--include/sound/sof/dai.h1
-rw-r--r--include/sound/sof/header.h23
-rw-r--r--include/sound/sof/info.h20
-rw-r--r--include/sound/sof/xtensa.h9
-rw-r--r--include/uapi/sound/sof/abi.h2
-rw-r--r--sound/firewire/motu/motu-stream.c2
-rw-r--r--sound/firewire/oxfw/oxfw.c3
-rw-r--r--sound/hda/ext/hdac_ext_bus.c1
-rw-r--r--sound/pci/hda/hda_codec.c9
-rw-r--r--sound/pci/hda/patch_realtek.c91
-rw-r--r--sound/pci/ice1712/ews.c2
-rw-r--r--sound/soc/codecs/ak4458.c18
-rw-r--r--sound/soc/codecs/cs4265.c2
-rw-r--r--sound/soc/codecs/cs42xx8.c1
-rw-r--r--sound/soc/codecs/max98090.c16
-rw-r--r--sound/soc/codecs/rt274.c3
-rw-r--r--sound/soc/codecs/rt5670.c12
-rw-r--r--sound/soc/codecs/rt5677-spi.c5
-rw-r--r--sound/soc/fsl/fsl_asrc.c4
-rw-r--r--sound/soc/intel/atom/sst/sst_pvt.c4
-rw-r--r--sound/soc/intel/boards/bytcht_es8316.c2
-rw-r--r--sound/soc/intel/boards/cht_bsw_max98090_ti.c2
-rw-r--r--sound/soc/intel/boards/cht_bsw_nau8824.c2
-rw-r--r--sound/soc/intel/boards/cht_bsw_rt5672.c2
-rw-r--r--sound/soc/intel/boards/sof_rt5682.c11
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-byt-match.c17
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-cnl-match.c10
-rw-r--r--sound/soc/mediatek/Kconfig2
-rw-r--r--sound/soc/soc-core.c36
-rw-r--r--sound/soc/soc-dapm.c7
-rw-r--r--sound/soc/soc-pcm.c3
-rw-r--r--sound/soc/sof/Kconfig8
-rw-r--r--sound/soc/sof/control.c9
-rw-r--r--sound/soc/sof/core.c29
-rw-r--r--sound/soc/sof/intel/bdw.c26
-rw-r--r--sound/soc/sof/intel/byt.c25
-rw-r--r--sound/soc/sof/intel/cnl.c4
-rw-r--r--sound/soc/sof/intel/hda-ctrl.c102
-rw-r--r--sound/soc/sof/intel/hda-ipc.c17
-rw-r--r--sound/soc/sof/intel/hda.c129
-rw-r--r--sound/soc/sof/ipc.c26
-rw-r--r--sound/soc/sof/loader.c2
-rw-r--r--sound/soc/sof/pcm.c8
-rw-r--r--sound/soc/sof/xtensa/core.c2
-rw-r--r--sound/soc/sunxi/sun4i-codec.c9
-rw-r--r--sound/soc/sunxi/sun4i-i2s.c6
46 files changed, 465 insertions, 259 deletions
diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h
index 3b67c93ff101..3d174e20aa53 100644
--- a/include/sound/sof/dai.h
+++ b/include/sound/sof/dai.h
@@ -49,6 +49,7 @@ enum sof_ipc_dai_type {
49 SOF_DAI_INTEL_SSP, /**< Intel SSP */ 49 SOF_DAI_INTEL_SSP, /**< Intel SSP */
50 SOF_DAI_INTEL_DMIC, /**< Intel DMIC */ 50 SOF_DAI_INTEL_DMIC, /**< Intel DMIC */
51 SOF_DAI_INTEL_HDA, /**< Intel HD/A */ 51 SOF_DAI_INTEL_HDA, /**< Intel HD/A */
52 SOF_DAI_INTEL_SOUNDWIRE, /**< Intel SoundWire */
52}; 53};
53 54
54/* general purpose DAI configuration */ 55/* general purpose DAI configuration */
diff --git a/include/sound/sof/header.h b/include/sound/sof/header.h
index ccb6a004b37b..1efcf7b18ec2 100644
--- a/include/sound/sof/header.h
+++ b/include/sound/sof/header.h
@@ -48,6 +48,7 @@
48#define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U) 48#define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U)
49#define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U) 49#define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U)
50#define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U) 50#define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U)
51#define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU)
51 52
52/* 53/*
53 * DSP Command Message Types 54 * DSP Command Message Types
@@ -78,6 +79,7 @@
78#define SOF_IPC_COMP_GET_VALUE SOF_CMD_TYPE(0x002) 79#define SOF_IPC_COMP_GET_VALUE SOF_CMD_TYPE(0x002)
79#define SOF_IPC_COMP_SET_DATA SOF_CMD_TYPE(0x003) 80#define SOF_IPC_COMP_SET_DATA SOF_CMD_TYPE(0x003)
80#define SOF_IPC_COMP_GET_DATA SOF_CMD_TYPE(0x004) 81#define SOF_IPC_COMP_GET_DATA SOF_CMD_TYPE(0x004)
82#define SOF_IPC_COMP_NOTIFICATION SOF_CMD_TYPE(0x005)
81 83
82/* DAI messages */ 84/* DAI messages */
83#define SOF_IPC_DAI_CONFIG SOF_CMD_TYPE(0x001) 85#define SOF_IPC_DAI_CONFIG SOF_CMD_TYPE(0x001)
@@ -153,6 +155,27 @@ struct sof_ipc_compound_hdr {
153 uint32_t count; /**< count of 0 means end of compound sequence */ 155 uint32_t count; /**< count of 0 means end of compound sequence */
154} __packed; 156} __packed;
155 157
158/**
159 * OOPS header architecture specific data.
160 */
161struct sof_ipc_dsp_oops_arch_hdr {
162 uint32_t arch; /* Identifier of architecture */
163 uint32_t totalsize; /* Total size of oops message */
164} __packed;
165
166/**
167 * OOPS header platform specific data.
168 */
169struct sof_ipc_dsp_oops_plat_hdr {
170 uint32_t configidhi; /* ConfigID hi 32bits */
171 uint32_t configidlo; /* ConfigID lo 32bits */
172 uint32_t numaregs; /* Special regs num */
173 uint32_t stackoffset; /* Offset to stack pointer from beginning of
174 * oops message
175 */
176 uint32_t stackptr; /* Stack ptr */
177} __packed;
178
156/** @}*/ 179/** @}*/
157 180
158#endif 181#endif
diff --git a/include/sound/sof/info.h b/include/sound/sof/info.h
index 21dae04d8183..16528d2b4a50 100644
--- a/include/sound/sof/info.h
+++ b/include/sound/sof/info.h
@@ -18,6 +18,14 @@
18 18
19#define SOF_IPC_MAX_ELEMS 16 19#define SOF_IPC_MAX_ELEMS 16
20 20
21/*
22 * Firmware boot info flag bits (64-bit)
23 */
24#define SOF_IPC_INFO_BUILD BIT(0)
25#define SOF_IPC_INFO_LOCKS BIT(1)
26#define SOF_IPC_INFO_LOCKSV BIT(2)
27#define SOF_IPC_INFO_GDB BIT(3)
28
21/* extended data types that can be appended onto end of sof_ipc_fw_ready */ 29/* extended data types that can be appended onto end of sof_ipc_fw_ready */
22enum sof_ipc_ext_data { 30enum sof_ipc_ext_data {
23 SOF_IPC_EXT_DMA_BUFFER = 0, 31 SOF_IPC_EXT_DMA_BUFFER = 0,
@@ -49,16 +57,8 @@ struct sof_ipc_fw_ready {
49 uint32_t hostbox_size; 57 uint32_t hostbox_size;
50 struct sof_ipc_fw_version version; 58 struct sof_ipc_fw_version version;
51 59
52 /* Miscellaneous debug flags showing build/debug features enabled */ 60 /* Miscellaneous flags */
53 union { 61 uint64_t flags;
54 uint64_t reserved;
55 struct {
56 uint64_t build:1;
57 uint64_t locks:1;
58 uint64_t locks_verbose:1;
59 uint64_t gdb:1;
60 } bits;
61 } debug;
62 62
63 /* reserved for future use */ 63 /* reserved for future use */
64 uint32_t reserved[4]; 64 uint32_t reserved[4];
diff --git a/include/sound/sof/xtensa.h b/include/sound/sof/xtensa.h
index a7189984000d..d25c764b10e8 100644
--- a/include/sound/sof/xtensa.h
+++ b/include/sound/sof/xtensa.h
@@ -17,7 +17,8 @@
17 17
18/* Xtensa Firmware Oops data */ 18/* Xtensa Firmware Oops data */
19struct sof_ipc_dsp_oops_xtensa { 19struct sof_ipc_dsp_oops_xtensa {
20 struct sof_ipc_hdr hdr; 20 struct sof_ipc_dsp_oops_arch_hdr arch_hdr;
21 struct sof_ipc_dsp_oops_plat_hdr plat_hdr;
21 uint32_t exccause; 22 uint32_t exccause;
22 uint32_t excvaddr; 23 uint32_t excvaddr;
23 uint32_t ps; 24 uint32_t ps;
@@ -38,7 +39,11 @@ struct sof_ipc_dsp_oops_xtensa {
38 uint32_t intenable; 39 uint32_t intenable;
39 uint32_t interrupt; 40 uint32_t interrupt;
40 uint32_t sar; 41 uint32_t sar;
41 uint32_t stack; 42 uint32_t debugcause;
43 uint32_t windowbase;
44 uint32_t windowstart;
45 uint32_t excsave1;
46 uint32_t ar[];
42} __packed; 47} __packed;
43 48
44#endif 49#endif
diff --git a/include/uapi/sound/sof/abi.h b/include/uapi/sound/sof/abi.h
index 37e0a90dc9e6..0868eb47acf7 100644
--- a/include/uapi/sound/sof/abi.h
+++ b/include/uapi/sound/sof/abi.h
@@ -26,7 +26,7 @@
26 26
27/* SOF ABI version major, minor and patch numbers */ 27/* SOF ABI version major, minor and patch numbers */
28#define SOF_ABI_MAJOR 3 28#define SOF_ABI_MAJOR 3
29#define SOF_ABI_MINOR 4 29#define SOF_ABI_MINOR 6
30#define SOF_ABI_PATCH 0 30#define SOF_ABI_PATCH 0
31 31
32/* SOF ABI version number. Format within 32bit word is MMmmmppp */ 32/* SOF ABI version number. Format within 32bit word is MMmmmppp */
diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c
index 37e47fa7b0e3..81f7edc560d0 100644
--- a/sound/firewire/motu/motu-stream.c
+++ b/sound/firewire/motu/motu-stream.c
@@ -344,7 +344,7 @@ static void destroy_stream(struct snd_motu *motu,
344 } 344 }
345 345
346 amdtp_stream_destroy(stream); 346 amdtp_stream_destroy(stream);
347 fw_iso_resources_free(resources); 347 fw_iso_resources_destroy(resources);
348} 348}
349 349
350int snd_motu_stream_init_duplex(struct snd_motu *motu) 350int snd_motu_stream_init_duplex(struct snd_motu *motu)
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 5e31c460a90f..9fd145cc4b07 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -148,9 +148,6 @@ static int detect_quirks(struct snd_oxfw *oxfw)
148 oxfw->midi_input_ports = 0; 148 oxfw->midi_input_ports = 0;
149 oxfw->midi_output_ports = 0; 149 oxfw->midi_output_ports = 0;
150 150
151 /* Output stream exists but no data channels are useful. */
152 oxfw->has_output = false;
153
154 return snd_oxfw_scs1x_add(oxfw); 151 return snd_oxfw_scs1x_add(oxfw);
155 } 152 }
156 153
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c
index ad1b55a1f045..a3a113ef5d56 100644
--- a/sound/hda/ext/hdac_ext_bus.c
+++ b/sound/hda/ext/hdac_ext_bus.c
@@ -162,7 +162,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
162void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev) 162void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
163{ 163{
164 snd_hdac_device_exit(hdev); 164 snd_hdac_device_exit(hdev);
165 kfree(hdev);
166} 165}
167EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit); 166EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
168 167
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index c5e46df9c548..6c51b8363f8b 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -826,7 +826,14 @@ static int snd_hda_codec_dev_free(struct snd_device *device)
826 if (codec->core.type == HDA_DEV_LEGACY) 826 if (codec->core.type == HDA_DEV_LEGACY)
827 snd_hdac_device_unregister(&codec->core); 827 snd_hdac_device_unregister(&codec->core);
828 codec_display_power(codec, false); 828 codec_display_power(codec, false);
829 put_device(hda_codec_dev(codec)); 829
830 /*
831 * In the case of ASoC HD-audio bus, the device refcount is released in
832 * snd_hdac_ext_bus_device_remove() explicitly.
833 */
834 if (codec->core.type == HDA_DEV_LEGACY)
835 put_device(hda_codec_dev(codec));
836
830 return 0; 837 return 0;
831} 838}
832 839
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 974244978509..5b3c26991f26 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4120,18 +4120,19 @@ static struct coef_fw alc225_pre_hsmode[] = {
4120static void alc_headset_mode_unplugged(struct hda_codec *codec) 4120static void alc_headset_mode_unplugged(struct hda_codec *codec)
4121{ 4121{
4122 static struct coef_fw coef0255[] = { 4122 static struct coef_fw coef0255[] = {
4123 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4123 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */ 4124 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4124 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/ 4125 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4125 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */ 4126 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4126 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */ 4127 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4127 {} 4128 {}
4128 }; 4129 };
4129 static struct coef_fw coef0255_1[] = {
4130 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4131 {}
4132 };
4133 static struct coef_fw coef0256[] = { 4130 static struct coef_fw coef0256[] = {
4134 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */ 4131 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4132 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4133 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4134 WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4135 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4135 {} 4136 {}
4136 }; 4137 };
4137 static struct coef_fw coef0233[] = { 4138 static struct coef_fw coef0233[] = {
@@ -4194,13 +4195,11 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
4194 4195
4195 switch (codec->core.vendor_id) { 4196 switch (codec->core.vendor_id) {
4196 case 0x10ec0255: 4197 case 0x10ec0255:
4197 alc_process_coef_fw(codec, coef0255_1);
4198 alc_process_coef_fw(codec, coef0255); 4198 alc_process_coef_fw(codec, coef0255);
4199 break; 4199 break;
4200 case 0x10ec0236: 4200 case 0x10ec0236:
4201 case 0x10ec0256: 4201 case 0x10ec0256:
4202 alc_process_coef_fw(codec, coef0256); 4202 alc_process_coef_fw(codec, coef0256);
4203 alc_process_coef_fw(codec, coef0255);
4204 break; 4203 break;
4205 case 0x10ec0234: 4204 case 0x10ec0234:
4206 case 0x10ec0274: 4205 case 0x10ec0274:
@@ -4253,6 +4252,12 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4253 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */ 4252 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4254 {} 4253 {}
4255 }; 4254 };
4255 static struct coef_fw coef0256[] = {
4256 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
4257 WRITE_COEFEX(0x57, 0x03, 0x09a3),
4258 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4259 {}
4260 };
4256 static struct coef_fw coef0233[] = { 4261 static struct coef_fw coef0233[] = {
4257 UPDATE_COEF(0x35, 0, 1<<14), 4262 UPDATE_COEF(0x35, 0, 1<<14),
4258 WRITE_COEF(0x06, 0x2100), 4263 WRITE_COEF(0x06, 0x2100),
@@ -4300,14 +4305,19 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4300 }; 4305 };
4301 4306
4302 switch (codec->core.vendor_id) { 4307 switch (codec->core.vendor_id) {
4303 case 0x10ec0236:
4304 case 0x10ec0255: 4308 case 0x10ec0255:
4305 case 0x10ec0256:
4306 alc_write_coef_idx(codec, 0x45, 0xc489); 4309 alc_write_coef_idx(codec, 0x45, 0xc489);
4307 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 4310 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4308 alc_process_coef_fw(codec, coef0255); 4311 alc_process_coef_fw(codec, coef0255);
4309 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 4312 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4310 break; 4313 break;
4314 case 0x10ec0236:
4315 case 0x10ec0256:
4316 alc_write_coef_idx(codec, 0x45, 0xc489);
4317 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4318 alc_process_coef_fw(codec, coef0256);
4319 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4320 break;
4311 case 0x10ec0234: 4321 case 0x10ec0234:
4312 case 0x10ec0274: 4322 case 0x10ec0274:
4313 case 0x10ec0294: 4323 case 0x10ec0294:
@@ -4389,6 +4399,14 @@ static void alc_headset_mode_default(struct hda_codec *codec)
4389 WRITE_COEF(0x49, 0x0049), 4399 WRITE_COEF(0x49, 0x0049),
4390 {} 4400 {}
4391 }; 4401 };
4402 static struct coef_fw coef0256[] = {
4403 WRITE_COEF(0x45, 0xc489),
4404 WRITE_COEFEX(0x57, 0x03, 0x0da3),
4405 WRITE_COEF(0x49, 0x0049),
4406 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4407 WRITE_COEF(0x06, 0x6100),
4408 {}
4409 };
4392 static struct coef_fw coef0233[] = { 4410 static struct coef_fw coef0233[] = {
4393 WRITE_COEF(0x06, 0x2100), 4411 WRITE_COEF(0x06, 0x2100),
4394 WRITE_COEF(0x32, 0x4ea3), 4412 WRITE_COEF(0x32, 0x4ea3),
@@ -4439,11 +4457,16 @@ static void alc_headset_mode_default(struct hda_codec *codec)
4439 alc_process_coef_fw(codec, alc225_pre_hsmode); 4457 alc_process_coef_fw(codec, alc225_pre_hsmode);
4440 alc_process_coef_fw(codec, coef0225); 4458 alc_process_coef_fw(codec, coef0225);
4441 break; 4459 break;
4442 case 0x10ec0236:
4443 case 0x10ec0255: 4460 case 0x10ec0255:
4444 case 0x10ec0256:
4445 alc_process_coef_fw(codec, coef0255); 4461 alc_process_coef_fw(codec, coef0255);
4446 break; 4462 break;
4463 case 0x10ec0236:
4464 case 0x10ec0256:
4465 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4466 alc_write_coef_idx(codec, 0x45, 0xc089);
4467 msleep(50);
4468 alc_process_coef_fw(codec, coef0256);
4469 break;
4447 case 0x10ec0234: 4470 case 0x10ec0234:
4448 case 0x10ec0274: 4471 case 0x10ec0274:
4449 case 0x10ec0294: 4472 case 0x10ec0294:
@@ -4487,8 +4510,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
4487 }; 4510 };
4488 static struct coef_fw coef0256[] = { 4511 static struct coef_fw coef0256[] = {
4489 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */ 4512 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4490 WRITE_COEF(0x1b, 0x0c6b), 4513 WRITE_COEF(0x1b, 0x0e6b),
4491 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4492 {} 4514 {}
4493 }; 4515 };
4494 static struct coef_fw coef0233[] = { 4516 static struct coef_fw coef0233[] = {
@@ -4606,8 +4628,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
4606 }; 4628 };
4607 static struct coef_fw coef0256[] = { 4629 static struct coef_fw coef0256[] = {
4608 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */ 4630 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4609 WRITE_COEF(0x1b, 0x0c6b), 4631 WRITE_COEF(0x1b, 0x0e6b),
4610 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4611 {} 4632 {}
4612 }; 4633 };
4613 static struct coef_fw coef0233[] = { 4634 static struct coef_fw coef0233[] = {
@@ -4739,13 +4760,37 @@ static void alc_determine_headset_type(struct hda_codec *codec)
4739 }; 4760 };
4740 4761
4741 switch (codec->core.vendor_id) { 4762 switch (codec->core.vendor_id) {
4742 case 0x10ec0236:
4743 case 0x10ec0255: 4763 case 0x10ec0255:
4764 alc_process_coef_fw(codec, coef0255);
4765 msleep(300);
4766 val = alc_read_coef_idx(codec, 0x46);
4767 is_ctia = (val & 0x0070) == 0x0070;
4768 break;
4769 case 0x10ec0236:
4744 case 0x10ec0256: 4770 case 0x10ec0256:
4771 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
4772 alc_write_coef_idx(codec, 0x06, 0x6104);
4773 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
4774
4775 snd_hda_codec_write(codec, 0x21, 0,
4776 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4777 msleep(80);
4778 snd_hda_codec_write(codec, 0x21, 0,
4779 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4780
4745 alc_process_coef_fw(codec, coef0255); 4781 alc_process_coef_fw(codec, coef0255);
4746 msleep(300); 4782 msleep(300);
4747 val = alc_read_coef_idx(codec, 0x46); 4783 val = alc_read_coef_idx(codec, 0x46);
4748 is_ctia = (val & 0x0070) == 0x0070; 4784 is_ctia = (val & 0x0070) == 0x0070;
4785
4786 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
4787 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4788
4789 snd_hda_codec_write(codec, 0x21, 0,
4790 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4791 msleep(80);
4792 snd_hda_codec_write(codec, 0x21, 0,
4793 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4749 break; 4794 break;
4750 case 0x10ec0234: 4795 case 0x10ec0234:
4751 case 0x10ec0274: 4796 case 0x10ec0274:
@@ -6210,15 +6255,13 @@ static const struct hda_fixup alc269_fixups[] = {
6210 .chain_id = ALC269_FIXUP_THINKPAD_ACPI, 6255 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6211 }, 6256 },
6212 [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = { 6257 [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
6213 .type = HDA_FIXUP_VERBS, 6258 .type = HDA_FIXUP_PINS,
6214 .v.verbs = (const struct hda_verb[]) { 6259 .v.pins = (const struct hda_pintbl[]) {
6215 /* Enable the Mic */ 6260 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6216 { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 }, 6261 { }
6217 { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
6218 {}
6219 }, 6262 },
6220 .chained = true, 6263 .chained = true,
6221 .chain_id = ALC269_FIXUP_LIFEBOOK_EXTMIC 6264 .chain_id = ALC255_FIXUP_HEADSET_MODE
6222 }, 6265 },
6223 [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = { 6266 [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6224 .type = HDA_FIXUP_PINS, 6267 .type = HDA_FIXUP_PINS,
@@ -7263,10 +7306,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
7263 {0x19, 0x0181303F}, 7306 {0x19, 0x0181303F},
7264 {0x21, 0x0221102f}), 7307 {0x21, 0x0221102f}),
7265 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE, 7308 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
7266 {0x12, 0x90a60140},
7267 {0x14, 0x90170120},
7268 {0x21, 0x02211030}),
7269 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
7270 {0x12, 0x90a601c0}, 7309 {0x12, 0x90a601c0},
7271 {0x14, 0x90171120}, 7310 {0x14, 0x90171120},
7272 {0x21, 0x02211030}), 7311 {0x21, 0x02211030}),
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 3729b132ad85..fe08dd9f1564 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -812,7 +812,7 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg
812 812
813 snd_i2c_lock(ice->i2c); 813 snd_i2c_lock(ice->i2c);
814 byte = reg; 814 byte = reg;
815 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1)) { 815 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
816 snd_i2c_unlock(ice->i2c); 816 snd_i2c_unlock(ice->i2c);
817 dev_err(ice->card->dev, "cannot send pca\n"); 817 dev_err(ice->card->dev, "cannot send pca\n");
818 return -EIO; 818 return -EIO;
diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index eab7c76cfcd9..71562154c0b1 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -304,7 +304,10 @@ static int ak4458_rstn_control(struct snd_soc_component *component, int bit)
304 AK4458_00_CONTROL1, 304 AK4458_00_CONTROL1,
305 AK4458_RSTN_MASK, 305 AK4458_RSTN_MASK,
306 0x0); 306 0x0);
307 return ret; 307 if (ret < 0)
308 return ret;
309
310 return 0;
308} 311}
309 312
310static int ak4458_hw_params(struct snd_pcm_substream *substream, 313static int ak4458_hw_params(struct snd_pcm_substream *substream,
@@ -536,9 +539,10 @@ static void ak4458_power_on(struct ak4458_priv *ak4458)
536 } 539 }
537} 540}
538 541
539static void ak4458_init(struct snd_soc_component *component) 542static int ak4458_init(struct snd_soc_component *component)
540{ 543{
541 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); 544 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
545 int ret;
542 546
543 /* External Mute ON */ 547 /* External Mute ON */
544 if (ak4458->mute_gpiod) 548 if (ak4458->mute_gpiod)
@@ -546,21 +550,21 @@ static void ak4458_init(struct snd_soc_component *component)
546 550
547 ak4458_power_on(ak4458); 551 ak4458_power_on(ak4458);
548 552
549 snd_soc_component_update_bits(component, AK4458_00_CONTROL1, 553 ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
550 0x80, 0x80); /* ACKS bit = 1; 10000000 */ 554 0x80, 0x80); /* ACKS bit = 1; 10000000 */
555 if (ret < 0)
556 return ret;
551 557
552 ak4458_rstn_control(component, 1); 558 return ak4458_rstn_control(component, 1);
553} 559}
554 560
555static int ak4458_probe(struct snd_soc_component *component) 561static int ak4458_probe(struct snd_soc_component *component)
556{ 562{
557 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); 563 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
558 564
559 ak4458_init(component);
560
561 ak4458->fs = 48000; 565 ak4458->fs = 48000;
562 566
563 return 0; 567 return ak4458_init(component);
564} 568}
565 569
566static void ak4458_remove(struct snd_soc_component *component) 570static void ak4458_remove(struct snd_soc_component *component)
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c
index ab27d2b94d02..c0190ec59e74 100644
--- a/sound/soc/codecs/cs4265.c
+++ b/sound/soc/codecs/cs4265.c
@@ -60,7 +60,7 @@ static const struct reg_default cs4265_reg_defaults[] = {
60static bool cs4265_readable_register(struct device *dev, unsigned int reg) 60static bool cs4265_readable_register(struct device *dev, unsigned int reg)
61{ 61{
62 switch (reg) { 62 switch (reg) {
63 case CS4265_CHIP_ID ... CS4265_SPDIF_CTL2: 63 case CS4265_CHIP_ID ... CS4265_MAX_REGISTER:
64 return true; 64 return true;
65 default: 65 default:
66 return false; 66 return false;
diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index ebb9e0cf8364..28a4ac36c4f8 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -558,6 +558,7 @@ static int cs42xx8_runtime_resume(struct device *dev)
558 msleep(5); 558 msleep(5);
559 559
560 regcache_cache_only(cs42xx8->regmap, false); 560 regcache_cache_only(cs42xx8->regmap, false);
561 regcache_mark_dirty(cs42xx8->regmap);
561 562
562 ret = regcache_sync(cs42xx8->regmap); 563 ret = regcache_sync(cs42xx8->regmap);
563 if (ret) { 564 if (ret) {
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 7619ea31ab50..ada8c25e643d 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -1909,6 +1909,21 @@ static int max98090_configure_dmic(struct max98090_priv *max98090,
1909 return 0; 1909 return 0;
1910} 1910}
1911 1911
1912static int max98090_dai_startup(struct snd_pcm_substream *substream,
1913 struct snd_soc_dai *dai)
1914{
1915 struct snd_soc_component *component = dai->component;
1916 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
1917 unsigned int fmt = max98090->dai_fmt;
1918
1919 /* Remove 24-bit format support if it is not in right justified mode. */
1920 if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_RIGHT_J) {
1921 substream->runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
1922 snd_pcm_hw_constraint_msbits(substream->runtime, 0, 16, 16);
1923 }
1924 return 0;
1925}
1926
1912static int max98090_dai_hw_params(struct snd_pcm_substream *substream, 1927static int max98090_dai_hw_params(struct snd_pcm_substream *substream,
1913 struct snd_pcm_hw_params *params, 1928 struct snd_pcm_hw_params *params,
1914 struct snd_soc_dai *dai) 1929 struct snd_soc_dai *dai)
@@ -2316,6 +2331,7 @@ EXPORT_SYMBOL_GPL(max98090_mic_detect);
2316#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) 2331#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
2317 2332
2318static const struct snd_soc_dai_ops max98090_dai_ops = { 2333static const struct snd_soc_dai_ops max98090_dai_ops = {
2334 .startup = max98090_dai_startup,
2319 .set_sysclk = max98090_dai_set_sysclk, 2335 .set_sysclk = max98090_dai_set_sysclk,
2320 .set_fmt = max98090_dai_set_fmt, 2336 .set_fmt = max98090_dai_set_fmt,
2321 .set_tdm_slot = max98090_set_tdm_slot, 2337 .set_tdm_slot = max98090_set_tdm_slot,
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c
index adf59039a3b6..cdd312db3e78 100644
--- a/sound/soc/codecs/rt274.c
+++ b/sound/soc/codecs/rt274.c
@@ -405,6 +405,8 @@ static int rt274_mic_detect(struct snd_soc_component *component,
405{ 405{
406 struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); 406 struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component);
407 407
408 rt274->jack = jack;
409
408 if (jack == NULL) { 410 if (jack == NULL) {
409 /* Disable jack detection */ 411 /* Disable jack detection */
410 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, 412 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL,
@@ -412,7 +414,6 @@ static int rt274_mic_detect(struct snd_soc_component *component,
412 414
413 return 0; 415 return 0;
414 } 416 }
415 rt274->jack = jack;
416 417
417 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, 418 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL,
418 RT274_IRQ_EN, RT274_IRQ_EN); 419 RT274_IRQ_EN, RT274_IRQ_EN);
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index 9a037108b1ae..a746e11ccfe3 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -2882,6 +2882,18 @@ static const struct dmi_system_id dmi_platform_intel_quirks[] = {
2882 RT5670_DEV_GPIO | 2882 RT5670_DEV_GPIO |
2883 RT5670_JD_MODE3), 2883 RT5670_JD_MODE3),
2884 }, 2884 },
2885 {
2886 .callback = rt5670_quirk_cb,
2887 .ident = "Aegex 10 tablet (RU2)",
2888 .matches = {
2889 DMI_MATCH(DMI_SYS_VENDOR, "AEGEX"),
2890 DMI_MATCH(DMI_PRODUCT_VERSION, "RU2"),
2891 },
2892 .driver_data = (unsigned long *)(RT5670_DMIC_EN |
2893 RT5670_DMIC2_INR |
2894 RT5670_DEV_GPIO |
2895 RT5670_JD_MODE3),
2896 },
2885 {} 2897 {}
2886}; 2898};
2887 2899
diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c
index 84b6bd8b50e1..a4dfa0345c6e 100644
--- a/sound/soc/codecs/rt5677-spi.c
+++ b/sound/soc/codecs/rt5677-spi.c
@@ -101,7 +101,7 @@ static void rt5677_spi_reverse(u8 *dst, u32 dstlen, const u8 *src, u32 srclen)
101 u32 word_size = min_t(u32, dstlen, 8); 101 u32 word_size = min_t(u32, dstlen, 8);
102 102
103 for (w = 0; w < dstlen; w += word_size) { 103 for (w = 0; w < dstlen; w += word_size) {
104 for (i = 0; i < word_size; i++) { 104 for (i = 0; i < word_size && i + w < dstlen; i++) {
105 si = w + word_size - i - 1; 105 si = w + word_size - i - 1;
106 dst[w + i] = si < srclen ? src[si] : 0; 106 dst[w + i] = si < srclen ? src[si] : 0;
107 } 107 }
@@ -152,8 +152,9 @@ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len)
152 status |= spi_sync(g_spi, &m); 152 status |= spi_sync(g_spi, &m);
153 mutex_unlock(&spi_mutex); 153 mutex_unlock(&spi_mutex);
154 154
155
155 /* Copy data back to caller buffer */ 156 /* Copy data back to caller buffer */
156 rt5677_spi_reverse(cb + offset, t[1].len, body, t[1].len); 157 rt5677_spi_reverse(cb + offset, len - offset, body, t[1].len);
157 } 158 }
158 return status; 159 return status;
159} 160}
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 0b937924d2e4..ea035c12a325 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -282,8 +282,8 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
282 return -EINVAL; 282 return -EINVAL;
283 } 283 }
284 284
285 if ((outrate > 8000 && outrate < 30000) && 285 if ((outrate >= 8000 && outrate <= 30000) &&
286 (outrate/inrate > 24 || inrate/outrate > 8)) { 286 (outrate > 24 * inrate || inrate > 8 * outrate)) {
287 pair_err("exceed supported ratio range [1/24, 8] for \ 287 pair_err("exceed supported ratio range [1/24, 8] for \
288 inrate/outrate: %d/%d\n", inrate, outrate); 288 inrate/outrate: %d/%d\n", inrate, outrate);
289 return -EINVAL; 289 return -EINVAL;
diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c
index 1ec298dd0e4f..13db2854db3e 100644
--- a/sound/soc/intel/atom/sst/sst_pvt.c
+++ b/sound/soc/intel/atom/sst/sst_pvt.c
@@ -158,11 +158,11 @@ int sst_create_ipc_msg(struct ipc_post **arg, bool large)
158{ 158{
159 struct ipc_post *msg; 159 struct ipc_post *msg;
160 160
161 msg = kzalloc(sizeof(*msg), GFP_KERNEL); 161 msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
162 if (!msg) 162 if (!msg)
163 return -ENOMEM; 163 return -ENOMEM;
164 if (large) { 164 if (large) {
165 msg->mailbox_data = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL); 165 msg->mailbox_data = kzalloc(SST_MAILBOX_SIZE, GFP_ATOMIC);
166 if (!msg->mailbox_data) { 166 if (!msg->mailbox_data) {
167 kfree(msg); 167 kfree(msg);
168 return -ENOMEM; 168 return -ENOMEM;
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 1f00d473793f..2fe1ce879123 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -487,6 +487,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
487 } 487 }
488 488
489 /* override plaform name, if required */ 489 /* override plaform name, if required */
490 byt_cht_es8316_card.dev = dev;
490 platform_name = mach->mach_params.platform; 491 platform_name = mach->mach_params.platform;
491 492
492 ret = snd_soc_fixup_dai_links_platform_name(&byt_cht_es8316_card, 493 ret = snd_soc_fixup_dai_links_platform_name(&byt_cht_es8316_card,
@@ -567,7 +568,6 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
567 (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo", 568 (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo",
568 mic_name[BYT_CHT_ES8316_MAP(quirk)]); 569 mic_name[BYT_CHT_ES8316_MAP(quirk)]);
569 byt_cht_es8316_card.long_name = long_name; 570 byt_cht_es8316_card.long_name = long_name;
570 byt_cht_es8316_card.dev = dev;
571 snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv); 571 snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
572 572
573 ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card); 573 ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card);
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index d72623f508b7..613b37172441 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -446,6 +446,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
446 } 446 }
447 447
448 /* override plaform name, if required */ 448 /* override plaform name, if required */
449 snd_soc_card_cht.dev = &pdev->dev;
449 mach = (&pdev->dev)->platform_data; 450 mach = (&pdev->dev)->platform_data;
450 platform_name = mach->mach_params.platform; 451 platform_name = mach->mach_params.platform;
451 452
@@ -455,7 +456,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
455 return ret_val; 456 return ret_val;
456 457
457 /* register the soc card */ 458 /* register the soc card */
458 snd_soc_card_cht.dev = &pdev->dev;
459 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 459 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
460 460
461 if (drv->quirks & QUIRK_PMC_PLT_CLK_0) 461 if (drv->quirks & QUIRK_PMC_PLT_CLK_0)
diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c
index 1c17f82fc922..b0d658e3d3f7 100644
--- a/sound/soc/intel/boards/cht_bsw_nau8824.c
+++ b/sound/soc/intel/boards/cht_bsw_nau8824.c
@@ -249,6 +249,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
249 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 249 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
250 250
251 /* override plaform name, if required */ 251 /* override plaform name, if required */
252 snd_soc_card_cht.dev = &pdev->dev;
252 mach = (&pdev->dev)->platform_data; 253 mach = (&pdev->dev)->platform_data;
253 platform_name = mach->mach_params.platform; 254 platform_name = mach->mach_params.platform;
254 255
@@ -258,7 +259,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
258 return ret_val; 259 return ret_val;
259 260
260 /* register the soc card */ 261 /* register the soc card */
261 snd_soc_card_cht.dev = &pdev->dev;
262 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); 262 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
263 if (ret_val) { 263 if (ret_val) {
264 dev_err(&pdev->dev, 264 dev_err(&pdev->dev,
diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c
index 1731cc0fac25..028e571f6a77 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5672.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5672.c
@@ -418,6 +418,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
418 } 418 }
419 419
420 /* override plaform name, if required */ 420 /* override plaform name, if required */
421 snd_soc_card_cht.dev = &pdev->dev;
421 platform_name = mach->mach_params.platform; 422 platform_name = mach->mach_params.platform;
422 423
423 ret_val = snd_soc_fixup_dai_links_platform_name(&snd_soc_card_cht, 424 ret_val = snd_soc_fixup_dai_links_platform_name(&snd_soc_card_cht,
@@ -435,7 +436,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
435 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 436 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
436 437
437 /* register the soc card */ 438 /* register the soc card */
438 snd_soc_card_cht.dev = &pdev->dev;
439 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); 439 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
440 if (ret_val) { 440 if (ret_val) {
441 dev_err(&pdev->dev, 441 dev_err(&pdev->dev,
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c
index f28fb98cc306..3343dbcd506f 100644
--- a/sound/soc/intel/boards/sof_rt5682.c
+++ b/sound/soc/intel/boards/sof_rt5682.c
@@ -29,9 +29,10 @@
29#define SOF_RT5682_MCLK_EN BIT(3) 29#define SOF_RT5682_MCLK_EN BIT(3)
30#define SOF_RT5682_MCLK_24MHZ BIT(4) 30#define SOF_RT5682_MCLK_24MHZ BIT(4)
31#define SOF_SPEAKER_AMP_PRESENT BIT(5) 31#define SOF_SPEAKER_AMP_PRESENT BIT(5)
32#define SOF_RT5682_SSP_AMP(quirk) ((quirk) & GENMASK(8, 6))
33#define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6))
34#define SOF_RT5682_SSP_AMP_SHIFT 6 32#define SOF_RT5682_SSP_AMP_SHIFT 6
33#define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6))
34#define SOF_RT5682_SSP_AMP(quirk) \
35 (((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK)
35 36
36/* Default: MCLK on, MCLK 19.2M, SSP0 */ 37/* Default: MCLK on, MCLK 19.2M, SSP0 */
37static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN | 38static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
@@ -144,9 +145,9 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
144 jack = &ctx->sof_headset; 145 jack = &ctx->sof_headset;
145 146
146 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 147 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
147 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); 148 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
148 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); 149 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
149 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); 150 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
150 ret = snd_soc_component_set_jack(component, jack, NULL); 151 ret = snd_soc_component_set_jack(component, jack, NULL);
151 152
152 if (ret) { 153 if (ret) {
diff --git a/sound/soc/intel/common/soc-acpi-intel-byt-match.c b/sound/soc/intel/common/soc-acpi-intel-byt-match.c
index abd34fa27749..55e80c3d2af0 100644
--- a/sound/soc/intel/common/soc-acpi-intel-byt-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-byt-match.c
@@ -13,6 +13,7 @@ static unsigned long byt_machine_id;
13 13
14#define BYT_THINKPAD_10 1 14#define BYT_THINKPAD_10 1
15#define BYT_POV_P1006W 2 15#define BYT_POV_P1006W 2
16#define BYT_AEGEX_10 3
16 17
17static int byt_thinkpad10_quirk_cb(const struct dmi_system_id *id) 18static int byt_thinkpad10_quirk_cb(const struct dmi_system_id *id)
18{ 19{
@@ -26,6 +27,12 @@ static int byt_pov_p1006w_quirk_cb(const struct dmi_system_id *id)
26 return 1; 27 return 1;
27} 28}
28 29
30static int byt_aegex10_quirk_cb(const struct dmi_system_id *id)
31{
32 byt_machine_id = BYT_AEGEX_10;
33 return 1;
34}
35
29static const struct dmi_system_id byt_table[] = { 36static const struct dmi_system_id byt_table[] = {
30 { 37 {
31 .callback = byt_thinkpad10_quirk_cb, 38 .callback = byt_thinkpad10_quirk_cb,
@@ -66,9 +73,18 @@ static const struct dmi_system_id byt_table[] = {
66 DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"), 73 DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"),
67 }, 74 },
68 }, 75 },
76 {
77 /* Aegex 10 tablet (RU2) */
78 .callback = byt_aegex10_quirk_cb,
79 .matches = {
80 DMI_MATCH(DMI_SYS_VENDOR, "AEGEX"),
81 DMI_MATCH(DMI_PRODUCT_VERSION, "RU2"),
82 },
83 },
69 { } 84 { }
70}; 85};
71 86
87/* The Thinkapd 10 and Aegex 10 tablets have the same ID problem */
72static struct snd_soc_acpi_mach byt_thinkpad_10 = { 88static struct snd_soc_acpi_mach byt_thinkpad_10 = {
73 .id = "10EC5640", 89 .id = "10EC5640",
74 .drv_name = "cht-bsw-rt5672", 90 .drv_name = "cht-bsw-rt5672",
@@ -95,6 +111,7 @@ static struct snd_soc_acpi_mach *byt_quirk(void *arg)
95 111
96 switch (byt_machine_id) { 112 switch (byt_machine_id) {
97 case BYT_THINKPAD_10: 113 case BYT_THINKPAD_10:
114 case BYT_AEGEX_10:
98 return &byt_thinkpad_10; 115 return &byt_thinkpad_10;
99 case BYT_POV_P1006W: 116 case BYT_POV_P1006W:
100 return &byt_pov_p1006w; 117 return &byt_pov_p1006w;
diff --git a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
index df7c52cad5c3..c36c0aa4f683 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
@@ -29,17 +29,17 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_machines[] = {
29 .sof_tplg_filename = "sof-cnl-rt274.tplg", 29 .sof_tplg_filename = "sof-cnl-rt274.tplg",
30 }, 30 },
31 { 31 {
32 .id = "10EC5682", 32 .id = "MX98357A",
33 .drv_name = "sof_rt5682", 33 .drv_name = "sof_rt5682",
34 .quirk_data = &cml_codecs,
34 .sof_fw_filename = "sof-cnl.ri", 35 .sof_fw_filename = "sof-cnl.ri",
35 .sof_tplg_filename = "sof-cml-rt5682.tplg", 36 .sof_tplg_filename = "sof-cml-rt5682-max98357a.tplg",
36 }, 37 },
37 { 38 {
38 .id = "MX98357A", 39 .id = "10EC5682",
39 .drv_name = "sof_rt5682", 40 .drv_name = "sof_rt5682",
40 .quirk_data = &cml_codecs,
41 .sof_fw_filename = "sof-cnl.ri", 41 .sof_fw_filename = "sof-cnl.ri",
42 .sof_tplg_filename = "sof-cml-rt5682-max98357a.tplg", 42 .sof_tplg_filename = "sof-cml-rt5682.tplg",
43 }, 43 },
44 44
45 {}, 45 {},
diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index 933ab51af05b..111e44b64b38 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -133,7 +133,7 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A
133 133
134config SND_SOC_MT8183_DA7219_MAX98357A 134config SND_SOC_MT8183_DA7219_MAX98357A
135 tristate "ASoC Audio driver for MT8183 with DA7219 MAX98357A codec" 135 tristate "ASoC Audio driver for MT8183 with DA7219 MAX98357A codec"
136 depends on SND_SOC_MT8183 136 depends on SND_SOC_MT8183 && I2C
137 select SND_SOC_MT6358 137 select SND_SOC_MT6358
138 select SND_SOC_MAX98357A 138 select SND_SOC_MAX98357A
139 select SND_SOC_DA7219 139 select SND_SOC_DA7219
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2403bec2fccf..41c0cfaf2db5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -228,7 +228,10 @@ static void soc_init_card_debugfs(struct snd_soc_card *card)
228 228
229static void soc_cleanup_card_debugfs(struct snd_soc_card *card) 229static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
230{ 230{
231 if (!card->debugfs_card_root)
232 return;
231 debugfs_remove_recursive(card->debugfs_card_root); 233 debugfs_remove_recursive(card->debugfs_card_root);
234 card->debugfs_card_root = NULL;
232} 235}
233 236
234static void snd_soc_debugfs_init(void) 237static void snd_soc_debugfs_init(void)
@@ -2037,8 +2040,10 @@ match:
2037static int soc_cleanup_card_resources(struct snd_soc_card *card) 2040static int soc_cleanup_card_resources(struct snd_soc_card *card)
2038{ 2041{
2039 /* free the ALSA card at first; this syncs with pending operations */ 2042 /* free the ALSA card at first; this syncs with pending operations */
2040 if (card->snd_card) 2043 if (card->snd_card) {
2041 snd_card_free(card->snd_card); 2044 snd_card_free(card->snd_card);
2045 card->snd_card = NULL;
2046 }
2042 2047
2043 /* remove and free each DAI */ 2048 /* remove and free each DAI */
2044 soc_remove_dai_links(card); 2049 soc_remove_dai_links(card);
@@ -2065,6 +2070,16 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
2065 int ret, i, order; 2070 int ret, i, order;
2066 2071
2067 mutex_lock(&client_mutex); 2072 mutex_lock(&client_mutex);
2073 for_each_card_prelinks(card, i, dai_link) {
2074 ret = soc_init_dai_link(card, dai_link);
2075 if (ret) {
2076 soc_cleanup_platform(card);
2077 dev_err(card->dev, "ASoC: failed to init link %s: %d\n",
2078 dai_link->name, ret);
2079 mutex_unlock(&client_mutex);
2080 return ret;
2081 }
2082 }
2068 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); 2083 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
2069 2084
2070 card->dapm.bias_level = SND_SOC_BIAS_OFF; 2085 card->dapm.bias_level = SND_SOC_BIAS_OFF;
@@ -2789,26 +2804,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
2789 */ 2804 */
2790int snd_soc_register_card(struct snd_soc_card *card) 2805int snd_soc_register_card(struct snd_soc_card *card)
2791{ 2806{
2792 int i, ret;
2793 struct snd_soc_dai_link *link;
2794
2795 if (!card->name || !card->dev) 2807 if (!card->name || !card->dev)
2796 return -EINVAL; 2808 return -EINVAL;
2797 2809
2798 mutex_lock(&client_mutex);
2799 for_each_card_prelinks(card, i, link) {
2800
2801 ret = soc_init_dai_link(card, link);
2802 if (ret) {
2803 soc_cleanup_platform(card);
2804 dev_err(card->dev, "ASoC: failed to init link %s\n",
2805 link->name);
2806 mutex_unlock(&client_mutex);
2807 return ret;
2808 }
2809 }
2810 mutex_unlock(&client_mutex);
2811
2812 dev_set_drvdata(card->dev, card); 2810 dev_set_drvdata(card->dev, card);
2813 2811
2814 snd_soc_initialize_card_lists(card); 2812 snd_soc_initialize_card_lists(card);
@@ -2839,12 +2837,14 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
2839 snd_soc_dapm_shutdown(card); 2837 snd_soc_dapm_shutdown(card);
2840 snd_soc_flush_all_delayed_work(card); 2838 snd_soc_flush_all_delayed_work(card);
2841 2839
2840 mutex_lock(&client_mutex);
2842 /* remove all components used by DAI links on this card */ 2841 /* remove all components used by DAI links on this card */
2843 for_each_comp_order(order) { 2842 for_each_comp_order(order) {
2844 for_each_card_rtds(card, rtd) { 2843 for_each_card_rtds(card, rtd) {
2845 soc_remove_link_components(card, rtd, order); 2844 soc_remove_link_components(card, rtd, order);
2846 } 2845 }
2847 } 2846 }
2847 mutex_unlock(&client_mutex);
2848 2848
2849 soc_cleanup_card_resources(card); 2849 soc_cleanup_card_resources(card);
2850 if (!unregister) 2850 if (!unregister)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 81a7a12196ff..55f8278077f4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2193,7 +2193,10 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
2193 2193
2194static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) 2194static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
2195{ 2195{
2196 if (!dapm->debugfs_dapm)
2197 return;
2196 debugfs_remove_recursive(dapm->debugfs_dapm); 2198 debugfs_remove_recursive(dapm->debugfs_dapm);
2199 dapm->debugfs_dapm = NULL;
2197} 2200}
2198 2201
2199#else 2202#else
@@ -3831,8 +3834,8 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3831 ret); 3834 ret);
3832 goto out; 3835 goto out;
3833 } 3836 }
3834 source->active++;
3835 } 3837 }
3838 source->active++;
3836 ret = soc_dai_hw_params(&substream, params, source); 3839 ret = soc_dai_hw_params(&substream, params, source);
3837 if (ret < 0) 3840 if (ret < 0)
3838 goto out; 3841 goto out;
@@ -3853,8 +3856,8 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3853 ret); 3856 ret);
3854 goto out; 3857 goto out;
3855 } 3858 }
3856 sink->active++;
3857 } 3859 }
3860 sink->active++;
3858 ret = soc_dai_hw_params(&substream, params, sink); 3861 ret = soc_dai_hw_params(&substream, params, sink);
3859 if (ret < 0) 3862 if (ret < 0)
3860 goto out; 3863 goto out;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0a4f60c7a188..c46ad0f66292 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2479,7 +2479,8 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
2479 2479
2480 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && 2480 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) &&
2481 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && 2481 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
2482 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) 2482 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) &&
2483 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
2483 continue; 2484 continue;
2484 2485
2485 dev_dbg(be->dev, "ASoC: prepare BE %s\n", 2486 dev_dbg(be->dev, "ASoC: prepare BE %s\n",
diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig
index 048c7b034d70..71d87a86f060 100644
--- a/sound/soc/sof/Kconfig
+++ b/sound/soc/sof/Kconfig
@@ -45,7 +45,10 @@ config SND_SOC_SOF_OPTIONS
45if SND_SOC_SOF_OPTIONS 45if SND_SOC_SOF_OPTIONS
46 46
47config SND_SOC_SOF_NOCODEC 47config SND_SOC_SOF_NOCODEC
48 tristate "SOF nocodec mode Support" 48 tristate
49
50config SND_SOC_SOF_NOCODEC_SUPPORT
51 bool "SOF nocodec mode support"
49 help 52 help
50 This adds support for a dummy/nocodec machine driver fallback 53 This adds support for a dummy/nocodec machine driver fallback
51 option if no known codec is detected. This is typically only 54 option if no known codec is detected. This is typically only
@@ -81,7 +84,7 @@ if SND_SOC_SOF_DEBUG
81 84
82config SND_SOC_SOF_FORCE_NOCODEC_MODE 85config SND_SOC_SOF_FORCE_NOCODEC_MODE
83 bool "SOF force nocodec Mode" 86 bool "SOF force nocodec Mode"
84 depends on SND_SOC_SOF_NOCODEC 87 depends on SND_SOC_SOF_NOCODEC_SUPPORT
85 help 88 help
86 This forces SOF to use dummy/nocodec as machine driver, even 89 This forces SOF to use dummy/nocodec as machine driver, even
87 though there is a codec detected on the real platform. This is 90 though there is a codec detected on the real platform. This is
@@ -136,6 +139,7 @@ endif ## SND_SOC_SOF_OPTIONS
136config SND_SOC_SOF 139config SND_SOC_SOF
137 tristate 140 tristate
138 select SND_SOC_TOPOLOGY 141 select SND_SOC_TOPOLOGY
142 select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT
139 help 143 help
140 This option is not user-selectable but automagically handled by 144 This option is not user-selectable but automagically handled by
141 'select' statements at a higher level 145 'select' statements at a higher level
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 11762c4580f1..84e2cbfbbcbb 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -349,6 +349,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
349 struct snd_sof_dev *sdev = scontrol->sdev; 349 struct snd_sof_dev *sdev = scontrol->sdev;
350 struct sof_ipc_ctrl_data *cdata = scontrol->control_data; 350 struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
351 struct sof_abi_hdr *data = cdata->data; 351 struct sof_abi_hdr *data = cdata->data;
352 size_t size = data->size + sizeof(*data);
352 int ret, err; 353 int ret, err;
353 354
354 if (be->max > sizeof(ucontrol->value.bytes.data)) { 355 if (be->max > sizeof(ucontrol->value.bytes.data)) {
@@ -358,10 +359,10 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
358 return -EINVAL; 359 return -EINVAL;
359 } 360 }
360 361
361 if (data->size > be->max) { 362 if (size > be->max) {
362 dev_err_ratelimited(sdev->dev, 363 dev_err_ratelimited(sdev->dev,
363 "error: size too big %d bytes max is %d\n", 364 "error: size too big %zu bytes max is %d\n",
364 data->size, be->max); 365 size, be->max);
365 return -EINVAL; 366 return -EINVAL;
366 } 367 }
367 368
@@ -375,7 +376,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
375 } 376 }
376 377
377 /* copy from kcontrol */ 378 /* copy from kcontrol */
378 memcpy(data, ucontrol->value.bytes.data, data->size); 379 memcpy(data, ucontrol->value.bytes.data, size);
379 380
380 /* notify DSP of byte control updates */ 381 /* notify DSP of byte control updates */
381 snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, 382 snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index 32105e0fabe8..5beda47cdf9f 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -382,7 +382,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
382 382
383 if (IS_ERR(plat_data->pdev_mach)) { 383 if (IS_ERR(plat_data->pdev_mach)) {
384 ret = PTR_ERR(plat_data->pdev_mach); 384 ret = PTR_ERR(plat_data->pdev_mach);
385 goto comp_err; 385 goto fw_run_err;
386 } 386 }
387 387
388 dev_dbg(sdev->dev, "created machine %s\n", 388 dev_dbg(sdev->dev, "created machine %s\n",
@@ -393,8 +393,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
393 393
394 return 0; 394 return 0;
395 395
396comp_err: 396#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)
397 snd_soc_unregister_component(sdev->dev);
398fw_run_err: 397fw_run_err:
399 snd_sof_fw_unload(sdev); 398 snd_sof_fw_unload(sdev);
400fw_load_err: 399fw_load_err:
@@ -403,6 +402,21 @@ ipc_err:
403 snd_sof_free_debug(sdev); 402 snd_sof_free_debug(sdev);
404dbg_err: 403dbg_err:
405 snd_sof_remove(sdev); 404 snd_sof_remove(sdev);
405#else
406
407 /*
408 * when the probe_continue is handled in a work queue, the
409 * probe does not fail so we don't release resources here.
410 * They will be released with an explicit call to
411 * snd_sof_device_remove() when the PCI/ACPI device is removed
412 */
413
414fw_run_err:
415fw_load_err:
416ipc_err:
417dbg_err:
418
419#endif
406 420
407 return ret; 421 return ret;
408} 422}
@@ -484,7 +498,6 @@ int snd_sof_device_remove(struct device *dev)
484 snd_sof_ipc_free(sdev); 498 snd_sof_ipc_free(sdev);
485 snd_sof_free_debug(sdev); 499 snd_sof_free_debug(sdev);
486 snd_sof_free_trace(sdev); 500 snd_sof_free_trace(sdev);
487 snd_sof_remove(sdev);
488 501
489 /* 502 /*
490 * Unregister machine driver. This will unbind the snd_card which 503 * Unregister machine driver. This will unbind the snd_card which
@@ -494,6 +507,14 @@ int snd_sof_device_remove(struct device *dev)
494 if (!IS_ERR_OR_NULL(pdata->pdev_mach)) 507 if (!IS_ERR_OR_NULL(pdata->pdev_mach))
495 platform_device_unregister(pdata->pdev_mach); 508 platform_device_unregister(pdata->pdev_mach);
496 509
510 /*
511 * Unregistering the machine driver results in unloading the topology.
512 * Some widgets, ex: scheduler, attempt to power down the core they are
513 * scheduled on, when they are unloaded. Therefore, the DSP must be
514 * removed only after the topology has been unloaded.
515 */
516 snd_sof_remove(sdev);
517
497 /* release firmware */ 518 /* release firmware */
498 release_firmware(pdata->fw); 519 release_firmware(pdata->fw);
499 pdata->fw = NULL; 520 pdata->fw = NULL;
diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c
index 065cb868bdfa..70d524ef9bc0 100644
--- a/sound/soc/sof/intel/bdw.c
+++ b/sound/soc/sof/intel/bdw.c
@@ -220,17 +220,20 @@ static void bdw_get_registers(struct snd_sof_dev *sdev,
220 struct sof_ipc_panic_info *panic_info, 220 struct sof_ipc_panic_info *panic_info,
221 u32 *stack, size_t stack_words) 221 u32 *stack, size_t stack_words)
222{ 222{
223 /* first read regsisters */ 223 u32 offset = sdev->dsp_oops_offset;
224 sof_mailbox_read(sdev, sdev->dsp_oops_offset, xoops, sizeof(*xoops)); 224
225 /* first read registers */
226 sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
227
228 /* note: variable AR register array is not read */
225 229
226 /* then get panic info */ 230 /* then get panic info */
227 sof_mailbox_read(sdev, sdev->dsp_oops_offset + sizeof(*xoops), 231 offset += xoops->arch_hdr.totalsize;
228 panic_info, sizeof(*panic_info)); 232 sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
229 233
230 /* then get the stack */ 234 /* then get the stack */
231 sof_mailbox_read(sdev, sdev->dsp_oops_offset + sizeof(*xoops) + 235 offset += sizeof(*panic_info);
232 sizeof(*panic_info), stack, 236 sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
233 stack_words * sizeof(u32));
234} 237}
235 238
236static void bdw_dump(struct snd_sof_dev *sdev, u32 flags) 239static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
@@ -283,6 +286,8 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
283 SHIM_IMRX, SHIM_IMRX_DONE, 286 SHIM_IMRX, SHIM_IMRX_DONE,
284 SHIM_IMRX_DONE); 287 SHIM_IMRX_DONE);
285 288
289 spin_lock_irq(&sdev->ipc_lock);
290
286 /* 291 /*
287 * handle immediate reply from DSP core. If the msg is 292 * handle immediate reply from DSP core. If the msg is
288 * found, set done bit in cmd_done which is called at the 293 * found, set done bit in cmd_done which is called at the
@@ -294,6 +299,8 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
294 snd_sof_ipc_reply(sdev, ipcx); 299 snd_sof_ipc_reply(sdev, ipcx);
295 300
296 bdw_dsp_done(sdev); 301 bdw_dsp_done(sdev);
302
303 spin_unlock_irq(&sdev->ipc_lock);
297 } 304 }
298 305
299 ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD); 306 ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
@@ -485,7 +492,6 @@ static void bdw_get_reply(struct snd_sof_dev *sdev)
485{ 492{
486 struct snd_sof_ipc_msg *msg = sdev->msg; 493 struct snd_sof_ipc_msg *msg = sdev->msg;
487 struct sof_ipc_reply reply; 494 struct sof_ipc_reply reply;
488 unsigned long flags;
489 int ret = 0; 495 int ret = 0;
490 496
491 /* 497 /*
@@ -501,8 +507,6 @@ static void bdw_get_reply(struct snd_sof_dev *sdev)
501 /* get reply */ 507 /* get reply */
502 sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); 508 sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
503 509
504 spin_lock_irqsave(&sdev->ipc_lock, flags);
505
506 if (reply.error < 0) { 510 if (reply.error < 0) {
507 memcpy(msg->reply_data, &reply, sizeof(reply)); 511 memcpy(msg->reply_data, &reply, sizeof(reply));
508 ret = reply.error; 512 ret = reply.error;
@@ -521,8 +525,6 @@ static void bdw_get_reply(struct snd_sof_dev *sdev)
521 } 525 }
522 526
523 msg->reply_error = ret; 527 msg->reply_error = ret;
524
525 spin_unlock_irqrestore(&sdev->ipc_lock, flags);
526} 528}
527 529
528static void bdw_host_done(struct snd_sof_dev *sdev) 530static void bdw_host_done(struct snd_sof_dev *sdev)
diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c
index 7bf9143d3106..39d1ae01c45d 100644
--- a/sound/soc/sof/intel/byt.c
+++ b/sound/soc/sof/intel/byt.c
@@ -265,17 +265,20 @@ static void byt_get_registers(struct snd_sof_dev *sdev,
265 struct sof_ipc_panic_info *panic_info, 265 struct sof_ipc_panic_info *panic_info,
266 u32 *stack, size_t stack_words) 266 u32 *stack, size_t stack_words)
267{ 267{
268 u32 offset = sdev->dsp_oops_offset;
269
268 /* first read regsisters */ 270 /* first read regsisters */
269 sof_mailbox_read(sdev, sdev->dsp_oops_offset, xoops, sizeof(*xoops)); 271 sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
272
273 /* note: variable AR register array is not read */
270 274
271 /* then get panic info */ 275 /* then get panic info */
272 sof_mailbox_read(sdev, sdev->dsp_oops_offset + sizeof(*xoops), 276 offset += xoops->arch_hdr.totalsize;
273 panic_info, sizeof(*panic_info)); 277 sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
274 278
275 /* then get the stack */ 279 /* then get the stack */
276 sof_mailbox_read(sdev, sdev->dsp_oops_offset + sizeof(*xoops) + 280 offset += sizeof(*panic_info);
277 sizeof(*panic_info), stack, 281 sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
278 stack_words * sizeof(u32));
279} 282}
280 283
281static void byt_dump(struct snd_sof_dev *sdev, u32 flags) 284static void byt_dump(struct snd_sof_dev *sdev, u32 flags)
@@ -329,6 +332,9 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
329 SHIM_IMRX, 332 SHIM_IMRX,
330 SHIM_IMRX_DONE, 333 SHIM_IMRX_DONE,
331 SHIM_IMRX_DONE); 334 SHIM_IMRX_DONE);
335
336 spin_lock_irq(&sdev->ipc_lock);
337
332 /* 338 /*
333 * handle immediate reply from DSP core. If the msg is 339 * handle immediate reply from DSP core. If the msg is
334 * found, set done bit in cmd_done which is called at the 340 * found, set done bit in cmd_done which is called at the
@@ -340,6 +346,8 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
340 snd_sof_ipc_reply(sdev, ipcx); 346 snd_sof_ipc_reply(sdev, ipcx);
341 347
342 byt_dsp_done(sdev); 348 byt_dsp_done(sdev);
349
350 spin_unlock_irq(&sdev->ipc_lock);
343 } 351 }
344 352
345 /* new message from DSP */ 353 /* new message from DSP */
@@ -383,7 +391,6 @@ static void byt_get_reply(struct snd_sof_dev *sdev)
383{ 391{
384 struct snd_sof_ipc_msg *msg = sdev->msg; 392 struct snd_sof_ipc_msg *msg = sdev->msg;
385 struct sof_ipc_reply reply; 393 struct sof_ipc_reply reply;
386 unsigned long flags;
387 int ret = 0; 394 int ret = 0;
388 395
389 /* 396 /*
@@ -399,8 +406,6 @@ static void byt_get_reply(struct snd_sof_dev *sdev)
399 /* get reply */ 406 /* get reply */
400 sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); 407 sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
401 408
402 spin_lock_irqsave(&sdev->ipc_lock, flags);
403
404 if (reply.error < 0) { 409 if (reply.error < 0) {
405 memcpy(msg->reply_data, &reply, sizeof(reply)); 410 memcpy(msg->reply_data, &reply, sizeof(reply));
406 ret = reply.error; 411 ret = reply.error;
@@ -419,8 +424,6 @@ static void byt_get_reply(struct snd_sof_dev *sdev)
419 } 424 }
420 425
421 msg->reply_error = ret; 426 msg->reply_error = ret;
422
423 spin_unlock_irqrestore(&sdev->ipc_lock, flags);
424} 427}
425 428
426static void byt_host_done(struct snd_sof_dev *sdev) 429static void byt_host_done(struct snd_sof_dev *sdev)
diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c
index 08a1a3d3c08d..b2eba7adcad8 100644
--- a/sound/soc/sof/intel/cnl.c
+++ b/sound/soc/sof/intel/cnl.c
@@ -64,6 +64,8 @@ static irqreturn_t cnl_ipc_irq_thread(int irq, void *context)
64 CNL_DSP_REG_HIPCCTL, 64 CNL_DSP_REG_HIPCCTL,
65 CNL_DSP_REG_HIPCCTL_DONE, 0); 65 CNL_DSP_REG_HIPCCTL_DONE, 0);
66 66
67 spin_lock_irq(&sdev->ipc_lock);
68
67 /* handle immediate reply from DSP core */ 69 /* handle immediate reply from DSP core */
68 hda_dsp_ipc_get_reply(sdev); 70 hda_dsp_ipc_get_reply(sdev);
69 snd_sof_ipc_reply(sdev, msg); 71 snd_sof_ipc_reply(sdev, msg);
@@ -75,6 +77,8 @@ static irqreturn_t cnl_ipc_irq_thread(int irq, void *context)
75 77
76 cnl_ipc_dsp_done(sdev); 78 cnl_ipc_dsp_done(sdev);
77 79
80 spin_unlock_irq(&sdev->ipc_lock);
81
78 ret = IRQ_HANDLED; 82 ret = IRQ_HANDLED;
79 } 83 }
80 84
diff --git a/sound/soc/sof/intel/hda-ctrl.c b/sound/soc/sof/intel/hda-ctrl.c
index 2c3645736e1f..07bc123112c9 100644
--- a/sound/soc/sof/intel/hda-ctrl.c
+++ b/sound/soc/sof/intel/hda-ctrl.c
@@ -161,21 +161,105 @@ int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)
161 return 0; 161 return 0;
162} 162}
163 163
164#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
165/*
166 * While performing reset, controller may not come back properly and causing
167 * issues, so recommendation is to set CGCTL.MISCBDCGE to 0 then do reset
168 * (init chip) and then again set CGCTL.MISCBDCGE to 1
169 */
170int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset) 164int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
171{ 165{
172 struct hdac_bus *bus = sof_to_bus(sdev); 166 struct hdac_bus *bus = sof_to_bus(sdev);
173 int ret; 167 struct hdac_stream *stream;
168 int sd_offset, ret = 0;
169
170 if (bus->chip_init)
171 return 0;
174 172
175 hda_dsp_ctrl_misc_clock_gating(sdev, false); 173 hda_dsp_ctrl_misc_clock_gating(sdev, false);
176 ret = snd_hdac_bus_init_chip(bus, full_reset); 174
175 if (full_reset) {
176 /* clear WAKESTS */
177 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_WAKESTS,
178 SOF_HDA_WAKESTS_INT_MASK,
179 SOF_HDA_WAKESTS_INT_MASK);
180
181 /* reset HDA controller */
182 ret = hda_dsp_ctrl_link_reset(sdev, true);
183 if (ret < 0) {
184 dev_err(sdev->dev, "error: failed to reset HDA controller\n");
185 return ret;
186 }
187
188 usleep_range(500, 1000);
189
190 /* exit HDA controller reset */
191 ret = hda_dsp_ctrl_link_reset(sdev, false);
192 if (ret < 0) {
193 dev_err(sdev->dev, "error: failed to exit HDA controller reset\n");
194 return ret;
195 }
196
197 usleep_range(1000, 1200);
198 }
199
200#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
201 /* check to see if controller is ready */
202 if (!snd_hdac_chip_readb(bus, GCTL)) {
203 dev_dbg(bus->dev, "controller not ready!\n");
204 return -EBUSY;
205 }
206
207 /* Accept unsolicited responses */
208 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);
209
210 /* detect codecs */
211 if (!bus->codec_mask) {
212 bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS);
213 dev_dbg(bus->dev, "codec_mask = 0x%lx\n", bus->codec_mask);
214 }
215#endif
216
217 /* clear stream status */
218 list_for_each_entry(stream, &bus->stream_list, list) {
219 sd_offset = SOF_STREAM_SD_OFFSET(stream);
220 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
221 sd_offset +
222 SOF_HDA_ADSP_REG_CL_SD_STS,
223 SOF_HDA_CL_DMA_SD_INT_MASK,
224 SOF_HDA_CL_DMA_SD_INT_MASK);
225 }
226
227 /* clear WAKESTS */
228 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_WAKESTS,
229 SOF_HDA_WAKESTS_INT_MASK,
230 SOF_HDA_WAKESTS_INT_MASK);
231
232#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
233 /* clear rirb status */
234 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK);
235#endif
236
237 /* clear interrupt status register */
238 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS,
239 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_ALL_STREAM);
240
241#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
242 /* initialize the codec command I/O */
243 snd_hdac_bus_init_cmd_io(bus);
244#endif
245
246 /* enable CIE and GIE interrupts */
247 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
248 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN,
249 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN);
250
251#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
252 /* program the position buffer */
253 if (bus->use_posbuf && bus->posbuf.addr) {
254 snd_hdac_chip_writel(bus, DPLBASE, (u32)bus->posbuf.addr);
255 snd_hdac_chip_writel(bus, DPUBASE,
256 upper_32_bits(bus->posbuf.addr));
257 }
258#endif
259
260 bus->chip_init = true;
261
177 hda_dsp_ctrl_misc_clock_gating(sdev, true); 262 hda_dsp_ctrl_misc_clock_gating(sdev, true);
178 263
179 return ret; 264 return ret;
180} 265}
181#endif
diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c
index 73ead7070cde..51b285103394 100644
--- a/sound/soc/sof/intel/hda-ipc.c
+++ b/sound/soc/sof/intel/hda-ipc.c
@@ -72,7 +72,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
72 struct snd_sof_ipc_msg *msg = sdev->msg; 72 struct snd_sof_ipc_msg *msg = sdev->msg;
73 struct sof_ipc_reply reply; 73 struct sof_ipc_reply reply;
74 struct sof_ipc_cmd_hdr *hdr; 74 struct sof_ipc_cmd_hdr *hdr;
75 unsigned long flags;
76 int ret = 0; 75 int ret = 0;
77 76
78 /* 77 /*
@@ -84,7 +83,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
84 dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); 83 dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n");
85 return; 84 return;
86 } 85 }
87 spin_lock_irqsave(&sdev->ipc_lock, flags);
88 86
89 hdr = msg->msg_data; 87 hdr = msg->msg_data;
90 if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE)) { 88 if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE)) {
@@ -123,7 +121,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
123out: 121out:
124 msg->reply_error = ret; 122 msg->reply_error = ret;
125 123
126 spin_unlock_irqrestore(&sdev->ipc_lock, flags);
127} 124}
128 125
129static bool hda_dsp_ipc_is_sof(uint32_t msg) 126static bool hda_dsp_ipc_is_sof(uint32_t msg)
@@ -172,6 +169,18 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
172 HDA_DSP_REG_HIPCCTL, 169 HDA_DSP_REG_HIPCCTL,
173 HDA_DSP_REG_HIPCCTL_DONE, 0); 170 HDA_DSP_REG_HIPCCTL_DONE, 0);
174 171
172 /*
173 * Make sure the interrupt thread cannot be preempted between
174 * waking up the sender and re-enabling the interrupt. Also
175 * protect against a theoretical race with sof_ipc_tx_message():
176 * if the DSP is fast enough to receive an IPC message, reply to
177 * it, and the host interrupt processing calls this function on
178 * a different core from the one, where the sending is taking
179 * place, the message might not yet be marked as expecting a
180 * reply.
181 */
182 spin_lock_irq(&sdev->ipc_lock);
183
175 /* handle immediate reply from DSP core - ignore ROM messages */ 184 /* handle immediate reply from DSP core - ignore ROM messages */
176 if (hda_dsp_ipc_is_sof(msg)) { 185 if (hda_dsp_ipc_is_sof(msg)) {
177 hda_dsp_ipc_get_reply(sdev); 186 hda_dsp_ipc_get_reply(sdev);
@@ -187,6 +196,8 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
187 /* set the done bit */ 196 /* set the done bit */
188 hda_dsp_ipc_dsp_done(sdev); 197 hda_dsp_ipc_dsp_done(sdev);
189 198
199 spin_unlock_irq(&sdev->ipc_lock);
200
190 ret = IRQ_HANDLED; 201 ret = IRQ_HANDLED;
191 } 202 }
192 203
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 7e3980a2f7ba..faf1a8ada091 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -108,17 +108,21 @@ static void hda_dsp_get_registers(struct snd_sof_dev *sdev,
108 struct sof_ipc_panic_info *panic_info, 108 struct sof_ipc_panic_info *panic_info,
109 u32 *stack, size_t stack_words) 109 u32 *stack, size_t stack_words)
110{ 110{
111 u32 offset = sdev->dsp_oops_offset;
112
111 /* first read registers */ 113 /* first read registers */
112 sof_block_read(sdev, sdev->mmio_bar, sdev->dsp_oops_offset, xoops, 114 sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
113 sizeof(*xoops)); 115
116 /* note: variable AR register array is not read */
114 117
115 /* then get panic info */ 118 /* then get panic info */
116 sof_block_read(sdev, sdev->mmio_bar, sdev->dsp_oops_offset + 119 offset += xoops->arch_hdr.totalsize;
117 sizeof(*xoops), panic_info, sizeof(*panic_info)); 120 sof_block_read(sdev, sdev->mmio_bar, offset,
121 panic_info, sizeof(*panic_info));
118 122
119 /* then get the stack */ 123 /* then get the stack */
120 sof_block_read(sdev, sdev->mmio_bar, sdev->dsp_oops_offset + 124 offset += sizeof(*panic_info);
121 sizeof(*xoops) + sizeof(*panic_info), stack, 125 sof_block_read(sdev, sdev->mmio_bar, offset, stack,
122 stack_words * sizeof(u32)); 126 stack_words * sizeof(u32));
123} 127}
124 128
@@ -223,7 +227,9 @@ static int hda_init(struct snd_sof_dev *sdev)
223 227
224 /* initialise hdac bus */ 228 /* initialise hdac bus */
225 bus->addr = pci_resource_start(pci, 0); 229 bus->addr = pci_resource_start(pci, 0);
230#if IS_ENABLED(CONFIG_PCI)
226 bus->remap_addr = pci_ioremap_bar(pci, 0); 231 bus->remap_addr = pci_ioremap_bar(pci, 0);
232#endif
227 if (!bus->remap_addr) { 233 if (!bus->remap_addr) {
228 dev_err(bus->dev, "error: ioremap error\n"); 234 dev_err(bus->dev, "error: ioremap error\n");
229 return -ENXIO; 235 return -ENXIO;
@@ -264,9 +270,12 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
264 return tplg_filename; 270 return tplg_filename;
265} 271}
266 272
273#endif
274
267static int hda_init_caps(struct snd_sof_dev *sdev) 275static int hda_init_caps(struct snd_sof_dev *sdev)
268{ 276{
269 struct hdac_bus *bus = sof_to_bus(sdev); 277 struct hdac_bus *bus = sof_to_bus(sdev);
278#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
270 struct hdac_ext_link *hlink; 279 struct hdac_ext_link *hlink;
271 struct snd_soc_acpi_mach_params *mach_params; 280 struct snd_soc_acpi_mach_params *mach_params;
272 struct snd_soc_acpi_mach *hda_mach; 281 struct snd_soc_acpi_mach *hda_mach;
@@ -274,8 +283,9 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
274 struct snd_soc_acpi_mach *mach; 283 struct snd_soc_acpi_mach *mach;
275 const char *tplg_filename; 284 const char *tplg_filename;
276 int codec_num = 0; 285 int codec_num = 0;
277 int ret = 0;
278 int i; 286 int i;
287#endif
288 int ret = 0;
279 289
280 device_disable_async_suspend(bus->dev); 290 device_disable_async_suspend(bus->dev);
281 291
@@ -283,6 +293,14 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
283 if (bus->ppcap) 293 if (bus->ppcap)
284 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); 294 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n");
285 295
296 ret = hda_dsp_ctrl_init_chip(sdev, true);
297 if (ret < 0) {
298 dev_err(bus->dev, "error: init chip failed with ret: %d\n",
299 ret);
300 return ret;
301 }
302
303#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
286 if (bus->mlcap) 304 if (bus->mlcap)
287 snd_hdac_ext_bus_get_ml_capabilities(bus); 305 snd_hdac_ext_bus_get_ml_capabilities(bus);
288 306
@@ -293,12 +311,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
293 return ret; 311 return ret;
294 } 312 }
295 313
296 ret = hda_dsp_ctrl_init_chip(sdev, true);
297 if (ret < 0) {
298 dev_err(bus->dev, "error: init chip failed with ret: %d\n", ret);
299 goto out;
300 }
301
302 /* codec detection */ 314 /* codec detection */
303 if (!bus->codec_mask) { 315 if (!bus->codec_mask) {
304 dev_info(bus->dev, "no hda codecs found!\n"); 316 dev_info(bus->dev, "no hda codecs found!\n");
@@ -339,8 +351,10 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
339 /* use local variable for readability */ 351 /* use local variable for readability */
340 tplg_filename = pdata->tplg_filename; 352 tplg_filename = pdata->tplg_filename;
341 tplg_filename = fixup_tplg_name(sdev, tplg_filename); 353 tplg_filename = fixup_tplg_name(sdev, tplg_filename);
342 if (!tplg_filename) 354 if (!tplg_filename) {
343 goto out; 355 hda_codec_i915_exit(sdev);
356 return ret;
357 }
344 pdata->tplg_filename = tplg_filename; 358 pdata->tplg_filename = tplg_filename;
345 } 359 }
346 } 360 }
@@ -364,35 +378,10 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
364 */ 378 */
365 list_for_each_entry(hlink, &bus->hlink_list, list) 379 list_for_each_entry(hlink, &bus->hlink_list, list)
366 snd_hdac_ext_bus_link_put(bus, hlink); 380 snd_hdac_ext_bus_link_put(bus, hlink);
367 381#endif
368 return 0;
369
370out:
371 hda_codec_i915_exit(sdev);
372 return ret;
373}
374
375#else
376
377static int hda_init_caps(struct snd_sof_dev *sdev)
378{
379 /*
380 * set CGCTL.MISCBDCGE to 0 during reset and set back to 1
381 * when reset finished.
382 * TODO: maybe no need for init_caps?
383 */
384 hda_dsp_ctrl_misc_clock_gating(sdev, 0);
385
386 /* clear WAKESTS */
387 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_WAKESTS,
388 SOF_HDA_WAKESTS_INT_MASK,
389 SOF_HDA_WAKESTS_INT_MASK);
390
391 return 0; 382 return 0;
392} 383}
393 384
394#endif
395
396static const struct sof_intel_dsp_desc 385static const struct sof_intel_dsp_desc
397 *get_chip_info(struct snd_sof_pdata *pdata) 386 *get_chip_info(struct snd_sof_pdata *pdata)
398{ 387{
@@ -409,9 +398,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
409 struct pci_dev *pci = to_pci_dev(sdev->dev); 398 struct pci_dev *pci = to_pci_dev(sdev->dev);
410 struct sof_intel_hda_dev *hdev; 399 struct sof_intel_hda_dev *hdev;
411 struct hdac_bus *bus; 400 struct hdac_bus *bus;
412 struct hdac_stream *stream;
413 const struct sof_intel_dsp_desc *chip; 401 const struct sof_intel_dsp_desc *chip;
414 int sd_offset, ret = 0; 402 int ret = 0;
415 403
416 /* 404 /*
417 * detect DSP by checking class/subclass/prog-id information 405 * detect DSP by checking class/subclass/prog-id information
@@ -468,7 +456,9 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
468 goto hdac_bus_unmap; 456 goto hdac_bus_unmap;
469 457
470 /* DSP base */ 458 /* DSP base */
459#if IS_ENABLED(CONFIG_PCI)
471 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); 460 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR);
461#endif
472 if (!sdev->bar[HDA_DSP_BAR]) { 462 if (!sdev->bar[HDA_DSP_BAR]) {
473 dev_err(sdev->dev, "error: ioremap error\n"); 463 dev_err(sdev->dev, "error: ioremap error\n");
474 ret = -ENXIO; 464 ret = -ENXIO;
@@ -558,56 +548,9 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
558 if (ret < 0) 548 if (ret < 0)
559 goto free_ipc_irq; 549 goto free_ipc_irq;
560 550
561 /* reset HDA controller */ 551 /* enable ppcap interrupt */
562 ret = hda_dsp_ctrl_link_reset(sdev, true); 552 hda_dsp_ctrl_ppcap_enable(sdev, true);
563 if (ret < 0) { 553 hda_dsp_ctrl_ppcap_int_enable(sdev, true);
564 dev_err(sdev->dev, "error: failed to reset HDA controller\n");
565 goto free_ipc_irq;
566 }
567
568 /* exit HDA controller reset */
569 ret = hda_dsp_ctrl_link_reset(sdev, false);
570 if (ret < 0) {
571 dev_err(sdev->dev, "error: failed to exit HDA controller reset\n");
572 goto free_ipc_irq;
573 }
574
575 /* clear stream status */
576 list_for_each_entry(stream, &bus->stream_list, list) {
577 sd_offset = SOF_STREAM_SD_OFFSET(stream);
578 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
579 sd_offset +
580 SOF_HDA_ADSP_REG_CL_SD_STS,
581 SOF_HDA_CL_DMA_SD_INT_MASK,
582 SOF_HDA_CL_DMA_SD_INT_MASK);
583 }
584
585 /* clear WAKESTS */
586 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_WAKESTS,
587 SOF_HDA_WAKESTS_INT_MASK,
588 SOF_HDA_WAKESTS_INT_MASK);
589
590 /* clear interrupt status register */
591 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS,
592 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_ALL_STREAM);
593
594 /* enable CIE and GIE interrupts */
595 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
596 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN,
597 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN);
598
599 /* re-enable CGCTL.MISCBDCGE after reset */
600 hda_dsp_ctrl_misc_clock_gating(sdev, true);
601
602 device_disable_async_suspend(&pci->dev);
603
604 /* enable DSP features */
605 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
606 SOF_HDA_PPCTL_GPROCEN, SOF_HDA_PPCTL_GPROCEN);
607
608 /* enable DSP IRQ */
609 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
610 SOF_HDA_PPCTL_PIE, SOF_HDA_PPCTL_PIE);
611 554
612 /* initialize waitq for code loading */ 555 /* initialize waitq for code loading */
613 init_waitqueue_head(&sdev->waitq); 556 init_waitqueue_head(&sdev->waitq);
diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index f0b9d3c53f6f..2414640a32d1 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -115,7 +115,7 @@ static void ipc_log_header(struct device *dev, u8 *text, u32 cmd)
115 } 115 }
116 break; 116 break;
117 case SOF_IPC_GLB_COMP_MSG: 117 case SOF_IPC_GLB_COMP_MSG:
118 str = "GLB_COMP_MSG: SET_VALUE"; 118 str = "GLB_COMP_MSG";
119 switch (type) { 119 switch (type) {
120 case SOF_IPC_COMP_SET_VALUE: 120 case SOF_IPC_COMP_SET_VALUE:
121 str2 = "SET_VALUE"; break; 121 str2 = "SET_VALUE"; break;
@@ -308,19 +308,8 @@ EXPORT_SYMBOL(sof_ipc_tx_message);
308int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id) 308int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id)
309{ 309{
310 struct snd_sof_ipc_msg *msg = &sdev->ipc->msg; 310 struct snd_sof_ipc_msg *msg = &sdev->ipc->msg;
311 unsigned long flags;
312
313 /*
314 * Protect against a theoretical race with sof_ipc_tx_message(): if the
315 * DSP is fast enough to receive an IPC message, reply to it, and the
316 * host interrupt processing calls this function on a different core
317 * from the one, where the sending is taking place, the message might
318 * not yet be marked as expecting a reply.
319 */
320 spin_lock_irqsave(&sdev->ipc_lock, flags);
321 311
322 if (msg->ipc_complete) { 312 if (msg->ipc_complete) {
323 spin_unlock_irqrestore(&sdev->ipc_lock, flags);
324 dev_err(sdev->dev, "error: no reply expected, received 0x%x", 313 dev_err(sdev->dev, "error: no reply expected, received 0x%x",
325 msg_id); 314 msg_id);
326 return -EINVAL; 315 return -EINVAL;
@@ -330,8 +319,6 @@ int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id)
330 msg->ipc_complete = true; 319 msg->ipc_complete = true;
331 wake_up(&msg->waitq); 320 wake_up(&msg->waitq);
332 321
333 spin_unlock_irqrestore(&sdev->ipc_lock, flags);
334
335 return 0; 322 return 0;
336} 323}
337EXPORT_SYMBOL(snd_sof_ipc_reply); 324EXPORT_SYMBOL(snd_sof_ipc_reply);
@@ -776,16 +763,19 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev)
776 } 763 }
777 } 764 }
778 765
779 if (ready->debug.bits.build) { 766 if (ready->flags & SOF_IPC_INFO_BUILD) {
780 dev_info(sdev->dev, 767 dev_info(sdev->dev,
781 "Firmware debug build %d on %s-%s - options:\n" 768 "Firmware debug build %d on %s-%s - options:\n"
782 " GDB: %s\n" 769 " GDB: %s\n"
783 " lock debug: %s\n" 770 " lock debug: %s\n"
784 " lock vdebug: %s\n", 771 " lock vdebug: %s\n",
785 v->build, v->date, v->time, 772 v->build, v->date, v->time,
786 ready->debug.bits.gdb ? "enabled" : "disabled", 773 ready->flags & SOF_IPC_INFO_GDB ?
787 ready->debug.bits.locks ? "enabled" : "disabled", 774 "enabled" : "disabled",
788 ready->debug.bits.locks_verbose ? "enabled" : "disabled"); 775 ready->flags & SOF_IPC_INFO_LOCKS ?
776 "enabled" : "disabled",
777 ready->flags & SOF_IPC_INFO_LOCKSV ?
778 "enabled" : "disabled");
789 } 779 }
790 780
791 /* copy the fw_version into debugfs at first boot */ 781 /* copy the fw_version into debugfs at first boot */
diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c
index 81c7452aae17..628fae552442 100644
--- a/sound/soc/sof/loader.c
+++ b/sound/soc/sof/loader.c
@@ -372,6 +372,8 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev)
372 msecs_to_jiffies(sdev->boot_timeout)); 372 msecs_to_jiffies(sdev->boot_timeout));
373 if (ret == 0) { 373 if (ret == 0) {
374 dev_err(sdev->dev, "error: firmware boot failure\n"); 374 dev_err(sdev->dev, "error: firmware boot failure\n");
375 /* after this point FW_READY msg should be ignored */
376 sdev->boot_complete = true;
375 snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX | 377 snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX |
376 SOF_DBG_TEXT | SOF_DBG_PCI); 378 SOF_DBG_TEXT | SOF_DBG_PCI);
377 return -EIO; 379 return -EIO;
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 649968841dad..dace6c4cd91e 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -211,8 +211,8 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream,
211 /* save pcm hw_params */ 211 /* save pcm hw_params */
212 memcpy(&spcm->params[substream->stream], params, sizeof(*params)); 212 memcpy(&spcm->params[substream->stream], params, sizeof(*params));
213 213
214 INIT_WORK(&spcm->stream[substream->stream].period_elapsed_work, 214 /* clear hw_params_upon_resume flag */
215 sof_pcm_period_elapsed_work); 215 spcm->hw_params_upon_resume[substream->stream] = 0;
216 216
217 return ret; 217 return ret;
218} 218}
@@ -429,8 +429,8 @@ static int sof_pcm_open(struct snd_pcm_substream *substream)
429 dev_dbg(sdev->dev, "pcm: open stream %d dir %d\n", spcm->pcm.pcm_id, 429 dev_dbg(sdev->dev, "pcm: open stream %d dir %d\n", spcm->pcm.pcm_id,
430 substream->stream); 430 substream->stream);
431 431
432 /* clear hw_params_upon_resume flag */ 432 INIT_WORK(&spcm->stream[substream->stream].period_elapsed_work,
433 spcm->hw_params_upon_resume[substream->stream] = 0; 433 sof_pcm_period_elapsed_work);
434 434
435 caps = &spcm->pcm.caps[substream->stream]; 435 caps = &spcm->pcm.caps[substream->stream];
436 436
diff --git a/sound/soc/sof/xtensa/core.c b/sound/soc/sof/xtensa/core.c
index c3ad23a85b99..46a4905a9dce 100644
--- a/sound/soc/sof/xtensa/core.c
+++ b/sound/soc/sof/xtensa/core.c
@@ -110,7 +110,7 @@ static void xtensa_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack,
110 u32 stack_words) 110 u32 stack_words)
111{ 111{
112 struct sof_ipc_dsp_oops_xtensa *xoops = oops; 112 struct sof_ipc_dsp_oops_xtensa *xoops = oops;
113 u32 stack_ptr = xoops->stack; 113 u32 stack_ptr = xoops->plat_hdr.stackptr;
114 /* 4 * 8chars + 3 ws + 1 terminating NUL */ 114 /* 4 * 8chars + 3 ws + 1 terminating NUL */
115 unsigned char buf[4 * 8 + 3 + 1]; 115 unsigned char buf[4 * 8 + 3 + 1];
116 int i; 116 int i;
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index f2deffe026c5..9e1f00e8c32b 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1320,6 +1320,15 @@ static int sun4i_codec_spk_event(struct snd_soc_dapm_widget *w,
1320 gpiod_set_value_cansleep(scodec->gpio_pa, 1320 gpiod_set_value_cansleep(scodec->gpio_pa,
1321 !!SND_SOC_DAPM_EVENT_ON(event)); 1321 !!SND_SOC_DAPM_EVENT_ON(event));
1322 1322
1323 if (SND_SOC_DAPM_EVENT_ON(event)) {
1324 /*
1325 * Need a delay to wait for DAC to push the data. 700ms seems
1326 * to be the best compromise not to feel this delay while
1327 * playing a sound.
1328 */
1329 msleep(700);
1330 }
1331
1323 return 0; 1332 return 0;
1324} 1333}
1325 1334
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index c53bfed8d4c2..fd7c37596f21 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -106,7 +106,7 @@
106 106
107#define SUN8I_I2S_TX_CHAN_MAP_REG 0x44 107#define SUN8I_I2S_TX_CHAN_MAP_REG 0x44
108#define SUN8I_I2S_TX_CHAN_SEL_REG 0x34 108#define SUN8I_I2S_TX_CHAN_SEL_REG 0x34
109#define SUN8I_I2S_TX_CHAN_OFFSET_MASK GENMASK(13, 11) 109#define SUN8I_I2S_TX_CHAN_OFFSET_MASK GENMASK(13, 12)
110#define SUN8I_I2S_TX_CHAN_OFFSET(offset) (offset << 12) 110#define SUN8I_I2S_TX_CHAN_OFFSET(offset) (offset << 12)
111#define SUN8I_I2S_TX_CHAN_EN_MASK GENMASK(11, 4) 111#define SUN8I_I2S_TX_CHAN_EN_MASK GENMASK(11, 4)
112#define SUN8I_I2S_TX_CHAN_EN(num_chan) (((1 << num_chan) - 1) << 4) 112#define SUN8I_I2S_TX_CHAN_EN(num_chan) (((1 << num_chan) - 1) << 4)
@@ -456,6 +456,10 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
456 regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG, 456 regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
457 SUN8I_I2S_TX_CHAN_OFFSET_MASK, 457 SUN8I_I2S_TX_CHAN_OFFSET_MASK,
458 SUN8I_I2S_TX_CHAN_OFFSET(offset)); 458 SUN8I_I2S_TX_CHAN_OFFSET(offset));
459
460 regmap_update_bits(i2s->regmap, SUN8I_I2S_RX_CHAN_SEL_REG,
461 SUN8I_I2S_TX_CHAN_OFFSET_MASK,
462 SUN8I_I2S_TX_CHAN_OFFSET(offset));
459 } 463 }
460 464
461 regmap_field_write(i2s->field_fmt_mode, val); 465 regmap_field_write(i2s->field_fmt_mode, val);