mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wu. JackBB (GSM)" <JackBB_Wu@compal.com>
To: "netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@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>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"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>,
	"edumazet@kernel.org" <edumazet@kernel.org>,
	"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 net-next v14 5/6] net: wwan: t9xx: Add FSM thread
Date: Fri, 4 Dec 2026 06:14:51 +0000	[thread overview]
Message-ID: <4a5a30add6ac4f528cb82f8e25bf8e68@compal.com> (raw)
In-Reply-To: <179629120173.3146.3576973350427912504@kernel.org>

Thanks for the review.

> If mtk_fsm_evt_submit() fails here, for example because kzalloc_obj()
> returns NULL, what clears the HS2_DONE bits recorded for the earlier boot?
>
> For a new boot, the only code that drops them is the bare STARTUP branch
> of mtk_fsm_startup_act():
>
>     if (fsm->state != FSM_STATE_BOOTUP)
>         mtk_fsm_switch_state(fsm, to_state, event);
>     else
>         fsm->fsm_flag &= ~FSM_HS2_DONE_MASK;
>
> A new HS1 clears only its own side's bit:
>
>     fsm->fsm_flag &= ~hs_info->fsm_flag_hs2;
>
> Take an MD+SAP device in BOOTUP. SAP has finished HS1/HS2 and MD has sent
> HS1. The modem reboots and reports IDLE, and the STARTUP allocation fails.
> boot_seq is still bumped and both channels are still unmasked.
>
> The new MD HS1 and HS2 then complete and set MD_HS2_DONE. The READY test
> passes because SAP_HS2_DONE is still set from the earlier boot:
>
>     hs_done_flag = READ_ONCE(fsm->hs_done_flag);
>     if (((fsm->fsm_flag | event->fsm_flag) & hs_done_flag) == hs_done_flag) {
>
> When the new boot's SAP HS1 arrives, the FSM is in READY and the HS1 is
> refused with -EPROTO. Would the SAP control path then stay down while the
> FSM reports READY?
>
> This also seems to contradict the commit message:
>
>     Before READY, the IDLE report of the new boot drops the HS2 results
>     recorded so far
>
> Could the HS2_DONE bits be dropped in a way that does not depend on the
> event allocation succeeding?

True.

Will fix in v15: the READY decision itself reads the boot count
once and drops the HS2_DONE bit of every side whose last HS1 was handled
before the latest IDLE report. The bare STARTUP no longer clears
anything, so a failed allocation of it no longer leaves the earlier
boot's HS2_DONE counting; in your sequence the stale SAP bit is dropped,
READY is not reached and the new SAP HS1 is accepted.

> What keeps fsm->boot_seq stable between the boot_seq check and the READY
> switch below?
>
> mtk_fsm_idle_evt_handler() bumps boot_seq from the MHCCIF work and shares
> no lock with the FSM thread. The new boot's IDLE report can land after the
> check but before mtk_fsm_switch_state(..., READY). In that case the
> earlier boot's HS2 is still parsed, HS3 goes to the rebooted device, and
> READY is reached.
>
> The bare STARTUP and new HS1 events queued for the new boot then hit:
>
>     if (fsm->state != FSM_STATE_ON && fsm->state != FSM_STATE_BOOTUP) {
>         ret = -EPROTO;
>         goto free_skb;
>     }
>
> so the modem stays down until the device is rebound.
>
> The only exception the commit message lists is an HS2 of the earlier boot
> "that completes READY before the new boot reports IDLE". Is the window
> where the report arrives during HS2 handling meant to be covered by that
> too?

True.

Will fix in v15 together with the item above: the boot count is
read once where READY is decided, and a side whose last HS1 was handled
before that count is not counted done. An IDLE report seen before that
read now keeps the FSM in BOOTUP, so the new boot's STARTUP and HS1 are
accepted. A report counted after it is ordered after READY, which is the
reboot-after-READY case the commit message describes. The device's
reboot itself, between its HS2 and our HS3, stays invisible to the host
until that report; recovery from it belongs with the reset interrupt
this series does not handle.

> Does masking QUEUE_ERROR here keep a late error away from the next
> occupant, or does it only postpone the error to the next unmask?
>
> mtk_cldma_get_intr_status() computes the pending bits as status & ~mask:
>
>     *tx_sta = (*tx_sta) & (~tx_mask);
>
> That suggests the L2 status register keeps latching bits for masked
> sources. The only code that clears QUEUE_ERROR status is mtk_cldma_isr(),
> and only for unmasked bits it has just seen. The atomic_andnot() and
> flush_work() here clear only the software copy.
>
> On reopen, mtk_cldma_txq_alloc() unmasks without first clearing the
> queue's status:
>
>     mtk_cldma_unmask_intr(drv_info, DIR_TX, txq->txqno, QUEUE_ERROR);
>
> mtk_cldma_dev_init() only clears the PCIe L1 bit. mtk_cldma_rxq_free() and
> mtk_cldma_rxq_alloc() follow the same pattern on RX.
>
> Here is one sequence. mtk_cldma_err_tx_one() fails to stop the queue, so
> QUEUE_ERROR stays masked, and the queue raises the error again. A later
> close then stops the queue without a reset, which would leave that bit
> latched.
>
> When the channel is reopened, the stale error would fire at unmask.
> mtk_cldma_err_tx_one() would then stop the new queue and complete its HWO
> descriptors with -EPIPE. If that happens after the first HS1 kick, which
> the device does not retry, would the handshake fail?
>
> On RX, the stale error would set need_restart and stop/restart the newly
> armed ring.
>
> Should the free or alloc paths clear the queue's QUEUE_ERROR (and
> XFER_DONE) status before unmasking?

True.

Will fix in v15: mtk_cldma_txq_alloc() and mtk_cldma_rxq_alloc()
clear the queue's XFER_DONE status, and its QUEUE_ERROR status when it
is set, after the stop and before the unmask (for RX, before the start).
The L2 status does latch for masked sources; the TX and RX done workers
already poll it while XFER_DONE is masked. Clearing at alloc also covers
status left after the free has finished.

Thanks,
Jack

pw-bot: cr

  reply	other threads:[~2026-12-04  6:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:58 [PATCH net-next v14 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-12-02  8:59 ` [PATCH net-next v14 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-04  6:15     ` Wu. JackBB (GSM)
2026-12-02  8:59 ` [PATCH net-next v14 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-12-02  8:59 ` [PATCH net-next v14 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-02  8:59 ` [PATCH net-next v14 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-02  8:59 ` [PATCH net-next v14 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-04  6:14     ` Wu. JackBB (GSM) [this message]
2026-12-02  8:59 ` [PATCH net-next v14 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-04  6:15     ` Wu. JackBB (GSM)
2026-12-04  6:21 ` [PATCH net-next v14 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver 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=4a5a30add6ac4f528cb82f8e25bf8e68@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@kernel.org \
    --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-bot+sashiko@kernel.org \
    --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

all inboxes | Powered by JetHome®