Skip to contentSkip to conversation

ASoC: wm_adsp: Some improvements to firmware file search

PATCH In review Richard Fitzgerald 3 participants 20 messages Mar 10 – Mar 18

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: wm_adsp: Some improvements to firmware file search

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

The remaining patches remove duplicated code and clean up some of the implementation.

Richard Fitzgerald (10):
ASoC: wm_adsp: Remove unused argument to
wm_adsp_release_firmware_files()
ASoC: wm_adsp: Add KUnit redirection stubs for firmware file search
ASoC: wm_adsp: Export function for KUnit test to get firmware
filenames
ASoC: wm_adsp: Add kunit test for firmware file search
ASoC: wm_adsp: Remove duplicated code to find firmware file
ASoC: wm_adsp: Use consistent error checks in
wm_adsp_request_firmware_files()
ASoC: wm_adsp: Convert '/' to '-' when normalizing firmware filenames
ASoC: wm_adsp: Add KUnit test cases for '/' in firmware filenames
ASoC: wm_adsp: Use a struct to pass around firmware struct and
filename
ASoC: wm_adsp: Combine some similar code in firmware file search

 sound/soc/codecs/Kconfig                |   14 +-
 sound/soc/codecs/Makefile               |    2 +
 sound/soc/codecs/wm_adsp.c              |  234 +++--
 sound/soc/codecs/wm_adsp.h              |   19 +
 sound/soc/codecs/wm_adsp_fw_find_test.c | 1221 +++++++++++++++++++++++
 5 files changed, 1383 insertions(+), 107 deletions(-)
 create mode 100644 sound/soc/codecs/wm_adsp_fw_find_test.c
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/10 ASoC: wm_adsp: Remove unused argument to wm_adsp_release_firmware_files()

The dsp argument to wm_adsp_release_firmware_files() isn't used so remove it.

---
 sound/soc/codecs/wm_adsp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
sound/soc/codecs/wm_adsp.c +3 -6
index f0aa6e3a1cfa..4b0c53d4f524 100644
@@ -704,8 +704,7 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
 }
 EXPORT_SYMBOL_GPL(wm_adsp_read_ctl);
 
-static void wm_adsp_release_firmware_files(struct wm_adsp *dsp,
-					   const struct firmware *wmfw_firmware,
+static void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
 					   char *wmfw_filename,
 					   const struct firmware *coeff_firmware,
 					   char *coeff_filename)
@@ -908,8 +907,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
 					    coeff_firmware, coeff_filename,
 					    wm_adsp_fw_text[dsp->fw]);
 
-		wm_adsp_release_firmware_files(dsp,
-					       wmfw_firmware, wmfw_filename,
+		wm_adsp_release_firmware_files(wmfw_firmware, wmfw_filename,
 					       coeff_firmware, coeff_filename);
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
@@ -1011,8 +1009,7 @@ int wm_adsp_power_up(struct wm_adsp *dsp, bool load_firmware)
 			      wm_adsp_fw_text[dsp->fw]);
 
 err:
-	wm_adsp_release_firmware_files(dsp,
-				       wmfw_firmware, wmfw_filename,
+	wm_adsp_release_firmware_files(wmfw_firmware, wmfw_filename,
 				       coeff_firmware, coeff_filename);
 
 	return ret;
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/10 ASoC: wm_adsp: Add KUnit redirection stubs for firmware file search

In reply to Richard Fitzgerald

Make some of the firmware file search functions redirectable for KUnit testing.

- The call to firmware_request_nowarn() is factored out into a wrapper function so that it can be redirected.

- wm_adsp_request_firmware_files() and wm_adsp_release_firmware_files() are made visible and exported if KUNIT is enabled.

---
 sound/soc/codecs/wm_adsp.c | 38 ++++++++++++++++++++++++++++----------
 sound/soc/codecs/wm_adsp.h | 15 +++++++++++++++
 2 files changed, 43 insertions(+), 10 deletions(-)
sound/soc/codecs/wm_adsp.c +28 -10
index 4b0c53d4f524..68e00970b8a2 100644
@@ -7,6 +7,8 @@
  * Author: Mark Brown <[email protected]>
  */
 
+#include <kunit/static_stub.h>
+#include <kunit/visibility.h>
 #include <linux/array_size.h>
 #include <linux/cleanup.h>
 #include <linux/ctype.h>
@@ -704,17 +706,32 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
 }
 EXPORT_SYMBOL_GPL(wm_adsp_read_ctl);
 
-static void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
-					   char *wmfw_filename,
-					   const struct firmware *coeff_firmware,
-					   char *coeff_filename)
+VISIBLE_IF_KUNIT void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
+						     char *wmfw_filename,
+						     const struct firmware *coeff_firmware,
+						     char *coeff_filename)
 {
+	KUNIT_STATIC_STUB_REDIRECT(wm_adsp_release_firmware_files,
+				   wmfw_firmware, wmfw_filename,
+				   coeff_firmware, coeff_filename);
+
 	release_firmware(wmfw_firmware);
 	kfree(wmfw_filename);
 
 	release_firmware(coeff_firmware);
 	kfree(coeff_filename);
 }
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_release_firmware_files);
+
+VISIBLE_IF_KUNIT int wm_adsp_firmware_request(const struct firmware **firmware,
+					      const char *filename,
+					      struct device *dev)
+{
+	KUNIT_STATIC_STUB_REDIRECT(wm_adsp_firmware_request, firmware, filename, dev);
+
+	return firmware_request_nowarn(firmware, filename, dev);
+}
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_firmware_request);
 
 static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 					 const struct firmware **firmware, char **filename,
@@ -762,7 +779,7 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		s++;
 	}
 
-	ret = firmware_request_nowarn(firmware, *filename, cs_dsp->dev);
+	ret = wm_adsp_firmware_request(firmware, *filename, cs_dsp->dev);
 	if (ret != 0) {
 		adsp_dbg(dsp, "Failed to request '%s'\n", *filename);
 		kfree(*filename);
@@ -775,11 +792,11 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 }
 
 static const char * const cirrus_dir = "cirrus/";
-static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
-					  const struct firmware **wmfw_firmware,
-					  char **wmfw_filename,
-					  const struct firmware **coeff_firmware,
-					  char **coeff_filename)
+VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
+						    const struct firmware **wmfw_firmware,
+						    char **wmfw_filename,
+						    const struct firmware **coeff_firmware,
+						    char **coeff_filename)
 {
 	const char *system_name = dsp->system_name;
 	const char *suffix = dsp->component->name_prefix;
@@ -856,6 +873,7 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 
 	return -ENOENT;
 }
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_request_firmware_files);
 
 static int wm_adsp_common_init(struct wm_adsp *dsp)
 {
sound/soc/codecs/wm_adsp.h +15 -0
index a9118be793d7..599be409b669 100644
@@ -143,4 +143,19 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name,  int type,
 int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name,  int type,
 		      unsigned int alg, void *buf, size_t len);
 
+#if IS_ENABLED(CONFIG_KUNIT)
+void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
+				    char *wmfw_filename,
+				    const struct firmware *coeff_firmware,
+				    char *coeff_filename);
+int wm_adsp_firmware_request(const struct firmware **firmware,
+			     const char *filename,
+			     struct device *dev);
+int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
+				   const struct firmware **wmfw_firmware,
+				   char **wmfw_filename,
+				   const struct firmware **coeff_firmware,
+				   char **coeff_filename);
+#endif
+
 #endif
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/10 ASoC: wm_adsp: Export function for KUnit test to get firmware filenames

In reply to Richard Fitzgerald

Export a function that KUnit tests can use to get the firmware filenames from the wm_adsp_fw[] array.

---
 sound/soc/codecs/wm_adsp.c | 11 +++++++++++
 sound/soc/codecs/wm_adsp.h |  1 +
 2 files changed, 12 insertions(+)
sound/soc/codecs/wm_adsp.c +11 -0
index 68e00970b8a2..79695ead5788 100644
@@ -318,6 +318,17 @@ struct wm_coeff_ctl {
 	struct work_struct work;
 };
 
+#if IS_ENABLED(CONFIG_KUNIT)
+const char *wm_adsp_get_fwf_name_by_index(int index)
+{
+	if (index < ARRAY_SIZE(wm_adsp_fw))
+		return wm_adsp_fw[index].file;
+
+	return NULL;
+}
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_get_fwf_name_by_index);
+#endif
+
 int wm_adsp_fw_get(struct snd_kcontrol *kcontrol,
 		   struct snd_ctl_elem_value *ucontrol)
 {
sound/soc/codecs/wm_adsp.h +1 -0
index 599be409b669..b4d5bd321c0b 100644
@@ -144,6 +144,7 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name,  int type,
 		      unsigned int alg, void *buf, size_t len);
 
 #if IS_ENABLED(CONFIG_KUNIT)
+const char *wm_adsp_get_fwf_name_by_index(int index);
 void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
 				    char *wmfw_filename,
 				    const struct firmware *coeff_firmware,
Signature · 1 line
2.47.3
#4 lore raw

PATCH 4/10 ASoC: wm_adsp: Add kunit test for firmware file search

In reply to Richard Fitzgerald

Add KUnit testing of the wm_adsp code that searches for firmware files. Also make the SND_SOC_WM_ADSP Kconfig symbol visible if KUNIT is enabled so that wm_adsp can be manually included for KUnit testing.

The firmware filename is composed of several fields, some of which are optional, and there is a search algorithm to fallback from specific to generic versions of firmware for a device. This KUnit test verifies that wm_adsp is searching for the correct sequence of filenames.

The are two ways of testing this, and both are used in this KUnit test.

1. Trap the calls to firmware_request_nowarn() and test that the sequence of filenames request is correct.

This is the most thorough test because it proves that exactly the expected filenames are requested, in the correct order.

But it doesn't fully cover regression testing. If a change to the search algorithm changes the expected sequence of requested files, the test must also be changed to expect that new sequence. If the expectation is wrong, the tests can pass (because the search order is as expected) while picking a different file in some cases from what it did before the change.

2. Test which file is picked from a simulated directory of files.

This is better for regression testing because it is independent of the search algorithm. It does not need to change if the search algorithm changes. It is not testing exactly which files the algorithm searches for, only which file it eventually picks from a given set of available files.

In other words, the regression test is: does it still pick the same file from the same directory of files?

But it is impractical for thorough testing. It doesn't prove that exactly the correct files were searched for, unless it was to test with every possible combination of file names and directory content that could ever exist. Clearly this is impossible to implement, since the number of combations of possible valid filenames in a directory and number of files in a directory is astronomically large.

---
 sound/soc/codecs/Kconfig                |   14 +-
 sound/soc/codecs/Makefile               |    2 +
 sound/soc/codecs/wm_adsp_fw_find_test.c | 1223 +++++++++++++++++++++++
 3 files changed, 1238 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/codecs/wm_adsp_fw_find_test.c
sound/soc/codecs/Kconfig +13 -1
index adb3fb923be3..f9e6a83e55c6 100644
@@ -398,7 +398,7 @@ config SND_SOC_WM_HUBS
 	default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
 
 config SND_SOC_WM_ADSP
-	tristate
+	tristate "Cirrus Logic wm_adsp driver" if KUNIT
 	select FW_CS_DSP
 	select SND_SOC_COMPRESS
 	default y if SND_SOC_MADERA=y
@@ -424,6 +424,18 @@ config SND_SOC_WM_ADSP
 	default m if SND_SOC_CS35L56=m
 	default m if SND_SOC_CS48L32=m
 
+config SND_SOC_WM_ADSP_TEST
+	tristate "KUnit tests for Cirrus Logic wm_adsp" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	depends on SND_SOC_WM_ADSP
+	default KUNIT_ALL_TESTS
+	help
+	  This builds KUnit tests for the Cirrus Logic wm_adsp library.
+	  For more information on KUnit and unit tests in general,
+	  please refer to the KUnit documentation in
+	  Documentation/dev-tools/kunit/.
+	  If in doubt, say "N".
+
 config SND_SOC_AB8500_CODEC
 	tristate
 	depends on ABX500_CORE
sound/soc/codecs/Makefile +2 -0
index 3ddee5298721..172861d17cfd 100644
@@ -361,6 +361,7 @@ snd-soc-wcd938x-sdw-y := wcd938x-sdw.o
 snd-soc-wcd939x-y := wcd939x.o
 snd-soc-wcd939x-sdw-y := wcd939x-sdw.o
 snd-soc-wm-adsp-y := wm_adsp.o
+snd-soc-wm-adsp-test-y := wm_adsp_fw_find_test.o
 snd-soc-wm0010-y := wm0010.o
 snd-soc-wm1250-ev1-y := wm1250-ev1.o
 snd-soc-wm2000-y := wm2000.o
@@ -862,6 +863,7 @@ obj-$(CONFIG_SND_SOC_WM9705)	+= snd-soc-wm9705.o
 obj-$(CONFIG_SND_SOC_WM9712)	+= snd-soc-wm9712.o
 obj-$(CONFIG_SND_SOC_WM9713)	+= snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_WM_ADSP)	+= snd-soc-wm-adsp.o
+obj-$(CONFIG_SND_SOC_WM_ADSP_TEST)	+= snd-soc-wm-adsp-test.o
 obj-$(CONFIG_SND_SOC_WM_HUBS)	+= snd-soc-wm-hubs.o
 obj-$(CONFIG_SND_SOC_WSA881X)	+= snd-soc-wsa881x.o
 obj-$(CONFIG_SND_SOC_WSA883X)	+= snd-soc-wsa883x.o
sound/soc/codecs/wm_adsp_fw_find_test.c new file +1223 -0

1,223 lines not on this page · raw message

Signature · 1 line
2.47.3
#5 lore raw

PATCH 5/10 ASoC: wm_adsp: Remove duplicated code to find firmware file

In reply to Richard Fitzgerald

The 3rd search case in wm_adsp_request_firmware_files() does exactly the same bin file searches as the case immediately above it. Merge the conditional from the 3rd case into the second case so the duplicated code can be removed.

