Linux ACPI
 help / color / mirror / Atom feed
From: "Bowman, Terry" <terry.bowman@amd.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Dan Williams <djbw@kernel.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-cxl@vger.kernel.org, Tony Luck <tony.luck@intel.com>,
	Borislav Petkov <bp@alien8.de>, Hanjun Guo <guohanjun@huawei.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shuai Xue <xueshuai@linux.alibaba.com>,
	Len Brown <lenb@kernel.org>, Ira Weiny <iweiny@kernel.org>,
	Li Ming <ming.li@zohomail.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Ben Cheatham <Benjamin.Cheatham@amd.com>,
	Richard Cheng <icheng@nvidia.com>,
	Robert Richter <rrichter@amd.com>, Lukas Wunner <lukas@wunner.de>,
	linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v20 9/9] Documentation: cxl: Document CXL protocol error handling
Date: Thu, 10 Sep 2026 10:19:44 -0500	[thread overview]
Message-ID: <841e2342-273b-437d-82b0-f85bf6940001@amd.com> (raw)
In-Reply-To: <20260908193906.093dd008@jic23-huawei>

On 9/8/2026 1:39 PM, Jonathan Cameron wrote:
> On Wed, 2 Sep 2026 08:39:33 -0500
> Terry Bowman <terry.bowman@amd.com> wrote:
> 
>> Add Documentation/driver-api/cxl/linux/protocol-error-handling.rst
>> describing the end-to-end CXL protocol error path: AER ingress, the
>> AER-CXL kfifo handoff, the cxl_core consumer worker, RCD/RCH special
>> cases, severity policy, trace events, and a source code map.
>>
>> This documents the architecture introduced by the preceding patches in
>> this series.
>>
>> Assisted-by: Claude:claude-opus-4.8
> Assited-by: LLM
Ok, will switch to "Assisted-by: LLM" across the series.

> for all of these (kernel documentation was recently changed on this).
>> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> 
> 
> ...
> 
>> diff --git a/Documentation/driver-api/cxl/linux/protocol-error-handling.rst b/Documentation/driver-api/cxl/linux/protocol-error-handling.rst
>> new file mode 100644
>> index 0000000000000..1da71d0409a05
>> --- /dev/null
>> +++ b/Documentation/driver-api/cxl/linux/protocol-error-handling.rst
>> @@ -0,0 +1,441 @@
>> +Error flow
>> +==========
>> +
>> +.. code-block:: text
>> +
>> +   CXL device raises AER Internal Error
>> +   (PCI_ERR_COR_INTERNAL or PCI_ERR_UNC_INTN)
>> +                   |
>> +                   v
>> +   +--------------------------------------+
>> +   | AER core (aer.c)                     |
>> +   |  aer_irq() -> aer_isr()              |
>> +   |  -> find_source_device()             |
>> +   |  -> handle_error_source(dev, info)   |
>> +   +--------------------------------------+
>> +                   |
>> +                   v
>> +   +--------------------------------------+
>> +   | handle_error_source() dispatch       |
>> +   |                                      |
>> +   |  1. cxl_rch_handle_error()           |
>> +   |     [always; filters internally.     |
>> +   |      RC_END enters the kfifo here    |
>> +   |      via pcie_walk_rcec(), NOT via   |
>> +   |      is_cxl_error() below]           |
>> +   |                                      |
>> +   |  2. if is_cxl_error():               |
>> +   |       cxl_forward_error()            |
>> +   |       [enqueue to kfifo; EP/RP/USP/  |
>> +   |        DSP only, RC_END excluded]    |
>> +   |                                      |
>> +   |  3. if cxl_pending && non-CE:        |
>> +   |       cxl_proto_err_wait_for_empty() |
>> +   |       [sync drain before recovery]   |
>> +   |                                      |
>> +   |  4. pci_aer_handle_error() [always]  |
>> +   +--------------------------------------+
>> +                   |
>> +          (kfifo -> workqueue)
>> +                   |
>> +                   v
>> +   +--------------------------------------+
>> +   | __cxl_proto_err_work_fn() consumer   |
>> +   |                                      |
>> +   |  if is_cxl_restricted(pdev):         |
>> +   |    cxl_handle_rdport_errors()        |
>> +   |    [RCH dport RAS first]             |
>> +   |                                      |
>> +   |  cxl_handle_proto_error()            |
>> +   +--------------------------------------+
>> +            |                |
>> +            v                v
>> +   +-----------------+  +--------------------+
>> +   | CE              |  | UCE                |
>> +   | cxl_handle_     |  | cxl_do_recovery()  |
>> +   |   cor_ras()     |  |  read RAS status   |
>> +   | trace + clear   |  |  trace + panic     |
>> +   +-----------------+  +--------------------+
> 
> Why so narrow. Seems like bits of this diag would be more readable if
> you use the whole 80 chars?
> 

