Commit 523abd48 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

Merge tag 'asoc-fix-v6.19-rc8' of...

Merge tag 'asoc-fix-v6.19-rc8' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v6.19

A bunch more small fixes here, plus some more of the constant stream of
quirks.   The most notable change here is Richard's change to the cs_dsp
code for the KUnit tests which is relatively large, mostly due to
boilerplate.  The tests were triggering large numbers of error messages
as part of verifying that problems with input data are appropriately
detected which in turn caused runtime issues for the framework due to
the performance impact of pushing the logging out, while the logging is
valuable in normal operation it's basically useless while doing tests
designed to trigger it so rate limiting is an appropriate fix.
parents 124bdc6e f5142487
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ maintainers:
properties:
  compatible:
    enum:
      - ti,tlv320aic23
      - ti,tlv320aic3x
      - ti,tlv320aic33
      - ti,tlv320aic3007
+37 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
 *                         Cirrus Logic International Semiconductor Ltd.
 */

#include <kunit/visibility.h>
#include <linux/cleanup.h>
#include <linux/ctype.h>
#include <linux/debugfs.h>
@@ -24,6 +25,41 @@
#include <linux/firmware/cirrus/cs_dsp.h>
#include <linux/firmware/cirrus/wmfw.h>

#include "cs_dsp.h"

/*
 * When the KUnit test is running the error-case tests will cause a lot
 * of messages. Rate-limit to prevent overflowing the kernel log buffer
 * during KUnit test runs.
 */
#if IS_ENABLED(CONFIG_FW_CS_DSP_KUNIT_TEST)
bool cs_dsp_suppress_err_messages;
EXPORT_SYMBOL_IF_KUNIT(cs_dsp_suppress_err_messages);

bool cs_dsp_suppress_warn_messages;
EXPORT_SYMBOL_IF_KUNIT(cs_dsp_suppress_warn_messages);

bool cs_dsp_suppress_info_messages;
EXPORT_SYMBOL_IF_KUNIT(cs_dsp_suppress_info_messages);

#define cs_dsp_err(_dsp, fmt, ...) \
	do { \
		if (!cs_dsp_suppress_err_messages) \
			dev_err_ratelimited(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__); \
	} while (false)
#define cs_dsp_warn(_dsp, fmt, ...) \
	do { \
		if (!cs_dsp_suppress_warn_messages) \
			dev_warn_ratelimited(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__); \
	} while (false)
#define cs_dsp_info(_dsp, fmt, ...) \
	do { \
		if (!cs_dsp_suppress_info_messages) \
			dev_info_ratelimited(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__); \
	} while (false)
#define cs_dsp_dbg(_dsp, fmt, ...) \
	dev_dbg_ratelimited(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#else
#define cs_dsp_err(_dsp, fmt, ...) \
	dev_err(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define cs_dsp_warn(_dsp, fmt, ...) \
@@ -32,6 +68,7 @@
	dev_info(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define cs_dsp_dbg(_dsp, fmt, ...) \
	dev_dbg(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#endif

#define ADSP1_CONTROL_1                   0x00
#define ADSP1_CONTROL_2                   0x02
+18 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * cs_dsp.h  --  Private header for cs_dsp driver.
 *
 * Copyright (C) 2026 Cirrus Logic, Inc. and
 *                    Cirrus Logic International Semiconductor Ltd.
 */

#ifndef FW_CS_DSP_H
#define FW_CS_DSP_H

#if IS_ENABLED(CONFIG_KUNIT)
extern bool cs_dsp_suppress_err_messages;
extern bool cs_dsp_suppress_warn_messages;
extern bool cs_dsp_suppress_info_messages;
#endif

#endif /* ifndef FW_CS_DSP_H */
+21 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <linux/random.h>
#include <linux/regmap.h>

#include "../cs_dsp.h"

/*
 * Test method is:
 *
@@ -2224,7 +2226,22 @@ static int cs_dsp_bin_test_common_init(struct kunit *test, struct cs_dsp *dsp)
		return ret;

	/* Automatically call cs_dsp_remove() when test case ends */
	return kunit_add_action_or_reset(priv->test, _cs_dsp_remove_wrapper, dsp);
	ret = kunit_add_action_or_reset(priv->test, _cs_dsp_remove_wrapper, dsp);
	if (ret)
		return ret;

	/*
	 * The large number of test cases will cause an unusually large amount
	 * of dev_info() messages from cs_dsp, so suppress these.
	 */
	cs_dsp_suppress_info_messages = true;

	return 0;
}

static void cs_dsp_bin_test_exit(struct kunit *test)
{
	cs_dsp_suppress_info_messages = false;
}

static int cs_dsp_bin_test_halo_init(struct kunit *test)
@@ -2536,18 +2553,21 @@ static struct kunit_case cs_dsp_bin_test_cases_adsp2[] = {
static struct kunit_suite cs_dsp_bin_test_halo = {
	.name = "cs_dsp_bin_halo",
	.init = cs_dsp_bin_test_halo_init,
	.exit = cs_dsp_bin_test_exit,
	.test_cases = cs_dsp_bin_test_cases_halo,
};

static struct kunit_suite cs_dsp_bin_test_adsp2_32bit = {
	.name = "cs_dsp_bin_adsp2_32bit",
	.init = cs_dsp_bin_test_adsp2_32bit_init,
	.exit = cs_dsp_bin_test_exit,
	.test_cases = cs_dsp_bin_test_cases_adsp2,
};

static struct kunit_suite cs_dsp_bin_test_adsp2_16bit = {
	.name = "cs_dsp_bin_adsp2_16bit",
	.init = cs_dsp_bin_test_adsp2_16bit_init,
	.exit = cs_dsp_bin_test_exit,
	.test_cases = cs_dsp_bin_test_cases_adsp2,
};

+18 −6
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include <linux/string.h>
#include <linux/vmalloc.h>

#include "../cs_dsp.h"

KUNIT_DEFINE_ACTION_WRAPPER(_put_device_wrapper, put_device, struct device *);
KUNIT_DEFINE_ACTION_WRAPPER(_cs_dsp_remove_wrapper, cs_dsp_remove, struct cs_dsp *);

@@ -380,11 +382,9 @@ static void bin_block_payload_len_garbage(struct kunit *test)

static void cs_dsp_bin_err_test_exit(struct kunit *test)
{
	/*
	 * Testing error conditions can produce a lot of log output
	 * from cs_dsp error messages, so rate limit the test cases.
	 */
	usleep_range(200, 500);
	cs_dsp_suppress_err_messages = false;
	cs_dsp_suppress_warn_messages = false;
	cs_dsp_suppress_info_messages = false;
}

static int cs_dsp_bin_err_test_common_init(struct kunit *test, struct cs_dsp *dsp,
@@ -474,7 +474,19 @@ static int cs_dsp_bin_err_test_common_init(struct kunit *test, struct cs_dsp *ds
		return ret;

	/* Automatically call cs_dsp_remove() when test case ends */
	return kunit_add_action_or_reset(priv->test, _cs_dsp_remove_wrapper, dsp);
	ret = kunit_add_action_or_reset(priv->test, _cs_dsp_remove_wrapper, dsp);
	if (ret)
		return ret;

	/*
	 * Testing error conditions can produce a lot of log output
	 * from cs_dsp error messages, so suppress messages.
	 */
	cs_dsp_suppress_err_messages = true;
	cs_dsp_suppress_warn_messages = true;
	cs_dsp_suppress_info_messages = true;

	return 0;
}

static int cs_dsp_bin_err_test_halo_init(struct kunit *test)
Loading