---
 sound/soc/codecs/wm_adsp.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)
sound/soc/codecs/wm_adsp.c +7 -20
index 79695ead5788..b904d1e1b00c 100644
@@ -828,9 +828,10 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 	}
 
 	if (system_name) {
-		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
-						   cirrus_dir, system_name,
-						   NULL, "wmfw")) {
+		ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						    cirrus_dir, system_name,
+						    NULL, "wmfw");
+		if (!ret || dsp->wmfw_optional) {
 			if (suffix)
 				wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
 							      cirrus_dir, system_name,
@@ -840,26 +841,12 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 				wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
 							      cirrus_dir, system_name,
 							      NULL, "bin");
-			return 0;
+
+			if (*wmfw_firmware || (dsp->wmfw_optional && *coeff_firmware))
+				return 0;
 		}
 	}
 
-	/* Check system-specific bin without wmfw before falling back to generic */
-	if (dsp->wmfw_optional && system_name) {
-		if (suffix)
-			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-						      cirrus_dir, system_name,
-						      suffix, "bin");
-
-		if (!*coeff_firmware)
-			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-						      cirrus_dir, system_name,
-						      NULL, "bin");
-
-		if (*coeff_firmware)
-			return 0;
-	}
-
 	/* Check legacy location */
 	if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
 					   "", NULL, NULL, "wmfw")) {
Signature · 1 line
2.47.3
#6 lore raw

PATCH 6/10 ASoC: wm_adsp: Use consistent error checks in wm_adsp_request_firmware_files()

In reply to Richard Fitzgerald

Use a consistent pattern of error checking in
wm_adsp_request_firmware_files().

- The integer return value of wm_adsp_request_firmware_file() reports unrecoverable errors, for example -ENOMEM.

- A NULL struct firmware pointer is a valid result. This not an error, not all DSPs require both files, some may not require any files.

Previously wm_adsp_request_firmware_files() was using a mix of checking the return value and checking the struct firmware pointer to determine whether a file was found. It wasn't checking for unrecoverable errors.

---
 sound/soc/codecs/wm_adsp.c | 92 +++++++++++++++++++++++++++-----------
 1 file changed, 65 insertions(+), 27 deletions(-)
sound/soc/codecs/wm_adsp.c +65 -27
index b904d1e1b00c..69e573507df3 100644
@@ -753,7 +753,7 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 	struct cs_dsp *cs_dsp = &dsp->cs_dsp;
 	const char *fwf;
 	char *s, c;
-	int ret = 0;
+	int ret;
 
 	if (dsp->fwf_name)
 		fwf = dsp->fwf_name;
@@ -791,15 +791,17 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 	}
 
 	ret = wm_adsp_firmware_request(firmware, *filename, cs_dsp->dev);
-	if (ret != 0) {
-		adsp_dbg(dsp, "Failed to request '%s'\n", *filename);
+	if (ret < 0) {
+		adsp_dbg(dsp, "Failed to request '%s': %d\n", *filename, ret);
 		kfree(*filename);
 		*filename = NULL;
+		if (ret != -ENOENT)
+			return ret;
 	} else {
 		adsp_dbg(dsp, "Found '%s'\n", *filename);
 	}
 
-	return ret;
+	return 0;
 }
 
 static const char * const cirrus_dir = "cirrus/";
@@ -817,12 +819,19 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 		suffix = dsp->fwf_suffix;
 
 	if (system_name && suffix) {
-		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
-						   cirrus_dir, system_name,
-						   suffix, "wmfw")) {
-			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-						      cirrus_dir, system_name,
-						      suffix, "bin");
+		ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						    cirrus_dir, system_name,
+						    suffix, "wmfw");
+		if (ret < 0)
+			goto err;
+
+		if (*wmfw_firmware) {
+			ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							    cirrus_dir, system_name,
+							    suffix, "bin");
+			if (ret < 0)
+				goto err;
+
 			return 0;
 		}
 	}
@@ -831,16 +840,27 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 		ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
 						    cirrus_dir, system_name,
 						    NULL, "wmfw");
-		if (!ret || dsp->wmfw_optional) {
-			if (suffix)
-				wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-							      cirrus_dir, system_name,
-							      suffix, "bin");
+		if (ret < 0)
+			goto err;
 
-			if (!*coeff_firmware)
-				wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-							      cirrus_dir, system_name,
-							      NULL, "bin");
+		if (*wmfw_firmware || dsp->wmfw_optional) {
+			if (suffix) {
+				ret = wm_adsp_request_firmware_file(dsp,
+								    coeff_firmware, coeff_filename,
+								    cirrus_dir, system_name,
+								    suffix, "bin");
+				if (ret < 0)
+					goto err;
+			}
+
+			if (!*coeff_firmware) {
+				ret = wm_adsp_request_firmware_file(dsp,
+								    coeff_firmware, coeff_filename,
+								    cirrus_dir, system_name,
+								    NULL, "bin");
+				if (ret < 0)
+					goto err;
+			}
 
 			if (*wmfw_firmware || (dsp->wmfw_optional && *coeff_firmware))
 				return 0;
@@ -848,19 +868,32 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 	}
 
 	/* Check legacy location */
-	if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
-					   "", NULL, NULL, "wmfw")) {
-		wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-					      "", NULL, NULL, "bin");
+	ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+					    "", NULL, NULL, "wmfw");
+	if (ret < 0)
+		goto err;
+
+	if (*wmfw_firmware) {
+		ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+						    "", NULL, NULL, "bin");
+		if (ret < 0)
+			goto err;
+
 		return 0;
 	}
 
 	/* Fall back to generic wmfw and optional matching bin */
 	ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
 					    cirrus_dir, NULL, NULL, "wmfw");
-	if (!ret || dsp->wmfw_optional) {
-		wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-					      cirrus_dir, NULL, NULL, "bin");
+	if (ret < 0)
+		goto err;
+
+	if (*wmfw_firmware || dsp->wmfw_optional) {
+		ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+						    cirrus_dir, NULL, NULL, "bin");
+		if (ret < 0)
+			goto err;
+
 		return 0;
 	}
 
@@ -869,7 +902,12 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 		 dsp->fwf_name ? dsp->fwf_name : dsp->cs_dsp.name,
 		 wm_adsp_fw[dsp->fw].file, system_name, suffix);
 
-	return -ENOENT;
+	ret = -ENOENT;
+err:
+	wm_adsp_release_firmware_files(*wmfw_firmware, *wmfw_filename,
+				       *coeff_firmware, *coeff_filename);
+
+	return ret;
 }
 EXPORT_SYMBOL_IF_KUNIT(wm_adsp_request_firmware_files);
 
Signature · 1 line
2.47.3
#7 lore raw

PATCH 7/10 ASoC: wm_adsp: Convert '/' to '-' when normalizing firmware filenames

In reply to Richard Fitzgerald

Don't preserve '/' in firmware filename fields - convert it to '-' like other punctuation characters.

The code originally normalized the entire string, including the directory prefix. To prevent breaking the directory it had to preserve '/' characters in the name, but this meant that the system name and ALSA prefix must not contain those characters.

