Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 v14 1/6] net: wwan: t9xx: Add PCIe core
Date: Thu, 03 Dec 2026 09:46:36 +0000	[thread overview]
Message-ID: <179629119600.3146.12340573869676520153@kernel.org> (raw)
In-Reply-To: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 3

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] After MRST._RST succeeds, mtk_pci_remove()
  (drivers/net/wwan/t9xx/pcie/mtk_pci.c:1004-1029) polls PCI_COMMAND via…
- [Low] In mtk_pci_remove() (drivers/net/wwan/t9xx/pcie/mtk_pci.c), the
  branch `else if (!mtk_pci_link_check(mdev))` is the 'PLDR failed and…
- [Low] mtk_pci_hold_active()
  (drivers/net/wwan/t9xx/pcie/mtk_pci.c:645-660) sets FORCE_MAC_ACTIVE…
- [Low] mtk_pci_err_handler
  (drivers/net/wwan/t9xx/pcie/mtk_pci.c:1053-1055) provides only…

--

net: wwan: t9xx: Add PCIe core

This commit adds the PCIe core of the MediaTek T9xx 5G WWAN modem driver.
It covers probe and removal, MSI-X setup, the MHCCIF event channels and
reset doorbell, and the register and interrupt helpers. Probe holds the
device out of its low-power states. Removal and kexec shutdown reset the
modem through ACPI MRST._RST, or the MHCCIF doorbell if that fails, and
then restore config space.

> 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..12ad8ec202ea8
> --- /dev/null
> +++ b/drivers/net/wwan/t9xx/pcie/mtk_pci.c
> @@ -0,0 +1,1069 @@

[ ... ]

> +/* Keep the device out of its low-power states; only a failed probe or a
> + * reset of the device releases it.
> + */
> +static void mtk_pci_hold_active(struct mtk_md_dev *mdev)
> +{
> +	struct mtk_pci_priv *priv = mdev->hw_priv;
> +	u32 val;
> +
> +	val = mtk_pci_mac_read32(priv, REG_PCIE_MISC_CTRL);
> +	mtk_pci_mac_write32(priv, REG_PCIE_MISC_CTRL, val | MTK_FORCE_MAC_ACTIVE);
> +	mtk_pci_mac_write32(priv, REG_DIS_ASPM_LOWPWR_SET_0, MTK_DIS_LOWPWR_L1);
> +
> +	if (read_poll_timeout(mtk_pci_mac_read32, val,
> +			      val == U32_MAX ||
> +			      (val & MTK_RESOURCE_ACTIVE_MASK) == MTK_RESOURCE_ACTIVE_MASK,
> +			      MTK_RESOURCE_POLL_US, MTK_RESOURCE_TIMEOUT_US, false,
> +			      priv, REG_PCIE_RESOURCE_STATUS) || val == U32_MAX)
> +		dev_warn(mdev->dev, "device not active, resource status %#x\n", val);
> +}

[Severity: Low]
If this poll times out before all the resource bits are set, should probe
still continue?

The commit message says "a device in low power loses MMIO writes".
However, mtk_pci_hold_active() returns void, and mtk_pci_probe() carries
on regardless:

    mtk_pci_hold_active(mdev);

    ret = mtk_pci_atr_init(mdev);

The ATR table writes come next. After them come the MHCCIF EP2RC mask
write through the BAR2/3 window, the IMASK writes and the MHCCIF unmask.
Nothing checks that any of these writes landed. The read-back in
mtk_pci_setup_atr() discards its value:

    /* Ensure ATR is set */
    mtk_pci_mac_read32(priv, addr);

The all-ones case is caught later, when mtk_pci_link_check() makes probe
return -ENOLINK. A plain timeout is not caught.

Can probe then report success with the ATR window and the MHCCIF masks
never programmed? Would it be better for mtk_pci_hold_active() to return
an error on timeout and fail the probe?

[ ... ]

