Skip to contentSkip to conversation

ASoC: Use the maple tree register cache for RealTek SoundWire CODECs

PATCH In review Mark Brown 3 participants 15 messages Jun 10, 2023 – Jun 27, 2023

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

cover ASoC: Use the maple tree register cache for RealTek SoundWire CODECs

The RealTek SoundWire CODECs don't support bulk register operations so they gain no advantage from using the rbtree cache, convert them to use the maple tree cache instead - it is more modern.

---
Mark Brown (8):
ASoC: rt700: Use maple tree register cache
ASoC: rt711: Use maple tree register cache
ASoC: rt712: Use maple tree register cache
ASoC: rt715: Use maple tree register cache
ASoC: rt722: Use maple tree register cache
ASoC: rt1308: Use maple tree register cache
ASoC: rt1316: Use maple tree register cache
ASoC: rt1318: Use maple tree register cache

 sound/soc/codecs/rt1308-sdw.c      | 2 +-
 sound/soc/codecs/rt1316-sdw.c      | 2 +-
 sound/soc/codecs/rt1318-sdw.c      | 2 +-
 sound/soc/codecs/rt700-sdw.c       | 2 +-
 sound/soc/codecs/rt711-sdca-sdw.c  | 4 ++--
 sound/soc/codecs/rt711-sdw.c       | 2 +-
 sound/soc/codecs/rt712-sdca-dmic.c | 4 ++--
 sound/soc/codecs/rt712-sdca-sdw.c  | 4 ++--
 sound/soc/codecs/rt715-sdca-sdw.c  | 4 ++--
 sound/soc/codecs/rt722-sdca-sdw.c  | 4 ++--
 10 files changed, 15 insertions(+), 15 deletions(-)

---
base-commit: 08e6c4bb17087584261c4aff555d32fc1c620b81
change-id: 20230609-asoc-rt-sdw-maple-fa6714ac4318

Best regards,

Signature · 1 line
Mark Brown <[email protected]>
author maintainer
#1 lore raw

PATCH 1/8 ASoC: rt700: Use maple tree register cache

