Message ID | 20240821100221.99699-1-rf@opensource.cirrus.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | ASoC: cs-amp-lib: Ignore empty UEFI calibration entries | expand |
On Wed, Aug 21, 2024 at 11:02:21AM +0100, Richard Fitzgerald wrote: > If the timestamp of a calibration entry is 0 it is an unused entry and > must be ignored. > > Some end-products reserve EFI space for calibration entries by shipping > with a zero-filled EFI file. When searching the file for calibration > data the driver must skip the empty entries. The timestamp of a valid > entry is always non-zero. This breaks the build if I apply it on either for-6.11 or for-6.12: In file included from /build/stage/linux/sound/soc/codecs/cs-amp-lib-test.c:8: /build/stage/linux/sound/soc/codecs/cs-amp-lib-test.c: In function ‘cs_amp_lib_test_get_efi_cal_by_uid_test’: /build/stage/linux/sound/soc/codecs/cs-amp-lib-test.c:224:50: error: subscripted value is neither array nor pointer nor vector 224 | KUNIT_EXPECT_EQ(test, result_data.calTime[0], | ^ /build/stage/linux/include/kunit/test.h:724:22: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’ 724 | const typeof(left) __left = (left); \ | ^~~~ (with lots more errors) - I'm guessins some missing dependency somewhere?
On Wed, 21 Aug 2024 11:02:21 +0100, Richard Fitzgerald wrote: > If the timestamp of a calibration entry is 0 it is an unused entry and > must be ignored. > > Some end-products reserve EFI space for calibration entries by shipping > with a zero-filled EFI file. When searching the file for calibration > data the driver must skip the empty entries. The timestamp of a valid > entry is always non-zero. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: cs-amp-lib: Ignore empty UEFI calibration entries commit: bb4485562f5907708f1c218b5d70dce04165d1e1 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
diff --git a/include/sound/cs-amp-lib.h b/include/sound/cs-amp-lib.h index f481148735e1..77c4c1c9cf1a 100644 --- a/include/sound/cs-amp-lib.h +++ b/include/sound/cs-amp-lib.h @@ -14,7 +14,7 @@ struct cs_dsp; struct cirrus_amp_cal_data { u32 calTarget[2]; - u32 calTime[2]; + u64 calTime; s8 calAmbient; u8 calStatus; u16 calR; diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c index 605964af8afa..8aaca88ef1b6 100644 --- a/sound/soc/codecs/cs-amp-lib.c +++ b/sound/soc/codecs/cs-amp-lib.c @@ -182,6 +182,10 @@ static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, for (i = 0; i < efi_data->count; ++i) { u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[i]); + /* Skip empty entries */ + if (efi_data->data[i].calTime == 0) + continue; + /* Skip entries with unpopulated silicon ID */ if (cal_target == 0) continue; @@ -193,7 +197,8 @@ static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, } } - if (!cal && (amp_index >= 0) && (amp_index < efi_data->count)) { + if (!cal && (amp_index >= 0) && (amp_index < efi_data->count) && + (efi_data->data[amp_index].calTime != 0)) { u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[amp_index]); /*
If the timestamp of a calibration entry is 0 it is an unused entry and must be ignored. Some end-products reserve EFI space for calibration entries by shipping with a zero-filled EFI file. When searching the file for calibration data the driver must skip the empty entries. The timestamp of a valid entry is always non-zero. The type of struct cirrus_amp_efi_data.calTime has been changed from an array of two u32 to a single u64. The timestamp is a 64-bit value and treating it as such simplifies the code. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 1cad8725f2b9 ("ASoC: cs-amp-lib: Add helpers for factory calibration data") --- include/sound/cs-amp-lib.h | 2 +- sound/soc/codecs/cs-amp-lib.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)