/* * Empty list to prevent warnings about unknown class/instance types * as not all class/instanace types have entries on all platforms.
*/ staticconststruct __guc_mmio_reg_descr empty_regs_list[] = {
};
/* 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;
/* 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(gen8_extregs); ++i) {
__fill_ext_reg(extarray, &gen8_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;
}
}
}
guc_dbg(guc, "capture found %d ext-regs.\n", num_tot_regs);
guc->capture->extlists = extlists;
}
/* * 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, lists);
return lists;
}
staticconstchar *
__stringify_type(u32 type)
{ switch (type) { case GUC_CAPTURE_LIST_TYPE_GLOBAL: return"Global"; case GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS: return"Class"; case GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE: return"Instance"; default: break;
}
return"unknown";
}
staticconstchar *
__stringify_engclass(u32 class)
{ switch (class) { case GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE: return"Render/Compute"; case GUC_CAPTURE_LIST_CLASS_VIDEO: return"Video"; case GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE: return"VideoEnhance"; case GUC_CAPTURE_LIST_CLASS_BLITTER: return"Blitter"; case GUC_CAPTURE_LIST_CLASS_GSC_OTHER: return"GSC-Other"; default: break;
}
/* * 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_engine(engine, 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;
/* * 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
staticvoid check_guc_capture_size(struct intel_guc *guc)
{ int min_size = guc_capture_output_min_size_est(guc); int spare_size = min_size * GUC_CAPTURE_OVERBUFFER_MULTIPLIER;
u32 buffer_size = intel_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: * INTEL_GUC_STATE_CAPTURE_EVENT_STATUS_NOSPACE.
*/ if (min_size < 0)
guc_warn(guc, "Failed to calculate error state capture buffer minimum size: %d!\n",
min_size); elseif (min_size > buffer_size)
guc_warn(guc, "Error state capture buffer maybe small: %d < %d\n",
buffer_size, min_size); elseif (spare_size > buffer_size)
guc_dbg(guc, "Error state capture buffer lacks spare size: %d < %d (min = %d)\n",
buffer_size, spare_size, min_size);
}
/* * KMD Init time flows: * -------------------- * --> alloc A: GuC input capture regs lists (registered to GuC via ADS). * intel_guc_ads acquires the register lists by calling * intel_guc_capture_list_size and intel_guc_capture_list_get 'n' times, * where n = 1 for global-reg-list + * num_engine_classes for class-reg-list + * num_engine_classes for instance-reg-list * (since all instances of the same engine-class type * have an identical engine-instance register-list). * ADS module also calls separately for PF vs VF. * * --> alloc B: GuC output capture buf (registered via guc_init_params(log_param)) * Size = #define CAPTURE_BUFFER_SIZE (warns if on too-small) * Note2: 'x 3' to hold multiple capture groups * * GUC Runtime notify capture: * -------------------------- * --> G2H STATE_CAPTURE_NOTIFICATION * L--> intel_guc_capture_process * L--> Loop through B (head..tail) and for each engine instance's * err-state-captured register-list we find, we alloc 'C': * --> alloc C: A capture-output-node structure that includes misc capture info along * with 3 register list dumps (global, engine-class and engine-instance) * This node is created from a pre-allocated list of blank nodes in * guc->capture->cachelist and populated with the error-capture * data from GuC and then it's added into guc->capture->outlist linked * list. This list is used for matchup and printout by i915_gpu_coredump * and err_print_gt, (when user invokes the error capture sysfs). * * GUC --> notify context reset: * ----------------------------- * --> G2H CONTEXT RESET * L--> guc_handle_context_reset --> i915_capture_error_state * L--> i915_gpu_coredump(..IS_GUC_CAPTURE) --> gt_record_engines * --> capture_engine(..IS_GUC_CAPTURE) * L--> intel_guc_capture_get_matching_node is where * detach C from internal linked list and add it into * intel_engine_coredump struct (if the context and * engine of the event notification matches a node * in the link list). * * User Sysfs / Debugfs * -------------------- * --> i915_gpu_coredump_copy_to_buffer-> * L--> err_print_to_sgl --> err_print_gt * L--> error_print_guc_captures * L--> intel_guc_capture_print_node prints the * register lists values of the attached node * on the error-engine-dump being reported. * L--> i915_reset_error_state ... -->__i915_gpu_coredump_free * L--> ... cleanup_gt --> * L--> intel_guc_capture_free_node returns the * capture-output-node back to the internal * cachelist for reuse. *
*/
/* * GuC's error-capture output is a ring buffer populated in a byte-stream fashion: * * The GuC Log buffer region for error-capture is managed like a ring buffer. * The GuC firmware dumps error capture logs into this ring in a byte-stream flow. * Additionally, as per the current and foreseeable future, all packed error- * capture output structures are dword aligned. * * That said, if the GuC firmware is in the midst of writing a structure that is larger * than one dword but the tail end of the err-capture buffer-region has lesser space left, * we would need to extract that structure one dword at a time straddled across the end, * onto the start of the ring. * * Below function, guc_capture_log_remove_dw is a helper for that. All callers of this * function would typically do a straight-up memcpy from the ring contents and will only * call this helper if their structure-extraction is straddling across the end of the * ring. GuC firmware does not add any padding. The reason for the no-padding is to ease * scalability for future expansion of output data types without requiring a redesign * of the flow controls.
*/ staticint
guc_capture_log_remove_dw(struct intel_guc *guc, struct __guc_capture_bufstate *buf,
u32 *dw)
{ int tries = 2; int avail = 0;
u32 *src_data;
if (!guc_capture_buf_cnt(buf)) return 0;
while (tries--) {
avail = guc_capture_buf_cnt_to_end(buf); if (avail >= sizeof(u32)) {
src_data = (u32 *)(buf->data + buf->rd);
*dw = *src_data;
buf->rd += 4; return 4;
} if (avail)
guc_dbg(guc, "Register capture log not dword aligned, skipping.\n");
buf->rd = 0;
}
/* * NOTE: At the end of driver operation, we must assume that we * have prealloc nodes in both the cachelist as well as outlist * if unclaimed error capture events occurred prior to shutdown.
*/
list_for_each_entry_safe(n, ntmp, &guc->capture->outlist, link)
guc_capture_delete_one_node(guc, n);
if (!list_empty(&guc->capture->cachelist)) { struct __guc_capture_parsed_output *n, *ntmp;
/* get first avail node from the cache list */
list_for_each_entry_safe(n, ntmp, &guc->capture->cachelist, link) {
found = n;
list_del(&n->link); break;
}
} else { struct __guc_capture_parsed_output *n, *ntmp;
/* traverse down and steal back the oldest node already allocated */
list_for_each_entry_safe(n, ntmp, &guc->capture->outlist, link) {
found = n;
} if (found)
list_del(&found->link);
} if (found)
guc_capture_init_node(guc, found);
new = guc_capture_get_prealloc_node(guc); if (!new) return NULL; if (!original) returnnew;
new->is_partial = original->is_partial;
/* copy reg-lists that we want to clone */ for (i = 0; i < GUC_CAPTURE_LIST_TYPE_MAX; ++i) { if (keep_reglist_mask & BIT(i)) {
GEM_BUG_ON(original->reginfo[i].num_regs >
guc->capture->max_mmio_per_node);
for (i = 0; i < PREALLOC_NODES_MAX_COUNT; ++i) {
node = guc_capture_alloc_one_node(guc); if (!node) {
guc_warn(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);
}
}
staticint
guc_get_max_reglist_count(struct intel_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;
}
staticvoid
guc_capture_create_prealloc_nodes(struct intel_guc *guc)
{ /* skip if we've already done the pre-alloc */ if (guc->capture->max_mmio_per_node) return;
i = guc_capture_buf_cnt(buf); if (!i) return -ENODATA; if (i % sizeof(u32)) {
guc_warn(guc, "Got mis-aligned register capture entries\n");
ret = -EIO; goto bailout;
}
while (numlists--) { if (guc_capture_log_get_data_hdr(guc, buf, &hdr)) {
ret = -EIO; break;
}
datatype = FIELD_GET(CAP_HDR_CAPTURE_TYPE, hdr.info); if (datatype > GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE) { /* unknown capture type - skip over to next capture set */
numregs = FIELD_GET(CAP_HDR_NUM_MMIOS, hdr.num_mmios); while (numregs--) { if (guc_capture_log_get_register(guc, buf, &tmp)) {
ret = -EIO; break;
}
} continue;
} elseif (node) { /* * Based on the current capture type and what we have so far, * decide if we should add the current node into the internal * linked list for match-up when i915_gpu_coredump calls later * (and alloc a blank node for the next set of reglists) * or continue with the same node or clone the current node * but only retain the global or class registers (such as the * case of dependent engine resets).
*/ if (datatype == GUC_CAPTURE_LIST_TYPE_GLOBAL) {
guc_capture_add_node_to_outlist(guc->capture, node);
node = NULL;
} elseif (datatype == GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS &&
node->reginfo[GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS].num_regs) { /* Add to list, clone node and duplicate global list */
guc_capture_add_node_to_outlist(guc->capture, node);
node = guc_capture_clone_node(guc, node,
GCAP_PARSED_REGLIST_INDEX_GLOBAL);
} elseif (datatype == GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE &&
node->reginfo[GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE].num_regs) { /* Add to list, clone node and duplicate global + class lists */
guc_capture_add_node_to_outlist(guc->capture, node);
node = guc_capture_clone_node(guc, node,
(GCAP_PARSED_REGLIST_INDEX_GLOBAL |
GCAP_PARSED_REGLIST_INDEX_ENGCLASS));
}
}
if (!node) {
node = guc_capture_get_prealloc_node(guc); if (!node) {
ret = -ENOMEM; break;
} if (datatype != GUC_CAPTURE_LIST_TYPE_GLOBAL)
guc_dbg(guc, "Register capture missing global dump: %08x!\n",
datatype);
}
node->is_partial = is_partial;
node->reginfo[datatype].vfid = FIELD_GET(CAP_HDR_CAPTURE_VFID, hdr.owner); switch (datatype) { case GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE:
node->eng_class = FIELD_GET(CAP_HDR_ENGINE_CLASS, hdr.info);
node->eng_inst = FIELD_GET(CAP_HDR_ENGINE_INSTANCE, hdr.info);
node->lrca = hdr.lrca;
node->guc_id = hdr.guc_id; break; case GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS:
node->eng_class = FIELD_GET(CAP_HDR_ENGINE_CLASS, hdr.info); break; default: break;
}
numregs = FIELD_GET(CAP_HDR_NUM_MMIOS, hdr.num_mmios); if (numregs > guc->capture->max_mmio_per_node) {
guc_dbg(guc, "Register capture list extraction clipped by prealloc!\n");
numregs = guc->capture->max_mmio_per_node;
}
node->reginfo[datatype].num_regs = numregs;
regs = node->reginfo[datatype].regs;
i = 0; while (numregs--) { if (guc_capture_log_get_register(guc, buf, ®s[i++])) {
ret = -EIO; break;
}
}
}
bailout: if (node) { /* If we have data, add to linked list for match-up when i915_gpu_coredump calls */ for (i = GUC_CAPTURE_LIST_TYPE_GLOBAL; i < GUC_CAPTURE_LIST_TYPE_MAX; ++i) { if (node->reginfo[i].regs) {
guc_capture_add_node_to_outlist(guc->capture, node);
node = NULL; break;
}
} if (node) /* else return it back to cache list */
guc_capture_add_node_to_cachelist(guc->capture, node);
} return ret;
}
/* * Make a copy of the state structure, inside GuC log buffer * (which is uncached mapped), on the stack to avoid reading * from it multiple times.
*/
memcpy(&log_buf_state_local, log_buf_state, sizeof(struct guc_log_buffer_state));
buffer_size = intel_guc_get_log_buffer_size(&guc->log, GUC_CAPTURE_LOG_BUFFER);
read_offset = log_buf_state_local.read_ptr;
write_offset = log_buf_state_local.sampled_write_ptr;
full_count = log_buf_state_local.buffer_full_cnt;
if (!uc->reset_in_progress) { do {
ret = guc_capture_extract_reglists(guc, &buf);
} while (ret >= 0);
}
/* Update the state of log buffer err-cap state */
log_buf_state->read_ptr = write_offset;
log_buf_state->flush_to_file = 0;
__guc_capture_flushlog_complete(guc);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.