Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Laguna, Lukasz" <lukasz.laguna@intel.com>
To: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>,
	Jakub Kolakowski <jakub1.kolakowski@intel.com>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: Re: [PATCH i-g-t 4/6] lib/xe/xe_sriov_admin: Add bulk scheduling params setter
Date: Tue, 18 Aug 2026 16:15:29 +0200	[thread overview]
Message-ID: <0c717c70-881c-46d3-9227-9f6eae589fd8@intel.com> (raw)
In-Reply-To: <17c3a7f8e02e94f11b7beb6e3359dbd8afeb4567.1787056235.git.marcin.bernatowicz@linux.intel.com>


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 <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>

Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>

> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
>   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);

  reply	other threads:[~2026-08-18 14:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 12:39 [PATCH i-g-t 0/6] Order SR-IOV scheduling provisioning safely Marcin Bernatowicz
2026-08-18 12:39 ` [PATCH i-g-t 1/6] tests/intel/xe_sriov_scheduling: Disable VFs before resetting sched params Marcin Bernatowicz
2026-08-18 14:14   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 2/6] lib/xe/xe_sriov_admin: Rename restore defaults helpers Marcin Bernatowicz
2026-08-18 14:14   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 3/6] lib/xe/xe_sriov_admin: Lower priority before clearing timeslicing Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 4/6] lib/xe/xe_sriov_admin: Add bulk scheduling params setter Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz [this message]
2026-08-18 12:39 ` [PATCH i-g-t 5/6] tests/intel/xe_sriov_scheduling: Use safe scheduling params helpers Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 6/6] tests/intel/xe_pmu: Disable VFs before restoring sched params Marcin Bernatowicz
2026-08-18 14:16   ` Laguna, Lukasz
2026-08-18 14:11 ` ✓ Xe.CI.BAT: success for Order SR-IOV scheduling provisioning safely Patchwork
2026-08-18 14:20 ` ✓ i915.CI.BAT: " Patchwork
2026-08-18 16:39 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-19  1:50 ` ✓ 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=0c717c70-881c-46d3-9227-9f6eae589fd8@intel.com \
    --to=lukasz.laguna@intel.com \
    --cc=adam.miszczak@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=marcin.bernatowicz@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox