From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795937968; b=yproE3TiHziUkAkKgZUGYGqBVCvwzEp8l4RNh6qyk1l3dgJ0HngaI2bmGGhnDsnpP+Pf DJeKm6EyKGO97xgXPiIWxhKeWEY1h9H0iZfZbpzWsi4gmDmKVunFPvqrZFN5k4agqjuUn 0lokSqPfsD712/VQq6u7KTeinestTB8Rb91XMQ7OOVBMuRFMZ2HJXFnodpG49rH8z8Fqa oct9Y+L9lj4dT6Q60G2SvX/y22qmoKcv2ysE1zIR7aZDUlOFuTVvbstHYYZ+PtxW0B2KB SZT00oqJlss2Y0wW6Rqbho/nVvfZPxC8z0YN5CSXn8DDGpUf69XgmbiUuPMjDbh7k0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795937968; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=BhdpN3tlHymuKkWH635WOnKJqKoxs5AlhVR25mx8ef0=; b=LuK1dJ0uqaMp0NKDsjpzvAUaQZefAtioDy+OPB26rJlKB/KDeNTJA8+ZimLIBNfKjxTK R2tJDeJPSVLW3fjlmhxXqg0l9/of1pIvG501v85bfIYVgoy/0/cRrAET37RgDoggbCDoA 52brnNwzJoq5XlWuvL9+eJprfGdAp2AkWcBjt9dXoVN2WhaFLVBd3TvJDuYNt5Rgw/v3K NC/fxqzRxFNZIK2yCdICouqznpiJorkmwbFPx2WkzBNHlV3o+5i+BuukDPDP6JdjN+W9D gN2uEAVdan80yQlxJyewuF45wPbQqpY032TZW5EQYSwjy/aniJh7YsC/ifJlJrfhTHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dNG6Lzo2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 312C3606A331; Sun, 29 Nov 2026 07:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dNG6Lzo2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A41531F000C1; Sun, 29 Nov 2026 07:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795937967; bh=BhdpN3tlHymuKkWH635WOnKJqKoxs5AlhVR25mx8ef0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dNG6Lzo2tv7rkK52VtZWMVUGHgYHMuO2j0Zx/b1BM1H5tjQCGRCEoYNxvoVsYqa3U Oqu+PHQRj2E9jIk2XrVldVPO0rEKlPxRJATiiNZWEwVuqE9RqbApd+qJX2tAS7ZgFA 8YT0rX8Cj4w+bIB4fNhBhY08f6W9MWSwvkHjRrL3pnevHB5aEu73vdRM+o004D0dU/ OGHrrgSLICcc8ZNOb62q5zS1N2hRMJ303AamG+2woXU/yuCK2PEPKDnp9h2ZuVTp1n DSxXkLZI2aJXKW8Qag+U5Tvu6HXPvZW3+9LqKPiC5mRH8zu7Gg1p2oOX0taA232w4p xNVWwFbC00b/w== Subject: Re: [PATCH net-next v13 4/6] net: wwan: t9xx: Add control port 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:26 +0000 Message-ID: <179593796621.3146.9100120473874620233@kernel.org> In-Reply-To: <20261125-t9xx_driver_v1-v13-4-92d9be5fb51e@compal.com> References: <20261125-t9xx_driver_v1-v13-4-92d9be5fb51e@compal.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 `rx_done` contract is documented as "consumes the skb; the return value is informational" on both `struct trb_open_priv` and… - [Low] mtk_port_ch_enable() resets port->tx_seq and port->rx_seq with plain stores while the TRB kthread… - [Low] The concern: struct mtk_port is kfree()d in mtk_port_release() while TRBs (trb->priv) or armed RX queues (rxq->arg) still point at… - [Low] mtk_port_internal_close() clears PORT_S_OPEN twice: once with test_and_clear_bit() and again in mtk_port_common_close(). - [Low] mtk_port_release() runs with the global mtk_port_mngr_grp_mtx held and calls ->exit(). - [Low] mtk_port_send_data() does not compare skb->len with port->tx_mtu, and mtk_cldma_submit_tx() writes data_buff_len = cpu_to_le16(skb->len)… -- net: wwan: t9xx: Add control port This patch adds the port I/O layer and the port manager to the t9xx WWAN driver. Together they build and tear down the port table and move control data to and from CLDMA through TRBs. It also gives struct trb a kref so the TRB handler holds a reference while it dispatches, and it stamps the TX sequence number when the packet is handed to the hardware. > diff --git a/drivers/net/wwan/t9xx/mtk_port.c b/drivers/net/wwan/t9xx/mtk_port.c > new file mode 100644 > index 0000000000000..410bd4d506a7b > --- /dev/null > +++ b/drivers/net/wwan/t9xx/mtk_port.c > @@ -0,0 +1,641 @@ [ ... ] > +/* Called with mtk_port_mngr_grp_mtx held. */ > +void mtk_port_release(struct kref *port_kref) > +{ > + struct mtk_port *port; > + > + port = container_of(port_kref, struct mtk_port, kref); > + mtk_port_get_ops(port->info.type)->exit(port); > + kfree(port); > +} [Severity: Low] Can the port be freed here while a TRB (trb->priv) or an armed RX queue (rxq->arg) still points at it? mtk_port_trb_init() takes no reference on the port. Also, mtk_port_ch_trb_complete() publishes trb->done before it touches the port's waitqueue: smp_store_release(&trb->done, true); wake_up_all(&port->trb_wq); So a waiter that sees done and returns could, in principle, overlap with the wake_up_all(). At this commit nothing calls ->enable() or submits a TRB, so this path is not live yet. Later in the series, mtk_trans_ctrl_exit() calls mtk_pcie_hif_exit() before mtk_ctrl_exit()->mtk_port_mngr_exit(). That quiesces CLDMA, stops the TRB thread and flushes pending TRBs, and the FSM thread has already been stopped. That order looks like it prevents the overlap. Would a comment near mtk_port_release() help? It could say that ports may only be freed after the HIF teardown has joined every completer. [ ... ] > +int mtk_port_send_data(struct mtk_port *port, void *data, bool blocking, bool force_send) > +{ [ ... ] > + /* add ccci header */ > + ret = mtk_port_add_header(skb); > + if (!ret) > + ret = mtk_port_status_check(port); > + if (!ret) > + ret = mtk_pcie_hif_submit_skb(port_mngr->ctrl_blk->mdev, skb, > + force_send); [Severity: Low] Is there a reason mtk_port_send_data() does not compare skb->len with port->tx_mtu before it submits? mtk_cldma_submit_tx() also writes data_buff_len = cpu_to_le16(skb->len) with no MTU check. As far as I can tell, every TX producer in the series already bounds the length: - mtk_port_common_write(), added in "Add AT & MBIM WWAN ports", splits payloads into tx_mtu-sized packets. - The FSM's HS1 and HS3 messages are far below Q_MTU_3_5K - MTK_CCCI_H_ELEN. The port->tx_mtu value set in mtk_port_ch_enable() is not used at this commit. A check here would only be defense in depth. The missing check in mtk_cldma_submit_tx() comes from the earlier CLDMA patch. [ ... ] > +static int mtk_port_rx_dispatch(struct sk_buff *skb, void *priv) > +{ > + struct mtk_port_mngr *port_mngr; > + struct mtk_ccci_header *ccci_h; > + struct mtk_port *port = priv; > + int ret = -EPROTO; > + u16 channel; > + > + if (!skb || !priv) { > + pr_err("Invalid input value in rx dispatch\n"); > + return -EINVAL; > + } [Severity: Low] This isn't a bug, but the rx_done contract in struct trb_open_priv says: /* consumes the skb; the return value is informational */ int (*rx_done)(struct sk_buff *skb, void *priv); This early return does not free a non-NULL skb when priv is NULL. priv comes from rxq->arg, which mtk_cldma_open() copies from trb->priv. mtk_port_trb_init() always sets that to a port that mtk_port_ch_enable() has already dereferenced, so the guard looks unreachable. Should the guard free the skb, or be removed? [ ... ] > +int mtk_port_ch_enable(struct mtk_port *port) > +{ [ ... ] > + /* The modem restarts its sequence numbering with the channel, and > + * the first packet after it is not checked. > + */ > + port->tx_seq = 0; > + port->rx_seq = MTK_INVALID_RX_SEQ; [Severity: Low] Can these plain stores race with the TRB kthread in mtk_port_tx_seq_stamp() and mtk_port_tx_seq_advance(), or with mtk_port_rx_dispatch()? None of these accesses are synchronized. For tx_seq it looks unreachable: - ->enable() returns early when PORT_S_ENABLE is set. - TX needs PORT_S_ENABLE and PORT_S_WR via mtk_port_status_check(). - A TX skb that passes the status check in mtk_port_send_data() and is queued after the flush fails in mtk_cldma_submit_tx() because the txq is closed. - At the end of the series FSM_STATE_OFF is terminal, so no re-enable follows. The overlap that remains is on rx_seq. It needs this sequence: an ENABLE times out, the follow-up mtk_port_ch_disable() submit fails, and a later enable gets -EBUSY while the RX queue armed by the first ENABLE is still running. The worst effect seems to be one spurious or missed out-of-order warning from mtk_port_check_rx_seq(). At this commit nothing calls ->enable(). [ ... ] > diff --git a/drivers/net/wwan/t9xx/mtk_port_io.c b/drivers/net/wwan/t9xx/mtk_port_io.c > new file mode 100644 > index 0000000000000..912b04c24784c > --- /dev/null > +++ b/drivers/net/wwan/t9xx/mtk_port_io.c > @@ -0,0 +1,236 @@ [ ... ] > +static void mtk_port_internal_exit(struct mtk_port *port) > +{ > + if (test_bit(PORT_S_ENABLE, &port->status)) > + mtk_port_get_ops(port->info.type)->disable(port); > +} [Severity: Low] mtk_port_release() calls ->exit() with the global mtk_port_mngr_grp_mtx held. If PORT_S_ENABLE were still set here, ->disable() would reach mtk_port_ch_disable(). That function allocates with GFP_KERNEL, takes trans->submit_lock, and waits up to MTK_DFLT_TRB_TIMEOUT. Would that create a mtk_port_mngr_grp_mtx -> submit_lock lock ordering? >>From what I can see the branch is never taken: - The last kref_put() comes after mtk_port_tbl_destroy() has run ->disable() on every port. - The FSM thread, the only caller of ->enable(), is stopped before mtk_port_mngr_exit(). - In the mtk_port_mngr_init() error path, no port was ever enabled. Is this branch needed, given that callers always disable first? [ ... ] > +static void mtk_port_common_close(struct mtk_port *port) > +{ > + clear_bit(PORT_S_OPEN, &port->status); > + > + set_bit(PORT_S_FLUSH, &port->status); > + wake_up_all(&port->trb_wq); > +} [ ... ] > +int mtk_port_internal_close(void *i_port) > +{ [ ... ] > + /* Claim the close: a second caller must not drop the reference again. > + * mtk_port_common_close() clears the bit itself, for every port type. > + */ > + if (!test_and_clear_bit(PORT_S_OPEN, &port->status)) { > + pr_err("Port(%s) has been closed\n", port->info.name); > + ret = -EBADF; > + goto end; > + } > + > + mtk_port_common_close(port); > + mtk_port_put_locked(port); [Severity: Low] PORT_S_OPEN is cleared twice on this path: once by test_and_clear_bit() here, and again by clear_bit() in mtk_port_common_close(). If an open ran between the two clears, could it lose its OPEN claim, end up with PORT_S_FLUSH set, and leak its port reference? That would need a concurrent open and close on the same internal port. In the series the only internal user is the FSM: mtk_fsm_ctrl_ch_start() and mtk_fsm_ctrl_ch_stop() run on the FSM kthread, or after kthread_stop(). WWAN open and close are serialized by the WWAN core's ops_lock. So the second clear_bit() looks redundant rather than racy. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-t9xx_driver_v1-v13-0-92d9be5fb51e%40compal.com