[PATCH net-next v12 3/6] net: wwan: t9xx: Add control DMA interface

Wu. JackBB (GSM) JackBB_Wu at compal.com
Sun Nov 22 19:06:30 PST 2026


Thanks for the review.

> 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.

The code is right here, but the comment in mtk_cldma_drv_init() is
wrong: it says the device can lose its queue state, which suggests an RX
queue can lose its address on its own.  v13 rewords it to say what
actually happens: a TX start address reads zero after the device has
powered the block down.

In this series a zero SO_CUR_ADDR with need_restart clear means the link
is dead: every host-side reset sets need_restart under rearm_lock before
this worker can take that lock.  t7xx detects lost state on TX
submission only, in the same way.

> 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?

Will fix in v13: the drain loop in mtk_cldma_rxq_free() checks req->skb
first, as the loop in mtk_cldma_rx_done_work() does.  A well-behaved
device cannot get there, since the host zeroes data_recv_len when it
reaps the slot and the device stops at the unarmed descriptor before it,
but the field is device-writable.

> 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.

No functional change; the comment above mtk_cldma_hw_recovery() will say
what a zero start address means.

The host never leaves a published TX queue without a start address, so a
zero is read only after the device has powered the block down.  That
clears the configuration and the start addresses of all its TX queues
together and leaves no TX engine running.  Re-arming only the affected
queue, as t7xx does, would leave the descriptors already submitted on
the other queues waiting for their next submission.  An RX queue is
restarted from its own worker, which stops it first later in the series.

> 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?

Will fix in v13: TRB_CMD_STOP and TRB_CMD_RECOVER are removed, together
with the early completion in mtk_pcie_hif_submit_skb(). Nothing in the
series issues them.

Thanks,
Jack

pw-bot: cr


More information about the Linux-mediatek mailing list