linux-2.6-microblaze.git
21 months agoRevert "ALSA: hda: Fix page fault in snd_hda_codec_shutdown()"
Takashi Iwai [Fri, 15 Jul 2022 18:29:03 +0000 (20:29 +0200)]
Revert "ALSA: hda: Fix page fault in snd_hda_codec_shutdown()"

This reverts commit 980b3a8790b402e959a6d773b38b771019682be1.

The commit didn't consider the fact that ASoC hdac-hda driver
initializes the HD-audio stuff without calling
snd_hda_codec_device_init().  Hence this caused a regression leading
to Oops.

Revert the commit to restore the behavior.

Fixes: 980b3a8790b4 ("ALSA: hda: Fix page fault in snd_hda_codec_shutdown()")
Link: https://lore.kernel.org/r/3c40df55-3aee-1e08-493b-7b30cd84dc00@linux.intel.com
Link: https://lore.kernel.org/r/20220715182903.19594-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoRevert "ALSA: hda: cs35l41: Allow compilation test on non-ACPI configurations"
Takashi Iwai [Fri, 15 Jul 2022 18:24:27 +0000 (20:24 +0200)]
Revert "ALSA: hda: cs35l41: Allow compilation test on non-ACPI configurations"

Since the recent change in CS35L41 codec requires the reference of
acpi_dev handle, the current Kconfig may lead to a build breakage.

Revert the Kconfig change and re-introduce the hard dependency on
CONFIG_ACPI again as a temporary workaround.

Fixes: eef375960210 ("ALSA: hda: cs35l41: Support reading subsystem id from ACPI")
Link: https://lore.kernel.org/r/20220715182427.18891-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Skip event processing for unregistered codecs
Cezary Rojewski [Wed, 6 Jul 2022 12:02:26 +0000 (14:02 +0200)]
ALSA: hda: Skip event processing for unregistered codecs

