🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24076

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

#24076
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 07:39
184 lines
14973 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] The CLDMA queue code reads and writes registers in a power
  domain that, per the driver's own comments (mtk_cldma_hw_recovery()…
- [Low] The commit message leaves out two hardware-facing decisions made
  in this patch.

--

net: wwan: t9xx: Add control DMA interface

This commit adds the CLDMA control-plane DMA driver. It covers the GPD
rings for TX and RX, queue start/stop/reset handling and a TRB service
thread. It also adds mtk_pci_dev_init()/mtk_pci_dev_exit() hooks in probe
and remove so the transport context is attached to the control plane.

> 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..d1472b6759746
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_cldma.c

[ ... ]

> +/* A TX start address reads zero after the device has switched the block's
> + * power domain off.  That clears the configuration and the start addresses
> + * of all its TX queues together and stops them, so every queue is re-armed,
> + * as after a reset.
> + */
> +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);
> +
> +	val = mtk_cldma_get_tx_start_addr(drv_info, qno);
> +	if (!val || val == U64_MAX)
> +		return -EIO;
> +
> +	return 0;
> +}
> +
> +static int mtk_cldma_start_xfer(struct cldma_drv_info *drv_info, u32 qno)
> +{
> +	struct txq *txq;
> +	int ret = 0;
> +	u64 val;
> +
> +	txq = drv_info->txq[qno];
> +
> +	/* a reset in another queue's teardown must not land between the
> +	 * address check and the kick
> +	 */
> +	mutex_lock(&drv_info->rearm_lock);
> +	val = mtk_cldma_get_tx_start_addr(drv_info, qno);
> +	if (unlikely(val == U64_MAX)) {
> +		ret = -EIO;
> +		goto out;
> +	}
> +
> +	if (unlikely(!val)) {
> +		ret = mtk_cldma_hw_recovery(drv_info, qno);
> +		if (ret)
> +			goto out;
> +	}
> +
> +	/* Hold ring_lock across programming and kicking the queue so the
> +	 * start address given to the device is the one free_idx still
> +	 * names; tx_done_work advances free_idx under the same lock.
> +	 */
> +	spin_lock(&txq->ring_lock);
> +	if (unlikely(!READ_ONCE(txq->tx_started))) {
> +		mtk_cldma_setup_start_addr(drv_info, DIR_TX, qno,
> +					   txq->req_pool[mtk_cldma_tx_start_idx(txq)].gpd_dma_addr);
> +		mtk_cldma_start_queue(drv_info, DIR_TX, qno);
> +		WRITE_ONCE(txq->tx_started, true);
> +	} else {
> +		mtk_cldma_resume_queue(drv_info, DIR_TX, qno);
> +	}
> +	spin_unlock(&txq->ring_lock);

[Severity: Medium]

The comments in mtk_cldma_hw_recovery() and mtk_cldma_drv_init() say the
device can switch the CLDMA block's power domain off by itself. Is
anything holding the domain on for this sequence?

mtk_cldma_start_xfer()
    mtk_cldma_get_tx_start_addr()      <- reads a non-zero address
    [device gates the power domain here]
    mtk_cldma_resume_queue() / mtk_cldma_start_queue()   <- write lost

rearm_lock and ring_lock only serialize the host side. As far as I can
tell, nothing stops the device from gating the domain between the address
check and the doorbell write.

If the write is lost, the descriptor stays at HWO=1, no XFER_DONE comes
in and tx_done_work never runs. The queue then seems to stay stuck until
a later TX submission reads the zero start address and recovers. In a
request/response control exchange that is waiting for the reply to the
stuck message, that later submission may never happen.

The same applies if the domain is still off when mtk_cldma_hw_recovery()
runs. The register rewrites in mtk_cldma_rearm_queues() would be lost and
the read-back would be zero. The TX then fails with -EIO and gets flushed,
and the device is never woken.

I couldn't find a device sleep lock, a wake handshake or any pm_runtime
use in the t9xx tree, including in the later patches of the series. For
comparison, the t7xx CLDMA send path calls t7xx_pci_disable_sleep() and
waits for t7xx_pci_sleep_disable_complete() before it touches CLDMA
registers. Does this driver need a similar handshake?

> +out:
> +	mutex_unlock(&drv_info->rearm_lock);
> +	return ret;
> +}

[ ... ]

> diff --git a/drivers/net/wwan/t9xx/pcie/mtk_cldma_drv.c b/drivers/net/wwan/t9xx/pcie/mtk_cldma_drv.c
> new file mode 100644
> index 0000000000000..6693528dd2300
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_cldma_drv.c

[ ... ]

> +	/* enable interrupt to PCIe */
> +	mtk_pci_write32(mdev, base + hw_regs->reg_cldma_int_mask, 0);
> +
> +	/* Bit 0 is ILLEGAL_MEMORY_CHECK_DISABLE.  The check only flags a zero
> +	 * GPD/BD/data pointer, through an L3 interrupt this driver does not
> +	 * service; a stale non-zero address is not covered.  It is off because
> +	 * the TX start addresses read zero after the device has switched the
> +	 * block's power domain off, and a TX submission that reads one
> +	 * re-initializes instead.
> +	 */
> +	mtk_pci_write32(mdev, base + hw_regs->reg_cldma_ul_dummy_0, 1);
> +	mtk_pci_write32(mdev, base + hw_regs->reg_cldma_so_dummy_0, 1);
> +}

[Severity: Low]

This isn't a bug, but the commit message doesn't mention that these writes
turn ILLEGAL_MEMORY_CHECK off for both TX and RX. With the check off, the
engine no longer flags a zero GPD/BD/data pointer.

The commit message also doesn't mention that any TX kick can
re-initialize the whole instance:

mtk_cldma_start_xfer()
    if (unlikely(!val))
        mtk_cldma_hw_recovery()
            mtk_cldma_rearm_queues()
                mtk_cldma_drv_init()
                reprograms every published TX queue
                sets need_restart on every RX queue

The only reset behaviour the changelog describes is the escalation when a
queue stop times out:

  A queue that does not stop within the poll escalates to a reset of
  its CLDMA instance, which also cuts the instance's other queues.

Could both of these changes be described in the commit message? None of
the later patches in the series describe them either.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-t9xx_driver_v1-v13-0-92d9be5fb51e%40compal.com
Technical Details
Message-ID: <179593796434.3146.14992460300155341559@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.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-373399-linux-kernel-netdev=dewy.ru
References: <20261125-t9xx_driver_v1-v13-3-92d9be5fb51e@compal.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-373399-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v13 3/6] net: wwan: t9xx: Add control DMA interface
Date: Sun, 29 Nov 2026 07:39:24 +0000
Organization: Usenet Network
Message-ID: <179593796434.3146.14992460300155341559@kernel.org>
References: <20261125-t9xx_driver_v1-v13-3-92d9be5fb51e@compal.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1126867"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:R9/M7RFZ5U5P9442xhsFFuwk83Q= sha256:kh4XWFO3yuwS8TzarS6u6MuIbaO46nz0hL+cLPUPiZI=
	sha1:U7n8foKa7Wxtw20NN4nabXHYE/o= sha256:sDqjDLBe0/hIant1CoLLPFjsxwhfFhwtR2jpQviaVho=
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 1846E125F8A; Sun, 29 Nov 2026 10:40:05 +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 lWTZ5wTsBscz;
	Sun, 29 Nov 2026 10:40:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373399-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 0F625125F95; Sun, 29 Nov 2026 10:39:52 +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 047E3278C6; Sun, 29 Nov 2026 07:39: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=1795937972;
	b=uobMMATjGQyvRxthxiujTVVF1Oqen7tMUIHH6UIg6EZ4ZH4FPRgCxltUjBSQJiXnZMgh
	 9vRAoxjmeVbSfgsbqOAEojUtas00/uHWRZXPNleOXtsJcfEyZqMtsNE2ach5+2hD+YRVi
	 ZeRIdw6txYIkX9N5hVSTSpBQQOs8RdrDRoewug2uaZV908sDqijtJ7IIYxOtY+CSKSEb6
	 Wwmdw4l43p/1MEAaDFq5U0DFTLBN4gJdA4yOUPH1llIXbAGZKn/KRrN2ZWzodRjEyy+wb
	 Nkyq7cSHbmQzBOK5ju0hUfUVfF/dyRfv6v/TPNSnBU8qpubUK18qLG6D7ZyWKvHpG7A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795937972;
	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=BuTlUPlFekHjvMIFHJ5w36ZZxAzMmSuQ1fXkXyWe/gI=;
	b=M+WR/+rsgxKDUiGRx0B+G7jHA1hzTWp/DbC605929UqGwEf50BxuHCfl5ctGybus6nq2
	 JwCG/QlA5PQpJY2VkcuHm5JJ2fb6UANgF1sTi1Taeo5278dbcEKwOns3fsWKhDIUEgFck
	 iRpLzMOoDU8tltW77QhE4LqtgPRamaG9TtmbrjHEdDowtNqO/L0Dk/dEdKBzmyBtvX61u
	 XlwpLKfUhVq9qVKpnB/UY5jOj7iuN5LyUkCphfNDf5HH2pmfv7pXTCT5U2/o1rUxex4q3
	 ZzvM9PmQAaBvbWYYXBi0PDZE5nGTcxIIPcaAr2FQws3nP6EEA/oIKwo0OkxXGDqJTXw==
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="YoGPERP/";
	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 3F9E1606A6A4;
	Sun, 29 Nov 2026 07:39:32 +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=YoGPERP/
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=1795937966;
	b=1Neix4O+cEC5CXokfXfshn592L5uShJHe+bKjSN7wOBHZbk6r9kJGyFJMKVUP+qd017X
	 MoW7jeujeoQbaUKMlRVamRxrDryPtDuoyO30mKeFYcUM+1lHPFV9zx2aLJEuhg7OOkYlO
	 f/nzYrbm0vufxotDioCqcZKj42lIRvIN3NSVOmWj5y65IKfcPbGtnES9r4DNWeKqcfs3X
	 UNeJF6Dq0dgZkBsC5HhNWN1j9rJpFnU/0BHjc0rGxc+WVAwSOQoV9aLRMQ6JoyewBgbfB
	 Gk6hA+uC+HimqWMuMv8xscqg32l7/AAUyOMO/2DDETKludzODtDJI5Q8Ts7hqPVFohQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795937966;
	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=BuTlUPlFekHjvMIFHJ5w36ZZxAzMmSuQ1fXkXyWe/gI=;
	b=NziOEuxNGqMyeKiL9p4KLL++rk2MIiUpDefnTUIw3756pQca6/aYYb8CL8wRqBNhUWax
	 mfCrRAA0/OZScYdRf3SoYpFJtvvdETo4KdRbaSl0NFBLIbcd3BsPdi7Fj1Y6u620YdPJH
	 Ufcz8Hv3wCC2yMR3poHnpSdje42m4u0jPSwbxvWIj3jyBbJt80z+MNoEPzFs9dvkDIHwm
	 48sXqMCApgVDTVfjgTtXtSUiR2jc0At6OXYc23yqU00BVOUZ0Xbtm9wqaKGsQYAP5M7WM
	 T6adU8sJrwtim/WYObrUftlSxvKhFGrqCyTF0p9J9g5LERaCImxOndI71z7eq89wW8A==
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="YoGPERP/";
	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 617CA606A339;
	Sun, 29 Nov 2026 07:39:26 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C08E21F000C1;
	Sun, 29 Nov 2026 07:39:24 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795937966;
	bh=BuTlUPlFekHjvMIFHJ5w36ZZxAzMmSuQ1fXkXyWe/gI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YoGPERP/36eImCBN2GJGFNimqPaMVPCp3KpbELfxspSTReNFXVBuQK1NyfVB7nLus
	 eVCbWsv/Wy1C6svkYljo0BppP8UPRUA3Ju7BK9qND1aC4mLb2oEE+fy2u8ee/o77zZ
	 t1B38dY9uM1G3u1PpFJhRZBDFtYdhaF+ol/+n87/4fE+5M9CwOMSbRJeWB56OOng32
	 fXiVmwMsXHoZ2GqgvzOfu2+g02RGXANN459nUaGW5BXTe4dBOCqAXEBKBn3Q+NWLTy
	 6Dc/u7DAH4cBdzHwruCQyF8hUj4BgOM3FkxfQqICURMU35G6qWT6Cyrho7J/8MPp4n
	 El0MQKxmccrjw==
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: <20261125-t9xx_driver_v1-v13-3-92d9be5fb51e@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