The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: jackbb_wu@compal.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com,
	johannes@sipsolutions.net, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, 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, 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
Subject: Re: [PATCH v6 2/7] net: wwan: t9xx: Add control plane transaction layer
Date: Mon, 17 Aug 2026 15:36:52 -0700	[thread overview]
Message-ID: <20260817223652.3688666-1-kuba@kernel.org> (raw)
In-Reply-To: <20260811-t9xx_driver_v1-v6-2-2c969fad57c6@compal.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: wwan: t9xx: Add control plane transaction layer

This patch adds the mtk_ctrl_blk and mtk_ctrl_trans data structures along
with mtk_ctrl_init()/mtk_ctrl_exit() for the T9XX WWAN driver.  It also
splits the build into a separate pcie/ Makefile gated by a new hidden
MTK_T9XX_PCI symbol.

A couple of questions below about the module split and the mtk_ctrl_exit()
documentation.

> diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig
> index 18bd40b3b8d21..a2ffed346acc9 100644
> --- a/drivers/net/wwan/Kconfig
> +++ b/drivers/net/wwan/Kconfig
> @@ -124,6 +124,7 @@ config MTK_T7XX
>  config MTK_T9XX
>  	tristate "MediaTek PCIe 5G WWAN modem T9xx device"
>  	depends on PCI && ACPI
> +	select MTK_T9XX_PCI
>  	select NET_DEVLINK
>  	help
>  	  Enables MediaTek PCIe based 5G WWAN modem (T9xx series) device.
> @@ -133,6 +134,10 @@ config MTK_T9XX
>  
>  	  If unsure, say N.
>  
> +config MTK_T9XX_PCI
> +	tristate
> +	depends on PCI
> +
>  endif # WWAN
>  
>  endmenu
> diff --git a/drivers/net/wwan/t9xx/Makefile b/drivers/net/wwan/t9xx/Makefile
> index 6f2dd3f914543..ae9d6f2344ab4 100644
> --- a/drivers/net/wwan/t9xx/Makefile
> +++ b/drivers/net/wwan/t9xx/Makefile
> @@ -4,7 +4,8 @@ ccflags-y += -I$(src)/pcie
>  ccflags-y += -I$(src)
>  
>  obj-$(CONFIG_MTK_T9XX) += mtk_t9xx.o
> +obj-$(CONFIG_MTK_T9XX_PCI) += pcie/
>  
>  mtk_t9xx-y := \
> -	pcie/mtk_pci.o \
> -	pcie/mtk_pci_drv_m9xx.o
> +	mtk_dev.o \
> +	mtk_ctrl_plane.o

[Severity: Low]
Should the commit message mention this module split?  Before this patch
mtk_t9xx-y contained pcie/mtk_pci.o and pcie/mtk_pci_drv_m9xx.o, so
mtk_t9xx.ko was the module carrying module_pci_driver() and
MODULE_DEVICE_TABLE(pci, ...) from mtk_pci.c.

After this patch those two objects move into a second module built from
pcie/Makefile:

  obj-$(CONFIG_MTK_T9XX_PCI) += mtk_t9xx_pcie.o

  mtk_t9xx_pcie-y := \
	mtk_pci_drv_m9xx.o \
	mtk_pci.o

so the module that binds the hardware and carries the PCI modaliases is
now mtk_t9xx_pcie.ko, while mtk_t9xx.ko only holds mtk_dev.o and
mtk_ctrl_plane.o with no driver registration.

The MTK_T9XX help text still says:

	  To compile this driver as a module, choose M here: the module will be
	  called mtk_t9xx.

Should that be updated to name mtk_t9xx_pcie as well?  The new hidden
MTK_T9XX_PCI symbol, which is what actually gates building the PCI driver
objects, is not described anywhere either.  Both the split and the help
text are still in this shape at the end of the series (cbf822bf).

> diff --git a/drivers/net/wwan/t9xx/mtk_ctrl_plane.c b/drivers/net/wwan/t9xx/mtk_ctrl_plane.c
> new file mode 100644
> index 0000000000000..cf6079218e1ce
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/mtk_ctrl_plane.c
> @@ -0,0 +1,45 @@

[ ... ]

> +int mtk_ctrl_init(struct mtk_md_dev *mdev)
> +{
> +	struct mtk_ctrl_blk *ctrl_blk;
> +
> +	ctrl_blk = devm_kzalloc(mdev->dev, sizeof(*ctrl_blk), GFP_KERNEL);
> +	if (!ctrl_blk)
> +		return -ENOMEM;
> +
> +	ctrl_blk->mdev = mdev;
> +	mdev->ctrl_blk = ctrl_blk;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(mtk_ctrl_init);
> +
> +/**
> + * mtk_ctrl_exit() - Clean up the control plane block.
> + * @mdev: Pointer to the MTK modem device.
> + *
> + * Frees the control plane block associated with @mdev.
> + */
> +void mtk_ctrl_exit(struct mtk_md_dev *mdev)
> +{
> +	mdev->ctrl_blk = NULL;
> +}
> +EXPORT_SYMBOL(mtk_ctrl_exit);

[Severity: Low]
Does the kernel-doc for mtk_ctrl_exit() match what the function does?  The
comment says "Frees the control plane block associated with @mdev", but the
body only clears the pointer:

  void mtk_ctrl_exit(struct mtk_md_dev *mdev)
  {
	mdev->ctrl_blk = NULL;
  }

The block comes from devm_kzalloc(mdev->dev, ...) in mtk_ctrl_init(), so it
stays on the device's devres list until driver detach.

Tracing the callers at the end of the series (cbf822bf), mtk_ctrl_init() is
only reached via mtk_pci_probe()->mtk_pci_dev_init()->mtk_trans_ctrl_init(),
and mtk_ctrl_exit() only from the probe error path and mtk_pci_remove(), so
there is one init/exit per device lifetime and nothing is actually leaked
here.

The wording is still "Frees the control plane block" at cbf822bf, where the
body unregisters the FSM notifier, calls mtk_port_mngr_exit() and nulls the
pointer.  Could the doc be reworded to say the pointer is cleared and the
allocation is released by devres, so a later patch adding an explicit
devm_kfree() does not end up double freeing it?

  reply	other threads:[~2026-08-17 22:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  7:14 [PATCH v6 0/7] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-08-11  7:14 ` [PATCH v6 1/7] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-08-17 22:35   ` Jakub Kicinski
2026-08-11  7:14 ` [PATCH v6 2/7] net: wwan: t9xx: Add control plane transaction layer Jack Wu via B4 Relay
2026-08-17 22:36   ` Jakub Kicinski [this message]
2026-08-11  7:14 ` [PATCH v6 3/7] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-08-17 22:36   ` Jakub Kicinski
2026-08-11  7:14 ` [PATCH v6 4/7] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-08-11  7:14 ` [PATCH v6 5/7] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-08-17 22:36   ` Jakub Kicinski
2026-08-11  7:14 ` [PATCH v6 6/7] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay
2026-08-17 22:36   ` Jakub Kicinski
2026-08-11  7:14 ` [PATCH v6 7/7] net: wwan: t9xx: Add maintainers entry Jack Wu via B4 Relay
2026-08-17 22:38   ` Jakub Kicinski
2026-08-17 22:39 ` [PATCH v6 0/7] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jakub Kicinski

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=20260817223652.3688666-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --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=jackbb_wu@compal.com \
    --cc=johannes@sipsolutions.net \
    --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@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