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
Subject: Re: [PATCH net-next v12 1/6] net: wwan: t9xx: Add PCIe core
Date: Sat, 21 Nov 2026 12:42:25 +0000 [thread overview]
Message-ID: <179526494505.3135.4658538684680862441@kernel.org> (raw)
In-Reply-To: <20261117-t9xx_driver_v1-v12-1-e181b616b820@compal.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] mtk_pci_remove() resets the modem itself after
pci_save_state(), and mtk_pci_shutdown() reuses it on a kexec reboot.
- [Low] mtk_pci_probe() enables the device with pcim_enable_device(),
which sets pdev->is_managed.
--
net: wwan: t9xx: Add PCIe core
This commit adds the PCIe core for the MediaTek T9xx 5G WWAN modem driver.
It covers probe/remove, MSI-X setup, the MHCCIF event channels and the
register accessors. On removal, and on shutdown during a kexec reboot, the
modem is reset through ACPI MRST._RST, falling back to the MHCCIF
DEV_EVT_H2D_DEVICE_RESET doorbell.
> diff --git a/drivers/net/wwan/t9xx/pcie/mtk_pci.c b/drivers/net/wwan/t9xx/pcie/mtk_pci.c
> new file mode 100644
> index 0000000000000..cf59038f09067
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_pci.c
> @@ -0,0 +1,1034 @@
[ ... ]
> +static int mtk_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> +{
[ ... ]
> + ret = pcim_enable_device(pdev);
> + if (ret) {
> + dev_err(mdev->dev, "Failed to enable pci device.\n");
> + goto log_err;
> + }
[ ... ]
> +free_irq:
> + mtk_pci_free_irq(mdev);
> +free_mhccif:
> + mtk_mhccif_exit(mdev);
> + pci_free_irq_vectors(pdev);
[Severity: Low]
Is it safe to call pci_free_irq_vectors() here and in mtk_pci_remove() when
the device was enabled with pcim_enable_device()?
pcim_enable_device() sets pdev->is_managed. Because of that,
pci_alloc_irq_vectors() in mtk_pci_request_irq() goes through
pci_setup_msi_context()->pcim_setup_msi_release(), which registers
pcim_msi_release() as a devres action.
The kernel-doc of pci_free_irq_vectors() in drivers/pci/msi/api.c says:
* WARNING: Do not call this function if the device has been enabled
* with pcim_enable_device(). In that case, IRQ vectors are automatically
* managed via pcim_msi_release() and calling pci_free_irq_vectors() can
* lead to double-free issues.
After a failed probe, or once mtk_pci_remove() returns, devres calls
pci_free_irq_vectors() a second time. Today that does nothing, because
pci_disable_msix() returns early when !dev->msix_enabled. The TODO in
drivers/pci/msi/msi.c says this implicit managed behaviour is going to
change, though, so the driver would then be relying on an idempotence that
may go away.
This is still the same at the end of the series.
> + priv->irq_cnt = 0;
> +disable_atr:
> + mtk_pci_atr_disable(priv);
[ ... ]
> +static void mtk_pci_remove(struct pci_dev *pdev)
> +{
[ ... ]
> + mtk_pci_free_irq(mdev);
> + mtk_mhccif_exit(mdev);
> + pci_free_irq_vectors(pdev);
> + priv->irq_cnt = 0;
> + pci_clear_master(pdev);
> + /* A dead link reads all-ones: keep the copy saved while it was up. */
> + if (mtk_pci_link_check(mdev))
> + pci_save_state(pdev);
> +
> + /* Reset last: the endpoint comes back at power-on defaults, so no MMIO
> + * and no MSI-X teardown may follow it.
> + */
> + ret = mtk_pci_pldr(mdev);
[Severity: Medium]
Could pciehp treat this reset as a surprise removal of the modem?
MRST._RST in mtk_pci_pldr() is a platform reset that drops and retrains the
link. The MHCCIF DEV_EVT_H2D_DEVICE_RESET fallback below may drop the link
too, depending on the firmware.
Neither path is wrapped in pci_hp_ignore_link_change() and
pci_hp_unignore_link_change() on pdev->bus->self. Their kernel-doc covers
this case:
* Mark the beginning of a code section causing spurious link changes on the
* Secondary Bus of @pdev, e.g. as a side effect of a Secondary Bus Reset,
* D3cold transition, firmware update or FPGA reconfiguration.
...
* Must be paired with pci_hp_unignore_link_change(). May be called both
* from the PCI core and from Endpoint drivers.
pciehp_ist() ignores the link events only when that bracket is set:
drivers/pci/hotplug/pciehp_hpc.c:pciehp_ist() {
...
if ((events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC)) &&
(pci_dpc_recovered(pdev) || pci_hp_spurious_link_change(pdev)) &&
ctrl->state == ON_STATE) {
...
}
Without the bracket, on a hotplug-capable upstream port,
pciehp_handle_presence_or_link_change() would disable the slot, mark the
device disconnected and re-enumerate it.
Once the device is marked disconnected, pci_device_is_present() returns
false. The 50 x 20 ms poll on mtk_pci_link_check() then runs to the end and
the "device not back" warning fires. pci_restore_state() is then sent to a
device the core has already given up on.
The core's own pciehp_reset_slot() brackets its link-dropping bus reset with
these helpers. Would it make sense to do the same around both reset paths
here? mtk_pci_shutdown() runs this same code during a kexec reboot.
This is still the same at the end of the series.
> + if (!ret) {
> + /* MRST._RST may return before the link has retrained, and a
> + * config write the device does not take is simply lost.
> + */
> + for (i = 0; i < MTK_PLDR_READY_POLLS && !mtk_pci_link_check(mdev); i++)
> + msleep(MTK_PLDR_READY_POLL_MS);
> + if (!mtk_pci_link_check(mdev))
> + dev_warn(dev, "device not back %d ms after reset, its config space may not be restored\n",
> + MTK_PLDR_READY_POLLS * MTK_PLDR_READY_POLL_MS);
> + } else if (!mtk_pci_link_check(mdev)) {
> + dev_warn(dev, "PLDR failed (%d) and link is down, modem not reset\n", ret);
> + } else {
> + dev_warn(dev, "PLDR failed (%d), trying MHCCIF reset\n", ret);
> + if (mtk_pci_send_ext_evt(mdev, DEV_EVT_H2D_DEVICE_RESET)) {
[ ... ]
> + /* The reset returned the endpoint to its power-on defaults: put back
> + * the saved config space for the next driver that binds.
> + */
> + pci_restore_state(pdev);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-t9xx_driver_v1-v12-0-e181b616b820%40compal.com
next prev parent reply other threads:[~2026-11-21 12:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 10:50 [PATCH net-next v12 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-17 10:50 ` [PATCH net-next v12 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-17 15:28 ` Loic Poulain
2026-11-18 2:41 ` [External Mail] " Wu. JackBB (GSM)
2026-11-21 12:42 ` netdev-bot+sashiko [this message]
2026-11-17 10:50 ` [PATCH net-next v12 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-17 15:31 ` Loic Poulain
2026-11-18 2:44 ` Wu. JackBB (GSM)
2026-11-17 10:50 ` [PATCH net-next v12 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-21 12:42 ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-21 12:42 ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-21 12:42 ` netdev-bot+sashiko
2026-11-17 10:50 ` [PATCH net-next v12 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=179526494505.3135.4658538684680862441@kernel.org \
--to=netdev-bot+sashiko@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@kernel.org \
--cc=horms@kernel.org \
--cc=jackbb_wu@compal.com \
--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@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®