It's trivial to skip the directory name prefix and start the normalization after it, and that means the normalization does not need to make a special case for '/'.

---
 sound/soc/codecs/wm_adsp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/soc/codecs/wm_adsp.c +4 -5
index 69e573507df3..034766760c86 100644
@@ -776,16 +776,15 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		return -ENOMEM;
 
 	/*
-	 * Make sure that filename is lower-case and any non alpha-numeric
-	 * characters except full stop and forward slash are replaced with
-	 * hyphens.
+	 * Make sure that filename after dir is lower-case and any non-alpha-numeric
+	 * characters except full-stop are replaced with hyphens.
 	 */
-	s = *filename;
+	s = *filename + strlen(dir);
 	while (*s) {
 		c = *s;
 		if (isalnum(c))
 			*s = tolower(c);
-		else if ((c != '.') && (c != '/'))
+		else if (c != '.')
 			*s = '-';
 		s++;
 	}
Signature · 1 line
2.47.3
#8 lore raw

PATCH 8/10 ASoC: wm_adsp: Add KUnit test cases for '/' in firmware filenames

In reply to Richard Fitzgerald

Add test cases that '/' in the system name or ALSA prefix are converted to '-' in the firmware filename.

---
 sound/soc/codecs/wm_adsp_fw_find_test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/soc/codecs/wm_adsp_fw_find_test.c +15 -0
index 556221d38a50..11047851fd80 100644
@@ -949,6 +949,13 @@ static const struct wm_adsp_fw_find_test_params wm_adsp_fw_find_normalization_ca
 			"cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw "
 			"cirrus/cs1234-dsp1-mbc-vss-vendor-device.bin",
 	},
+	{
+		.part = "cs1234", .dsp_name = "dsp1", .system_name = "Vendor/Device",
+		.expect_wmfw = "cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw",
+		.expected_searches =
+			"cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw "
+			"cirrus/cs1234-dsp1-mbc-vss-vendor-device.bin",
+	},
 	{
 		.part = "cs1234", .dsp_name = "dsp1", .system_name = "1234:56AB",
 		.expect_wmfw = "cirrus/cs1234-dsp1-mbc-vss-1234-56ab.wmfw",
@@ -997,6 +1004,14 @@ static const struct wm_adsp_fw_find_test_params wm_adsp_fw_find_normalization_ca
 			"cirrus/cs1234-dsp1-mbc-vss-abc-cs1234.1.wmfw "
 			"cirrus/cs1234-dsp1-mbc-vss-abc-cs1234.1.bin",
 	},
+	{
+		.part = "cs1234", .dsp_name = "dsp1", .system_name = "abc",
+		.alsa_name = "Spk/Jack",
+		.expect_wmfw = "cirrus/cs1234-dsp1-mbc-vss-abc-spk-jack.wmfw",
+		.expected_searches =
+			"cirrus/cs1234-dsp1-mbc-vss-abc-spk-jack.wmfw "
+			"cirrus/cs1234-dsp1-mbc-vss-abc-spk-jack.bin",
+	},
 };
 KUNIT_ARRAY_PARAM(wm_adsp_fw_find_normalization,
 		  wm_adsp_fw_find_normalization_cases,
Signature · 1 line
2.47.3
#9 lore raw

PATCH 9/10 ASoC: wm_adsp: Use a struct to pass around firmware struct and filename

In reply to Richard Fitzgerald

Bundle the pointers to struct firmware and its filename into a new struct wm_adsp_fw_files. This simplifies passing these pointers around.

Changes are also needed to the test cases in wm_adsp_fw_find_test.c that use this API.

---
 sound/soc/codecs/wm_adsp.c              | 123 ++++++++++--------------
 sound/soc/codecs/wm_adsp.h              |  21 ++--
 sound/soc/codecs/wm_adsp_fw_find_test.c |  47 +++------
 3 files changed, 77 insertions(+), 114 deletions(-)
sound/soc/codecs/wm_adsp.c +50 -73
index 034766760c86..1c480d59bd55 100644
@@ -717,20 +717,15 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
 }
 EXPORT_SYMBOL_GPL(wm_adsp_read_ctl);
 
-VISIBLE_IF_KUNIT void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
-						     char *wmfw_filename,
-						     const struct firmware *coeff_firmware,
-						     char *coeff_filename)
+VISIBLE_IF_KUNIT void wm_adsp_release_firmware_files(struct wm_adsp_fw_files *fw)
 {
-	KUNIT_STATIC_STUB_REDIRECT(wm_adsp_release_firmware_files,
-				   wmfw_firmware, wmfw_filename,
-				   coeff_firmware, coeff_filename);
+	KUNIT_STATIC_STUB_REDIRECT(wm_adsp_release_firmware_files, fw);
 
-	release_firmware(wmfw_firmware);
-	kfree(wmfw_filename);
+	release_firmware(fw->wmfw.firmware);
+	kfree(fw->wmfw.filename);
 
-	release_firmware(coeff_firmware);
-	kfree(coeff_filename);
+	release_firmware(fw->coeff.firmware);
+	kfree(fw->coeff.filename);
 }
 EXPORT_SYMBOL_IF_KUNIT(wm_adsp_release_firmware_files);
 
@@ -745,7 +740,7 @@ VISIBLE_IF_KUNIT int wm_adsp_firmware_request(const struct firmware **firmware,
 EXPORT_SYMBOL_IF_KUNIT(wm_adsp_firmware_request);
 
 static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
-					 const struct firmware **firmware, char **filename,
+					 struct wm_adsp_fw_file *fw,
 					 const char *dir, const char *system_name,
 					 const char *asoc_component_prefix,
 					 const char *filetype)
@@ -761,25 +756,25 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		fwf = dsp->cs_dsp.name;
 
 	if (system_name && asoc_component_prefix)
-		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-%s.%s", dir, dsp->part,
-				      fwf, wm_adsp_fw[dsp->fw].file, system_name,
-				      asoc_component_prefix, filetype);
+		fw->filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-%s.%s", dir, dsp->part,
+					 fwf, wm_adsp_fw[dsp->fw].file, system_name,
+					 asoc_component_prefix, filetype);
 	else if (system_name)
-		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
-				      fwf, wm_adsp_fw[dsp->fw].file, system_name,
-				      filetype);
+		fw->filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+					 fwf, wm_adsp_fw[dsp->fw].file, system_name,
+					 filetype);
 	else
-		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, fwf,
-				      wm_adsp_fw[dsp->fw].file, filetype);
+		fw->filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, fwf,
+					 wm_adsp_fw[dsp->fw].file, filetype);
 
-	if (*filename == NULL)
+	if (!fw->filename)
 		return -ENOMEM;
 
 	/*
 	 * Make sure that filename after dir is lower-case and any non-alpha-numeric
 	 * characters except full-stop are replaced with hyphens.
 	 */
-	s = *filename + strlen(dir);
+	s = fw->filename + strlen(dir);
 	while (*s) {
 		c = *s;
 		if (isalnum(c))
@@ -789,15 +784,15 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		s++;
 	}
 
-	ret = wm_adsp_firmware_request(firmware, *filename, cs_dsp->dev);
+	ret = wm_adsp_firmware_request(&fw->firmware, fw->filename, cs_dsp->dev);
 	if (ret < 0) {
-		adsp_dbg(dsp, "Failed to request '%s': %d\n", *filename, ret);
-		kfree(*filename);
-		*filename = NULL;
+		adsp_dbg(dsp, "Failed to request '%s': %d\n", fw->filename, ret);
+		kfree(fw->filename);
+		fw->filename = NULL;
 		if (ret != -ENOENT)
 			return ret;
 	} else {
-		adsp_dbg(dsp, "Found '%s'\n", *filename);
+		adsp_dbg(dsp, "Found '%s'\n", fw->filename);
 	}
 
 	return 0;
@@ -805,10 +800,7 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 
 static const char * const cirrus_dir = "cirrus/";
 VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
-						    const struct firmware **wmfw_firmware,
-						    char **wmfw_filename,
-						    const struct firmware **coeff_firmware,
-						    char **coeff_filename)
+						    struct wm_adsp_fw_files *fw)
 {
 	const char *system_name = dsp->system_name;
 	const char *suffix = dsp->component->name_prefix;
@@ -818,14 +810,14 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 		suffix = dsp->fwf_suffix;
 
 	if (system_name && suffix) {
-		ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+		ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
 						    cirrus_dir, system_name,
 						    suffix, "wmfw");
 		if (ret < 0)
 			goto err;
 
-		if (*wmfw_firmware) {
-			ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+		if (fw->wmfw.firmware) {
+			ret = wm_adsp_request_firmware_file(dsp, &fw->coeff,
 							    cirrus_dir, system_name,
 							    suffix, "bin");
 			if (ret < 0)
@@ -836,45 +828,43 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 	}
 
 	if (system_name) {
-		ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+		ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
 						    cirrus_dir, system_name,
 						    NULL, "wmfw");
 		if (ret < 0)
 			goto err;
 
-		if (*wmfw_firmware || dsp->wmfw_optional) {
+		if (fw->wmfw.firmware || dsp->wmfw_optional) {
 			if (suffix) {
 				ret = wm_adsp_request_firmware_file(dsp,
-								    coeff_firmware, coeff_filename,
+								    &fw->coeff,
 								    cirrus_dir, system_name,
 								    suffix, "bin");
 				if (ret < 0)
 					goto err;
 			}
 
-			if (!*coeff_firmware) {
+			if (!fw->coeff.firmware) {
 				ret = wm_adsp_request_firmware_file(dsp,
-								    coeff_firmware, coeff_filename,
+								    &fw->coeff,
 								    cirrus_dir, system_name,
 								    NULL, "bin");
 				if (ret < 0)
 					goto err;
 			}
 
-			if (*wmfw_firmware || (dsp->wmfw_optional && *coeff_firmware))
+			if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
 				return 0;
 		}
 	}
 
 	/* Check legacy location */
-	ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
-					    "", NULL, NULL, "wmfw");
+	ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw, "", NULL, NULL, "wmfw");
 	if (ret < 0)
 		goto err;
 
-	if (*wmfw_firmware) {
-		ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
-						    "", NULL, NULL, "bin");
+	if (fw->wmfw.firmware) {
+		ret = wm_adsp_request_firmware_file(dsp, &fw->coeff, "", NULL, NULL, "bin");
 		if (ret < 0)
 			goto err;
 
@@ -882,13 +872,13 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 	}
 
 	/* Fall back to generic wmfw and optional matching bin */
-	ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+	ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
 					    cirrus_dir, NULL, NULL, "wmfw");
 	if (ret < 0)
 		goto err;
 
