[PATCH v2 2/2] cxl/pci: Guard decoder accesses after reset

From: Richard Cheng

Date: Fri Nov 06 2026 - 06:36:13 EST


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@xxxxxxxxxx>
Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
---
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