/* * 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.
*/ for (n = 1; n <= num_vfs; n++) {
pdev_vf = xe_pci_pf_get_vf_dev(xe, n - 1);
/* unlikely, something weird is happening, abort */ if (!pdev_vf) {
xe_sriov_err(xe, "Cannot find VF%u device, aborting link%s creation!\n",
n, str_plural(num_vfs)); break;
}
link = device_link_add(&pdev_vf->dev, &pdev_pf->dev,
DL_FLAG_AUTOREMOVE_CONSUMER); /* unlikely and harmless, continue with other VFs */ if (!link)
xe_sriov_notice(xe, "Failed linking VF%u\n", n);
pci_dev_put(pdev_vf);
}
}
staticvoid pf_engine_activity_stats(struct xe_device *xe, unsignedint num_vfs, bool enable)
{ struct xe_gt *gt; unsignedint id; int ret = 0;
for_each_gt(gt, xe, id) {
ret = xe_guc_engine_activity_function_stats(>->uc.guc, num_vfs, enable); if (ret)
xe_gt_sriov_info(gt, "Failed to %s engine activity function stats (%pe)\n",
str_enable_disable(enable), ERR_PTR(ret));
}
}
err = xe_sriov_pf_wait_ready(xe); if (err) goto out;
/* * We must hold additional reference to the runtime PM to keep PF in D0 * during VFs lifetime, as our VFs do not implement the PM capability. * * With PF being in D0 state, all VFs will also behave as in D0 state. * This will also keep GuC alive with all VFs' configurations. * * We will release this additional PM reference in pf_disable_vfs().
*/
xe_pm_runtime_get_noresume(xe);
err = pf_provision_vfs(xe, num_vfs); if (err < 0) goto failed;
if (IS_DGFX(xe)) {
err = resize_vf_vram_bar(xe, num_vfs); if (err)
xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err);
}
err = pci_enable_sriov(pdev, 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));
/** * xe_pci_sriov_configure - Configure SR-IOV (enable/disable VFs). * @pdev: the &pci_dev * @num_vfs: number of VFs to enable or zero to disable all VFs * * This is the Xe implementation of struct pci_driver.sriov_configure callback. * * This callback will be called by the PCI subsystem to enable or disable SR-IOV * Virtual Functions (VFs) as requested by the used via the PCI sysfs interface. * * Return: number of configured VFs or a negative error code on failure.
*/ int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
{ struct xe_device *xe = pdev_to_xe_device(pdev); int ret;
if (!IS_SRIOV_PF(xe)) return -ENODEV;
if (num_vfs < 0) return -EINVAL;
if (num_vfs > xe_sriov_pf_get_totalvfs(xe)) return -ERANGE;
if (num_vfs && pci_num_vf(pdev)) return -EBUSY;
xe_pm_runtime_get(xe); if (num_vfs > 0)
ret = pf_enable_vfs(xe, num_vfs); else
ret = pf_disable_vfs(xe);
xe_pm_runtime_put(xe);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.