🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26249

Re: [PATCH net-next v14 1/6] net: wwan: t9xx: Add PCIe core

#26249
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 09:46
224 lines
16883 bytes
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
Technical Details
Message-ID: <179629119600.3146.12340573869676520153@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376450-linux-kernel-netdev=dewy.ru
References: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376450-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v14 1/6] net: wwan: t9xx: Add PCIe core
Date: Thu, 03 Dec 2026 09:46:36 +0000
Organization: Usenet Network
Message-ID: <179629119600.3146.12340573869676520153@kernel.org>
References: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2451448"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CFp+lTaELxkRc7T0/rfSiIxC8XA= sha256:wnCgU8xl2maInDokhSFbakdPwEX2vBOlLlfY/c1k4VU=
	sha1:bM80mHoUt9D/yBhZdQJH/Roo+Sk= sha256:MXcohUu2V836t7WqrooFEaRwh3jp9nMF5KNderIn9XA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6CCFE1178AF; Thu,  3 Dec 2026 12:46:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id jpl7Fs3stWaD;
	Thu,  3 Dec 2026 12:46:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376450-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 166D41178A7; Thu,  3 Dec 2026 12:46:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 5D3F32FE66; Thu,  3 Dec 2026 09:46:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796291199;
	b=c5MpY4mE1UytQpVmGIFD0IQdqSm2E5ZZYJPGsdLNODQyzgIKGamAslRjA+A8YOQ/u/Zv
	 UVE7iW4ARjX28lZ9zPpyt3j4v8Zqwyd2t4eiZdUSOOIJSDB/tMeTa7KLh0vBoe4lwEPMi
	 /6nGDI2Awrl2S3eWQ0Ze5Ey6H6aB3iv7Fy67LQ3M6j3N2p1j1tWyvRaokbxO1vhwTHqo8
	 S2paLta7NbAXGQvk5dsNM7mUOJuALr9GmnC7k4IDwyIZFS35kS+1iuXltO5rdOlEagVgq
	 RrkaT8uBsQ26BurCWzxg0e7A/z+Mo5cHbZ6n2NUxTZFTtcsrcMhj62l/3S5bBHu1Whw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796291199;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=iRg3d73rYHgiEb9FJsBgCzwSn03XnR5O/spiSxvjHug=;
	b=uptJt7k4B/gVjNaW1Z2CmvbkXnkErjOwfF72oS6R9lAIQ2Nj5739CmpBPGJU7kKiIDjj
	 DrcZM8ivXwFpQTPRS9dhF83mfKXeSOSujOW4AzYk7LaGbSVwnZH/GsyTSDbxtHBLJTZiT
	 mzG3kn231bsdg1+rD2gmzAVOroFQ5T1uDtR+HMT7J/OdseZwN1DnsoFatrYtyQXag8dmb
	 zHXlFsJretNT44vUZ8F8pUS36oMcHq4+0YEHMJHxBNX9JAmJ1N9KEUOOyC3W7gUSuI7Gw
	 FMofkGN0On0aBabMCBnbfAJXJZmSaednAEDlVDs7v3lDkacjsk8RF0b0HkQL4C2cATA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YA07uFfE;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 35B4D606A33B;
	Thu,  3 Dec 2026 09:46:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YA07uFfE
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796291198;
	b=GK6JtF0NPOaSgHAeZICoHKboTRBIIwfr3cVIsfFnHRiehIM5JrPqsIQAvoYI7h7k/nc6
	 lSW9HzAel7pD3iAv0fYPXchxxP9vPfxIknuzc6nuMoqx/jY45XoHoqnxvWoft8kH8l5Xk
	 jFoqNk4a2eUVRTNdBdLx3H6pvuHvpwX46vrJR2Kq1lM1njdSgKljBcpkdBkvEbQWj8tXt
	 wiUg9qBv1mSKbXuPcs0laK+SPERIz6BKwH6Q5WJpaA2rnru/Ff11tIRFu5RTOh5YaaMaS
	 PHMNAe27+nhjSkvF1lQP/ty6PA0RKPThUiFLLicIcLGiW9zxIJM7hNFjG1jPDubMAfA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796291198;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=iRg3d73rYHgiEb9FJsBgCzwSn03XnR5O/spiSxvjHug=;
	b=T4chdFBF7XFIHeGdOLjM0DY6bXHf39DJTSHUES4i2jc7Z+eRe31e8cE7t9e+CBm+1Hha
	 ZK2TZ7sp+ZPV9XlcO5MBOpuLWN8IQCOJJQUbnalqhb8Nm1dZNPAJT7NHvOhE2gfPWkT7N
	 wDEWD21bunmdTxXxSsBekOTC5TwSx5r87Ermp8h6zWqkhDJugpsoCSPIpXw9Cl3QM3Eh2
	 pq0LO3oAXscgobKtUbvSA+GoTEO7PtmqYJoS1X6nJF7p9R7ZZTZaMzLMj06cKqNFwgCJ5
	 OL+vco74RqbQh7amRMgJO8gpb3NVeezE/B5Vdrm/kHqiLMU8m89qYgZBDK1KE4X+PuQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YA07uFfE;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30AC5606A322;
	Thu,  3 Dec 2026 09:46:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77DB91F0089B;
	Thu,  3 Dec 2026 09:46:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796291197;
	bh=iRg3d73rYHgiEb9FJsBgCzwSn03XnR5O/spiSxvjHug=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YA07uFfEmESzuUB7Fle9klWbJ5Qw4Z+XDBaE8X/HiOWLBhcxubc5Bhh8onwP3IelX
	 RzdtkRnulUna1aknSdPhCyJ9nOOMgSGdeeOd4T780UfzhdUJq2WjVSL1DWGmhIsdN2
	 a2M3kS3SY+tnYAdvo3E2FfOcM3TnZpVNyXGO00YsFDvkrLPiVKriHHu0iKb7PsBMiy
	 qFfTM0qTWLf72MM25k4/gFc9kNmV4gbw6m+JdG4rZ8YBs45Ajl/757eRSpAE6Zm2rw
	 4oyKMq3Z7VNxdNf7NNf/h5GcYbV4QFFxNVkE+exeP4OnwWlvv0Q11gGI7R1GhVIBuE
	 RpubcE8QUCHQg==
X-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
X-In-Reply-To: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list