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 12/14] drm/xe/pf: Add sysfs device symlinks to enabled VFs
Date: Fri, 24 Oct 2025 15:47:56 -0400 [thread overview]
Message-ID: <aPvX7K8DhE6wXnR8@intel.com> (raw)
In-Reply-To: <20251020182414.576-13-michal.wajdeczko@intel.com>
On Mon, Oct 20, 2025 at 08:24:12PM +0200, Michal Wajdeczko wrote:
> For convenience, for every enabled VF add 'device' symlink from
> our SR-IOV admin VF folder to enabled sysfs PCI VF device entry.
> Remove all those links when disabling PCI VFs.
>
> For completeness, add static 'device' symlink for the PF itself.
>
> /sys/bus/pci/drivers/xe/BDF/sriov_admin/
> ├── pf
> │ └── device -> ../../../BDF # PF BDF
> ├── vf1
> │ └── device -> ../../../BDF' # VF1 BDF
> ├── vf2
> │ └── device -> ../../../BDF" # VF2 BDF
>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> 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_pci_sriov.c | 5 ++
> drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c | 93 ++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_sriov_pf_sysfs.h | 3 +
> 3 files changed, 101 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index 678e76703cd8..fb2fd1d9066d 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -20,6 +20,7 @@
> #include "xe_sriov_pf_control.h"
> #include "xe_sriov_pf_helpers.h"
> #include "xe_sriov_pf_provision.h"
> +#include "xe_sriov_pf_sysfs.h"
> #include "xe_sriov_printk.h"
>
> static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
> @@ -138,6 +139,8 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> xe_sriov_info(xe, "Enabled %u of %u VF%s\n",
> num_vfs, total_vfs, str_plural(total_vfs));
>
> + xe_sriov_pf_sysfs_link_vfs(xe, num_vfs);
> +
> pf_engine_activity_stats(xe, num_vfs, true);
>
> return num_vfs;
> @@ -165,6 +168,8 @@ static int pf_disable_vfs(struct xe_device *xe)
>
> pf_engine_activity_stats(xe, num_vfs, false);
>
> + xe_sriov_pf_sysfs_unlink_vfs(xe, num_vfs);
> +
> pci_disable_sriov(pdev);
>
> pf_reset_vfs(xe, num_vfs);
> diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> index a6be3c88fa4f..c68acf6cd34f 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
> @@ -9,6 +9,7 @@
> #include <drm/drm_managed.h>
>
> #include "xe_assert.h"
> +#include "xe_pci_sriov.h"
> #include "xe_pm.h"
> #include "xe_sriov.h"
> #include "xe_sriov_pf.h"
> @@ -43,12 +44,14 @@ static int emit_choice(char *buf, int choice, const char * const *array, size_t
> * │ └── sched_priority
> * ├── pf/
> * │ ├── ...
> + * │ ├── device -> ../../../BDF
> * │ └── profile
> * │ ├── exec_quantum_ms
> * │ ├── preempt_timeout_us
> * │ └── sched_priority
> * ├── vf1/
> * │ ├── ...
> + * │ ├── device -> ../../../BDF.1
> * │ └── profile
> * │ ├── exec_quantum_ms
> * │ ├── preempt_timeout_us
> @@ -422,6 +425,11 @@ static int pf_sysfs_error(struct xe_device *xe, int err, const char *what)
> return err;
> }
>
> +static void pf_sysfs_note(struct xe_device *xe, int err, const char *what)
> +{
> + xe_sriov_dbg(xe, "Failed to setup sysfs %s (%pe)\n", what, ERR_PTR(err));
> +}
> +
> static void action_put_kobject(void *arg)
> {
> struct kobject *kobj = arg;
> @@ -488,6 +496,29 @@ static int pf_setup_tree(struct xe_device *xe)
> return 0;
> }
>
> +static void action_rm_device_link(void *arg)
> +{
> + struct kobject *kobj = arg;
> +
> + sysfs_remove_link(kobj, "device");
> +}
> +
> +static int pf_link_pf_device(struct xe_device *xe)
> +{
> + struct kobject *kobj = xe->sriov.pf.vfs[PFID].kobj;
> + int err;
> +
> + err = sysfs_create_link(kobj, &xe->drm.dev->kobj, "device");
> + if (err)
> + return pf_sysfs_error(xe, err, "PF device link");
> +
> + err = devm_add_action_or_reset(xe->drm.dev, action_rm_device_link, kobj);
> + if (err)
> + return pf_sysfs_error(xe, err, "PF unlink action");
> +
> + return 0;
> +}
> +
> /**
> * xe_sriov_pf_sysfs_init() - Setup PF's SR-IOV sysfs tree.
> * @xe: the PF &xe_device to setup sysfs
> @@ -509,5 +540,67 @@ int xe_sriov_pf_sysfs_init(struct xe_device *xe)
> if (err)
> return err;
>
> + err = pf_link_pf_device(xe);
> + if (err)
> + return err;
> +
> return 0;
> }
> +
> +/**
> + * xe_sriov_pf_sysfs_link_vfs() - Add VF's links in SR-IOV sysfs tree.
> + * @xe: the &xe_device where to update sysfs
> + * @num_vfs: number of enabled VFs to link
> + *
> + * This function is specific for the PF driver.
> + *
> + * This function will add symbolic links between VFs represented in the SR-IOV
> + * sysfs tree maintained by the PF and enabled VF PCI devices.
> + *
> + * The @xe_sriov_pf_sysfs_unlink_vfs() shall be used to remove those links.
> + */
> +void xe_sriov_pf_sysfs_link_vfs(struct xe_device *xe, unsigned int num_vfs)
> +{
> + unsigned int totalvfs = xe_sriov_pf_get_totalvfs(xe);
> + struct pci_dev *pf_pdev = to_pci_dev(xe->drm.dev);
> + struct pci_dev *vf_pdev = NULL;
> + unsigned int n;
> + int err;
> +
> + xe_assert(xe, IS_SRIOV_PF(xe));
> + xe_assert(xe, num_vfs <= totalvfs);
> +
> + for (n = 1; n <= num_vfs; n++) {
> + vf_pdev = xe_pci_sriov_get_vf_pdev(pf_pdev, VFID(n));
> + if (!vf_pdev)
> + return pf_sysfs_note(xe, -ENOENT, "VF link");
> +
> + err = sysfs_create_link(xe->sriov.pf.vfs[VFID(n)].kobj,
> + &vf_pdev->dev.kobj, "device");
> +
> + /* must balance xe_pci_sriov_get_vf_pdev() */
> + pci_dev_put(vf_pdev);
> +
> + if (err)
> + return pf_sysfs_note(xe, err, "VF link");
> + }
> +}
> +
> +/**
> + * xe_sriov_pf_sysfs_unlink_vfs() - Remove VF's links from SR-IOV sysfs tree.
> + * @xe: the &xe_device where to update sysfs
> + * @num_vfs: number of VFs to unlink
> + *
> + * This function shall be called only on the PF.
> + * This function will remove "device" links added by @xe_sriov_sysfs_link_vfs().
> + */
> +void xe_sriov_pf_sysfs_unlink_vfs(struct xe_device *xe, unsigned int num_vfs)
> +{
> + unsigned int n;
> +
> + xe_assert(xe, IS_SRIOV_PF(xe));
> + xe_assert(xe, num_vfs <= xe_sriov_pf_get_totalvfs(xe));
> +
> + for (n = 1; n <= num_vfs; n++)
> + sysfs_remove_link(xe->sriov.pf.vfs[VFID(n)].kobj, "device");
> +}
> diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.h b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.h
> index 1e6698cc29d3..ae92ed1766e7 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.h
> +++ b/drivers/gpu/drm/xe/xe_sriov_pf_sysfs.h
> @@ -10,4 +10,7 @@ struct xe_device;
>
> int xe_sriov_pf_sysfs_init(struct xe_device *xe);
>
> +void xe_sriov_pf_sysfs_link_vfs(struct xe_device *xe, unsigned int num_vfs);
> +void xe_sriov_pf_sysfs_unlink_vfs(struct xe_device *xe, unsigned int num_vfs);
> +
> #endif
> --
> 2.47.1
>
next prev parent reply other threads:[~2025-10-24 19:48 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
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 [this message]
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=aPvX7K8DhE6wXnR8@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