From: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
To: Ira Weiny <ira.weiny@intel.com>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-cxl@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Yazen Ghannam <yazen.ghannam@amd.com>
Subject: Re: [PATCH 3/4] acpi/ghes, efi/cper: Recognize and process CXL Protocol Errors.
Date: Wed, 3 Jan 2024 13:12:06 -0800 [thread overview]
Message-ID: <66b7feb6-b151-ad97-0ee4-3fd7da7137eb@amd.com> (raw)
In-Reply-To: <65944ec1dccee_151dc1294f3@iweiny-mobl.notmuch>
On 1/2/2024 9:58 AM, Ira Weiny wrote:
> Smita Koralahalli wrote:
>> UEFI v2.10 section N.2.13 defines a CPER record for CXL Protocol errors.
>>
>> Add GHES support to detect CXL CPER Protocol record and cache error
>> severity, device_id, serial number and a pointer to CXL RAS capability
>> struct in struct cxl_cper_rec_data.
>>
>> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
>> ---
>> drivers/acpi/apei/ghes.c | 15 ++++++++++
>> drivers/firmware/efi/cper_cxl.c | 52 +++++++++++++++++++++++++++++++++
>> include/linux/cxl-event.h | 6 ++++
>> 3 files changed, 73 insertions(+)
>>
>> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
>> index d6a85fbc0a8b..6471584b2e79 100644
>> --- a/drivers/acpi/apei/ghes.c
>> +++ b/drivers/acpi/apei/ghes.c
>> @@ -714,6 +714,18 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
>> cper_callback(event_type, &data);
>> }
>>
>> +void cxl_cper_handle_prot_err(struct acpi_hest_generic_data *gdata)
>> +{
>> + struct cxl_cper_rec_data data;
>> +
>> + memset(&data, 0, sizeof(data));
>
> Does this need to be done? Could cxl_cper_handle_prot_err_info() use
> something like this initially?
>
> *data = (struct cxl_cper_rec_data) {
> .rec.hdr.dev_serial_num.lower_dw = prot_err->dev_serial_num.lower_dw;
> .rec.hdr.dev_serial_num.upper_dw = prot_err->dev_serial_num.upper_dw;
> };
>
> The serial number is always set even if it is not valid.
Ok will copy serial number at the beginning of
cxl_cper_handle_prot_err_info() and remove memset.
>
>> +
>> + if (cxl_cper_handle_prot_err_info(gdata, &data))
>> + return;
>> +
>> + data.severity = gdata->error_severity;
>> +}
>> +
>> int cxl_cper_register_callback(cxl_cper_callback callback)
>> {
>> guard(rwsem_write)(&cxl_cper_rw_sem);
>> @@ -768,6 +780,9 @@ static bool ghes_do_proc(struct ghes *ghes,
>> else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
>> queued = ghes_handle_arm_hw_error(gdata, sev);
>> }
>> + else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
>> + cxl_cper_handle_prot_err(gdata);
>> + }
>> else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
>> struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
>>
>> diff --git a/drivers/firmware/efi/cper_cxl.c b/drivers/firmware/efi/cper_cxl.c
>> index 4fd8d783993e..3bc0b9f28c9e 100644
>> --- a/drivers/firmware/efi/cper_cxl.c
>> +++ b/drivers/firmware/efi/cper_cxl.c
>> @@ -8,6 +8,7 @@
>> */
>>
>> #include <linux/cper.h>
>> +#include <acpi/ghes.h>
>> #include "cper_cxl.h"
>>
>> #define PROT_ERR_VALID_AGENT_TYPE BIT_ULL(0)
>> @@ -176,3 +177,54 @@ void cper_print_prot_err(const char *pfx, const struct cper_sec_prot_err *prot_e
>> sizeof(cxl_ras->header_log), 0);
>> }
>> }
>> +
>> +int cxl_cper_handle_prot_err_info(struct acpi_hest_generic_data *gdata,
>> + struct cxl_cper_rec_data *data)
>> +{
>> + struct cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
>> + struct cper_cxl_event_devid *device_id = &data->rec.hdr.device_id;
>> + struct cper_cxl_event_sn *dev_serial_num = &data->rec.hdr.dev_serial_num;
>> + size_t size = sizeof(*prot_err) + prot_err->dvsec_len;
>> +
>> + if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
>> + pr_err(FW_WARN "Not a valid protocol error log\n");
>> + return -EINVAL;
>> + }
>> +
>> + if (!(prot_err->valid_bits & PROT_ERR_VALID_DEVICE_ID)) {
>> + pr_err(FW_WARN "Not a valid Device ID\n");
>> + return -EINVAL;
>> + }
>> +
>> + /*
>> + * The device ID or agent address is only valid for CXL 1.1 device,
>> + * CXL 2.0 device, CXL 2.0 Logical device, CXL 2.0 Fabric Manager
>> + * Managed Logical Device, CXL Root Port, CXL Downstream Switch
>> + * Port, or CXL Upstream Switch Port.
>> + */
>> + if (prot_err->agent_type <= 0x7 && prot_err->agent_type != RCH_DP) {
>> + device_id->segment_num = prot_err->agent_addr.segment;
>> + device_id->bus_num = prot_err->agent_addr.bus;
>> + device_id->device_num = prot_err->agent_addr.device;
>> + device_id->func_num = prot_err->agent_addr.function;
>> + } else {
>> + pr_err(FW_WARN "Not a valid agent type\n");
>> + return -EINVAL;
>> + }
>> +
>> + /*
>> + * The device serial number is only valid for CXL 1.1 device, CXL
>> + * 2.0 device, CXL 2.0 Logical device, or CXL 2.0 Fabric Manager
>> + * Managed Logical Device.
>> + */
>> + if (!(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER) ||
>> + prot_err->agent_type > 0x4 || prot_err->agent_type == RCH_DP)
>> + pr_warn(FW_WARN "No valid serial number present\n");
>> +
>> + dev_serial_num->lower_dw = prot_err->dev_serial_num.lower_dw;
>> + dev_serial_num->upper_dw = prot_err->dev_serial_num.upper_dw;
>> +
>> + data->cxl_ras = (struct cxl_ras_capability_regs *)((long)prot_err + size);
>
> I think this is ok now because the cxl trace code processes the data
> before returning (in next patch). But I'm a bit leary about passing a
> pointer to data controlled by the acpi sub-system. At some point the
> event may get cached to be processed by another thread and it might be
> better to copy the struct here.
Ok will make the changes. Rewrote the struct in patch 1.
>
>> +
>> + return 0;
>> +}
>> diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h
>> index 90d8390a73cb..7ba2dfd6619e 100644
>> --- a/include/linux/cxl-event.h
>> +++ b/include/linux/cxl-event.h
>> @@ -154,11 +154,17 @@ struct cxl_ras_capability_regs {
>>
>> struct cxl_cper_rec_data {
>> struct cxl_cper_event_rec rec;
>> + struct cxl_ras_capability_regs *cxl_ras;
>> + int severity;
>
> NIT: When I saw this without any addition to event type I wondered if the
> series would bisect. I see it does because the record is not sent until
> the next patch. But I wonder if the 2 patches would be best reversed.
You mean to say patch 4 to be 3 and 3 to be 4?
And since I haven't used severity yet, fix it by declaring severity to
where it is used..
>
> Also, should cxl_ras + severity be put in a protocol error sub-struct?
> Does severity ever apply to event records?
No, not in any of the component event records. Only place is in "Event
Record Flags" in Common Event Record Format (Table 8-42).
Addressed in patch 1 to make a sub-struct.
Thanks,
Smita
>
> Ira
>
>> };
>>
>> typedef void (*cxl_cper_callback)(enum cxl_event_type type,
>> struct cxl_cper_rec_data *data);
>>
>> +struct acpi_hest_generic_data;
>> +int cxl_cper_handle_prot_err_info(struct acpi_hest_generic_data *gdata,
>> + struct cxl_cper_rec_data *data);
>> +
>> #ifdef CONFIG_ACPI_APEI_GHES
>> int cxl_cper_register_callback(cxl_cper_callback callback);
>> int cxl_cper_unregister_callback(cxl_cper_callback callback);
>> --
>> 2.17.1
>>
>
>
next prev parent reply other threads:[~2024-01-03 21:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-02 15:09 [PATCH 0/4] acpi/ghes, cper, cxl: Trace FW-First CXL Protocol Errors Smita Koralahalli
2024-01-02 15:09 ` [PATCH 1/4] acpi/ghes, cxl: Create a common CXL struct to handle different CXL CPER records Smita Koralahalli
2024-01-02 16:23 ` Ira Weiny
2024-01-03 20:04 ` Smita Koralahalli
2024-01-03 20:35 ` Ira Weiny
2024-01-02 15:09 ` [PATCH 2/4] efi/cper, cxl: Make definitions and structures global Smita Koralahalli
2024-01-02 16:30 ` Ira Weiny
2024-01-03 20:16 ` Smita Koralahalli
2024-01-03 22:30 ` Ira Weiny
2024-01-02 15:09 ` [PATCH 3/4] acpi/ghes, efi/cper: Recognize and process CXL Protocol Errors Smita Koralahalli
2024-01-02 17:58 ` Ira Weiny
2024-01-03 21:12 ` Smita Koralahalli [this message]
2024-01-03 22:32 ` Ira Weiny
2024-01-02 15:09 ` [PATCH 4/4] acpi/ghes, cxl/pci: Trace FW-First " Smita Koralahalli
2024-01-02 20:27 ` Ira Weiny
2024-01-03 21:13 ` Smita Koralahalli
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=66b7feb6-b151-ad97-0ee4-3fd7da7137eb@amd.com \
--to=smita.koralahallichannabasappa@amd.com \
--cc=Jonathan.Cameron@huawei.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=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