🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20128

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

#20128
From: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 12:42
247 lines
16842 bytes
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
Technical Details
Message-ID: <179526494702.3135.6051033006782624225@kernel.org>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368333-linux-kernel-netdev=dewy.ru
References: <20261117-t9xx_driver_v1-v12-3-e181b616b820@compal.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368333-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v12 3/6] net: wwan: t9xx: Add control DMA interface
Date: Sat, 21 Nov 2026 12:42:27 +0000
Organization: Usenet Network
Message-ID: <179526494702.3135.6051033006782624225@kernel.org>
References: <20261117-t9xx_driver_v1-v12-3-e181b616b820@compal.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3411012"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mFsdcVnZq3Xf5u6f16atnipKTfM= sha256:57AQjMuqGqMZkwWEk5lVd3Rdw6I1p/lwVWdL/me6CqQ=
	sha1:cbh40Mk/55ZCeawMy4E1rptGGuE= sha256:J6gVYzUuM3LYcykc7Oq0/e+8rJxXm9kUISw0fd6yVnE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 9150B115B54; Sat, 21 Nov 2026 15:43:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id h0mpbcj5iEXV;
	Sat, 21 Nov 2026 15:42:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368333-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 676CC115B5E; Sat, 21 Nov 2026 15:42:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 5BE8F3EDD6; Sat, 21 Nov 2026 12:42:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795264955;
	b=b+V5j0zEd2w1zVriagCk47PlnRf1G0HB5Zry5UYMc+02FV+2Y6ywtnEbclkPepKSRmLF
	 pvN+pn2E/iLDhGc1L1I/7ESmadI14nwt+hCY9wPfpQ7TPaYBtturC4b6DZRZ1hqXPVONm
	 lDs4GJjPlsx38mCEa1XqhJSFBv26HwLmq2UgOsEjnYNl3BXTHNl9UnpV5oHwnl/ZNKwmv
	 cQ4npFKBjGcJF97XHeHIEF7D8ftABF3MRMsAThxp335PfgEW+7EgPTU2u4tay8n26dBSD
	 scexFRVhUcvT2Jw+GJ3+/vIuTzIm/BJG7xtV004WhJWTXPzzQa0C5QJytwJZAdOWgkw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795264955;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=LLtVvNcvdiWE9Bm0C9C4fhNTth/wg7FRqwbs/4Sj6Dk=;
	b=wVNGw4QhTb4TAZWzOf14fAV7jvATkhGv6zop+ag/z5RZzj6W7dBFiaGyGA9fYXlrULdM
	 KNdbKoN5DQxhMIMqMcU50OIXohCgti3hsyj5JNiVyDMsIVUese5JTUkbsciM8dwfRgMB1
	 za3GVdcdfDd3mIkVeQmxC1eduoVhOIog5etz/i5sgWDdGhLy+FQl90iUuqTyGz/KZ0AV1
	 rG5E69YC2AJVbSm7mTdx+RgYY16n3i/LpBu7eVoMPYlJv0B5b7S0VQ1hQscRTWAA5d3Jk
	 qamVFBgUWNqROdqpj7/nKpAmXwwF2x8FqsM4dp2tT1R7OJDN0eIk22KZG0cCERGid5g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=echgHL+0;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E61606A335;
	Sat, 21 Nov 2026 12:42:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=echgHL+0
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795264949;
	b=QoH/+VaRnCdN3o9Y1+dYXhz5dDWPj0BTQYPfrJFe7BmM1hudjByFGVlIeOKJyk31IYPX
	 dYn4oUD1huO446L+jPXVkXmDNV3MRhQ6FsAc2B6SHbtGjk0YuBMAO5u4rxOXe8ZoUhLLj
	 n18GzxWKd55M8mYexzYbh+tUNqCSIFukoetypS6H/14wzIQgAwyoF28LfUVbf0W6fVgcX
	 WI0HyRniVQUng5+gOOTV6iVjuLRnP8Iu9OBkOas+a3Q6z3PV5zLjt4/C4x/FOTFGlECq7
	 PIKC9NN6TD74MzXYdgDS0Wv/G0d2cmr6InE3rZeiR1n7GN5mLIJ9bl74IJatB0JY5QA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795264949;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=LLtVvNcvdiWE9Bm0C9C4fhNTth/wg7FRqwbs/4Sj6Dk=;
	b=JPt0azhcBcmg5pgiG2kcseyap50H8nqaCu+f0/FCp02rKohqOSAFNPJSZSxo7goxvKum
	 jf09vHIPJKENKW2pgtPc8OpvXnv5NXO7nZ5h5ebD+q1vU0+lpC99ETwRvS2QB2YUl6g8B
	 zeYc0GYIdy6L8pNjNODCYq2sEIXxMicrYmL60qcsLjw5tnWAER3HmkmDXO0UWYwJ9kBHu
	 z7j5IEiuCe3DL5fI0Jh3xndI3m6V0veKu5ryj9KdRxRmjxcaVsZPtWNY4EQiYx45yJTrf
	 LMqYz6yL/7QftEeVNqvR6LRNGm2Ity2EV29vopnsHNFScSHzLqo5nBMM43oV/cyQVoA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=echgHL+0;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54454606A686;
	Sat, 21 Nov 2026 12:42:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FFC81F000C4;
	Sat, 21 Nov 2026 12:42:27 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795264948;
	bh=LLtVvNcvdiWE9Bm0C9C4fhNTth/wg7FRqwbs/4Sj6Dk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=echgHL+0OoagPMZ9zwm/xjZ2yloMB9WT+OohPiIJP8INhpDnZJEydHCfxrUVUKR2V
	 FqQW6sGNyudsW3Qike7vYm6BhXmZF9oYOuETY3IzAbAxqKMo/P1cAPRfdGbUpm+Iyl
	 +P+ZBuE2xe+09QDS5NAAUG6vQo1JljJeJ/C2/p2Cl63FSRTQatNKEurCR8cmcMoKPI
	 O4jher4tqa4P8cTMP4TJ/xUdZ8X456gXCfZbBmh0KK0AJcb9eRRRCPbi6N5+NPuZvS
	 9ThOelBVoQqBrdqyjrKIl/4jqDNuhJ1YCPdIqIb8r/IINgA/1I9Taun7T1OS2ZYi3x
	 RLN4jeZLprsmA==
X-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
X-In-Reply-To: <20261117-t9xx_driver_v1-v12-3-e181b616b820@compal.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list