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 v13 1/6] net: wwan: t9xx: Add PCIe core
Date: Sun, 29 Nov 2026 07:39:22 +0000 [thread overview]
Message-ID: <179593796217.3146.12932735833019291995@kernel.org> (raw)
In-Reply-To: <20261125-t9xx_driver_v1-v13-1-92d9be5fb51e@compal.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 5
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_drv sets no .driver.pm, so the PCI core uses its
default handling for suspend/resume: it saves and restores config…
- [Medium] mtk_pci_remove() never confirms that the modem actually went
through reset before it calls pci_restore_state() (line 1001).
- [Low] On kexec, mtk_pci_shutdown()
(drivers/net/wwan/t9xx/pcie/mtk_pci.c:1008) calls mtk_pci_remove()…
- [Low] The kernel-doc of mtk_pci_pldr() says that -EIO means "MRST._RST
failed.
- [Low] mtk_pci_remove() calls mtk_pci_pldr() (line 963) without first
checking whether the device has already been marked disconnected.
- [Low] mtk_pci_error_detected() (line 1014) only logs and returns
PCI_ERS_RESULT_DISCONNECT, with the comment 'disconnect the device'.
- [Low] mtk_pci_request_irq() (line 822) allocates 32 MSI-X vectors but
deliberately never writes the MAC's MSI-X configuration register.
--
net: wwan: t9xx: Add PCIe core
This adds the PCIe core of the MediaTek T9xx 5G WWAN modem driver:
probe/remove, MSI-X setup, ATR programming, the MHCCIF event channels,
and the modem reset done on removal and on kexec shutdown. It also adds
the Kconfig, Makefile and MAINTAINERS entries.
> 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..72b8e7043bd17
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_pci.c
> @@ -0,0 +1,1041 @@
[ ... ]
> +/**
> + * mtk_pci_pldr() - Reset the modem via its ACPI MRST._RST method
> + * @mdev: MTK MD device
> + *
> + * Return:
> + * * 0 - Success, device was reset.
> + * * -ENODEV - No ACPI, no handle or no MRST._RST method. Device
> + * untouched.
> + * * -EIO - MRST._RST failed. Device untouched, still running;
> + * a different reset may be attempted.
> + */
> +static int mtk_pci_pldr(struct mtk_md_dev *mdev)
> +{
[ ... ]
> + acpi_ret = acpi_evaluate_object(handle, "MRST._RST", NULL, NULL);
> + if (ACPI_FAILURE(acpi_ret)) {
> + dev_err(mdev->dev, "Failed to execute MRST._RST method: %s\n",
> + acpi_format_exception(acpi_ret));
> + return -EIO;
> + }
[Severity: Low]
Can mtk_pci_pldr() actually promise "Device untouched, still running" on
-EIO? The only check is ACPI_FAILURE() on the acpi_evaluate_object()
status. A failure status doesn't say whether the AML had already toggled
a reset GPIO or power rail before it failed.
mtk_pci_remove() relies on this promise. On -EIO with
pci_device_is_present() still true, it rings the DEV_EVT_H2D_DEVICE_RESET
doorbell through BAR2/3 and then sleeps 2 seconds. A device that is part
way through a reset can still answer the Vendor ID config read.
Should the kernel-doc be relaxed, or should the MHCCIF fallback be
skipped on -EIO?
[ ... ]
> +static int mtk_pci_request_irq(struct mtk_md_dev *mdev)
> +{
> + struct pci_dev *pdev = to_pci_dev(mdev->dev);
> + int ret;
> +
> + /* 32 vectors map 1:1 at the MAC's power-on default and the driver
> + * never merges them, so the MSI-X config register is left alone.
> + */
> + ret = pci_alloc_irq_vectors(pdev, MTK_IRQ_CNT_MAX,
> + MTK_IRQ_CNT_MAX, PCI_IRQ_MSIX);
[Severity: Low]
Is it safe to rely on the power-on default here? mtk_pci_irq_msix()
limits each vector to its own bit:
irq_state &= irq_desc->msix_bits; /* scope to this vector */
if (unlikely(!irq_state))
return IRQ_NONE;
So delivery depends on ISTATUS bit N being routed to vector N.
Probe doesn't reset the modem. The commit message says the device can
arrive un-reset, for example in a kdump capture kernel or after a failed
removal reset. If something earlier changed the MAC MSI-X mapping (for
example a vendor driver in the kexec'ing kernel that merged vectors), the
MHCCIF event (bit 28) could arrive on a vector whose msix_bits doesn't
include bit 28.
In that case the handler returns IRQ_NONE without masking or dispatching
the event. The boot handshake would never complete, and genirq may
eventually disable the vector.
The t7xx driver treats this register as host-owned. It programs it with
t7xx_pcie_set_mac_msix_cfg() at probe and again in
t7xx_pcie_interrupt_reinit(). Would programming it explicitly here be
more robust?
[ ... ]
> +static void mtk_pci_remove(struct pci_dev *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);
> + 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);
[Severity: Low]
What happens here on a surprise removal? With presence == false,
pciehp_unconfigure_device() calls pci_dev_set_disconnected() before the
driver is unbound. After that, pci_device_is_present() always returns
false:
drivers/pci/pci.c:pci_device_is_present() {
...
if (pci_dev_is_disconnected(pdev))
return false;
...
}
If MRST._RST succeeds in that case, this loop always runs all 50 x 20 ms
iterations and always prints the "device not back" warning. Then
pci_restore_state() runs on a disconnected device. The platform reset is
also issued for a slot that pciehp has already declared gone.
Should mtk_pci_remove() check pci_dev_is_disconnected() before it
attempts the reset?
> + } else if (!mtk_pci_link_check(mdev)) {
> + dev_warn(dev, "PLDR failed (%d) and link is down, modem not reset\n", ret);
> + } else {
> + if (ret == -ENODEV)
> + dev_info(dev, "no MRST._RST, trying MHCCIF reset\n");
> + else
> + dev_warn(dev, "PLDR failed (%d), trying MHCCIF reset\n", ret);
> + if (mtk_pci_send_ext_evt(mdev, DEV_EVT_H2D_DEVICE_RESET)) {
> + dev_err(dev, "MHCCIF reset failed\n");
> + } else {
> + /* Unlike MRST._RST the doorbell returns before the device
> + * has reset, and whether the link drops is up to the
> + * firmware: wait a fixed time, then for a link that is
> + * still down to come back, before the restore below.
> + */
> + msleep(MTK_MHCCIF_RESET_DELAY_MS);
> + 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 MHCCIF reset, its config space may not be restored\n",
> + MTK_MHCCIF_RESET_DELAY_MS +
> + MTK_PLDR_READY_POLLS * MTK_PLDR_READY_POLL_MS);
> + }
> + }
> +
> + /* 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);
> +}
[Severity: Medium]
Does a link that is up after the fixed delay show that the reset has
actually happened? mtk_pci_send_ext_evt() posts the doorbell writes and
returns 0 straight away:
mtk_pci_write32(mdev, rc_base + MHCCIF_RC2EP_SW_BSY, hw_bits);
mtk_pci_write32(mdev, rc_base + MHCCIF_RC2EP_SW_TCHNUM, ffs(hw_bits) - 1);
return 0;
mtk_pci_link_check() is only a Vendor ID config read. It can't tell "not
reset yet, link still up" apart from "reset and back".
Suppose the firmware carries out the reset after the 2 second window.
Then pci_restore_state() writes to the device before the reset, and the
late reset wipes it, with no warning. The BARs and PCI_COMMAND would be
left at power-on defaults. The next probe's pcim_enable_device() doesn't
reprogram the BAR registers, so pcim_iomap_region() would map addresses
the device no longer decodes.
The MRST._RST path seems to have the same gap if _RST returns before the
link has dropped, since the first presence check then passes at once.
The comment above that loop says _RST "may return before the link has
retrained", which suggests it can be asynchronous.
Is there a positive sign of reset completion that could be waited for
before the restore? For example, a device state register returning to
its reset value, or the link going down first.
> +/* A kexec reboot neither resets nor powers down the slot, and the boot
> + * notification the next kernel waits for is one-shot, so reset the modem
> + * on the way down the same way remove() does.
> + */
> +static void mtk_pci_shutdown(struct pci_dev *pdev)
> +{
> + if (kexec_is_in_progress())
> + mtk_pci_remove(pdev);
> +}
[Severity: Low]
Can mtk_pci_remove() end up running twice on a kexec reboot? The driver
core doesn't know that shutdown already ran remove, so the driver stays
bound.
Below a hotplug-capable port the reset drops the link. As the commit
message says, pciehp then removes the modem:
device_shutdown()
mtk_pci_shutdown()
mtk_pci_remove()
mtk_pci_pldr() <- link drops
pciehp IRQ thread
pciehp_disable_slot()
pciehp_unconfigure_device()
pci_stop_and_remove_bus_device()
mtk_pci_remove() <- second time
On the second run, mtk_mhccif_exit()->mtk_pci_unregister_irq() finds the
MHCCIF callback already NULL and logs "irq_id=%d has not been
registered". The IRQ masks are written over MMIO again. MRST._RST is
evaluated again, or the doorbell is rung again with another 2 second
sleep. The readiness poll also runs again, and it can never succeed if
pciehp has marked the device disconnected.
Later in the series, mtk_pci_dev_exit() gets a comment saying "remove()
can follow a kexec shutdown that already ran this". That guard only
covers the FSM and transport teardown. It doesn't cover the IRQ and
MHCCIF teardown or the reset here.
Could mtk_pci_remove() record that its teardown has already run and
skip it the second time?
> +static pci_ers_result_t mtk_pci_error_detected(struct pci_dev *pdev,
> + pci_channel_state_t state)
> +{
> + struct mtk_md_dev *mdev = pci_get_drvdata(pdev);
> +
> + dev_err(mdev->dev, "AER detected: pci_channel_state_t=%u\n", state);
> +
> + /* AER recovery not supported, disconnect the device */
> + return PCI_ERS_RESULT_DISCONNECT;
> +}
[Severity: Low]
Does returning PCI_ERS_RESULT_DISCONNECT actually disconnect the device?
For frozen channels, pcie_do_recovery() resets the link whatever the
driver returns:
drivers/pci/pcie/err.c:pcie_do_recovery() {
...
if (status == PCI_ERS_RESULT_NEED_RESET ||
state == pci_channel_io_frozen) {
if (reset_subordinates(bridge) != PCI_ERS_RESULT_RECOVERED) {
...
}
When recovery fails, the core only calls report_perm_failure_detected(),
and the driver stays bound.
After the secondary bus reset or DPC, the ATR tables, IMASK and MHCCIF
EAP masks are back at their defaults. Nothing here quiesces the device
(masking IMASK, cancelling mhccif_work, pci_clear_master()), and nothing
reprograms those registers.
A later mtk_pci_remove() then rings the DEV_EVT_H2D_DEVICE_RESET
doorbell through an unprogrammed BAR2/3 window and still waits 2
seconds.
Should mtk_pci_error_detected() at least quiesce the device? The
"disconnect the device" comment could also be reworded, since the core
doesn't disconnect it.
> +static const struct pci_error_handlers mtk_pci_err_handler = {
> + .error_detected = mtk_pci_error_detected,
> +};
> +
> +static struct pci_driver mtk_pci_drv = {
> + .name = KBUILD_MODNAME,
> + .id_table = t9xx_pci_table,
> + .probe = mtk_pci_probe,
> + .remove = mtk_pci_remove,
> + .shutdown = mtk_pci_shutdown,
> + .err_handler = &mtk_pci_err_handler
> +};
[Severity: Medium]
There's no .driver.pm in mtk_pci_drv, so across system suspend the PCI
core only saves and restores config space. The commit message says
"system suspend is not supported". However, nothing refuses or detects a
suspend/resume cycle, and MODULE_DEVICE_TABLE autoloads the driver on
laptops that have this modem.
If the slot loses power in S3 or D3cold, the state programmed at probe
returns to reset defaults, and config space restore doesn't bring it
back. That state is:
- the ATR tables from mtk_pci_atr_init()
- the MAC IMASK state
- the MHCCIF EP2RC mask written through the BAR2/3 window
mtk_mhccif_isr_work() and the DEV_EVT_H2D_DEVICE_RESET doorbell in
mtk_pci_remove() would then go through an unprogrammed ATR window, and
the modem would fail silently after resume.
Could the driver either reprogram this state on resume, or fail the
suspend while the modem is bound?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-t9xx_driver_v1-v13-0-92d9be5fb51e%40compal.com
next prev parent reply other threads:[~2026-11-29 7:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:27 [PATCH net-next v13 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-25 6:27 ` [PATCH net-next v13 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-29 7:39 ` netdev-bot+sashiko [this message]
2026-11-25 6:27 ` [PATCH net-next v13 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-25 6:27 ` [PATCH net-next v13 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-29 7:39 ` netdev-bot+sashiko
2026-11-25 6:27 ` [PATCH net-next v13 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-29 7:39 ` netdev-bot+sashiko
2026-11-25 6:27 ` [PATCH net-next v13 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-29 7:39 ` netdev-bot+sashiko
2026-11-25 6:27 ` [PATCH net-next v13 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=179593796217.3146.12932735833019291995@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