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 6/7] drm/xe/rtp: Fully parse the ruleset
Date: Thu, 30 Apr 2026 17:20:07 -0300 [thread overview]
Message-ID: <20260430-rtp-rule-parser-v2-6-157e98b4ab51@intel.com> (raw)
In-Reply-To: <20260430-rtp-rule-parser-v2-0-157e98b4ab51@intel.com>
The function rule_matches() short-circuits evaluation of the implicit
conjunctions (each substring of rules not containing OR) and the
explicit disjunctions (implicit conjunctions joined by OR). In other
words:
- in a conjunction, once a rule evaluate to false, we skip to the next
OR (if any) to evaluate the next conjunction;
- in a disjunction, once a conjunction evaluates to true, we return
true and skip evaluating all the remaining rules.
While this behavior results in a correct logical value, due to how the
"OR" short-circuiting is implemented, it has the side-effect that rule
set does not get fully "parsed", allowing incomplete constructs like
(rule1, OR) to evaluate to true when rule1 is true. We should treat
such constructs as invalid and treat them the same way we do for stuff
like (OR, rule1).
As such, update rule_matches() to "parse" the whole rule set, and that
while keeping the short-circuit aspect of evaluation. With that, we can
fix the FIXME test cases that cover that behavior.
v2:
- Do not change short-circuit *evaluation* behavior. (Matt)
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
drivers/gpu/drm/xe/tests/xe_rtp_test.c | 6 ++----
drivers/gpu/drm/xe/xe_rtp.c | 26 +++++++++++++-------------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
index e009c1243b7c..3429c5d1b5b6 100644
--- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
@@ -186,8 +186,7 @@ static const struct rtp_rules_test_case rtp_rules_cases[] = {
{
.name = "yes-or",
.expected_match = true,
- /* FIXME: The parser should raise an error here. */
- .expected_err = 0,
+ .expected_err = -EINVAL,
XE_RTP_RULES(FUNC(match_yes), OR),
},
{
@@ -205,8 +204,7 @@ static const struct rtp_rules_test_case rtp_rules_cases[] = {
{
.name = "yes-or-or-no",
.expected_match = true,
- /* FIXME: The parser should raise an error here. */
- .expected_err = 0,
+ .expected_err = -EINVAL,
XE_RTP_RULES(FUNC(match_yes), OR, OR, FUNC(match_no)),
},
{
diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index c49f80f398af..976a2e1f5592 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -129,6 +129,7 @@ static bool rule_matches_with_err(const struct xe_device *xe,
{
const struct xe_rtp_rule *r;
unsigned int i, rcount = 0;
+ bool short_circuit_or = false;
if (err)
*err = 0;
@@ -143,13 +144,16 @@ static bool rule_matches_with_err(const struct xe_device *xe,
/*
* This is only reached if a complete conjunction of
- * rules passed, in which case we shortcut the other
- * rules and return true.
+ * rules passed, in which case we short-circuit rule
+ * evaluation, but still keep parsing to find any syntax
+ * errors.
*/
- return true;
+ short_circuit_or = true;
+ rcount = 0;
+ continue;
}
- if (rule_match_item(xe, gt, hwe, r)) {
+ if (short_circuit_or || rule_match_item(xe, gt, hwe, r)) {
rcount++;
} else {
/*
@@ -166,16 +170,12 @@ static bool rule_matches_with_err(const struct xe_device *xe,
}
}
- if (drm_WARN_ON(&xe->drm, !rcount))
- goto error;
-
- return true;
-
-error:
- if (err)
- *err = -EINVAL;
+ if (drm_WARN_ON(&xe->drm, !rcount)) {
+ if (err)
+ *err = -EINVAL;
+ }
- return false;
+ return short_circuit_or || rcount;
}
static bool rule_matches(const struct xe_device *xe,
--
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 ` [PATCH v2 4/7] drm/xe/rtp: Do not break parsing when missing context Gustavo Sousa
2026-04-30 20:20 ` [PATCH v2 5/7] drm/xe/rtp: Extract rule_match_item() Gustavo Sousa
2026-04-30 20:20 ` Gustavo Sousa [this message]
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-6-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