-	if (*wmfw_firmware || dsp->wmfw_optional) {
-		ret = wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+	if (fw->wmfw.firmware || dsp->wmfw_optional) {
+		ret = wm_adsp_request_firmware_file(dsp, &fw->coeff,
 						    cirrus_dir, NULL, NULL, "bin");
 		if (ret < 0)
 			goto err;
@@ -903,8 +893,7 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 
 	ret = -ENOENT;
 err:
-	wm_adsp_release_firmware_files(*wmfw_firmware, *wmfw_filename,
-				       *coeff_firmware, *coeff_filename);
+	wm_adsp_release_firmware_files(fw);
 
 	return ret;
 }
@@ -939,29 +928,23 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
 	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 	struct wm_adsp *dsps = snd_soc_component_get_drvdata(component);
 	struct wm_adsp *dsp = &dsps[w->shift];
+	struct wm_adsp_fw_files fw = { 0 };
 	int ret = 0;
-	char *wmfw_filename = NULL;
-	const struct firmware *wmfw_firmware = NULL;
-	char *coeff_filename = NULL;
-	const struct firmware *coeff_firmware = NULL;
 
 	dsp->component = component;
 
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
-		ret = wm_adsp_request_firmware_files(dsp,
-						     &wmfw_firmware, &wmfw_filename,
-						     &coeff_firmware, &coeff_filename);
+		ret = wm_adsp_request_firmware_files(dsp, &fw);
 		if (ret)
 			break;
 
 		ret = cs_dsp_adsp1_power_up(&dsp->cs_dsp,
-					    wmfw_firmware, wmfw_filename,
-					    coeff_firmware, coeff_filename,
+					    fw.wmfw.firmware, fw.wmfw.filename,
+					    fw.coeff.firmware, fw.coeff.filename,
 					    wm_adsp_fw_text[dsp->fw]);
 
-		wm_adsp_release_firmware_files(wmfw_firmware, wmfw_filename,
-					       coeff_firmware, coeff_filename);
+		wm_adsp_release_firmware_files(&fw);
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
 		cs_dsp_adsp1_power_down(&dsp->cs_dsp);
@@ -1037,33 +1020,27 @@ EXPORT_SYMBOL_GPL(wm_adsp2_preloader_put);
 
 int wm_adsp_power_up(struct wm_adsp *dsp, bool load_firmware)
 {
+	struct wm_adsp_fw_files fw = { 0 };
 	int ret = 0;
-	char *wmfw_filename = NULL;
-	const struct firmware *wmfw_firmware = NULL;
-	char *coeff_filename = NULL;
-	const struct firmware *coeff_firmware = NULL;
 
 	if (load_firmware) {
-		ret = wm_adsp_request_firmware_files(dsp,
-						     &wmfw_firmware, &wmfw_filename,
-						     &coeff_firmware, &coeff_filename);
+		ret = wm_adsp_request_firmware_files(dsp, &fw);
 		if (ret)
 			return ret;
 	}
 
-	if (dsp->bin_mandatory && !coeff_firmware) {
+	if (dsp->bin_mandatory && !fw.coeff.firmware) {
 		ret = -ENOENT;
 		goto err;
 	}
 
 	ret = cs_dsp_power_up(&dsp->cs_dsp,
-			      wmfw_firmware, wmfw_filename,
-			      coeff_firmware, coeff_filename,
+			      fw.wmfw.firmware, fw.wmfw.filename,
+			      fw.coeff.firmware, fw.coeff.filename,
 			      wm_adsp_fw_text[dsp->fw]);
 
 err:
-	wm_adsp_release_firmware_files(wmfw_firmware, wmfw_filename,
-				       coeff_firmware, coeff_filename);
+	wm_adsp_release_firmware_files(&fw);
 
 	return ret;
 }
sound/soc/codecs/wm_adsp.h +12 -9
index b4d5bd321c0b..8922732479c2 100644
@@ -79,6 +79,16 @@ struct wm_adsp {
 	SOC_ENUM_EXT(dspname " Firmware", wm_adsp_fw_enum[num], \
 		     wm_adsp_fw_get, wm_adsp_fw_put)
 
+struct wm_adsp_fw_file {
+	const struct firmware *firmware;
+	char *filename;
+};
+
+struct wm_adsp_fw_files {
+	struct wm_adsp_fw_file wmfw;
+	struct wm_adsp_fw_file coeff;
+};
+
 extern const struct soc_enum wm_adsp_fw_enum[];
 
 int wm_adsp1_init(struct wm_adsp *dsp);
@@ -145,18 +155,11 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name,  int type,
 
 #if IS_ENABLED(CONFIG_KUNIT)
 const char *wm_adsp_get_fwf_name_by_index(int index);
-void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
-				    char *wmfw_filename,
-				    const struct firmware *coeff_firmware,
-				    char *coeff_filename);
+void wm_adsp_release_firmware_files(struct wm_adsp_fw_files *fw);
 int wm_adsp_firmware_request(const struct firmware **firmware,
 			     const char *filename,
 			     struct device *dev);
-int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
-				   const struct firmware **wmfw_firmware,
-				   char **wmfw_filename,
-				   const struct firmware **coeff_firmware,
-				   char **coeff_filename);
+int wm_adsp_request_firmware_files(struct wm_adsp *dsp, struct wm_adsp_fw_files *fw);
 #endif
 
 #endif
sound/soc/codecs/wm_adsp_fw_find_test.c +15 -32

100 lines not on this page · raw message

Signature · 1 line
2.47.3
#10 lore raw

PATCH 10/10 ASoC: wm_adsp: Combine some similar code in firmware file search

In reply to Richard Fitzgerald

In wm_adsp_request_firmware_files() squash the if (system_name && suffix) and the following if (system_name) blocks together. This removes some duplicated code.

---
 sound/soc/codecs/wm_adsp.c | 49 +++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 27 deletions(-)
sound/soc/codecs/wm_adsp.c +22 -27
index 1c480d59bd55..a637e22c3929 100644
@@ -804,47 +804,42 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 {
 	const char *system_name = dsp->system_name;
 	const char *suffix = dsp->component->name_prefix;
+	bool require_bin_suffix = false;
 	int ret = 0;
 
 	if (dsp->fwf_suffix)
 		suffix = dsp->fwf_suffix;
 
-	if (system_name && suffix) {
+	if (system_name) {
 		ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
 						    cirrus_dir, system_name,
 						    suffix, "wmfw");
 		if (ret < 0)
 			goto err;
 
-		if (fw->wmfw.firmware) {
+		if (suffix) {
+			if (fw->wmfw.firmware) {
+				require_bin_suffix = true;
+			} else {
+				/* Fallback to name without suffix */
+				ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
+								    cirrus_dir, system_name,
+								    NULL, "wmfw");
+				if (ret < 0)
+					goto err;
+			}
+		}
+
+		/* Look for matching .bin file */
+		if (fw->wmfw.firmware || dsp->wmfw_optional) {
 			ret = wm_adsp_request_firmware_file(dsp, &fw->coeff,
 							    cirrus_dir, system_name,
 							    suffix, "bin");
 			if (ret < 0)
 				goto err;
 
-			return 0;
-		}
-	}
-
-	if (system_name) {
-		ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
-						    cirrus_dir, system_name,
-						    NULL, "wmfw");
-		if (ret < 0)
-			goto err;
-
-		if (fw->wmfw.firmware || dsp->wmfw_optional) {
-			if (suffix) {
-				ret = wm_adsp_request_firmware_file(dsp,
-								    &fw->coeff,
-								    cirrus_dir, system_name,
-								    suffix, "bin");
-				if (ret < 0)
-					goto err;
-			}
-
-			if (!fw->coeff.firmware) {
+			if (suffix && !fw->coeff.firmware && !require_bin_suffix) {
+				/* Fallback to name without suffix */
 				ret = wm_adsp_request_firmware_file(dsp,
 								    &fw->coeff,
 								    cirrus_dir, system_name,
@@ -852,10 +847,10 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 				if (ret < 0)
 					goto err;
 			}
-
-			if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
-				return 0;
 		}
+
+		if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
+			return 0;
 	}
 
 	/* Check legacy location */
Signature · 1 line
2.47.3
maintainer
#11 lore raw
In reply to Richard Fitzgerald
Quoted 10 lines · Richard Fitzgerald

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

[...]

Applied to

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

Thanks!

[01/10] ASoC: wm_adsp: Remove unused argument to wm_adsp_release_firmware_files()

        commit: 1eadb7791ee5699ca58920ef705ce0934c814ece
[02/10] ASoC: wm_adsp: Add KUnit redirection stubs for firmware file search
        commit: 70057cfe492d600c2b83598e8b8b64780b2ca147
[03/10] ASoC: wm_adsp: Export function for KUnit test to get firmware filenames
        commit: b4e6b01191afb9516570437a7aff61019134fd59
[04/10] ASoC: wm_adsp: Add kunit test for firmware file search
        commit: bf2d44d07de726b0393439cb4d4defc5cf89a4fc
[05/10] ASoC: wm_adsp: Remove duplicated code to find firmware file
        commit: 2c7c27025374abbdeda201ad103ddf27e8079aec
[06/10] ASoC: wm_adsp: Use consistent error checks in wm_adsp_request_firmware_files()
        commit: f8f0c68c75214e326c0d4cbcab8ecab882201f48
[07/10] ASoC: wm_adsp: Convert '/' to '-' when normalizing firmware filenames
        commit: 66170cc7ed59fb7e1e192e53f1d690bd04e8c720
[08/10] ASoC: wm_adsp: Add KUnit test cases for '/' in firmware filenames
        commit: d8a4c96082e6f5c7aaf6f3e101effe7ff0ea4d6e
[09/10] ASoC: wm_adsp: Use a struct to pass around firmware struct and filename
        commit: 7bca3ca55ef53ca66fdf6e663290d0596a8f520d
[10/10] ASoC: wm_adsp: Combine some similar code in firmware file search
        commit: 8fc5c7895185d1119ae76b509892a1d14e0bd483

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

maintainer
#12 lore raw
In reply to Richard Fitzgerald
Quoted 11 lines · Richard Fitzgerald

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

The remaining patches remove duplicated code and clean up some of the implementation.

Actually I'm seeing failures with this running on arm64, they were missed by my testing due to issues with KUnit in -rc1, looking at this clearly a lot of the problems are knock on results of an initial failure:

[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name:ao system:ABC123 alsa_name:amp1 expects:( )
[14:52:36] [PASSED] cs1234 dsp1 fwf_name:ao system:ABC123 alsa_name:amp1 wmfw_optional expects:( )
[14:52:36] ======== [PASSED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc123-amp1.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123-amp1.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc123-amp1.wmfw cirrus/cs1234-dsp1-mbc [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123-amp1.wmfw cirrus/cs [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234-dsp1-mbc-vss- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234-dsp1-mbc-vss- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss-abc123-amp1.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss-abc123.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mb [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name:amp1 wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Unable to handle kernel paging request at virtual address ffffffffc202b0c8
[14:52:36] Mem abort info:

[14:52:36]   ESR = 0x0000000096000006
[14:52:36]   EC = 0x25: DABT (current EL), IL = 32 bits
[14:52:36]   SET = 0, FnV = 0
[14:52:36]   EA = 0, S1PTW = 0
[14:52:36]   FSC = 0x06: level 2 translation fault
[14:52:36] Data abort info:
[14:52:36]   ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000
[14:52:36]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[14:52:36]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0

[14:52:36] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000040e95000
[14:52:36] [ffffffffc202b0c8] pgd=0000000000000000, p4d=0000000041103403, pud=0000000041104403, pmd=0000000000000000 [14:52:36] Internal error: Oops: 0000000096000006 [#2] SMP
[14:52:36] CPU: 0 UID: 0 PID: 11523 Comm: kunit_try_catch Tainted: G D W N 7.0.0-rc3-ga7ea17ac86d4 #11 PREEMPTLAZY
[14:52:36] Tainted: [D]=DIE, [W]=WARN, [N]=TEST
[14:52:36] Hardware name: linux,dummy-virt (DT)
[14:52:36] pstate: a3400005 (NzCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
[14:52:36] pc : kfree+0x38/0x2a0
[14:52:36] lr : release_firmware+0x28/0x6c
[14:52:36] sp : ffff80008348bda0
[14:52:36] x29: ffff80008348bda0 x28: 0000000000000000 x27: 0000000000000000
[14:52:36] x26: 0000000000000000 x25: 0000000000000000 x24: ffff800080fbb850
[14:52:36] x23: ffff8000803e9e80 x22: ffff800080fbb680 x21: ffff000006923b40
[14:52:36] x20: ffff800080ac3010 x19: ffffffffc202b0c0 x18: 0000000000000014
[14:52:36] x17: 00000000f7d33fac x16: 00000000fda59ba1 x15: 00000000e1f102aa
[14:52:36] x14: 000000000000026d x13: 0000000000000000 x12: ffff00003fddaf40
[14:52:36] x11: 00000000000000c0 x10: ffff0000045a26e8 x9 : 0000000000000000
[14:52:36] x8 : ffff00000a1e4cc0 x7 : 0000000000000000 x6 : 0000000000000001
[14:52:36] x5 : 000000000000003c x4 : ffff800080fbb898 x3 : ffff8000803e8820
[14:52:36] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffffffc202b0c0
[14:52:36] Call trace:

[14:52:36]  kfree+0x38/0x2a0 (P)
[14:52:36]  release_firmware+0x28/0x6c
[14:52:36]  wm_adsp_release_firmware_files+0x20/0x80
[14:52:36]  wm_adsp_fw_find_test_case_exit+0x18/0x24
[14:52:36]  kunit_try_run_case_cleanup+0x2c/0x44
[14:52:36]  kunit_generic_run_threadfn_adapter+0x28/0x4c
[14:52:36]  kthread+0x108/0x120
[14:52:36]  ret_from_fork+0x10/0x20
[14:52:36] Code: d34cfe73 f2d83fe0 8b131813 aa1303e0 (f9400661)
[14:52:36] ---[ end trace 0000000000000000 ]---
[14:52:36]     # wm_adsp_fw_find_test_search_order: try faulted: last line seen sound/soc/codecs/wm_adsp_fw_find_test.c:193
[14:52:36]     # wm_adsp_fw_find_test_search_order: internal error occurred during test case cleanup: -4
[14:52:36]     # wm_adsp_fw_find_test_search_order: pass:0 fail:21 skip:0 total:21

[14:52:36] ======== [FAILED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234-dsp1-mbc-vss-abc1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-abc123.wmfw cirrus/cs1234-dsp1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss-abc123.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vs [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:ABC123 alsa_name: wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] # wm_adsp_fw_find_test_search_order: pass:0 fail:14 skip:0 total:14
[14:52:36] ======== [FAILED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 expects:(cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss. [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name:amp1 wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] # wm_adsp_fw_find_test_search_order: pass:0 fail:9 skip:0 total:9
[14:52:36] ======== [FAILED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: expects:(cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: wmfw_optional expects:(cs1234-dsp1-mbc-vss.wmfw cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] # wm_adsp_fw_find_test_search_order: pass:0 fail:9 skip:0 total:9
[14:52:36] ======== [FAILED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============ wm_adsp_fw_find_test_search_order ============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:Vendor alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-vendor.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:Vendor Device alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:Vendor_Device alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:Vendor/Device alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-vendor-device.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:1234:56AB alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss-1234-56ab.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:LEFT expects:(cirrus/cs1234-dsp1-mbc-vss-abc-left.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:LEFT AMP expects:(cirrus/cs1234-dsp1-mbc-vss-abc-left-amp.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:Left Amp expects:(cirrus/cs1234-dsp1-mbc-vss-abc-left-amp.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:Amp_1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc-amp-1.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:cs1234.1 expects:(cirrus/cs1234-dsp1-mbc-vss-abc-cs1234.1.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:abc alsa_name:Spk/Jack expects:(cirrus/cs1234-dsp1-mbc-vss-abc-spk-jack.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_search_order: failed to initialize: -16
[14:52:36] # wm_adsp_fw_find_test_search_order: pass:0 fail:11 skip:0 total:11
[14:52:36] ======== [FAILED] wm_adsp_fw_find_test_search_order ========
[14:52:36] ============= wm_adsp_fw_find_test_pick_file ==============
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFBF1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-wfbf1111-amp1.wmfw cirrus/cs1234-dsp1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFBF1111 alsa_name:l1u2 expects:(cirrus/cs1234-dsp1-mbc-vss-wfbf1111-l1u2.wmfw cirrus/cs1234-dsp1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WSBF1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-wsbf1111.wmfw cirrus/cs1234-dsp1-mbc- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WSBF1111 alsa_name:l1u2 expects:(cirrus/cs1234-dsp1-mbc-vss-wsbf1111.wmfw cirrus/cs1234-dsp1-mbc- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFBF1111 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-wfbf1111-amp1.wmfw cirru [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WSBS1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-wsbs1111.wmfw cirrus/cs1234-dsp1-mbc- [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WSBF1111 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-wsbf1111.wmfw cirrus/cs1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:XXBF1111 alsa_name:amp1 wmfw_optional expects:( cirrus/cs1234-dsp1-mbc-vss-xxbf1111-amp1.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFBF1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-wfbf1111-amp1.wmfw cirrus/cs1234-dsp1 [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFXX1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss-wfxx1111.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:WFXX1111 alsa_name:amp1 wmfw_optional expects:(cirrus/cs1234-dsp1-mbc-vss-wfxx1111.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system:XXXX1111 alsa_name:amp1 expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234nobin dsp1 fwf_name: system:XXXX1111 alsa_name:amp1 expects:(cirrus/cs1234nobin-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] wm1234nobin dsp1 fwf_name: system: alsa_name: expects:(wm1234nobin-dsp1-mbc-vss.wmfw )
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] wm1234 dsp1 fwf_name: system: alsa_name: expects:(wm1234-dsp1-mbc-vss.wmfw wm1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234nobin dsp1 fwf_name: system: alsa_name: expects:(cirrus/cs1234nobin-dsp1-mbc-vss.wmfw ) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] [FAILED] cs1234 dsp1 fwf_name: system: alsa_name: expects:(cirrus/cs1234-dsp1-mbc-vss.wmfw cirrus/cs1234-dsp1-mbc-vss.bin) [14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_pick_file: failed to initialize: -16
[14:52:36] # wm_adsp_fw_find_test_pick_file: pass:0 fail:17 skip:0 total:17
[14:52:36] ========= [FAILED] wm_adsp_fw_find_test_pick_file ==========
[14:52:36] Error: Driver 'wm_adsp_test_drv' is already registered, aborting...
[14:52:36] # wm_adsp_fw_find_test_find_firmware_byindex: failed to initialize: -16
[14:52:36] [FAILED] wm_adsp_fw_find_test_find_firmware_byindex
[14:52:36] # module: snd_soc_wm_adsp_test
[14:52:36] # wm-adsp-fw-find: pass:1 fail:7 skip:0 total:8
[14:52:36] # Totals: pass:8 fail:82 skip:0 total:90
[14:52:36] ================= [FAILED] wm-adsp-fw-find =================

Failures: wm-adsp-fw-find.wm_adsp_fw_find_test_search_order, wm-adsp-fw-find.wm_adsp_fw_find_test_search_order, wm-adsp-fw-find.wm_adsp_fw_find_test_search_order, wm-adsp-fw-find.wm_adsp_fw_find_test_search_order, wm-adsp-fw-find.wm_adsp_fw_find_test_search_order, wm-adsp-fw-find.wm_adsp_fw_find_test_pick_file, wm-adsp-fw-find.wm_adsp_fw_find_test_find_firmware_byindex

maintainer
#13 lore raw
Quoted 11 lines · Mark Brown
Quoted 8 lines · Richard Fitzgerald

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

Quoted 6 lines
Quoted 2 lines

The remaining patches remove duplicated code and clean up some of the implementation.

Actually I'm seeing failures with this running on arm64, they were missed by my testing due to issues with KUnit in -rc1, looking at this clearly a lot of the problems are knock on results of an initial failure:

Any updates on getting this fixed?

#14 lore raw
Quoted 12 lines · Mark Brown
Quoted 10 lines · Mark Brown
Quoted 8 lines · Richard Fitzgerald

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

The remaining patches remove duplicated code and clean up some of the implementation.

Actually I'm seeing failures with this running on arm64, they were missed by my testing due to issues with KUnit in -rc1, looking at this clearly a lot of the problems are knock on results of an initial failure:

Any updates on getting this fixed?

Apologies Richard is on holiday this week. I will see if I can find a moment to have a quick look.

Thanks,
Charles

#15 lore raw
Quoted 16 lines · Charles Keepax
Quoted 15 lines · Mark Brown
Quoted 13 lines · Mark Brown
Quoted 11 lines · Richard Fitzgerald

This series makes some improvements to the code that searches for firmware files.

Patch 1 is a trivial patch to remove an unused function argument, before
adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
break anything.

The remaining patches remove duplicated code and clean up some of the implementation.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Actually I'm seeing failures with this running on arm64, they were missed by my testing due to issues with KUnit in -rc1, looking at this clearly a lot of the problems are knock on results of an initial failure:

Any updates on getting this fixed?

Apologies Richard is on holiday this week. I will see if I can find a moment to have a quick look.

The rabbit whole looks pretty deep on this one. As far as I can see it fails adding the device because the device already exists on the bus but this is the first time it added the device and also I can find no evidence it even created a bus in the first place. Feels like there is a large piece of my understanding of how this is supposed to work that is missing. I think we might have to wait for Richard to return on Monday, how much of a problem is that from your end?

Thanks,
Charles

maintainer
#16 lore raw
Quoted 8 lines · Charles Keepax

The rabbit whole looks pretty deep on this one. As far as I can see it fails adding the device because the device already exists on the bus but this is the first time it added the device and also I can find no evidence it even created a bus in the first place. Feels like there is a large piece of my understanding of how this is supposed to work that is missing. I think we might have to wait for Richard to return on Monday, how much of a problem is that from your end?

This is holding inclusion of any new ASoC code since last Thursday out of -next, that's pretty disruptive really. It might be easiest to just drop the changes and let Richard resubmit when he gets back.

#17 lore raw
Quoted 11 lines · Mark Brown
Quoted 8 lines · Charles Keepax

The rabbit whole looks pretty deep on this one. As far as I can see it fails adding the device because the device already exists on the bus but this is the first time it added the device and also I can find no evidence it even created a bus in the first place. Feels like there is a large piece of my understanding of how this is supposed to work that is missing. I think we might have to wait for Richard to return on Monday, how much of a problem is that from your end?

Quoted 3 lines

This is holding inclusion of any new ASoC code since last Thursday out of -next, that's pretty disruptive really. It might be easiest to just drop the changes and let Richard resubmit when he gets back.

Ok I will have a bit more of a gander today and chat to the boss here, but I suspect you are right we may have to revert the change. I will report back by end of today if not sooner.

Thanks,
Charles

#18 lore raw
Quoted 12 lines · Charles Keepax
Quoted 11 lines · Mark Brown
Quoted 8 lines · Charles Keepax

The rabbit whole looks pretty deep on this one. As far as I can see it fails adding the device because the device already exists on the bus but this is the first time it added the device and also I can find no evidence it even created a bus in the first place. Feels like there is a large piece of my understanding of how this is supposed to work that is missing. I think we might have to wait for Richard to return on Monday, how much of a problem is that from your end?

Quoted 7 lines
Quoted 3 lines

This is holding inclusion of any new ASoC code since last Thursday out of -next, that's pretty disruptive really. It might be easiest to just drop the changes and let Richard resubmit when he gets back.

Ok I will have a bit more of a gander today and chat to the boss here, but I suspect you are right we may have to revert the change. I will report back by end of today if not sooner.

Ok looking again with fresh eyes I think I have it. Turns out most of my problems yesterday were just finding the right incantations to get kunit to show me all the debug.

Patch incoming shortly.

Thanks,
Charles

maintainer
#19 lore raw
Quoted 11 lines · Charles Keepax
Quoted 3 lines · Charles Keepax

Ok I will have a bit more of a gander today and chat to the boss here, but I suspect you are right we may have to revert the change. I will report back by end of today if not sooner.

Ok looking again with fresh eyes I think I have it. Turns out most of my problems yesterday were just finding the right incantations to get kunit to show me all the debug.

Patch incoming shortly.

Awesome, thanks so much!