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=1796409727; b=oJACLTtZOaqOlq70/2aKn7QDd7UefVWPGG5EgJXX3Q2U9XuLaTQzLdciSNe0ul6b2uKL kPIzeGecwD/mq9Mujd0RjgOaNdz3dahZOYeB/6HluzXxGKpi1I4SJ8CD3vIVkmk6nwOWV q79aXuNWoJqV6enddmiSUsoZ2CtQUnq3/CDcgJTN7FhlMEFnj5fUpG6RkNfKGdwstLKEY 149B5Owc2z8+TW8F0vNbsc3O1ATn0U6feMMjTaIZ4Yjy6x7tGcxQ4luWi3VYunfd3IM8h 8euG/FynW7xQXzZO70+0FLGrUPdbDue6bpDwdIv10el4vKyKjSvkBFAxzpGGFAUU/Rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409727; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=SsoQFmAdZHfjvQ1UsOkpOC6c/dSI6B5qw/9LQI0mc8c=; b=Jo/cyFUg7isWfeCLqvdKt8/A4OslrbbBncssr4v+7A+jmoCp6oYElmAX2jDwQO4o4x3h SqzQoLuJf8/QwVqHruVR4Y1ocQy9xvwE1jBA722+8jGM13VrSgCZrrYzhQ6pH7He7RNxp 4Znu/8HdpGIMyab+h580sesITz2l2F8RoZnHxzZaAO/FIMQKHvcYZ9yyYMLngccEzO9KM Id6EtolAOcUmUpvE/U0uuW0DOLATZMnwm4Y4KU1B2sxpnrcUWslnP1/lcb/rcz9iozWQg iJp+GA+yS1Wuj4wCA+UN9I5+qWTp07KqztKBIcK1SRlZchFqUUWbs+DYrxhAk/J3oRQ== 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=dS5mTtbX; 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 5ABD1606A32C for ; Fri, 4 Dec 2026 18:42:07 +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=dS5mTtbX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D57C1F0093B; Fri, 4 Dec 2026 18:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409726; bh=SsoQFmAdZHfjvQ1UsOkpOC6c/dSI6B5qw/9LQI0mc8c=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=dS5mTtbXy6l+U6HAWJ6md7nUOcY2eH5SrE2xjFfRUw4vn/1AyZgOlnGiKWeo+B9tN yq/+OLk1/IiEcX+YsVVaXU7PzQ6ehnV9uG2iXegXkLlLVk2U+X3bpRWX6aGhhiSpd4 /QMxJilO5DkE7uolBJW5M1Dr/M5xzh4HwpJ642uzfs0vmjtSoVHP/KLyq9AYzhe82H gNHXUAbZcNDM1OzGcRLur7q2PVBi/ysfq9I75U/ISH2F+qfDOYOtzHdkx2H2oIPS4f GoByX5+r3pzUpJpaNk+j7k/Ef6B31KOhfBq7NGIQn386e96piegOzk0Z6gftsBFw05 IOmVkLltwRwRQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 3/6] PCI/FLIT: Add support for Flit Logging Extended Capability Reply-To: sashiko-reviews@lists.linux.dev To: "Yazen Ghannam" , linux-pci@vger.kernel.org In-Reply-To: <20261204181556.1418843-4-yazen.ghannam@amd.com> References: <20261204181556.1418843-1-yazen.ghannam@amd.com> <20261204181556.1418843-4-yazen.ghannam@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:42:06 +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 5 potential issues to consider: - [Medium] PCI/FLIT: flitdriver omits suspend and runtime_suspend callbacks - [Medium] PCI/FLIT: flit_cntr_enable() omits trigger update in saved state buffer - [Medium] PCI/FLIT: unratelimited pci_warn() in flit_report() can flood logs - [Medium] PCI/FLIT: restore and enable paths overwrite flit_cntr_pause() mid-drain - [Low] PCI/FLIT: pci_flit_init() ignores PCI_POSSIBLE_ERROR() from flit_cntr_read() -- commit 9ae9be8138a1e81dfc7aa4e70ca57f2664899c69 Author: Yazen Ghannam PCI/FLIT: Add support for Flit Logging Extended Capability This commit adds a PCIe port service driver for the Flit Logging Extended Capability, along with ACPI _OSC control negotiation and config state save/restore support. Link: https://pcisig.com/specification/extend-osc-negotiate-control-pcie-fl= it-logging-extended-capability > diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c > new file mode 100644 > index 0000000000000..00409dd7bb956 > --- /dev/null > +++ b/drivers/pci/pcie/flit.c [ ... ] > + ctrl =3D flit_cntr_read(pdev, info->cntr->ctrl); > + trigger =3D field_get(info->cntr->trigger, ctrl); > + info->trigger =3D trigger ? trigger : FLIT_DEFAULT_TRIGGER; [Severity: Low] Should pci_flit_init() check PCI_POSSIBLE_ERROR(ctrl) before extracting trigger? flit_cntr_read() translates a 0xffff config read error to ~0U for PCI_POSSIBLE_ERROR(), so a failed read leaves trigger as 0xff instead of falling back to FLIT_DEFAULT_TRIGGER (0xfe). Because an event requires the count to exceed the trigger, 0xff prevents Flit events from ever firing on that port. [ ... ] > +static void flit_cntr_enable(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + const struct flit_cntr *cntr =3D info->cntr; > + u32 ctrl =3D cntr->en | cntr->intr_en; > + unsigned long flags; > + > + spin_lock_irqsave(&info->lock, flags); > + info->cntr_enabled =3D true; > + > + /* A 0->1 transition of Counter Enable clears stale event status */ > + __flit_cntr_ctrl_update(pdev, cntr->en, 0); > + __flit_cntr_ctrl_update(pdev, cntr->trigger | ctrl, > + field_prep(cntr->trigger, info->trigger) | > + info->enable); > + __flit_save_state_update(pdev, cntr->slot, ctrl, info->enable); > + spin_unlock_irqrestore(&info->lock, flags); > +} [Severity: Medium] Should __flit_save_state_update() also update cntr->trigger with field_prep(cntr->trigger, info->trigger)? If flit_probe() runs after pci_save_state() captured the hardware reset default trigger of 0 (for instance under driver_async_probe=3Dflit or a man= ual sysfs bind), slots[FLIT_SAVE_CNTR_CTRL] still holds trigger 0. During pcie_portdrv_slot_reset(), flit_cntr_restore() runs before pci_restore_state() with no save in between, so pci_restore_flit_state() writes that stale 0 trigger back to PCI_FLIT_ERR_CNTR_CTRL and stops Flit events from firing. [ ... ] > +/* Stop counting until the log is drained */ > +static void flit_cntr_pause(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + unsigned long flags; > + > + spin_lock_irqsave(&info->lock, flags); > + __flit_cntr_ctrl_update(pdev, info->cntr->en, 0); > + spin_unlock_irqrestore(&info->lock, flags); > +} > + > +/* Re-arm event generation, unless flit_cntr_disable() ran meanwhile */ > +static void flit_cntr_resume(struct pci_dev *pdev) > +{ > + struct flit_info *info =3D pdev->flit_info; > + unsigned long flags; > + > + spin_lock_irqsave(&info->lock, flags); > + if (info->cntr_enabled) > + __flit_cntr_ctrl_update(pdev, 0, info->cntr->en); > + spin_unlock_irqrestore(&info->lock, flags); > +} [Severity: Medium] Can pci_restore_flit_state() and flit_cntr_enable() re-enable cntr->en while flit_ist() is still draining the log? flit_cntr_pause() clears cntr->en in hardware without recording paused state in struct flit_info, so a concurrent restore or enable re-arms the counter mid-drain: CPU0 (slot_reset) CPU1 (flit_isr / flit_ist) pcie_portdrv_slot_reset() flit_cntr_restore() flit_cntr_enable() flit_isr() flit_cntr_pause() return IRQ_WAKE_THREAD pci_restore_state() pci_restore_flit_state() <-- re-enables cntr->en mid-drain flit_ist() (draining log) flit_isr() (2nd IRQ) flit_cntr_pause() return IRQ_WAKE_THREAD flit_ist() finishes 1st pass flit_cntr_resume() <-- unpauses early The same race can happen during pci_pm_runtime_resume() or flit_probe() when flit_isr() pauses the counter before flit_cntr_enable() runs, where the 0->1 toggle of cntr->en can also clear pending event status. Tracking whether an event drain is in progress under info->lock would prevent restore and enable paths from re-enabling cntr->en early. > +static void flit_report(struct pci_dev *pdev, u32 err_log1, u32 err_log2) > +{ > + if (!(err_log1 & FLIT_ERR_LOG1_ERROR) && !err_log2) > + return; > + > + pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2); > +} [Severity: Medium] Should pci_warn() in flit_report() be ratelimited? flit_drain_log() can invoke flit_report() up to 255 times per interrupt, including for FEC-correctable syndrome errors, and flit_ist() immediately re-arms the counter via flit_cntr_resume(). On a noisy Flit Mode link this can flood dmesg and slow serial consoles enough to cause latency spikes or soft lockups. Draining the FIFO while ratelimiting the log messages (as AER does with per-device ratelimit_state) would avoid this. [ ... ] > +/* No suspend callbacks: pci_save_state() would save the counter disable= d */ > +static int flit_cntr_restore(struct pcie_device *dev) > +{ > + flit_cntr_enable(dev->port); > + return 0; > +} > + > +/* Disable first, or an event can assert a shared INTx line with no hand= ler */ > +static void flit_cntr_remove(struct pcie_device *dev) > +{ > + flit_cntr_disable(dev->port); > + free_irq(dev->irq, dev); > +} > + > +static struct pcie_port_service_driver flitdriver =3D { > + .name =3D "flit", > + .port_type =3D PCIE_ANY_PORT, > + .service =3D PCIE_PORT_SERVICE_FLIT, > + .probe =3D flit_probe, > + .resume =3D flit_cntr_restore, > + .runtime_resume =3D flit_cntr_restore, > + .slot_reset =3D flit_cntr_restore, > + .remove =3D flit_cntr_remove, > +}; [Severity: Medium] Can omitting .suspend and .runtime_suspend on flitdriver cause spurious wakeups and a D3cold config-write race with flit_ist()? PCIE_PORT_SERVICE_FLIT is part of PCIE_PORT_SERVICES_EXPCAP and shares its IRQ with PME, which calls enable_irq_wake() in pcie_pme_suspend(). Leaving the Flit counter and its interrupt enabled across suspend allows Flit events to fire the shared wakeup IRQ and spuriously wake the system during s2idle. During runtime suspend, pci_pm_runtime_suspend() transitions the port to D3hot/D3cold without synchronizing threaded IRQs, and flit_ist() holds no runtime PM reference: CPU0 (runtime suspend) CPU1 (flit_ist) flit_isr() return IRQ_WAKE_THREAD pci_pm_runtime_suspend() pci_save_state() pci_finish_runtime_suspend() (port enters D3cold) flit_ist() flit_drain_log() flit_cntr_resume() pci_clear_and_set_config_word() <-- reads/writes 0xffff in D3cold Saving the counter enabled also causes pci_restore_state() to re-enable Flit interrupts in pci_restore_flit_state() before pci_restore_config_space() and pci_restore_msi_state() restore PCI_COMMAND and MSI/MSI-X vectors. Since flitdriver already re-enables the counter in .resume and .runtime_resume, .suspend and .runtime_suspend can disable the hardware counter/interrupt and call synchronize_irq(dev->irq). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204181556.1418= 843-1-yazen.ghannam@amd.com?part=3D3