From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
igt-dev@lists.freedesktop.org
Cc: adam.miszczak@linux.intel.com, jakub1.kolakowski@intel.com,
lukasz.laguna@intel.com
Subject: Re: [PATCH i-g-t 3/5] lib/xe/xe_sriov_admin: Add SR-IOV admin sysfs accessors
Date: Mon, 17 Nov 2025 10:31:53 +0100 [thread overview]
Message-ID: <7dd5427d-6252-4abd-8e6a-dae82ea72163@linux.intel.com> (raw)
In-Reply-To: <87cf5659-2bc5-4674-b027-1539c2928954@intel.com>
On 11/14/2025 8:53 PM, Michal Wajdeczko wrote:
>
> On 11/14/2025 8:07 PM, Marcin Bernatowicz wrote:
>> Reflect recent kernel changes and expose SR-IOV admin sysfs helpers for
>> scheduling control. Add per-VF and bulk accessors for execution quantum,
>> preemption timeout, scheduling priority, VF stop and restoring defaults.
>>
>> Link: https://lore.kernel.org/intel-xe/20251030222348.186658-1-michal.wajdeczko@intel.com/
>> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
>> Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
>> Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
>> Cc: Lukasz Laguna <lukasz.laguna@intel.com>
>> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> ---
> ...
>
>> +
>> +/* Parse a raw sched_priority line into current priority enum (required) and optional mask.
>> + * Behavior:
>> + * - If prio_mask == NULL: validate only the bracketed (current) priority; ignore unknown others.
>> + * - If prio_mask != NULL: validate all priorities; unknown priority causes -EOPNOTSUPP.
>> + * Returns 0 on success, -EOPNOTSUPP on semantic issues, or other -errno from callers.
>> + */
>> +static int parse_sched_prio_line(const char *line,
>> + enum xe_sriov_sched_priority *cur_prio,
>> + unsigned int *prio_mask)
> the idea behind
>
> "When read, this file will display the current and available
> scheduling priorities. The currently active priority level will
> be enclosed in square brackets"
>
> was that in the future we might want to add new priorities or the
> list of supported priorities will change based on the platform or
> firmware capability
>
> so you should start by adding a function that just looks for the item
> "enclosed in square brackets" and return it, and/or other function
> that will return list of all parsed items and the pointer to the
> selected item
>
> then in other function you can try to match returned string to your
> priority enum and decide whether you support that priority
> or just rely on the returned string everywhere
Thanks, makes sense.
I'll split this into two parts:
- Bare token parser – returns all strings + the bracketed one, no enum
mapping, tolerant to unknown priorities. This will be used for ABI/format
checks and to handle future FW/platform extensions.
- Strict helper on top – map known strings to our enum, build the mask, and
return -EOPNOTSUPP when the current token or any masked token is unknown.
This matches the existing enum-based helpers used by tests that need to
understand LOW/NORMAL/HIGH semantics.
This should give us a future-proof parser while keeping the current strict
behaviour where tests depend on it.
>
>> +{
>> + enum xe_sriov_sched_priority e;
>> + const char *p = line, *start;
>> + unsigned int mask = 0;
>> + bool bracketed, have_cur = false;
>> + char tok[16];
>> + size_t len;
>> +
>> + igt_assert(line && cur_prio);
>> +
>> + while (*p) {
>> + while (*p == ' ' || *p == '\t')
>> + p++;
>> + if (!*p)
>> + break;
>> +
>> + bracketed = (*p == '[');
>> + start = p + (bracketed ? 1 : 0);
>> +
>> + if (bracketed) {
>> + while (*p && *p != ']')
>> + p++;
>> + } else {
>> + while (*p && *p != ' ' && *p != '\t')
>> + p++;
>> + }
>> +
>> + /* token bounds: [start, p) */
>> + len = (size_t)(p - start);
>> + if (len >= sizeof(tok))
>> + len = sizeof(tok) - 1;
>> + memcpy(tok, start, len);
>> + tok[len] = '\0';
>> +
>> + /* map token -> enum */
>> + if (!xe_sriov_sched_priority_from_string(tok, &e)) {
>> + if (e == XE_SRIOV_SCHED_PRIORITY_LOW)
>> + mask |= XE_SRIOV_SCHED_PRIORITY_MASK_LOW;
>> + else if (e == XE_SRIOV_SCHED_PRIORITY_NORMAL)
>> + mask |= XE_SRIOV_SCHED_PRIORITY_MASK_NORMAL;
>> + else if (e == XE_SRIOV_SCHED_PRIORITY_HIGH)
>> + mask |= XE_SRIOV_SCHED_PRIORITY_MASK_HIGH;
>> +
>> + if (bracketed) {
>> + *cur_prio = e;
>> + have_cur = true;
>> + }
>> + } else {
>> + if (bracketed) {
>> + igt_debug("unknown current scheduling priority '%s' (line='%s')\n",
>> + tok, line);
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + if (prio_mask) {
>> + igt_debug("unknown scheduling priority '%s' (line='%s')\n",
>> + tok, line);
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + igt_debug("ignoring unknown scheduling priority '%s' (line='%s')\n",
>> + tok, line);
>> + }
>> +
>> + if (*p)
>> + p++; /* skip ']' or the delimiter */
>> + }
>> +
>> + if (!have_cur)
>> + return -EOPNOTSUPP;
>> +
>> + if (prio_mask)
>> + *prio_mask = mask;
>> +
>> + return 0;
>> +}
>> +
>> +/**
>> + * __xe_sriov_profile_get_sched_priority - Read VF scheduling priority + mask
>> + * @pf_fd: PF device file descriptor.
>> + * @vf_num: VF index (0 for PF, >0 for VFs).
>> + * @prio: Output pointer for the effective priority.
>> + * @prio_mask: Output mask of allowed priorities.
>> + *
>> + * Returns: 0 on success or negative errno on error.
>> + */
>> +int __xe_sriov_profile_get_sched_priority(int pf_fd, unsigned int vf_num,
>> + enum xe_sriov_sched_priority *cur_prio,
>> + unsigned int *prio_mask)
>> +{
>> + char path[PATH_MAX];
>> + char line[256] = { 0 };
>> + int sysfs, ret;
>> +
>> + igt_assert(cur_prio);
>> +
>> + sysfs = igt_sysfs_open(pf_fd);
>> + if (sysfs < 0)
>> + return sysfs;
>> +
>> + fmt_profile_rel_path(path, sizeof(path), vf_num,
>> + "profile/sched_priority");
>> + ret = igt_sysfs_scanf(sysfs, path, "%255[^\n]", line);
>> + close(sysfs);
>> +
>> + ret = ret_from_scanf_items(ret, 1);
>> + if (ret)
>> + return ret;
>> +
>> + ret = parse_sched_prio_line(line, cur_prio, prio_mask);
>> + if (ret)
>> + igt_debug("sched prio: parse/map failed (err=%d), line='%s'\n",
>> + ret, line);
>> + return ret;
>> +}
>> +
>> +/**
>> + * xe_sriov_profile_get_sched_priority - Assert wrapper for reading VF priority
>> + * @pf_fd: PF device file descriptor.
>> + * @vf_num: VF index (0 for PF, >0 for VFs).
>> + * @prio_mask: Output mask of supported priorities.
>> + *
>> + * Returns: effective priority; asserts on error.
>> + */
>> +enum xe_sriov_sched_priority
>> +xe_sriov_profile_get_sched_priority(int pf_fd, unsigned int vf_num,
>> + unsigned int *prio_mask)
>> +{
>> + enum xe_sriov_sched_priority cur_prio;
>> +
>> + igt_assert_eq(0,
>> + __xe_sriov_profile_get_sched_priority(pf_fd, vf_num, &cur_prio, prio_mask));
>> +
>> + return cur_prio;
>> +}
>> +
next prev parent reply other threads:[~2025-11-17 9:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 19:07 [PATCH i-g-t 0/5] Xe SR-IOV admin scheduling helpers and test updates Marcin Bernatowicz
2025-11-14 19:07 ` [PATCH i-g-t 1/5] lib/xe/xe_sriov_provisioning: Add string conversion helpers for scheduling priority Marcin Bernatowicz
2025-11-14 19:07 ` [PATCH i-g-t 2/5] lib/xe/xe_sriov_provisioning: Add sched priority mask to string helper Marcin Bernatowicz
2025-11-14 20:15 ` Michal Wajdeczko
2025-11-17 11:00 ` Bernatowicz, Marcin
2025-11-14 19:07 ` [PATCH i-g-t 3/5] lib/xe/xe_sriov_admin: Add SR-IOV admin sysfs accessors Marcin Bernatowicz
2025-11-14 19:53 ` Michal Wajdeczko
2025-11-17 9:31 ` Bernatowicz, Marcin [this message]
2025-11-14 19:07 ` [PATCH i-g-t 4/5] tests/intel/xe_sriov_scheduling: Avoid assert on scheduling params restore in cleanup Marcin Bernatowicz
2025-11-14 19:07 ` [PATCH i-g-t 5/5] tests/intel/xe_sriov_scheduling: Prefer SR-IOV admin sysfs accessors Marcin Bernatowicz
2025-11-14 19:57 ` Michal Wajdeczko
2025-11-17 8:51 ` Bernatowicz, Marcin
2025-11-14 23:29 ` ✓ Xe.CI.BAT: success for Xe SR-IOV admin scheduling helpers and test updates Patchwork
2025-11-15 9:54 ` ✓ Xe.CI.Full: " Patchwork
2025-11-15 15:11 ` ✓ i915.CI.Full: " 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=7dd5427d-6252-4abd-8e6a-dae82ea72163@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=adam.miszczak@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.