From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAAF7606A323 for ; Sun, 29 Nov 2026 07:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pCMbfBzQ; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eoUd8Aue DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=kNTNZBLC1ZG3T6kKzbimLkbsgYWEEV+ZNeyrGc8QOJg=; b=pCMbfBzQf5ChjWG3kEtIHtfJ+0 uTTWX7fh1rOawyb+ijDWDHpjJgvzmvOSOmyPvDNLF1gkd9jq1PweN06jxM72zpWEGuWRplRLn5hM5 bgJaejvM6fWm2NQzkYBpvcEAbDCndSCnt+D6TjGNnMy+7yrLa36Txl3ty7kcnwlYpSkfz+eW54nmd rgBYbOj+Yxb00e5oFwCr9LtbPAcZFzFDB3jQCkSDvkJdZkaQwnMUf5RhjTO63Xh63isrWxRhn5L4i m+Ruz/ipyf1vbRfJRL8dqjVvstf7AHtZE5CnQMYvqv6LuWQxgOnaro2NpZwxTl5ppHaJIRadCQHk7 hfKEWPtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXZW5-00000001flA-2Jaz; Sun, 29 Nov 2026 07:40:09 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXZVS-00000001fVk-2uHw; Sun, 29 Nov 2026 07:39:30 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 243C260D66; Sun, 29 Nov 2026 07:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C0E51F00925; Sun, 29 Nov 2026 07:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795937969; bh=kNTNZBLC1ZG3T6kKzbimLkbsgYWEEV+ZNeyrGc8QOJg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=eoUd8AuelP5dqp6LrQ9DeETNcZwg6PCl/bERsF5opdnkQyUGKZnbd+mN/OZFd3Y4n 3pzI5tAKvuu2bclZAwXwBI1DCupQsz110XgNJazDxPe7+gzW+JPvJc6LxH/SUncJGp 0HmXrA4l8ckC2oofSa7MvNwlv6IXgpkAitvQ8AiIDVL5Z91cwIEy/5O0Ta7CzKgUBB rqbYa1OJmh8fHuFwcU2TpqQ5rVQU6PiRgSJuMWwmWLzGYccbRAhpJ1Wiy/94t5j9Kq jb4yPRtvbqPgkSxoA7S07U1Lhj8yqi9luN4nlewo/mhAW8KYirEfNQdrqH5lETZGcX zaj6gcWbyLPaA== Subject: Re: [PATCH net-next v13 5/6] net: wwan: t9xx: Add FSM thread 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 Date: Sun, 29 Nov 2026 07:39:28 +0000 Message-ID: <179593796811.3146.4950323951333239906@kernel.org> In-Reply-To: <20261125-t9xx_driver_v1-v13-5-92d9be5fb51e@compal.com> References: <20261125-t9xx_driver_v1-v13-5-92d9be5fb51e@compal.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message contradicts what mtk_fsm_startup_act() (drivers/net/wwan/t9xx/mtk_fsm.c) does before READY. - [Low] mtk_cldma_dev_exit() (drivers/net/wwan/t9xx/pcie/mtk_cldma.c) deliberately calls dma_pool_destroy(drv_info->gpd_dma_pool) while the… - [Low] mtk_fsm_early_bootup_handler() (drivers/net/wwan/t9xx/mtk_fsm.c) only skips a notification when the whole 32-bit device-state word is… -- net: wwan: t9xx: Add FSM thread This adds an FSM kthread to the t9xx WWAN driver. The thread sequences device and OS events, runs the HS1/HS2/HS3 runtime feature handshake for MD and SAP, and notifies the port manager and transport layer of each state change. CLDMA bring-up and teardown now follow FSM transitions, and the patch also adds a queue error recovery worker and a quiesce step on teardown. > diff --git a/drivers/net/wwan/t9xx/mtk_fsm.c b/drivers/net/wwan/t9xx/mtk_fsm.c > new file mode 100644 > index 0000000000000..bdb4ac75cc039 > --- /dev/null > +++ b/drivers/net/wwan/t9xx/mtk_fsm.c > @@ -0,0 +1,1011 @@ [ ... ] > +static void mtk_fsm_idle_evt_handler(struct mtk_md_dev *mdev, > + u32 dev_state, struct mtk_md_fsm *fsm) > +{ > + u32 dev_cfg = dev_state >> DEVICE_CFG_SHIFT & DEVICE_CFG_REGION_MASK; > + int hs_id; > + > + if (dev_cfg == DEV_CFG_MD_ONLY) > + WRITE_ONCE(fsm->hs_done_flag, FSM_F_MD_HS_START | FSM_F_MD_HS2_DONE); > + else > + WRITE_ONCE(fsm->hs_done_flag, FSM_HS_START_MASK | FSM_HS2_DONE_MASK); > + > + if (mtk_fsm_evt_submit(mdev, FSM_EVT_STARTUP, FSM_F_DFLT, > + NULL, 0)) > + dev_err(mdev->dev, "Failed to submit STARTUP evt\n"); > + [ ... ] > + for (hs_id = 0; hs_id < HS_ID_MAX; hs_id++) > + mtk_fsm_unmask_ext_evt(fsm, fsm->hs_info[hs_id].mhccif_ch); > +} > + > +static void mtk_fsm_early_bootup_handler(u32 status, void *__fsm) > +{ [ ... ] > + if (dev_state == fsm->last_dev_state) > + goto exit; > + > + if (dev_stage == DEV_STAGE_IDLE) > + mtk_fsm_idle_evt_handler(mdev, dev_state, fsm); > + > + fsm->last_dev_state = dev_state; [Severity: Low] Can the IDLE work run more than once per boot? The duplicate check compares the whole 32-bit state word. The call to mtk_fsm_idle_evt_handler() depends only on the stage nibble. Suppose firmware changes some other bit of REG_PCIE_DEBUG_DUMMY_7 (for example the dev_cfg field at bits 24-25) while the stage stays DEV_STAGE_IDLE, and raises BOOT_FLOW_SYNC again. Then mtk_fsm_idle_evt_handler() runs a second time and: - rewrites fsm->hs_done_flag in the middle of a handshake. mtk_fsm_startup_act() re-reads that flag to decide READY, so a switch from MD-only to full would leave READY waiting for a SAP handshake that never comes. - queues another bare STARTUP, which is refused with -EPROTO once the FSM is READY. - unmasks both HS notify channels that mtk_fsm_hs1_handler() masked "until the device boots again". mtk_mhccif_isr_work() only acks unmasked status bits: stat &= ~mask; if (stat) mtk_pci_ack_ext_evt_hw(mdev, stat); Could a notify that latched while the channel was masked then be delivered after the unmask? In BOOTUP that would restart that side's handshake and clear its HS2_DONE bit. This depends on firmware behaviour I can't check from the tree, and the comment says the device notifies once per boot stage. Would it make sense to record that the IDLE work has already run for this boot? [ ... ] > +static int mtk_fsm_startup_act(struct mtk_md_fsm *fsm, struct mtk_fsm_evt *event) > +{ [ ... ] > + /* The device signals its own reboot with a separate reset interrupt; > + * a handshake event outside ON/BOOTUP is not a restart request and is > + * refused. > + */ > + if (fsm->state != FSM_STATE_ON && fsm->state != FSM_STATE_BOOTUP) { > + ret = -EPROTO; > + goto free_skb; > + } [ ... ] > + if (event->fsm_flag & FSM_HS_START_MASK) { > + /* An HS1 that raced ahead of the bare STARTUP must both > + * switch ON to BOOTUP and run the handshake below; returning > + * after the switch would consume the only trigger. > + * A side that sends HS1 again before READY has booted again: > + * its earlier HS2 no longer counts. > + */ > + fsm->fsm_flag &= ~hs_info->fsm_flag_hs2; > + mtk_fsm_switch_state(fsm, to_state, event); > + > + ret = mtk_fsm_ctrl_ch_start(fsm, hs_info, O_NONBLOCK); > + if (!ret) > + ret = mtk_fsm_send_hs1_msg(hs_info); > + if (ret) > + goto hs_err; [Severity: Low] Does this match the commit message? It says: The device sends HS1 once per boot and does not retry a failed handshake; it starts again only after a modem reset, which removal performs. A modem that reboots on its own announces it with a separate reset interrupt, and recovery is driven from that interrupt, not from the new handshake. Here, a second HS1 that arrives while the FSM is in BOOTUP is treated as a device reboot. That side's HS2_DONE bit is cleared, the FSM re-enters BOOTUP, and the whole handshake runs again. That looks like recovery driven from the new handshake. The path would be mtk_fsm_early_bootup_handler()-> mtk_fsm_idle_evt_handler(), which unmasks the HS channels on the new IDLE. mtk_fsm_hs1_handler() then submits STARTUP with the HS_START flag. The re-run also seems to reuse host-side state from the previous boot. mtk_fsm_ctrl_ch_start() skips the open because hs_info->ctrl_port is still set: if (!hs_info->ctrl_port) { hs_info->ctrl_port = mtk_port_internal_open(...); mtk_cldma_dev_init() also returns early for the existing instance: if (cd->cldma_drv_info[hif_id]) return 0; The control port's enable resets tx_seq/rx_seq, but mtk_cldma_open() returns -EBUSY because the queues still exist. Recovery would then rely on mtk_cldma_start_xfer() reading a zero TX start address and calling mtk_cldma_hw_recovery(). Is this pre-READY restart path intended? If so, could the commit message describe it, and how the CLDMA queues are expected to recover? [ ... ] > diff --git a/drivers/net/wwan/t9xx/pcie/mtk_cldma.c b/drivers/net/wwan/t9xx/pcie/mtk_cldma.c > index d1472b6759746..aa72d7b46d031 100644 > --- a/drivers/net/wwan/t9xx/pcie/mtk_cldma.c > +++ b/drivers/net/wwan/t9xx/pcie/mtk_cldma.c [ ... ] > @@ -788,9 +1025,110 @@ static int mtk_cldma_hw_recovery(struct cldma_drv_info *drv_info, u32 qno) [ ... ] > +static int mtk_cldma_dev_exit(struct cldma_dev *cd, int hif_id) > +{ [ ... ] > + /* Best-effort: reset the IP so it drops its queue state before the > + * descriptor memory goes away. Not guaranteed to stop the engine, > + * hence ring_leaked. > + */ > + mtk_cldma_drv_reset(drv_info); > + /* A handler retired by the quiesce may have unmasked the vector on > + * its way out, and nothing handles it any more: leave it masked. > + */ > + mtk_pci_mask_irq(mdev, drv_info->pci_ext_irq_id); > + > + if (drv_info->ring_leaked) > + dev_err(mdev->dev, "CLDMA%d rings leaked\n", drv_info->hw_id); > + /* The leaked rings keep the pool busy: it keeps its pages and only its > + * bookkeeping is freed. Not destroying it would leak the same pages > + * and the pool. > + */ > + dma_pool_destroy(drv_info->gpd_dma_pool); [Severity: Low] Is it safe to call dma_pool_destroy() here while the pool still has blocks handed out? When mtk_cldma_txq_free() or mtk_cldma_rxq_free() hits a stop timeout, it sets ring_leaked and returns without calling dma_pool_free() on the ring's GPDs. The device may still be walking those descriptors. The documented contract in mm/dmapool.c says: * Caller guarantees that no more memory from the pool is in use, * and that nothing will try to use the pool after this call. The comment here, and the commit message ("dma_pool_destroy() does not free the pages of a pool that still has blocks outstanding"), rely on the current implementation skipping dma_free_coherent() when pool->nr_active is non-zero. That looks like defensive handling of caller bugs rather than an API guarantee. This path also: - prints the "dma_pool_destroy ... busy" error on every such teardown. - leaks every page of the pool, not only the leaked rings. - with CONFIG_DMA_API_DEBUG, reports pending allocations at unbind. If dmapool ever frees pages on a busy destroy, the device could DMA into freed coherent memory. Would it be better to skip dma_pool_destroy() and leave the pool allocated together with the rings when ring_leaked is set? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-t9xx_driver_v1-v13-0-92d9be5fb51e%40compal.com