Re: [PATCH v4 09/22] ASoC: apple: Add macaudio machine driver
From: Mark Brown
Date: Mon Nov 09 2026 - 16:00:52 EST
> Apple Silicon Macs have a complex audio subsystem consisting
> of an I2S peripheral (MCA) and multiple codecs of various
> models and capabilities. Some machines have a basic mono
> speaker with hardware downmix, while others have a very
> intricate stereo system consisting of multiple codecs and
> drivers per L/R channel. Some machines report voice coil
> voltage and current information back to the SoC, and others
> do not. All machines have a headset jack.
> +#include <sound/simple_card_utils.h>
This is unused.
> +static void macaudio_vlimit_update(struct macaudio_snd_data *ma, bool take_rwsem)
> +{
> + bool unlock = true;
> + const char *reason;
> + /*
> + * If this has been called from either of the safety interlock
> + * workqueues, the core API has not taken controls_rwsem for us.
> + * Take the write semaphore since macaudio_vlimit_unlock writes
> + * to the kcontrols.
> + */
> + if (take_rwsem)
> + down_write(&ma->card.snd_card->controls_rwsem);
The callers with take_rwsem all have volume_lock_mutex.
macaudio_slk_put() is called from snd_ctl_elem_write() which has
controls_rwsem already so we end up with an ABBA deadlock.
> +static int macaudio_parse_of_component(struct device_node *node, int index,
> + struct snd_soc_dai_link_component *comp)
> +{
> + struct of_phandle_args args;
> + int ret;
> +
> + ret = of_parse_phandle_with_args(node, "sound-dai", "#sound-dai-cells",
> + index, &args);
> + if (ret)
> + return ret;
> + comp->of_node = args.np;
This gets cleaned up on failure but not on success.
> + 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;
> +
We don't otherwise check the return value before we start overwriting
it.
> + /* Fallback, jack only */
> + { .compatible = "apple,macaudio"},
The cover letter said this was dropped and the binding did so.
> +static void macaudio_devm_release(void *data)
> +{
> + struct macaudio_snd_data *ma = data;
> +
> + cancel_work_sync(&ma->lock_update_work);
> + cancel_delayed_work_sync(&ma->lock_timeout_work);
> +}
This is registered before we register the card with devm but these work
items use the card, they need to be stopped first.
> + 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;
> + }
The action registration doesn't do the unwind that the card registration
does.
--
Mark Brown <broonie@xxxxxxxxxx>