From: Lucas De Marchi <lucas.demarchi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
Stuart Summers <stuart.summers@intel.com>,
Matt Roper <matthew.d.roper@intel.com>,
Riana Tauro <riana.tauro@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v3 3/6] drm/xe/configfs: Extract function to parse engine
Date: Fri, 5 Sep 2025 22:50:31 -0700 [thread overview]
Message-ID: <20250905-wa-bb-cmds-v3-3-3da2b7bdc73e@intel.com> (raw)
In-Reply-To: <20250905-wa-bb-cmds-v3-0-3da2b7bdc73e@intel.com>
Move the part that copies the engine to a local buffer so it can be
shared in future for other configfs attributes parsing an engine.
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/xe_configfs.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
index acdabb3a6b50d..d487c0e0b7ab9 100644
--- a/drivers/gpu/drm/xe/xe_configfs.c
+++ b/drivers/gpu/drm/xe/xe_configfs.c
@@ -283,24 +283,34 @@ static bool lookup_engine_mask(const char *pattern, u64 *mask)
return false;
}
+static int parse_engine(const char *s, const char *end_chars, u64 *mask)
+{
+ char buf[MAX_ENGINE_CLASS_CHARS + MAX_ENGINE_INSTANCE_CHARS + 1];
+ size_t len;
+
+ len = strcspn(s, end_chars);
+ if (len >= sizeof(buf))
+ return -EINVAL;
+
+ memcpy(buf, s, len);
+ buf[len] = '\0';
+
+ if (!lookup_engine_mask(buf, mask))
+ return -ENOENT;
+
+ return len;
+}
+
static ssize_t engines_allowed_store(struct config_item *item, const char *page,
size_t len)
{
struct xe_config_group_device *dev = to_xe_config_group_device(item);
- size_t patternlen, p;
+ ssize_t patternlen, p;
u64 mask, val = 0;
for (p = 0; p < len; p += patternlen + 1) {
- char buf[MAX_ENGINE_CLASS_CHARS + MAX_ENGINE_INSTANCE_CHARS + 1];
-
- patternlen = strcspn(page + p, ",\n");
- if (patternlen >= sizeof(buf))
- return -EINVAL;
-
- memcpy(buf, page + p, patternlen);
- buf[patternlen] = '\0';
-
- if (!lookup_engine_mask(buf, &mask))
+ patternlen = parse_engine(page + p, ",\n", &mask);
+ if (patternlen < 0)
return -EINVAL;
val |= mask;
--
2.50.1
next prev parent reply other threads:[~2025-09-06 5:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-06 5:50 [PATCH v3 0/6] drm/xe: Add user commands to WA BB via configfs Lucas De Marchi
2025-09-06 5:50 ` [PATCH v3 1/6] drm/xe: Update workaround documentation Lucas De Marchi
2025-09-06 5:50 ` [PATCH v3 2/6] drm/xe/configfs: Fix documentation warning Lucas De Marchi
2025-09-06 5:50 ` Lucas De Marchi [this message]
2025-09-06 5:50 ` [PATCH v3 4/6] drm/xe/configfs: Allow to select by class only Lucas De Marchi
2025-09-09 10:27 ` Raag Jadav
2025-09-09 12:42 ` Lucas De Marchi
2025-09-09 17:22 ` Raag Jadav
2025-09-06 5:50 ` [PATCH v3 5/6] drm/xe/lrc: Allow to add user commands on context switch Lucas De Marchi
2025-09-06 5:50 ` [PATCH v3 6/6] drm/xe/configfs: Add post context restore bb Lucas De Marchi
2025-09-08 22:39 ` Matt Roper
2025-09-09 12:56 ` Lucas De Marchi
2025-09-08 19:46 ` ✗ CI.checkpatch: warning for drm/xe: Add user commands to WA BB via configfs Patchwork
2025-09-08 19:47 ` ✓ CI.KUnit: success " Patchwork
2025-09-08 20:27 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-08 23:55 ` ✗ 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=20250905-wa-bb-cmds-v3-3-3da2b7bdc73e@intel.com \
--to=lucas.demarchi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.d.roper@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=stuart.summers@intel.com \
--cc=tursulin@ursulin.net \
--cc=umesh.nerlige.ramappa@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