hw/cxl: add trace-events coverage
v2 cover hw/cxl: add trace-events coverage
The CXL subsystem in QEMU currently has no trace coverage. Debugging mailbox commands, HDM decoder programming, event log activity, and CFMWS address decoding relies on temporary printf or qemu_log_mask.
This series introduces trace-events infrastructure for the CXL subsystem and adds 11 trace points covering the above paths. All events use the cxl_ prefix so -trace 'cxl_*' captures everything.
Changes since v1:
- Split patch 2 into HDM-only; dropped CDAT traces -- source is commandline-controlled (Jonathan)
- Split patch 3 into separate event-log and CFMWS patches (Jonathan)
- Pass set and cmd as separate uint8_t parameters instead of a combined opcode (Jonathan)
- Cover all 21 CXL_MBOX_INVALID_PAYLOAD_LENGTH return sites, not just the centralised entry check (Jonathan)
- Rename depth -> occupancy in event log trace (Jonathan)
- Defer passthrough-specific trace pending upstream support (Jonathan)
- Add cxl_hdm_decoder_uncommit for commit/uncommit symmetry
v1: https://lore.kernel.org/qemu-devel/[email protected]/
Junjie Cao (5):
hw/cxl: introduce trace-events infrastructure hw/cxl: trace mailbox command dispatch and payload errors hw/cxl: trace HDM decoder write, commit and uncommit hw/cxl: trace event log insertion, overflow and clear hw/cxl: trace CFMWS address-to-device routing
hw/cxl/cxl-events.c | 13 +++++-- hw/cxl/cxl-host.c | 4 +++ hw/cxl/cxl-mailbox-utils.c | 71 +++++++++++++++++++++++++++++++++++-- hw/cxl/trace-events | 15 ++++++++ hw/cxl/trace.h | 2 ++ hw/mem/cxl_type3.c | 19 +++++++++- hw/mem/trace-events | 5 +++ include/hw/cxl/cxl_device.h | 1 + meson.build | 1 + 9 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 hw/cxl/trace-events create mode 100644 hw/cxl/trace.h
Signature · 1 line
2.43.0
PATCH v2 1/5 hw/cxl: introduce trace-events infrastructure
The CXL subsystem currently has no trace-events file. Create one under hw/cxl/ and register it in the top-level meson.build trace_events_subdirs list so that subsequent patches can add trace points incrementally.
--- hw/cxl/trace-events | 1 + hw/cxl/trace.h | 2 ++ meson.build | 1 + 3 files changed, 4 insertions(+) create mode 100644 hw/cxl/trace-events create mode 100644 hw/cxl/trace.h
hw/cxl/trace-events new file +1 -0
@@ -0,0 +1 @@ +# See docs/devel/tracing.rst for syntax documentation.
hw/cxl/trace.h new file +2 -0
@@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "trace/trace-hw_cxl.h"
meson.build +1 -0
@@ -3596,6 +3596,7 @@ if have_system 'hw/audio', 'hw/block', 'hw/char', + 'hw/cxl', 'hw/display', 'hw/dma', 'hw/fsi',
Signature · 1 line
2.43.0
PATCH v2 2/5 hw/cxl: trace mailbox command dispatch and payload errors
In reply to Junjie CaoAdd trace events for CXL mailbox command processing: command entry, handler completion, and all payload-length validation failures.
Three trace points are added:
cxl_mailbox_cmd - command entry with set, cmd, name, len_in
cxl_mailbox_cmd_done - handler return with ret code and len_out
cxl_mailbox_payload_error - payload length mismatch (all 21 sites)
To make set/cmd accessible inside individual command handlers (which do not receive them as parameters), add a current_opcode field to CXLCCI that is set before handler dispatch. This mirrors the existing cci->bg.opcode pattern used for background operations.
The payload_error event covers not only the centralised entry check in cxl_process_cci_message() but also every handler-internal return of CXL_MBOX_INVALID_PAYLOAD_LENGTH, including variable-length command validators in tunnelling, DCD, firmware update, set-feature, media operations, and physical-port commands.
As a minor cleanup, add a CXLCCI *cci parameter to media_operations_discovery() so it can access current_opcode. This aligns it with media_operations_sanitize() which already receives cci.
--- hw/cxl/cxl-mailbox-utils.c | 71 +++++++++++++++++++++++++++++++++++-- hw/cxl/trace-events | 5 +++ include/hw/cxl/cxl_device.h | 1 + 3 files changed, 75 insertions(+), 2 deletions(-)
hw/cxl/cxl-mailbox-utils.c +69 -2
@@ -27,6 +27,7 @@#include "system/hostmem.h" #include "qemu/range.h" #include "qapi/qapi-types-cxl.h" +#include "trace.h" #define CXL_CAPACITY_MULTIPLIER (256 * MiB)#define CXL_DC_EVENT_LOG_SIZE 8
@@ -179,14 +180,23 @@ static CXLRetCode cmd_tunnel_management_cmd(const struct cxl_cmd *cmd, out = (void *)payload_out;if (len_in <sizeof (*in)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }/* Enough room for minimum sized message - no payload */ if (in->size <sizeof (in->ccimessage)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }/* Length of input payload should be in->size + a wrapping tunnel header */ if (in->size != len_in - offsetof(typeof(*out), ccimessage)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }if (in->ccimessage.category !=CXL_CCI_CAT_REQ ) {
@@ -299,6 +309,9 @@ static CXLRetCode cmd_events_clear_records(const struct cxl_cmd *cmd,if (len_in <sizeof (*pl) || len_in <sizeof (*pl) +sizeof (*pl->handle) * pl->nr_recs) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -361,6 +374,9 @@ static CXLRetCode cmd_events_set_interrupt_policy(const struct cxl_cmd *cmd,CXLEventLog *log;if (len_in <CXL_EVENT_INT_SETTING_MIN_LEN ) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -604,6 +620,9 @@ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, out = (struct cxl_fmapi_get_phys_port_state_resp_pl *)payload_out;if (len_in <sizeof (*in)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }/* Check if what was requested can fit */
@@ -782,6 +801,9 @@ static CXLRetCode cmd_physical_port_control(const struct cxl_cmd *cmd, }QEMU_PACKED *in = (void *)payload_in;if (len_in <sizeof (*in)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -961,6 +983,9 @@ static CXLRetCode cmd_firmware_update_transfer(const struct cxl_cmd *cmd,size_t offset, length;if (len <sizeof (*fw_transfer)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -1718,6 +1743,9 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd,uint16_t count;if (len_in <sizeof (*hdr)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -1748,6 +1776,9 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, bytes_to_copy = len_in -sizeof (CXLSetFeatureInHeader);if (bytes_to_copy ==0 ) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -1762,6 +1793,9 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd,if ((uint32_t )hdr->offset + bytes_to_copy >sizeof (ct3d->patrol_scrub_wr_attrs)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; } memcpy((uint8_t *)&ct3d->patrol_scrub_wr_attrs + hdr->offset,
@@ -1789,6 +1823,9 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd,if ((uint32_t )hdr->offset + bytes_to_copy >sizeof (ct3d->ecs_wr_attrs)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; } memcpy((uint8_t *)&ct3d->ecs_wr_attrs + hdr->offset,
@@ -2294,6 +2331,9 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, *len_out =0 ;if (len_in < hdr_len) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -2661,7 +2701,8 @@ static const struct media_op_supported_list_entry media_op_matrix[] = {static CXLRetCode media_operations_discovery (uint8_t *payload_in,size_t len_in,uint8_t *payload_out, -size_t *len_out) +size_t *len_out, +CXLCCI *cci) {struct {uint8_t media_operation_class;
@@ -2680,6 +2721,9 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,int count =0 ;if (len_in <sizeof (*media_op_in_disc_pl)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , +"MEDIA_OPERATIONS" , len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -2741,6 +2785,9 @@ static CXLRetCode media_operations_sanitize(CXLType3Dev *ct3d, dpa_range_list_size = dpa_range_count *sizeof (struct dpa_range_list_entry );if (len_in < (sizeof (*media_op_in_sanitize_pl) + dpa_range_list_size)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , +"MEDIA_OPERATIONS" , len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -2792,6 +2839,9 @@ static CXLRetCode cmd_media_operations(const struct cxl_cmd *cmd,uint8_t media_op_subclass =0 ;if (len_in <sizeof (*media_op_in_common_pl)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -2805,7 +2855,7 @@ static CXLRetCode cmd_media_operations(const struct cxl_cmd *cmd, }return media_operations_discovery (payload_in, len_in, payload_out, - len_out); + len_out, cci);case MEDIA_OP_CLASS_SANITIZE :switch (media_op_subclass) {case MEDIA_OP_SAN_SUBC_SANITIZE :
@@ -3712,6 +3762,9 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd,CXLRetCode ret;if (len_in <sizeof (*in)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -3723,6 +3776,9 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd,if (len_in <sizeof (*in) +sizeof (*in->updated_entries) * in->num_entries_updated) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -3883,6 +3939,9 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd,CXLRetCode ret;if (len_in <sizeof (*in)) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -3892,6 +3951,9 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd,if (len_in <sizeof (*in) +sizeof (*in->updated_entries) * in->num_entries_updated) { +trace_cxl_mailbox_payload_error (cci->current_opcode >>8 , + cci->current_opcode &0xff , + cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -4588,7 +4650,11 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd,return CXL_MBOX_UNSUPPORTED ; } + cci->current_opcode = (set <<8 ) | cmd; +trace_cxl_mailbox_cmd (set, cmd, cxl_cmd->name, len_in); +if (len_in != cxl_cmd->in && cxl_cmd->in != ~0 ) { +trace_cxl_mailbox_payload_error (set, cmd, cxl_cmd->name, len_in);return CXL_MBOX_INVALID_PAYLOAD_LENGTH ; }
@@ -4620,6 +4686,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, } ret = (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); +trace_cxl_mailbox_cmd_done (set, cmd, ret, *len_out);if ((cxl_cmd->effect &CXL_MBOX_BACKGROUND_OPERATION ) && ret ==CXL_MBOX_BG_STARTED ) { *bg_started = true;
hw/cxl/trace-events +5 -0
@@ -1 +1,6 @@ # See docs/devel/tracing.rst for syntax documentation. + +# cxl-mailbox-utils.c +cxl_mailbox_cmd(uint8_t set, uint8_t cmd, const char *name, size_t len_in) "set=0x%02x cmd=0x%02x [%s] len_in=%zu" +cxl_mailbox_cmd_done(uint8_t set, uint8_t cmd, int ret, size_t len_out) "set=0x%02x cmd=0x%02x ret=%d len_out=%zu" +cxl_mailbox_payload_error(uint8_t set, uint8_t cmd, const char *name, size_t len_in) "set=0x%02x cmd=0x%02x [%s] len_in=%zu"
include/hw/cxl/cxl_device.h +1 -0
@@ -207,6 +207,7 @@ typedef struct CXLCCI {time_t last_partxfer; } fw; +uint16_t current_opcode;size_t payload_max;/* Pointer to device hosting the CCI */ DeviceState *d;
Signature · 1 line
2.43.0
PATCH v2 3/5 hw/cxl: trace HDM decoder write, commit and uncommit
In reply to Junjie CaoAdd trace events for HDM decoder programming in the CXL Type-3 device model. These paths control address-decode behaviour and are among the most frequently debugged during CXL topology bring-up.
Three trace points are added:
cxl_hdm_decoder_write - guest write to a decoder CTRL register,
with the raw value and commit flag
cxl_hdm_decoder_commit - actual commit with decoded base, size,
interleave ways (IW) and granularity (IG)
cxl_hdm_decoder_uncommit - decoder uncommit with index
Base and size are extracted using the same split-register pattern (ldl_le_p + 0xf0000000 mask) used by cxl_hdm_find_target() in cxl-host.c, producing architecturally-meaningful addresses. IW and IG are extracted from CTRL via FIELD_EX32.
--- hw/mem/cxl_type3.c | 19 ++++++++++++++++++- hw/mem/trace-events | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-)
hw/mem/cxl_type3.c +18 -1
@@ -30,6 +30,7 @@#include "system/numa.h" #include "hw/cxl/cxl.h" #include "hw/pci/msix.h" +#include "trace.h" /* type3 device private */ enum CXL_T3_MSIX_VECTOR {
@@ -419,13 +420,24 @@ static void hdm_decoder_commit(CXLType3Dev *ct3d, int which)int hdm_inc =R_CXL_HDM_DECODER1_BASE_LO -R_CXL_HDM_DECODER0_BASE_LO ;ComponentRegisters *cregs = &ct3d->cxl_cstate.crb;uint32_t *cache_mem = cregs->cache_mem_registers; -uint32_t ctrl; +uint32_t ctrl, low, high; +uint64_t base, size; ctrl =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_CTRL + which * hdm_inc);/* TODO: Sanity checks that the decoder is possible */ ctrl =FIELD_DP32 (ctrl,CXL_HDM_DECODER0_CTRL ,ERR ,0 ); ctrl =FIELD_DP32 (ctrl,CXL_HDM_DECODER0_CTRL ,COMMITTED ,1 ); + low =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_BASE_LO + which * hdm_inc); + high =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_BASE_HI + which * hdm_inc); + base = (low &0xf0000000 ) | ((uint64_t )high <<32 ); + low =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_SIZE_LO + which * hdm_inc); + high =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_SIZE_HI + which * hdm_inc); + size = (low &0xf0000000 ) | ((uint64_t )high <<32 ); +trace_cxl_hdm_decoder_commit (which, base, size, +FIELD_EX32 (ctrl,CXL_HDM_DECODER0_CTRL ,IW ), +FIELD_EX32 (ctrl,CXL_HDM_DECODER0_CTRL ,IG )); +stl_le_p (cache_mem +R_CXL_HDM_DECODER0_CTRL + which * hdm_inc, ctrl); }
@@ -436,6 +448,8 @@ static void hdm_decoder_uncommit(CXLType3Dev *ct3d, int which)uint32_t *cache_mem = cregs->cache_mem_registers;uint32_t ctrl; +trace_cxl_hdm_decoder_uncommit (which); + ctrl =ldl_le_p (cache_mem +R_CXL_HDM_DECODER0_CTRL + which * hdm_inc); ctrl =FIELD_DP32 (ctrl,CXL_HDM_DECODER0_CTRL ,ERR ,0 );
@@ -623,6 +637,9 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value, }stl_le_p ((uint8_t *)cache_mem + offset, value); +if (which_hdm >=0 ) { +trace_cxl_hdm_decoder_write (which_hdm, value, should_commit); + }if (should_commit) {hdm_decoder_commit (ct3d, which_hdm); }else if (should_uncommit) {
hw/mem/trace-events +5 -0
@@ -6,3 +6,8 @@ mhp_pc_dimm_assigned_slot(int slot) "%d" memory_device_pre_plug(const char *id, uint64_t addr) "id=%s addr=0x%"PRIx64 memory_device_plug(const char *id, uint64_t addr) "id=%s addr=0x%"PRIx64 memory_device_unplug(const char *id, uint64_t addr) "id=%s addr=0x%"PRIx64 + +# cxl_type3.c +cxl_hdm_decoder_write(int which, uint32_t value, bool commit) "decoder=%d ctrl=0x%08x commit=%d" +cxl_hdm_decoder_commit(int which, uint64_t base, uint64_t size, int iw, int ig) "decoder=%d base=0x%"PRIx64" size=0x%"PRIx64" iw=%d ig=%d" +cxl_hdm_decoder_uncommit(int which) "decoder=%d"
Signature · 1 line
2.43.0
PATCH v2 4/5 hw/cxl: trace event log insertion, overflow and clear
In reply to Junjie CaoAdd trace events for CXL event log activity. Event insertion, overflow, and clearing are exercised on every error injection or dynamic capacity event, but the interaction with the per-log overflow counter was previously opaque.
Three trace points are added:
cxl_event_insert - successful enqueue, with log type and resulting
occupancy (queue depth after insert)
cxl_event_overflow - overflow threshold hit, event dropped, with
cumulative overflow count
cxl_event_clear - bulk clear with log type and number of records
removed
As a minor optimisation, cache the result of cxl_event_count() in a local variable so the O(n) queue walk is performed once per insert rather than twice.
--- hw/cxl/cxl-events.c | 13 +++++++++++-- hw/cxl/trace-events | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-)
hw/cxl/cxl-events.c +11 -2
@@ -13,6 +13,7 @@#include "hw/pci/msix.h" #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" +#include "trace.h" /* Artificial limit on the number of events a log can hold */ #define CXL_TEST_EVENT_OVERFLOW 8
@@ -98,6 +99,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLogType log_type,uint64_t time;CXLEventLog *log;CXLEvent *entry; +int occupancy;if (log_type >=CXL_EVENT_TYPE_MAX ) {return false;
@@ -109,12 +111,15 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLogType log_type,QEMU_LOCK_GUARD (&log->lock); -if (cxl_event_count (log) >=CXL_TEST_EVENT_OVERFLOW ) { + occupancy =cxl_event_count (log); + +if (occupancy >=CXL_TEST_EVENT_OVERFLOW ) {if (log->overflow_err_count ==0 ) { log->first_overflow_timestamp = time; } log->overflow_err_count++; log->last_overflow_timestamp = time; +trace_cxl_event_overflow (log_type, log->overflow_err_count);return false; }
@@ -133,8 +138,10 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLogType log_type,QSIMPLEQ_INSERT_TAIL (&log->events, entry, node);cxl_event_set_status (cxlds, log_type, true); +trace_cxl_event_insert (log_type, occupancy +1 ); +/* Count went from 0 to 1 */ -return cxl_event_count (log) ==1 ; +return occupancy ==0 ; }void cxl_discard_all_event_records (CXLDeviceState *cxlds)
@@ -234,6 +241,8 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, entry =cxl_event_get_head (log); } +trace_cxl_event_clear (log_type, nr); +return CXL_MBOX_SUCCESS ; }
hw/cxl/trace-events +5 -0
@@ -4,3 +4,8 @@ cxl_mailbox_cmd(uint8_t set, uint8_t cmd, const char *name, size_t len_in) "set=0x%02x cmd=0x%02x [%s] len_in=%zu" cxl_mailbox_cmd_done(uint8_t set, uint8_t cmd, int ret, size_t len_out) "set=0x%02x cmd=0x%02x ret=%d len_out=%zu" cxl_mailbox_payload_error(uint8_t set, uint8_t cmd, const char *name, size_t len_in) "set=0x%02x cmd=0x%02x [%s] len_in=%zu" + +# cxl-events.c +cxl_event_insert(int log_type, int occupancy) "log_type=%d occupancy=%d" +cxl_event_overflow(int log_type, uint16_t overflow_count) "log_type=%d overflow_count=%u" +cxl_event_clear(int log_type, int nr_recs) "log_type=%d nr_recs=%d"
Signature · 1 line
2.43.0
PATCH v2 5/5 hw/cxl: trace CFMWS address-to-device routing
In reply to Junjie CaoAdd trace events for the CXL Fixed Memory Window address routing path. This translates a host physical address through interleave granularity calculation and up to two levels of HDM decoder lookups (host-bridge and optional switch USP).
Two trace points are added:
cxl_cfmws_lookup - entry to CFMWS decode with the computed
root-bus interleave index
cxl_cfmws_target_resolved - HDM decoder produced a port target (fires
for both host-bridge and switch USP lookups)
In non-passthrough topologies, a cxl_cfmws_lookup without a following cxl_cfmws_target_resolved indicates the host-bridge HDM decode failed. Passthrough-mode routing goes through pcie_find_port_first() without HDM decoding, so no target_resolved event is expected in that case. A dedicated passthrough-mode trace event is deferred pending upstream passthrough topology support.
--- hw/cxl/cxl-host.c | 4 ++++ hw/cxl/trace-events | 4 ++++ 2 files changed, 8 insertions(+)
hw/cxl/cxl-host.c +4 -0
@@ -21,6 +21,7 @@#include "hw/pci/pci_host.h" #include "hw/pci/pcie_port.h" #include "hw/pci-bridge/pci_expander_bridge.h" +#include "trace.h" static void cxl_fixed_memory_window_config (CXLFixedMemoryWindowOptions *object,int index,Error **errp)
@@ -169,6 +170,7 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)PCIDevice *rp, *d; rb_index = (addr /cxl_decode_ig (fw->enc_int_gran)) % fw->num_targets; +trace_cxl_cfmws_lookup (addr, rb_index); hb =PCI_HOST_BRIDGE (fw->target_hbs[rb_index]->cxl_host_bridge);if (!hb || !hb->bus || !pci_bus_is_cxl (hb->bus)) {return NULL ;
@@ -191,6 +193,7 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)if (!target_found) {return NULL ; } +trace_cxl_cfmws_target_resolved (addr, target); rp =pcie_find_port_by_pn (hb->bus, target);if (!rp) {
@@ -227,6 +230,7 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)if (!target_found) {return NULL ; } +trace_cxl_cfmws_target_resolved (addr, target); d =pcie_find_port_by_pn (&PCI_BRIDGE (d)->sec_bus, target);if (!d) {
hw/cxl/trace-events +4 -0
@@ -9,3 +9,7 @@ cxl_mailbox_payload_error(uint8_t set, uint8_t cmd, const char *name, size_t len cxl_event_insert(int log_type, int occupancy) "log_type=%d occupancy=%d" cxl_event_overflow(int log_type, uint16_t overflow_count) "log_type=%d overflow_count=%u" cxl_event_clear(int log_type, int nr_recs) "log_type=%d nr_recs=%d" + +# cxl-host.c +cxl_cfmws_lookup(uint64_t addr, int rb_index) "addr=0x%"PRIx64" rb_index=%d" +cxl_cfmws_target_resolved(uint64_t addr, uint8_t target) "addr=0x%"PRIx64" target=0x%02x"
Signature · 1 line
2.43.0