From: "Wu. JackBB (GSM)" <JackBB_Wu@compal.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "loic.poulain@oss.qualcomm.com" <loic.poulain@oss.qualcomm.com>,
"ryazanov.s.a@gmail.com" <ryazanov.s.a@gmail.com>,
"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"wen-zhi.huang@mediatek.com" <wen-zhi.huang@mediatek.com>,
"shi-wei.yeh@mediatek.com" <shi-wei.yeh@mediatek.com>,
"Minano.tseng@mediatek.com" <Minano.tseng@mediatek.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"horms@kernel.org" <horms@kernel.org>,
"corbet@lwn.net" <corbet@lwn.net>,
"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
"Yu. Robert (GSM)" <robert_yu@compal.com>,
"Chang. Jeff (GSM)" <Jeff_Chang@compal.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v6 5/7] net: wwan: t9xx: Add FSM thread
Date: Wed, 19 Aug 2026 08:09:59 +0000 [thread overview]
Message-ID: <0ce2325ddab34fd184a17c8642eeaaa4@compal.com> (raw)
In-Reply-To: <20260817223657.3688752-1-kuba@kernel.org>
On Mon, 17 Aug 2026 at 22:36, Jakub Kicinski <kuba@kernel.org> wrote:
> [Severity: Low]
> Does the code match this description? enum mtk_fsm_state in the new
> mtk_fsm.h defines five states:
...
> There is also no sub-state anywhere: struct mtk_md_fsm and
...
> only ever assigns fsm->state. Should the count and the sub-state
> sentence be updated?
Will fix in v7. Will update commit message to say "Five FSM states"
and remove the sub-state sentence.
> [Severity: Low]
> The changelog only mentions the FSM thread, but the patch carries several
> other functional changes. Would it help reviewers to split them out or at
> least mention them?
Will fix in v7. Will expand the commit message to mention the HS1/HS2/HS3
handshake protocol, CLDMA device init/exit wiring, and CLDMA4 removal.
> [Severity: High]
> Can a failing ops->init() here lead to a NULL dereference on removal?
...
> and mtk_ctrl_trb_srv_exit() does:
...
> with no NULL check.
Will fix in v7. Will check ops->init() return value in
mtk_ctrl_trans_fsm_state_handler() and add NULL check for srv in
mtk_ctrl_trb_srv_exit() as defensive hardening.
> [Severity: High]
> Can two HS2 messages race on the single hs_info->rt_data slot?
...
> skb1 is leaked, skb2 is freed early, and event B then reaches:
...
> on a NULL pointer.
Will fix in v7. Will add a guard in the ctrl_msg_handlers to reject
a duplicate HS2 if hs_info->rt_data is already set, dropping the
duplicate with dev_warn.
> [Severity: High]
> What protects these two list walks against concurrent unregistration?
...
> kfree() from other threads. There is no mutex, no _rcu list variant, no
> synchronize_rcu() before the kfree, and no barrier.
Will fix in v7. Will add a mutex (fsm->notifier_lock) to protect the
notifier lists in switch_state, register, unregister, and cleanup.
> [Severity: High]
> Can fsm->fsm_handler be NULL at this wake_up_process()?
...
> On the probe error path (mtk_pci_dev_init() -> goto free_fsm
> -> mtk_fsm_exit()) no DEV_RM is ever submitted, so the gate is open, and
...
> mtk_fsm_exit() also never clears mdev->fsm, so the torn-down (devm-freed)
> fsm stays reachable from those callbacks.
Will fix in v7. Will move wake_up_process() inside the evtq_lock
critical section with a NULL check, set EVT_TF_GATECLOSED in
mtk_fsm_exit() before NULLing fsm_handler, and clear mdev->fsm.
> [Severity: Medium]
> Can the FSM reach FSM_STATE_READY when HS3 was never delivered?
...
> hs_err exit does not clear the already-committed FSM_F_*_HS2_DONE bit.
Will fix in v7. Will move mtk_fsm_switch_state() (which commits
the HS2_DONE flag) to after mtk_fsm_send_hs3_msg() succeeds.
> [Severity: Medium]
> Is there a way back if the queued startup action later fails?
...
> path only logs; the channel stays masked and no retry is scheduled, so the
> FSM stays in FSM_STATE_BOOTUP.
Will fix in v7. Will unmask the handshake channels in the hs_err
path so the modem can re-trigger HS1.
> [Severity: Medium]
> What happens to the QUEUE_ERROR bits that get masked but never handled?
...
> So the first queue error permanently disarms error reporting, leaves the
> bit latched in L2TISAR0/L2RISAR0, and leaves the halted queue with no log,
> no queue reset and no GPD/HWO recovery.
Will fix in v7. Will extract and handle QUEUE_ERROR bits in
mtk_cldma_isr(): log dev_err, clear the error bits, and re-unmask.
Full queue recovery will be a follow-up if needed.
> [Severity: High]
> Is the initial mask plus synchronize_irq() enough to keep the ISR away
> from the freed drv_info?
...
> so an ISR that was already running when the vector was masked unmasks it
> again before returning, and synchronize_irq() only waits for that ISR to
> finish.
Will fix in v7. Will reorder mtk_cldma_dev_exit() to unregister the
IRQ callback first, then mask + synchronize_irq, then free resources.
Will also add a NULL callback check in mtk_pci_irq_handler().
> [Severity: High]
> Are the TRB service threads guaranteed to be stopped before this runs?
...
> In mtk_ctrl_trans_fsm_state_handler(), the FSM_STATE_OFF arm calls
> fsm_indication() (which lands here and tears down every CLDMA hif)
> before ops->exit(), and it is ops->exit() -> mtk_pcie_hif_exit() that
> clears trans->available and stops the TRB kthreads.
Will fix in v7. Will swap the ordering in FSM_STATE_OFF: call
ops->exit() (stop TRB threads) before fsm_indication() (free CLDMA).
Will also swap kfree/NULL assignment order in mtk_cldma_dev_exit().
> [Severity: High]
> What happens here when the blocking removal event does not complete?
...
> the result is discarded. In that case the FSM_STATE_OFF notifier chain
> never runs, so ctrl_blk->ops->exit() = mtk_pcie_hif_exit() is never
> called: the CLDMA IRQ callback stays registered, the CLDMA workqueue and
> DMA pools stay alive, the TRB service kthreads keep running and
> trans->available stays 1.
Will fix in v7. Will check DEV_RM return value in mtk_pci_dev_exit().
On failure (kzalloc fail or timeout), fall back to direct cleanup
of HIF resources before proceeding with teardown.
> [Severity: Medium]
> Should these two return values be propagated? mtk_pci_dev_start() is
...
> but both calls are discarded and 0 is returned unconditionally.
Will fix in v7. Will propagate return values of mtk_fsm_evt_submit()
and mtk_fsm_start() from mtk_pci_dev_start().
> [Severity: Medium]
> Should these registrations be checked? mtk_dev_register_dev_evt() reaches
...
> Here the return value is dropped, and the two per-handshake-channel
> registrations inside the void mtk_fsm_hs_info_init() cannot report failure
> at all.
Will fix in v7. Will check return values of mtk_dev_register_dev_evt()
in mtk_fsm_init() and make mtk_fsm_hs_info_init() return int so it
can propagate registration failures.
> [Severity: Low]
> Should this loop key off rtft_entry->feature_id instead of the loop index?
...
> Here the received entry's feature_id is never read, so the parser assumes
> the device returns exactly FEATURE_CNT entries in dense ascending order.
The loop intentionally uses the index rather than rtft_entry->feature_id
for dispatch. The protocol contract requires the device to return exactly
FEATURE_CNT entries in dense ascending order, enforced by the check after
the loop:
if (ft_id != FEATURE_CNT) {
dev_err(..., "Unable to handle mistake hs2 msg, ft_id=%d\n", ft_id);
return -EPROTO;
}
The reason this check cannot be moved before the loop is that
runtime_feature_entry is variable-length — each entry carries a data_len
field followed by an inline payload, so the number of entries can only be
determined by traversing the buffer. If the device omits or reorders
entries, ft_id will fall short of FEATURE_CNT and the entire HS2 is
rejected as a hard protocol error. There is no partial-match path. The
feature_id field exists in the wire struct as a marker but is not used as
a dispatch key by design, to prevent a misbehaving device from
redirecting its response to an unintended handler.
> [Severity: Medium]
> Is a minimum length check missing here? Only an upper bound on data_len
> is applied, so data_len == 0 is accepted and passed to
> mtk_port_status_update(), which dereferences the 12-byte
> struct mtk_port_enum_msg header before validating the length:
Will fix in v7. Will add a data_len == 0 check before calling the
handler, and move the sizeof(*msg) length check in
mtk_port_status_update() before the header dereference.
Thanks.
--
Jack
next prev parent reply other threads:[~2026-08-19 8:10 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 7:14 [PATCH v6 0/7] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-11 7:14 ` [PATCH v6 1/7] net: wwan: t9xx: Add PCIe core Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:35 ` Jakub Kicinski
2026-08-19 7:56 ` Wu. JackBB (GSM)
2026-08-11 7:14 ` [PATCH v6 2/7] net: wwan: t9xx: Add control plane transaction layer Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:36 ` Jakub Kicinski
2026-08-18 12:22 ` [External Mail] " Wu. JackBB (GSM)
2026-08-11 7:14 ` [PATCH v6 3/7] net: wwan: t9xx: Add control DMA interface Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:36 ` Jakub Kicinski
2026-08-18 12:24 ` [External Mail] " Wu. JackBB (GSM)
2026-08-11 7:14 ` [PATCH v6 4/7] net: wwan: t9xx: Add control port Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-11 7:14 ` [PATCH v6 5/7] net: wwan: t9xx: Add FSM thread Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:36 ` Jakub Kicinski
2026-08-19 8:09 ` Wu. JackBB (GSM) [this message]
2026-08-11 7:14 ` [PATCH v6 6/7] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:36 ` Jakub Kicinski
2026-08-18 12:41 ` [External Mail] " Wu. JackBB (GSM)
2026-08-11 7:14 ` [PATCH v6 7/7] net: wwan: t9xx: Add maintainers entry Jack Wu
2026-08-11 7:14 ` Jack Wu via B4 Relay
2026-08-17 22:38 ` Jakub Kicinski
2026-08-19 7:59 ` Wu. JackBB (GSM)
2026-08-17 22:39 ` [PATCH v6 0/7] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jakub Kicinski
2026-08-18 12:20 ` [External Mail] " Wu. JackBB (GSM)
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=0ce2325ddab34fd184a17c8642eeaaa4@compal.com \
--to=jackbb_wu@compal.com \
--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@google.com \
--cc=horms@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.