From: Ira Weiny <ira.weiny@intel.com>
To: Dave Jiang <dave.jiang@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
Shiju Jose <shiju.jose@huawei.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
Yazen Ghannam <yazen.ghannam@amd.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ard Biesheuvel <ardb@kernel.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-cxl@vger.kernel.org, Ira Weiny <ira.weiny@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>
Subject: [PATCH v2 3/3] ras/events: Trace CXL CPER events without CXL stack
Date: Mon, 22 Apr 2024 15:25:47 -0700 [thread overview]
Message-ID: <20240422-cxl-cper3-v2-3-5cdd378fcd0b@intel.com> (raw)
In-Reply-To: <20240422-cxl-cper3-v2-0-5cdd378fcd0b@intel.com>
If CXL is solely managed by firmware (including HDM configuration and
event processing via firmware first) it is possible to run the system
without the CXL software loaded. In this case no CXL callback will be
loaded and CXL CPER errors will not be processed at all.
In this case memory device and region (HPA) information is missing but
omitting the error completely is not friendly. Some device information
is available the event.
Trace CXL CPER events if the CXL stack is not loaded. A balance was
chosen to decode only the CPER header as this configuration is likely
rare.
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes:
[djbw: remove local work task and call trace directly]
[djbw: strip down the generic trace information]
---
drivers/acpi/apei/ghes.c | 6 +++++-
include/ras/ras_event.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index cdcfdf6ebe81..20a0e622f829 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -739,8 +739,12 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
guard(spinlock_irqsave)(&cxl_cper_work_lock);
- if (!cxl_cper_work)
+ if (!cxl_cper_work) {
+ union cxl_event *evt = &rec->event;
+
+ trace_cper_cxl_event(rec, &evt->generic, event_type);
return;
+ }
wd.event_type = event_type;
memcpy(&wd.rec, rec, sizeof(wd.rec));
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index c011ea236e9b..c1fac66fb44a 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -422,6 +422,57 @@ TRACE_EVENT(memory_failure_event,
)
);
#endif /* CONFIG_MEMORY_FAILURE */
+
+#include <linux/cxl-event.h>
+#include <asm-generic/unaligned.h>
+
+TRACE_EVENT(cper_cxl_event,
+
+ TP_PROTO(struct cxl_cper_event_rec *cper_rec,
+ struct cxl_event_generic *gen_rec,
+ enum cxl_event_type event_type),
+
+ TP_ARGS(cper_rec, gen_rec, event_type),
+
+ /* packed record */
+ TP_STRUCT__entry(
+ __field(u16, segment)
+ __field(u8, bus)
+ __field(u8, device)
+ __field(u32, hdr_flags)
+ __field(u64, serial)
+ __field(u64, hdr_timestamp)
+ __field(u8, func)
+ __field(u8, hdr_length)
+ __field(u8, hdr_maint_op_class)
+ __field(u8, event_type)
+ __array(u8, data, CXL_EVENT_RECORD_DATA_LENGTH)
+ ),
+
+ TP_fast_assign(
+ __entry->event_type = event_type;
+ __entry->segment = cper_rec->hdr.device_id.segment_num;
+ __entry->bus = cper_rec->hdr.device_id.bus_num;
+ __entry->device = cper_rec->hdr.device_id.device_num;
+ __entry->func = cper_rec->hdr.device_id.func_num;
+ __entry->serial = (((u64)cper_rec->hdr.dev_serial_num.upper_dw) << 32) |
+ cper_rec->hdr.dev_serial_num.lower_dw;
+ __entry->hdr_length = gen_rec->hdr.length;
+ __entry->hdr_flags = get_unaligned_le24(gen_rec->hdr.flags);
+ __entry->hdr_timestamp = le64_to_cpu(gen_rec->hdr.timestamp);
+ __entry->hdr_maint_op_class = gen_rec->hdr.maint_op_class;
+ memcpy(__entry->data, gen_rec->data, CXL_EVENT_RECORD_DATA_LENGTH);
+ ),
+
+ TP_printk("device=%04x:%02x:%02x.%02x serial=%lld : event_type=%d time=%llu "
+ "len=%d flags=%x maint_op_class=%u : %s",
+ __entry->segment, __entry->bus, __entry->device, __entry->func,
+ __entry->serial, __entry->event_type, __entry->hdr_timestamp,
+ __entry->hdr_length, __entry->hdr_flags, __entry->hdr_maint_op_class,
+ __print_hex(__entry->data, CXL_EVENT_RECORD_DATA_LENGTH))
+
+);
+
#endif /* _TRACE_HW_EVENT_MC_H */
/* This part must be outside protection */
--
2.44.0
next prev parent reply other threads:[~2024-04-22 22:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 22:25 [PATCH v2 0/3] efi/cxl-cper: Report CXL CPER events through tracing Ira Weiny
2024-04-22 22:25 ` [PATCH v2 1/3] acpi/ghes: Process CXL Component Events Ira Weiny
2024-04-22 23:54 ` Dan Williams
2024-04-23 3:47 ` Ira Weiny
2024-04-23 4:16 ` Ira Weiny
2024-04-22 22:25 ` [PATCH v2 2/3] cxl/pci: Process CPER events Ira Weiny
2024-04-22 22:25 ` Ira Weiny [this message]
2024-04-23 0:16 ` [PATCH v2 3/3] ras/events: Trace CXL CPER events without CXL stack Dan Williams
2024-04-23 4:10 ` Ira Weiny
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=20240422-cxl-cper3-v2-3-5cdd378fcd0b@intel.com \
--to=ira.weiny@intel.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=alison.schofield@intel.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=shiju.jose@huawei.com \
--cc=tony.luck@intel.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