cxl/port: Unmask AER internal errors for VH endpoints
Subsystems (3)
PATCH 1/1 cxl/port: Unmask AER internal errors for VH endpoints
CXL protocol errors are reported through PCIe AER internal errors. Unmasking the endpoint's CXL RAS register alone leaves the AER internal errors masked, thus the notification can't reach the Root Port.
Unmask AER internal errors during native endpoint RAS setup for VH devices. Allow cxl_port to use pci_aer_unmask_internal_errors() through its module-restricted export.
Verified with QEMU mem-data-ecc injection: the Root Port AER interrupt fires, the CXL correctable-error trace is emitted, and the endpoint's CorrIntErr counter increments.
--- drivers/cxl/port.c | 7 +++++++ drivers/pci/pcie/aer.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/cxl/port.c +7 -0
@@ -121,6 +121,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); } +/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev); +return 0 ; }
drivers/pci/pcie/aer.c +2 -1
@@ -1287,7 +1287,8 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)* Internal errors are too device-specific to enable generally, however for CXL * their behavior is standardized for conveying CXL protocol errors. */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors, +"cxl_core,cxl_port" );#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info)
base-commit: f0c48323b0402349530abc60ea908b5f5f40c395
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] cxl/port: unreachable pci_aer_unmask_internal_errors() in cxl_ras_unmask() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] cxl/port: unreachable pci_aer_unmask_internal_errors() in cxl_ras_unmask() --
commit d1558f7f8a341adaa60fba2aa3820ba77f94d9bf
Author: Richard Cheng <[email protected]>
cxl/port: Unmask AER internal errors for VH endpoints
This commit unmasks PCIe AER internal errors during CXL endpoint RAS setup for Virtual Host (VH) devices and exports pci_aer_unmask_internal_errors() to the cxl_port module.
Quoted 5 lines
drivers/cxl/port.c +0
-0
drivers/cxl/port.c static int cxl_ras_unmask(struct cxl_port *port) · line 126
Quoted 9 lines
drivers/cxl/port.c +6
-0@@ -118,6 +118,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); } +/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev);
[Severity: High]
Can pci_aer_unmask_internal_errors(pdev) ever be reached here?
The only caller of cxl_ras_unmask() is cxl_endpoint_port_probe(), where port->uport_dev is the struct cxl_memdev device on cxl_bus_type rather than the underlying struct pci_dev (which is port->uport_dev->parent):
drivers/cxl/port.c:devm_cxl_add_endpoint() {
...
endpoint = devm_cxl_add_port(host, &cxlmd->dev, CXL_RESOURCE_NONE,
parent_dport);
...
}drivers/cxl/port.c:cxl_endpoint_port_probe() {
struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
...
devm_cxl_port_ras_setup(port);
if (cxl_ras_unmask(port))
dev_dbg(&port->dev, "failed to unmask RAS interrupts\n");
...
}At the start of cxl_ras_unmask(), port->uport_dev is checked with dev_is_pci():
drivers/cxl/port.c:cxl_ras_unmask() {
...
if (!dev_is_pci(port->uport_dev))
return 0;
pdev = to_pci_dev(port->uport_dev);
...
}Because port->uport_dev is &cxlmd->dev on cxl_bus_type, dev_is_pci(port->uport_dev) always evaluates to false, causing cxl_ras_unmask() to return 0 immediately without unmasking the CXL RAS registers or calling pci_aer_unmask_internal_errors(pdev).
Should cxl_ras_unmask() inspect port->uport_dev->parent (similar to how read_cdat_data() in drivers/cxl/core/pci.c checks uport->parent when is_cxl_memdev(uport) is true) to obtain the endpoint's struct pci_dev?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 26 lines · Richard Cheng
CXL protocol errors are reported through PCIe AER internal errors. Unmasking the endpoint's CXL RAS register alone leaves the AER internal errors masked, thus the notification can't reach the Root Port.
Unmask AER internal errors during native endpoint RAS setup for VH devices. Allow
cxl_portto usepci_aer_unmask_internal_errors()through its module-restricted export.Verified with QEMU mem-data-ecc injection: the Root Port AER interrupt fires, the CXL correctable-error trace is emitted, and the endpoint's CorrIntErr counter increments.
Signed-off-by Richard Cheng <[email protected]>--- drivers/cxl/port.c | 7 +++++++ drivers/pci/pcie/aer.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)drivers/cxl/port.c +0
-0@@ -121,6 +121,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); }
drivers/cxl/port.c static int cxl_ras_unmask(struct cxl_port *port) · line 133
Quoted 10 lines
drivers/cxl/port.c +7
-0+/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev); +return 0 ; }
Hi Richard,
The unmasking needs to cover the RCD case as well. The RCD AER is used to mask reporting. The is_cxl_restricted() gate should be removed so the pci_aer_unmask_internal_errors() is called for both the VH and RCD cases.
I confirmed Sashiko's finding that the unmasking will never execute, thanks to this early return:
if (!dev_is_pci(port->uport_dev)) <<== Fails here
return 0;
pdev = to_pci_dev(port->uport_dev);For an endpoint port, port->uport_dev is the cxl_memdev, not a PCI device. So dev_is_pci() is false and we return early. The PCI device is port->uport_dev->parent.
Note, I used base v7.3-rc7. I couldn't find f0c48323b040.
- Terry
Quoted 16 lines
drivers/pci/pcie/aer.c +2
-1@@ -1287,7 +1287,8 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)* Internal errors are too device-specific to enable generally, however for CXL * their behavior is standardized for conveying CXL protocol errors. */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors, +"cxl_core,cxl_port" );#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info)base-commit:
f0c48323b0402349530abc60ea908b5f5f40c395
Quoted 44 lines · Terry
Quoted 26 lines · Richard Cheng
CXL protocol errors are reported through PCIe AER internal errors. Unmasking the endpoint's CXL RAS register alone leaves the AER internal errors masked, thus the notification can't reach the Root Port.
Unmask AER internal errors during native endpoint RAS setup for VH devices. Allow
cxl_portto usepci_aer_unmask_internal_errors()through its module-restricted export.Verified with QEMU mem-data-ecc injection: the Root Port AER interrupt fires, the CXL correctable-error trace is emitted, and the endpoint's CorrIntErr counter increments.
Signed-off-by Richard Cheng <[email protected]>--- drivers/cxl/port.c | 7 +++++++ drivers/pci/pcie/aer.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)drivers/cxl/port.c +0
-0@@ -121,6 +121,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); }drivers/cxl/port.c static int cxl_ras_unmask(struct cxl_port *port) · line 133
Quoted 10 lines
drivers/cxl/port.c +7
-0+/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev); +return 0 ; }Hi Richard,
The unmasking needs to cover the RCD case as well. The RCD AER is used to mask reporting. The
is_cxl_restricted()gate should be removed so thepci_aer_unmask_internal_errors()is called for both the VH and RCD cases.
Quoted 9 lines
I confirmed Sashiko's finding that the unmasking will never execute, thanks to this early return:
if (!dev_is_pci(port->uport_dev)) <<== Fails here return 0; pdev = to_pci_dev(port->uport_dev);For an endpoint port,
port->uport_devis thecxl_memdev, not a PCI device. Sodev_is_pci()is false and we return early. The PCI device isport->uport_dev->parent.
Hi Terry,
Thanks for the headup, and I've also send a patch to fix this issue [1].
And seems like your patch mentioned by Li Ming is already covering this bug ? if that's the case we can focus on yours, if not I would love to make the fix in.
Best regards,
Richard Cheng.
[1]: https://lore.kernel.org/linux-cxl/[email protected]/
Quoted 21 lines
Note, I used base v7.3-rc7. I couldn't find
f0c48323b040.- Terry
Quoted 16 lines
drivers/pci/pcie/aer.c +2
-1@@ -1287,7 +1287,8 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)* Internal errors are too device-specific to enable generally, however for CXL * their behavior is standardized for conveying CXL protocol errors. */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors, +"cxl_core,cxl_port" );#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info)base-commit:
f0c48323b0402349530abc60ea908b5f5f40c395
Li Ming
reviewerQuoted 11 lines · Richard Cheng
CXL protocol errors are reported through PCIe AER internal errors. Unmasking the endpoint's CXL RAS register alone leaves the AER internal errors masked, thus the notification can't reach the Root Port.
Unmask AER internal errors during native endpoint RAS setup for VH devices. Allow
cxl_portto usepci_aer_unmask_internal_errors()through its module-restricted export.Verified with QEMU mem-data-ecc injection: the Root Port AER interrupt fires, the CXL correctable-error trace is emitted, and the endpoint's CorrIntErr counter increments.
I found the similiar implementation[1] in CXL RAS support for VH patchset[2], seems like it is under review.
[1]: https://lore.kernel.org/linux-cxl/[email protected]/
[2]: https://lore.kernel.org/linux-cxl/[email protected]/
Ming
Quoted 41 lines
Signed-off-by Richard Cheng <[email protected]>--- drivers/cxl/port.c | 7 +++++++ drivers/pci/pcie/aer.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)drivers/cxl/port.c +7
-0@@ -121,6 +121,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); } +/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev); +return 0 ; }drivers/pci/pcie/aer.c +2
-1@@ -1287,7 +1287,8 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)* Internal errors are too device-specific to enable generally, however for CXL * their behavior is standardized for conveying CXL protocol errors. */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors, +"cxl_core,cxl_port" );#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info)base-commit:
f0c48323b0402349530abc60ea908b5f5f40c395
Quoted 9 lines · Li Ming
Quoted 8 lines · Richard Cheng
CXL protocol errors are reported through PCIe AER internal errors. Unmasking the endpoint's CXL RAS register alone leaves the AER internal errors masked, thus the notification can't reach the Root Port.
Unmask AER internal errors during native endpoint RAS setup for VH devices. Allow
cxl_portto usepci_aer_unmask_internal_errors()through its module-restricted export.
Quoted 6 lines
Quoted 3 lines
Verified with QEMU mem-data-ecc injection: the Root Port AER interrupt fires, the CXL correctable-error trace is emitted, and the endpoint's CorrIntErr counter increments.
I found the similiar implementation[1] in CXL RAS support for VH patchset[2], seems like it is under review.
Ohh ok, then I think we can drop this one.
Thanks.
Quoted 51 lines
[1]: https://lore.kernel.org/linux-cxl/[email protected]/
[2]: https://lore.kernel.org/linux-cxl/[email protected]/
Ming
Quoted 41 lines
Signed-off-by Richard Cheng <[email protected]>--- drivers/cxl/port.c | 7 +++++++ drivers/pci/pcie/aer.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)drivers/cxl/port.c +7
-0@@ -121,6 +121,13 @@ static int cxl_ras_unmask(struct cxl_port *port) orig_val, val); } +/* +* RCH errors are reported by the RCEC. VH endpoints report CXL +* protocol errors as PCIe AER internal errors. +*/ +if (!is_cxl_restricted (pdev)) +pci_aer_unmask_internal_errors (pdev); +return 0 ; }drivers/pci/pcie/aer.c +2
-1@@ -1287,7 +1287,8 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)* Internal errors are too device-specific to enable generally, however for CXL * their behavior is standardized for conveying CXL protocol errors. */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors, +"cxl_core,cxl_port" );#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info)base-commit:
f0c48323b0402349530abc60ea908b5f5f40c395