From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77DB91F0089B; Thu, 3 Dec 2026 09:46:36 +0000 (UTC) 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== Subject: Re: [PATCH net-next v14 1/6] net: wwan: t9xx: Add PCIe core 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 Date: Thu, 03 Dec 2026 09:46:36 +0000 Message-ID: <179629119600.3146.12340573869676520153@kernel.org> In-Reply-To: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com> References: <20261202-t9xx_driver_v1-v14-1-08ebc870ea94@compal.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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