Skip to content

Commit 2d6c1e6

Browse files
weiny2djbw
authored andcommitted
cxl/mem: Trace DRAM Event Record
CXL rev 3.0 section 8.2.9.2.1.2 defines the DRAM Event Record. Determine if the event read is a DRAM event record and if so trace the record. Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Davidlohr Bueso <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Ira Weiny <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent d54a531 commit 2d6c1e6

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

drivers/cxl/core/mbox.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,14 @@ static const uuid_t gen_media_event_uuid =
726726
UUID_INIT(0xfbcd0a77, 0xc260, 0x417f,
727727
0x85, 0xa9, 0x08, 0x8b, 0x16, 0x21, 0xeb, 0xa6);
728728

729+
/*
730+
* DRAM Event Record
731+
* CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44
732+
*/
733+
static const uuid_t dram_event_uuid =
734+
UUID_INIT(0x601dcbb3, 0x9c06, 0x4eab,
735+
0xb8, 0xaf, 0x4e, 0x9b, 0xfb, 0x5c, 0x96, 0x24);
736+
729737
static void cxl_event_trace_record(const struct device *dev,
730738
enum cxl_event_log_type type,
731739
struct cxl_event_record_raw *record)
@@ -737,6 +745,10 @@ static void cxl_event_trace_record(const struct device *dev,
737745
(struct cxl_event_gen_media *)record;
738746

739747
trace_cxl_general_media(dev, type, rec);
748+
} else if (uuid_equal(id, &dram_event_uuid)) {
749+
struct cxl_event_dram *rec = (struct cxl_event_dram *)record;
750+
751+
trace_cxl_dram(dev, type, rec);
740752
} else {
741753
/* For unknown record types print just the header */
742754
trace_cxl_generic_event(dev, type, record);

drivers/cxl/core/trace.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,98 @@ TRACE_EVENT(cxl_general_media,
346346
)
347347
);
348348

349+
/*
350+
* DRAM Event Record - DER
351+
*
352+
* CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44
353+
*/
354+
/*
355+
* DRAM Event Record defines many fields the same as the General Media Event
356+
* Record. Reuse those definitions as appropriate.
357+
*/
358+
#define CXL_DER_VALID_CHANNEL BIT(0)
359+
#define CXL_DER_VALID_RANK BIT(1)
360+
#define CXL_DER_VALID_NIBBLE BIT(2)
361+
#define CXL_DER_VALID_BANK_GROUP BIT(3)
362+
#define CXL_DER_VALID_BANK BIT(4)
363+
#define CXL_DER_VALID_ROW BIT(5)
364+
#define CXL_DER_VALID_COLUMN BIT(6)
365+
#define CXL_DER_VALID_CORRECTION_MASK BIT(7)
366+
#define show_dram_valid_flags(flags) __print_flags(flags, "|", \
367+
{ CXL_DER_VALID_CHANNEL, "CHANNEL" }, \
368+
{ CXL_DER_VALID_RANK, "RANK" }, \
369+
{ CXL_DER_VALID_NIBBLE, "NIBBLE" }, \
370+
{ CXL_DER_VALID_BANK_GROUP, "BANK GROUP" }, \
371+
{ CXL_DER_VALID_BANK, "BANK" }, \
372+
{ CXL_DER_VALID_ROW, "ROW" }, \
373+
{ CXL_DER_VALID_COLUMN, "COLUMN" }, \
374+
{ CXL_DER_VALID_CORRECTION_MASK, "CORRECTION MASK" } \
375+
)
376+
377+
TRACE_EVENT(cxl_dram,
378+
379+
TP_PROTO(const struct device *dev, enum cxl_event_log_type log,
380+
struct cxl_event_dram *rec),
381+
382+
TP_ARGS(dev, log, rec),
383+
384+
TP_STRUCT__entry(
385+
CXL_EVT_TP_entry
386+
/* DRAM */
387+
__field(u64, dpa)
388+
__field(u8, descriptor)
389+
__field(u8, type)
390+
__field(u8, transaction_type)
391+
__field(u8, channel)
392+
__field(u16, validity_flags)
393+
__field(u16, column) /* Out of order to pack trace record */
394+
__field(u32, nibble_mask)
395+
__field(u32, row)
396+
__array(u8, cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE)
397+
__field(u8, rank) /* Out of order to pack trace record */
398+
__field(u8, bank_group) /* Out of order to pack trace record */
399+
__field(u8, bank) /* Out of order to pack trace record */
400+
__field(u8, dpa_flags) /* Out of order to pack trace record */
401+
),
402+
403+
TP_fast_assign(
404+
CXL_EVT_TP_fast_assign(dev, log, rec->hdr);
405+
406+
/* DRAM */
407+
__entry->dpa = le64_to_cpu(rec->phys_addr);
408+
__entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK;
409+
__entry->dpa &= CXL_DPA_MASK;
410+
__entry->descriptor = rec->descriptor;
411+
__entry->type = rec->type;
412+
__entry->transaction_type = rec->transaction_type;
413+
__entry->validity_flags = get_unaligned_le16(rec->validity_flags);
414+
__entry->channel = rec->channel;
415+
__entry->rank = rec->rank;
416+
__entry->nibble_mask = get_unaligned_le24(rec->nibble_mask);
417+
__entry->bank_group = rec->bank_group;
418+
__entry->bank = rec->bank;
419+
__entry->row = get_unaligned_le24(rec->row);
420+
__entry->column = get_unaligned_le16(rec->column);
421+
memcpy(__entry->cor_mask, &rec->correction_mask,
422+
CXL_EVENT_DER_CORRECTION_MASK_SIZE);
423+
),
424+
425+
CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' descriptor='%s' type='%s' " \
426+
"transaction_type='%s' channel=%u rank=%u nibble_mask=%x " \
427+
"bank_group=%u bank=%u row=%u column=%u cor_mask=%s " \
428+
"validity_flags='%s'",
429+
__entry->dpa, show_dpa_flags(__entry->dpa_flags),
430+
show_event_desc_flags(__entry->descriptor),
431+
show_mem_event_type(__entry->type),
432+
show_trans_type(__entry->transaction_type),
433+
__entry->channel, __entry->rank, __entry->nibble_mask,
434+
__entry->bank_group, __entry->bank,
435+
__entry->row, __entry->column,
436+
__print_hex(__entry->cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE),
437+
show_dram_valid_flags(__entry->validity_flags)
438+
)
439+
);
440+
349441
#endif /* _CXL_EVENTS_H */
350442

351443
#define TRACE_INCLUDE_FILE trace

drivers/cxl/cxlmem.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,29 @@ struct cxl_event_gen_media {
463463
u8 reserved[46];
464464
} __packed;
465465

466+
/*
467+
* DRAM Event Record - DER
468+
* CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
469+
*/
470+
#define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20
471+
struct cxl_event_dram {
472+
struct cxl_event_record_hdr hdr;
473+
__le64 phys_addr;
474+
u8 descriptor;
475+
u8 type;
476+
u8 transaction_type;
477+
u8 validity_flags[2];
478+
u8 channel;
479+
u8 rank;
480+
u8 nibble_mask[3];
481+
u8 bank_group;
482+
u8 bank;
483+
u8 row[3];
484+
u8 column[2];
485+
u8 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE];
486+
u8 reserved[0x17];
487+
} __packed;
488+
466489
struct cxl_mbox_get_partition_info {
467490
__le64 active_volatile_cap;
468491
__le64 active_persistent_cap;

0 commit comments

Comments
 (0)