Linux Documentation
 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 v13 3/6] net: wwan: t9xx: Add control DMA interface
Date: Sun, 29 Nov 2026 07:39:24 +0000	[thread overview]
Message-ID: <179593796434.3146.14992460300155341559@kernel.org> (raw)
In-Reply-To: <20261125-t9xx_driver_v1-v13-3-92d9be5fb51e@compal.com>

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

  reply	other threads:[~2026-11-29  7:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  6:27 [PATCH net-next v13 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-25  6:27 ` [PATCH net-next v13 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-29  7:39   ` netdev-bot+sashiko
2026-11-25  6:27 ` [PATCH net-next v13 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-25  6:27 ` [PATCH net-next v13 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-29  7:39   ` netdev-bot+sashiko [this message]
2026-11-25  6:27 ` [PATCH net-next v13 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-29  7:39   ` netdev-bot+sashiko
2026-11-25  6:27 ` [PATCH net-next v13 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-29  7:39   ` netdev-bot+sashiko
2026-11-25  6:27 ` [PATCH net-next v13 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=179593796434.3146.14992460300155341559@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