]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/xe/rtp: Implement a structured parser for rule matching
authorGustavo Sousa <gustavo.sousa@intel.com>
Fri, 22 May 2026 08:45:22 +0000 (05:45 -0300)
committerGustavo Sousa <gustavo.sousa@intel.com>
Fri, 22 May 2026 13:52:29 +0000 (10:52 -0300)
commitdf07911cb72dabebec3dd18d94c33f9ced74c3d6
tree49660be7580d5bf9b4529ad0765fb07afa7b85cd
parent0da9ab6c4e12e66dbd2e8f54481662225a79b7f5
drm/xe/rtp: Implement a structured parser for rule matching

The current unwritten grammar for RTP rules is as follows:

          rules = disjunction;
    disjunction = conjunction, { "OR", conjunction };
    conjunction = single_rule, { single_rule };
        (* the AND operator is implicit *)
    single_rule = ? GRAPHICS_VERSION(...), MEDIA_VERSION(...),
                    FUNC(...), etc ?

While rule_matches() currently works for the grammar above, it doesn't
easily resemble it.  Let's replace it with an implementation that is
structured in a way to resemble the grammar.

Such a new implementation, although a bit more verbose, is arguably
easier to reason about and to adapt to any extension we do to the
grammer in the future.

Also take this opportunity to update the kernel-doc for XE_RTP_RULES()
to include the grammar, so that it is not unwritten anymore.

v2:
  - Include the grammar in the code documentation. (Matt)

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Violet Monti <violet.monti@intel.com>
Link: https://patch.msgid.link/20260522-rtp-rule-parser-v3-7-0c51039899f4@intel.com
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
drivers/gpu/drm/xe/xe_rtp.c
drivers/gpu/drm/xe/xe_rtp.h