From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH 10/14] drm/xe/pf: Allow change PF scheduling priority using sysfs
Date: Fri, 24 Oct 2025 15:47:22 -0400 [thread overview]
Message-ID: <aPvXyh49bwFILFEU@intel.com> (raw)
In-Reply-To: <20251020182414.576-11-michal.wajdeczko@intel.com>
On Mon, Oct 20, 2025 at 08:24:10PM +0200, Michal Wajdeczko wrote:
> We have just added bulk change of the scheduling priority for all
> VFs and PF, but that only allow to select LOW and NORMAL priority.
>
> Add read-write attribute under PF to allow changing its priority
> without impacting other VFs priority settings.
>
> For completeness also add read-only attributes under VFs, to show
> currently selected priority levels used by the VFs.
>
> /sys/bus/pci/drivers/xe/BDF/
> ├── sriov_admin/
> ├── pf/
> │ └── profile
> │ └── sched_priority [RW] low, normal, high
> ├── vf1/
> │ └── profile
> │ └── sched_priority [RO] low, normal
>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Writing "high" to the PF read-write attribute will change PF
> priority on all tiles/GTs to HIGH (schedule function in the next
> time-slice after current one completes and it has work). Writing
> "low" or "normal" to change priority to LOW/NORMAL is supported.
>
> When read, those files will display the current and available
> scheduling priorities. The currently active priority level will
> be enclosed in square brackets, default output will be like:
>
> $ grep . -h sriov_admin/{pf,vf1,vf2}/profile/sched_priority
> [low] normal high
> [low] normal
> [low] normal
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c | 82 +++++++++++++++++++++++++-
> 1 file changed, 80 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> index 26ba9a2efec9..a6be3c88fa4f 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> @@ -17,6 +17,21 @@
> #include "xe_sriov_pf_sysfs.h"
> #include "xe_sriov_printk.h"
>
> +static int emit_choice(char *buf, int choice, const char * const *array, size_t size)
> +{
> + int pos = 0;
> + int n;
> +
> + for (n = 0; n < size; n++) {
> + pos += sysfs_emit_at(buf, pos, "%s%s%s%s",
> + n ? " " : "",
> + n == choice ? "[" : "",
> + array[n],
> + n == choice ? "]" : "");
> + }
> + return pos + sysfs_emit_at(buf, pos, "\n");
> +}
> +
> /*
> * /sys/bus/pci/drivers/xe/BDF/
> * :
> @@ -30,12 +45,14 @@
> * │ ├── ...
> * │ └── profile
> * │ ├── exec_quantum_ms
> - * │ └── preempt_timeout_us
> + * │ ├── preempt_timeout_us
> + * │ └── sched_priority
> * ├── vf1/
> * │ ├── ...
> * │ └── profile
> * │ ├── exec_quantum_ms
> - * │ └── preempt_timeout_us
> + * │ ├── preempt_timeout_us
> + * │ └── sched_priority
> * ├── vf2/
> * :
> * └── vfN/
> @@ -115,6 +132,12 @@ static const char * const sched_priority_names[] = {
> [GUC_SCHED_PRIORITY_HIGH] = "high",
> };
>
> +static bool sched_priority_change_allowed(unsigned int vfid)
> +{
> + /* As of today GuC FW allows to selectively change only the PF priority. */
> + return vfid == PFID;
> +}
> +
> static bool sched_priority_high_allowed(unsigned int vfid)
> {
> /* As of today GuC FW allows to select 'high' priority only for the PF. */
> @@ -199,15 +222,70 @@ static XE_SRIOV_VF_ATTR(NAME)
> DEFINE_SIMPLE_PROVISIONING_SRIOV_VF_ATTR(exec_quantum_ms, eq, u32, "%u\n");
> DEFINE_SIMPLE_PROVISIONING_SRIOV_VF_ATTR(preempt_timeout_us, pt, u32, "%u\n");
>
> +static ssize_t xe_sriov_vf_attr_sched_priority_show(struct xe_device *xe, unsigned int vfid,
> + char *buf)
> +{
> + size_t num_priorities = ARRAY_SIZE(sched_priority_names);
> + u32 priority;
> + int err;
> +
> + err = xe_sriov_pf_provision_query_vf_priority(xe, vfid, &priority);
> + if (err)
> + return err;
> +
> + if (!sched_priority_high_allowed(vfid))
> + num_priorities--;
> +
> + xe_assert(xe, priority < num_priorities);
> + return emit_choice(buf, priority, sched_priority_names, num_priorities);
> +}
> +
> +static ssize_t xe_sriov_vf_attr_sched_priority_store(struct xe_device *xe, unsigned int vfid,
> + const char *buf, size_t count)
> +{
> + size_t num_priorities = ARRAY_SIZE(sched_priority_names);
> + int match;
> + int err;
> +
> + if (!sched_priority_change_allowed(vfid))
> + return -EOPNOTSUPP;
> +
> + if (!sched_priority_high_allowed(vfid))
> + num_priorities--;
> +
> + match = __sysfs_match_string(sched_priority_names, num_priorities, buf);
> + if (match < 0)
> + return -EINVAL;
> +
> + err = xe_sriov_pf_provision_apply_vf_priority(xe, vfid, match);
> + return err ?: count;
> +}
> +
> +static XE_SRIOV_VF_ATTR(sched_priority);
> +
> static struct attribute *profile_vf_attrs[] = {
> &xe_sriov_vf_attr_exec_quantum_ms.attr,
> &xe_sriov_vf_attr_preempt_timeout_us.attr,
> + &xe_sriov_vf_attr_sched_priority.attr,
> NULL
> };
>
> +static umode_t profile_vf_attr_is_visible(struct kobject *kobj,
> + struct attribute *attr, int index)
> +{
> + struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
> +
> + if (attr == &xe_sriov_vf_attr_sched_priority.attr &&
> + !sched_priority_change_allowed(vkobj->vfid))
> + return attr->mode & 0444;
> +
> + return attr->mode;
> +}
> +
> static const struct attribute_group profile_vf_attr_group = {
> .name = "profile",
> .attrs = profile_vf_attrs,
> + .is_visible = profile_vf_attr_is_visible,
> };
>
> static const struct attribute_group *xe_sriov_vf_attr_groups[] = {
> --
> 2.47.1
>
next prev parent reply other threads:[~2025-10-24 19:47 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 18:24 [PATCH 00/14] PF: Add sriov_admin sysfs tree Michal Wajdeczko
2025-10-20 18:24 ` [PATCH 01/14] drm/xe/pf: Prepare sysfs for SR-IOV admin attributes Michal Wajdeczko
2025-10-24 19:43 ` Rodrigo Vivi
2025-10-27 17:11 ` Lucas De Marchi
2025-10-27 17:59 ` Michal Wajdeczko
2025-10-27 18:30 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 02/14] drm/xe/pf: Take RPM during calls to SR-IOV attr.store() Michal Wajdeczko
2025-10-27 17:14 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 03/14] drm/xe/pf: Allow change PF and VFs EQ/PT using sysfs Michal Wajdeczko
2025-10-24 19:45 ` Rodrigo Vivi
2025-10-27 17:27 ` Lucas De Marchi
2025-10-27 18:09 ` Michal Wajdeczko
2025-10-27 18:32 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 04/14] drm/xe/pf: Relax report helper to accept PF in bulk configs Michal Wajdeczko
2025-10-27 18:50 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 05/14] drm/xe/pf: Add functions to bulk configure EQ/PT on GT Michal Wajdeczko
2025-10-27 19:03 ` Lucas De Marchi
2025-10-27 20:12 ` Michal Wajdeczko
2025-10-20 18:24 ` [PATCH 06/14] drm/xe/pf: Add functions to bulk provision EQ/PT Michal Wajdeczko
2025-10-27 19:18 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 07/14] drm/xe/pf: Allow bulk change all VFs EQ/PT using sysfs Michal Wajdeczko
2025-10-24 19:46 ` Rodrigo Vivi
2025-10-27 19:28 ` Lucas De Marchi
2025-10-27 20:15 ` Michal Wajdeczko
2025-10-20 18:24 ` [PATCH 08/14] drm/xe/pf: Add functions to provision scheduling priority Michal Wajdeczko
2025-10-28 11:17 ` Piotr Piórkowski
2025-10-20 18:24 ` [PATCH 09/14] drm/xe/pf: Allow bulk change all VFs priority using sysfs Michal Wajdeczko
2025-10-24 19:47 ` Rodrigo Vivi
2025-10-20 18:24 ` [PATCH 10/14] drm/xe/pf: Allow change PF scheduling " Michal Wajdeczko
2025-10-24 19:47 ` Rodrigo Vivi [this message]
2025-10-20 18:24 ` [PATCH 11/14] drm/xe/pf: Promote xe_pci_sriov_get_vf_pdev Michal Wajdeczko
2025-10-28 9:57 ` Piotr Piórkowski
2025-10-28 12:22 ` Michal Wajdeczko
2025-10-28 16:03 ` Piotr Piórkowski
2025-10-20 18:24 ` [PATCH 12/14] drm/xe/pf: Add sysfs device symlinks to enabled VFs Michal Wajdeczko
2025-10-24 19:47 ` Rodrigo Vivi
2025-10-20 18:24 ` [PATCH 13/14] drm/xe/pf: Allow to stop and reset VF using sysfs Michal Wajdeczko
2025-10-24 19:51 ` Rodrigo Vivi
2025-10-27 20:58 ` Lucas De Marchi
2025-10-20 18:24 ` [PATCH 14/14] drm/xe/pf: Add documentation for sriov_admin attributes Michal Wajdeczko
2025-10-27 16:44 ` Rodrigo Vivi
2025-10-21 4:35 ` ✗ CI.checkpatch: warning for PF: Add sriov_admin sysfs tree Patchwork
2025-10-21 4:36 ` ✓ CI.KUnit: success " Patchwork
2025-10-21 10:19 ` ✗ 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=aPvXyh49bwFILFEU@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@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