All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, linux-sound@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/3] soundwire: qcom: add multi-master support
Date: Mon, 23 Nov 2026 17:38:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-229770@kernel.org> (raw)
In-Reply-To: <20261123171411.444381-3-srinivas.kandagatla@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] soundwire: qcom: missing peer reset and init in
  swrm_runtime_resume()
- [Medium] soundwire: qcom: broken peer DPn offset check in
  qcom_swrm_port_target()
--

commit 246740e00d8bf63dfe08723ccdaf279410a75753
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

soundwire: qcom: add multi-master support

This commit adds multi-master support for Qualcomm v3.1.0+ SoundWire
controllers, allowing a primary controller to pair with a dependent
controller that contributes additional DATA lanes and routes port register
accesses across the two instances.

> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index a4cb62897192e..396b57d8eb0e9 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
[ ... ]
> @@ -1091,9 +1109,48 @@ static int qcom_swrm_pre_bank_switch(struct sdw_bus *bus)
>  	u32p_replace_bits(&val, ctrl->cols_index, SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK);
>  	u32p_replace_bits(&val, ctrl->rows_index, SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK);
>  
> +	if (ctrl->peer_ctrl)
> +		ctrl->peer_ctrl->reg_write(ctrl->peer_ctrl, reg, val);
> +
>  	return ctrl->reg_write(ctrl, reg, val);
>  }
>  
> +static struct qcom_swrm_ctrl *
> +qcom_swrm_port_target(struct qcom_swrm_ctrl *ctrl, u8 port_num, u32 *reg)
> +{
> +	u8 lane;
> +
> +	if (WARN_ON_ONCE(!port_num || port_num > ctrl->nports))
> +		return ctrl;
> +
> +	lane = ctrl->pconfig[port_num].lane_control;
> +
> +	if (ctrl->peer_ctrl && lane >= ctrl->peer_first_lane &&
> +	    lane < ctrl->peer_first_lane + ctrl->num_peer_lanes) {
> +		if (WARN_ON_ONCE(*reg < ctrl->peer_dpn_offset))
> +			return ctrl;
> +		*reg -= ctrl->peer_dpn_offset;
> +		return ctrl->peer_ctrl;
> +	}
> +	return ctrl;
> +}

[Severity: Medium]
Can *reg -= ctrl->peer_dpn_offset underflow below the dependent
controller's DP1 register base when port_num <= offset?

Callers compute *reg with the SWRM_DPn_* macros as base_offset + 0x100 *
(port_num - 1) (+ 0x40 * bank), where base_offset is 0x1224..0x123c, while
qcom_swrm_multi_master_setup() sets ctrl->peer_dpn_offset to offset *
0x100 without that base address.  As a result, *reg < ctrl->peer_dpn_offset
does not catch port_num <= offset, and subtracting ctrl->peer_dpn_offset
produces an offset below DP1 (0x1224) that reads or writes non-DPn
registers on ctrl->peer_ctrl.

Also, qcom_swrm_transport_params() subtracts ctrl->peer_first_lane from
value before calling qcom_swrm_port_reg_write(), so if the WARN_ON_ONCE
fallback returns ctrl, the peer-shifted lane number is written to the
primary controller, and qcom_swrm_multi_master_setup() only checks offset
against ctrl->num_lanes rather than bounding the port offset against
ctrl->nports.

[ ... ]
> @@ -1795,6 +2028,10 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
>  	struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);
>  	int ret;
>  
> +	/* no bus of its own; the primary restarts the link */
> +	if (ctrl->mm_role == QCOM_SWRM_MM_DEPENDENT)
> +		return clk_prepare_enable(ctrl->hclk);
> +
>  	if (ctrl->wake_irq > 0) {
>  		if (!irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq)))
>  			disable_irq_nosync(ctrl->wake_irq);

[Severity: High]
Does swrm_runtime_resume() leave the dependent controller's audio_cgcr
unreset and skip re-initializing ctrl->peer_ctrl when
clock_stop_not_supported is set?

For QCOM_SWRM_MM_DEPENDENT, swrm_runtime_resume() enables ctrl->hclk and
returns without calling reset_control_reset(ctrl->audio_cgcr).  In the
primary controller's resume path, the clock_stop_not_supported branch soft
resets and calls qcom_swrm_init(ctrl) on the primary alone:

drivers/soundwire/qcom.c:swrm_runtime_resume() {
    ...
	if (ctrl->clock_stop_not_supported) {
		reinit_completion(&ctrl->enumeration);
		ctrl->reg_write(ctrl, SWRM_COMP_SW_RESET, 0x01);
		usleep_range(100, 105);

		qcom_swrm_init(ctrl);
    ...
	} else {
		reset_control_reset(ctrl->audio_cgcr);
    ...
}

Unlike qcom_swrm_probe(), which initializes both ctrl and ctrl->peer_ctrl,
a runtime suspend and resume leaves the dependent controller without an
audio_cgcr reset and out of sync with the primary (such as on the old
frame control bank after a primary reset back to bank 0), breaking data
transport on the dependent lanes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123171411.444381-1-srinivas.kandagatla@oss.qualcomm.com?part=2

  reply	other threads:[~2026-11-23 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:14 [PATCH v3 0/3] soundwire: qcom: add multi-master support Srinivas Kandagatla
2026-11-23 17:14 ` [PATCH v3 1/3] dt-bindings: soundwire: qcom: describe multi-master Srinivas Kandagatla
2026-11-23 17:14 ` [PATCH v3 2/3] soundwire: qcom: add multi-master support Srinivas Kandagatla
2026-11-23 17:38   ` sashiko-bot [this message]
2026-11-23 17:14 ` [PATCH v3 3/3] soundwire: qcom: program MM_SYNC for multi-master Srinivas Kandagatla
2026-11-24  9:52 ` [PATCH v3 0/3] soundwire: qcom: add multi-master support Vinod Koul

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-229770@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=srinivas.kandagatla@oss.qualcomm.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.