devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC 09/23] ASoC: qcom: lpass: add support for optional WSA interface
Date: Fri, 13 Nov 2026 19:11:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-213518@kernel.org> (raw)
In-Reply-To: <20261113-topic-sm8650-el2-v1-9-5183f6aab9fc@linaro.org>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] ASoC: qcom: lpass: lpass_wsa_regmap_config uses RXTX
  callbacks and macros
- [Medium] ASoC: qcom: lpass: lpass_platform_pcmops_trigger() enables
  WSA IRQs on stop
- [Medium] ASoC: qcom: lpass: unchecked regmap_read() in
  lpass_platform_wsaif_irq()
- [Medium] ASoC: qcom: lpass: missing wsa_lpaif_map handling in suspend
  and resume
--

commit ee7ef8a5c6b3d75b7ea08d4564f71cd7fbf7abeb
Author: Neil Armstrong <neil.armstrong@linaro.org>

ASoC: qcom: lpass: add support for optional WSA interface

This commit adds LPASS CPU, regmap, and platform DMA support for the
optional WSA LPAIF Codec DMA interface used for speaker SoundWire buses.

> diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
> index ea8b6083529c1..d46b72c926b2b 100644
> --- a/sound/soc/qcom/lpass-cpu.c
> +++ b/sound/soc/qcom/lpass-cpu.c
> @@ -983,6 +983,16 @@ static struct regmap_config lpass_va_regmap_config = {
>  	.cache_type = REGCACHE_FLAT,
>  };
>  
> +static struct regmap_config lpass_wsa_regmap_config = {
> +	.reg_bits = 32,
> +	.reg_stride = 4,
> +	.val_bits = 32,
> +	.writeable_reg = lpass_rxtx_regmap_writeable,
> +	.readable_reg = lpass_rxtx_regmap_readable,
> +	.volatile_reg = lpass_rxtx_regmap_volatile,
> +	.cache_type = REGCACHE_FLAT,
> +};
> +
>  static unsigned int of_lpass_cpu_parse_sd_lines(struct device *dev,
>  						struct device_node *node,
>  						const char *name)

[ ... ]

> @@ -1142,6 +1161,18 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
>  		if (IS_ERR(drvdata->va_lpaif_map))
>  			return PTR_ERR(drvdata->va_lpaif_map);
>  
> +		if (drvdata->wsa_enable) {
> +			lpass_wsa_regmap_config.max_register = LPAIF_CDC_RXTX_WRDMAPER_REG(variant,
> +						variant->wsa_wrdma_channels +
> +						variant->wsa_wrdma_channel_start,
> +						LPASS_CDC_DMA_WSA_TX0);
> +
> +			drvdata->wsa_lpaif_map = devm_regmap_init_mmio(dev, drvdata->wsa_lpaif,
> +								       &lpass_wsa_regmap_config);
> +			if (IS_ERR(drvdata->wsa_lpaif_map))
> +				return PTR_ERR(drvdata->wsa_lpaif_map);
> +		}
> +
>  		ret = of_lpass_cdc_dma_clks_parse(dev, drvdata);
>  		if (ret) {
>  			dev_err(dev, "failed to get cdc dma clocks %d\n", ret);

[Severity: Medium]
Should lpass_wsa_regmap_config use dedicated WSA regmap callbacks instead
of the RXTX ones, and should max_register use LPAIF_CDC_WSA_WRDMAPER_REG()?

__lpass_rxtx_regmap_accessible() and lpass_rxtx_regmap_volatile() check
v->rxtx_* parameters and pass LPASS_CDC_DMA_RX0 / LPASS_CDC_DMA_TX3 to
LPAIF_CDC_RXTX_*_REG(), leaving the newly added v->wsa_irq_ports,
LPAIF_CDC_WSA_RDMA_INTF_REG(), and LPAIF_CDC_WSA_WRDMA_INTF_REG() unused.
Any difference between WSA and RXTX register geometry or channel counts
causes accesses on wsa_lpaif_map to fail with -EIO or return stale
REGCACHE_FLAT entries.  In addition, __lpass_rxtx_regmap_accessible()
omits adding wrdma_channel_start to i when checking
LPAIF_CDC_RXTX_WRDMACURR_REG(), so lpass_platform_pcmops_pointer() reads
of LPAIF_DMACURR_REG on WRDMA capture channels >= rxtx_wrdma_channels also
fail with -EIO:

sound/soc/qcom/lpass-cpu.c:__lpass_rxtx_regmap_accessible() {
    ...
	for (i = 0; i < v->rxtx_wrdma_channels; ++i) {
		if (reg == LPAIF_CDC_RXTX_WRDMACTL_REG(v, i + v->rxtx_wrdma_channel_start,
							LPASS_CDC_DMA_TX3))
			return true;
    ...
		if (rw == LPASS_REG_READ) {
			if (reg == LPAIF_CDC_RXTX_WRDMACURR_REG(v, i, LPASS_CDC_DMA_RX0))
				return true;
		}
    ...
}

> diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
> index e162627d6f86e..9c879a8090bbf 100644
> --- a/sound/soc/qcom/lpass-platform.c
> +++ b/sound/soc/qcom/lpass-platform.c

[ ... ]

> @@ -838,6 +937,22 @@ static int lpass_platform_pcmops_trigger(struct snd_soc_component *component,
>  			val_mask = LPAIF_IRQ_ALL(ch);
>  			val_irqen = LPAIF_IRQ_ALL(ch);
>  			break;
> +		case LPASS_CDC_DMA_WSA_RX0 ... LPASS_CDC_DMA_WSA_RX9:
> +		case LPASS_CDC_DMA_WSA_TX0 ... LPASS_CDC_DMA_WSA_TX8:
> +			ret = regmap_fields_write(dmactl->dyncclk, id, LPAIF_DMACTL_DYNCLK_OFF);
> +			if (ret) {
> +				dev_err(soc_runtime->dev,
> +					"error writing to rdmactl reg field: %d\n", ret);
> +				return ret;
> +			}
> +
> +			reg_irqclr = LPAIF_WSA_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
> +			val_irqclr = LPAIF_IRQ_ALL(ch);
> +
> +			reg_irqen = LPAIF_WSA_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
> +			val_mask = LPAIF_IRQ_ALL(ch);
> +			val_irqen = LPAIF_IRQ_ALL(ch);
> +			break;
>  		default:
>  			dev_err(soc_runtime->dev, "%s: invalid %d interface\n", __func__, dai_id);
>  			return -EINVAL;

[Severity: Medium]
In the SNDRV_PCM_TRIGGER_STOP branch of lpass_platform_pcmops_trigger(),
doesn't setting val_irqen = LPAIF_IRQ_ALL(ch) keep WSA channel interrupts
enabled in LPAIF_WSA_IRQEN_REG instead of disabling them?

reg_irqclr and val_irqclr are also never written in the stop branch.  Once
lpass_platform_pcmops_close() clears drvdata->wsa_substream[data->dma_ch],
lpass_platform_wsaif_irq() ignores any pending interrupt on that channel
without clearing LPAIF_WSA_IRQCLEAR_REG while returning IRQ_HANDLED, which
can cause an interrupt storm.

[ ... ]

> @@ -1124,6 +1245,31 @@ static irqreturn_t lpass_platform_vaif_irq(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> +static irqreturn_t lpass_platform_wsaif_irq(int irq, void *data)
> +{
> +	struct lpass_data *drvdata = data;
> +	const struct lpass_variant *v = drvdata->variant;
> +	unsigned int irqs;
> +	irqreturn_t rv;
> +	int chan;
> +
> +	rv = regmap_read(drvdata->wsa_lpaif_map,
> +			 LPAIF_WSA_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
> +
> +	/* Handle per channel interrupts */
> +	for (chan = 0; chan < LPASS_MAX_CDC_DMA_CHANNELS; chan++) {
> +		if (irqs & LPAIF_IRQ_ALL(chan) && drvdata->wsa_substream[chan]) {
> +			rv = lpass_dma_interrupt_handler(
> +						drvdata->wsa_substream[chan],
> +						drvdata, chan, irqs);
> +			if (rv != IRQ_HANDLED)
> +				return rv;
> +		}
> +	}
> +
> +	return IRQ_HANDLED;
> +}

[Severity: Medium]
What happens in lpass_platform_wsaif_irq() if regmap_read() fails?

Unlike lpass_platform_lpaif_irq() and lpass_platform_hdmiif_irq(), rv is
not checked before reading the uninitialized stack variable irqs, which
can dispatch spurious period, xrun, or bus-error events on active streams.

[ ... ]

> @@ -1359,6 +1513,34 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
>  				"error initializing va dmactl fields: %d\n", ret);
>  			return ret;
>  		}
> +
> +		if (drvdata->wsa_enable) {
> +			ret = regmap_write(drvdata->wsa_lpaif_map,
> +				LPAIF_WSA_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0x0);
> +			if (ret) {
> +				dev_err(&pdev->dev, "error writing to wsa irqen reg: %d\n", ret);
> +				return ret;
> +			}
> +			drvdata->wsaif_irq = platform_get_irq_byname(pdev, "lpass-irq-wsaif");
> +			if (drvdata->wsaif_irq < 0)
> +				return -ENODEV;
> +
> +			ret = devm_request_irq(&pdev->dev, drvdata->wsaif_irq,
> +					       lpass_platform_wsaif_irq, 0,
> +					       "lpass-irq-wsaif", drvdata);
> +			if (ret) {
> +				dev_err(&pdev->dev, "wsa irq request failed: %d\n", ret);
> +				return ret;
> +			}
> +
> +			ret = lpass_platform_alloc_wsa_dmactl_fields(&pdev->dev,
> +								     drvdata->wsa_lpaif_map);
> +			if (ret) {
> +				dev_err(&pdev->dev,
> +					"error initializing wsa dmactl fields: %d\n", ret);
> +				return ret;
> +			}
> +		}
>  	}

[Severity: Medium]
Should lpass_platform_pcmops_suspend() and lpass_platform_pcmops_resume()
also handle drvdata->wsa_lpaif_map when drvdata->wsa_enable is set?

lpass_wsa_regmap_config uses REGCACHE_FLAT, but suspend and resume only
manage hdmiif_map and lpaif_map.  If LPASS loses hardware state across
system suspend, cached WSA DMA registers are not synced on resume, and
subsequent regmap_update_bits() or regmap_fields_write() calls see the
pre-suspend values in the flat cache and skip writing to hardware.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-topic-sm8650-el2-v1-0-5183f6aab9fc@linaro.org?part=9

  reply	other threads:[~2026-11-13 19:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 18:38 [PATCH RFC 00/23] arm64: qcom: enable SM8650 audio without ADSP firmware Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 01/23] dt-bindings: clock: qcom: add SM8650 LPASS core & audio clock controllers Neil Armstrong
2026-11-13 18:57   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 02/23] clk: " Neil Armstrong
2026-11-13 19:14   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 03/23] dt-bindings: pinctrl: qcom,sm8650-lpass-lpi-pinctrl: document clocks and power domaines when ADSP is not used Neil Armstrong
2026-11-13 19:02   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 04/23] ASoC: dt-bindings: qcom,lpass: add Senary & Septenary MI2S ids Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 05/23] ASoC: dt-bindings: qcom,lpass: add WSA RX and TX channels ids Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 06/23] ASoC: dt-bindings: qcom,lpass-*-macro: document less clock when ADSP is not used Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 07/23] ASoC: dt-bindings: qcom,lpass-cpu: document the SM8650 LPASS Neil Armstrong
2026-11-13 18:57   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 08/23] ASoC: qcom: lpass-cpu: get the optional codec_mem3 clock Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 09/23] ASoC: qcom: lpass: add support for optional WSA interface Neil Armstrong
2026-11-13 19:11   ` sashiko-bot [this message]
2026-11-13 18:38 ` [PATCH RFC 10/23] ASoC: qcom: lpass-cdc-dma: add support for WSA codec DMA Neil Armstrong
2026-11-13 19:07   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 11/23] ASoC: qcom: lpass: prepare to handle multiple lpaifs for i2s Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 12/23] ASoC: qcom: lpass: add support for MI2S_SENARY & MI2S_SEPTENARY Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 13/23] ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs Neil Armstrong
2026-11-13 19:04   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 14/23] ASoC: qcom: lpass: support LPM memory type for I2S LPAIFs Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 15/23] ASoC: qcom: lpass: allocate LPM buffer memory to DAIs Neil Armstrong
2026-11-13 19:12   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 16/23] ASoC: qcom: lpass: enable the right codec_mem clock when usin LPM memory Neil Armstrong
2026-11-13 19:06   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 17/23] ASoC: qcom: add SM8650 LPASS CPU driver Neil Armstrong
2026-11-13 19:22   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 18/23] ASoC: qcom: swd: allow LPASS_CDC_DMA_WSA_RX0 as soundwire dai Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 19/23] ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu Neil Armstrong
2026-11-13 19:12   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 20/23] arm64: dts: qcom: sm8650: move EL1 Gunyah nodes to sm8650-el1.dtsi Neil Armstrong
2026-11-13 19:08   ` Val Packett
2026-11-13 19:11   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 21/23] arm64: dts: qcom: add SM8650 LPASS CPU dtsi Neil Armstrong
2026-11-13 19:18   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 22/23] arm64: dts: qcom: sm8650-valve-deckard: enable audio Neil Armstrong
2026-11-13 19:23   ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 23/23] arm64: defconfig: enable the SM8650 LPASS CPU driver Neil Armstrong

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-213518@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).