Netdev List
 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 v13 5/6] net: wwan: t9xx: Add FSM thread
Date: Mon, 30 Nov 2026 08:04:25 +0000	[thread overview]
Message-ID: <f09fe68d8f624282943a71352309b047@compal.com> (raw)
In-Reply-To: <179593796811.3146.4950323951333239906@kernel.org>

Thanks for the review.

> 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?

No change.  The state word carries more than the stage, so the whole
word is compared and the latest report is the one used; running the IDLE
work only once would keep the configuration of the first report if the
device ever updated it.  The effects listed follow what the device
reports: a repeated STARTUP is a no-op in BOOTUP and only logs after
READY, and a handshake notify can be latched behind the mask only if the
device sent HS1 again, which means it rebooted and that side's handshake
is meant to restart.

> 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?

Will fix in v14: the commit message will say that a modem which reboots
before READY has its new HS1 accepted and that side's handshake run
again on the control channel that is already open, and that only after
READY the new handshake is refused.  The sentence "recovery is driven
from that interrupt, not from the new handshake" was wrong for the
pre-READY case and is removed; the code and its comment are as intended.

The path is intended.  The control channel is still open, so the
handshake is run again on it, and if the reboot cost the transport its
queue addresses the first transmit sees a zero start address and re-arms
that instance's queues, as for any transmit.  The port is not re-enabled
on this path, so mtk_cldma_open() is not reached and the sequence
numbers are not reset; the receive side only warns about a gap and still
delivers the packet.

> 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?

No change.  The pool is a single page here, so both ways leak exactly
the same coherent memory and give the same DMA_API_DEBUG report;
skipping the destroy would additionally leave the pool object on the
device's pool list and in its "pools" attribute after unbind, and would
only save the "busy" line.  The descriptors cannot be given back while
the device may still use them, so the caller guarantee cannot be met on
this path either way; it is reached only after a queue failed to stop
even after a reset, and it is reported.

Thanks,
Jack
--
pw-bot: cr

  reply	other threads:[~2026-11-30  8:04 UTC|newest]

Thread overview: 15+ 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-30  7:58     ` Wu. JackBB (GSM)
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
2026-11-30  8:01     ` Wu. JackBB (GSM)
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-30  8:02     ` Wu. JackBB (GSM)
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-30  8:04     ` Wu. JackBB (GSM) [this message]
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=f09fe68d8f624282943a71352309b047@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