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=1796291201; b=NU7rZfQ+5nl/G8fIHxDBmPbNy+WXzEaBr6gVUNapF7//xxC33WnlEPa5bgazbiJ65WcE +bLcrxGC5Cd2YVhvQZHUS9JAw/o4v3lle70mWw3ZPnVTOHCfjFdzGIL/P1znaYtKXVP3e BgcxmmA4i1pfEg6gwSc66JcyzmEOxrGZ3p7c8IuUPFAXFqginl1QrrmlzT7ru2hOjUXmL Wb4kREq4klaa4EEvVX58DhygnM86wgtjk93dD4YfA7cqGXtVWLHGQaxXZuQquzP8lW261 IyKLIH5KAQHHjsnwIO38o2FqXSEDk2+fO9ONiv7r5FD6Fn2OjHqeYJciQDARwQ+3Zng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291201; 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=wIu5oaCPpgSnkfGoZOVfQ8JxdG6q8hd2U1tpIGca7sQ=; b=2fXJz6jbV8s0JzqNXzKc0JcD3AHhDPr+4izrPiWDsPSyNl2iKkKz3OCMGF1lQpZR8s7+ jYZJn2uMoxnm1BQ+thX9i8WbYNFV9sJyN8sOI552v+8k0AqsWZWXsXZYq5Jo2uBEE1AEQ mpjSF+44KR8GS4pVi20MOkqanQeiOHRBG0dYTuMWZ04QaS16becBNcZqq5msQCeKuo+QD vV9RlP1uF0R6BHrE/D72Zhaaypg1gjhHowaqsLIj5c2IMXQzWsK8SxphKs6ueTornId15 kvuBmshobFkF44DCZHQiz8OGhILaZD9Az5WvLPOePCu33g5v1g1dRfNVe5CV1Gpbiwg== 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=AN3W+MbZ; 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 B6A36606A68F; Thu, 3 Dec 2026 09:46:41 +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=AN3W+MbZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 649491F0089B; Thu, 3 Dec 2026 09:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291201; bh=wIu5oaCPpgSnkfGoZOVfQ8JxdG6q8hd2U1tpIGca7sQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=AN3W+MbZXm3DxUasqJj7DwscAajs5u9GSu9R2Rry27xXwOZHG04EG9/xH7NXeL+R6 sLJ3SyGA8+eMCufV0Xi3bXjWx6LWMB0HVK4lFZAZerexKoFFuBf8u2x91brQ1c0wJM CCZcCXNeAwFFtIJB4kkKrDfghSJIee9Iw64iAm1l+VOqhFXJlTP/sLVRKfmGXVIT8u Hs567tm4Ve7HDX+J0IMLcc0+06dLx6RJTUQCs2NjB4YWDChsQOl61oK6k7VepzGNwY aK3GbqKwwjMkzcjB/4vqvD5Vq62RXQulSTxw3GaHe2s7uqJaadAQQLmAKAngd260xP WiRezW54QA7QQ== Subject: Re: [PATCH net-next v14 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: Thu, 03 Dec 2026 09:46:39 +0000 Message-ID: <179629119999.3146.8573557356536424800@kernel.org> In-Reply-To: <20261202-t9xx_driver_v1-v14-4-08ebc870ea94@compal.com> References: <20261202-t9xx_driver_v1-v14-4-08ebc870ea94@compal.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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] mtk_port_alloc_and_add() (drivers/net/wwan/t9xx/mtk_port.c) inserts the kzalloc()'ed port into port_mngr->port_tbl[] with… - [Low] mtk_port_internal_close() (drivers/net/wwan/t9xx/mtk_port_io.c) clears PORT_S_OPEN with test_and_clear_bit() before… -- net: wwan: t9xx: Add control port This adds the t9xx port I/O layer and the port manager. Together they create and manage the control ports and pass TRBs between the ports and CLDMA. The patch also gives struct trb a kref, so the TRB handler holds a reference while it dispatches, and it stamps the TX sequence number at hardware hand-off. > diff --git a/drivers/net/wwan/t9xx/mtk_port.c b/drivers/net/wwan/t9xx/mtk_port.c > new file mode 100644 > index 0000000000000..95b8ba4993cdc > --- /dev/null > +++ b/drivers/net/wwan/t9xx/mtk_port.c [ ... ] > +static struct mtk_port *mtk_port_alloc_and_add(struct mtk_port_mngr *port_mngr, > + const struct mtk_port_cfg *dflt_info) > +{ > + struct mtk_port *port; > + int ret; > + > + port = kzalloc_obj(*port, GFP_KERNEL); > + if (!port) { > + ret = -ENOMEM; > + goto err_alloc_port; > + } > + memcpy(&port->info, dflt_info, sizeof(*dflt_info)); > + > + ret = mtk_port_tbl_add(port_mngr, port); > + if (ret < 0) { > + dev_err(port_mngr->ctrl_blk->mdev->dev, > + "Failed to add port(%s) to port tbl\n", dflt_info->name); > + goto err_free_port; > + } > + > + port->port_mngr = port_mngr; > + ret = mtk_port_get_ops(port->info.type)->init(port); > + if (ret < 0) { > + mtk_port_tbl_del(port_mngr, port); > + goto err_free_port; > + } [Severity: Low] This isn't a bug, but should the port be fully set up before it goes into port_tbl[]? mtk_port_tbl_add() publishes the port with xa_insert() before port->port_mngr is set. It also runs before ->init() calls mtk_port_struct_init(): mtk_port_struct_init() { clear_bit(PORT_S_ENABLE, &port->status); kref_init(&port->kref); init_waitqueue_head(&port->trb_wq); } Suppose a lookup such as mtk_port_get_by_name() found the port in this window. It would kref_get() a zero refcount, and the port would still have a NULL port->port_mngr. On ->init() failure the port is also freed with a plain kfree() after xa_erase(). As far as I can tell, this cannot happen in the current series: - mtk_port_mngr_init() sets ctrl_blk->port_mngr only after mtk_port_tbl_create() returns. - Every reader gets port_mngr either from ctrl_blk->port_mngr or from a port that is already in the table. - Every ->init() returns 0, so the kfree() on init failure never runs. Would it still be clearer to set port->port_mngr and call ->init() before mtk_port_tbl_add(), so the ordering no longer depends on those conditions? [ ... ] > 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..392d2ae54ef55 > --- /dev/null > +++ b/drivers/net/wwan/t9xx/mtk_port_io.c [ ... ] > +static int mtk_port_common_open(struct mtk_port *port) > +{ > + int ret = 0; > + > + if (!test_bit(PORT_S_ENABLE, &port->status)) > + return -ENODEV; > + > + if (test_and_set_bit(PORT_S_OPEN, &port->status)) > + return -EBUSY; > + > + clear_bit(PORT_S_FLUSH, &port->status); > + > + return ret; > +} > + > +static void mtk_port_common_close(struct mtk_port *port) > +{ > + set_bit(PORT_S_FLUSH, &port->status); > + wake_up_all(&port->trb_wq); > +} [ ... ] > +int mtk_port_internal_close(struct mtk_port *port) > +{ > + int ret = 0; > + > + if (!port) { > + ret = -EINVAL; > + goto end; > + } > + > + /* Claim the close: a second caller must not drop the reference again. */ > + 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); [Severity: Low] Could an open run between the clear of PORT_S_OPEN and the set of PORT_S_FLUSH here? If mtk_port_common_open() ran in that window, the order would be: close: test_and_clear_bit(PORT_S_OPEN) open: test_and_set_bit(PORT_S_OPEN) open: clear_bit(PORT_S_FLUSH) close: mtk_port_common_close()->set_bit(PORT_S_FLUSH) The port would then have both PORT_S_OPEN and PORT_S_FLUSH set. mtk_port_status_check() would fail every write with -EBADF until the port is closed again. This doesn't look reachable in the series: - The internal ports are opened and closed only from mtk_fsm_ctrl_ch_start() and mtk_fsm_ctrl_ch_stop(). - Both run in the single FSM kthread. - mtk_fsm_stop() joins that thread with kthread_stop() before it calls mtk_fsm_ctrl_ch_stop() itself. - The WWAN ports added later in the series do the same steps under port->w_priv.w_lock. The comment above enum mtk_port_status says callers serialise ->enable(), ->disable() and open of a port. Should it mention close as well, since this sequence also depends on that? > + mtk_port_put_locked(port); > +end: > + return ret; > +} -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-t9xx_driver_v1-v14-0-08ebc870ea94%40compal.com