> +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) {
> +		/* Already hot-removed: its config space is out of reach, so
> +		 * there is nothing to wait for and nothing to restore.
> +		 */
> +		if (pci_dev_is_disconnected(pdev))
> +			return;
> +		polls = MTK_PLDR_READY_POLLS;
> +	} else if (!mtk_pci_link_check(mdev)) {
> +		dev_warn(dev, "PLDR failed (%d) and link is down, modem not reset\n", ret);

[Severity: Low]
This branch issues no reset and leaves polls at 0. It has no early return,
so mtk_pci_remove() still reaches the pci_restore_state() at its end. The
comment there says "The reset returned the endpoint to its power-on
defaults", which is not true on this path.

The PLDR success branch returns early for a disconnected device, but this
branch has no such guard.

pci_restore_state() does not check state_saved. If the earlier link check
in front of pci_save_state() also failed, the snapshot written back is
the pre-bind one taken in pci_bus_add_device().

The link check might also fail only briefly. One example is a device that
answers with RRS after a partly executed MRST._RST returned -EIO. In that
case the restore reaches the device with no readiness wait, and the
config writes can be lost.

If the device really is disconnected, the config accessors return at once
and the restore does nothing.

Should the restore be skipped when no reset was issued?

> +	} 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);
> +		mtk_pci_send_ext_evt(mdev, DEV_EVT_H2D_DEVICE_RESET);
> +		polls = MTK_MHCCIF_RESET_POLLS;
> +	}
> +
> +	/* Wait for the reset to show before the restore below: a config
> +	 * write the device does not take is simply lost, and one it takes
> +	 * before the reset is wiped by it.
> +	 */
> +	for (i = 0; i < polls && !mtk_pci_reset_seen(pdev); i++)
> +		msleep(MTK_PLDR_READY_POLL_MS);
> +	if (polls && !mtk_pci_reset_seen(pdev))
> +		dev_warn(dev, "device not back %d ms after reset, its config space may not be restored\n",
> +			 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]
Is 1 s enough after a successful MRST._RST? In that case polls is
MTK_PLDR_READY_POLLS, which gives 50 x 20 ms. On timeout the code only
warns and still calls pci_restore_state().

drivers/pci/pci.c notes that devices may extend the post-reset period:

    /*
     * Devices may extend the 1 sec period through Request Retry Status
     * completions (PCIe r6.0 sec 2.3.1).  The spec does not provide an upper
     * limit, but 60 sec ought to be enough for any device to become
     * responsive.
     */
    #define PCIE_RESET_READY_POLL_MS 60000 /* msec */

The polling also starts as soon as the ACPI method returns. The core waits
100 ms after a reset before it accesses the device; this code does not.

The comment above the loop says a config write the device does not take
is lost. So if the modem holds off readiness past 1 s with RRS, the
restore writes are lost. The BARs and the Command register then stay at
their reset values, while the PCI core believes they were restored. A
later bind on the same pci_dev cannot reach the device's MMIO.

Could the wait follow the core's timing? Alternatively, could the restore
be skipped when the device never became ready?

[ ... ]

> +static const struct pci_error_handlers mtk_pci_err_handler = {
> +	.error_detected = mtk_pci_error_detected,
> +};

[Severity: Low]
What happens if the PCI core resets the function while the driver is
bound? There are no .reset_prepare or .reset_done callbacks. A root write
to the sysfs reset attribute, for example, goes through:

pci_reset_function()
  pci_dev_save_and_disable()   /* no reset_prepare, only pci_warn */
  FLR, PM or bus reset
  pci_dev_restore()            /* no reset_done */

pci_dev_restore() puts back config space and MSI-X state. It does not put
back the BAR0 MAC state that probe set up:

  - the ATR tables: the BAR2/3 window to 0x10000000 and the transparent
    AXIS DMA tables
  - FORCE_MAC_ACTIVE in REG_PCIE_MISC_CTRL
  - DIS_ASPM_LOWPWR
  - IMASK
  - the MHCCIF EP2RC mask

After the reset, mtk_mhccif_isr_work(), mtk_pci_mask_ext_evt(),
mtk_pci_unmask_ext_evt() and the reset doorbell in mtk_pci_remove() all
access a BAR2/3 window that is no longer translated. The device can also
drop back into low power, where writes are lost. The modem stays unusable
until the driver is bound again.

The commit message covers AER recovery and system PM, but not resets
started by the PCI core.

Should reset_prepare and reset_done be implemented, or should the commit
message document this limitation?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-t9xx_driver_v1-v14-0-08ebc870ea94%40compal.com


  reply	other threads:[~2026-12-03  9:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:58 [PATCH net-next v14 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-12-02  8:59 ` [PATCH net-next v14 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko [this message]
2026-12-02  8:59 ` [PATCH net-next v14 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-12-02  8:59 ` [PATCH net-next v14 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-02  8:59 ` [PATCH net-next v14 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-02  8:59 ` [PATCH net-next v14 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko
2026-12-02  8:59 ` [PATCH net-next v14 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay
2026-12-03  9:46   ` netdev-bot+sashiko

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=179629119600.3146.12340573869676520153@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