From: Alex Williamson <alex@shazbot.org>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev,
"Josh Hilke" <jrhilke@google.com>,
kvm@vger.kernel.org, alex@shazbot.org
Subject: Re: [PATCH v3 6/9] vfio: selftests: igb: Disable PCIe completion timeout retries
Date: Thu, 9 Jul 2026 16:59:13 -0600 [thread overview]
Message-ID: <20260709165913.422fd951@shazbot.org> (raw)
In-Reply-To: <20260708233123.F2EEC1F000E9@smtp.kernel.org>
On Wed, 08 Jul 2026 23:31:23 +0000
sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] Missing SW/FW synchronization semaphore when accessing PHY registers via MDIO.
> - [Medium] Missing DMA read memory barrier (dma_rmb) after descriptor completion polling.
> --
>
> --- Patch [6]: [PATCH v3 6/9] vfio: selftests: igb: Disable PCIe completion timeout retries ---
> commit b47012b45a463be841715f383fb27408df2c020e
> Author: Alex Williamson <alex.williamson@nvidia.com>
>
> vfio: selftests: igb: Disable PCIe completion timeout retries
>
> The mix_and_match test intentionally submits TX descriptors with an
> unmapped source IOVA so that the DMA read fails. By default the 82576
> re-sends the request after a PCIe completion timeout (datasheet section
> 8.6.1, GCR.Completion_Timeout_Resend, bit 16, initial value 1b). On
> real hardware this turns a single fault into a stream of retried reads,
> keeping PCIe AER and IOMMU error handling busy and interfering with
> reset recovery.
>
> Clear GCR.Completion_Timeout_Resend during device initialization so a
> failed read fails once and stays failed.
>
> > diff --git a/tools/testing/selftests/vfio/lib/drivers/igb/igb.c b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c
> > index 1848be6cd46c9..a7a30660b23ed 100644
> > --- a/tools/testing/selftests/vfio/lib/drivers/igb/igb.c
> > +++ b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c
> > @@ -219,6 +219,18 @@ static void igb_init(struct vfio_pci_device *device)
> > vfio_pci_config_writew(device, PCI_COMMAND, cmd_reg);
> > }
> >
> > + /*
> > + * Disable DMA re-send on PCIe completion timeout (82576 datasheet
> > + * section 8.6.1, GCR.Completion_Timeout_Resend, bit 16). The
> > + * mix_and_match test intentionally submits descriptors targeting
> > + * unmapped IOVAs; with the default (set) value, the device keeps
> > + * retrying the failed read indefinitely, which keeps PCIe AER and
> > + * IOMMU error handling busy and interferes with reset recovery.
> > + */
> > + ctrl = igb_read32(igb, E1000_GCR);
> > + ctrl &= ~E1000_GCR_CMPL_TMOUT_RESEND;
> > + igb_write32(igb, E1000_GCR, ctrl);
> > +
> > /* Configure PHY internal loopback for testing. */
> > igb_setup_loopback(igb);
>
> [Severity: Medium]
> Does writing directly to the MDIC register on real 82576 hardware risk
> colliding with the firmware or BMC management engine?
>
> When running tests on physical devices, accessing PHY registers without
> acquiring the E1000_SW_FW_SYNC semaphore can cause corrupted MDIO
> transactions or hardware hangs. For example, in igb_write_phy():
>
> mdic = (((u32)data) |
> (offset << E1000_MDIC_REG_SHIFT) |
> (1 << E1000_MDIC_PHY_SHIFT) |
> E1000_MDIC_OP_WRITE);
>
> igb_write32(igb, E1000_MDIC, mdic);
Technically yes, but it's non-trivial and we assume an isolated
environment. I test on a plugin dual-port NIC, potentially an
integrated NIC with manageability on the platform might encounter
something like this, but it's a narrow window that's probably
acceptable for a selftest driver. We could add the following above
igb_write_phy() to note the deferral:
+/*
+ * Write a PHY register over MDIO.
+ *
+ * A production driver would hold the SW/FW semaphore (SWSM.SWESMBI + the
+ * SW_FW_SYNC PHY bit) across the MDIO transaction to serialize against the
+ * device's management firmware. The selftest owns the assigned function
+ * exclusively on a dedicated test device with no active manageability
+ * contending for the PHY, so the sync is omitted; it should be added here
+ * if this ever needs to run on a manageability-enabled NIC.
+ */
> [Severity: Medium]
> Can the CPU speculatively read the destination DMA buffer before the hardware
> descriptor writeback is architecturally complete?
>
> In igb_memcpy_wait(), the code polls the status bit via READ_ONCE() but
> returns without issuing a dma_rmb():
>
> status = le32_to_cpu(READ_ONCE(rx->wb.status_error));
> if (status & 1)
> break;
> usleep(1000);
> }
>
> igb_irq_clear(igb);
>
> On weakly-ordered architectures like ARM64, the test runner's subsequent
> memcmp() reads on the DMA destination buffer could be speculatively
> reordered before the loop's status poll finishes, resulting in stale
> data reads and sporadic test failures.
igb_memcpy_wait() is implemented in patch 1, and could indeed make use
of an rmb(). This function changes through the series, created in 1,
touched in 5 and 9. Before we get here we could include
<asm/barrier.h> and call rmb() just before return 0;
Re-tested all the suggested code changes, reorder in igb_hw_init() and
rmb() in igb_memcpy_wait() against physical 82576 NIC, 35/35 pass.
Thanks,
Alex
next prev parent reply other threads:[~2026-07-09 22:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 23:18 [PATCH v3 0/9] vfio: selftests: Add driver for Intel Ethernet Gigabit Controller (IGB) Josh Hilke
2026-07-08 23:18 ` [PATCH v3 1/9] vfio: selftests: igb: Add driver for IGB QEMU device Josh Hilke
2026-07-08 23:31 ` sashiko-bot
2026-07-09 19:23 ` Josh Hilke
2026-07-08 23:18 ` [PATCH v3 2/9] vfio: selftests: igb: Use PHY internal loopback on 82576 Josh Hilke
2026-07-08 23:28 ` sashiko-bot
2026-07-09 19:27 ` Josh Hilke
2026-07-08 23:18 ` [PATCH v3 3/9] vfio: selftests: igb: Use advanced TX and RX descriptors Josh Hilke
2026-07-08 23:29 ` sashiko-bot
2026-07-09 20:43 ` Josh Hilke
2026-07-09 21:33 ` Alex Williamson
2026-07-08 23:18 ` [PATCH v3 4/9] vfio: selftests: igb: Program MSI-X interrupt routing Josh Hilke
2026-07-08 23:33 ` sashiko-bot
2026-07-09 20:44 ` Josh Hilke
2026-07-09 22:59 ` Alex Williamson
2026-07-08 23:18 ` [PATCH v3 5/9] vfio: selftests: igb: Extend memcpy completion timeout for line-rate hardware Josh Hilke
2026-07-08 23:18 ` [PATCH v3 6/9] vfio: selftests: igb: Disable PCIe completion timeout retries Josh Hilke
2026-07-08 23:31 ` sashiko-bot
2026-07-09 22:48 ` Josh Hilke
2026-07-09 22:59 ` Alex Williamson [this message]
2026-07-08 23:18 ` [PATCH v3 7/9] vfio: selftests: Add helpers to re-enable interrupts Josh Hilke
2026-07-08 23:18 ` [PATCH v3 8/9] vfio: selftests: igb: Factor hardware programming into igb_hw_init() Josh Hilke
2026-07-08 23:18 ` [PATCH v3 9/9] vfio: selftests: igb: Recover after DMA-read faults Josh Hilke
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=20260709165913.422fd951@shazbot.org \
--to=alex@shazbot.org \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.