Skip to content

[PW_SID:1087951] ASoC: add shared BCLK rate constraint for cross-DAI coordination#1847

Closed
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1087951
Closed

[PW_SID:1087951] ASoC: add shared BCLK rate constraint for cross-DAI coordination#1847
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1087951

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1087951 applied to workflow__riscv__fixes

Name: ASoC: add shared BCLK rate constraint for cross-DAI coordination
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1087951
Version: 1

Add a bclk field to struct snd_soc_dai and a helper function
snd_soc_dai_set_bclk_clk() that platform drivers can use to declare
which clock is their BCLK.

Also cache the bclk_ratio in snd_soc_dai_set_bclk_ratio() so that
the framework can use it later in hw_rule evaluation for TDM
configurations where BCLK = rate * slots * slot_width.

When multiple DAIs on the same card share the same physical BCLK
(detected via clk_is_match()), the ASoC core can automatically
constrain their hw_params so that the resulting BCLK rates are
compatible. This commit adds the data structure support; the actual
constraint logic follows in the next patch.

Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When multiple CPU DAIs on the same sound card share the same physical
BCLK, add a hw_rule during PCM open that constrains the sample rate so
the resulting BCLK rate stays consistent across all sharing DAIs.

The hw_rule is registered unconditionally for every DAI that has a bclk
clock pointer set. The actual peer scanning happens inside the rule
callback at hw_refine time: it walks all DAIs on the card, looking for
an active peer that shares the same physical BCLK (via clk_is_match())
and has already completed hw_params (checked via dai->symmetric_rate
!= 0). This ensures the constraint uses the real BCLK rate established
by the peer's clk_set_rate() in hw_params, not a stale boot-time
default.

The first DAI to complete hw_params is unconstrained (no active peer
yet); subsequent DAIs are constrained to match.

The rule supports two modes:
- If the DAI has an explicit bclk_ratio set (e.g. for TDM where
  BCLK = rate * slots * slot_width), the rate is constrained to
  active_bclk_rate / bclk_ratio.
- Otherwise, the default formula BCLK = rate * channels * sample_bits
  is used to derive the valid rate range.

The constraint is purely additive: DAIs that do not set a bclk clock
pointer are completely unaffected.

Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
On SpacemiT K3, multiple I2S controllers share the same physical BCLK
(c_bclk). Declare this clock via snd_soc_dai_set_bclk_clk() so the
ASoC core can automatically constrain hw_params when one controller is
already streaming.

For K1, c_bclk is NULL (obtained via devm_clk_get_optional_enabled),
so this call is a no-op and behavior is unchanged.

Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 139.45 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1099.37 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1488.56 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.72 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.01 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 86.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
kdoc
Desc: Detects for kdoc errors
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 138.52 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1046.42 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1425.99 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.33 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.12 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 86.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
kdoc
Desc: Detects for kdoc errors
Duration: 0.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
module-param
Desc: Detect module_param changes
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.33 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 139.16 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 743.05 seconds
Result: ERROR
Output:

Redirect to /build/tmp.9LSAIneDd2 and /build/tmp.ebDTxbKtGX
Tree base:
84d8e16ec3f7c ("ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK")
Building the whole tree with the patch
error:
Warning: /build/tmp8r0vuy2w/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c:245 struct __packed mtk_mfg_opp_entry { __le32 freq_khz; __le32 voltage_core; __le32 voltage_sram; __le32 posdiv; __le32 voltage_margin; __le32 power_mw; }; error: Cannot parse struct or union!
/build/tmp8r0vuy2w/sound/soc/spacemit/k1_i2s.c:291:37: error: no member named 'c_bclk' in 'struct spacemit_i2s_dev'; did you mean 'bclk'?



real	12m16.800s
user	477m48.440s
sys	82m58.453s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1024.36 seconds
Result: ERROR
Output:

Redirect to /build/tmp.lEdv8dhnHu and /build/tmp.gdJYDXEuu8
Tree base:
84d8e16ec3f7c ("ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK")
Building the whole tree with the patch
error:
Warning: /build/tmp8r0vuy2w/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c:245 struct __packed mtk_mfg_opp_entry { __le32 freq_khz; __le32 voltage_core; __le32 voltage_sram; __le32 posdiv; __le32 voltage_margin; __le32 power_mw; }; error: Cannot parse struct or union!
/build/tmp8r0vuy2w/sound/soc/spacemit/k1_i2s.c:291:44: error: 'struct spacemit_i2s_dev' has no member named 'c_bclk'; did you mean 'bclk'?



real	16m58.210s
user	667m46.947s
sys	102m21.971s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.96 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.16 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.76 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 86.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
kdoc
Desc: Detects for kdoc errors
Duration: 0.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] ASoC: spacemit: declare shared BCLK for cross-DAI rate constraint"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1087951 branch April 30, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants