From: sashiko-bot@kernel.org
To: raoxu <raoxu@uniontech.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/MSI: Retry a mismatched MSI-X message once during restore
Date: Thu, 26 Nov 2026 07:11:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-234935@kernel.org> (raw)
In-Reply-To: <4EDB2ADA2CFC5963+20261126064901.1798104-1-raoxu@uniontech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] PCI/MSI: __pci_restore_msix_state() reads MSI-X table when
channel is frozen
- [Medium] PCI/MSI: unreliable retry and offline read in
__pci_restore_msix_state()
--
commit a9578a3be66676c84a41222ba8afbb2d8beac990
Author: Xu Rao <raoxu@uniontech.com>
PCI/MSI: Retry a mismatched MSI-X message once during restore
This commit reads back each MSI-X table entry in __pci_restore_msix_state()
after writing it and retries __pci_write_msi_msg() once if the readback
differs from the cached message.
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 4e8ec8d42aa6b..4ab2c670a2d40 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -870,6 +870,7 @@ int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int
> void __pci_restore_msix_state(struct pci_dev *dev)
> {
> struct msi_desc *entry;
> + struct msi_msg actual;
> bool write_msg;
> u16 cmd;
>
> @@ -895,6 +896,15 @@ void __pci_restore_msix_state(struct pci_dev *dev)
> msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
> if (write_msg)
> __pci_write_msi_msg(entry, &entry->msg);
> + if (write_msg && dev->current_state == PCI_D0 &&
> + !pci_dev_is_disconnected(dev) &&
> + !entry->pci.msi_attrib.is_virtual) {
> + __pci_read_msi_msg(entry, &actual);
[Severity: Medium]
Should this guard check !pci_channel_offline(dev) instead of
!pci_dev_is_disconnected(dev)?
Both __pci_write_msi_msg() and pci_msix_write_vector_ctrl() skip MSI-X
table MMIO accesses when pci_channel_offline(dev) is true, as updated in
2e2f69fc8ae2 ("PCI/MSI: Skip MSI/MSI-X programming while the channel is
offline"). pci_dev_is_disconnected() only checks for
pci_channel_io_perm_failure, so if __pci_restore_msix_state() runs while
dev->error_state is pci_channel_io_frozen, __pci_read_msi_msg() still
issues three MMIO reads to the unreachable MSI-X table BAR. When a
Downstream Port link is contained by DPC, those reads complete with
Unsupported Request (returning 0xffffffff), which can trigger an RP PIO
error and secondary Root Port containment on Root Ports with DPC RP
Extensions, as well as a duplicate __pci_write_msi_msg() call.
> + if (actual.address_lo != entry->msg.address_lo ||
> + actual.address_hi != entry->msg.address_hi ||
> + actual.data != entry->msg.data)
> + __pci_write_msi_msg(entry, &entry->msg);
> + }
[Severity: Medium]
Can an immediate single __pci_write_msi_msg() retry still fail when the
device is not yet responding to MSI-X BAR MMIO accesses?
pci_write_msg_msix() already ends with a readl() flush of
PCI_MSIX_ENTRY_DATA, so when __pci_read_msi_msg() reads back all ones (as
in cycle 18 of the changelog), all three readl() calls in
__pci_read_msi_msg() also failed and the device is still not decoding MMIO
at the moment the retry runs. Without waiting for readiness or verifying
the retry, the second write and the following pci_msix_write_vector_ctrl()
can be dropped as well.
In addition, pci_write_config_word(dev, PCI_COMMAND, cmd |
PCI_COMMAND_MEMORY) earlier in __pci_restore_msix_state() is not flushed
with a config read before the MSI-X table MMIO writes begin, and the
unconditional readback adds three synchronous readl() calls per MSI-X
descriptor on every restore across all devices. Retrying via
__pci_write_msi_msg() rather than pci_write_msg_msix() also invokes
entry->write_msi_msg() a second time.
--
Sashiko AI review · https://sashiko.dev/#/patchset/4EDB2ADA2CFC5963+20261126064901.1798104-1-raoxu@uniontech.com?part=1
prev parent reply other threads:[~2026-11-26 7:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:49 [PATCH] PCI/MSI: Retry a mismatched MSI-X message once during restore raoxu
2026-11-26 7:11 ` sashiko-bot [this message]
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=sashiko-outbox-234935@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=raoxu@uniontech.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox