Commit cefeb763 authored by Lucas De Marchi's avatar Lucas De Marchi Committed by Rodrigo Vivi

drm/xe/rtp: Allow to track active workarounds

Add the metadata in struct xe_rtp_process_ctx, to be set by
xe_rtp_process_ctx_enable_active_tracking(), so rtp knows how to mark
the active entries while processing the table. This can be used by the
WA infra to record what are the active workarounds.
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20230526164358.86393-6-lucas.demarchi@intel.comSigned-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 91042671
...@@ -112,7 +112,7 @@ static void rtp_add_sr_entry(const struct xe_rtp_action *action, ...@@ -112,7 +112,7 @@ static void rtp_add_sr_entry(const struct xe_rtp_action *action,
xe_reg_sr_add(sr, &sr_entry); xe_reg_sr_add(sr, &sr_entry);
} }
static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry, static bool rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
struct xe_device *xe, struct xe_gt *gt, struct xe_device *xe, struct xe_gt *gt,
struct xe_hw_engine *hwe, struct xe_reg_sr *sr) struct xe_hw_engine *hwe, struct xe_reg_sr *sr)
{ {
...@@ -121,7 +121,7 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry, ...@@ -121,7 +121,7 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
unsigned int i; unsigned int i;
if (!rule_matches(xe, gt, hwe, entry)) if (!rule_matches(xe, gt, hwe, entry))
return; return false;
for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) { for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
if ((entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) || if ((entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) ||
...@@ -132,6 +132,8 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry, ...@@ -132,6 +132,8 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
rtp_add_sr_entry(action, gt, mmio_base, sr); rtp_add_sr_entry(action, gt, mmio_base, sr);
} }
return true;
} }
static void rtp_get_context(struct xe_rtp_process_ctx *ctx, static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
...@@ -153,6 +155,38 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx, ...@@ -153,6 +155,38 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
}; };
} }
/**
* xe_rtp_process_ctx_enable_active_tracking - Enable tracking of active entries
*
* Set additional metadata to track what entries are considered "active", i.e.
* their rules match the condition. Bits are never cleared: entries with
* matching rules set the corresponding bit in the bitmap.
*
* @ctx: The context for processing the table
* @active_entries: bitmap to store the active entries
* @n_entries: number of entries to be processed
*/
void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
unsigned long *active_entries,
size_t n_entries)
{
ctx->active_entries = active_entries;
ctx->n_entries = n_entries;
}
static void rtp_mark_active(struct xe_device *xe,
struct xe_rtp_process_ctx *ctx,
unsigned int bit)
{
if (!ctx->active_entries)
return;
if (drm_WARN_ON(&xe->drm, bit > ctx->n_entries))
return;
bitmap_set(ctx->active_entries, bit, 1);
}
/** /**
* xe_rtp_process_to_sr - Process all rtp @entries, adding the matching ones to * xe_rtp_process_to_sr - Process all rtp @entries, adding the matching ones to
* the save-restore argument. * the save-restore argument.
...@@ -178,15 +212,21 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx, ...@@ -178,15 +212,21 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
rtp_get_context(ctx, &hwe, &gt, &xe); rtp_get_context(ctx, &hwe, &gt, &xe);
for (entry = entries; entry && entry->name; entry++) { for (entry = entries; entry && entry->name; entry++) {
bool match = false;
if (entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) { if (entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) {
struct xe_hw_engine *each_hwe; struct xe_hw_engine *each_hwe;
enum xe_hw_engine_id id; enum xe_hw_engine_id id;
for_each_hw_engine(each_hwe, gt, id) for_each_hw_engine(each_hwe, gt, id)
rtp_process_one_sr(entry, xe, gt, each_hwe, sr); match |= rtp_process_one_sr(entry, xe, gt,
each_hwe, sr);
} else { } else {
rtp_process_one_sr(entry, xe, gt, hwe, sr); match = rtp_process_one_sr(entry, xe, gt, hwe, sr);
} }
if (match)
rtp_mark_active(xe, ctx, entry - entries);
} }
} }
EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr); EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
......
...@@ -359,6 +359,10 @@ struct xe_reg_sr; ...@@ -359,6 +359,10 @@ struct xe_reg_sr;
struct xe_hw_engine *: (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE }, \ struct xe_hw_engine *: (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE }, \
struct xe_gt *: (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT }) struct xe_gt *: (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT })
void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
unsigned long *active_entries,
size_t n_entries);
void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx, void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
const struct xe_rtp_entry_sr *entries, const struct xe_rtp_entry_sr *entries,
struct xe_reg_sr *sr); struct xe_reg_sr *sr);
......
...@@ -106,6 +106,8 @@ struct xe_rtp_process_ctx { ...@@ -106,6 +106,8 @@ struct xe_rtp_process_ctx {
struct xe_hw_engine *hwe; struct xe_hw_engine *hwe;
}; };
enum xe_rtp_process_type type; enum xe_rtp_process_type type;
unsigned long *active_entries;
size_t n_entries;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment