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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
+/* 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?
quoted hunk ↗ jump to hunk
+out:
+ mutex_unlock(&drv_info->rearm_lock);
+ return ret;
+}
[ ... ]
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
+ /* 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