2023-04-14 15:29:53

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 0/4] Fixes and cleanup for CS35L41 HDA

Several minor issues were found during additional testing and
static analysis. These patches fix these minor issues.

Stefan Binding (4):
ALSA: hda: cs35l41: Clean up Firmware Load Controls
ALSA: hda: cs35l41: Fix endian conversions
ALSA: cs35l41: Fix default regmap values for some registers
ALSA: hda/realtek: Delete cs35l41 component master during free

sound/pci/hda/cs35l41_hda.c | 40 +++++++++++++++-------------------
sound/pci/hda/patch_realtek.c | 2 ++
sound/soc/codecs/cs35l41-lib.c | 6 ++---
3 files changed, 23 insertions(+), 25 deletions(-)

--
2.34.1


2023-04-14 15:29:56

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 4/4] ALSA: hda/realtek: Delete cs35l41 component master during free

This ensures that the driver is properly cleaned up when freed.

Signed-off-by: Stefan Binding <[email protected]>
---
sound/pci/hda/patch_realtek.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 3b9f077a227f7..bbeffbb84091e 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6757,6 +6757,8 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char
else
spec->gen.pcm_playback_hook = comp_generic_playback_hook;
break;
+ case HDA_FIXUP_ACT_FREE:
+ component_master_del(dev, &comp_master_ops);
}
}

--
2.34.1

2023-04-14 15:30:45

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 2/4] ALSA: hda: cs35l41: Fix endian conversions

Found during static analysis, ensure variables are correct
types before endian conversion.

Signed-off-by: Stefan Binding <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index d100189e15b83..b02462ae21f04 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -308,8 +308,8 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41,
}

#if IS_ENABLED(CONFIG_EFI)
-static int cs35l41_apply_calibration(struct cs35l41_hda *cs35l41, unsigned int ambient,
- unsigned int r0, unsigned int status, unsigned int checksum)
+static int cs35l41_apply_calibration(struct cs35l41_hda *cs35l41, __be32 ambient, __be32 r0,
+ __be32 status, __be32 checksum)
{
int ret;

@@ -379,10 +379,10 @@ static int cs35l41_save_calibration(struct cs35l41_hda *cs35l41)

/* Calibration can only be applied whilst the DSP is not running */
ret = cs35l41_apply_calibration(cs35l41,
- cpu_to_be32(cl->calAmbient),
- cpu_to_be32(cl->calR),
- cpu_to_be32(cl->calStatus),
- cpu_to_be32(cl->calR + 1));
+ (__be32)cpu_to_be32(cl->calAmbient),
+ (__be32)cpu_to_be32(cl->calR),
+ (__be32)cpu_to_be32(cl->calStatus),
+ (__be32)cpu_to_be32(cl->calR + 1));
}
}
vfree(data);
@@ -745,7 +745,7 @@ static int cs35l41_runtime_resume(struct device *dev)

static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
{
- int halo_sts;
+ __be32 halo_sts;
int ret;

ret = cs35l41_init_dsp(cs35l41);
@@ -773,7 +773,7 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
&halo_sts, sizeof(halo_sts));

if (ret) {
- dev_err(cs35l41->dev, "Timeout waiting for HALO Core to start. State: %d\n",
+ dev_err(cs35l41->dev, "Timeout waiting for HALO Core to start. State: %u\n",
halo_sts);
goto clean_dsp;
}
--
2.34.1

2023-04-14 15:31:12

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 1/4] ALSA: hda: cs35l41: Clean up Firmware Load Controls

Ensure Firmware Load control and Firmware Type control
returns 1 when the value changes.

Remove fw_mutex from firmware load control put, since it is
unnecessary, and prevents any possibility of mutex inversion.

Signed-off-by: Stefan Binding <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index b5210abb5141f..d100189e15b83 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -835,34 +835,26 @@ static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol);
- unsigned int ret = 0;
-
- mutex_lock(&cs35l41->fw_mutex);

if (cs35l41->request_fw_load == ucontrol->value.integer.value[0])
- goto err;
+ return 0;

if (cs35l41->fw_request_ongoing) {
dev_dbg(cs35l41->dev, "Existing request not complete\n");
- ret = -EBUSY;
- goto err;
+ return -EBUSY;
}

