From: sashiko-bot@kernel.org
To: "James Calligeros" <jcalligeros99@gmail.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 12/22] arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
Date: Tue, 03 Nov 2026 08:36:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-194839@kernel.org> (raw)
In-Reply-To: <20261103-macaudio-v4-12-637484efe46d@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] ASoC: apple: macaudio: OF ref leak and devres order in macaudio_devm_release()
- [Medium] ASoC: tas2770: tas2770_set_dai_tdm_idle() treats positive return as error
- [Medium] ASoC: apple: macaudio: macaudio_be_assign_tdm() overwrites slot error
- [Low] arm64: dts: apple: t8103-j313: unused #address-cells/#size-cells in sound
--
commit dd4cb33fc5a853fd54101899a161b5d0c84f160e
Author: James Calligeros <jcalligeros99@gmail.com>
arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
This commit adds the TI TAS5770L speaker amplifier and Cirrus CS42L83
headset jack codec device tree nodes for the M1 MacBook Air (J313), along
with the sound node advertising them to the macaudio machine driver.
> diff --git a/arch/arm64/boot/dts/apple/t8103-j313.dts b/arch/arm64/boot/dts/apple/t8103-j313.dts
> index f8b2b1637b9dc..36c47734a1dc0 100644
> --- a/arch/arm64/boot/dts/apple/t8103-j313.dts
> +++ b/arch/arm64/boot/dts/apple/t8103-j313.dts
> @@ -55,4 +55,89 @@ &typec1 {
[ ... ]
> +/ {
> + sound: sound {
> + compatible = "apple,j313-macaudio";
> + model = "MacBook Air J313";
[Severity: High]
As reported by Sashiko on v3 [1], when this apple,j313-macaudio node binds to
macaudio_snd_driver, does macaudio_snd_platform_probe() in
sound/soc/apple/macaudio.c leak the backend DAI link CPU and CODEC device_node
references on unbind or if devm_add_action() fails, and can the devres
registration order cause macaudio_vlimit_update() to dereference a NULL
ma->card.snd_card during unbind?
During probe, macaudio_parse_of() -> macaudio_parse_of_be_dai_link() ->
macaudio_parse_of_component() acquires device_node references via
of_parse_phandle_with_args() for the CPU and CODEC DAIs. In
macaudio_snd_platform_probe():
sound/soc/apple/macaudio.c:macaudio_snd_platform_probe() {
...
ret = devm_add_action(dev, macaudio_devm_release, data);
if (ret)
return ret;
ret = devm_snd_soc_register_card(dev, &data->card);
if (ret) {
for_each_card_prelinks(&data->card, i, link) {
snd_soc_of_put_dai_link_codecs(link);
snd_soc_of_put_dai_link_cpus(link);
}
return ret;
}
}
If devm_add_action() fails, macaudio_snd_platform_probe() returns without
releasing the DAI link CPU and CODEC device_node references. Likewise, when
probe succeeds and the device is later unbound, neither ASoC core teardown
nor macaudio_devm_release() calls snd_soc_of_put_dai_link_codecs() and
snd_soc_of_put_dai_link_cpus():
sound/soc/apple/macaudio.c:macaudio_devm_release() {
struct macaudio_snd_data *ma = data;
cancel_work_sync(&ma->lock_update_work);
cancel_delayed_work_sync(&ma->lock_timeout_work);
}
In addition, because devm_add_action(dev, macaudio_devm_release, data) is
registered before devm_snd_soc_register_card(), devres LIFO teardown runs
devm_card_bind_release() -> snd_soc_unregister_card() ->
soc_cleanup_card_resources() first, which frees card->snd_card and sets it to
NULL before macaudio_devm_release() cancels lock_update_work and
lock_timeout_work. If either work item runs during teardown,
macaudio_vlimit_update() accesses ma->card.snd_card->controls_rwsem:
sound/soc/apple/macaudio.c:macaudio_vlimit_update() {
...
if (take_rwsem)
down_write(&ma->card.snd_card->controls_rwsem);
}
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
[Severity: Low]
Will defining #address-cells and #size-cells on the sound node trigger a dtc
avoid_unnecessary_addr_size warning when building with W=1?
Neither headphone-dai-link nor speaker-dai-link uses a reg or ranges property
(and Documentation/devicetree/bindings/sound/apple,macaudio.yaml does not
define reg on child dai-link nodes despite listing #address-cells and
#size-cells in required), which causes check_avoid_unnecessary_addr_size() in
scripts/dtc/checks.c to warn under W=1.
Also, since arch/arm64/boot/dts/apple/t8103-j313.dts already has a root
/ { ... }; block at the top of the file, should the sound node be placed in
that existing root node block rather than opening a second / { ... }; block
after the phandle overrides?
> +
> + headphone-dai-link {
> + link-name = "Headphone Jack";
> +
> + codec {
> + sound-dai = <&jack_codec>;
> + };
> +
> + cpu {
> + sound-dai = <&mca 2>;
> + };
> + };
> +
> + speaker-dai-link {
> + dai-tdm-idle-mode-0 = "zero";
> + dai-tdm-idle-mode-1 = "zero";
[Severity: Medium]
When speaker-dai-link sets dai-tdm-idle-mode-0 and dai-tdm-idle-mode-1 to
"zero" for the two ti,tas5770l codecs, will tas2770_set_dai_tdm_idle() fail to
complete the TDM idle setup and cause macaudio_be_assign_tdm() to fail?
During backend initialization, macaudio_be_init() -> macaudio_be_assign_tdm()
calls snd_soc_dai_set_tdm_idle() with SND_SOC_DAI_TDM_IDLE_ZERO, which
dispatches to tas2770_set_dai_tdm_idle() in sound/soc/codecs/tas2770.c:
sound/soc/codecs/tas2770.c:tas2770_set_dai_tdm_idle() {
...
case SND_SOC_DAI_TDM_IDLE_ZERO:
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG4,
TAS2770_TDM_CFG_REG4_TX_KEEPER,
TAS2770_TDM_CFG_REG4_TX_KEEPER);
if (ret)
return ret;
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG4,
TAS2770_TDM_CFG_REG4_TX_FILL, 0);
if (ret)
return ret;
break;
}
Because snd_soc_component_update_bits() returns 1 when the register value
changes, 0 when unchanged, and a negative errno on error, setting
TAS2770_TDM_CFG_REG4_TX_KEEPER after reset returns 1. Checking if (ret)
instead of if (ret < 0) causes tas2770_set_dai_tdm_idle() to return 1 early
without clearing TAS2770_TDM_CFG_REG4_TX_FILL or updating
tas2770->idle_tx_mode.
In sound/soc/apple/macaudio.c, macaudio_be_assign_tdm() then checks if (ret)
on the return value of snd_soc_dai_set_tdm_idle():
sound/soc/apple/macaudio.c:macaudio_be_assign_tdm() {
...
if (props->codecs[0].idle_mode) {
ret = snd_soc_dai_set_tdm_idle(dai, props->codecs[0].idle_mask,
0, props->codecs[0].idle_mode, 0);
if (ret) {
dev_err(card->dev, "Failed to set idle props for codec\n");
return ret;
}
}
}
Won't this treat the positive return value 1 as an error and log "Failed to
set idle props for codec" when initializing speaker_left and speaker_right?
[Severity: Medium]
In the same single-codec branch of macaudio_be_assign_tdm() in
sound/soc/apple/macaudio.c (used for each of the two CPU/CODEC pairs in
speaker-dai-link), can a failure from snd_soc_dai_set_tdm_slot() be
overwritten when props->codecs[0].idle_mode is set?
Looking at macaudio_be_assign_tdm():
sound/soc/apple/macaudio.c:macaudio_be_assign_tdm() {
if (rtd->dai_link->num_codecs == 1) {
dai = snd_soc_rtd_to_codec(rtd, 0);
ret = snd_soc_dai_set_tdm_slot(dai, mask, 0, nslots, MACAUDIO_SLOTWIDTH);
/*
* Headphones get a pass on -ENOTSUPP (see the comment
* around bclk_ratio value for primary FE).
*/
if (ret == -ENOTSUPP && props->is_headphones)
return 0;
if (props->codecs[0].idle_mode) {
ret = snd_soc_dai_set_tdm_idle(dai, props->codecs[0].idle_mask,
0, props->codecs[0].idle_mode, 0);
if (ret) {
dev_err(card->dev, "Failed to set idle props for codec\n");
return ret;
}
}
return ret;
}
}
Unlike the multi-codec loop below it (which checks if (ret) return ret;
immediately after snd_soc_dai_set_tdm_slot()), the num_codecs == 1 path does
not check ret before entering if (props->codecs[0].idle_mode), so
snd_soc_dai_set_tdm_idle() overwrites any negative error returned by
snd_soc_dai_set_tdm_slot().
[1] https://lore.kernel.org/r/20261018-macaudio-v3-11-abdff7741dea@gmail.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-macaudio-v4-0-637484efe46d@gmail.com?part=12
next prev parent reply other threads:[~2026-11-03 8:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 7:39 [PATCH v4 00/22] Add speaker and headset jack support for Apple Silicon Macs James Calligeros
2026-11-03 7:39 ` [PATCH v4 01/22] ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties James Calligeros
2026-11-03 7:53 ` sashiko-bot
2026-11-04 10:48 ` Krzysztof Kozlowski
2026-11-04 10:59 ` James Calligeros
2026-11-03 7:39 ` [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: " James Calligeros
2026-11-03 7:51 ` sashiko-bot
2026-11-04 10:49 ` Krzysztof Kozlowski
2026-11-04 10:52 ` Krzysztof Kozlowski
2026-11-04 10:58 ` James Calligeros
2026-11-04 11:04 ` Krzysztof Kozlowski
2026-11-03 7:39 ` [PATCH v4 03/22] ASoC: dt-bindings: tdm-slot: Allow indexed TDM idle properties James Calligeros
2026-11-03 7:39 ` [PATCH v4 04/22] ASoC: dt-bindings: Add binding for Apple Silicon Mac audio James Calligeros
2026-11-03 7:58 ` sashiko-bot
2026-11-03 7:39 ` [PATCH v4 05/22] ASoC: ops: Introduce 'snd_soc_ctl_activate' James Calligeros
2026-11-03 7:39 ` [PATCH v4 06/22] ASoC: ops: Introduce 'soc_set_enum_kctl' James Calligeros
2026-11-03 8:06 ` sashiko-bot
2026-11-03 7:39 ` [PATCH v4 07/22] ASoC: card: Let 'fixup_controls' return errors James Calligeros
2026-11-03 7:39 ` [PATCH v4 08/22] ASoC: tas2770: Add compatible for TAS5770L James Calligeros
2026-11-03 7:39 ` [PATCH v4 09/22] ASoC: apple: Add macaudio machine driver James Calligeros
2026-11-03 8:28 ` sashiko-bot
2026-11-03 7:39 ` [PATCH v4 10/22] arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply James Calligeros
2026-11-03 7:39 ` [PATCH v4 11/22] arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes James Calligeros
2026-11-03 8:15 ` sashiko-bot
2026-11-03 7:40 ` [PATCH v4 12/22] arm64: dts: apple: t8103-j313: " James Calligeros
2026-11-03 8:36 ` sashiko-bot [this message]
2026-11-03 7:40 ` [PATCH v4 13/22] arm64: dts: apple: t8103-j293: " James Calligeros
2026-11-03 8:52 ` sashiko-bot
2026-11-03 7:40 ` [PATCH v4 14/22] arm64: dts: apple: t8103-j45x: Add headset " James Calligeros
2026-11-03 7:40 ` [PATCH v4 15/22] arm64: dts: apple: t8112-j413: Add speaker/headset " James Calligeros
2026-11-03 7:40 ` [PATCH v4 16/22] arm64: dts: apple: t8112-j415: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 17/22] arm64: dts: apple: t8112-j473: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 18/22] arm64: dts: apple: t8112-j493: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 19/22] arm64: dts: apple: t600x-j31x: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 20/22] arm64: dts: apple: t600x-j375: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 21/22] arm64: dts: apple: t602x-j41x: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 22/22] arm64: dts: apple: t602x-j47x: " James Calligeros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-194839@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jcalligeros99@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox