Re: [PATCH i-g-t 4/6] lib/xe/xe_sriov_admin: Add bulk scheduling params setter
"Laguna, Lukasz" <[email protected]>
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/2026 14:39, Marcin Bernatowicz wrote: > Provisioning execution quantum, preemption timeout and priority is not > order independent. Priority above LOW combined with infinite timeslicing > is a risky state, which can be left via PAUSE/FLR, so timeslicing has to > be programmed before priority is raised. > > Add struct xe_sriov_sched_params and a bulk setter that enforces that > order, and that rejects infinite execution quantum or preemption timeout. > Together with xe_sriov_admin_bulk_restore_sched_defaults(), which now > lowers priority first, callers get a safe setup and cleanup pair without > having to open code the sequence. > > Assisted-by: Copilot:Claude-Opus-5 > Signed-off-by: Marcin Bernatowicz <[email protected]> > Cc: Adam Miszczak <[email protected]> > Cc: Jakub Kolakowski <[email protected]> > Cc: Lukasz Laguna <[email protected]> Reviewed-by: Lukasz Laguna <[email protected]> > Cc: Michal Wajdeczko <[email protected]> > --- > lib/xe/xe_sriov_admin.c | 53 +++++++++++++++++++++++++++++++++++++++++ > lib/xe/xe_sriov_admin.h | 20 ++++++++++++++++ > 2 files changed, 73 insertions(+) > > diff --git a/lib/xe/xe_sriov_admin.c b/lib/xe/xe_sriov_admin.c > index 0433ddcfc..2f47d0965 100644 > --- a/lib/xe/xe_sriov_admin.c > +++ b/lib/xe/xe_sriov_admin.c > @@ -505,6 +505,59 @@ void xe_sriov_admin_bulk_set_sched_priority(int pf_fd, > igt_assert_eq(0, __xe_sriov_admin_bulk_set_sched_priority(pf_fd, prio)); > } > > +/** > + * __xe_sriov_admin_bulk_set_sched_params - Set scheduling parameters for PF and all VFs > + * @pf_fd: PF device file descriptor. > + * @params: Scheduling parameters to apply. > + * > + * Applies execution quantum and preemption timeout before priority, so that a > + * priority above LOW is never active while timeslicing is still infinite. > + * > + * Both &xe_sriov_sched_params.exec_quantum_ms and > + * &xe_sriov_sched_params.preempt_timeout_us must be non-zero. Use > + * __xe_sriov_admin_bulk_restore_sched_defaults() to restore infinite timeslicing. > + * > + * Returns: 0 on success or negative errno on error. > + */ > +int __xe_sriov_admin_bulk_set_sched_params(int pf_fd, > + const struct xe_sriov_sched_params *params) > +{ > + int ret; > + > + if (igt_warn_on_f(!params->exec_quantum_ms || !params->preempt_timeout_us, > + "Infinite timeslicing requires restoring defaults: eq=%u pt=%u\n", > + params->exec_quantum_ms, params->preempt_timeout_us)) > + return -EINVAL; > + > + ret = __xe_sriov_admin_bulk_set_exec_quantum_ms(pf_fd, params->exec_quantum_ms); > + if (igt_warn_on_f(ret, "Failed to bulk set exec quantum=%u: %d\n", > + params->exec_quantum_ms, ret)) > + return ret; > + > + ret = __xe_sriov_admin_bulk_set_preempt_timeout_us(pf_fd, params->preempt_timeout_us); > + if (igt_warn_on_f(ret, "Failed to bulk set preempt timeout=%u: %d\n", > + params->preempt_timeout_us, ret)) > + return ret; > + > + ret = __xe_sriov_admin_bulk_set_sched_priority(pf_fd, params->priority); > + if (igt_warn_on_f(ret, "Failed to bulk set sched priority=%d: %d\n", > + params->priority, ret)) > + return ret; > + > + return 0; > +} > + > +/** > + * xe_sriov_admin_bulk_set_sched_params - Assert wrapper for bulk scheduling params update > + * @pf_fd: PF device file descriptor. > + * @params: Scheduling parameters to apply. > + */ > +void xe_sriov_admin_bulk_set_sched_params(int pf_fd, > + const struct xe_sriov_sched_params *params) > +{ > + igt_assert_eq(0, __xe_sriov_admin_bulk_set_sched_params(pf_fd, params)); > +} > + > /** > * __xe_sriov_admin_vf_stop - Issue stop command for a VF > * @pf_fd: PF device file descriptor. > diff --git a/lib/xe/xe_sriov_admin.h b/lib/xe/xe_sriov_admin.h > index 4eb9c83a6..6d482f8bf 100644 > --- a/lib/xe/xe_sriov_admin.h > +++ b/lib/xe/xe_sriov_admin.h > @@ -13,6 +13,22 @@ > > struct igt_sysfs_choice; > > +/** > + * struct xe_sriov_sched_params - Scheduling parameters for a function > + * @exec_quantum_ms: Execution quantum in milliseconds > + * @preempt_timeout_us: Preemption timeout in microseconds > + * @priority: Scheduling priority > + * > + * Zero @exec_quantum_ms or zero @preempt_timeout_us means infinity, which is > + * only valid together with %XE_SRIOV_SCHED_PRIORITY_LOW. Use > + * xe_sriov_admin_bulk_restore_sched_defaults() to return to that state. > + */ > +struct xe_sriov_sched_params { > + uint32_t exec_quantum_ms; > + uint32_t preempt_timeout_us; > + enum xe_sriov_sched_priority priority; > +}; > + > bool xe_sriov_admin_is_present(int pf_fd); > > int __xe_sriov_admin_set_exec_quantum_ms(int pf_fd, unsigned int vf_num, uint32_t eq_ms); > @@ -48,6 +64,10 @@ int __xe_sriov_admin_bulk_set_sched_priority(int pf_fd, > enum xe_sriov_sched_priority prio); > void xe_sriov_admin_bulk_set_sched_priority(int pf_fd, > enum xe_sriov_sched_priority prio); > +int __xe_sriov_admin_bulk_set_sched_params(int pf_fd, > + const struct xe_sriov_sched_params *params); > +void xe_sriov_admin_bulk_set_sched_params(int pf_fd, > + const struct xe_sriov_sched_params *params); > > int __xe_sriov_admin_vf_stop(int pf_fd, unsigned int vf_num); > void xe_sriov_admin_vf_stop(int pf_fd, unsigned int vf_num);