The rt700 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt700-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt700-sdw.c +1 -1
index ba7767bee07c..8b28e47775cc 100644
@@ -292,7 +292,7 @@ static const struct regmap_config rt700_regmap = {
 	.max_register = 0x755800,
 	.reg_defaults = rt700_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt700_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 	.reg_read = rt700_sdw_read,
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH 2/8 ASoC: rt711: Use maple tree register cache

In reply to Mark Brown

The rt711 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt711-sdca-sdw.c | 4 ++--
 sound/soc/codecs/rt711-sdw.c      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/rt711-sdca-sdw.c +2 -2
index 2c5eb28259dc..119e1f9605d7 100644
@@ -119,7 +119,7 @@ static const struct regmap_config rt711_sdca_regmap = {
 	.max_register = 0x44ffffff,
 	.reg_defaults = rt711_sdca_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt711_sdca_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
@@ -133,7 +133,7 @@ static const struct regmap_config rt711_sdca_mbq_regmap = {
 	.max_register = 0x40800f12,
 	.reg_defaults = rt711_sdca_mbq_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt711_sdca_mbq_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
sound/soc/codecs/rt711-sdw.c +1 -1
index b8ed3c6236d8..87dafcb4545d 100644
@@ -296,7 +296,7 @@ static const struct regmap_config rt711_regmap = {
 	.max_register = 0x755800,
 	.reg_defaults = rt711_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt711_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 	.reg_read = rt711_sdw_read,
Signature · 1 line
2.30.2
author maintainer
#3 lore raw

PATCH 3/8 ASoC: rt712: Use maple tree register cache

In reply to Mark Brown

The rt712 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt712-sdca-dmic.c | 4 ++--
 sound/soc/codecs/rt712-sdca-sdw.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/rt712-sdca-dmic.c +2 -2
index 847198e6c07e..869cc7bfd178 100644
@@ -110,7 +110,7 @@ static const struct regmap_config rt712_sdca_dmic_regmap = {
 	.max_register = 0x40981300,
 	.reg_defaults = rt712_sdca_dmic_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt712_sdca_dmic_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
@@ -124,7 +124,7 @@ static const struct regmap_config rt712_sdca_dmic_mbq_regmap = {
 	.max_register = 0x40800f14,
 	.reg_defaults = rt712_sdca_dmic_mbq_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt712_sdca_dmic_mbq_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
sound/soc/codecs/rt712-sdca-sdw.c +2 -2
index 8f65516e7562..ad06267b0ea0 100644
@@ -116,7 +116,7 @@ static const struct regmap_config rt712_sdca_regmap = {
 	.max_register = 0x44ffffff,
 	.reg_defaults = rt712_sdca_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt712_sdca_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
@@ -130,7 +130,7 @@ static const struct regmap_config rt712_sdca_mbq_regmap = {
 	.max_register = 0x41000312,
 	.reg_defaults = rt712_sdca_mbq_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt712_sdca_mbq_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
author maintainer
#4 lore raw

PATCH 4/8 ASoC: rt715: Use maple tree register cache

In reply to Mark Brown

The rt715 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt715-sdca-sdw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/rt715-sdca-sdw.c +2 -2
index 7e5ddce8097d..df10916bab46 100644
@@ -97,7 +97,7 @@ static const struct regmap_config rt715_sdca_regmap = {
 	.max_register = 0x43ffffff,
 	.reg_defaults = rt715_reg_defaults_sdca,
 	.num_reg_defaults = ARRAY_SIZE(rt715_reg_defaults_sdca),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
@@ -111,7 +111,7 @@ static const struct regmap_config rt715_sdca_mbq_regmap = {
 	.max_register = 0x43ffffff,
 	.reg_defaults = rt715_mbq_reg_defaults_sdca,
 	.num_reg_defaults = ARRAY_SIZE(rt715_mbq_reg_defaults_sdca),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
author maintainer
#5 lore raw

PATCH 5/8 ASoC: rt722: Use maple tree register cache

In reply to Mark Brown

The rt722 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt722-sdca-sdw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/rt722-sdca-sdw.c +2 -2
index bfb2dac6bfee..cc57e4e27805 100644
@@ -139,7 +139,7 @@ static const struct regmap_config rt722_sdca_regmap = {
 	.max_register = 0x44ffffff,
 	.reg_defaults = rt722_sdca_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt722_sdca_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
@@ -153,7 +153,7 @@ static const struct regmap_config rt722_sdca_mbq_regmap = {
 	.max_register = 0x41000312,
 	.reg_defaults = rt722_sdca_mbq_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt722_sdca_mbq_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

PATCH 6/8 ASoC: rt1308: Use maple tree register cache

In reply to Mark Brown

The rt1308 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt1308-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1308-sdw.c +1 -1
index 313e97c94532..f43520ca3187 100644
@@ -68,7 +68,7 @@ static const struct regmap_config rt1308_sdw_regmap = {
 	.max_register = 0xcfff,
 	.reg_defaults = rt1308_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt1308_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
author maintainer
#7 lore raw

PATCH 7/8 ASoC: rt1316: Use maple tree register cache

In reply to Mark Brown

The rt1316 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt1316-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1316-sdw.c +1 -1
index 601b76320124..721821d9e9af 100644
@@ -188,7 +188,7 @@ static const struct regmap_config rt1316_sdw_regmap = {
 	.max_register = 0x4108ffff,
 	.reg_defaults = rt1316_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt1316_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
author maintainer
#8 lore raw

PATCH 8/8 ASoC: rt1318: Use maple tree register cache

In reply to Mark Brown

The rt1318 can only support single register read and write operations so does not benefit from block writes. This means it gets no benefit from using the rbtree register cache over the maple tree register cache so convert it to use maple trees instead, it is more modern.

---
 sound/soc/codecs/rt1318-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1318-sdw.c +1 -1
index 3751d923611c..16d750102c8c 100644
@@ -337,7 +337,7 @@ static const struct regmap_config rt1318_sdw_regmap = {
 	.max_register = 0x41081488,
 	.reg_defaults = rt1318_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(rt1318_reg_defaults),
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.use_single_read = true,
 	.use_single_write = true,
 };
Signature · 1 line
2.30.2
Tested-by on the v1 series
#9 lore raw
In reply to Mark Brown
Quoted 5 lines · Mark Brown

The RealTek SoundWire CODECs don't support bulk register operations so they gain no advantage from using the rbtree cache, convert them to use the maple tree cache instead - it is more modern.

Tested on a Dell laptop with rt1316, rt711-sdca, and rt715-sdca.

Quoted 27 lines

---
Mark Brown (8):
ASoC: rt700: Use maple tree register cache
ASoC: rt711: Use maple tree register cache
ASoC: rt712: Use maple tree register cache
ASoC: rt715: Use maple tree register cache
ASoC: rt722: Use maple tree register cache
ASoC: rt1308: Use maple tree register cache
ASoC: rt1316: Use maple tree register cache
ASoC: rt1318: Use maple tree register cache

  sound/soc/codecs/rt1308-sdw.c      | 2 +-
  sound/soc/codecs/rt1316-sdw.c      | 2 +-
  sound/soc/codecs/rt1318-sdw.c      | 2 +-
  sound/soc/codecs/rt700-sdw.c       | 2 +-
  sound/soc/codecs/rt711-sdca-sdw.c  | 4 ++--
  sound/soc/codecs/rt711-sdw.c       | 2 +-
  sound/soc/codecs/rt712-sdca-dmic.c | 4 ++--
  sound/soc/codecs/rt712-sdca-sdw.c  | 4 ++--
  sound/soc/codecs/rt715-sdca-sdw.c  | 4 ++--
  sound/soc/codecs/rt722-sdca-sdw.c  | 4 ++--
  10 files changed, 15 insertions(+), 15 deletions(-)

---
base-commit: 08e6c4bb17087584261c4aff555d32fc1c620b81
change-id: 20230609-asoc-rt-sdw-maple-fa6714ac4318

Best regards,

author maintainer
#10 lore raw
In reply to Mark Brown
Quoted 5 lines · Mark Brown

The RealTek SoundWire CODECs don't support bulk register operations so they gain no advantage from using the rbtree cache, convert them to use the maple tree cache instead - it is more modern.

Applied to

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

Thanks!

[1/8] ASoC: rt700: Use maple tree register cache

      commit: 049a78048e15ab276052d846c9692ea272699644
[2/8] ASoC: rt711: Use maple tree register cache
      commit: 0a5757293339fbbbb627baa7d2da65fd083c7cce
[3/8] ASoC: rt712: Use maple tree register cache
      commit: f438c799aa934fcd9b956083043b6f691bcc8492
[4/8] ASoC: rt715: Use maple tree register cache
      commit: dd08b6ddcb319375b4ee69cd02ce3298ca7608aa
[5/8] ASoC: rt722: Use maple tree register cache
      commit: 799457a3200b0451ca9859c77dd4e863f70ba608
[6/8] ASoC: rt1308: Use maple tree register cache
      commit: 4f69e29ace9dce5f8226bfc99b77b8497d3d3d79
[7/8] ASoC: rt1316: Use maple tree register cache
      commit: 6179a2e84f0b0b353079fe965d321ed25251c996
[8/8] ASoC: rt1318: Use maple tree register cache
      commit: 22691a051377763e6a4e149b7362944253fb434a

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

#11 lore raw
In reply to Mark Brown

Hello,

With cache type changing to maple tree for SoundWire Codec patch series, we are observing rcu warnings with AMD SoundWire stack.

Below are the pastebin links for rcu warnings dmesg logs.

https://pastebin.com/6sadwNCw <https://pastebin.com/6sadwNCw>

https://pastebin.com/zwhfUKGf <https://pastebin.com/zwhfUKGf>

Acquiring rcu lock in between register read/writes causes context switch.

In AMD SoundWire manager xfer_msg() callback, we are using read_poll_timeout logic. Below is the link.
https://elixir.bootlin.com/linux/v6.4-rc7/source/drivers/soundwire/amd_manager.c#L177

As per our understanding, we need to go with busy wait rather than using usleep_range() which will be invoked by read_poll_timeout() logic.

Could you please suggest us how to fix this issue?

Thanks,
Vijendar

author maintainer
#12 lore raw
Quoted 2 lines · Mukunda,Vijendar

With cache type changing to maple tree for SoundWire Codec patch series, we are observing rcu warnings with AMD SoundWire stack.

Do you you have 0cc6578048e0980 ("regmap: maple: Drop the RCU read lock while syncing registers") in your tree when testing?

Quoted 3 lines

Below are the pastebin links for rcu warnings dmesg logs.

https://pastebin.com/6sadwNCw <https://pastebin.com/6sadwNCw>

Please include at least some of the actual warning in your emails so they are directly readable.

#13 lore raw
Quoted 6 lines · Mark Brown
Quoted 2 lines · Mukunda,Vijendar

With cache type changing to maple tree for SoundWire Codec patch series, we are observing rcu warnings with AMD SoundWire stack.

Do you you have 0cc6578048e0980 ("regmap: maple: Drop the RCU read lock while syncing registers") in your tree when testing?

We have tested with ASoC tree for-next branch code. This patch is not included in our tree while testing.

We will verify with the patch and let you know our findings.

Quoted 4 lines
Quoted 2 lines

Below are the pastebin links for rcu warnings dmesg logs.
https://pastebin.com/6sadwNCw <https://pastebin.com/6sadwNCw>

Please include at least some of the actual warning in your emails so they are directly readable.

#14 lore raw
Quoted 11 lines · Mukunda,Vijendar
Quoted 6 lines · Mark Brown
Quoted 2 lines · Mukunda,Vijendar

With cache type changing to maple tree for SoundWire Codec patch series, we are observing rcu warnings with AMD SoundWire stack.

Do you you have 0cc6578048e0980 ("regmap: maple: Drop the RCU read lock while syncing registers") in your tree when testing?

We have tested with ASoC tree for-next branch code. This patch is not included in our tree while testing.

We will verify with the patch and let you know our findings.

After inclusion of above-mentioned patch, we are no longer observing rcu warnings.

Thanks,
Vijendar

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Below are the pastebin links for rcu warnings dmesg logs.
https://pastebin.com/6sadwNCw <https://pastebin.com/6sadwNCw>

Please include at least some of the actual warning in your emails so they are directly readable.