From: "Wu. JackBB (GSM)" <JackBB_Wu@compal.com>
To: "netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>
Cc: "loic.poulain@oss.qualcomm.com" <loic.poulain@oss.qualcomm.com>,
"ryazanov.s.a@gmail.com" <ryazanov.s.a@gmail.com>,
"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"wen-zhi.huang@mediatek.com" <wen-zhi.huang@mediatek.com>,
"shi-wei.yeh@mediatek.com" <shi-wei.yeh@mediatek.com>,
"Minano.tseng@mediatek.com" <Minano.tseng@mediatek.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"horms@kernel.org" <horms@kernel.org>,
"corbet@lwn.net" <corbet@lwn.net>,
"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
"Yu. Robert (GSM)" <robert_yu@compal.com>,
"Chang. Jeff (GSM)" <Jeff_Chang@compal.com>,
"edumazet@kernel.org" <edumazet@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH net-next v13 1/6] net: wwan: t9xx: Add PCIe core
Date: Mon, 30 Nov 2026 07:58:33 +0000 [thread overview]
Message-ID: <99a52f16c10145a3b0c2863cd0fd9da7@compal.com> (raw)
In-Reply-To: <179593796217.3146.12932735833019291995@kernel.org>
Thanks for the review.
> 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?
Will fix in v14: the kernel-doc of mtk_pci_pldr() only says that -EIO
means MRST._RST failed and no longer states what the device looks like
afterwards.
The fallback on -EIO stays. Trying the next reset when one fails is
what __pci_reset_function_locked() does after a failed _RST, and a
doorbell written to a device that is part way through a reset is simply
lost. Skipping it would leave a platform whose method fails with no
reset at all.
> 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?
No change. In the case described the device reaches probe without a
reset, and then the driver cannot use the modem whatever the vector
mapping is: the boot notification is one-shot and has already been
consumed, which is what the commit message says about kdump. The 1:1
mapping is the reset default, this driver never changes it, and every
reset the driver performs returns to it.
> 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?
Will fix in v14 the wait: after the reset, mtk_pci_remove() returns at
once when the device is already disconnected, so there is no poll, no
warning and no restore in that case.
The reset itself stays. pciehp marks the device disconnected on any
link down, including a modem that has crashed and dropped off the bus,
and the platform reset is what brings that modem back so the port can
enumerate it again.
> 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.
No change in v14 yet. You are right that the Vendor ID read cannot tell
"not reset yet" from "reset and back". I will check with the hardware
team whether the device has a register that shows the reset has
completed and that can be read before the restore.
The device state register cannot be used for this as it is: it is MMIO
and the BARs are unprogrammed until the restore. Waiting for the link
to go down first would time out whenever MRST._RST returns after the
link is already back.
The sequence is the one t7xx_reset_device() uses: it restores right
after MRST._RST returns, and after a fixed 2 s for the reset doorbell.
The presence poll here is in addition to that.
> 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?
Will fix in v14: mtk_pci_remove() returns at once when it has already
run, so a hot-remove that follows the kexec shutdown no longer repeats
the IRQ and MHCCIF teardown or the reset. That makes the guard in
mtk_pci_dev_exit() unnecessary and it goes away.
> 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.
Will fix in v14 the comment: it only says that AER recovery is not
supported.
No quiesce in error_detected(): two of the three steps (masking IMASK,
clearing bus master) are device accesses, which pci-error-recovery.rst
rules out in this callback, and the interrupt handler and the MHCCIF
work already return early when the device reads all-ones. The modem
stays unusable until the driver is unbound, where the normal teardown
and the platform reset run.
> 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?
No code change in this series; v14 states in the commit message what
happens instead of "not supported": suspend is not refused, the PCI
core's default handling restores config space only, and where the
platform removes power from the slot, as it does for hibernation, the
modem restarts and is unusable until the driver is bound again.
Suspend and resume have to be negotiated with the modem over MHCCIF,
which comes with the power management patches after this series.
Reprogramming only the ATR windows and masks on resume would leave the
driver in its handshaked state against a modem that has restarted, and
refusing suspend would keep the whole machine from sleeping.
Thanks,
Jack
--
pw-bot: cr
next prev parent reply other threads:[~2026-11-30 7:59 UTC|newest]
Thread overview: 14+ 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
2026-11-30 7:58 ` Wu. JackBB (GSM) [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-30 8:02 ` Wu. JackBB (GSM)
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-30 8:04 ` Wu. JackBB (GSM)
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=99a52f16c10145a3b0c2863cd0fd9da7@compal.com \
--to=jackbb_wu@compal.com \
--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=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-bot+sashiko@kernel.org \
--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