Yes, would be more readable with wider boxes. I'll make all wider.

> 
>> +
>> +.. code-block:: text
>> +
>> +   Fatal UCE on Endpoint (VH Endpoint or RCD; link down, no AER status)
>> +                   |
>> +                   v
>> +   +--------------------------------------+
>> +   | PCIe core error recovery             |
>> +   |  pcie_do_recovery()                  |
>> +   |  -> report_error_detected()          |
>> +   |  -> cxl_pci_error_detected()         |
>> +   |     [pci_error_handlers callback in  |
>> +   |      cxl_core/ras.c; the RAS handler,|
>> +   |      NOT the AER kfifo path]         |
>> +   +--------------------------------------+
>> +                   |
>> +                   v
>> +   +--------------------------------------+
>> +   | cxl_pci_error_detected()             |
>> +   |                                      |
>> +   |  if is_cxl_restricted(pdev):         |
>> +   |    cxl_handle_rdport_errors()        |
>> +   |    [RCD-only: RCH Dport RAS first]   |
>> +   |                                      |
>> +   |  if port->dev.driver == NULL:        |
>> +   |    return DISCONNECT [port unbound]  |
>> +   |                                      |
>> +   |  cxl_handle_ras(port, NULL,          |
>> +   |                 to_ras_base(...),    |
>> +   |                 pdev->dsn)           |
>> +   |    [EP RAS read, independent of      |
>> +   |     channel state (not skipped for   |
>> +   |     io_normal); dead link            |
>> +   |     readl()==0xFFFFFFFF sets all UE  |
>> +   |     bits -> panic]                   |
>> +   |                                      |
>> +   |  if ue: panic("CXL cachemem error")  |
>> +   |                                      |
>> +   |  else switch (channel state):        |
>> +   |    io_normal      -> CAN_RECOVER     |
>> +   |    io_frozen      -> release driver, |
>> +   |                      NEED_RESET      |
>> +   |    perm_failure   -> DISCONNECT      |
>> +   +--------------------------------------+
> 
> Similar.  I have a new favourite irritation - overly narrow LLM (I guess)
> generated diagrams!
> 
> 
> 
>> +.. code-block:: text
>> +
>> +   Platform firmware CPER record (CPER_SEC_CXL_PROT_ERR)
>> +            |
>> +            v
>> +   +----------------------+
>> +   | GHES/APEI (ghes.c)   |
>> +   |  ghes_do_proc()      |
>> +   |  cxl_cper_post_      |
>> +   |    prot_err()        |
>> +   |  kfifo_put(CPER-CXL) |
>> +   |  schedule_work()     |
>> +   +----------------------+
> Ouch. Definitely wider here too to avoid splitting those function names.
> 
>> +            |
>> +            v
>> +   +----------------------+
>> +   | CPER-CXL kfifo       |
>> +   | + work_struct        |
>> +   +----------------------+
>> +            |
>> +            v
>> +   +----------------------+
>> +   | cxl_cper_prot_err_   |
>> +   |   work_fn() consumer |
>> +   | (cxl_core/ras.c)     |
>> +   |  drain kfifo ->      |
>> +   +----------------------+
>> +            |
>> +            v
>> +   +--------------------------------+
>> +   | cxl_cper_handle_prot_err()     |
>> +   |  pci_get_domain_bus_and_slot() |
>> +   |  find_cxl_port_by_dev()        |
>> +   |  cxl_find_dport_by_dev()       |
>> +   |                                |
>> +   |  if CE: trace correctable      |
>> +   |  else:  trace uncorrectable    |
>> +   |  [trace-only; no panic,        |
>> +   |   no cxl_do_recovery()]        |
>> +   +--------------------------------+
> 
>> +Severity policy
>> +===============
> 
>> +**Fatal UCE on EP/USP** - A fatal event brings the link down, so the AER
>> +core reads no AER status and is_cxl_error() cannot enqueue the event to the
>> +kfifo. Endpoints and RCDs are instead handled through the
>> +pci_error_handlers .error_detected callback (cxl_pci_error_detected()),
>> +which reads the CXL RAS registers when they are mapped and panics on any UE
>> +bit. If the RAS registers are unmapped the read is skipped without a panic,
>> +because this path has no prior confirmation that the error is CXL internal.
>> +Upstream Ports bound to portdrv fall back to standard AER recovery - a known
>> +limitation. See "Fatal UCE flow for Endpoints and RCDs" above for the full
>> +path and channel-state handling.
> 
> This 'known limitation' language kind of implies there is a solution. I'm curious,
> do you have one in mind?  I can sort of see maybe that the class of UCE that leaves
> CXL.io up is larger than that for PCIe so maybe it would be worth logic to probe
> the device and see if we can get to it's registers?  Anyhow, job for another day.
> 

Yes, we may be able to update aer_get_device_error_info() to check for upstream link 
health and if its intact then can possibly read the AER registers. I was leaving this 
for future improvement.

> 
> This looks good to me and even the diag things is just a 'make it prettier' so
> Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

Thanks

-Terry

  reply	other threads:[~2026-09-10 15:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 13:39 [PATCH v20 0/9] Enable CXL PCIe Port Protocol Error handling and logging Terry Bowman
2026-09-02 13:39 ` [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-08  0:51   ` Jonathan Cameron
2026-09-09 15:38     ` Bowman, Terry
2026-09-09 22:02       ` Jonathan Cameron
2026-09-10 14:57         ` Bowman, Terry
2026-09-02 13:39 ` [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-10 16:55     ` Bowman, Terry
2026-09-08  0:57   ` Jonathan Cameron
2026-09-02 13:39 ` [PATCH v20 3/9] cxl/ras: Handle RCH correctable and uncorrectable errors in one pass Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-08  1:06   ` Jonathan Cameron
2026-09-02 13:39 ` [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-09 14:42     ` Bowman, Terry
2026-09-09 15:21     ` Bowman, Terry
2026-09-08 17:47   ` Jonathan Cameron
2026-09-02 13:39 ` [PATCH v20 5/9] cxl: Update CXL Endpoint AER handler Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-02 13:39 ` [PATCH v20 6/9] PCI: Cache PCI DSN into pci_dev->dsn during probe Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-09 15:16   ` Lukas Wunner
2026-09-02 13:39 ` [PATCH v20 7/9] cxl: Add port and dport identifiers to CXL AER trace events Terry Bowman
2026-09-08 18:13   ` Jonathan Cameron
2026-09-02 13:39 ` [PATCH v20 8/9] PCI/CXL: Mask/Unmask CXL protocol errors Terry Bowman
2026-09-02 20:57   ` Cheatham, Benjamin
2026-09-02 13:39 ` [PATCH v20 9/9] Documentation: cxl: Document CXL protocol error handling Terry Bowman
2026-09-08 18:39   ` Jonathan Cameron
2026-09-10 15:19     ` Bowman, Terry [this message]
2026-09-09 16:03 ` [PATCH v20 0/9] Enable CXL PCIe Port Protocol Error handling and logging Lukas Wunner
2026-09-09 20:31   ` Bowman, Terry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=841e2342-273b-437d-82b0-f85bf6940001@amd.com \
    --to=terry.bowman@amd.com \
    --cc=Benjamin.Cheatham@amd.com \
    --cc=alison.schofield@intel.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=guohanjun@huawei.com \
    --cc=icheng@nvidia.com \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mchehab@kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=rafael@kernel.org \
    --cc=rrichter@amd.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tony.luck@intel.com \
    --cc=vishal.l.verma@intel.com \
    --cc=xueshuai@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox