From: Matt Roper <matthew.d.roper@intel.com>
To: Gustavo Sousa <gustavo.sousa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 4/6] drm/xe/rtp: Extract rule_match_item()
Date: Tue, 10 Feb 2026 14:24:25 -0800 [thread overview]
Message-ID: <20260210222425.GH4694@mdroper-desk1.amr.corp.intel.com> (raw)
In-Reply-To: <20260114-rtp-rule-parser-v1-4-fa9029586bff@intel.com>
On Wed, Jan 14, 2026 at 07:49:54PM -0300, Gustavo Sousa wrote:
> The currently logic in rule_matches() mixes individual rule matching
> with the logic necessary for handling OR operations. Let's simplify
> rule_matches() to focus on the latter by extracting individual rule
> matching into a separate function called rule_match_item().
>
> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> ---
> drivers/gpu/drm/xe/xe_rtp.c | 205 +++++++++++++++++++-------------------------
> 1 file changed, 88 insertions(+), 117 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> index e0bed5ac1369..dabc2e74e2ce 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.c
> +++ b/drivers/gpu/drm/xe/xe_rtp.c
> @@ -30,6 +30,90 @@ static bool has_samedia(const struct xe_device *xe)
> return xe->info.media_verx100 >= 1300;
> }
>
> +static bool rule_match_item(const struct xe_device *xe,
> + struct xe_gt *gt,
> + struct xe_hw_engine *hwe,
> + const struct xe_rtp_rule *r)
> +{
> + switch (r->match_type) {
> + case XE_RTP_MATCH_PLATFORM:
> + return xe->info.platform == r->platform;
> + case XE_RTP_MATCH_SUBPLATFORM:
> + return xe->info.platform == r->platform &&
> + xe->info.subplatform == r->subplatform;
> + case XE_RTP_MATCH_GRAPHICS_VERSION:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.graphics_verx100 == r->ver_start &&
> + (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.graphics_verx100 >= r->ver_start &&
> + xe->info.graphics_verx100 <= r->ver_end &&
> + (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_GRAPHICS_VERSION_ANY_GT:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.graphics_verx100 == r->ver_start;
> + case XE_RTP_MATCH_GRAPHICS_STEP:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.step.graphics >= r->step_start &&
> + xe->info.step.graphics < r->step_end &&
> + (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_MEDIA_VERSION:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.media_verx100 == r->ver_start &&
> + (!has_samedia(xe) || xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_MEDIA_VERSION_RANGE:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.media_verx100 >= r->ver_start &&
> + xe->info.media_verx100 <= r->ver_end &&
> + (!has_samedia(xe) || xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_MEDIA_STEP:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.step.media >= r->step_start &&
> + xe->info.step.media < r->step_end &&
> + (!has_samedia(xe) || xe_gt_is_media_type(gt));
> + case XE_RTP_MATCH_MEDIA_VERSION_ANY_GT:
> + if (drm_WARN_ON(&xe->drm, !gt))
> + return false;
> +
> + return xe->info.media_verx100 == r->ver_start;
> + case XE_RTP_MATCH_INTEGRATED:
> + return !xe->info.is_dgfx;
> + case XE_RTP_MATCH_DISCRETE:
> + return xe->info.is_dgfx;
> + case XE_RTP_MATCH_ENGINE_CLASS:
> + if (drm_WARN_ON(&xe->drm, !hwe))
> + return false;
> +
> + return hwe->class == r->engine_class;
> + case XE_RTP_MATCH_NOT_ENGINE_CLASS:
> + if (drm_WARN_ON(&xe->drm, !hwe))
> + return false;
> +
> + return hwe->class != r->engine_class;
> + case XE_RTP_MATCH_FUNC:
> + return r->match_func(xe, gt, hwe);
> + default:
> + drm_warn(&xe->drm, "Invalid RTP match %u\n",
> + r->match_type);
> + return false;
> + }
> +}
> +
> static bool rule_matches_with_err(const struct xe_device *xe,
> struct xe_gt *gt,
> struct xe_hw_engine *hwe,
> @@ -39,133 +123,22 @@ static bool rule_matches_with_err(const struct xe_device *xe,
> {
> const struct xe_rtp_rule *r;
> unsigned int i, rcount = 0;
> - bool match;
>
> if (err)
> *err = 0;
>
> for (r = rules, i = 0; i < n_rules; r = &rules[++i]) {
> - switch (r->match_type) {
> - case XE_RTP_MATCH_OR:
> + if (r->match_type == XE_RTP_MATCH_OR)
> /*
> * This is only reached if a complete set of
> * rules passed or none were evaluated. For both cases,
> * shortcut the other rules and return the proper value.
> */
> goto done;
> - case XE_RTP_MATCH_PLATFORM:
> - match = xe->info.platform == r->platform;
> - break;
> - case XE_RTP_MATCH_SUBPLATFORM:
> - match = xe->info.platform == r->platform &&
> - xe->info.subplatform == r->subplatform;
> - break;
> - case XE_RTP_MATCH_GRAPHICS_VERSION:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.graphics_verx100 == r->ver_start &&
> - (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.graphics_verx100 >= r->ver_start &&
> - xe->info.graphics_verx100 <= r->ver_end &&
> - (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_GRAPHICS_VERSION_ANY_GT:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.graphics_verx100 == r->ver_start;
> - break;
> - case XE_RTP_MATCH_GRAPHICS_STEP:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.step.graphics >= r->step_start &&
> - xe->info.step.graphics < r->step_end &&
> - (!has_samedia(xe) || !xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_MEDIA_VERSION:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.media_verx100 == r->ver_start &&
> - (!has_samedia(xe) || xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_MEDIA_VERSION_RANGE:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.media_verx100 >= r->ver_start &&
> - xe->info.media_verx100 <= r->ver_end &&
> - (!has_samedia(xe) || xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_MEDIA_STEP:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.step.media >= r->step_start &&
> - xe->info.step.media < r->step_end &&
> - (!has_samedia(xe) || xe_gt_is_media_type(gt));
> - break;
> - case XE_RTP_MATCH_MEDIA_VERSION_ANY_GT:
> - if (drm_WARN_ON(&xe->drm, !gt)) {
> - match = false;
> - break;
> - }
> -
> - match = xe->info.media_verx100 == r->ver_start;
> - break;
> - case XE_RTP_MATCH_INTEGRATED:
> - match = !xe->info.is_dgfx;
> - break;
> - case XE_RTP_MATCH_DISCRETE:
> - match = xe->info.is_dgfx;
> - break;
> - case XE_RTP_MATCH_ENGINE_CLASS:
> - if (drm_WARN_ON(&xe->drm, !hwe)) {
> - match = false;
> - break;
> - }
> -
> - match = hwe->class == r->engine_class;
> - break;
> - case XE_RTP_MATCH_NOT_ENGINE_CLASS:
> - if (drm_WARN_ON(&xe->drm, !hwe)) {
> - match = false;
> - break;
> - }
> -
> - match = hwe->class != r->engine_class;
> - break;
> - case XE_RTP_MATCH_FUNC:
> - match = r->match_func(xe, gt, hwe);
> - break;
> - default:
> - drm_warn(&xe->drm, "Invalid RTP match %u\n",
> - r->match_type);
> - match = false;
> - }
>
> - if (!match) {
> + if (rule_match_item(xe, gt, hwe, r)) {
> + rcount++;
> + } else {
> /*
> * Advance rules until we find XE_RTP_MATCH_OR to check
> * if there's another set of conditions to check
> @@ -177,8 +150,6 @@ static bool rule_matches_with_err(const struct xe_device *xe,
> return false;
>
> rcount = 0;
> - } else {
> - rcount++;
> }
> }
>
>
> --
> 2.52.0
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
next prev parent reply other threads:[~2026-02-10 22:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 22:49 [PATCH 0/6] drm/xe/rtp: Miscellaneous improvements to rule matching Gustavo Sousa
2026-01-14 22:49 ` [PATCH 1/6] drm/xe/rtp: Write kunit test cases specific for " Gustavo Sousa
2026-01-14 22:57 ` Gustavo Sousa
2026-02-10 22:03 ` Matt Roper
2026-01-14 22:49 ` [PATCH 2/6] drm/xe/rtp: Drop rule matching cases from rtp_to_sr_cases and rtp_cases Gustavo Sousa
2026-02-10 22:06 ` Matt Roper
2026-01-14 22:49 ` [PATCH 3/6] drm/xe/rtp: Do not break parsing when missing context Gustavo Sousa
2026-02-10 22:20 ` Matt Roper
2026-04-29 19:45 ` Gustavo Sousa
2026-01-14 22:49 ` [PATCH 4/6] drm/xe/rtp: Extract rule_match_item() Gustavo Sousa
2026-02-10 22:24 ` Matt Roper [this message]
2026-01-14 22:49 ` [PATCH 5/6] drm/xe/rtp: Fully parse the ruleset Gustavo Sousa
2026-02-10 22:34 ` Matt Roper
2026-04-30 13:33 ` Gustavo Sousa
2026-01-14 22:49 ` [PATCH 6/6] drm/xe/rtp: Implement a structured parser for rule matching Gustavo Sousa
2026-01-14 22:56 ` ✗ CI.checkpatch: warning for drm/xe/rtp: Miscellaneous improvements to " Patchwork
2026-01-14 22:57 ` ✓ CI.KUnit: success " Patchwork
2026-01-14 23:30 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-15 4:53 ` ✗ Xe.CI.Full: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260210222425.GH4694@mdroper-desk1.amr.corp.intel.com \
--to=matthew.d.roper@intel.com \
--cc=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox