From: David Heidelberg <david@ixit.cz>
To: Srinivas Kandagatla <srini@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
David Rhodes <david.rhodes@cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
David Rhodes <drhodes@opensource.cirrus.com>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com,
devicetree@vger.kernel.org, phone-devel@vger.kernel.org
Subject: Re: [PATCH v4 7/8] slimbus: qcom-ngd-ctrl: Remove data channels on stream disable
Date: Fri, 25 Sep 2026 10:34:29 +0200 [thread overview]
Message-ID: <f15ad2f9-dfde-4156-980a-bac9596b45bf@ixit.cz> (raw)
In-Reply-To: <781fc756-bde6-4d83-a09c-19d4fd70e588@kernel.org>
On 25/09/2026 10:09, Srinivas Kandagatla wrote:
> On 9/24/26 2:24 PM, David Heidelberg via B4 Relay wrote:
>> From: David Heidelberg <david@ixit.cz>
>>
>> qcom_slim_ngd_xfer_msg() silently returns success for every core
>> reconfiguration message, so the generic channel removal done by
>> slim_stream_disable() never reaches the ADSP SLIMbus master. The
>> master therefore keeps the channels of a closed stream. When the next
>> stream defines the same channel numbers again, the WCD9340 capture
>> completes without any error but records only zeros; removing the
>> channels explicitly when the stream is disabled makes it work again.
>>
>> Implement the disable_stream controller op with the sequence the
>> downstream NGD driver sends for channel removal, CHAN_CTRL(REMOVE)
>> listing the stream's channels followed by RECONFIG_NOW. Like
>> downstream, treat -EREMOTEIO from the removal as success: it means the
>> controller is being restarted and the channels are gone anyway.
>>
>> Based on work done by Casey Tunturi.
>>
>> Assisted-by: Claude:claude-fable-5-1
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
>
> there is an identical patch on the list,
> https://lore.kernel.org/linux-arm-msm/247e4ce7-1ba2-43b8-8a11-ec70f99a4fc1@linaro.org/T/#m3b50aa43a6493f8d3b607b1607b37bf14b199f69
I was not aware, I'll try to look into it today and address the comments on the
original one (and keep the credits as LLM likely "got heavily inspired there").
David
>
> --srini
>
>
>> drivers/slimbus/qcom-ngd-ctrl.c | 81 +++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 81 insertions(+)
>>
>> diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
>> index eb0ccb31e9074..0a4859466c82d 100644
>> --- a/drivers/slimbus/qcom-ngd-ctrl.c
>> +++ b/drivers/slimbus/qcom-ngd-ctrl.c
>> @@ -1081,16 +1081,96 @@ static int qcom_slim_ngd_enable_stream(struct slim_stream_runtime *rt)
>> slim_free_txn_tid(ctrl, &txn);
>> dev_err(&sdev->dev, "TX timed out:MC:0x%x,mt:0x%x", txn.mc,
>> txn.mt);
>> }
>>
>> return ret;
>> }
>>
>> +/* CHAN_CTRL operation, bits [7:6] of the first payload byte */
>> +#define SLIM_USR_CHAN_CTRL_REMOVE 2
>> +
>> +static int qcom_slim_ngd_disable_stream(struct slim_stream_runtime *rt)
>> +{
>> + struct slim_device *sdev = rt->dev;
>> + struct slim_controller *ctrl = sdev->ctrl;
>> + struct slim_val_inf msg = {0};
>> + u8 wbuf[SLIM_MSGQ_BUF_LEN];
>> + u8 rbuf[SLIM_MSGQ_BUF_LEN];
>> + struct slim_msg_txn txn = {0,};
>> + int i, ret;
>> +
>> + txn.mt = SLIM_MSG_MT_DEST_REFERRED_USER;
>> + txn.dt = SLIM_MSG_DEST_LOGICALADDR;
>> + txn.la = SLIM_LA_MGR;
>> + txn.ec = 0;
>> + txn.msg = &msg;
>> + txn.msg->num_bytes = 0;
>> + txn.msg->wbuf = wbuf;
>> + txn.msg->rbuf = rbuf;
>> +
>> + /*
>> + * The NGD drops the core reconfiguration messages that
>> + * slim_stream_disable() uses to remove channels, so ask the master
>> + * to remove them the way the downstream NGD driver does:
>> + * CHAN_CTRL(REMOVE) listing every channel, then RECONFIG_NOW.
>> + * Without this the master keeps the channels active and a later
>> + * DEF_ACT_CHAN with the same channel numbers is a no-op, so the
>> + * data path is never re-armed and a reopened stream moves no data.
>> + */
>> + /* 5-bit client number, operation in bits [7:6] */
>> + wbuf[txn.msg->num_bytes++] = (SLIM_USR_CHAN_CTRL_REMOVE << 6) |
>> + (sdev->laddr & 0x1f);
>> +
>> + ret = slim_alloc_txn_tid(ctrl, &txn);
>> + if (ret) {
>> + dev_err(&sdev->dev, "Fail to allocate TID\n");
>> + return ret;
>> + }
>> + wbuf[txn.msg->num_bytes++] = txn.tid;
>> +
>> + for (i = 0; i < rt->num_ports; i++)
>> + wbuf[txn.msg->num_bytes++] = rt->ports[i].ch.id;
>> +
>> + txn.mc = SLIM_USR_MC_CHAN_CTRL;
>> + txn.rl = txn.msg->num_bytes + 4;
>> + ret = qcom_slim_ngd_xfer_msg_sync(ctrl, &txn);
>> + if (ret) {
>> + slim_free_txn_tid(ctrl, &txn);
>> + /* Controller restarting, the channels are gone anyway */
>> + if (ret == -EREMOTEIO)
>> + return 0;
>> + dev_err(&sdev->dev, "TX timed out:MC:0x%x,mt:0x%x", txn.mc,
>> + txn.mt);
>> + return ret;
>> + }
>> +
>> + txn.mc = SLIM_USR_MC_RECONFIG_NOW;
>> + txn.msg->num_bytes = 2;
>> + wbuf[1] = sdev->laddr;
>> + txn.rl = txn.msg->num_bytes + 4;
>> +
>> + ret = slim_alloc_txn_tid(ctrl, &txn);
>> + if (ret) {
>> + dev_err(ctrl->dev, "Fail to allocate TID\n");
>> + return ret;
>> + }
>> +
>> + wbuf[0] = txn.tid;
>> + ret = qcom_slim_ngd_xfer_msg_sync(ctrl, &txn);
>> + if (ret) {
>> + slim_free_txn_tid(ctrl, &txn);
>> + dev_err(&sdev->dev, "TX timed out:MC:0x%x,mt:0x%x", txn.mc,
>> + txn.mt);
>> + }
>> +
>> + return ret;
>> +}
>> +
>> static int qcom_slim_ngd_get_laddr(struct slim_controller *ctrl,
>> struct slim_eaddr *ea, u8 *laddr)
>> {
>> struct slim_val_inf msg = {0};
>> u8 failed_ea[6] = {0, 0, 0, 0, 0, 0};
>> struct slim_msg_txn txn;
>> u8 wbuf[10] = {0};
>> u8 rbuf[10] = {0};
>> @@ -1620,16 +1700,17 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev)
>> ctrl->framer.rootfreq = SLIM_ROOT_FREQ >> 3;
>> ctrl->framer.superfreq =
>> ctrl->framer.rootfreq / SLIM_CL_PER_SUPERFRAME_DIV8;
>>
>> ctrl->ctrl.a_framer = &ctrl->framer;
>> ctrl->ctrl.clkgear = SLIM_MAX_CLK_GEAR;
>> ctrl->ctrl.get_laddr = qcom_slim_ngd_get_laddr;
>> ctrl->ctrl.enable_stream = qcom_slim_ngd_enable_stream;
>> + ctrl->ctrl.disable_stream = qcom_slim_ngd_disable_stream;
>> ctrl->ctrl.xfer_msg = qcom_slim_ngd_xfer_msg;
>> ctrl->ctrl.wakeup = NULL;
>> ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;
>>
>> mutex_init(&ctrl->tx_lock);
>> mutex_init(&ctrl->ssr_lock);
>> spin_lock_init(&ctrl->tx_buf_lock);
>> init_completion(&ctrl->reconf);
>>
>
next prev parent reply other threads:[~2026-09-25 8:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 13:24 [PATCH v4 0/8] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
2026-09-24 13:24 ` [PATCH v4 1/8] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
2026-09-25 8:14 ` Srinivas Kandagatla
2026-09-24 13:24 ` [PATCH v4 2/8] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
2026-09-25 8:22 ` Srinivas Kandagatla
2026-09-24 13:24 ` [PATCH v4 3/8] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
2026-09-25 8:23 ` Srinivas Kandagatla
2026-09-24 13:24 ` [PATCH v4 4/8] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
2026-09-25 8:26 ` Srinivas Kandagatla
2026-09-24 13:24 ` [PATCH v4 5/8] ASoC: cs35l36: Implement set_tdm_slot to program RX and TX slots David Heidelberg via B4 Relay
2026-09-24 13:24 ` [PATCH v4 6/8] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
2026-09-24 13:24 ` [PATCH v4 7/8] slimbus: qcom-ngd-ctrl: Remove data channels on stream disable David Heidelberg via B4 Relay
2026-09-25 8:09 ` Srinivas Kandagatla
2026-09-25 8:34 ` David Heidelberg [this message]
2026-09-25 14:30 ` David Heidelberg
2026-09-24 13:24 ` [PATCH v4 8/8] arm64: dts: qcom: sdm845-google: Add WCD9340 codec and microphone capture David Heidelberg via B4 Relay
2026-09-24 14:11 ` [PATCH v4 0/8] Speakers for Pixel 3 / 3 XL Mark Brown
2026-09-24 14:13 ` David Heidelberg
2026-09-25 11:18 ` (subset) " Mark Brown
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=f15ad2f9-dfde-4156-980a-bac9596b45bf@ixit.cz \
--to=david@ixit.cz \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=devicetree@vger.kernel.org \
--cc=drhodes@opensource.cirrus.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=phone-devel@vger.kernel.org \
--cc=rf@opensource.cirrus.com \
--cc=robh@kernel.org \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
/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
all inboxes | Powered by JetHome®