/* Check if playback is ongoing when initial request is made */
if (cs35l41->playback_started) {
dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n");
- ret = -EBUSY;
- goto err;
+ return -EBUSY;
}

cs35l41->fw_request_ongoing = true;
cs35l41->request_fw_load = ucontrol->value.integer.value[0];
schedule_work(&cs35l41->fw_load_work);

-err:
- mutex_unlock(&cs35l41->fw_mutex);
-
- return ret;
+ return 1;
}

static int cs35l41_fw_type_ctl_get(struct snd_kcontrol *kcontrol,
@@ -881,8 +873,12 @@ static int cs35l41_fw_type_ctl_put(struct snd_kcontrol *kcontrol,
struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol);

if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) {
- cs35l41->firmware_type = ucontrol->value.enumerated.item[0];
- return 0;
+ if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) {
+ cs35l41->firmware_type = ucontrol->value.enumerated.item[0];
+ return 1;
+ } else {
+ return 0;
+ }
}

return -EINVAL;
--
2.34.1

2023-04-14 15:31:38

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 3/4] ALSA: cs35l41: Fix default regmap values for some registers

Several values do not match the defaults of CS35L41, fix them.

Signed-off-by: Stefan Binding <[email protected]>
---
sound/soc/codecs/cs35l41-lib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c
index 8538e2871c5fa..1e4205295a0de 100644
--- a/sound/soc/codecs/cs35l41-lib.c
+++ b/sound/soc/codecs/cs35l41-lib.c
@@ -46,7 +46,7 @@ static const struct reg_default cs35l41_reg[] = {
{ CS35L41_DSP1_RX5_SRC, 0x00000020 },
{ CS35L41_DSP1_RX6_SRC, 0x00000021 },
{ CS35L41_DSP1_RX7_SRC, 0x0000003A },
- { CS35L41_DSP1_RX8_SRC, 0x00000001 },
+ { CS35L41_DSP1_RX8_SRC, 0x0000003B },
{ CS35L41_NGATE1_SRC, 0x00000008 },
{ CS35L41_NGATE2_SRC, 0x00000009 },
{ CS35L41_AMP_DIG_VOL_CTRL, 0x00008000 },
@@ -58,8 +58,8 @@ static const struct reg_default cs35l41_reg[] = {
{ CS35L41_IRQ1_MASK2, 0xFFFFFFFF },
{ CS35L41_IRQ1_MASK3, 0xFFFF87FF },
{ CS35L41_IRQ1_MASK4, 0xFEFFFFFF },
- { CS35L41_GPIO1_CTRL1, 0xE1000001 },
- { CS35L41_GPIO2_CTRL1, 0xE1000001 },
+ { CS35L41_GPIO1_CTRL1, 0x81000001 },
+ { CS35L41_GPIO2_CTRL1, 0x81000001 },
{ CS35L41_MIXER_NGATE_CFG, 0x00000000 },
{ CS35L41_MIXER_NGATE_CH1_CFG, 0x00000303 },
{ CS35L41_MIXER_NGATE_CH2_CFG, 0x00000303 },
--
2.34.1

2023-04-14 15:31:39

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v1 3/4] ALSA: cs35l41: Fix default regmap values for some registers

On Fri, Apr 14, 2023 at 04:25:51PM +0100, Stefan Binding wrote:
> Several values do not match the defaults of CS35L41, fix them.

Acked-by: Mark Brown <[email protected]>

or can this just be applied separately?


Attachments:
(No filename) (219.00 B)
signature.asc (499.00 B)
Download all attachments

2023-05-23 20:56:11

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH v1 0/4] Fixes and cleanup for CS35L41 HDA

On Fri, 14 Apr 2023 16:25:48 +0100, Stefan Binding wrote:
> Several minor issues were found during additional testing and
> static analysis. These patches fix these minor issues.
>
> Stefan Binding (4):
> ALSA: hda: cs35l41: Clean up Firmware Load Controls
> ALSA: hda: cs35l41: Fix endian conversions
> ALSA: cs35l41: Fix default regmap values for some registers
> ALSA: hda/realtek: Delete cs35l41 component master during free
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[3/4] ALSA: cs35l41: Fix default regmap values for some registers
commit: e2d035f5a7d597bbabc268e236ec6c0408c4af0e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark