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>,
	"edumazet@google.com" <edumazet@google.com>,
	"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>,
	"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 v11 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports
Date: Wed, 11 Nov 2026 08:58:20 +0000	[thread overview]
Message-ID: <f0a480783459458f97c70a01e25e7ec7@compal.com> (raw)
In-Reply-To: <179430863921.994134.2627836072572850693@kernel.org>

Thanks for the review.

> Can a stale port->enable reach READY here? mtk_port_status_update() only
> writes port->enable for channels that appear in the current enumeration:
>
>     port->enable = FIELD_GET(MTK_INFO_FLD_EN, le16_to_cpu(port_info->channel));
>
> Nothing resets the ports that are not listed.
>
> In mtk_fsm_startup_act(), mtk_fsm_parse_hs2_msg() applies the MD port
> enumeration first. If a later RTFT entry is malformed, or
> mtk_fsm_send_hs3_msg() fails, the code takes hs_err and re-arms the
> channel so the modem can retry the handshake:
>
>     ret = mtk_fsm_parse_hs2_msg(fsm, hs_info, skb);
>     if (!ret)
>         ret = mtk_fsm_send_hs3_msg(hs_info, skb);
>     ...
> hs_err:
>     if (hs_info)
>         mtk_pci_unmask_ext_evt(mdev, hs_info->mhccif_ch);
>
> Suppose the retried enumeration leaves out a port that the first one
> marked enabled. That port keeps port->enable == true. On READY,
> mtk_port_wwan_enable() would then arm its CLDMA1 queue and call
> wwan_create_port() for a channel the final enumeration did not advertise.
> That goes against the comment above.
>
> This depends on the modem firmware sending a different port list across
> handshake retries, so it may not happen in practice. FSM_STATE_OFF is
> terminal in this driver, so the handshake retry seems to be the only way
> to get here, not a later boot.
>
> Would clearing all port->enable flags before applying a new enumeration
> close this gap?

No change for the retry case.  The MD and SAP enumerations both go
through mtk_port_status_update() and arrive as independent HS2s, so
clearing every port->enable before applying one would wipe the flags the
other side had already set, and READY would enable no MD port.  A
per-table reset would need the handshake id passed through the RTFT
action signature, for a modem that would have to change its own port
list between two handshakes of the same boot.

Will fix in v12 the store you point at: mtk_port_enable_by_type() no
longer clears port->enable, and its comment goes with it.  FSM_STATE_OFF
is terminal and READY is reached at most once per bind, so nothing can
observe the cleared flag.

> Is the CCCI header subtracted twice here? mtk_port_ch_enable() already
> removes it from port->tx_mtu:
>
>     port->tx_mtu = trb_open_priv->tx_mtu - MTK_CCCI_H_ELEN;
>
> mtk_port.h documents MTK_CCCI_H_ELEN as:
>
> /* ccci header length + reserved space that is used in exception flow */
> #define MTK_CCCI_H_ELEN		(128)
>
> So port->tx_mtu already looks like the payload budget. This code and
> caps.frag_len in mtk_port_wwan_enable() both subtract
> sizeof(struct mtk_ccci_header) a second time. Each packet then carries
> 16 bytes less payload: with Q_MTU_3_5K, frag_len is 3440 instead of 3456.
>
> The error is in the safe direction, so nothing overflows. Still, this
> math, the "payload budget" comment in mtk_port_wwan_enable(), and the
> MTK_CCCI_H_ELEN definition can't all be right. Which meaning of
> port->tx_mtu is intended?

Will fix in v12: port->tx_mtu is the payload budget, as MTK_CCCI_H_ELEN
says.  The write path and caps.frag_len now use it directly and allocate
tx_mtu plus the header, so a packet carries 3456 bytes of payload.  One
core fragment still maps to exactly one CCCI packet.

> This isn't a functional bug, but does this patch make the comment on enum
> mtk_port_status in mtk_port.h inaccurate?
>
> /* State bits, not locks: callers serialise ->enable(), ->disable() and
>  * open of a port.  The atomic bitops only make a repeated call a no-op.
>  */
>
> For the WWAN ports, open comes from userspace through the WWAN core:
> mtk_port_wwan_open() runs under the core's ops_lock. ->enable() and
> ->disable() come from the FSM through mtk_port_mngr_fsm_state_handler().
> Nothing serialises the two paths, and the comment above set_bit()
> here expects open to run at the same time as enable.
>
> The open vs. enable and open vs. disable interleavings look safe because
> of the w_lock ordering, but the header comment no longer describes how
> this works. Could it be updated so later code doesn't count on caller
> serialisation that doesn't exist?

Will fix in v12: the comment will say that ->enable() and ->disable()
are serialised by their callers, while a WWAN open comes from userspace,
can only reach a node created after ->enable(), and is ordered against
->disable() by w_priv.w_lock.

--
Jack

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  7:56 [PATCH v11 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-05  7:56 ` [PATCH v11 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:54     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-05  7:56 ` [PATCH v11 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:56     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:57     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:57     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:58     ` Wu. JackBB (GSM) [this message]

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=f0a480783459458f97c70a01e25e7ec7@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-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®