[PATCH 1/2] drm/xe/pf: Create a link between PF and VF devices
Piotr Piórkowski
piotr.piorkowski at intel.com
Thu Feb 20 11:33:32 UTC 2025
Satyanarayana K V P <satyanarayana.k.v.p at intel.com> wrote on czw [2025-lut-20 12:11:18 +0530]:
> When both PF and VF devices are enabled on the host, they
> resume simultaneously during system resume.
>
> However, the PF must finish provisioning the VF before any
> VFs can successfully resume.
>
> Establish a parent-child device link between the PF and VF
> devices to ensure the correct order of resumption.
>
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
> Cc: Michał Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Michał Winiarski <michal.winiarski at intel.com>
> Cc: Piotr Piórkowski <piotr.piorkowski at intel.com>
> ---
> drivers/gpu/drm/xe/xe_pci_sriov.c | 37 +++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index aaceee748287..429e1c7909a1 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -62,6 +62,41 @@ static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
> xe_gt_sriov_pf_control_trigger_flr(gt, n);
> }
>
> +static void pf_link_vfs(struct xe_device *xe, int num_vfs)
> +{
> + struct pci_dev *pdev_pf = to_pci_dev(xe->drm.dev);
> + int domain = pci_domain_nr(pdev_pf->bus);
> + unsigned int bus = pdev_pf->bus->number;
> + struct device_link *link;
> + struct pci_dev *pdev_vf;
> + unsigned int n;
> +
> + for (n = 1; n <= num_vfs; n++) {
> + pdev_vf = pci_get_domain_bus_and_slot(domain, bus,
> + pci_iov_virtfn_devfn(pdev_pf, n - 1));
I think this function requires a call pci_dev_put when you have finished using pdev_vf
> +
> + if (!pdev_vf) {
> + xe_sriov_notice(xe, "Can't link PF and VF%d due to missing pci dev..\n", n);
>
I wonder if the log about the missing VF pci device is not a serious enough problem to deserve at least a warn
Thanks,
Piotr
> + continue;
> + }
> +
> + /*
> + * When both PF and VF devices are enabled on the host, during system
> + * resume they are resuming in parallel.
> + *
> + * But PF has to complete the provision of VF first to allow any VFs to
> + * successfully resume.
> + *
> + * Create a parent-child device link between PF and VF devices that will
> + * enforce correct resume order.
> + */
> + link = device_link_add(&pdev_vf->dev, &pdev_pf->dev,
> + DL_FLAG_AUTOREMOVE_CONSUMER);
> + if (!link)
> + xe_sriov_notice(xe, "Failed linking PF and VF%u\n", n);
> + }
> +}
> +
> static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> {
> struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> @@ -92,6 +127,8 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> if (err < 0)
> goto failed;
>
> + pf_link_vfs(xe, num_vfs);
> +
> xe_sriov_info(xe, "Enabled %u of %u VF%s\n",
> num_vfs, total_vfs, str_plural(total_vfs));
> return num_vfs;
> --
> 2.35.3
>
--
More information about the Intel-xe
mailing list