From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Niranjan H Y <niranjan.hy@ti.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
yung-chuan.liao@linux.intel.com
Cc: broonie@kernel.org, ckeepax@opensource.cirrus.com,
shumingf@realtek.com, lgirdwood@gmail.com,
ranjani.sridharan@linux.intel.com, cezary.rojewski@intel.com,
peter.ujfalusi@linux.intel.com, kai.vehmanen@linux.intel.com,
vkoul@kernel.org, shenghao-ding@ti.com, baojun.xu@ti.com,
sandeepk@ti.com, Richard Fitzgerald <rf@opensource.cirrus.com>
Subject: Re: [PATCH v1 RESEND] SoundWire: Allow Prepare command for Simplified_CP_SM
Date: Mon, 9 Feb 2026 15:43:01 +0100 [thread overview]
Message-ID: <97872c17-73c9-4484-9f8e-373ed9a59a25@linux.dev> (raw)
In-Reply-To: <20260209070905.10749-1-niranjan.hy@ti.com>
On 2/9/26 08:09, Niranjan H Y wrote:
> As defined in the MIPI SoundWire specification v1-2 for
> Simplified Channel Prepare State Machine (Simplified_CP_SM):
>
> * Figure 141 for the Simplified_CP_SM in the specification
> shows the "Ready" state (NF=0, P=1) that can be reached via
> "Prepare0 OR Prepare1" transitions.
> * Table 115 (Stimulus to the Channel Prepare State Machine)
> indicates that Prepare0 and Prepare1 are read-only/"write-ignored"
> bits for Simplified_CP_SM.
>
> In TI device implementations, we've found that some devices with
> Simplified_CP_SM still benefit from receiving the Prepare command.
This is a bit weird really...
There is no such thing as a Prepare command, what is used is a regular write that sets or clears Prepare bits in port registers. If those bits are NOT read-only/write-ignored, then presumably they are writable. One could then argue the device does not follow the Simplified_CP_SM state machine but the generic one.
It would also be good to clarify when the device is actually prepared after the bits are set, if the implementation cannot guarantee that the prepared status is reached by the end of the frame where the write occurs, then it's definitively NOT a Simplified_CP_SM.
What happens is the simple_ch_prep_sm bit is not set for those devices, and the regular state machine is used instead? Is anything broken?
> This patch modifies the code to:
> 1. Send the Prepare command to all devices, including those with
> Simplified_CP_SM
> 2. Ignore errors returned by devices with Simplified_CP_SM that
> might not support this command
>
> This approach maintains compatibility with all devices while ensuring
> proper functionality of dataport operations for devices that can
> make use of the Prepare command despite using Simplified_CP_SM.
>
> Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> Tested-by: Shuming Fan <shumingf@realtek.com>
> ---
> drivers/soundwire/stream.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 38c9dbd35..33605dc83 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -504,14 +504,19 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
> sdw_do_port_prep(s_rt, prep_ch, prep ? SDW_OPS_PORT_PRE_PREP : SDW_OPS_PORT_PRE_DEPREP);
>
> /* Prepare Slave port implementing CP_SM */
> - if (!simple_ch_prep_sm) {
> - addr = SDW_DPN_PREPARECTRL(p_rt->num);
> -
> - if (prep)
> - ret = sdw_write_no_pm(s_rt->slave, addr, p_rt->ch_mask);
> - else
> - ret = sdw_write_no_pm(s_rt->slave, addr, 0x0);
> + /* For Simplified_CP_SM, MIPI SoundWire specification v1-2 indicates
> + * Prepare bits are "write-ignored" - this means devices may ignore the command.
> + * Some devices still benefit from receiving this command even when using
> + * Simplified_CP_SM, so we send it to all devices and ignore errors from those
> + * that don't support it.
> + */
> + addr = SDW_DPN_PREPARECTRL(p_rt->num);
> + if (prep)
> + ret = sdw_write_no_pm(s_rt->slave, addr, p_rt->ch_mask);
> + else
> + ret = sdw_write_no_pm(s_rt->slave, addr, 0x0);
>
> + if (!simple_ch_prep_sm) {
> if (ret < 0) {
> dev_err(&s_rt->slave->dev,
> "Slave prep_ctrl reg write failed\n");
> @@ -530,6 +535,11 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
> "Chn prep failed for port %d: %d\n", prep_ch.num, ret);
> return ret;
> }
> + } else {
> + /* Some device return error for the prepare command,
> + * ignore the error for Simplified CP_SM
that comment is misleading anyways, it's not 'some device' it's ALL the conformant devices that will return Command_Ignored when trying to write read-only bits. You haven't described what the TI devices would return in this case.
> + */
> + ret = 0;
> }
>
> /* Inform slaves about ports prepared */
next prev parent reply other threads:[~2026-02-09 14:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 7:09 Niranjan H Y
2026-02-09 14:43 ` Pierre-Louis Bossart [this message]
2026-02-10 11:08 ` Holalu Yogendra, Niranjan
2026-02-10 17:04 ` Pierre-Louis Bossart
2026-02-10 17:29 ` Richard Fitzgerald
2026-02-10 20:28 ` Pierre-Louis Bossart
2026-02-11 10:41 ` Richard Fitzgerald
2026-02-12 16:17 ` [EXTERNAL] " Holalu Yogendra, Niranjan
2026-02-12 16:28 ` Richard Fitzgerald
2026-02-13 14:56 ` Pierre-Louis Bossart
2026-02-14 16:42 ` Holalu Yogendra, Niranjan
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=97872c17-73c9-4484-9f8e-373ed9a59a25@linux.dev \
--to=pierre-louis.bossart@linux.dev \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=ckeepax@opensource.cirrus.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=niranjan.hy@ti.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=rf@opensource.cirrus.com \
--cc=sandeepk@ti.com \
--cc=shenghao-ding@ti.com \
--cc=shumingf@realtek.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.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
Powered by JetHome