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=1796409976; b=17gLZ2KE+y5tKJSnYEoN2raQ6qFWyUic8vYH3do4ztiGXaR5GU9QSpL51FQ+vTZs3/JH PTOZ/mOwLnLbQZpzTh95/RuREOKvajwBQFIwfiKy6ULLURFFd43dRcZhzDL1VY4TPoJp8 1davUucvXG0xFhRkl7XkBqi0kmNNb8b2bcSxfn+95FsZSQcvxcF38sr3AzhTGdtJW7yol 24FFeO08VQJeThkFOaCAzHwJ2Dk2WkEELPYVq6csL3mwbvyCUAp+ga/XOIHEqGI0JTvuc 6YEeDOAACI8uuHByqh+n4K5lUXrnq80kfAV00Y/bM8Ho/4yMnhlN9gfCZnFkjuylQaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409976; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=r7Gwj3gHa4aJ43lspcGg0kUAyVk105uHRXjPoaWMW/8=; b=gFTx4PLM2Ohicn9ezh99MAIoTdqNz6bshj0sySEPdsE1YLesPQsRK/03VXMYg91MMPUG QAWjhaV7nAcUDr4HmUPZGT1PXsOp86sIso1zL9wjt4Fd7EdMeQC1WdtFZXrOIaZe3aSc8 oXSW6HT/qsHQtrLeo2bjqCgPAFCEOuat44wVi/FdogCGjsW/ngxSymKSNU9A3wiDyct5P EBxLw0GkS7q6xEjwwZMEVw4zTDkPHAUkldPAdAPHkT5p20GQz7D2pq9nyNgt/RZVtvN7G 82vQsch87Ou686Ms2n6DLZJ4GQ6adTfVe/RagRcTaOVXFFnFeJ6b23zLlqAHakCKePQ== 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=FN4cfXCh; 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69911606A32C for ; Fri, 4 Dec 2026 18:46:16 +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=FN4cfXCh Received: by smtp.kernel.org (Postfix) with ESMTPSA id E32251F0093B; Fri, 4 Dec 2026 18:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409976; bh=r7Gwj3gHa4aJ43lspcGg0kUAyVk105uHRXjPoaWMW/8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=FN4cfXChRG7gqqDp6lsAh78xPQwDVFwgsJR8HMqix3JJpt/ifKEnnlRRqR9GxeJ5A Z1/C3ZGzNA5Kg/AUE6TcMkyEU9icEAkLrmd7qSBc+HVVGghZgbU6E0NErRS/sAPFZd g7fJlQFl7lt4ZeWyUifjv+/7ZYZJugPk2Pbbh9zLXXXjMRyrfH3lp18BJgtV2nbsy4 AI4QJ4rpZP51U0Uf/u9tSh5PAP+5bXFigLAiyKlfwbE5gSi81kXNow4/eL8ENgssBE o7C7JFPnkbWTO0OHfYnGKQQrSmxLfJsw9hZOb09YjaEjfj4s41Nf7DedJ6kiKIKgdQ nfij1s1FFowIA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 5/6] PCI/FLIT: Signal Flit Error Counter events with ERR_COR Reply-To: sashiko-reviews@lists.linux.dev To: "Yazen Ghannam" , linux-pci@vger.kernel.org In-Reply-To: <20261204181556.1418843-6-yazen.ghannam@amd.com> References: <20261204181556.1418843-1-yazen.ghannam@amd.com> <20261204181556.1418843-6-yazen.ghannam@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:46:15 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 10 potential issues to consider: - [Medium] PCI/AER: aer_root_reset() clears root status without re-arming Flit counters - [Medium] PCI/AER: find_device_iter() overflow permanently silences Flit counters - [Medium] PCI/FLIT: pci_flit_init() enables ERR_COR before device is on bus->devices - [Medium] PCI/FLIT: flit_err_cor_usable() ignores pcie_ports_disabled on non-ACPI - [Medium] PCI/FLIT: pci_flit_rearm() accesses D3cold devices and resets idle counters - [Medium] PCI/FLIT: Root Port runtime resume discards Flit ERR_COR without re-arming - [Medium] PCI/AER: aer_enable_rootport() rearms Flit counters before aer_enable_irq() - [Medium] PCI/FLIT: pci_restore_flit_state() races with flit_service() counter pause - [Medium] PCI/FLIT: flit_cntr_enable() leaves ERR_COR_EN set in IRQ fallback mode - [Low] PCI/AER: is_error_source() gates Flit ERR_COR check on PCI_EXP_AER_FLAGS -- commit 9ac7a72e2e543419624dd388eb814ff690ac98e9 Author: Yazen Ghannam PCI/FLIT: Signal Flit Error Counter events with ERR_COR This commit uses ERR_COR signaling instead of the PCIe Capability interrupt for Flit Error Counter events when Capability Version 2h supports it. It hooks into AER to identify and service those events and re-arms ERR_COR counters when AER enables a Root Port or RCEC. > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index 1973b6eba6b38..376ee74981087 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -1210,6 +1210,11 @@ static bool is_error_source(struct pci_dev *dev, s= truct aer_err_info *e_info) > if (!(reg16 & PCI_EXP_AER_FLAGS)) > return false; > =20 > + /* A Flit Error Counter event sets no AER status bit */ > + if (e_info->severity =3D=3D AER_CORRECTABLE && > + pci_flit_err_cor_pending(dev)) > + return true; > + [Severity: Low] Should the pci_flit_err_cor_pending() check come before the PCI_EXP_AER_FLAGS check? Flit Error Counter ERR_COR generation is gated by PCI_FLIT_ERR_CNTR_CTRL_ERR_COR_EN rather than PCI_EXP_DEVCTL, and flit_err_cor_usable() only checks the Root Port's aer_cap. If PCI_EXP_AER_FLAGS is clear on the device -- for example after an OOM in pci_aer_init() skips pci_enable_pcie_error_reporting() -- a multi-error search skips the device and leaves its Flit Error Counter permanently silent. [ ... ] > @@ -1594,6 +1599,8 @@ static inline void aer_process_err_devices(struct a= er_err_info *e_info) > =20 > /* Report all before handling them, to not lose records by reset etc. */ > for (i =3D 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { > + if (e_info->severity =3D=3D AER_CORRECTABLE) > + pci_flit_handle_err_cor(e_info->dev[i]); > if (aer_get_device_error_info(e_info, i)) > aer_print_error(e_info, i); > } [Severity: Medium] Can an AER multi-error overflow permanently silence Flit Error Counters on devices beyond the fifth match? find_device_iter() stops walking the bus once add_error_device() hits AER_MAX_MULTI_ERR_DEVICES (5), so aer_process_err_devices() never calls pci_flit_handle_err_cor() for any remaining device with a pending Flit ERR_COR. Because a Flit counter stays silent until its err_cor_gen bit is cleared, an overflowed device stops reporting Flit errors until another multi-error burst visits it first or the Root Port re-arms it. [ ... ] > @@ -1805,6 +1818,15 @@ static void aer_enable_rootport(struct aer_rpc *rp= c) > pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, ®32); > pci_write_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, reg32); > =20 > + /* Re-arm Flit Error Counters whose ERR_COR was never serviced */ > + if (IS_ENABLED(CONFIG_PCIE_FLIT)) { > + pci_flit_rearm(pdev); > + if (pci_pcie_type(pdev) =3D=3D PCI_EXP_TYPE_RC_EC) > + pcie_walk_rcec(pdev, flit_rearm_iter, NULL); > + else if (pdev->subordinate) > + pci_walk_bus(pdev->subordinate, flit_rearm_iter, NULL); > + } > + > aer_enable_irq(pdev); > } [Severity: Medium] Can re-arming Flit Error Counters before aer_enable_irq() drop a new ERR_COR? While the walk drains logs on downstream devices, an earlier re-armed device can reach its trigger and emit an ERR_COR while PCI_ERR_ROOT_CMD_COR_EN is still clear. On Root Ports or RCECs that do not retroactively fire an MSI/MSI-X when PCI_ERR_ROOT_CMD_COR_EN is set with PCI_ERR_ROOT_COR_RCV already latched, that event is never serviced and the counter stays silent. Moving the re-arm walk after aer_enable_irq() avoids this window since flit_service() already serializes with aer_isr() via service_lock. [Severity: Medium] Does aer_root_reset() also need to re-arm Flit Error Counters when it clears PCI_ERR_ROOT_STATUS? aer_root_reset() masks AER interrupts on root, runs FLR or a secondary bus reset, clears PCI_ERR_ROOT_STATUS, and re-enables interrupts: drivers/pci/pcie/aer.c:aer_root_reset() { ... if (host->native_aer && aer) { /* Clear Root Error Status */ pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, ®32); pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32); aer_enable_irq(root); } ... } Any Flit ERR_COR sent by root or an un-reset sibling port during that reset window is discarded when PCI_ERR_ROOT_STATUS is cleared, leaving that counter permanently silent. > diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c > index 97395b6942389..83a6b50221ef1 100644 > --- a/drivers/pci/pcie/flit.c > +++ b/drivers/pci/pcie/flit.c [ ... ] > @@ -143,6 +151,48 @@ static void flit_select_cntr(struct pci_dev *pdev) > info->cntr =3D &flit_ext_cntr; > } > =20 > +/* > + * The Root Port or RCEC needs AER to log the ERR_COR, and system firmwa= re must > + * not claim it through SIG_SFW Enable or RC ECS Handling. The device it= self > + * needs no AER Capability. > + */ > +static bool flit_err_cor_usable(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + struct pci_dev *root; > + u32 root_cmd, sfw; > + u16 ctrl; > + > + if (!(info->cntr_cap & PCI_FLIT_ERR_CNTR_CAP_ERR_COR)) > + return false; > + > + if (!pci_aer_available()) > + return false; [Severity: Medium] Should flit_err_cor_usable() also check pcie_ports_disabled? On non-ACPI platforms booted with pcie_ports=3Dcompat (or PowerNV, which sets pcie_ports_disabled unconditionally), pci_init_host_bridge() leaves native_flit set while pcie_portdrv_init() skips registering aerdriver. Because pci_aer_available() does not check pcie_ports_disabled, pci_flit_init() enables ERR_COR signaling with no AER driver bound to service the messages. [ ... ] > @@ -210,6 +271,12 @@ void pci_flit_init(struct pci_dev *pdev) > pci_dbg(pdev, "Flit Logging Extended Capability present, using the %s\n= ", > flit_ext(info) ? "Extended Flit Error Counter" : > "Flit Error Counter"); > + > + /* ERR_COR needs no port service, so start here, after pci_aer_init() */ > + if (info->err_cor) { > + pci_dbg(pdev, "Flit Error Counter events signaled with ERR_COR\n"); > + flit_cntr_enable(pdev); > + } > } [Severity: Medium] Can enabling the ERR_COR counter here lose the first event on hotplug or rescan? pci_device_add() calls pci_init_capabilities() (and then several other initializers, including DOE mailbox exchanges and platform_pci_configure_wake()) before adding dev to bus->devices. If the counter fires an ERR_COR beneath an already-probed Root Port before dev is on bus->devices, aer_irq() clears Root Error Status, find_source_device() cannot locate dev, and the counter stays permanently silent. [ ... ] > @@ -344,6 +424,10 @@ static void flit_cntr_enable(struct pci_dev *pdev) > =20 > /* A 0->1 transition of Counter Enable clears stale event status */ > __flit_cntr_ctrl_update(pdev, cntr->en, 0); > + > + if (info->err_cor) > + __flit_err_cor_enable(pdev); > + > __flit_cntr_ctrl_update(pdev, cntr->trigger | ctrl, > field_prep(cntr->trigger, info->trigger) | > info->enable); [Severity: Medium] When falling back to IRQ mode on a Capability Version 2h port, does flit_cntr_enable() leave PCI_FLIT_ERR_CNTR_CTRL_ERR_COR_EN set? If ERR_COR_EN was already set in hardware (for example across kexec into a kernel booted with pci=3Dnoaer), neither flit_select_cntr() nor flit_cntr_enable() clears it or its saved copy in FLIT_SAVE_CNTR_CTRL. Each trigger then emits both a PCIe interrupt and an unhandled ERR_COR message. [ ... ] > @@ -448,9 +532,71 @@ static irqreturn_t flit_isr(int irq, void *context) > return IRQ_WAKE_THREAD; > } > =20 > +/* > + * flit_isr() and flit_ist() in one, for ERR_COR. The AER thread and the > + * rearm walk can both get here, and must not drain one log at once. > + */ > +static void flit_service(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + > + mutex_lock(&info->service_lock); > + flit_cntr_pause(pdev); > + flit_cntr_write(pdev, info->cntr->sta, info->event); > + flit_drain_log(pdev); > + flit_cntr_resume(pdev); > + mutex_unlock(&info->service_lock); > +} [Severity: Medium] Can pci_restore_flit_state() race with flit_service() and re-enable the counter while it is paused? flit_service() runs without device_lock() and drops info->lock right after flit_cntr_pause(). A concurrent pci_restore_flit_state() (from pci_reset_function(), DPC slot reset, or runtime resume) takes only info->lock and writes the saved control register with cntr->en set: CPU0 CPU1 flit_service() flit_cntr_pause() /* cntr->en: 1 -> 0 */ pci_restore_flit_state() /* writes saved cntr->en =3D 1 */ /* new event latches sta */ flit_cntr_write(sta, event) <-- clears new event before AER runs flit_drain_log() flit_cntr_resume() <-- no 0 -> 1 transition to re-arm If errors reach the trigger before flit_cntr_write(), the RW1C write clears the new event status and flit_cntr_resume() misses the 0->1 transition needed to re-arm the counter. Tracking the paused state under info->lock and masking cntr->en in pci_restore_flit_state() while paused would prevent this. > + > bool pci_flit_uses_irq(struct pci_dev *pdev) > { > - return !!pdev->flit_info; > + return pdev->flit_info && !pdev->flit_info->err_cor; > +} [Severity: Medium] Does Root Port runtime resume discard latched Flit ERR_COR events without re-arming the counters? Returning false here keeps flitdriver (and its runtime_resume callback) from binding in ERR_COR mode, while aerdriver has no runtime_resume callback. When a Root Port runtime-resumes from D3hot, pci_restore_state() calls pci_aer_clear_status() to clear PCI_ERR_ROOT_STATUS, and pci_restore_flit_state() writes Counter Enable with no 0->1 transition, leaving any counter whose ERR_COR was latched during D3hot permanently silent. [ ... ] > +/** > + * pci_flit_rearm - service a counter whose ERR_COR may have been discar= ded > + * @pdev: PCI device reporting to a Root Port or RCEC AER is enabling > + * > + * An ERR_COR that AER cleared while enabling the Root Port or RCEC would > + * leave the counter silent for good. > + */ > +void pci_flit_rearm(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + > + if (info && info->err_cor) > + flit_service(pdev); > } [Severity: Medium] Can pci_flit_rearm() access D3cold subordinate devices during system resume? Because pcie_portdrv_probe() sets DPM_FLAG_SMART_SUSPEND, runtime- suspended subordinate ports can stay in D3cold when the parent Root Port runs aer_resume() -> aer_enable_rootport(). Calling flit_service() without checking runtime PM or PCI_D3cold state issues config read-modify-writes to D3cold devices right before aer_enable_irq(), causing spurious Unsupported Request errors and risking corrupting the control register if racing with runtime resume. Also, because pci_flit_rearm() does not check pci_flit_err_cor_pending(), it pauses and resumes healthy idle D0 counters (dropping accumulated counts) and drains logs under pci_bus_sem on every Root Port probe and resume. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204181556.1418= 843-1-yazen.ghannam@amd.com?part=3D5