Skip to contentSkip to conversation

cxl: Convert PCIBIOS errors to errno on remaining DVSEC/PCIe accesses

PATCH In review Richard Cheng 2 participants 2 messages Jun 23 CXL

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cxl: Convert PCIBIOS errors to errno on remaining DVSEC/PCIe accesses

Follow-up to Dav Jiang's commit 26aa60e02762 ("cxl/pci: Convert PCIBIOS errors to errno on DVSEC config accesses") .

PCI config and PCIe capability accessors return positive PCIBIOS_* status codes on failure, not negative errnos. update_gpf_port_dvsec() and cxl_ras_unmask() still return the raw status on their accessor error paths, inconsistent with the errno convention they otherwise use. Convert it with pcibios_err_to_errno()

---
Changelog:

v1->v2:
- update_gpf_port_dvsec(): Also convert the pci_read_config_word() failure path. v1 converted only the write path.
- Drop patch 2/2. On a failed config read the accessor returns ~0, which cxl_decode_regblock() already rejects, so
__cxl_find_regblock_instance() already returns -ENODDEV with map-resource cleared. There's no bug, so the change is dropped.
- Fix the commit message, the second call site is cxl_ras_unmask(), not cxl_setup_parent_dport(), fix a "Convert" typo.

---
 drivers/cxl/core/pci.c | 4 ++--
 drivers/cxl/port.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/cxl/core/pci.c +2 -2
index e4338fd7e01b..bf6d566b2d6b 100644
@@ -838,7 +838,7 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
 
 	rc = pci_read_config_word(pdev, dvsec + offset, &ctrl);
 	if (rc)
-		return rc;
+		return pcibios_err_to_errno(rc);
 
 	if (FIELD_GET(base, ctrl) == GPF_TIMEOUT_BASE_MAX &&
 	    FIELD_GET(scale, ctrl) == GPF_TIMEOUT_SCALE_MAX)
@@ -852,7 +852,7 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
 		pci_dbg(pdev, "Port GPF phase %d timeout: %d0 secs\n",
 			phase, GPF_TIMEOUT_BASE_MAX);
 
-	return rc;
+	return pcibios_err_to_errno(rc);
 }
 
 int cxl_gpf_port_setup(struct cxl_dport *dport)
drivers/cxl/port.c +1 -1
index 99cf77b6b699..8db4d15e9427 100644
@@ -92,7 +92,7 @@ static int cxl_ras_unmask(struct cxl_port *port)
 
 	rc = pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &cap);
 	if (rc)
-		return rc;
+		return pcibios_err_to_errno(rc);
 
 	if (cap & PCI_EXP_DEVCTL_URRE) {
 		addr = port->regs.ras + CXL_RAS_UNCORRECTABLE_MASK_OFFSET;

base-commit: ef0c9f75a19532d7675384708fc8621e10850104

Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Richard Cheng

Follow-up to Dav Jiang's commit 26aa60e02762 ("cxl/pci: Convert PCIBIOS errors to errno on DVSEC config accesses") .

PCI config and PCIe capability accessors return positive PCIBIOS_* status codes on failure, not negative errnos. update_gpf_port_dvsec() and cxl_ras_unmask() still return the raw status on their accessor error paths, inconsistent with the errno convention they otherwise use. Convert it with pcibios_err_to_errno()

Quoted 54 lines

---
Changelog:

v1->v2:
- update_gpf_port_dvsec(): Also convert the pci_read_config_word() failure path. v1 converted only the write path.
- Drop patch 2/2. On a failed config read the accessor returns ~0, which cxl_decode_regblock() already rejects, so
__cxl_find_regblock_instance() already returns -ENODDEV with map-resource cleared. There's no bug, so the change is dropped.
- Fix the commit message, the second call site is cxl_ras_unmask(), not cxl_setup_parent_dport(), fix a "Convert" typo.

---
 drivers/cxl/core/pci.c | 4 ++--
 drivers/cxl/port.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/cxl/core/pci.c +2 -2
index e4338fd7e01b..bf6d566b2d6b 100644
@@ -838,7 +838,7 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
 
 	rc = pci_read_config_word(pdev, dvsec + offset, &ctrl);
 	if (rc)
-		return rc;
+		return pcibios_err_to_errno(rc);
 
 	if (FIELD_GET(base, ctrl) == GPF_TIMEOUT_BASE_MAX &&
 	    FIELD_GET(scale, ctrl) == GPF_TIMEOUT_SCALE_MAX)
@@ -852,7 +852,7 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
 		pci_dbg(pdev, "Port GPF phase %d timeout: %d0 secs\n",
 			phase, GPF_TIMEOUT_BASE_MAX);
 
-	return rc;
+	return pcibios_err_to_errno(rc);
 }
 
 int cxl_gpf_port_setup(struct cxl_dport *dport)
drivers/cxl/port.c +1 -1
index 99cf77b6b699..8db4d15e9427 100644
@@ -92,7 +92,7 @@ static int cxl_ras_unmask(struct cxl_port *port)
 
 	rc = pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &cap);
 	if (rc)
-		return rc;
+		return pcibios_err_to_errno(rc);
 
 	if (cap & PCI_EXP_DEVCTL_URRE) {
 		addr = port->regs.ras + CXL_RAS_UNCORRECTABLE_MASK_OFFSET;

base-commit: ef0c9f75a19532d7675384708fc8621e10850104