From: netdev-bot+sashiko@kernel.org
To: vishnu.santhosh@oss.qualcomm.com
Cc: stephan@gerhold.net, andrew+netdev@lunn.ch, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com,
johannes@sipsolutions.net, edumazet@kernel.org,
linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
deepak.singh@oss.qualcomm.com
Subject: Re: [PATCH net-next v6 2/2] net: wwan: qcom_bam_dmux: Assign restricted DMA pool to remote processor
Date: Mon, 16 Nov 2026 13:54:32 +0000 [thread overview]
Message-ID: <179483727219.3136.17411591489340995392@kernel.org> (raw)
In-Reply-To: <20261112-qcom-bam-dmux-vmid-ext-v6-2-7a16bd3dff18@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 4 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch does not do what the commit message says for BAM
descriptor FIFOs.
- [Medium] The driver can unbind while the restricted DMA pool is still
assigned to {HLOS, vmid}, and then it loses the only record of that.
- [Medium] Requesting the PC IRQ with IRQF_NO_AUTOEN and enabling it only
at the end of bam_dmux_probe() means any change in the remote's power-…
- [Medium] bam_dmux_remove() decides whether to take the restricted DMA
pool away from the remote VM using the cached software flag…
--
net: wwan: qcom_bam_dmux: Assign restricted DMA pool to remote processor
When qcom,vmid is present, this patch requires a restricted DMA pool to
be attached to the device. It then calls qcom_scm_assign_mem() to share
that pool between HLOS and the modem VMID before the DMA channels are
requested. The pool is handed back to HLOS on remove or on a probe
error, unless the remote still holds its power vote, and the PC IRQ is
now requested with IRQF_NO_AUTOEN and enabled at the end of probe.
> diff --git a/drivers/net/wwan/qcom_bam_dmux.c b/drivers/net/wwan/qcom_bam_dmux.c
> index 1479f8362e04e..04f3d46d4c3f3 100644
> --- a/drivers/net/wwan/qcom_bam_dmux.c
> +++ b/drivers/net/wwan/qcom_bam_dmux.c
[ ... ]
> @@ -760,6 +766,88 @@ static int __maybe_unused bam_dmux_runtime_resume(struct device *dev)
> return 0;
> }
>
> +static int bam_dmux_assign_dma_pool(struct bam_dmux *dmux)
> +{
> + struct device *dev = dmux->dev;
> + struct device_node *rmem_np;
> + struct reserved_mem *rmem;
> + struct qcom_scm_vmperm dst[2];
> + u64 src = BIT_ULL(QCOM_SCM_VMID_HLOS);
[ ... ]
> + if (!is_swiotlb_for_alloc(dev))
> + return dev_err_probe(dev, -EINVAL,
> + "Restricted DMA pool not attached\n");
[Severity: Medium]
Does this cover the BAM descriptor FIFOs the way the commit message
describes? The commit message says:
"BAM-DMUX DMA mappings and BAM descriptor FIFOs must therefore be
constrained to a designated memory region"
and:
"When the BAM DMA controller references the same pool, its descriptor
FIFOs are covered by the assignment as well."
The FIFOs are allocated on the BAM DMA controller's own device, not on
dmux->dev:
drivers/dma/qcom/bam_dma.c:bam_alloc_chan() {
...
bchan->fifo_virt = dma_alloc_wc(bdev->dev, BAM_DESC_FIFO_SIZE,
&bchan->fifo_phys, GFP_KERNEL);
...
}
The FIFOs only come from the restricted pool if the BAM DMA node has its
own memory-region that points at the restricted-dma-pool. The binding
doesn't allow that. qcom,bam-dma.yaml has no memory-region property and
sets additionalProperties: false, and this series only updates
qcom,bam-dmux.yaml.
The check here only looks at is_swiotlb_for_alloc(dmux->dev). Nothing
checks the device behind the rx/tx channels.
With a DT that follows the bindings, probe would succeed without a
warning. Meanwhile, bam_dmux_power_on()->dma_request_chan()->
bam_alloc_chan() would allocate the FIFOs outside the assigned region.
Wouldn't that leave the XPU violation the patch is meant to prevent?
Is a bam-dma binding update or a check on the channel device needed
here?
[ ... ]
> +static void bam_dmux_reclaim_dma_pool(struct bam_dmux *dmux)
> +{
> + struct qcom_scm_vmperm hlos = {
> + .vmid = QCOM_SCM_VMID_HLOS,
> + .perm = QCOM_SCM_PERM_RW,
> + };
> + u64 src = dmux->dma_pool_perms;
> + int ret;
> +
> + if (!dmux->dma_pool_perms)
> + return;
> +
> + ret = qcom_scm_assign_mem(dmux->dma_pool_base, dmux->dma_pool_size, &src,
> + &hlos, 1);
> + if (ret) {
> + dev_err(dmux->dev, "SCM reclaim restricted DMA pool failed: %d\n", ret);
> + return;
> + }
[Severity: Medium]
What happens to the pool ownership when this call fails? The same
question applies when bam_dmux_remove() skips the reclaim on purpose
because pc_state is still set:
if (!dmux->pc_state)
bam_dmux_reclaim_dma_pool(dmux);
else if (dmux->dma_pool_perms)
dev_warn(dev, "Leaving restricted DMA pool assigned to remote\n");
In both cases the region stays assigned to HLOS and the modem VMID. The
only record of that is dmux->dma_pool_perms, which lives in the
devm_kzalloc'd struct bam_dmux. devres frees it as soon as remove() or
the failed probe returns.
On the next probe (module reload, sysfs rebind, deferred re-probe),
bam_dmux_assign_dma_pool() always starts from:
u64 src = BIT_ULL(QCOM_SCM_VMID_HLOS);
That no longer matches the real owners (HLOS | vmid). Hyp-assign checks
the source VM list against the current ownership, which is why users
such as rmtfs_mem keep their perms around for the reclaim.
Wouldn't qcom_scm_assign_mem() then fail with "SCM assign restricted DMA
pool failed" on every probe until reboot?
The commit message says the execution environments are tracked
explicitly for the reclaim. Isn't that record lost in exactly the unbind
case it is meant to handle?
> +
> + dmux->dma_pool_perms = 0;
> +}
[ ... ]
> @@ -821,7 +913,7 @@ static int bam_dmux_probe(struct platform_device *pdev)
> goto err_disable_pm;
>
> ret = devm_request_threaded_irq(dev, dmux->pc_irq, NULL, bam_dmux_pc_irq,
> - IRQF_ONESHOT, NULL, dmux);
> + IRQF_ONESHOT | IRQF_NO_AUTOEN, NULL, dmux);
> if (ret)
> goto err_disable_pm;
>
> @@ -838,11 +930,14 @@ static int bam_dmux_probe(struct platform_device *pdev)
> bam_dmux_power_off(dmux);
> }
>
> + enable_irq(dmux->pc_irq);
[Severity: Medium]
Can a remote power-control transition get lost between the line-level
sample and this enable_irq()? In bam_dmux_probe() the sequence is now:
ret = irq_get_irqchip_state(dmux->pc_irq, IRQCHIP_STATE_LINE_LEVEL,
&dmux->pc_state);
...
if (dmux->pc_state) {
if (bam_dmux_power_on(dmux))
...
enable_irq(dmux->pc_irq);
With IRQF_NO_AUTOEN, __setup_irq() skips irq_startup(), so the smp2p
and smsm unmask callbacks don't run until enable_irq(). During that
window, qcom_smp2p_notify_in() still updates last_value but only
dispatches bits set in irq_enabled:
drivers/soc/qcom/smp2p.c:qcom_smp2p_notify_in() {
...
status = val ^ entry->last_value;
entry->last_value = val;
...
for_each_set_bit(i, entry->irq_enabled, 32) {
...
}
smsm_intr() also updates last_value, and smsm_unmask_irq() resyncs the
cached state when the IRQ is enabled:
drivers/soc/qcom/smsm.c:smsm_unmask_irq() {
...
/* Make sure our last cached state is up-to-date */
assign_bit(irq, &entry->last_value,
readl(entry->remote_state) & BIT(irq));
...
}
handle_nested_irq() is never called, so IRQS_PENDING is never set and
enable_irq() has nothing to resend.
bam_dmux_pc_irq() flips the cached value instead of reading the line:
bool new_state = !dmux->pc_state;
A single missed edge would therefore leave the driver's view inverted
from then on. The remote's transition is never acked, later edges are
handled with the wrong polarity, and the pc_state check in
bam_dmux_remove() that gates the pool reclaim is wrong too.
When the modem is already up at probe time, the window also covers
bam_dmux_power_on() (dma_request_chan(), skb allocation, DMA mapping).
IRQF_NO_AUTOEN is set unconditionally. Wouldn't this regression affect
every BAM-DMUX platform, not just the ones with qcom,vmid?
>
> return 0;
>
> err_disable_pm:
> pm_runtime_disable(dev);
> pm_runtime_dont_use_autosuspend(dev);
> + bam_dmux_reclaim_dma_pool(dmux);
> return ret;
> }
>
> @@ -877,6 +972,12 @@ static void bam_dmux_remove(struct platform_device *pdev)
> disable_irq(dmux->pc_irq);
> bam_dmux_power_off(dmux);
> bam_dmux_free_skbs(dmux->tx_skbs, DMA_TO_DEVICE);
> +
> + /* The remote side may still access the pool if it holds its power vote */
> + if (!dmux->pc_state)
> + bam_dmux_reclaim_dma_pool(dmux);
> + else if (dmux->dma_pool_perms)
> + dev_warn(dev, "Leaving restricted DMA pool assigned to remote\n");
[Severity: Medium]
Can dmux->pc_state still be trusted at this point? Once
disable_irq(dmux->pc_irq) has run above, bam_dmux_pc_irq() no longer
runs. pc_state then shows the last edge that was processed, not the
remote's current power vote.
The RX side is started by the remote. The comment in probe says "the RX
path may be active even if we are runtime suspended, since it is
controlled by the remote side".
Suppose the remote raises its vote after disable_irq(), or pc_state is
already inverted by the lost edge in bam_dmux_probe(). This code would
still call bam_dmux_reclaim_dma_pool() and remove the modem VMID while
the remote holds its vote.
That seems to contradict the commit message:
"Skip the reclaim and leave the pool assigned if the remote side still
holds its power vote, since it may still access the pool."
Should the line level be read again here before deciding whether to
reclaim, for example with irq_get_irqchip_state(dmux->pc_irq,
IRQCHIP_STATE_LINE_LEVEL, ...)?
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-qcom-bam-dmux-vmid-ext-v6-0-7a16bd3dff18%40oss.qualcomm.com
next prev parent reply other threads:[~2026-11-16 13:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 9:13 [PATCH net-next v6 0/2] net: wwan: qcom_bam_dmux: Add restricted DMA pool support Vishnu Santhosh
2026-11-12 9:13 ` [PATCH net-next v6 1/2] dt-bindings: net: qcom,bam-dmux: Add memory-region and qcom,vmid properties Vishnu Santhosh
2026-11-16 13:54 ` netdev-bot+sashiko
2026-11-12 9:13 ` [PATCH net-next v6 2/2] net: wwan: qcom_bam_dmux: Assign restricted DMA pool to remote processor Vishnu Santhosh
2026-11-16 13:54 ` netdev-bot+sashiko [this message]
2026-11-16 14:43 ` Loic Poulain
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=179483727219.3136.17411591489340995392@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=deepak.singh@oss.qualcomm.com \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=ryazanov.s.a@gmail.com \
--cc=stephan@gerhold.net \
--cc=vishnu.santhosh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®