When codec is unbound but not yet removed, in the eyes of
snd_hdac_bus_process_unsol_events() it is still a valid target to
delegate work to. Such behaviour may lead to use-after-free errors.
Address by verifying if codec is actually registered.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-6-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Add module parameter to control firmware load
Stefan Binding [Thu, 30 Jun 2022 00:23:35 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Add module parameter to control firmware load

By default, the driver will automatically load DSP firmware
for the amps, if available. Adding this option allows the
autoload to be optional, which allows for different configurations.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-15-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Support Firmware switching and reloading
Stefan Binding [Thu, 30 Jun 2022 00:23:34 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Support Firmware switching and reloading

This is required to support CS35L41 calibration.

By default, speaker protection firmware will be loaded, if
available. However, different firmware is required to run
the calibration sequence, so it is necessary to add support
to be able to unload, switch and reload firmware.

This patch adds 2 ALSA Controls for each amp:
"DSP1 Firmware Load"
"DSP1 Firmware Type"

"DSP1 Firmware Load" can be used to unload and
load the firmware.
"DSP1 Firmware Type"  can be used to switch the
target firmware to be loaded by "DSP1 Firmware Load"

Since loading firmware can add new ALSA controls, it is
necessary to ensure the firmware loading is run asynchronously
from the ALSA control itself to prevent deadlocks.

Note: When switching between firmwares, an ALSA control is
only added if it has not previously existed. If it had existed
previously, it will be re-enabled instead.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-14-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Add defaulted values into dsp bypass config sequence
Stefan Binding [Thu, 30 Jun 2022 00:23:33 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Add defaulted values into dsp bypass config sequence

The config sequences for running with and without firmware and DSP
are different. The original behavior assumed that we would only
run without DSP only in the case where firmware load failed.
This meant the non-firmware sequence was written with the assumtion
that various registers would be set to their default value.
However, to support the ability to unload the firmware, the
non-firmware register sequence must be updated to update all
required registers, including values that would be defaulted,
in case the firmware sequence, which could have already run,
has changed their value.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-13-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: hda_cs_dsp_ctl: Add fw id strings
Stefan Binding [Thu, 30 Jun 2022 00:23:32 +0000 (01:23 +0100)]
ALSA: hda: hda_cs_dsp_ctl: Add fw id strings

This will be used to define the firmware names.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-12-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Read Speaker Calibration data from UEFI variables
Stefan Binding [Thu, 30 Jun 2022 00:23:31 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Read Speaker Calibration data from UEFI variables

Speaker Calibration data, specific to an individual speaker is
stored inside UEFI variables during calibration, and can be
used by the DSP.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-11-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Support Hibernation during Suspend
Stefan Binding [Thu, 30 Jun 2022 00:23:30 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Support Hibernation during Suspend

CS35L41 supports hibernation during suspend when using
DSP firmware.
When the driver suspends it will hibernate the part, if
firmware is running, and resume will wake from hibernation.
CS35L41 driver will suspend/resume when requested by
hda driver.
Note that suspend/resume and hibernation is only supported
when firmware is running.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-10-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoMerge tag 'asoc-v5.20' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
Takashi Iwai [Fri, 15 Jul 2022 14:11:58 +0000 (16:11 +0200)]
Merge tag 'asoc-v5.20' of https://git./linux/kernel/git/broonie/sound into for-next

ASoC: Updates for v5.20

This is a big release thus far and there will probably be more changes
to come, it's a combination of a larger than usual crop of new drivers
and some subsysetm wide cleanups from Charles rather than anything
structural.  The SOF and Intel DSP code both also continue to be very
actively developed.

 - Restructing of the set_fmt() callbacks to be specified in terms of
   the device rather than with semantics depending on if the device is
   supposed to be a CODEC or SoC, making things clearer in situations
   like CODEC to CODEC links.
 - Clean up of the way we flag which DAI naming scheme we use to reflect
   the progress that's been made modernising things.
 - Merge of more of the Intel AVS driver stack, including some board
   integrations.
 - New version 4 mechanism for communication with SOF DSPs.
 - Suppoort for dynamically selecting the PLL to use at runtime on i.MX
   platforms.
 - Improvements for CODEC to CODEC support in the generic cards.
 - Support for AMD Jadeite and various machines, Intel MetorLake DSPs,
   Mediatek MT8186 DSPs and MT6366, nVidia Tegra MDDRC, OPE and PEQ, NXP
   TFA9890, Qualcomm SDM845, WCD9335 and WAS883x, and Texas Instruments
   TAS2780.

21 months agoALSA: bcd2000: Fix a UAF bug on the error path of probing
Zheyu Ma [Fri, 15 Jul 2022 01:05:15 +0000 (09:05 +0800)]
ALSA: bcd2000: Fix a UAF bug on the error path of probing

When the driver fails in snd_card_register() at probe time, it will free
the 'bcd2k->midi_out_urb' before killing it, which may cause a UAF bug.

The following log can reveal it:

[   50.727020] BUG: KASAN: use-after-free in bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000]
[   50.727623] Read of size 8 at addr ffff88810fab0e88 by task swapper/4/0
[   50.729530] Call Trace:
[   50.732899]  bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000]

Fix this by adding usb_kill_urb() before usb_free_urb().

Fixes: b47a22290d58 ("ALSA: MIDI driver for Behringer BCD2000 USB device")
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220715010515.2087925-1-zheyuma97@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoASoC: Merge up revert of v5.19 version of the rockchip BCLK management
Mark Brown [Thu, 14 Jul 2022 15:42:29 +0000 (16:42 +0100)]
ASoC: Merge up revert of v5.19 version of the rockchip BCLK management

Needed for further development.

21 months agoASoC: rsnd: care default case on rsnd_ssiu_busif_err_irq_ctrl()
Kuninori Morimoto [Thu, 14 Jul 2022 06:28:15 +0000 (06:28 +0000)]
ASoC: rsnd: care default case on rsnd_ssiu_busif_err_irq_ctrl()

Before, ssiu.c didn't care SSI5-8, thus,
commit b1384d4c95088d0 ("ASoC: rsnd: care default case on
rsnd_ssiu_busif_err_status_clear()") cares it for status clear.

But we should care it for error irq handling, too.
This patch cares it.

Reported-by: Nguyen Bao Nguyen <nguyen.nguyen.yj@renesas.com>
Reported-by: Nishiyama Kunihiko <kunihiko.nishiyama.dn@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871quocio1.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc-msg-injector: fix copy in sof_msg_inject_ipc4_dfs_write()
Dan Carpenter [Fri, 8 Jul 2022 13:48:36 +0000 (16:48 +0300)]
ASoC: SOF: ipc-msg-injector: fix copy in sof_msg_inject_ipc4_dfs_write()

There are two bugs that have to do with when we copy the payload:

size = simple_write_to_buffer(ipc4_msg->data_ptr,
      priv->max_msg_size, ppos, buffer,
      count);

The value of "*ppos" was supposed to be zero but it is
sizeof(ipc4_msg->header_u64) so it will copy the data into the middle of
the "ipc4_msg->data_ptr" buffer instead of to the start.  The second
problem is "buffer" should be "buffer + sizeof(ipc4_msg->header_u64)".

This function is used for fuzz testing so the data is normally random
and this bug likely does not affect anyone very much.

In this context, it's simpler and more appropriate to use copy_from_user()
instead of simple_write_to_buffer() so I have re-written the function.

Fixes: 066c67624d8c ("ASoC: SOF: ipc-msg-injector: Add support for IPC4 messages")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Ysg1tB2FKLnRMsel@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rockchip-i2s: Undo BCLK pinctrl changes
Mark Brown [Wed, 13 Jul 2022 13:04:51 +0000 (14:04 +0100)]
ASoC: rockchip-i2s: Undo BCLK pinctrl changes

The version of the BCLK pinctrl management changes that made it into
v5.19 has caused problems on some systems due to overly strict DT
requirements but attempts to fix it have caused further breakage on
other platforms.  Just drop the changes for this release, we already
have a better version queued for -next.

Fixes: 26b9f2fa7b1c ("ASoC: rockchip: i2s: Fix NULL pointer dereference when pinctrl is not found")
Fixes: a5450aba737d ("ASoC: rockchip: i2s: switch BCLK to GPIO")
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220713130451.31481-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoALSA: hda: cs35l41: Support Speaker ID for laptops
Stefan Binding [Thu, 30 Jun 2022 00:23:29 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Support Speaker ID for laptops

Some Laptops use a number of gpios to define which vendor is
used for a particular laptop.
Different coefficient files are used for different vendors.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-9-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Support multiple load paths for firmware
Stefan Binding [Thu, 30 Jun 2022 00:23:28 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Support multiple load paths for firmware

To be able to support different firmwares and tuning
for different models, the driver needs to be able to
load a different firmware and coefficient file based
on its Subsystem ID.

The driver attempts to load the firmware in the
following order:

/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>-<ssid>-dev<#>.wmfw
/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>-<ssid>.wmfw
/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>.wmfw

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-8-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Support reading subsystem id from ACPI
Stefan Binding [Thu, 30 Jun 2022 00:23:27 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Support reading subsystem id from ACPI

On some laptop models, the ACPI contains the unique
Subsystem ID, and this value should be preferred
over the value from the HDA driver.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-7-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Save Subsystem ID inside CS35L41 Driver
Stefan Binding [Thu, 30 Jun 2022 00:23:26 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Save Subsystem ID inside CS35L41 Driver

The Subsystem ID is read from the HDA driver, and will
be used by the CS35L41 driver to be able to uniquely
identify the laptop, which is required to be able to
define firmware to be used by specific models.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-6-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Add initial DSP support and firmware loading
Vitaly Rodionov [Thu, 30 Jun 2022 00:23:25 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Add initial DSP support and firmware loading

This patch adds support for the CS35L41 DSP.
The DSP allows for extra features, such as running
speaker protection algorithms and hibernations.

To utilize these features, the driver must load
firmware into the DSP, as well as various tuning
files which allow for customization for specific
models.

[ Slightly simplified Kconfig changes by tiwai ]

Signed-off-by: Vitaly Rodionov <vitaly.rodionov@cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-5-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Save codec object inside component struct
Stefan Binding [Thu, 30 Jun 2022 00:23:24 +0000 (01:23 +0100)]
ALSA: hda: cs35l41: Save codec object inside component struct

This is required for ALSA control support.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-4-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: hda_cs_dsp_ctl: Add apis to write the controls directly
Stefan Binding [Thu, 30 Jun 2022 00:23:23 +0000 (01:23 +0100)]
ALSA: hda: hda_cs_dsp_ctl: Add apis to write the controls directly

DSP controls are exposed as ALSA controls, however,
some of these controls are required to be accessed by
the driver. Add apis which allow read/write of these
controls. The write api will also notify the ALSA control
on value change.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-3-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: hda_cs_dsp_ctl: Add Library to support CS_DSP ALSA controls
Stefan Binding [Thu, 30 Jun 2022 00:23:22 +0000 (01:23 +0100)]
ALSA: hda: hda_cs_dsp_ctl: Add Library to support CS_DSP ALSA controls

The cs35l41 part contains a DSP which is able to run firmware.
The cs_dsp library can be used to control the DSP.
These controls can be exposed to userspace using ALSA controls.
This library adds apis to be able to interface between
cs_dsp and hda drivers and expose the relevant controls as
ALSA controls.

[ Note: the dependency of CONFIG_SND_HDA_CS_DSP_CONTROLS Kconfig is
  corrected.  Also, this Kconfig isn't enabled now but will be
  actually enabled in a later patch -- tiwai ]

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-2-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update
Uros Bizjak [Wed, 13 Jul 2022 15:19:46 +0000 (17:19 +0200)]
ALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update

Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old in
ep_state_update. x86 CMPXCHG instruction returns success in ZF flag,
so this change saves a compare after cmpxchg (and related move instruction
in front of cmpxchg).

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Link: https://lore.kernel.org/r/20220713151946.4743-1-ubizjak@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoASoC/SoundWire: Intel: add sdw BE dai trigger
Mark Brown [Wed, 13 Jul 2022 15:52:55 +0000 (16:52 +0100)]
ASoC/SoundWire: Intel: add sdw BE dai trigger

Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

For SOF IPC4, we need to set pipeline state in BE DAI trigger.

21 months agoASoC: SOF: Intel: add trigger callback into sdw_callback
Bard Liao [Fri, 8 Jul 2022 06:13:12 +0000 (14:13 +0800)]
ASoC: SOF: Intel: add trigger callback into sdw_callback

For IPC4, we need to set pipeline state in BE DAI trigger.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220708061312.25878-3-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agosoundwire: Intel: add trigger callback
Bard Liao [Fri, 8 Jul 2022 06:13:11 +0000 (14:13 +0800)]
soundwire: Intel: add trigger callback

When a pipeline is split into FE and BE parts, the BE pipeline may need to
be triggered separately in the BE trigger op. So add the trigger callback
in the link_res ops that will be invoked during BE DAI trigger.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20220708061312.25878-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: mt6359: Fix refcount leak bug
Liang He [Wed, 13 Jul 2022 10:20:13 +0000 (18:20 +0800)]
ASoC: mt6359: Fix refcount leak bug

In mt6359_parse_dt() and mt6359_accdet_parse_dt(), we should call
of_node_put() for the reference returned by of_get_child_by_name()
which has increased the refcount.

Fixes: 683530285316 ("ASoC: mt6359: fix failed to parse DT properties")
Fixes: eef07b9e0925 ("ASoC: mediatek: mt6359: add MT6359 accdet jack driver")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220713102013.367336-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: fix Jadeite kconfig warning and build errors
Randy Dunlap [Tue, 12 Jul 2022 18:33:48 +0000 (11:33 -0700)]
ASoC: amd: fix Jadeite kconfig warning and build errors

Since SND_SOC_ES8316 has a hard dependency on I2C and since 'select'
does not follow any dependency chains, SND_SOC_AMD_ST_ES8336_MACH
also needs to have a hard dependency on I2C.

Fixes a kconfig warning and subsequent build errors:

WARNING: unmet direct dependencies detected for SND_SOC_ES8316
  Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && I2C [=n]
  Selected by [y]:
  - SND_SOC_AMD_ST_ES8336_MACH [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_SOC_AMD_ACP [=y] && ACPI [=y] && (I2C [=n] || COMPILE_TEST [=y])

sound/soc/codecs/es8316.c:866:1: warning: data definition has no type or storage class
  866 | module_i2c_driver(es8316_i2c_driver);
sound/soc/codecs/es8316.c:866:1: error: type defaults to ‘int’ in declaration of ‘module_i2c_driver’ [-Werror=implicit-int]
sound/soc/codecs/es8316.c:866:1: warning: parameter names (without types) in function declaration
sound/soc/codecs/es8316.c:857:26: warning: ‘es8316_i2c_driver’ defined but not used [-Wunused-variable]
  857 | static struct i2c_driver es8316_i2c_driver = {

Fixes: f94fa8405801 ("ASoC: amd: enable machine driver build for Jadeite platform")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Link: https://lore.kernel.org/r/20220712183348.31046-1-rdunlap@infradead.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoc: audio-graph-card2: Fix refcount leak bug in __graph_get_type()
Liang He [Wed, 13 Jul 2022 07:12:00 +0000 (15:12 +0800)]
ASoc: audio-graph-card2: Fix refcount leak bug in __graph_get_type()

We should call of_node_put() for the reference before its replacement
as it returned by of_get_parent() which has increased the refcount.
Besides, we should also call of_node_put() before return.

Fixes: c8c74939f791 ("ASoC: audio-graph-card2: add Multi CPU/Codec support")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220713071200.366729-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: Fix error pointer dereference
Dan Carpenter [Tue, 12 Jul 2022 14:42:12 +0000 (17:42 +0300)]
ASoC: amd: Fix error pointer dereference

The "gpio_pa" pointer is an error pointer, there is no need to try
put it.  Calling gpiod_put() on it will lead to an error pointer
dereference.

Fixes: 02527c3f2300 ("ASoC: amd: add Machine driver for Jadeite platform")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Ys2IRPHWGIwuVs21@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoALSA: core: Fix missing return value comments for kernel docs
Takashi Iwai [Wed, 13 Jul 2022 10:47:59 +0000 (12:47 +0200)]
ALSA: core: Fix missing return value comments for kernel docs

Each kernel doc comment expects the definition of the return value in
a proper format.  This patch adds or fixes the missing entries for the
remaining ALSA core API functions.

Link: https://lore.kernel.org/r/20220713104759.4365-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: memalloc: Fix missing return value comments for kernel docs
Takashi Iwai [Wed, 13 Jul 2022 10:47:58 +0000 (12:47 +0200)]
ALSA: memalloc: Fix missing return value comments for kernel docs

Each kernel doc comment expects the definition of the return value in
a proper format.  This patch adds or fixes the missing entries for
memory allocation helpers.

Link: https://lore.kernel.org/r/20220713104759.4365-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: control: Fix missing return value comments for kernel docs
Takashi Iwai [Wed, 13 Jul 2022 10:47:57 +0000 (12:47 +0200)]
ALSA: control: Fix missing return value comments for kernel docs

Each kernel doc comment expects the definition of the return value in
proper format.  This patch adds or fixes the missing entries for
control API.

Link: https://lore.kernel.org/r/20220713104759.4365-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: compress: Fix kernel doc warnings
Takashi Iwai [Wed, 13 Jul 2022 10:47:56 +0000 (12:47 +0200)]
ALSA: compress: Fix kernel doc warnings

Each kernel doc comment expects the definition of the return value and
the summary for each struct / enum in a proper format.  This patch
adds or fixes the missing entries for compress-offload API.

Link: https://lore.kernel.org/r/20220713104759.4365-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: dmaengine: Fix missing return value comments for kernel docs
Takashi Iwai [Wed, 13 Jul 2022 10:47:55 +0000 (12:47 +0200)]
ALSA: dmaengine: Fix missing return value comments for kernel docs

Each kernel doc comment expects the definition of the return value in
a proper format.  This patch adds or fixes the missing entries for PCM
dmaengine API.

Link: https://lore.kernel.org/r/20220713104759.4365-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: pcm: Fix missing return value comments for kernel docs
Takashi Iwai [Wed, 13 Jul 2022 10:47:54 +0000 (12:47 +0200)]
ALSA: pcm: Fix missing return value comments for kernel docs

Each kernel doc comment expects the definition of the return value in
a proper format.  This patch adds or fixes the missing entries for PCM
API.

Link: https://lore.kernel.org/r/20220713104759.4365-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: compress: Enable kernel doc markers for some functions
Takashi Iwai [Wed, 13 Jul 2022 10:47:53 +0000 (12:47 +0200)]
ALSA: compress: Enable kernel doc markers for some functions

The exported functions snd_compress_new() and snd_compr_stop_error()
had already kernel-doc-style comments but they were not processed as
they weren't marked properly.  Let's enable them.

This patch also fixes the missing argument id for snd_compress_new
comments, too.

Reported-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/3cd6b93b36b32ad6ae160931aaa00b20688e241a.1656759989.git.mchehab@kernel.org
Link: https://lore.kernel.org/r/20220713104759.4365-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Consolidate selections under SND_HDA_SCODEC_CS35L41
Andy Shevchenko [Tue, 12 Jul 2022 15:35:19 +0000 (18:35 +0300)]
ALSA: hda: cs35l41: Consolidate selections under SND_HDA_SCODEC_CS35L41

Selections can be propagated via selections, while dependencies are not.
Hence, consolidate selections under the SND_HDA_SCODEC_CS35L41 option.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220712153519.35692-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Drop wrong use of ACPI_PTR()
Andy Shevchenko [Tue, 12 Jul 2022 15:35:18 +0000 (18:35 +0300)]
ALSA: hda: cs35l41: Drop wrong use of ACPI_PTR()

ACPI_PTR() is more harmful than helpful. For example, in this case
if CONFIG_ACPI=n, the ID table left unused which is not what we want.

Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220712153519.35692-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Allow compilation test on non-ACPI configurations
Andy Shevchenko [Tue, 12 Jul 2022 15:35:17 +0000 (18:35 +0300)]
ALSA: hda: cs35l41: Allow compilation test on non-ACPI configurations

ACPI is needed only for functioning of this codec on some platforms,
there is no compilation dependency, so make it optional

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220712153519.35692-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Don't dereference fwnode handle
Andy Shevchenko [Tue, 12 Jul 2022 15:35:16 +0000 (18:35 +0300)]
ALSA: hda: cs35l41: Don't dereference fwnode handle

Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
which is a better coding practice.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220712153519.35692-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoASoC: SOF: Intel: hda: Correct Firmware State Register use
Mark Brown [Tue, 12 Jul 2022 18:21:45 +0000 (19:21 +0100)]
ASoC: SOF: Intel: hda: Correct Firmware State Register use

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

The FSR (Firmware State Register) holds the ROM state information, it does not
contain error information.
The FSR itself is a bit more complicated as well as the state depends on the
module currently in use.

The error code from ROM or the status code from the firmware is located at the
next register.

Fix the handling of the FSR in order to provide usable and human readable (in
most cases) report on the status and error.

21 months agoExtend ipc stream parameters sent to DSP
Mark Brown [Tue, 12 Jul 2022 18:21:43 +0000 (19:21 +0100)]
Extend ipc stream parameters sent to DSP

Merge series from Daniel Baluta <daniel.baluta@oss.nxp.com>
Daniel Baluta <daniel.baluta@nxp.com>:

From: Daniel Baluta <daniel.baluta@nxp.com>

We need a way to send extra parameters to DSP firmware. In order to do
this, we introduce ext_data array at the end of ipc_stream_params.

With this new addition we can send compress parameters.

This requires SOF ABI bump.

21 months agoASoC: SOF: Intel: Do not process IPC reply before firmware boot
Mark Brown [Tue, 12 Jul 2022 18:21:42 +0000 (19:21 +0100)]
ASoC: SOF: Intel: Do not process IPC reply before firmware boot

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

By mistake a developer managed to create a 'corrupted' IPC4 firmware image which
loaded fine to the DSP and after boot it sent an IPC reply before we would have
received the FW_READY message.
It turned out that the image was an IPC3 firmware and the IPC reply was the IPC3
FW_READY notification message which got understood as an IPC4 reply message due
to the difference between the two IPC mechanism.

This caused a NULL pointer dereference since the reply memory will be allocated
after the FW_READY message.

To make sure this will not bite again, skip any spurious reply messages before
the FW_READY.

21 months agoASoC: SOF: Intel: hda-dai: No need to decouple host/link DMA twice
Mark Brown [Tue, 12 Jul 2022 18:21:41 +0000 (19:21 +0100)]
ASoC: SOF: Intel: hda-dai: No need to decouple host/link DMA twice

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

There is no need to decouple a decoupled stream twice.
Keep the decoupling in hda_link_stream_assign() only as it is going to be
executed in all cases.

Drop the outdated comment from hda_link_dma_hw_params() as well since the code
has changed around it.

21 months agoASoC: SOF: ipc3-topology: Prevent double freeing of ipc_control_data via load_bytes
Peter Ujfalusi [Tue, 12 Jul 2022 13:01:03 +0000 (16:01 +0300)]
ASoC: SOF: ipc3-topology: Prevent double freeing of ipc_control_data via load_bytes

We have sanity checks for byte controls and if any of the fail the locally
allocated scontrol->ipc_control_data is freed up, but not set to NULL.

On a rollback path of the error the higher level code will also try to free
the scontrol->ipc_control_data which will eventually going to lead to
memory corruption as double freeing memory is not a good thing.

Fixes: b5cee8feb1d4 ("ASoC: SOF: topology: Make control parsing IPC agnostic")
Reported-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220712130103.31514-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: sof-client-probes: Only load the driver if IPC3 is used
Peter Ujfalusi [Tue, 12 Jul 2022 13:10:22 +0000 (16:10 +0300)]
ASoC: SOF: sof-client-probes: Only load the driver if IPC3 is used

The current implementation of probes only supports IPC3 and should not be
loaded for other IPC implementation.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220712131022.1124-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda: Use cold/purge boot after firmware crash
Mark Brown [Tue, 12 Jul 2022 15:10:05 +0000 (16:10 +0100)]
ASoC: SOF: Intel: hda: Use cold/purge boot after firmware crash

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

In case of a firmware crash we force the DSP to be powered down and rebooted.
To make sure that the next boot is going to be clean, force the boot process to
skip the IMR booting and re-download the firmware.

21 months agouapi: sof: abi: Bump SOF ABI for ext_data_length
Daniel Baluta [Tue, 12 Jul 2022 14:15:31 +0000 (17:15 +0300)]
uapi: sof: abi: Bump SOF ABI for ext_data_length

Add new field to sof_ipc_stream_params in order to extend
stream params struct with extended data to store compress parameters.

Older kernel will still work this as they ext_data_length will always be
zero.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220712141531.14599-5-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: compress: Prevent current kernel running with older FW
Daniel Baluta [Tue, 12 Jul 2022 14:15:30 +0000 (17:15 +0300)]
ASoC: SOF: compress: Prevent current kernel running with older FW

After introducing extended parameters we need to forbid older firmware
versions to run with the current and future kernel versions.

Although in theory the communication protocol will still work the
semantics at application level are undefined. So, prevent this by
disallowing older firmwares to run with newer kernels.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220712141531.14599-4-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Copy compress parameters into extended data
Daniel Baluta [Tue, 12 Jul 2022 14:15:29 +0000 (17:15 +0300)]
ASoC: SOF: Copy compress parameters into extended data

Allocate memory at the end of sof_ipc_stream_params to store
snd_compr_params in order to be sent them to SOF firmware.

This will help firmware correctly configure codecs parameters.

Notice, that we use 2 bytes from the reserved pool in order to store
the extended data length. This is compatible with older FWs where
there was no extended data.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220712141531.14599-3-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: compress: Dynamically allocate pcm params struct
Daniel Baluta [Tue, 12 Jul 2022 14:15:28 +0000 (17:15 +0300)]
ASoC: SOF: compress: Dynamically allocate pcm params struct

We need to extend sof_ipc_pcm_parmas with additional data in order
to send compress_params to SOF FW.

The extensions will be done at runtime so we need to dynamically
allocate pcm object of type struct sof_ipc_pcm_params.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220712141531.14599-2-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda-dai: Do snd_hdac_ext_stream_decouple() only once
Peter Ujfalusi [Tue, 12 Jul 2022 13:16:20 +0000 (16:16 +0300)]
ASoC: SOF: Intel: hda-dai: Do snd_hdac_ext_stream_decouple() only once

Call snd_hdac_ext_stream_decouple_locked() unconditionally in
hda_link_stream_assign(), the snd_hdac_ext_stream_decouple_locked() have
internal checks to avoid re-configuring.

There is no need to call snd_hdac_ext_stream_decouple() via
hda_link_dma_params() as the stream must have been set to decoupled when
it got assigned (even if it used local condition to call
snd_hdac_ext_stream_decouple_locked()).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220712131620.13365-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda-dai: Drop misleading comment regarding dma_data
Peter Ujfalusi [Tue, 12 Jul 2022 13:16:19 +0000 (16:16 +0300)]
ASoC: SOF: Intel: hda-dai: Drop misleading comment regarding dma_data

The comment in hda_link_dma_hw_params() is no longer valid as the dma_data
is set to NULL at system suspend as well.

Instead of rewording the comment to state the obvious: try to take the
hext_stream from the dma_data and if it is not set then assign a new one
and store it as dma_data.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220712131620.13365-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda: Correct the ROM/FW state reporting code
Peter Ujfalusi [Tue, 12 Jul 2022 12:57:32 +0000 (15:57 +0300)]
ASoC: SOF: Intel: hda: Correct the ROM/FW state reporting code

The FSR (Firmware State Register) can be found at offset 0 in the SRAM and
it is holding information about the state of the ROM/FW.
In case of a boot failure it can be used to get the state where the boot
process got stuck, it does not itself contains error codes as such.

The error code (or the firmware state information) is stored in the next
soft register at offset 0x4.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220712125734.30512-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: topology: remove unused variable
Ranjani Sridharan [Tue, 12 Jul 2022 12:39:02 +0000 (15:39 +0300)]
ASoC: SOF: topology: remove unused variable

'ret' is never used. Remove it and return 0 instead.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220712123902.14696-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: soc-pcm: demote warnings on non-atomic BE connection
Pierre-Louis Bossart [Fri, 8 Jul 2022 20:06:41 +0000 (15:06 -0500)]
ASoC: soc-pcm: demote warnings on non-atomic BE connection

When an FE, typically non-atomic, is connected to an atomic BE, we
force the BE as non-atomic. There's no reason to throw a warning, this
is a perfectly fine configuration and a conversion that's required
by-design.

This removes the unconditional warnings such as

[   12.054213]  iDisp1: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic
[   12.074693]  iDisp2: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic
[   12.096612]  iDisp3: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic
[   12.118637]  iDisp4: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic
[   12.140660]  dmic01: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic
[   12.147521]  dmic16k: dpcm_be_connect: FE is nonatomic but BE is not, forcing BE as nonatomic

and demotes them to dev_dbg(), as suggested in review comments.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220708200641.26923-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda: Introduce skip_imr_boot flag
Peter Ujfalusi [Tue, 12 Jul 2022 12:09:35 +0000 (15:09 +0300)]
ASoC: SOF: Intel: hda: Introduce skip_imr_boot flag

Use a dedicated flag instead of directly checking the
sdev->system_suspend_target to decide if we need to skip IMR boot due to
too deep sleep state where the memory used for IMR booting will not retain
its content.

The skip_imr_boot flag will be set true during suspend if the target state
is deeper than S3 and reset back to false on successful boot to re-enable
IMR booting in shallower sleep states.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220712120936.28072-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: mtl: Do not process IPC reply before firmware boot
Peter Ujfalusi [Tue, 12 Jul 2022 12:23:57 +0000 (15:23 +0300)]
ASoC: SOF: Intel: mtl: Do not process IPC reply before firmware boot

It is not yet clear, but it is possible to create a firmware so broken
that it will send a reply message before a FW_READY message (it is not
yet clear if FW_READY will arrive later).
Since the reply_data is allocated only after the FW_READY message, this
will lead to a NULL pointer dereference if not filtered out.

Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220712122357.31282-4-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: hda-ipc: Do not process IPC reply before firmware boot
Peter Ujfalusi [Tue, 12 Jul 2022 12:23:56 +0000 (15:23 +0300)]
ASoC: SOF: Intel: hda-ipc: Do not process IPC reply before firmware boot

It is not yet clear, but it is possible to create a firmware so broken
that it will send a reply message before a FW_READY message (it is not
yet clear if FW_READY will arrive later).
Since the reply_data is allocated only after the FW_READY message, this
will lead to a NULL pointer dereference if not filtered out.

The issue was reported with IPC4 firmware but the same condition is present
for IPC3.

Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220712122357.31282-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: Intel: cnl: Do not process IPC reply before firmware boot
Peter Ujfalusi [Tue, 12 Jul 2022 12:23:55 +0000 (15:23 +0300)]
ASoC: SOF: Intel: cnl: Do not process IPC reply before firmware boot

It is not yet clear, but it is possible to create a firmware so broken
that it will send a reply message before a FW_READY message (it is not
yet clear if FW_READY will arrive later).
Since the reply_data is allocated only after the FW_READY message, this
will lead to a NULL pointer dereference if not filtered out.

The issue was reported with IPC4 firmware but the same condition is present
for IPC3.

Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220712122357.31282-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoALSA: hda: cs35l41: Improve dev_err_probe() messaging
Andy Shevchenko [Mon, 11 Jul 2022 09:52:16 +0000 (12:52 +0300)]
ALSA: hda: cs35l41: Improve dev_err_probe() messaging

Drop duplicate print of returned value in the messages and use pattern
return dev_err_probe(...) where it's possible.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220711095219.36915-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: cs35l41: Fix comments wrt serial-multi-instantiate reference
Andy Shevchenko [Mon, 11 Jul 2022 10:01:29 +0000 (13:01 +0300)]
ALSA: hda: cs35l41: Fix comments wrt serial-multi-instantiate reference

The comments are inconsistent and point to the wrong driver name.
The initially named i2c-multi-instantiate it was renamed to the
serial-multi-instantiate exactly due to support of the platforms
with multiple CS35L41 codecs.

Fix comments accordingly.

While at it, drop file names from the files.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220711100129.37326-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoASoC: Intel: avs: Updates and cleanups
Mark Brown [Mon, 11 Jul 2022 21:13:49 +0000 (22:13 +0100)]
ASoC: Intel: avs: Updates and cleanups

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

Series consists of loosely connected patches and does not concentrate on
one specific subject.

First, as generic HDAudio codec driver is now part of ASoC, avs-driver
core is updated to register missing ext_bus operations. This completes
driver's core implementation.

The next change adds the last missing piece for port descriptions coming
from topology in formatted string format e.g.: ssp%d have full
effect. To do that, the port value needs to be provided to respective
copier configuration.

Third change relaxes core transition timings so that scenarios where
modules are interfering with each other while being on separate cores
are not occasionally causing trouble.

All other changes are addressing warnings, cleaning things up a little
and protecting driver from invalid firmware behavior - while not
expected in release binaries, does not hurt to add them.

21 months agoASoC: nau8821: Add headset button detection
Seven Lee [Mon, 27 Jun 2022 03:29:59 +0000 (11:29 +0800)]
ASoC: nau8821: Add headset button detection

This patch adds the function of headphone button detection,
Button detection will be enabled if the device tree
has a key_enable property.

Signed-off-by: Seven Lee <wtli@nuvoton.com>
Link: https://lore.kernel.org/r/20220627032959.3442064-1-wtli@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: Series of fixes for realtek codecs used on RVPs
Mark Brown [Mon, 11 Jul 2022 16:00:54 +0000 (17:00 +0100)]
ASoC: codecs: Series of fixes for realtek codecs used on RVPs

Merge series from Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>:

Our tests platforms do use realtek codecs, while implementing avs driver
and machine boards for it, we identified some problems with those codec
drivers.

This series aims to fix those issues.

21 months agoADD legacy audio driver support for rembrandt
Mark Brown [Mon, 11 Jul 2022 15:18:15 +0000 (16:18 +0100)]
ADD legacy audio driver support for rembrandt

Merge series from V sujith kumar Reddy <Vsujithkumar.Reddy@amd.com>:

Add Generic driver to support multiple platform,
ADD HS control instance for Rembrandt platform.
Add nau8825,max98560 and rt5682s,rt1019 combination support for legacy
platform.

21 months agoASoC: SOF: ipc4-topology: fix error and memory handling
Mark Brown [Mon, 11 Jul 2022 15:18:13 +0000 (16:18 +0100)]
ASoC: SOF: ipc4-topology: fix error and memory handling

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

Two patches to improve error and memory handling. When IPC4 is used,
some of the flows were incorrect.

21 months agoASoC: SOF: remove warning on ABI checks
Pierre-Louis Bossart [Fri, 8 Jul 2022 20:07:19 +0000 (15:07 -0500)]
ASoC: SOF: remove warning on ABI checks

We should only have an error when enforcing strict mapping between
kernel and firmware versions. In all other cases, there is no reason
to throw a warning.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220708200719.26961-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: atmel: mchp-pdmc: remove space in front of mchp_pdmc_dt_init()
Claudiu Beznea [Mon, 11 Jul 2022 11:22:12 +0000 (14:22 +0300)]
ASoC: atmel: mchp-pdmc: remove space in front of mchp_pdmc_dt_init()

Remove extra space in front of mchp_pdmc_dt_init().

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20220711112212.888895-1-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Merge up fixes
Mark Brown [Mon, 11 Jul 2022 14:51:01 +0000 (15:51 +0100)]
ASoC: Merge up fixes

Needed for the Rockchip driver.

21 months agoASoC: codecs: rt274: Set component to NULL on remove
Amadeusz Sławiński [Thu, 7 Jul 2022 12:57:01 +0000 (14:57 +0200)]
ASoC: codecs: rt274: Set component to NULL on remove

Make sure that component is set to proper value, otherwise we may
dereference freed component in interrupt.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707125701.3518263-6-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: rt298: Set component to NULL on remove
Amadeusz Sławiński [Thu, 7 Jul 2022 12:57:00 +0000 (14:57 +0200)]
ASoC: codecs: rt298: Set component to NULL on remove

Make sure that component is set to proper value, otherwise we may
dereference freed component in interrupt.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707125701.3518263-5-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: rt286: Set component to NULL on remove
Amadeusz Sławiński [Thu, 7 Jul 2022 12:56:59 +0000 (14:56 +0200)]
ASoC: codecs: rt286: Set component to NULL on remove

Make sure that component is set to proper value, otherwise we may
dereference freed component in interrupt.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707125701.3518263-4-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: rt298: Fix jack detection
Amadeusz Sławiński [Thu, 7 Jul 2022 12:56:58 +0000 (14:56 +0200)]
ASoC: codecs: rt298: Fix jack detection

On our RVP platforms using rt298 with combojack we've seen issues with
controls being in incorrect state after suspend/resume cycle. This is
caused by codec driver not setting pins to correct state and causing
codec suspend method to not be called. Which on resume caused codec
registers to be in undefined state. Fix this by setting pins correctly
in jack detect function.

Above problem is caused by the fact that when jack == NULL code doesn't
reach rt298_jack_detect() function which sets pins. Alternatively
problem could be fixed by just moving rt298_jack_detect, but as rt298
codec is similar to rt286, align the code by setting pins explicitly.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707125701.3518263-3-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: rt298: Fix NULL jack in interrupt
Amadeusz Sławiński [Thu, 7 Jul 2022 12:56:57 +0000 (14:56 +0200)]
ASoC: codecs: rt298: Fix NULL jack in interrupt

Set rt298->jack to passed value in mic_detect, otherwise when jack is
set to NULL on next interrupt call, we may use freed pointer.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707125701.3518263-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rockchip: i2s: Fix NULL pointer dereference when pinctrl is not found
Alexandru Elisei [Mon, 11 Jul 2022 13:05:22 +0000 (14:05 +0100)]
ASoC: rockchip: i2s: Fix NULL pointer dereference when pinctrl is not found

Commit a5450aba737d ("ASoC: rockchip: i2s: switch BCLK to GPIO") switched
BCLK to GPIO functions when probing the i2s bus interface, but missed
adding a check for when devm_pinctrl_get() returns an error.  This can lead
to the following NULL pointer dereference on a rockpro64-v2 if there are no
"pinctrl" properties in the i2s device tree node.

Check that i2s->pinctrl is valid before attempting to search for the
bclk_on and bclk_off pinctrl states.

Fixes: a5450aba737d ("ASoC: rockchip: i2s: switch BCLK to GPIO")
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20220711130522.401551-1-alexandru.elisei@arm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: fsl_utils: Drop usage of __clk_get_name()
Shengjiu Wang [Mon, 11 Jul 2022 02:39:50 +0000 (10:39 +0800)]
ASoC: fsl_utils: Drop usage of __clk_get_name()

Avoid build errors when CONFIG_COMMON_CLK is not set/enabled.

ERROR: modpost: "__clk_get_name" [sound/soc/fsl/snd-soc-fsl-utils.ko] undefined!

Fixes: 7bad8125549c ("ASoC: fsl_utils: Add function to handle PLL clock source")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1657507190-14546-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: mediatek: mt8186: Remove condition with no effect
Zhongjun Tan [Fri, 8 Jul 2022 02:46:51 +0000 (10:46 +0800)]
ASoC: mediatek: mt8186: Remove condition with no effect

Remove condition with no effect

Signed-off-by: Zhongjun Tan <tanzhongjun@coolpad.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220708024651.42999-1-hbut_tan@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoALSA: hda: Remove unused macro definition
Amadeusz Sławiński [Wed, 6 Jul 2022 12:02:29 +0000 (14:02 +0200)]
ALSA: hda: Remove unused macro definition

It is not used anywhere in the file, so there is no need to keep it.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-9-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Reset all SIE bits in INTCTL
Amadeusz Sławiński [Wed, 6 Jul 2022 12:02:28 +0000 (14:02 +0200)]
ALSA: hda: Reset all SIE bits in INTCTL

Old code resets SIE for up to 8 streams using byte accessor, but
register is laid out in following way:

31 GIE
30 CIE
29:x Reserved
x-1:0 SIE

If there is more than 8 streams, some of them may and up with enabled
interrupts. To fix this just clear whole INTCTL register when disabling
interrupts.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-8-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Fix page fault in snd_hda_codec_shutdown()
Cezary Rojewski [Wed, 6 Jul 2022 12:02:27 +0000 (14:02 +0200)]
ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

If early probe of HDAudio bus driver fails e.g.: due to missing
firmware file, snd_hda_codec_shutdown() ends in manipulating
uninitialized codec->pcm_list_head causing page fault.

Iinitialization of HDAudio codec in ASoC is split in two:
- snd_hda_codec_device_init()
- snd_hda_codec_device_new()

snd_hda_codec_device_init() is called during probe_codecs() by HDAudio
bus driver while snd_hda_codec_device_new() is called by
codec-component's ->probe(). The second call will not happen until all
components required by related sound card are present within the ASoC
framework. With firmware failing to load during the PCI's deferred
initialization i.e.: probe_work(), no platform components are ever
registered. HDAudio codec enumeration is done at that point though, so
the codec components became registered to ASoC framework, calling
snd_hda_codec_device_init() in the process.

Now, during platform reboot snd_hda_codec_shutdown() is called for every
codec found on the HDAudio bus causing oops if any of them has not
completed both of their initialization steps. Relocating field
initialization fixes the issue.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-7-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Fix put_device() inconsistency in error path
Cezary Rojewski [Wed, 6 Jul 2022 12:02:25 +0000 (14:02 +0200)]
ALSA: hda: Fix put_device() inconsistency in error path

AVS HDAudio bus driver does not tie with codec drivers tighly. Codec
device and its respective driver cleanup procedures are split and may
not occur one after the other. Device cleanup is performed only on
snd_hdac_ext_bus_device_remove() i.e. it's the bus driver's
responsibility. If codec component probing fails, put_device() found in
snd_hda_codec_device_new() may lead to page fault. Relocate it to
snd_hda_codec_new() to address the problem on ASoC side while keeping
status quo for snd_hda_intel.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-5-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Make device usage_count consistent across subsequent probing
Cezary Rojewski [Wed, 6 Jul 2022 12:02:24 +0000 (14:02 +0200)]
ALSA: hda: Make device usage_count consistent across subsequent probing

AVS HDAudio bus driver does not tie with codec drivers tighly and
snd_hda_codec_device_new() can be called after codec's module reload. In
such case, rpm is forbidden and invoking pm_runtime_forbid()
unconditionally causes device's usage_count to become unbalanced. This
is later caught by WARN_ON() found in sound/soc/hda.c. Detect such
circumstance and bump the usage_count instead.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-4-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoALSA: hda: Fix null-ptr-deref when i915 fails and hdmi is denylisted
Cezary Rojewski [Wed, 6 Jul 2022 12:02:23 +0000 (14:02 +0200)]
ALSA: hda: Fix null-ptr-deref when i915 fails and hdmi is denylisted

If snd_hda_hdmi_codec module is denylisted and any event causes i915
enumeration to fail, is_likely_hdmi_codec() ends in null-ptr-deref.

As snd_soc_hda is an ASoC-based driver, its initialization is delayed
until all the necessary components appear in the system - allowing
actual sound card to enumerate. snd_hda_codec_configure() gets called by
the avs-driver core during probe_codecs() but the
snd_hda_codec_device_new(), necessary to complete codecs initialization,
happens only when codec-component of hda sound card is being probed.

Denylisting snd_hda_codec_hdmi module causes snd_hda_codec_configure()
to reach: codec_bind_generic() -> is_likely_hdmi_codec() which makes use
of ->wcaps and at this point the it isn't initialized yet - again,
requires completion of snd_hda_codec_device_new().

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-3-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 months agoASoC: audio-graph-card2.c: make Codec2Codec settings optional
Mark Brown [Fri, 8 Jul 2022 20:46:29 +0000 (21:46 +0100)]
ASoC: audio-graph-card2.c: make Codec2Codec settings optional

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Audio Graph Card2 has Codec2Codec support, but I noticed
 - Current Codec2Codec setting value is not correct
   because it is using of_get_property().
 - simple-card-utils has default Codec2Codec settings
   and it is overwriting Card2 settings
 - This default settings works for non Codec2Codec case
   (= DPCM::BE case) too.

This patch-set solve these issues.

21 months agoASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload
Mark Brown [Fri, 8 Jul 2022 20:46:28 +0000 (21:46 +0100)]
ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload

Merge series from Brent Lu <brent.lu@intel.com>:

1. Add BT offload fetch to cs42l42 machine driver
2. Support cs42l42+max98360a on ADL platform

21 months agoASoC: SOF: ipc4-topology: free memories allocated in sof_ipc4_get_audio_fmt
Libin Yang [Fri, 8 Jul 2022 20:05:16 +0000 (15:05 -0500)]
ASoC: SOF: ipc4-topology: free memories allocated in sof_ipc4_get_audio_fmt

Free the memories allocated in sof_ipc4_get_audio_fmt in error handling
and ipc_free()

Fixes: 2cabd02b6090 ("ASoC: SOF: ipc4-topology: Add support for parsing AIF_IN/AIF_OUT widgets")
Fixes: abfb536bd116 ("ASoC: SOF: ipc4-topology: Add support for parsing DAI_IN/DAI_OUT widgets")
Fixes: 4f838ab20812 ("ASoC: SOF: ipc4-topology: Add support for parsing and preparing pga widgets")
Fixes: 4d4ba014ac4b ("ASoC: SOF: ipc4-topology: Add support for parsing mixer widgets")
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220708200516.26853-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-topology: check dai->private in ipc_free()
Libin Yang [Fri, 8 Jul 2022 20:05:15 +0000 (15:05 -0500)]
ASoC: SOF: ipc4-topology: check dai->private in ipc_free()

Set the swidget->private or dai->private to NULL after kfree in the error
handling in ipc_setup(). The private needs to be set NULL because if
ipc_setup() returns error, ipc_free() will be called later. ipc_free()
will judge the private is NULL or not to do the clearing.

For dai widget, dai->private is allocated and set in dai widget
ipc_setup(). So we need to check dai->private is NULL or not
in the ipc_free().

Fixes: 2cabd02b6090 ("ASoC: SOF: ipc4-topology: Add support for parsing AIF_IN/AIF_OUT widgets")
Fixes: abfb536bd116 ("ASoC: SOF: ipc4-topology: Add support for parsing DAI_IN/DAI_OUT widgets")
Fixes: 4f838ab20812 ("ASoC: SOF: ipc4-topology: Add support for parsing and preparing pga widgets")
Fixes: 4d4ba014ac4b ("ASoC: SOF: ipc4-topology: Add support for parsing mixer widgets")
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220708200516.26853-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration
Cezary Rojewski [Thu, 7 Jul 2022 12:41:53 +0000 (14:41 +0200)]
ASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration

To reduce the number of places to update if timeouts would have to
change, modify the constant declaration.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-13-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout
Cezary Rojewski [Thu, 7 Jul 2022 12:41:52 +0000 (14:41 +0200)]
ASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout

Module unloading operation performs memory unmapping and the weight of
the opration does not different from any other standard IPC. There is no
dependency on secondary task like in module loading scenario where
larger message timeout is recommended.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-12-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET
Cezary Rojewski [Thu, 7 Jul 2022 12:41:51 +0000 (14:41 +0200)]
ASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET

Improve readability of CLDMA reset operation by making use of
already defined SD_CTL_STREAM_RESET.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-11-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Recognize FW_CFG_RESERVED
Cezary Rojewski [Thu, 7 Jul 2022 12:41:50 +0000 (14:41 +0200)]
ASoC: Intel: avs: Recognize FW_CFG_RESERVED

If exposed by firmware, count RESERVED parameter as known one to avoid
dumping noise in kernel logs.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-10-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Use helper function to set up DMA
Amadeusz Sławiński [Thu, 7 Jul 2022 12:41:49 +0000 (14:41 +0200)]
ASoC: Intel: avs: Use helper function to set up DMA

dma_set_mask() and dma_set_coherent_mask() can be performed with one
call to dma_set_mask_and_coherent(), which slightly reduces amount of
code on our side.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-9-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Set max DMA segment size
Amadeusz Sławiński [Thu, 7 Jul 2022 12:41:48 +0000 (14:41 +0200)]
ASoC: Intel: avs: Set max DMA segment size

Apparently it is possible for code to allocate large buffers which may
cause warnings as reported in [1]. This was fixed for HDA, SOF and
skylake in patchset [2], fix it also for avs driver.

[1] https://github.com/thesofproject/linux/issues/3430
[2] https://lore.kernel.org/all/20220215132756.31236-1-tiwai@suse.de/

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-8-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Block IPC channel on suspend
Cezary Rojewski [Thu, 7 Jul 2022 12:41:47 +0000 (14:41 +0200)]
ASoC: Intel: avs: Block IPC channel on suspend

To allow for driver's filesystem interfaces e.g.: debugfs, to be touched
even when the device is asleep, mark IPC-channel as blocked when the
device is suspended. This causes any invocation of said interfaces that
do not toggle PM themselves to gracefully fail with "Operation not
permitted" message.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-7-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size
Cezary Rojewski [Thu, 7 Jul 2022 12:41:46 +0000 (14:41 +0200)]
ASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size

Some LARGE_CONFIG_GETs are never expected to return payload of size 0.
Check for such situation and collapse if met.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-6-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Copy only as many RX bytes as necessary
Cezary Rojewski [Thu, 7 Jul 2022 12:41:45 +0000 (14:41 +0200)]
ASoC: Intel: avs: Copy only as many RX bytes as necessary

There is no need to copy number of bytes specified by IPC message caller
if DSP firmware returned lower number. In consequence, LARGE_CONFIG_GET
handler is simplified.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-5-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: Intel: avs: Relax DSP core transition timings
Cezary Rojewski [Thu, 7 Jul 2022 12:41:44 +0000 (14:41 +0200)]
ASoC: Intel: avs: Relax DSP core transition timings

To avoid any false positives when checking CPA after setting SPA, do a
short wait. For stall operation, give HW more time to propagate the
change before moving on.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220707124153.1858249-4-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>