* [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible
2026-11-06 11:18 [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery Richard Cheng
@ 2026-11-06 11:18 ` Richard Cheng
2026-11-06 18:30 ` Farhan Ali
2026-11-06 11:18 ` [PATCH v2 2/2] cxl/pci: Guard decoder accesses after reset Richard Cheng
2026-11-06 11:22 ` [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery Richard Cheng
2 siblings, 1 reply; 5+ messages in thread
From: Richard Cheng @ 2026-11-06 11:18 UTC (permalink / raw)
To: bhelgaas, dave, jic23, dave.jiang, alison.schofield,
vishal.l.verma, benjamin.cheatham
Cc: iweiny, ming.li, icheng, linux-cxl, linux-kernel, linux-pci,
tglx, wangruikang, vidyas, lihaoxiang, xiangzao, shawn.lin,
alifm, 18255117159
PCI state restoration runs even when a reset fails. If the device's
configuration space remains inaccessible, MSI-X restoration can issue
table MMIO accesses that trigger additional errors, including DPC
containment.
Check the existing PCI Command register read and skip MSI-X restoration
if it fails or returns all ones. Preserve the existing handling of a
valid Command register with Memory Space Enable clear, which temporarily
enables memory decoding while restoring the MSI-X table.
Limit the change to MSI-X restoration. Leave other PCI state
restoration, driver reset callbacks, and reset return values unchanged.
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
drivers/pci/msi/msi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 8a0133a6a286..37de31f4cfb6 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -887,7 +887,11 @@ void __pci_restore_msix_state(struct pci_dev *dev)
* Since the MSI-X Table and PBA are in Memory Space, enable it
* while restoring them.
*/
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ if (pci_read_config_word(dev, PCI_COMMAND, &cmd) ||
+ PCI_POSSIBLE_ERROR(cmd)) {
+ pci_warn(dev, "Device config space inaccessible; unable to restore MSI-X state\n");
+ return;
+ }
pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
write_msg = arch_restore_msi_irqs(dev);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible
2026-11-06 11:18 ` [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible Richard Cheng
@ 2026-11-06 18:30 ` Farhan Ali
0 siblings, 0 replies; 5+ messages in thread
From: Farhan Ali @ 2026-11-06 18:30 UTC (permalink / raw)
To: Richard Cheng, bhelgaas, dave, jic23, dave.jiang,
alison.schofield, vishal.l.verma, benjamin.cheatham
Cc: iweiny, ming.li, linux-cxl, linux-kernel, linux-pci, tglx,
wangruikang, vidyas, lihaoxiang, xiangzao, shawn.lin,
18255117159
On 11/6/2026 3:18 AM, Richard Cheng wrote:
> PCI state restoration runs even when a reset fails. If the device's
> configuration space remains inaccessible, MSI-X restoration can issue
> table MMIO accesses that trigger additional errors, including DPC
> containment.
>
> Check the existing PCI Command register read and skip MSI-X restoration
> if it fails or returns all ones. Preserve the existing handling of a
> valid Command register with Memory Space Enable clear, which temporarily
> enables memory decoding while restoring the MSI-X table.
>
> Limit the change to MSI-X restoration. Leave other PCI state
> restoration, driver reset callbacks, and reset return values unchanged.
>
> Signed-off-by: Richard Cheng <icheng@nvidia.com>
Just curious, why are we limiting this to only MSI-X and not MSI? I
think MSI restoration will fail as well since the config space is not
accessible.
> ---
> drivers/pci/msi/msi.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 8a0133a6a286..37de31f4cfb6 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -887,7 +887,11 @@ void __pci_restore_msix_state(struct pci_dev *dev)
> * Since the MSI-X Table and PBA are in Memory Space, enable it
> * while restoring them.
> */
> - pci_read_config_word(dev, PCI_COMMAND, &cmd);
> + if (pci_read_config_word(dev, PCI_COMMAND, &cmd) ||
> + PCI_POSSIBLE_ERROR(cmd)) {
> + pci_warn(dev, "Device config space inaccessible; unable to restore MSI-X state\n");
> + return;
> + }
We have a helper function pci_dev_config_accessible() that does the same
check, so might be appropriate to use (of course we would have to make
the function global rather than static).
And maybe the check should be moved up before any config space access in
this function?
Thanks
Farhan
> pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
>
> write_msg = arch_restore_msi_irqs(dev);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] cxl/pci: Guard decoder accesses after reset
2026-11-06 11:18 [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery Richard Cheng
2026-11-06 11:18 ` [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible Richard Cheng
@ 2026-11-06 11:18 ` Richard Cheng
2026-11-06 11:22 ` [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery Richard Cheng
2 siblings, 0 replies; 5+ messages in thread
From: Richard Cheng @ 2026-11-06 11:18 UTC (permalink / raw)
To: bhelgaas, dave, jic23, dave.jiang, alison.schofield,
vishal.l.verma, benjamin.cheatham
Cc: iweiny, ming.li, icheng, linux-cxl, linux-kernel, linux-pci,
tglx, wangruikang, vidyas, lihaoxiang, xiangzao, shawn.lin,
alifm, 18255117159
cxl_reset_done() runs even when PCI state restoration is skipped.
Reading HDM decoder registers while the device is inaccessible can
trigger another error.
Skip decoder checks if the PCI Command read fails, returns all ones, or
Memory Space Enable is clear.
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index 3ed7c3e70042..ca9e2bb505c8 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -1106,6 +1106,12 @@ static void cxl_reset_done(struct pci_dev *pdev)
struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
struct cxl_memdev *cxlmd = cxlds->cxlmd;
struct device *dev = &pdev->dev;
+ u32 command;
+
+ /* PCI state restoration may have been skipped after a failed reset. */
+ if (pci_read_config_dword(pdev, PCI_COMMAND, &command) ||
+ PCI_POSSIBLE_ERROR(command) || !(command & PCI_COMMAND_MEMORY))
+ return;
/*
* FLR does not expect to touch the HDM decoders and related
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery
2026-11-06 11:18 [PATCH v2 0/2] PCI/CXL: Guard MMIO accesses during reset recovery Richard Cheng
2026-11-06 11:18 ` [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible Richard Cheng
2026-11-06 11:18 ` [PATCH v2 2/2] cxl/pci: Guard decoder accesses after reset Richard Cheng
@ 2026-11-06 11:22 ` Richard Cheng
2 siblings, 0 replies; 5+ messages in thread
From: Richard Cheng @ 2026-11-06 11:22 UTC (permalink / raw)
To: bhelgaas, dave, jic23, dave.jiang, alison.schofield,
vishal.l.verma, benjamin.cheatham
Cc: iweiny, ming.li, linux-cxl, linux-kernel, linux-pci, tglx,
wangruikang, vidyas, lihaoxiang, xiangzao, shawn.lin, alifm,
18255117159
On Fri, Nov 06, 2026 at 07:18:27PM +0800, Richard Cheng wrote:
> PCI reset recovery may proceed with state restoration and driver
> reset_done() callbacks even when a device has not recovered.
> Accessing device MMIO in that state can cause additional errors, including
> DPC containment.
>
> This series adds checks before two MMIO access paths: MSI-X table
> resoration and CXL HDM decoder checking.
>
> Patch 1 checks the existing PCI Command register read in
> __pci_restore_msix_state(). If the read fails or returns all ones,
> warn and return before accessing the MSI-X table.
>
> Patch 2 guards CXL decoder accesses after reset.
> The CXL reset_done() callback independently accesses HDM decoder
> MMIO to check whether decoder state was lost during reset.
>
> Changes since v1 [1]:
> - Dropped v1 patch 1, since commit e8df1d194c39
> ("PCI: Don't treat ~0 as ready in pci_dev_wait() with RRS SV")
> already addresses the issue.
> - Dropped v1 patch 2, following Benjamin Cheatham's review.
> That some devices rely on the existing fallback behavior.
> - Reworked v1 patch 3 into v2 patch 1. Instead of skipping all PCI
> state restoration, check config accessibility before MSI-X restoration.
> This reduces the impact on other restoration paths.
> - Retained v1 patch 4 as v2 patch 2.
>
>
Sorry forgot to attach the link for v1:
https://lore.kernel.org/all/20260929020405.9724-1-icheng@nvidia.com/
Best regards,
Richard Cheng.
> Richard Cheng (2):
> PCI/MSI: Skip MSI-X restoration when configuration is inaccessible
> cxl/pci: Guard decoder accesses after reset
>
> drivers/cxl/pci.c | 6 ++++++
> drivers/pci/msi/msi.c | 6 +++++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
>
> base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread