[PATCH v3 6/6] drm/xe/configfs: Allow adding configurations for future VFs

Lucas De Marchi lucas.demarchi at intel.com
Fri Jul 25 13:16:56 UTC 2025


On Tue, Jul 22, 2025 at 04:10:59PM +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 at intel.com>
>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>---
>v2: rebase and improve checks, fix include order
>---
> drivers/gpu/drm/xe/xe_configfs.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
>index b593337d05b3..f8222079b209 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
>@@ -295,11 +295,20 @@ 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 && PCI_DEVFN(slot, function) != pdev->devfn) {
>+		pdev = pci_physfn(pdev);

aren't you leaking the pdev assigned above and then putting the
wrong pdev below?

Lucas De Marchi

>+		if (!dev_is_pf(&pdev->dev) || !match->has_sriov ||
>+		    PCI_DEVFN(slot, function) - pdev->devfn > pci_sriov_get_totalvfs(pdev))
>+			match = NULL;
>+	}
> 	pci_dev_put(pdev);
>
> 	if (!match)
>-- 
>2.47.1
>


More information about the Intel-xe mailing list