DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vishnu Santhosh" <vishnu.santhosh@oss.qualcomm.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH net-next 3/3] net: wwan: qcom_bam_dmux: enable QMAP if supported by the modem
Date: Fri, 04 Dec 2026 16:11:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-250167@kernel.org> (raw)
In-Reply-To: <20261203-qcom-bam-dmux-qmap-v1-3-abc2e80a03af@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] wwan: qcom_bam_dmux: remote_channels published before
  remote_qmap
- [Medium] wwan: qcom_bam_dmux: unconditional QMAP OPEN may break Raw-IP
  userspace
--

commit 062c491a01057c87d44c5e0253e74c1080c4ce69
Author: Vishnu Santhosh <vishnu.santhosh@oss.qualcomm.com>

net: wwan: qcom_bam_dmux: enable QMAP if supported by the modem

This commit records whether the modem sets BAM_DMUX_OPEN_QMAP in each
channel's OPEN command and sets that bit in outgoing OPEN commands for
those channels.

> diff --git a/drivers/net/wwan/qcom_bam_dmux.c b/drivers/net/wwan/qcom_bam_dmux.c
> index a7d05b1b8b123..9e82a30b16a68 100644
> --- a/drivers/net/wwan/qcom_bam_dmux.c
> +++ b/drivers/net/wwan/qcom_bam_dmux.c

[ ... ]

> @@ -247,6 +251,8 @@ static int bam_dmux_send_cmd(struct bam_dmux_netdev *bndev, u8 cmd)
>  	hdr->magic = BAM_DMUX_HDR_MAGIC;
>  	hdr->cmd = cmd;
>  	hdr->ch = bndev->ch;
> +	if (cmd == BAM_DMUX_CMD_OPEN && test_bit(bndev->ch, dmux->remote_qmap))
> +		hdr->signal = BAM_DMUX_OPEN_QMAP;

[Severity: Medium]
Can unconditionally setting BAM_DMUX_OPEN_QMAP break existing userspace
that uses plain Raw-IP directly on wwanX without attaching rmnet?

If QMAP-capable firmware starts QMAP framing as soon as it receives
BAM_DMUX_OPEN_QMAP rather than waiting for QMI WDA configuration,
bam_dmux_cmd_data() will tag incoming frames as ETH_P_MAP and drop them
without an rmnet rx_handler, while TX still sends unframed Raw-IP.

If firmware keeps Raw-IP active until QMI WDA enables QMAP, documenting
that in the commit message would clarify compatibility; otherwise this
may need to be gated on rmnet attachment or an opt-in control.

[ ... ]

> @@ -548,13 +554,17 @@ static void bam_dmux_cmd_open(struct bam_dmux *dmux, struct bam_dmux_hdr *hdr)
>  {
>  	struct net_device *netdev = dmux->netdevs[hdr->ch];
>  
> -	dev_dbg(dmux->dev, "open channel: %u\n", hdr->ch);
> +	dev_dbg(dmux->dev, "open channel: %u (signal %#x)\n", hdr->ch,
> +		hdr->signal);
>  
>  	if (__test_and_set_bit(hdr->ch, dmux->remote_channels)) {
>  		dev_warn(dmux->dev, "Channel already open: %u\n", hdr->ch);
>  		return;
>  	}
>  
> +	/* Use QMAP on our side of the channel only if the remote supports it */
> +	assign_bit(hdr->ch, dmux->remote_qmap, hdr->signal & BAM_DMUX_OPEN_QMAP);

[Severity: Medium]
Can bam_dmux_send_cmd() miss BAM_DMUX_OPEN_QMAP because remote_channels
is published before remote_qmap is updated?

When the modem opens multiple channels at startup, an already-running
bam_dmux_register_netdev_work() scans dmux->remote_channels with
for_each_set_bit() without locking or acquire ordering:

CPU0 (RX DMA callback)              CPU1 (kworker)
bam_dmux_cmd_open()                 bam_dmux_register_netdev_work()
  __test_and_set_bit(ch,
    dmux->remote_channels)
                                      for_each_set_bit(ch,
                                        dmux->remote_channels, ...)
                                      register_netdev(netdev)
                                      ...
                                      bam_dmux_netdev_open()
                                        bam_dmux_send_cmd()
                                          test_bit(ch, remote_qmap) == 0
                                            <-- omits BAM_DMUX_OPEN_QMAP
  assign_bit(ch,
    dmux->remote_qmap, ...)

The same reorder can happen on weakly ordered ARM/ARM64 systems because
neither bitmap update nor for_each_set_bit() provides release/acquire
ordering.  This leaves QMAP disabled on the channel despite modem
support.

Testing remote_channels first, updating remote_qmap before setting
remote_channels, and pairing smp_mb__before_atomic() with smp_rmb() in
bam_dmux_register_netdev_work() would ensure remote_qmap is visible
before netdev registration.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom-bam-dmux-qmap-v1-0-abc2e80a03af@oss.qualcomm.com?part=3

  parent reply	other threads:[~2026-12-04 16:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:10 [PATCH net-next 0/3] net: wwan: qcom_bam_dmux: Add QMAP support Vishnu Santhosh
2026-12-03 16:10 ` [PATCH net-next 1/3] dmaengine: qcom: bam_dma: report residue for completed RX transfers Vishnu Santhosh
2026-12-03 16:19   ` Frank Li
2026-12-04 10:10   ` Stephan Gerhold
2026-12-04 11:18     ` Nickolay Goppen
2026-12-04 11:31     ` Nickolay Goppen
2026-12-04 16:11   ` sashiko-bot
2026-12-04 17:06   ` netdev-bot+sashiko
2026-12-03 16:10 ` [PATCH net-next 2/3] net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets Vishnu Santhosh
2026-12-04 10:14   ` Stephan Gerhold
2026-12-04 17:06   ` netdev-bot+sashiko
2026-12-03 16:10 ` [PATCH net-next 3/3] net: wwan: qcom_bam_dmux: enable QMAP if supported by the modem Vishnu Santhosh
2026-12-03 19:22   ` Loic Poulain
2026-12-04 10:42   ` Stephan Gerhold
2026-12-04 16:11   ` sashiko-bot [this message]
2026-12-04 17:06   ` netdev-bot+sashiko

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-250167@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vishnu.santhosh@oss.qualcomm.com \
    --cc=vkoul@kernel.org \
    /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