Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/port: Unmask AER internal errors for VH endpoints
@ 2026-10-30  9:59 Richard Cheng
  2026-10-30 10:16 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Cheng @ 2026-10-30  9:59 UTC (permalink / raw)
  To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma
  Cc: iweiny, ming.li, icheng, linux-cxl, linux-kernel, kaihengf, kobak,
	newtonl, kristinc

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.

Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
 drivers/cxl/port.c     | 7 +++++++
 drivers/pci/pcie/aer.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
index c48216e5078f..c94a310061b0 100644
--- a/drivers/cxl/port.c
+++ b/drivers/cxl/port.c
@@ -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;
 }
 
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index db4f607f889c..94eca22422b7 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/port: Unmask AER internal errors for VH endpoints
  2026-10-30  9:59 [PATCH] cxl/port: Unmask AER internal errors for VH endpoints Richard Cheng
@ 2026-10-30 10:16 ` sashiko-bot
  2026-10-30 18:28 ` Bowman, Terry
  2026-10-30 19:11 ` Li Ming
  2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-30 10:16 UTC (permalink / raw)
  To: Richard Cheng; +Cc: linux-cxl

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 <icheng@nvidia.com>

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.

> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
> index c12fd0b89883a..2da8fd9e33a39 100644
> --- a/drivers/cxl/port.c
> +++ b/drivers/cxl/port.c
> @@ -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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261030095951.46080-1-icheng@nvidia.com?part=1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/port: Unmask AER internal errors for VH endpoints
  2026-10-30  9:59 [PATCH] cxl/port: Unmask AER internal errors for VH endpoints Richard Cheng
  2026-10-30 10:16 ` sashiko-bot
@ 2026-10-30 18:28 ` Bowman, Terry
  2026-10-30 19:11 ` Li Ming
  2 siblings, 0 replies; 4+ messages in thread
From: Bowman, Terry @ 2026-10-30 18:28 UTC (permalink / raw)
  To: Richard Cheng, dave, jic23, dave.jiang, alison.schofield,
	vishal.l.verma
  Cc: iweiny, ming.li, linux-cxl, linux-kernel, kaihengf, kobak,
	newtonl, kristinc

On 10/30/2026 4:59 AM, Richard Cheng wrote:
> 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.
> 
> Signed-off-by: Richard Cheng <icheng@nvidia.com>
> ---
>  drivers/cxl/port.c     | 7 +++++++
>  drivers/pci/pcie/aer.c | 3 ++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
> index c48216e5078f..c94a310061b0 100644
> --- a/drivers/cxl/port.c
> +++ b/drivers/cxl/port.c
> @@ -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;
>  }
>  

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

> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index db4f607f889c..94eca22422b7 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/port: Unmask AER internal errors for VH endpoints
  2026-10-30  9:59 [PATCH] cxl/port: Unmask AER internal errors for VH endpoints Richard Cheng
  2026-10-30 10:16 ` sashiko-bot
  2026-10-30 18:28 ` Bowman, Terry
@ 2026-10-30 19:11 ` Li Ming
  2 siblings, 0 replies; 4+ messages in thread
From: Li Ming @ 2026-10-30 19:11 UTC (permalink / raw)
  To: Richard Cheng, dave, jic23, dave.jiang, alison.schofield,
	vishal.l.verma
  Cc: iweiny, linux-cxl, linux-kernel, kaihengf, kobak, newtonl,
	kristinc

On 10/30/2026 5:59 PM, Richard Cheng wrote:
> 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.

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/20260902133933.2992457-9-terry.bowman@amd.com/

[2]: https://lore.kernel.org/linux-cxl/20260902133933.2992457-1-terry.bowman@amd.com/


Ming

>
> Signed-off-by: Richard Cheng <icheng@nvidia.com>
> ---
>  drivers/cxl/port.c     | 7 +++++++
>  drivers/pci/pcie/aer.c | 3 ++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
> index c48216e5078f..c94a310061b0 100644
> --- a/drivers/cxl/port.c
> +++ b/drivers/cxl/port.c
> @@ -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;
>  }
>  
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index db4f607f889c..94eca22422b7 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-30 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30  9:59 [PATCH] cxl/port: Unmask AER internal errors for VH endpoints Richard Cheng
2026-10-30 10:16 ` sashiko-bot
2026-10-30 18:28 ` Bowman, Terry
2026-10-30 19:11 ` Li Ming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox