From: Gustavo Sousa <gustavo.sousa@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Gustavo Sousa <gustavo.sousa@intel.com>,
Matt Roper <matthew.d.roper@intel.com>
Subject: [PATCH v2 4/7] drm/xe/rtp: Do not break parsing when missing context
Date: Thu, 30 Apr 2026 17:20:05 -0300 [thread overview]
Message-ID: <20260430-rtp-rule-parser-v2-4-157e98b4ab51@intel.com> (raw)
In-Reply-To: <20260430-rtp-rule-parser-v2-0-157e98b4ab51@intel.com>
With the current implementation, the RTP framework will cause parsing of
the rule set to be interrupted if one rule requires a context item (gt
or hwe) that is missing (i.e. when the value is NULL).
This is arguably a semantic error instead of a syntactic one, meaning
that RTP should not interrupt parsing the rules. With the current
behavior, we would miss detecting other errors that could appear in the
remaining rules and could also prevent valid rules joined by "OR" from
being evaluated.
Make sure that we do not stop parsing the rule set when detecting
missing context and let's add rtp_rules_test_cases to reflect that.
v2:
- Add "missing-context" in the test case names to indicate that those
are about rules that are missing the necessary context. (Matt)
- Rebase: treat the new match type XE_RTP_MATCH_PLATFORM_STEP in the
same way when the platform is missing step information.
Reviewed-by: Matt Roper <matthew.d.roper@intel.com> # v1
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
drivers/gpu/drm/xe/tests/xe_rtp_test.c | 28 +++++++++++++++
drivers/gpu/drm/xe/xe_rtp.c | 66 ++++++++++++++++++++++------------
2 files changed, 72 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
index 5e0afde9eab4..e009c1243b7c 100644
--- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
@@ -215,6 +215,34 @@ static const struct rtp_rules_test_case rtp_rules_cases[] = {
.expected_err = -EINVAL,
XE_RTP_RULES(FUNC(match_no), OR, OR, FUNC(match_no)),
},
+
+ /* No match because hwe is NULL. */
+ {
+ .name = "missing-context-engine-class",
+ .expected_match = false,
+ XE_RTP_RULES(ENGINE_CLASS(RENDER)),
+ },
+
+ /*
+ * Missing context (hwe==NULL) does not cause parsing to stop, hence we
+ * expect a match.
+ */
+ {
+ .name = "missing-context-engine-class-or-yes",
+ .expected_match = true,
+ XE_RTP_RULES(ENGINE_CLASS(RENDER), OR, FUNC(match_yes)),
+ },
+
+ /*
+ * Missing context (hwe==NULL) does not cause parsing to stop, hence we
+ * expect a syntax error.
+ */
+ {
+ .name = "missing-context-engine-class-or-or-yes",
+ .expected_match = true,
+ .expected_err = -EINVAL,
+ XE_RTP_RULES(ENGINE_CLASS(RENDER), OR, OR, FUNC(match_yes)),
+ },
};
static void xe_rtp_rules_tests(struct kunit *test)
diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 299fa4209a26..df72b456ab16 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -67,67 +67,85 @@ static bool rule_matches_with_err(const struct xe_device *xe,
xe->info.subplatform == r->subplatform;
break;
case XE_RTP_MATCH_PLATFORM_STEP:
- if (drm_WARN_ON(&xe->drm, xe->info.step.platform == STEP_NONE))
- goto error;
+ if (drm_WARN_ON(&xe->drm, xe->info.step.platform == STEP_NONE)) {
+ match = false;
+ break;
+ }
match = xe->info.step.platform >= r->step_start &&
xe->info.step.platform < r->step_end;
break;
case XE_RTP_MATCH_GRAPHICS_VERSION:
- if (drm_WARN_ON(&xe->drm, !gt))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ 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))
- goto error;
+ if (drm_WARN_ON(&xe->drm, !gt)) {
+ match = false;
+ break;
+ }
match = xe->info.media_verx100 == r->ver_start;
break;
@@ -138,14 +156,18 @@ static bool rule_matches_with_err(const struct xe_device *xe,
match = xe->info.is_dgfx;
break;
case XE_RTP_MATCH_ENGINE_CLASS:
- if (drm_WARN_ON(&xe->drm, !hwe))
- goto error;
+ 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))
- goto error;
+ if (drm_WARN_ON(&xe->drm, !hwe)) {
+ match = false;
+ break;
+ }
match = hwe->class != r->engine_class;
break;
--
2.53.0
next prev parent reply other threads:[~2026-04-30 20:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 20:20 [PATCH v2 0/7] drm/xe/rtp: Miscellaneous improvements to rule matching Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 1/7] drm/xe/rtp: Write kunit test cases specific for " Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 2/7] drm/xe/rtp: Drop rule matching cases from rtp_to_sr_cases and rtp_cases Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 3/7] drm/xe/rtp: Don't short-circuit to false in or-yes case Gustavo Sousa
2026-04-30 20:20 ` Gustavo Sousa [this message]
2026-04-30 20:20 ` [PATCH v2 5/7] drm/xe/rtp: Extract rule_match_item() Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 6/7] drm/xe/rtp: Fully parse the ruleset Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 7/7] drm/xe/rtp: Implement a structured parser for rule matching Gustavo Sousa
2026-04-30 21:02 ` ✗ CI.checkpatch: warning for drm/xe/rtp: Miscellaneous improvements to rule matching (rev2) Patchwork
2026-04-30 21:03 ` ✓ CI.KUnit: success " Patchwork
2026-04-30 21:59 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-01 9:25 ` ✗ 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=20260430-rtp-rule-parser-v2-4-157e98b4ab51@intel.com \
--to=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.d.roper@intel.com \
/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