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>,
John Harrison <John.C.Harrison@intel.com>
Subject: Re: [PATCH v6 11/11] drm/xe/configfs: Allow adding configurations for future VFs
Date: Thu, 31 Jul 2025 16:37:05 -0400 [thread overview]
Message-ID: <aIvT8XHu4NCAb7wk@intel.com> (raw)
In-Reply-To: <20250731193339.179829-12-michal.wajdeczko@intel.com>
On Thu, Jul 31, 2025 at 09:33:39PM +0200, Michal Wajdeczko wrote:
> Since we are expecting that all configuration directory names
> will match some of the existing devices, we can't provide any
> configuration for the VFs until they are actually enabled.
>
> But we can relax that restriction by just checking if there
> is a PF device that could create given VF. This is easy since
> all our PF devices are always present at function 0 and we can
> query PF device for number of VFs it could support.
>
> Then for some system with PF device at 0000:00:02.0 we can add
> configs for all VFs:
>
> /sys/kernel/config/xe/
> ├── 0000:00:02.0
> │ └── ...
> ├── 0000:00:02.1
> │ └── ...
> ├── 0000:00:02.2
> │ └── ...
> :
> └── 0000:00:02.7
> └── ...
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> #v3
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> v2: rebase and improve checks, fix include order
> v3: put correct device (Lucas)
> v4: rebase and change reporting
> ---
> drivers/gpu/drm/xe/xe_configfs.c | 35 +++++++++++++++++++++++++++++---
> 1 file changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 0e2da7907afc..c2da2c60e321 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
> @@ -12,9 +12,9 @@
> #include <linux/string.h>
>
> #include "xe_configfs.h"
> -#include "xe_module.h"
> -
> #include "xe_hw_engine_types.h"
> +#include "xe_module.h"
> +#include "xe_pci_types.h"
>
> /**
> * DOC: Xe Configfs
> @@ -285,6 +285,15 @@ static const struct xe_device_desc *xe_match_desc(struct pci_dev *pdev)
> return found ? (const void *)found->driver_data : NULL;
> }
>
> +static struct pci_dev *get_physfn_instead(struct pci_dev *virtfn)
> +{
> + struct pci_dev *physfn = pci_physfn(virtfn);
> +
> + pci_dev_get(physfn);
> + pci_dev_put(virtfn);
> + return physfn;
> +}
> +
> static struct config_group *xe_config_make_device_group(struct config_group *group,
> const char *name)
> {
> @@ -293,6 +302,7 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
> const struct xe_device_desc *match;
> struct pci_dev *pdev;
> char canonical[16];
> + int vfnumber = 0;
> int ret;
>
> ret = sscanf(name, "%x:%x:%x.%x", &domain, &bus, &slot, &function);
> @@ -306,12 +316,31 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
> return ERR_PTR(-EINVAL);
>
> pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, function));
> + if (!pdev && function)
> + pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, 0));
> + if (!pdev && slot)
> + pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(0, 0));
> if (!pdev)
> return ERR_PTR(-ENODEV);
>
> match = xe_match_desc(pdev);
> - if (!match)
> +
> + if (PCI_DEVFN(slot, function) != pdev->devfn) {
> + pdev = get_physfn_instead(pdev);
> + vfnumber = PCI_DEVFN(slot, function) - pdev->devfn;
> + if (!dev_is_pf(&pdev->dev) || vfnumber > pci_sriov_get_totalvfs(pdev)) {
> + pci_dev_put(pdev);
> + return ERR_PTR(-ENODEV);
> + }
> + }
> +
> + match = xe_match_desc(pdev);
> + if (match && vfnumber && !match->has_sriov) {
> + pci_info(pdev, "xe driver does not support VFs on this device\n");
> + match = NULL;
> + } else if (!match) {
> pci_info(pdev, "xe driver does not support configuration of this device\n");
> + }
>
> pci_dev_put(pdev);
>
> --
> 2.47.1
>
next prev parent reply other threads:[~2025-07-31 20:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 19:33 [PATCH v6 00/11] Updates for drm/xe/configfs Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 01/11] drm/xe: Simplify module initialization code Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 02/11] drm/xe: Print module init abort code Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 03/11] drm/xe/configfs: Destroy xe_configfs.su_mutex on exit/error Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 04/11] drm/xe/configfs: Drop redundant init() error message Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 05/11] drm/xe/configfs: Rename struct xe_config_device Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 06/11] drm/xe/configfs: Rename configfs_find_group() helper Michal Wajdeczko
2025-08-05 13:14 ` Lucas De Marchi
2025-08-05 14:30 ` Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 07/11] drm/xe/configfs: Reintroduce struct xe_config_device Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 08/11] drm/xe/configfs: Keep default device config settings together Michal Wajdeczko
2025-08-05 13:28 ` Lucas De Marchi
2025-08-05 15:09 ` Michal Wajdeczko
2025-08-06 14:29 ` Lucas De Marchi
2025-07-31 19:33 ` [PATCH v6 09/11] drm/xe/configfs: Check if device was preconfigured Michal Wajdeczko
2025-08-05 19:30 ` Lucas De Marchi
2025-08-05 23:14 ` John Harrison
2025-08-06 14:49 ` Lucas De Marchi
2025-07-31 19:33 ` [PATCH v6 10/11] drm/xe/configfs: Only allow configurations for supported devices Michal Wajdeczko
2025-07-31 20:35 ` Rodrigo Vivi
2025-07-31 19:33 ` [PATCH v6 11/11] drm/xe/configfs: Allow adding configurations for future VFs Michal Wajdeczko
2025-07-31 20:37 ` Rodrigo Vivi [this message]
2025-07-31 21:21 ` [PATCH v7 " Michal Wajdeczko
2025-08-01 0:05 ` ✓ CI.KUnit: success for Updates for drm/xe/configfs (rev8) Patchwork
2025-08-01 1:08 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-01 2:31 ` ✓ Xe.CI.Full: " Patchwork
2025-08-05 19:44 ` [PATCH v6 00/11] Updates for drm/xe/configfs Lucas De Marchi
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=aIvT8XHu4NCAb7wk@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=John.C.Harrison@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