From: sashiko-bot@kernel.org
To: "Avi Weiss" <thnkslprpt@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] slimbus: preserve ports after failed disconnect
Date: Wed, 28 Oct 2026 15:06:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-188035@kernel.org> (raw)
In-Reply-To: <20261028145508.1111792-2-thnkslprpt@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] slimbus: retaining ports in slim_stream_unprepare() breaks stream re-prepare
--
commit a86f555a1b6f385fbf7a79c9ae53a6b9032ee169
Author: Avi Weiss <thnkslprpt@gmail.com>
slimbus: preserve ports after failed disconnect
This commit updates slim_disconnect_port() to set port disconnection state
only after a successful transfer, and modifies slim_stream_unprepare() to
propagate errors while retaining the port array on failure so it can be
retried or freed in slim_stream_free().
> diff --git a/drivers/slimbus/stream.c b/drivers/slimbus/stream.c
> index b4e70a7edd1cc..ab26b243802df 100644
> --- a/drivers/slimbus/stream.c
> +++ b/drivers/slimbus/stream.c
[ ... ]
> @@ -448,13 +453,22 @@ EXPORT_SYMBOL_GPL(slim_stream_disable);
> */
> int slim_stream_unprepare(struct slim_stream_runtime *stream)
> {
> - int i;
> + int ret = 0, err, i;
>
> if (!stream->ports || !stream->num_ports)
> return -EINVAL;
>
> - for (i = 0; i < stream->num_ports; i++)
> - slim_disconnect_port(stream, &stream->ports[i]);
> + for (i = 0; i < stream->num_ports; i++) {
> + if (stream->ports[i].state == SLIM_PORT_DISCONNECTED)
> + continue;
> +
> + err = slim_disconnect_port(stream, &stream->ports[i]);
> + if (err && !ret)
> + ret = err;
> + }
> +
> + if (ret)
> + return ret;
[Severity: Medium]
Can returning early here while retaining stream->ports prevent the stream
from recovering on subsequent trigger cycles and leak stream->ports?
When a SLIM_MSG_MC_DISCONNECT_PORT transaction fails in slim_do_transfer()
(for example with -ETIMEDOUT), slim_stream_unprepare() returns early with
stream->ports still allocated, while any ports processed before the failure
have already been disconnected in hardware and marked SLIM_PORT_DISCONNECTED.
The callers of this API in sound/soc/codecs/wcd9335.c (wcd9335_trigger())
and sound/soc/codecs/wcd934x.c (wcd934x_trigger()) do not retry
slim_stream_unprepare() on failure, and slim_stream_free() has no callers
in the tree:
sound/soc/codecs/wcd9335.c:wcd9335_trigger()
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
...
slim_stream_prepare(dai_data->sruntime, cfg);
slim_stream_enable(dai_data->sruntime);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
slim_stream_disable(dai_data->sruntime);
slim_stream_unprepare(dai_data->sruntime);
break;
When the stream is subsequently restarted or resumed, slim_stream_prepare()
sees the retained rt->ports pointer and rejects the call with -EINVAL:
drivers/slimbus/stream.c:slim_stream_prepare()
if (rt->ports) {
dev_err(&rt->dev->dev, "Stream already Prepared\n");
return -EINVAL;
}
As a result, slim_connect_port_channel() is skipped and the ports that were
disconnected during the partial unprepare are never reconnected. Immediately
after that, slim_stream_enable() runs and overwrites port->state on those
disconnected ports:
drivers/slimbus/stream.c:slim_stream_enable()
for (i = 0; i < stream->num_ports; i++) {
struct slim_port *port = &stream->ports[i];
slim_activate_channel(stream, port);
port->state = SLIM_PORT_CONFIGURED;
}
Furthermore, when wcd9335_slim_set_hw_params() or
wcd934x_slim_set_hw_params() is later called, dai_data->sruntime is
overwritten by a new slim_stream_allocate() call without calling
slim_stream_free(), leaking the retained stream->ports array.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261028145508.1111792-2-thnkslprpt@gmail.com?part=1
prev parent reply other threads:[~2026-10-28 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 14:55 [PATCH] slimbus: preserve ports after failed disconnect Avi Weiss
2026-10-28 15:06 ` sashiko-bot [this message]
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-188035@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=thnkslprpt@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.