Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 v12 1/6] net: wwan: t9xx: Add PCIe core
Date: Mon, 23 Nov 2026 03:05:20 +0000	[thread overview]
Message-ID: <e0c8e3ba67c44497929214dc4af457d9@compal.com> (raw)
In-Reply-To: <179526494505.3135.4658538684680862441@kernel.org>

Thanks for the review.

> 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.

No change.  The vectors have to be freed after mtk_mhccif_exit() and
before the reset, and devres only runs once remove() has returned, that
is after the reset and after pci_restore_state(); on the kexec shutdown
path it does not run at all.  The later pcim_msi_release() finds
msix_enabled clear and returns, and if the implicit managed behaviour is
removed, as the TODO says, the explicit call is what remains, so nothing
here depends on it.  t7xx enables with pcim_enable_device() and frees
its vectors the same way.

> 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.

No change for the bracket in this series: pci_hp_ignore_link_change()
and pci_hp_unignore_link_change() are not exported to modules, and this
driver can be built as one.  Their only caller is pciehp_reset_slot();
pci_dev_acpi_reset() and the MRST._RST reset in t7xx are not bracketed
either.  On a hotplug-capable port the result is what you describe: the
poll runs out, the warning is printed, and pciehp removes and
re-enumerates the modem, which leaves it with valid config space.  I
will state this in the commit message, and add the bracket once the
helpers can be called from a module.

Will fix in v13 the kexec case that follows from it: there pciehp can
unbind the device after .shutdown has already run the teardown, so
mtk_pci_dev_exit() will return early when it has already run.

Thanks,
Jack

pw-bot: cr

  reply	other threads:[~2026-11-23  3:06 UTC|newest]

Thread overview: 19+ 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
2026-11-23  3:05     ` Wu. JackBB (GSM) [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-23  3:06     ` Wu. JackBB (GSM)
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-23  3:07     ` Wu. JackBB (GSM)
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-23  3:08     ` Wu. JackBB (GSM)
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=e0c8e3ba67c44497929214dc4af457d9@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