drm/xe/mcr: Extract reg_in_steering_type_ranges()

The logic to check if a register falls within one of the ranges for a
steering type is already duplicated in
xe_gt_mcr_get_nonterminated_steering().  We will also want to use that
same logic in another upcoming function.  Let's factor out that logic
and put it into a function named reg_in_steering_type_ranges().

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patch.msgid.link/20260514-rtp-mcr-check-v3-6-30dd47855fee@intel.com
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
This commit is contained in:
Gustavo Sousa 2026-05-14 18:44:49 -03:00
parent 5f7266c3f3
commit cdf8489533

View File

@ -600,6 +600,20 @@ void xe_gt_mcr_set_implicit_defaults(struct xe_gt *gt)
}
}
static bool reg_in_steering_type_ranges(struct xe_gt *gt,
struct xe_reg reg,
int type)
{
if (!gt->steering[type].ranges)
return false;
for (int i = 0; gt->steering[type].ranges[i].end > 0; i++)
if (xe_mmio_in_range(&gt->mmio, &gt->steering[type].ranges[i], reg))
return true;
return false;
}
/*
* xe_gt_mcr_get_nonterminated_steering - find group/instance values that
* will steer a register to a non-terminated instance
@ -621,30 +635,21 @@ bool xe_gt_mcr_get_nonterminated_steering(struct xe_gt *gt,
u8 *group, u8 *instance)
{
const struct xe_reg reg = to_xe_reg(reg_mcr);
const struct xe_mmio_range *implicit_ranges;
for (int type = 0; type < IMPLICIT_STEERING; type++) {
if (!gt->steering[type].ranges)
continue;
if (reg_in_steering_type_ranges(gt, reg, type)) {
drm_WARN(&gt_to_xe(gt)->drm, !gt->steering[type].initialized,
"Uninitialized usage of MCR register %s/%#x\n",
xe_steering_types[type].name, reg.addr);
for (int i = 0; gt->steering[type].ranges[i].end > 0; i++) {
if (xe_mmio_in_range(&gt->mmio, &gt->steering[type].ranges[i], reg)) {
drm_WARN(&gt_to_xe(gt)->drm, !gt->steering[type].initialized,
"Uninitialized usage of MCR register %s/%#x\n",
xe_steering_types[type].name, reg.addr);
*group = gt->steering[type].group_target;
*instance = gt->steering[type].instance_target;
return true;
}
*group = gt->steering[type].group_target;
*instance = gt->steering[type].instance_target;
return true;
}
}
implicit_ranges = gt->steering[IMPLICIT_STEERING].ranges;
if (implicit_ranges)
for (int i = 0; implicit_ranges[i].end > 0; i++)
if (xe_mmio_in_range(&gt->mmio, &implicit_ranges[i], reg))
return false;
if (reg_in_steering_type_ranges(gt, reg, IMPLICIT_STEERING))
return false;
/*
* Not found in a steering table and not a register with implicit