Skip to content

ASoC: TI codecs: sort the reg_defaults tables

Peter Ujfalusi linux-sound stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5ASoC: pcm512x: sort the register default tablesound/soc/codecs/pcm512x.c+20 -200 replies
2/5ASoC: tas2552: sort the register default tablesound/soc/codecs/tas2552.c+7 -70 replies
3/5ASoC: tas2764: sort the register default tablesound/soc/codecs/tas2764.c+1 -10 replies
4/5ASoC: tas2780: sort the register default tablesound/soc/codecs/tas2780.c+1 -10 replies
5/5ASoC: tas675x: sort the register default tablesound/soc/codecs/tas675x.c+9 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] ASoC: TI codecs: sort the reg_defaults tables

The reg_defaults array of a regmap_config must be sorted by ascending register address: regcache_lookup_reg() finds entries in it with bsearch(), and regcache_init() only kmemdup_array()s the array, it never sorts it. See commit fd80df352ba1 ("regcache: Add support for sorting defaults arrays").

When the array is not sorted, bsearch() descends into the wrong half and a number of entries can never be found. regcache_reg_needs_sync() then cannot compare the cached value against the default and always reports that a sync is needed, so those registers are written to the device on every regcache_sync() even if they were never touched.

I found this while chasing a SoundWire NAK on an unimplemented register and audited the reg_defaults tables in sound/ by replaying lib/bsearch.c over each of them. These are the affected TI/Burr-Brown codecs:

  pcm512x_reg_defaults    45 entries, 24 unreachable
  tas675x_reg_defaults    69 entries, 14 unreachable
  tas2552_reg_defs        21 entries,  7 unreachable
  tas2764_reg_defaults    11 entries,  1 unreachable
  tas2780_reg_defaults    10 entries,  1 unreachable

The patches only reorder the existing entries. The text of every entry is kept verbatim, no default value is changed, and each resulting table was verified to be fully reachable.

tas2783-sdw was fixed separately, it had already been posted.

The series is based on broonie/for-linus.

Peter Ujfalusi (5):
ASoC: pcm512x: sort the register default table
ASoC: tas2552: sort the register default table
ASoC: tas2764: sort the register default table
ASoC: tas2780: sort the register default table
ASoC: tas675x: sort the register default table

 sound/soc/codecs/pcm512x.c | 40 +++++++++++++++++++-------------------
 sound/soc/codecs/tas2552.c | 14 ++++++-------
 sound/soc/codecs/tas2764.c |  2 +-
 sound/soc/codecs/tas2780.c |  2 +-
 sound/soc/codecs/tas675x.c | 18 ++++++++---------
 5 files changed, 38 insertions(+), 38 deletions(-)
Signature · 1 line
2.55.0