From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
Cc: <linux-efi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-cxl@vger.kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
"Alison Schofield" <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Yazen Ghannam <yazen.ghannam@amd.com>,
"Terry Bowman" <terry.bowman@amd.com>
Subject: Re: [PATCH v3 7/7] acpi/ghes, cxl/pci: Process CXL CPER Protocol Errors
Date: Tue, 26 Nov 2024 16:05:27 +0000 [thread overview]
Message-ID: <20241126160527.00005c2d@huawei.com> (raw)
In-Reply-To: <20241119003915.174386-8-Smita.KoralahalliChannabasappa@amd.com>
On Tue, 19 Nov 2024 00:39:15 +0000
Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> wrote:
> When PCIe AER is in FW-First, OS should process CXL Protocol errors from
> CPER records. Introduce support for handling and logging CXL Protocol
> errors.
>
> The defined trace events cxl_aer_uncorrectable_error and
> cxl_aer_correctable_error trace native CXL AER endpoint errors, while
> cxl_cper_trace_corr_prot_err and cxl_cper_trace_uncorr_prot_err
> trace native CXL AER port errors. Reuse both sets to trace FW-First
> protocol errors.
>
> Since the CXL code is required to be called from process context and
> GHES is in interrupt context, use workqueues for processing.
>
> Similar to CXL CPER event handling, use kfifo to handle errors as it
> simplifies queue processing by providing lock free fifo operations.
>
> Add the ability for the CXL sub-system to register a workqueue to
> process CXL CPER protocol errors.
>
> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
A few minor comments inline.
Thanks
Jonathan
> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> index 4ede038a7148..c992b34c290b 100644
> --- a/drivers/cxl/core/pci.c
> +++ b/drivers/cxl/core/pci.c
> @@ -650,6 +650,56 @@ void read_cdat_data(struct cxl_port *port)
> }
> EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL);
>
> +void cxl_cper_trace_corr_prot_err(struct pci_dev *pdev, bool flag,
> + struct cxl_ras_capability_regs ras_cap)
> +{
> + struct cxl_dev_state *cxlds;
> + u32 status;
> +
> + status = ras_cap.cor_status & ~ras_cap.cor_mask;
> +
> + if (!flag) {
As below. Name of flag is not very helpful when reading the code.
Perhaps we can rename?
> + trace_cxl_port_aer_correctable_error(&pdev->dev, status);
> + return;
> + }
> +
> + cxlds = pci_get_drvdata(pdev);
> + if (!cxlds)
> + return;
> +
> + trace_cxl_aer_correctable_error(cxlds->cxlmd, status);
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_cper_trace_corr_prot_err, CXL);
> +
> +void cxl_cper_trace_uncorr_prot_err(struct pci_dev *pdev, bool flag,
> + struct cxl_ras_capability_regs ras_cap)
> +{
> + struct cxl_dev_state *cxlds;
> + u32 status, fe;
> +
> + status = ras_cap.uncor_status & ~ras_cap.uncor_mask;
> +
> + if (hweight32(status) > 1)
> + fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK,
> + ras_cap.cap_control));
> + else
> + fe = status;
> +
> + if (!flag) {
Why does a bool named flag indicate it's a port error?
> + trace_cxl_port_aer_uncorrectable_error(&pdev->dev, status, fe,
> + ras_cap.header_log);
> + return;
> + }
> +
> + cxlds = pci_get_drvdata(pdev);
> + if (!cxlds)
> + return;
> +
> + trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe,
> + ras_cap.header_log);
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_cper_trace_uncorr_prot_err, CXL);
> +
> static void __cxl_handle_cor_ras(struct device *dev,
> void __iomem *ras_base)
> {
> diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h
> index 4da07727ab9c..5e4aa8681937 100644
> --- a/drivers/cxl/cxlpci.h
> +++ b/drivers/cxl/cxlpci.h
> @@ -129,4 +129,10 @@ void read_cdat_data(struct cxl_port *port);
> void cxl_cor_error_detected(struct pci_dev *pdev);
> pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
> pci_channel_state_t state);
> +
> +struct cxl_ras_capability_regs;
> +void cxl_cper_trace_corr_prot_err(struct pci_dev *pdev, bool flag,
> + struct cxl_ras_capability_regs ras_cap);
> +void cxl_cper_trace_uncorr_prot_err(struct pci_dev *pdev, bool flag,
> + struct cxl_ras_capability_regs ras_cap);
> #endif /* __CXL_PCI_H__ */
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 88a14d7baa65..e261abe60e90 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -1067,6 +1067,53 @@ static void cxl_cper_work_fn(struct work_struct *work)
> }
> static DECLARE_WORK(cxl_cper_work, cxl_cper_work_fn);
>
> +static void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
> +{
> + unsigned int devfn = PCI_DEVFN(data->prot_err.agent_addr.device,
> + data->prot_err.agent_addr.function);
> + struct pci_dev *pdev __free(pci_dev_put) =
> + pci_get_domain_bus_and_slot(
> + data->prot_err.agent_addr.segment,
> + data->prot_err.agent_addr.bus,
> + devfn
> + );
pci_get_domain_bus_and_slot(data->prot_err.agent_addr.segment,
data->prot_err.agent_addr.bus,
devfn);
> + int port_type;
> +
> + if (!pdev)
> + return;
> +
> + guard(device)(&pdev->dev);
> + if (pdev->driver != &cxl_pci_driver)
> + return;
> +
> + port_type = pci_pcie_type(pdev);
> + if (port_type == PCI_EXP_TYPE_ROOT_PORT ||
> + port_type == PCI_EXP_TYPE_DOWNSTREAM ||
> + port_type == PCI_EXP_TYPE_UPSTREAM) {
> + if (data->severity == AER_CORRECTABLE)
> + cxl_cper_trace_corr_prot_err(pdev, false, data->ras_cap);
> + else
> + cxl_cper_trace_uncorr_prot_err(pdev, false, data->ras_cap);
> +
> + return;
> + }
> +
> + if (data->severity == AER_CORRECTABLE)
> + cxl_cper_trace_corr_prot_err(pdev, true, data->ras_cap);
> + else
> + cxl_cper_trace_uncorr_prot_err(pdev, true, data->ras_cap);
> +
> +}
> static int __init cxl_pci_driver_init(void)
> {
> int rc;
> @@ -1079,13 +1126,21 @@ static int __init cxl_pci_driver_init(void)
> if (rc)
> pci_unregister_driver(&cxl_pci_driver);
>
> + rc = cxl_cper_register_prot_err_work(&cxl_cper_prot_err_work);
> + if (rc) {
> + cxl_cper_unregister_event_work(&cxl_cper_work);
> + pci_unregister_driver(&cxl_pci_driver);
I'd switch this to a goto style for error handling.
> + }
> +
> return rc;
that is
return 0;
err_unregister_event_work:
cxl_cper_unregister_event_work(&cxl_cper_work);
err_unreg:
pci_unregister_driver(&cxl_pci_driver);
return rc;
> }
next prev parent reply other threads:[~2024-11-26 16:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 0:39 [PATCH v3 0/7] acpi/ghes, cper, cxl: Process CXL CPER Protocol errors Smita Koralahalli
2024-11-19 0:39 ` [PATCH v3 1/7] efi/cper, cxl: Prefix protocol error struct and function names with cxl_ Smita Koralahalli
2024-11-26 15:05 ` Jonathan Cameron
2024-12-02 18:12 ` Ira Weiny
2024-11-19 0:39 ` [PATCH v3 2/7] efi/cper, cxl: Make definitions and structures global Smita Koralahalli
2024-11-26 15:09 ` Jonathan Cameron
2024-12-02 18:15 ` Ira Weiny
2024-11-19 0:39 ` [PATCH v3 3/7] efi/cper, cxl: Remove cper_cxl.h Smita Koralahalli
2024-11-26 15:51 ` Jonathan Cameron
2024-11-27 19:36 ` Smita Koralahalli
2024-12-02 18:15 ` Ira Weiny
2024-11-19 0:39 ` [PATCH v3 4/7] acpi/ghes, cxl: Rename cxl_cper_register_work to cxl_cper_register_event_work Smita Koralahalli
2024-11-26 15:53 ` Jonathan Cameron
2024-11-19 0:39 ` [PATCH v3 5/7] acpi/ghes, cxl: Refactor work registration functions to support multiple workqueues Smita Koralahalli
2024-11-26 15:57 ` Jonathan Cameron
2024-11-27 19:46 ` Smita Koralahalli
2024-11-19 0:39 ` [PATCH v3 6/7] acpi/ghes, cper: Recognize and cache CXL Protocol errors Smita Koralahalli
2024-11-26 16:05 ` Jonathan Cameron
2024-12-02 18:41 ` Ira Weiny
2024-12-06 16:16 ` Koralahalli Channabasappa, Smita
2024-11-19 0:39 ` [PATCH v3 7/7] acpi/ghes, cxl/pci: Process CXL CPER Protocol Errors Smita Koralahalli
2024-11-26 16:05 ` Jonathan Cameron [this message]
2024-11-27 20:35 ` Smita Koralahalli
2024-12-02 18:48 ` Ira Weiny
2024-12-06 16:29 ` Koralahalli Channabasappa, Smita
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=20241126160527.00005c2d@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=alison.schofield@intel.com \
--cc=ardb@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=yazen.ghannam@amd.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