drm/xe/guc: Add GuC based register capture for error capture
Subsystems (2)
PATCH v2 1/1 drm/xe/guc: Add GuC based register capture for error capture
Port GuC based register capture for error capture from i915 to Xe.
There are 3 parts in this commit:
. Prepare for capture registers
There is a bo create at guc ads init time, that is very early and engine map is not ready, make it hard to calculate the capture buffer size, new function created for worst case size caluation. Other than that, this part basically follows the i915 design.
. Process capture notification message
Basically follows i915 design
. Sysfs command process.
Xe switched to devcoredump, adopted command line process with captured list.
Zhanjun Dong (9):
drm/xe/guc: Add register defines for GuC based register capture drm/xe/guc: Expose dss per group for GuC error capture drm/xe/guc: Update GuC ADS size for error capture drm/xe/guc: Add XE_LP steered register lists drm/xe/guc: Add capture size check in GuC log buffer drm/xe/guc: Check sizing of guc_capture output drm/xe/guc: Extract GuC error capture lists on G2H notification drm/xe/guc: Pre-allocate output nodes for extraction drm/xe/guc: Plumb GuC-capture into dev coredump
drivers/gpu/drm/xe/Kconfig | 11 + drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/abi/guc_actions_abi.h | 7 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 + drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 + drivers/gpu/drm/xe/xe_gt_mcr.c | 4 +- drivers/gpu/drm/xe/xe_gt_mcr.h | 1 + drivers/gpu/drm/xe/xe_gt_printk.h | 3 + drivers/gpu/drm/xe/xe_gt_topology.c | 3 - drivers/gpu/drm/xe/xe_guc.c | 7 + drivers/gpu/drm/xe/xe_guc_ads.c | 255 +++- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 1404 ++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 35 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 225 ++++ drivers/gpu/drm/xe/xe_guc_ct.c | 2 + drivers/gpu/drm/xe/xe_guc_fwif.h | 68 ++ drivers/gpu/drm/xe/xe_guc_log.c | 179 +++ drivers/gpu/drm/xe/xe_guc_log.h | 15 + drivers/gpu/drm/xe/xe_guc_log_types.h | 26 + drivers/gpu/drm/xe/xe_guc_submit.c | 22 +- drivers/gpu/drm/xe/xe_guc_submit.h | 3 + drivers/gpu/drm/xe/xe_guc_types.h | 2 + drivers/gpu/drm/xe/xe_hw_engine.c | 73 +- drivers/gpu/drm/xe/xe_hw_engine_types.h | 106 +- 25 files changed, 2355 insertions(+), 131 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.c create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.h create mode 100644 drivers/gpu/drm/xe/xe_guc_capture_fwif.h
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Update GuC ADS size for error capture
Update GuC ADS size allocation to include space for the lists of error state capture register descriptors.
Then, populate GuC ADS with the lists of registers we want GuC to report back to host on engine reset events. This list should include global, engine-class and engine-instance registers for every engine-class type on the current hardware.
Ensure we allocate a persistent store for the register lists that are populated into ADS so that we don't need to allocate memory during GT resets when GuC is reloaded and ADS population happens again.
--- drivers/gpu/drm/xe/xe_guc_ads.c | 255 +++++++++++++++++++--- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 265 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 6 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 225 +++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_fwif.h | 20 ++ drivers/gpu/drm/xe/xe_guc_types.h | 2 + 7 files changed, 739 insertions(+), 36 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture_fwif.h
drivers/gpu/drm/xe/xe_guc_ads.c +219 -36
@@ -14,6 +14,8 @@#include "xe_gt.h" #include "xe_gt_ccs_mode.h" #include "xe_guc.h" +#include "xe_guc_capture.h" +#include "xe_guc_capture_fwif.h" #include "xe_hw_engine.h" #include "xe_lrc.h" #include "xe_map.h"
@@ -133,8 +135,7 @@ static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)static size_t guc_ads_capture_size (struct xe_guc_ads *ads) { -/* FIXME: Allocate a proper capture list */ -return PAGE_ALIGN (PAGE_SIZE ); +return PAGE_ALIGN (ads->capture_size); }static size_t guc_ads_um_queues_size (struct xe_guc_ads *ads)
@@ -260,6 +261,34 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)return total_size; } +static size_t calculate_capture_worst_size (struct xe_guc_ads *ads) +{ +struct xe_guc *guc =ads_to_guc (ads); +size_t total_size, class_size, instance_size, global_size; +int i, j; + +/* Early calcuate the capture size, to reserve capture size before guc init finished, +* as engine mask is not ready, the calculate here is the worst case size +*/ + total_size =PAGE_SIZE ;/* Pad a page in front for empty lists */ +for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { + class_size =0 ; + instance_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &class_size); +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &instance_size); + total_size += class_size + instance_size; + } + global_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &global_size); + total_size +=PAGE_ALIGN (global_size); + } + +return total_size; +} +#define MAX_GOLDEN_LRC_SIZE (SZ_4K * 64)int xe_guc_ads_init (struct xe_guc_ads *ads)
@@ -270,6 +299,7 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)struct xe_bo *bo; ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =calculate_capture_worst_size (ads); ads->regset_size =calculate_regset_size (gt); bo = xe_managed_bo_create_pin_map(xe, tile, guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE,
@@ -283,33 +313,6 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)return 0 ; } -/** -* xe_guc_ads_init_post_hwconfig - initialize ADS post hwconfig load -* @ads: Additional data structures object -* -* Recalcuate golden_lrc_size & regset_size as the number hardware engines may -* have changed after the hwconfig was loaded. Also verify the new sizes fit in -* the already allocated ADS buffer object. -* -* Return: 0 on success, negative error code on error. -*/ -int xe_guc_ads_init_post_hwconfig (struct xe_guc_ads *ads) -{ -struct xe_gt *gt =ads_to_gt (ads); -u32 prev_regset_size = ads->regset_size; - -xe_gt_assert (gt, ads->bo); - - ads->golden_lrc_size =calculate_golden_lrc_size (ads); - ads->regset_size =calculate_regset_size (gt); - -xe_gt_assert (gt, ads->golden_lrc_size + - (ads->regset_size - prev_regset_size) <= -MAX_GOLDEN_LRC_SIZE ); - -return 0 ; -} -static void guc_policies_init (struct xe_guc_ads *ads) { ads_blob_write(ads, policies.dpc_promote_time,
@@ -393,20 +396,171 @@ static void guc_mapping_table_init(struct xe_gt *gt, } } -static void guc_capture_list_init (struct xe_guc_ads *ads) +static u32 guc_get_capture_engine_mask (struct xe_gt *gt,struct iosys_map *info_map, +u32 capture_class) +{ +struct xe_device *xe =gt_to_xe (gt); +u32 mask; + +switch (capture_class) { +case GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_RENDER_CLASS ]); + mask |=info_map_read (xe, info_map, engine_enabled_masks[GUC_COMPUTE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEO : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEO_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEOENHANCE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_BLITTER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_BLITTER_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_GSC_OTHER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_GSC_OTHER_CLASS ]); +break ; + +default : + mask =0 ; + } + +return mask; +} + +static int guc_capture_prep_lists (struct xe_guc_ads *ads) { +struct xe_guc *guc =ads_to_guc (ads); +struct xe_gt *gt =ads_to_gt (ads); +u32 ads_ggtt, capture_offset, null_ggtt, total_size =0 ; +struct iosys_map info_map; +bool ads_is_mapped; +size_t size =0 ; +void *ptr;int i, j; -u32 addr =xe_bo_ggtt_addr (ads->bo) +guc_ads_capture_offset (ads); -/* FIXME: Populate a proper capture list */ + ads_is_mapped = ads->capture_size !=0 ; +if (ads_is_mapped) { + capture_offset =guc_ads_capture_offset (ads); + ads_ggtt =xe_bo_ggtt_addr (ads->bo); + info_map =IOSYS_MAP_INIT_OFFSET (ads_to_map (ads), + offsetof(struct __guc_ads_blob , system_info)); + }else { +/* Bail with worst case size calculations */ + total_size =calculate_capture_worst_size (ads); +return total_size; + } + +/* first, set aside the first page for a capture_list with zero descriptors */ + total_size =PAGE_SIZE ; +if (!xe_guc_capture_getnullheader (guc, &ptr, &size)) +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, size); + + null_ggtt = ads_ggtt + capture_offset; + capture_offset +=PAGE_SIZE ; + +/* Populate capture list : at this point adps is already allocated and mapped to worst case +* size +*/ for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +bool write_empty_list;for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { -ads_blob_write (ads, ads.capture_instance[i][j], addr); -ads_blob_write (ads, ads.capture_class[i][j], addr); +u32 engine_mask =guc_get_capture_engine_mask (gt, &info_map, j); +/* null list if we dont have said engine or list */ +if (!engine_mask) { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); +continue ; + } +/********************************************************/ +/*** engine exists: start with engine-class registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_class[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); + } + +/********************************************************/ +/*** engine exists: next, engine-instance registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } + +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_instance[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); + } } -ads_blob_write (ads, ads.capture_global[i], addr); +/********************************************************/ +/*** global registers is last in our PF/VF loops ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , + &ptr)) + write_empty_list = false;/* everything checked out, populate! */ + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_global[i], ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, + size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_global[i], null_ggtt); + } } + +if (ads->capture_size !=PAGE_ALIGN (total_size)) +xe_gt_info (gt,"ADS capture alloc size changed from %d to %d\n" , + ads->capture_size,PAGE_ALIGN (total_size)); +return PAGE_ALIGN (total_size); } static void guc_mmio_regset_write_one(struct xe_guc_ads *ads,
@@ -549,6 +703,35 @@ static void guc_doorbell_init(struct xe_guc_ads *ads) } } +/** +* xe_guc_ads_init_post_hwconfig - initialize ADS post hwconfig load +* @ads: Additional data structures object +* +* Recalcuate golden_lrc_size & regset_size as the number hardware engines may +* have changed after the hwconfig was loaded. Also verify the new sizes fit in +* the already allocated ADS buffer object. +* +* Return: 0 on success, negative error code on error. +*/ +int xe_guc_ads_init_post_hwconfig (struct xe_guc_ads *ads) +{ +struct xe_gt *gt =ads_to_gt (ads); +u32 prev_regset_size = ads->regset_size; + +xe_gt_assert (gt, ads->bo); + + ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =0 ;/* Clear capture_size before run guc_capture_prep_lists */ + ads->capture_size =guc_capture_prep_lists (ads); + ads->regset_size =calculate_regset_size (gt); + +xe_gt_assert (gt, ads->golden_lrc_size + ads->capture_size + + (ads->regset_size - prev_regset_size) <= +MAX_GOLDEN_LRC_SIZE ); + +return 0 ; +} +/** * xe_guc_ads_populate_minimal - populate minimal ADS * @ads: Additional data structures object
@@ -595,7 +778,7 @@ void xe_guc_ads_populate(struct xe_guc_ads *ads)guc_mmio_reg_state_init (ads);guc_prep_golden_lrc_null (ads);guc_mapping_table_init (gt, &info_map); -guc_capture_list_init (ads); +guc_capture_prep_lists (ads);guc_doorbell_init (ads);if (xe->info.has_usm) {
drivers/gpu/drm/xe/xe_guc_ads_types.h +2 -0
@@ -20,6 +20,8 @@ struct xe_guc_ads {size_t golden_lrc_size;/** @regset_size: size of register set passed to GuC for save/restore */ u32 regset_size; +/** @capture_size: size of register set passed to GuC for capture */ + u32 capture_size; };#endif
drivers/gpu/drm/xe/xe_guc_capture.c +265 -0
285 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_capture.h +6 -0
@@ -14,6 +14,12 @@ struct xe_hw_engine;struct xe_gt ;struct xe_guc ; +bool xe_guc_capture_is_matching_engine (struct xe_gt *gt,struct xe_exec_queue *ce, +struct xe_hw_engine *engine); +void xe_guc_capture_process (struct xe_guc *guc); +int xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr); +int xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size); +int xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size);int xe_guc_capture_init (struct xe_guc *guc);#endif /* _XE_GUC_CAPTURE_H */
drivers/gpu/drm/xe/xe_guc_capture_fwif.h new file +225 -0
225 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_fwif.h +20 -0
@@ -9,6 +9,7 @@#include <linux/bits.h> #include "abi/guc_klvs_abi.h" +#include "xe_hw_engine_types.h" #define G2H_LEN_DW_SCHED_CONTEXT_MODE_SET 4#define G2H_LEN_DW_DEREGISTER_CONTEXT 3
@@ -164,6 +165,8 @@ struct guc_mmio_reg {#define GUC_REGSET_MASKED BIT(0)#define GUC_REGSET_MASKED_WITH_VALUE BIT(2)#define GUC_REGSET_RESTORE_ONLY BIT(3) +#define GUC_REGSET_STEERING_GROUP GENMASK(15, 12) +#define GUC_REGSET_STEERING_INSTANCE GENMASK(23, 20) } __packed;/* GuC register sets */
@@ -192,6 +195,23 @@ enum { GUC_CAPTURE_LIST_INDEX_MAX = 2, }; +/*Register-types of GuC capture register lists */ +enum guc_capture_type { +GUC_CAPTURE_LIST_TYPE_GLOBAL =0 , +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , +GUC_CAPTURE_LIST_TYPE_MAX , +}; + +/* Class indecies for capture_class and capture_instance arrays */ +enum { +GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE =0 , +GUC_CAPTURE_LIST_CLASS_VIDEO =1 , +GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE =2 , +GUC_CAPTURE_LIST_CLASS_BLITTER =3 , +GUC_CAPTURE_LIST_CLASS_GSC_OTHER =4 , +}; +/* GuC Additional Data Struct */ struct guc_ads {struct guc_mmio_reg_set reg_state_list[GUC_MAX_ENGINE_CLASSES ][GUC_MAX_INSTANCES_PER_CLASS ];
drivers/gpu/drm/xe/xe_guc_types.h +2 -0
@@ -42,6 +42,8 @@ struct xe_guc {struct xe_guc_ads ads;/** @ct: GuC ct */ struct xe_guc_ct ct; +/** @capture: the error-state-capture module's data and objects */ +struct xe_guc_state_capture *capture;/** @pc: GuC Power Conservation */ struct xe_guc_pc pc;/** @dbm: GuC Doorbell Manager */
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Check sizing of guc_capture output
In reply to Zhanjun DongAdd capture output size check function to provide a reasonable minimum size for error capture region before allocating the shared buffer.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
drivers/gpu/drm/xe/xe_guc_capture.c +76 -0
@@ -559,6 +559,81 @@ xe_guc_capture_getnullheader(struct xe_guc *guc, void **outptr, size_t *size)return 0 ; } +static int +guc_capture_output_min_size_est (struct xe_guc *guc) +{ +struct xe_gt *gt =guc_to_gt (guc); +struct xe_hw_engine *hwe; +enum xe_hw_engine_id id; + +int worst_min_size =0 ; +size_t tmp =0 ; + +if (!guc->capture) +return -ENODEV ; + +/* +* If every single engine-instance suffered a failure in quick succession but +* were all unrelated, then a burst of multiple error-capture events would dump +* registers for every one engine instance, one at a time. In this case, GuC +* would even dump the global-registers repeatedly. +* +* For each engine instance, there would be 1 x guc_state_capture_group_t output +* followed by 3 x guc_state_capture_t lists. The latter is how the register +* dumps are split across different register types (where the '3' are global vs class +* vs instance). +*/ +for_each_hw_engine (hwe, gt, id) { + worst_min_size +=sizeof (struct guc_state_capture_group_header_t ) + + (3 *sizeof (struct guc_state_capture_header_t )); + +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &tmp, true)) + worst_min_size += tmp; + +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + hwe->class, &tmp, true)) { + worst_min_size += tmp; + } +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + hwe->class, &tmp, true)) { + worst_min_size += tmp; + } + } + +return worst_min_size; +} + +/* +* Add on a 3x multiplier to allow for multiple back-to-back captures occurring +* before the i915 can read the data out and process it +*/ +#define GUC_CAPTURE_OVERBUFFER_MULTIPLIER 3 + +static void check_guc_capture_size (struct xe_guc *guc) +{ +int min_size =guc_capture_output_min_size_est (guc); +int spare_size = min_size *GUC_CAPTURE_OVERBUFFER_MULTIPLIER ; +u32 buffer_size =xe_guc_log_section_size_capture (&guc->log); + +/* +* NOTE: min_size is much smaller than the capture region allocation (DG2: <80K vs 1MB) +* Additionally, its based on space needed to fit all engines getting reset at once +* within the same G2H handler task slot. This is very unlikely. However, if GuC really +* does run out of space for whatever reason, we will see an separate warning message +* when processing the G2H event capture-notification, search for: +* xe_guc_STATE_CAPTURE_EVENT_STATUS_NOSPACE. +*/ +if (min_size <0 ) +xe_gt_warn (guc_to_gt (guc),"Failed to calculate error state capture buffer minimum size: %d!\n" , + min_size); +else if (min_size > buffer_size) +xe_gt_warn (guc_to_gt (guc),"Error state capture buffer maybe small: %d < %d\n" , + buffer_size, min_size); +else if (spare_size > buffer_size) +xe_gt_dbg (guc_to_gt (guc),"Error state capture buffer lacks spare size: %d < %d (min = %d)\n" , + buffer_size, spare_size, min_size); +} +int xe_guc_capture_init (struct xe_guc *guc) { guc->capture =kzalloc (sizeof (*guc->capture),GFP_KERNEL );
@@ -570,6 +645,7 @@ int xe_guc_capture_init(struct xe_guc *guc)INIT_LIST_HEAD (&guc->capture->outlist);INIT_LIST_HEAD (&guc->capture->cachelist); +check_guc_capture_size (guc);return 0 ; }
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Expose dss per group for GuC error capture
In reply to Zhanjun DongExpose helper for dss per group of mcr, GuC error capture feature need this info to prepare buffer required.
--- drivers/gpu/drm/xe/xe_gt_mcr.c | 4 ++-- drivers/gpu/drm/xe/xe_gt_mcr.h | 1 + drivers/gpu/drm/xe/xe_gt_topology.c | 3 --- drivers/gpu/drm/xe/xe_guc_capture.c | 27 +++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_hw_engine_types.h | 3 +++ 5 files changed, 33 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_gt_mcr.c +2 -2
@@ -291,7 +291,7 @@ static void init_steering_mslice(struct xe_gt *gt) gt->steering[LNCF ].instance_target =0 ;/* unused */ } -static int num_dss_per_grp (struct xe_gt *gt) +int xe_gt_mcr_get_dss_per_group (struct xe_gt *gt) {struct xe_device *xe =gt_to_xe (gt);
@@ -313,7 +313,7 @@ static void init_steering_dss(struct xe_gt *gt) {unsigned int dss =min (xe_dss_mask_group_ffs (gt->fuse_topo.g_dss_mask,0 ,0 ),xe_dss_mask_group_ffs (gt->fuse_topo.c_dss_mask,0 ,0 )); -unsigned int dss_per_grp =num_dss_per_grp (gt); +int dss_per_grp =xe_gt_mcr_get_dss_per_group (gt); gt->steering[DSS ].group_target = dss / dss_per_grp; gt->steering[DSS ].instance_target = dss % dss_per_grp;
drivers/gpu/drm/xe/xe_gt_mcr.h +1 -0
@@ -14,6 +14,7 @@ struct xe_gt;void xe_gt_mcr_init (struct xe_gt *gt);void xe_gt_mcr_set_implicit_defaults (struct xe_gt *gt); +int xe_gt_mcr_get_dss_per_group (struct xe_gt *gt);u32 xe_gt_mcr_unicast_read (struct xe_gt *gt,struct xe_reg_mcr mcr_reg,int group,int instance);
drivers/gpu/drm/xe/xe_gt_topology.c +0 -3
@@ -11,9 +11,6 @@#include "xe_gt.h" #include "xe_mmio.h" -#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) -#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) -static void load_dss_mask (struct xe_gt *gt,xe_dss_mask_t mask,int numregs, ...) {
drivers/gpu/drm/xe/xe_guc_capture.c +27 -0
@@ -93,6 +93,33 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +static inline void xe_gt_mcr_get_ss_steering (struct xe_gt *gt,unsigned int dss, +unsigned int *group,unsigned int *instance) +{ +int dss_per_grp =xe_gt_mcr_get_dss_per_group (gt); + *group = dss / dss_per_grp; + *instance = dss % dss_per_grp; +} + +static inline bool xe_sseu_has_subslice (struct xe_gt *gt,int slice,int subslice) +{ +int dss_per_grp =xe_gt_mcr_get_dss_per_group (gt); +int index = slice * dss_per_grp + subslice; +return index >=XE_MAX_DSS_FUSE_BITS ? false :test_bit (index, gt->fuse_topo.g_dss_mask); +} + +#define _HAS_SS (ss_, gt_, group_, instance_) xe_sseu_has_subslice(gt_, group_, instance_) + +/* +* Loop over each subslice/DSS and determine the group and instance IDs that +* should be used to steer MCR accesses toward this DSS. +*/ +#define for_each_ss_steering (ss_, gt_, group_, instance_) \ + for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \ + ss_ < XE_MAX_DSS_FUSE_BITS; \ + ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \ + for_each_if(_HAS_SS(ss_, gt_, group_, instance_)) +int xe_guc_capture_init (struct xe_guc *guc) {return 0 ;
drivers/gpu/drm/xe/xe_hw_engine_types.h +3 -0
@@ -65,6 +65,9 @@ struct xe_bo;struct xe_execlist_port ;struct xe_gt ; +#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) +#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) +/** * struct xe_hw_engine_class_intf - per hw engine class struct interface *
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Add XE_LP steered register lists
In reply to Zhanjun DongAdd the ability for runtime allocation and freeing of steered register list extentions that depend on the detected HW config fuses.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 187 +++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_guc_capture.c +185 -2
@@ -94,6 +94,81 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +/* XE_LP Global */ +static const struct __guc_mmio_reg_descr xe_lp_global_regs[] = { +COMMON_XELP_BASE_GLOBAL , +}; + +/* XE_LP Render / Compute Per-Class */ +static const struct __guc_mmio_reg_descr xe_lp_rc_class_regs[] = { +COMMON_XELP_BASE_RENDER , +}; + +/* Pre-Xe Render / Compute Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_rc_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* Pre-Xe Media Decode/Encode Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_vd_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* XE_LP Video Enhancement Per-Class */ +static const struct __guc_mmio_reg_descr xe_lp_vec_class_regs[] = { +COMMON_XELP_BASE_VEC , +}; + +/* Pre-Xe Video Enhancement Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_vec_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* Pre-Xe Blitter Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_blt_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* XE_LP - GSC Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr xe_lp_gsc_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* +* Empty list to prevent warnings about unknown class/instance types +* as not all class/instanace types have entries on all platforms. +*/ +static const struct __guc_mmio_reg_descr empty_regs_list[] = { +}; + +#define TO_GCAP_DEF_OWNER (x) (GUC_CAPTURE_LIST_INDEX_##x) +#define TO_GCAP_DEF_TYPE (x) (GUC_CAPTURE_LIST_TYPE_##x) +#define MAKE_REGLIST (regslist, regsowner, regstype, class) \ + { \ + regslist, \ + ARRAY_SIZE(regslist), \ + TO_GCAP_DEF_OWNER(regsowner), \ + TO_GCAP_DEF_TYPE(regstype), \ + class, \ + NULL, \ + } + +/* List of lists */ +static const struct __guc_mmio_reg_descr_group xe_lp_lists[] = { +MAKE_REGLIST (xe_lp_global_regs,PF ,GLOBAL ,0 ), +MAKE_REGLIST (xe_lp_rc_class_regs,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ), +MAKE_REGLIST (pre_xe_rc_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_VIDEO ), +MAKE_REGLIST (pre_xe_vd_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_VIDEO ), +MAKE_REGLIST (xe_lp_vec_class_regs,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE ), +MAKE_REGLIST (pre_xe_vec_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_BLITTER ), +MAKE_REGLIST (pre_xe_blt_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_BLITTER ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_GSC_OTHER ), +MAKE_REGLIST (xe_lp_gsc_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_GSC_OTHER ), + {} +}; +static const char * capture_list_type_names [] = {"Global" ,"Class" ,
@@ -179,11 +254,119 @@ guc_capture_get_one_ext_list(struct __guc_mmio_reg_descr_group *reglists,return NULL ; } +struct __ext_steer_reg { +const char *name; +struct xe_reg_mcr reg; +}; + +static const struct __ext_steer_reg pre_xe_extregs[] = { + {"SAMPLER_INSTDONE" ,SAMPLER_INSTDONE }, + {"ROW_INSTDONE" ,ROW_INSTDONE } +}; + +static const struct __ext_steer_reg xehpg_extregs[] = { + {"XEHPG_INSTDONE_GEOM_SVG" ,XEHPG_INSTDONE_GEOM_SVG } +}; + +static void __fill_ext_reg (struct __guc_mmio_reg_descr *ext, +const struct __ext_steer_reg *extlist, +int slice_id,int subslice_id) +{ + ext->reg =XE_REG (extlist->reg.__reg.addr); + ext->flags =FIELD_PREP (GUC_REGSET_STEERING_GROUP , slice_id); + ext->flags |=FIELD_PREP (GUC_REGSET_STEERING_INSTANCE , subslice_id); + ext->regname = extlist->name; +} + +static int +__alloc_ext_regs (struct __guc_mmio_reg_descr_group *newlist, +const struct __guc_mmio_reg_descr_group *rootlist,int num_regs) +{ +struct __guc_mmio_reg_descr *list; + + list =kcalloc (num_regs,sizeof (struct __guc_mmio_reg_descr ),GFP_KERNEL ); +if (!list) +return -ENOMEM ; + + newlist->extlist = list; + newlist->num_regs = num_regs; + newlist->owner = rootlist->owner; + newlist->engine = rootlist->engine; + newlist->type = rootlist->type; + +return 0 ; +} + +static void +guc_capture_alloc_steered_lists (struct xe_guc *guc,const struct __guc_mmio_reg_descr_group *lists) +{ +struct xe_gt *gt =guc_to_gt (guc); +int slice, subslice, iter, i, num_steer_regs, num_tot_regs =0 ; +const struct __guc_mmio_reg_descr_group *list; +struct __guc_mmio_reg_descr_group *extlists; +struct __guc_mmio_reg_descr *extarray; +bool has_xehpg_extregs; + +/* steered registers currently only exist for the render-class */ + list =guc_capture_get_one_list (lists,GUC_CAPTURE_LIST_INDEX_PF , +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , +GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ); +/* skip if extlists was previously allocated */ +if (!list || guc->capture->extlists) +return ; + + has_xehpg_extregs =GRAPHICS_VERx100 (gt_to_xe (gt)) >=1255 ; + + num_steer_regs =ARRAY_SIZE (pre_xe_extregs); +if (has_xehpg_extregs) + num_steer_regs +=ARRAY_SIZE (xehpg_extregs); + + num_tot_regs += num_steer_regs *bitmap_weight (gt->fuse_topo.g_dss_mask, +sizeof (gt->fuse_topo.g_dss_mask) *8 ); +if (!num_tot_regs) +return ; + +/* allocate an extra for an end marker */ + extlists =kcalloc (2 ,sizeof (struct __guc_mmio_reg_descr_group ),GFP_KERNEL ); +if (!extlists) +return ; + +if (__alloc_ext_regs (&extlists[0 ], list, num_tot_regs)) { +kfree (extlists); +return ; + } + + extarray = extlists[0 ].extlist; +for_each_ss_steering (iter, gt, slice, subslice) { +for (i =0 ; i <ARRAY_SIZE (pre_xe_extregs); ++i) { +__fill_ext_reg (extarray, &pre_xe_extregs[i], slice, subslice); + ++extarray; + } + +if (has_xehpg_extregs) { +for (i =0 ; i <ARRAY_SIZE (xehpg_extregs); ++i) { +__fill_ext_reg (extarray, &xehpg_extregs[i], slice, subslice); + ++extarray; + } + } + } + +xe_gt_dbg (guc_to_gt (guc),"capture found %d ext-regs.\n" , num_tot_regs); + guc->capture->extlists = extlists; +} +static const struct __guc_mmio_reg_descr_group *guc_capture_get_device_reglist (struct xe_guc *guc) { -//FIXME: add register list -return NULL ; +/* +* For certain engine classes, there are slice and subslice +* level registers requiring steering. We allocate and populate +* these at init time based on hw config add it as an extension +* list at the end of the pre-populated render list. +*/ +guc_capture_alloc_steered_lists (guc, xe_lp_lists); + +return xe_lp_lists; } static int
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Add register defines for GuC based register capture
In reply to Zhanjun DongAdd registers defines and list of registers for GuC based error state capture.
--- drivers/gpu/drm/xe/Kconfig | 11 +++ drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 +++ drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 +++++ drivers/gpu/drm/xe/xe_guc.c | 7 ++ drivers/gpu/drm/xe/xe_guc_capture.c | 101 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 19 +++++ 7 files changed, 171 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.c create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.h
drivers/gpu/drm/xe/Kconfig +11 -0
@@ -107,6 +107,17 @@ config DRM_XE_PRESI_PCI_DEVELOPMENT_MODE If in doubt, say "N". +config DRM_XE_CAPTURE_ERROR + bool "Enable capturing GPU state following a hang" + depends on DRM_XE + default y + help + This option enables capturing the GPU state when a hang is detected. + This information is vital for triaging hangs and assists in debugging. + Please report any hang to your Intel representative to help with triaging. + + If in doubt, say "Y". + menu "drm/Xe Debugging" depends on DRM_XE depends on EXPERT
drivers/gpu/drm/xe/Makefile +1 -0
@@ -91,6 +91,7 @@ xe-y += xe_bb.o \ xe_gt_topology.o \ xe_guc.o \ xe_guc_ads.o \ + xe_guc_capture.o \ xe_guc_ct.o \ xe_guc_db_mgr.o \ xe_guc_debugfs.o \
drivers/gpu/drm/xe/regs/xe_engine_regs.h +12 -0
@@ -64,10 +64,16 @@#define RING_ACTHD_UDW (base) XE_REG((base) + 0x5c)#define RING_DMA_FADD_UDW (base) XE_REG((base) + 0x60) +#define RING_IPEIR (base) XE_REG((base) + 0x64)#define RING_IPEHR (base) XE_REG((base) + 0x68) +#define RING_INSTDONE (base) XE_REG((base) + 0x6c) +#define RING_INSTPS (base) XE_REG((base) + 0x70) +#define RING_ACTHD (base) XE_REG((base) + 0x74)#define RING_DMA_FADD (base) XE_REG((base) + 0x78)#define RING_HWS_PGA (base) XE_REG((base) + 0x80) +#define IPEIR (base) XE_REG((base) + 0x88) +#define RING_HWSTAM (base) XE_REG((base) + 0x98)#define RING_MI_MODE (base) XE_REG((base) + 0x9c)#define RING_NOPID (base) XE_REG((base) + 0x94)
@@ -110,9 +116,12 @@#define FF_DOP_CLOCK_GATE_DISABLE REG_BIT(1)#define REPLAY_MODE_GRANULARITY REG_BIT(0) +#define RING_BBSTATE (base) XE_REG((base) + 0x110)#define RING_BBADDR (base) XE_REG((base) + 0x140)#define RING_BBADDR_UDW (base) XE_REG((base) + 0x168) +#define CCID (base) XE_REG((base) + 0x180) +#define BCS_SWCTRL (base) XE_REG((base) + 0x200, XE_REG_OPTION_MASKED)#define BCS_SWCTRL_DISABLE_256B REG_BIT(2)
@@ -128,6 +137,9 @@#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH REG_BIT(3)#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT REG_BIT(0) +#define RING_PDP_UDW (base, n) XE_REG((base) + 0x270 + (n) * 8 + 4) +#define RING_PDP_LDW (base, n) XE_REG((base) + 0x270 + (n) * 8) +#define RING_MODE (base) XE_REG((base) + 0x29c)#define GFX_DISABLE_LEGACY_MODE REG_BIT(3)
drivers/gpu/drm/xe/regs/xe_gt_regs.h +20 -0
@@ -67,6 +67,8 @@#define VE1_AUX_INV XE_REG(0x42b8)#define AUX_INV REG_BIT(0) +#define AUX_ERR_DBG XE_REG(0x43f4) +#define _PAT_PTA 0x4820#define XE2_NO_PROMOTE REG_BIT(10)#define XE2_COMP_EN REG_BIT(9)
@@ -109,6 +111,8 @@#define FF_MODE2_TDS_TIMER_MASK REG_GENMASK(23, 16)#define FF_MODE2_TDS_TIMER_128 REG_FIELD_PREP(FF_MODE2_TDS_TIMER_MASK, 4) +#define XEHPG_INSTDONE_GEOM_SVG XE_REG_MCR(0x666c) +#define CACHE_MODE_1 XE_REG(0x7004, XE_REG_OPTION_MASKED)#define MSAA_OPTIMIZATION_REDUC_DISABLE REG_BIT(11)
@@ -125,6 +129,10 @@#define FLSH_IGNORES_PSD REG_BIT(10)#define FD_END_COLLECT REG_BIT(5) +#define SC_INSTDONE XE_REG(0x7100) +#define SC_INSTDONE_EXTRA XE_REG(0x7104) +#define SC_INSTDONE_EXTRA2 XE_REG(0x7108) +#define COMMON_SLICE_CHICKEN4 XE_REG(0x7300, XE_REG_OPTION_MASKED)#define DISABLE_TDC_LOAD_BALANCING_CALC REG_BIT(6)
@@ -326,6 +334,11 @@#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658) +#define FAULT_TLB_DATA0 XE_REG(0xceb8) +#define FAULT_TLB_DATA1 XE_REG(0xcebc) + +#define RING_FAULT_REG XE_REG(0xcec4) +#define XEHP_MERT_MOD_CTRL XE_REG_MCR(0xcf28)#define RENDER_MOD_CTRL XE_REG_MCR(0xcf2c)#define COMP_MOD_CTRL XE_REG_MCR(0xcf30)
@@ -349,6 +362,11 @@#define XE_OAG_BLT_BUSY_FREE XE_REG(0xdbbc)#define XE_OAG_RENDER_BUSY_FREE XE_REG(0xdbdc) +#define GAM_DONE XE_REG(0xcf68) + +#define SAMPLER_INSTDONE XE_REG_MCR(0xe160) +#define ROW_INSTDONE XE_REG_MCR(0xe164) +#define HALF_SLICE_CHICKEN5 XE_REG_MCR(0xe188, XE_REG_OPTION_MASKED)#define DISABLE_SAMPLE_G_PERFORMANCE REG_BIT(0)
@@ -515,6 +533,8 @@#define GT_CS_MASTER_ERROR_INTERRUPT REG_BIT(3)#define GT_RENDER_USER_INTERRUPT REG_BIT(0) +#define SFC_DONE (n) XE_REG(0x1cc000 + (n) * 0x1000) +#define PVC_GT0_PACKAGE_ENERGY_STATUS XE_REG(0x281004)#define PVC_GT0_PACKAGE_RAPL_LIMIT XE_REG(0x281008)#define PVC_GT0_PACKAGE_POWER_SKU_UNIT XE_REG(0x281068)
drivers/gpu/drm/xe/xe_guc.c +7 -0
@@ -17,6 +17,7 @@#include "xe_force_wake.h" #include "xe_gt.h" #include "xe_guc_ads.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_hwconfig.h" #include "xe_guc_log.h"
@@ -264,6 +265,12 @@ int xe_guc_init(struct xe_guc *guc)if (ret) goto out; +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) + ret =xe_guc_capture_init (guc); +if (ret) + goto out; +#endif + ret =xe_guc_ads_init (&guc->ads);if (ret) goto out;
drivers/gpu/drm/xe/xe_guc_capture.c new file +101 -0
102 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_capture.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021-2021 Intel Corporation +*/ + +#ifndef _XE_GUC_CAPTURE_H +#define _XE_GUC_CAPTURE_H + +#include <linux/types.h> +#include "xe_exec_queue_types.h" + +struct xe_hw_engine ; + +struct xe_gt ; +struct xe_guc ; + +int xe_guc_capture_init (struct xe_guc *guc); + +#endif /* _XE_GUC_CAPTURE_H */
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Plumb GuC-capture into dev coredump
In reply to Zhanjun DongAdd xe_hw_engine_snapshot_from_capture to take snapshot from capture node list.
Add data struct to map register to a snapshot field, although all field is mapped now, which means the offset could be optimized, while in the future, depends on system configuration, the field might not be consecutive. This is reserved for future.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 99 ++++++++++++++++++++++- drivers/gpu/drm/xe/xe_guc_capture.h | 10 +++ drivers/gpu/drm/xe/xe_hw_engine.c | 73 ++++++++--------- drivers/gpu/drm/xe/xe_hw_engine_types.h | 103 ++++++++++++------------ 4 files changed, 195 insertions(+), 90 deletions(-)
drivers/gpu/drm/xe/xe_guc_capture.c +98 -1
@@ -169,6 +169,33 @@ static const struct __guc_mmio_reg_descr_group xe_lp_lists[] = { {} }; +struct __reg_map_descr capture_engine_reg[] = { + {offsetof(struct snap_shot_regs , ring_hwstam),RING_HWSTAM (0 )}, + {offsetof(struct snap_shot_regs , ring_hws_pga),RING_HWS_PGA (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_status_lo),RING_EXECLIST_STATUS_LO (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_status_hi),RING_EXECLIST_STATUS_HI (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_sq_contents_lo),RING_EXECLIST_SQ_CONTENTS_LO (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_sq_contents_hi),RING_EXECLIST_SQ_CONTENTS_HI (0 )}, + {offsetof(struct snap_shot_regs , ring_start),RING_START (0 )}, + {offsetof(struct snap_shot_regs , ring_head),RING_HEAD (0 )}, + {offsetof(struct snap_shot_regs , ring_tail),RING_TAIL (0 )}, + {offsetof(struct snap_shot_regs , ring_ctl),RING_CTL (0 )}, + {offsetof(struct snap_shot_regs , ring_mi_mode),RING_MI_MODE (0 )}, + {offsetof(struct snap_shot_regs , ring_mode),RING_MODE (0 )}, + {offsetof(struct snap_shot_regs , ring_imr),RING_IMR (0 )}, + {offsetof(struct snap_shot_regs , ring_esr),RING_ESR (0 )}, + {offsetof(struct snap_shot_regs , ring_emr),RING_EMR (0 )}, + {offsetof(struct snap_shot_regs , ring_eir),RING_EIR (0 )}, + {offsetof(struct snap_shot_regs , ring_acthd_udw),RING_ACTHD_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_acthd),RING_ACTHD (0 )}, + {offsetof(struct snap_shot_regs , ring_bbaddr_udw),RING_BBADDR_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_bbaddr),RING_BBADDR (0 )}, + {offsetof(struct snap_shot_regs , ring_dma_fadd_udw),RING_DMA_FADD_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_dma_fadd),RING_DMA_FADD (0 )}, + {offsetof(struct snap_shot_regs , ipehr),RING_IPEHR (0 )}, + {offsetof(struct snap_shot_regs , rcu_mode),RCU_MODE }, +}; +static const char * capture_list_type_names [] = {"Global" ,"Class" ,
@@ -1304,4 +1331,74 @@ int xe_guc_capture_init(struct xe_guc *guc)return 0 ; } -#endif +inline struct __reg_map_descr *xe_guc_capture_get_register_map (int *count) +{ + *count =ARRAY_SIZE (capture_engine_reg); +return capture_engine_reg; +} + +static void cp_reg_to_snapshot (u32 offset,u32 value,struct snap_shot_regs *regs) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (capture_engine_reg); i++) +if (offset == capture_engine_reg[i].reg.addr) { +u32 *field = (u32 *)((uintptr_t )regs + capture_engine_reg[i].dst_offset); + *field = value; +return ; + } +} + +static void guc_capture_find_ecode (struct __guc_capture_parsed_output *node, +struct xe_hw_engine_snapshot *snapshot) +{ +struct gcap_reg_list_info *reginfo; +struct guc_mmio_reg *regs; +int i; + +if (!node) +return ; + + reginfo = node->reginfo +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE ; + regs = reginfo->regs; +for (i =0 ; i < reginfo->num_regs; i++) +cp_reg_to_snapshot (regs[i].offset, regs[i].value, &snapshot->reg); +} + +/** +* xe_hw_engine_snapshot_from_capture - Take a quick snapshot of the HW Engine. +* @hwe: Xe HW Engine. +* @snapshot: Xe HW Engine snapshot object to save data, copied from error capture +* +* This can be printed out in a later stage like during dev_coredump +* analysis. +* +* Returns: None +*/ +void +xe_hw_engine_snapshot_from_capture (struct xe_hw_engine *hwe,struct xe_hw_engine_snapshot *snapshot) +{ +struct xe_gt *gt = hwe->gt; +struct xe_guc *guc = >->uc.guc; +struct __guc_capture_parsed_output *n, *ntmp; + +if (!guc->capture) +return ; + +/* +* Look for a matching GuC reported error capture node from +* the internal output link-list based on engine class and instance. +*/ +list_for_each_entry_safe (n, ntmp, &guc->capture->outlist, link) { +u32 hwe_guc_class =xe_engine_class_to_guc_class (hwe->class); + +if (n->eng_class == hwe_guc_class + && n->eng_inst == hwe->instance) { +guc_capture_find_ecode (n, snapshot); +list_del (&n->link); +return ; + } + } +} + +#endif
drivers/gpu/drm/xe/xe_guc_capture.h +10 -0
@@ -14,6 +14,11 @@ struct xe_hw_engine;struct xe_gt ;struct xe_guc ; +struct __reg_map_descr { +u32 dst_offset; +struct xe_reg reg; +}; +bool xe_guc_capture_is_matching_engine (struct xe_gt *gt,struct xe_exec_queue *ce,struct xe_hw_engine *engine);void xe_guc_capture_process (struct xe_guc *guc);
@@ -21,5 +26,10 @@ int xe_guc_capture_getlist(struct xe_guc *guc, u32 owner, u32 type, u32 classid,int xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size);int xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size);int xe_guc_capture_init (struct xe_guc *guc); +struct __reg_map_descr *xe_guc_capture_get_register_map (int *count); +void xe_hw_engine_snapshot_from_capture (struct xe_hw_engine *hwe, +struct xe_hw_engine_snapshot *snapshot); +void xe_hw_engine_snapshot_from_engine (struct xe_hw_engine *hwe, +struct xe_hw_engine_snapshot *snapshot);#endif /* _XE_GUC_CAPTURE_H */
drivers/gpu/drm/xe/xe_hw_engine.c +34 -39
92 lines not on this page · raw message
drivers/gpu/drm/xe/xe_hw_engine_types.h +53 -50
115 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Pre-allocate output nodes for extraction
In reply to Zhanjun DongPre-allocate a fixed number of empty nodes up front (at the time of ADS registration) that we can consume from or return to an internal cached list of nodes.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/gpu/drm/xe/xe_guc_capture.c +83 -0
@@ -479,6 +479,8 @@ xe_guc_capture_getlistsize(struct xe_guc *guc, u32 owner, u32 type, u32 classid,return guc_capture_getlistsize (guc, owner, type, classid, size, false); } +static void guc_capture_create_prealloc_nodes (struct xe_guc *guc); +int xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr) {
@@ -497,6 +499,12 @@ xe_guc_capture_getlist(struct xe_guc *guc, u32 owner, u32 type, u32 classid, voireturn cache->status; } +/* +* ADS population of input registers is a good +* time to pre-allocate cachelist output nodes +*/ +guc_capture_create_prealloc_nodes (guc); + ret =xe_guc_capture_getlistsize (guc, owner, type, classid, &size);if (ret) { cache->is_valid = true;
@@ -896,6 +904,30 @@ guc_capture_get_prealloc_node(struct xe_guc *guc)return found; } +static struct __guc_capture_parsed_output * +guc_capture_alloc_one_node (struct xe_guc *guc) +{ +struct __guc_capture_parsed_output *new; +int i; + + new =kzalloc (sizeof (*new),GFP_KERNEL ); +if (!new) +return NULL ; + +for (i =0 ; i <GUC_CAPTURE_LIST_TYPE_MAX ; ++i) { + new->reginfo[i].regs =kcalloc (guc->capture->max_mmio_per_node, +sizeof (struct guc_mmio_reg ),GFP_KERNEL ); +if (!new->reginfo[i].regs) { +while (i) +kfree (new->reginfo[--i].regs); +kfree (new); +return NULL ; + } + } +guc_capture_init_node (guc, new); + +return new; +}static struct __guc_capture_parsed_output * guc_capture_clone_node(struct xe_guc *guc, struct __guc_capture_parsed_output *original,
@@ -937,6 +969,57 @@ guc_capture_clone_node(struct xe_guc *guc, struct __guc_capture_parsed_output *oreturn new; } +static void +__guc_capture_create_prealloc_nodes (struct xe_guc *guc) +{ +struct __guc_capture_parsed_output *node =NULL ; +int i; + +for (i =0 ; i <PREALLOC_NODES_MAX_COUNT ; ++i) { + node =guc_capture_alloc_one_node (guc); +if (!node) { +xe_gt_warn (guc_to_gt (guc),"Register capture pre-alloc-cache failure\n" ); +/* dont free the priors, use what we got and cleanup at shutdown */ +return ; + } +guc_capture_add_node_to_cachelist (guc->capture, node); + } +} + +static int +guc_get_max_reglist_count (struct xe_guc *guc) +{ +int i, j, k, tmp, maxregcount =0 ; + +for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; ++i) { +for (j =0 ; j <GUC_CAPTURE_LIST_TYPE_MAX ; ++j) { +for (k =0 ; k <GUC_MAX_ENGINE_CLASSES ; ++k) { +if (j ==GUC_CAPTURE_LIST_TYPE_GLOBAL && k >0 ) +continue ; + + tmp =guc_cap_list_num_regs (guc->capture, i, j, k); +if (tmp > maxregcount) + maxregcount = tmp; + } + } + } +if (!maxregcount) + maxregcount =PREALLOC_NODES_DEFAULT_NUMREGS ; + +return maxregcount; +} + +static void +guc_capture_create_prealloc_nodes (struct xe_guc *guc) +{ +/* skip if we've already done the pre-alloc */ +if (guc->capture->max_mmio_per_node) +return ; + + guc->capture->max_mmio_per_node =guc_get_max_reglist_count (guc); +__guc_capture_create_prealloc_nodes (guc); +} +static int guc_capture_extract_reglists (struct xe_guc *guc,struct __guc_capture_bufstate *buf) {
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Add capture size check in GuC log buffer
In reply to Zhanjun DongThe capture-nodes is included in GuC log buffer, add the size check for capture region in the whole GuC log buffer.
--- drivers/gpu/drm/xe/xe_gt_printk.h | 3 + drivers/gpu/drm/xe/xe_guc_fwif.h | 48 +++++++ drivers/gpu/drm/xe/xe_guc_log.c | 179 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_log.h | 15 +++ drivers/gpu/drm/xe/xe_guc_log_types.h | 26 ++++ 5 files changed, 271 insertions(+)
drivers/gpu/drm/xe/xe_gt_printk.h +3 -0
@@ -22,6 +22,9 @@#define xe_gt_notice (_gt, _fmt, ...) \ xe_gt_printk((_gt), notice, _fmt, ##__VA_ARGS__) +#define xe_gt_notice_ratelimited (_gt, _fmt, ...) \ + xe_gt_printk((_gt), err_ratelimited, _fmt, ##__VA_ARGS__) +#define xe_gt_info (_gt, _fmt, ...) \ xe_gt_printk((_gt), info, _fmt, ##__VA_ARGS__)
drivers/gpu/drm/xe/xe_guc_fwif.h +48 -0
54 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_log.c +179 -0
191 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_log.h +15 -0
@@ -7,6 +7,7 @@#define _XE_GUC_LOG_H_#include "xe_guc_log_types.h" +#include "xe_guc_types.h" struct drm_printer ;
@@ -36,6 +37,11 @@ struct drm_printer;#define GUC_VERBOSITY_TO_LOG_LEVEL (x) ((x) + 2)#define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) +static inline struct xe_guc *log_to_guc (struct xe_guc_log *log) +{ + return container_of(log, struct xe_guc, log); +} +int xe_guc_log_init (struct xe_guc_log *log);void xe_guc_log_print (struct xe_guc_log *log,struct drm_printer *p);
@@ -45,4 +51,13 @@ xe_guc_log_get_level(struct xe_guc_log *log) return log->level; } +u32 xe_guc_log_section_size_capture (struct xe_guc_log *log); + +bool xe_guc_check_log_buf_overflow (struct xe_guc_log *log, +enum guc_log_buffer_type type, +unsigned int full_cnt); +unsigned int xe_guc_get_log_buffer_size (struct xe_guc_log *log, +enum guc_log_buffer_type type); +size_t xe_guc_get_log_buffer_offset (struct xe_guc_log *log, +enum guc_log_buffer_type type);#endif
drivers/gpu/drm/xe/xe_guc_log_types.h +26 -0
@@ -6,7 +6,17 @@#ifndef _XE_GUC_LOG_TYPES_H_#define _XE_GUC_LOG_TYPES_H_ +#include <linux/mutex.h> #include <linux/types.h> +#include <linux/workqueue.h> +#include "xe_guc_fwif.h" + +enum { +GUC_LOG_SECTIONS_CRASH , +GUC_LOG_SECTIONS_DEBUG , +GUC_LOG_SECTIONS_CAPTURE , +GUC_LOG_SECTIONS_LIMIT +};struct xe_bo ;
@@ -18,6 +28,22 @@ struct xe_guc_log {u32 level;/** @bo: XE BO for GuC log */ struct xe_bo *bo; + +/* Allocation settings */ +struct { +s32 bytes;/* Size in bytes */ +s32 units;/* GuC API units - 1MB or 4KB */ +s32 count;/* Number of API units */ +u32 flag;/* GuC API units flag */ + } sizes[GUC_LOG_SECTIONS_LIMIT ]; +bool sizes_initialised; + +/* logging related stats */ +struct { +u32 sampled_overflow; +u32 overflow; +u32 flush; + } stats[GUC_MAX_LOG_BUFFER]; };#endif
Signature · 1 line
2.34.1
PATCH 1/1 drm/xe/guc: Extract GuC error capture lists on G2H notification
In reply to Zhanjun DongUpon the G2H Notify-Err-Capture event, parse through the GuC Log Buffer (error-capture-subregion) and generate one or more capture-nodes. A single node represents a single "engine- instance-capture-dump" and contains at least 3 register lists:
global, engine-class and engine-instance. An internal link list is maintained to store one or more nodes.
Because the link-list node generation happen before the call to devcoredump, duplicate global and engine-class register lists for each engine-instance register dump if we find dependent-engine resets in a engine-capture-group.
--- drivers/gpu/drm/xe/abi/guc_actions_abi.h | 7 + drivers/gpu/drm/xe/xe_guc_capture.c | 572 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_ct.c | 2 + drivers/gpu/drm/xe/xe_guc_submit.c | 22 +- drivers/gpu/drm/xe/xe_guc_submit.h | 3 + 5 files changed, 605 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/abi/guc_actions_abi.h +7 -0
@@ -182,6 +182,13 @@ enum xe_guc_sleep_state_status {#define GUC_LOG_CONTROL_VERBOSITY_MASK (0xF << GUC_LOG_CONTROL_VERBOSITY_SHIFT)#define GUC_LOG_CONTROL_DEFAULT_LOGGING (1 << 8) +enum intel_guc_state_capture_event_status { +XE_GUC_STATE_CAPTURE_EVENT_STATUS_SUCCESS =0x0 , +XE_GUC_STATE_CAPTURE_EVENT_STATUS_NOSPACE =0x1 , +}; + +#define XE_GUC_STATE_CAPTURE_EVENT_STATUS_MASK 0x000000FF +#define XE_GUC_TLB_INVAL_TYPE_SHIFT 0#define XE_GUC_TLB_INVAL_MODE_SHIFT 8/* Flush PPC or SMRO caches along with TLB invalidation request */
drivers/gpu/drm/xe/xe_guc_capture.c +572 -0
578 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_ct.c +2 -0
@@ -948,6 +948,8 @@ static int process_g2h_msg(struct xe_guc_ct *ct, u32 *msg, u32 len)/* Selftest only at the moment */ break ;case XE_GUC_ACTION_STATE_CAPTURE_NOTIFICATION : + ret =xe_guc_error_capture_handler (guc, payload, adj_len); +break ;case XE_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE :/* FIXME: Handle this */ break ;
drivers/gpu/drm/xe/xe_guc_submit.c +21 -1
@@ -23,7 +23,9 @@#include "xe_force_wake.h" #include "xe_gpu_scheduler.h" #include "xe_gt.h" +#include "xe_gt_printk.h" #include "xe_guc.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_exec_queue_types.h" #include "xe_guc_submit_types.h"
@@ -760,7 +762,7 @@ static void guc_exec_queue_free_job(struct drm_sched_job *drm_job)xe_sched_job_put (job); } -static int guc_read_stopped (struct xe_guc *guc) +int guc_read_stopped (struct xe_guc *guc) {return atomic_read (&guc->submission_state.stopped); }
@@ -1702,6 +1704,24 @@ int xe_guc_exec_queue_reset_handler(struct xe_guc *guc, u32 *msg, u32 len)return 0 ; } +int xe_guc_error_capture_handler (struct xe_guc *guc,u32 *msg,u32 len) +{ +u32 status; + +if (unlikely (len !=1 )) { +xe_gt_dbg (guc_to_gt (guc),"Invalid length %u" , len); +return -EPROTO ; + } + + status = msg[0 ] &XE_GUC_STATE_CAPTURE_EVENT_STATUS_MASK ; +if (status ==XE_GUC_STATE_CAPTURE_EVENT_STATUS_NOSPACE ) +xe_gt_warn (guc_to_gt (guc),"G2H-Error capture no space" ); + +xe_guc_capture_process (guc); + +return 0 ; +} +int xe_guc_exec_queue_memory_cat_error_handler (struct xe_guc *guc,u32 *msg,u32 len) {
drivers/gpu/drm/xe/xe_guc_submit.h +3 -0
@@ -19,12 +19,15 @@ void xe_guc_submit_reset_wait(struct xe_guc *guc);int xe_guc_submit_stop (struct xe_guc *guc);int xe_guc_submit_start (struct xe_guc *guc); +int guc_read_stopped (struct xe_guc *guc); +int xe_guc_sched_done_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_deregister_done_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_reset_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_memory_cat_error_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_reset_failure_handler (struct xe_guc *guc,u32 *msg,u32 len); +int xe_guc_error_capture_handler (struct xe_guc *guc,u32 *msg,u32 len);struct xe_guc_submit_exec_queue_snapshot *xe_guc_exec_queue_snapshot_capture (struct xe_exec_queue *q);
Signature · 1 line
2.34.1
Please ignore this patch
The patch is for Xe upstream, sent to wrong ML.
Regards,
Zhanjun
Quoted 58 lines · Zhanjun Dong
Port GuC based register capture for error capture from i915 to Xe.
There are 3 parts in this commit:
. Prepare for capture registers
There is a bo create at guc ads init time, that is very early and engine map is not ready, make it hard to calculate the capture buffer size, new function created for worst case size caluation. Other than that, this part basically follows the i915 design.
. Process capture notification message
Basically follows i915 design
. Sysfs command process.
Xe switched to devcoredump, adopted command line process with captured list.Signed-off-by Zhanjun Dong <[email protected]>Zhanjun Dong (9):
drm/xe/guc: Add register defines for GuC based register capture drm/xe/guc: Expose dss per group for GuC error capture drm/xe/guc: Update GuC ADS size for error capture drm/xe/guc: AddXE_LPsteered register lists drm/xe/guc: Add capture size check in GuC log buffer drm/xe/guc: Check sizing ofguc_captureoutput drm/xe/guc: Extract GuC error capture lists on G2H notification drm/xe/guc: Pre-allocate output nodes for extraction drm/xe/guc: Plumb GuC-capture into dev coredumpdrivers/gpu/drm/xe/Kconfig | 11 + drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/abi/guc_actions_abi.h | 7 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 + drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 + drivers/gpu/drm/xe/xe_gt_mcr.c | 4 +- drivers/gpu/drm/xe/xe_gt_mcr.h | 1 + drivers/gpu/drm/xe/xe_gt_printk.h | 3 + drivers/gpu/drm/xe/xe_gt_topology.c | 3 - drivers/gpu/drm/xe/xe_guc.c | 7 + drivers/gpu/drm/xe/xe_guc_ads.c | 255 +++- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 1404 ++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 35 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 225 ++++ drivers/gpu/drm/xe/xe_guc_ct.c | 2 + drivers/gpu/drm/xe/xe_guc_fwif.h | 68 ++ drivers/gpu/drm/xe/xe_guc_log.c | 179 +++ drivers/gpu/drm/xe/xe_guc_log.h | 15 + drivers/gpu/drm/xe/xe_guc_log_types.h | 26 + drivers/gpu/drm/xe/xe_guc_submit.c | 22 +- drivers/gpu/drm/xe/xe_guc_submit.h | 3 + drivers/gpu/drm/xe/xe_guc_types.h | 2 + drivers/gpu/drm/xe/xe_hw_engine.c | 73 +- drivers/gpu/drm/xe/xe_hw_engine_types.h | 106 +- 25 files changed, 2355 insertions(+), 131 deletions(-)create mode 100644
drivers/gpu/drm/xe/xe_guc_capture.ccreate mode 100644drivers/gpu/drm/xe/xe_guc_capture.hcreate mode 100644drivers/gpu/drm/xe/xe_guc_capture_fwif.h
Patchwork
CI✗ Fi.CI.BUILD: failure for drm/xe/guc: Extract GuC error capture lists on G2H notification
In reply to Zhanjun Dong== Series Details ==
== Series Details ==
Series: drm/xe/guc: Extract GuC error capture lists on G2H notification
URL : https://patchwork.freedesktop.org/series/128837/
State : failure
== Summary ==
Error: patch https://patchwork.freedesktop.org/api/1.0/series/128837/revisions/1/mbox/ not applied
Applying: drm/xe/guc: Update GuC ADS size for error capture
error: sha1 information is lacking or useless (drivers/gpu/drm/xe/xe_guc_capture.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/xe/guc: Update GuC ADS size for error capture
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced