Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jackbb_wu@compal.com
Cc: loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com,
	johannes@sipsolutions.net, andrew+netdev@lunn.ch,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	wen-zhi.huang@mediatek.com, shi-wei.yeh@mediatek.com,
	Minano.tseng@mediatek.com, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com, horms@kernel.org,
	corbet@lwn.net, skhan@linuxfoundation.org, robert_yu@compal.com,
	Jeff_Chang@compal.com, edumazet@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next v12 3/6] net: wwan: t9xx: Add control DMA interface
Date: Sat, 21 Nov 2026 12:42:27 +0000	[thread overview]
Message-ID: <179526494702.3135.6051033006782624225@kernel.org> (raw)
In-Reply-To: <20261117-t9xx_driver_v1-v12-3-e181b616b820@compal.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 1

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] In mtk_cldma_rxq_free()
  (drivers/net/wwan/t9xx/pcie/mtk_cldma.c), the final ring-drain loop…
- [Medium] mtk_cldma_hw_recovery() runs from mtk_cldma_start_xfer() when
  one TX queue's UL start-address register reads 0.
- [Medium] The driver says the CLDMA 'can lose its queue state, which
  leaves zero addresses' (comment in mtk_cldma_drv_init()).
- [Low] The patch adds TRB_CMD_STOP and TRB_CMD_RECOVER to the shared
  enum mtk_trb_cmd_type in mtk_ctrl_plane.h, but nothing implements them.

--

net: wwan: t9xx: Add control DMA interface

This adds the CLDMA (Cross Layer DMA) control-plane transport for the
t9xx WWAN driver. It covers the GPD ring handling for the TX and RX
queues, the reset and re-arm logic for an instance, and a TRB service
layer. Probe now attaches the transport context through the new
mtk_pci_dev_init()/mtk_pci_dev_exit() hooks.

> diff --git a/drivers/net/wwan/t9xx/pcie/mtk_cldma.c b/drivers/net/wwan/t9xx/pcie/mtk_cldma.c
> new file mode 100644
> index 0000000000000..c0bafb39e4f5a
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_cldma.c
> @@ -0,0 +1,1207 @@

[ ... ]

> +static void mtk_cldma_rx_done_work(struct work_struct *work)
> +{

[ ... ]

> +	ret = mtk_cldma_check_rx_req(drv_info, rxq);
> +	if (!ret)
> +		goto again;
> +
> +	/* -ENXIO means the queue has no start address programmed, which is
> +	 * exactly what a restart installs, so consume need_restart first.
> +	 * Only the resume below is skipped in that case.
> +	 */
> +	mutex_lock(&drv_info->rearm_lock);
> +	if (!atomic_read(&rxq->need_exit)) {
> +		if (atomic_xchg(&rxq->need_restart, 0)) {
> +			if (!mtk_cldma_rxq_restart(drv_info, rxq)) {
> +				atomic_set(&rxq->need_restart, 1);
> +				mutex_unlock(&drv_info->rearm_lock);
> +				goto again;
> +			}
> +		} else if (ret != -ENXIO) {
> +			mtk_cldma_resume_queue(drv_info, DIR_RX, rxq->rxqno);
> +		}
> +	}
> +	mutex_unlock(&drv_info->rearm_lock);
> +
> +	if (ret == -ENXIO)
> +		goto out;

[Severity: Medium]
What brings this RX queue back when mtk_cldma_check_rx_req() returns
-ENXIO and need_restart is clear?

mtk_cldma_check_rx_req() treats a zero SO_CUR_ADDR as lost state:

    curr_addr = mtk_cldma_get_rx_curr_addr(drv_info, rxq->rxqno);
    if (unlikely(!curr_addr))
        return -ENXIO;

The comment in mtk_cldma_drv_init() also says the device "can lose its
queue state, which leaves zero addresses".

In that case this worker skips the resume and goes to out. That path
unmasks XFER_DONE and returns. It does not set need_restart, restart
the queue or schedule any recovery.

An RX engine with no address should not raise another XFER_DONE, so
nothing reruns this worker. The only lost-state recovery is in the TX
submit path:

    mtk_cldma_start_xfer()
        if (unlikely(!val))
            mtk_cldma_hw_recovery()

Could RX on this CLDMA instance stay stuck until the host happens to
submit a TX on the same instance? On CLDMA0 (the SAP control channel),
host TX may be rare after the handshake. Unsolicited device-to-host
control messages could then sit there indefinitely.

This depends on SO_CUR_ADDR reading 0 after the state is lost, which
the driver's own comments say can happen.

[ ... ]

> +static void mtk_cldma_rxq_free(struct cldma_drv_info *drv_info, u32 rxqno)
> +{

[ ... ]

> +	/* free rx req resource */
> +	for (i = 0; i < rxq->nr_gpds; i++) {
> +		req = rxq->req_pool + rxq->free_idx;
> +		if (!(req->gpd->rx_gpd.gpd_flags & CLDMA_GPD_FLAG_HWO) &&
> +		    le16_to_cpu(req->gpd->rx_gpd.data_recv_len)) {
> +			if (!mtk_cldma_rx_skb_adjust(mdev, req)) {
> +				rxq->rx_done(req->skb, rxq->arg);
> +				req->skb = NULL;
> +			}
> +		}

[Severity: Medium]
Can req->skb be NULL when this loop reaches mtk_cldma_rx_skb_adjust()?

In mtk_cldma_rx_done_work(), if both the reload and the recycle
dma_map_single() fail, the slot is left empty:

    dev_kfree_skb_any(rx_skb);
    req->skb = NULL;
    req->data_dma_addr = 0;
    goto out_retry;

The leading refill for an empty slot (the !req->skb branch) can also
fail and jump to out_retry. The cancel_work_sync() earlier in
mtk_cldma_rxq_free() can then cancel the requeued retry before the
slot is refilled.

mtk_cldma_rx_skb_adjust() dereferences req->skb unconditionally:

    req->skb->len = 0;
    skb_reset_tail_pointer(req->skb);
    skb_put(req->skb, recv_len);

mtk_cldma_rx_skb_adjust() already zeroed data_recv_len for that slot.
To get here, the device would have to write a non-zero data_recv_len
into a GPD with HWO clear, which it does not own. The driver already
treats data_recv_len as device-controlled and clamps it against mtu.

If that happens, would closing the channel oops on a NULL skb? Would a
req->skb check here, like the one at the top of the loop in
mtk_cldma_rx_done_work(), be enough?

[ ... ]

> +/* The device reported a zero TX start address: it lost its queue state. */
> +static int mtk_cldma_hw_recovery(struct cldma_drv_info *drv_info, u32 qno)
> +{
> +	u64 val;
> +
> +	dev_err(drv_info->mdev->dev,
> +		"CLDMA%d lost its queue state, re-initializing\n",
> +		drv_info->hw_id);
> +
> +	mtk_cldma_rearm_queues(drv_info);

[Severity: Medium]
Is it safe to re-arm the whole instance here without a stop or a
mtk_cldma_drv_reset() first?

mtk_cldma_txq_free() and mtk_cldma_rxq_free() both reset the IP before
they call mtk_cldma_rearm_queues(). Here, the only evidence is that
one TX queue's UL start address read back as zero.

mtk_cldma_rearm_queues() then does three things:

  - mtk_cldma_drv_init() read-modify-writes UL_CFG and SO_CFG (the GPD
    format bits) and other IP-global registers.

  - On every published TX queue with tx_started set, it reprograms the
    start address and issues UL_START.

  - On every published RX queue, it sets need_restart, so
    mtk_cldma_rx_done_work() later reprograms SO_START_ADDR and issues
    SO_START.

What if a zero read on one queue does not mean the whole instance was
reset? Sibling TX and RX engines could still be running when they get
these CFG writes and START commands.

On TX, a START at the GPD currently being sent could resend or cut
that control message. On RX, a restart could lose or corrupt the frame
being written.

If the hardware only reads zero after a full IP reset, the other
engines are already idle and this does not apply. For comparison, the
t7xx driver re-initializes in a similar way without a stop, but only
reprograms the affected queue.

[ ... ]

> diff --git a/drivers/net/wwan/t9xx/pcie/mtk_trans_ctrl.c b/drivers/net/wwan/t9xx/pcie/mtk_trans_ctrl.c
> new file mode 100644
> index 0000000000000..3650878128a27
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_trans_ctrl.c
> @@ -0,0 +1,614 @@

[ ... ]

> +int mtk_pcie_hif_submit_skb(struct mtk_md_dev *mdev, struct sk_buff *skb, bool force_send)
> +{
> +	struct mtk_ctrl_blk *ctrl_blk = mdev->ctrl_blk;
> +	struct mtk_ctrl_trans *trans;
> +	struct queue_info *que;
> +	struct trb *trb;
> +	int ret;
> +
> +	trans = ctrl_blk->ctrl_hw_priv;
> +	trb = (struct trb *)skb->cb;
> +
> +	if (trb->cmd == TRB_CMD_STOP || trb->cmd == TRB_CMD_RECOVER) {
> +		trb->trb_complete(skb);
> +		return 0;
> +	}

[Severity: Low]
TRB_CMD_STOP and TRB_CMD_RECOVER are added to enum mtk_trb_cmd_type in
mtk_ctrl_plane.h, but nothing implements them. The commit message does
not mention them either.

Here they complete immediately and never set trb->status. They also
skip the trans->available check and submit_lock.
mtk_cldma_trb_process() rejects them in any case:

    if (!(trb->cmd > TRB_CMD_MIN && trb->cmd < TRB_CMD_STOP))
        return -EINVAL;

A caller trying to stop or recover a queue would get a successful
completion, with whatever status was left in skb->cb, while the queue
keeps running.

No caller in the series issues these commands yet. Could they be
dropped, or rejected with something like -EOPNOTSUPP until they are
implemented?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-t9xx_driver_v1-v12-0-e181b616b820%40compal.com


  reply	other threads:[~2026-11-21 12:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 10:50 [PATCH net-next v12 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-17 10:50 ` [PATCH net-next v12 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-17 15:28   ` Loic Poulain
2026-11-18  2:41     ` [External Mail] " Wu. JackBB (GSM)
2026-11-21 12:42   ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-17 15:31   ` Loic Poulain
2026-11-18  2:44     ` Wu. JackBB (GSM)
2026-11-17 10:50 ` [PATCH net-next v12 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-21 12:42   ` netdev-bot+sashiko [this message]
2026-11-17 10:50 ` [PATCH net-next v12 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-21 12:42   ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-21 12:42   ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay

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=179526494702.3135.6051033006782624225@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Jeff_Chang@compal.com \
    --cc=Minano.tseng@mediatek.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jackbb_wu@compal.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robert_yu@compal.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=shi-wei.yeh@mediatek.com \
    --cc=skhan@linuxfoundation.org \
    --cc=wen-zhi.huang@mediatek.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