drm/xe/pf: Add top level functions to control VFs

We already have control functions that we use to control the VF
state on the per-GT basis, but that is low level detail from the
user point of view, who rather expects VF-level functions.

For now add simple functions that just iterate over all GTs and
call per-GT control function. We will soon allow to use some of
them from the user facing interfaces like debugfs.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
Link: https://lore.kernel.org/r/20250930233525.201263-2-michal.wajdeczko@intel.com
This commit is contained in:
Michal Wajdeczko 2025-10-01 01:35:19 +02:00
parent 846a81abbe
commit c97cdf7686
4 changed files with 124 additions and 5 deletions

View File

@ -174,6 +174,7 @@ xe-$(CONFIG_PCI_IOV) += \
xe_lmtt_ml.o \
xe_pci_sriov.o \
xe_sriov_pf.o \
xe_sriov_pf_control.o \
xe_sriov_pf_debugfs.o \
xe_sriov_pf_service.o \
xe_tile_sriov_pf_debugfs.o

View File

@ -17,6 +17,7 @@
#include "xe_pm.h"
#include "xe_sriov.h"
#include "xe_sriov_pf.h"
#include "xe_sriov_pf_control.h"
#include "xe_sriov_pf_helpers.h"
#include "xe_sriov_printk.h"
@ -60,13 +61,10 @@ static void pf_unprovision_vfs(struct xe_device *xe, unsigned int num_vfs)
static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
{
struct xe_gt *gt;
unsigned int id;
unsigned int n;
for_each_gt(gt, xe, id)
for (n = 1; n <= num_vfs; n++)
xe_gt_sriov_pf_control_trigger_flr(gt, n);
for (n = 1; n <= num_vfs; n++)
xe_sriov_pf_control_reset_vf(xe, n);
}
static struct pci_dev *xe_pci_pf_get_vf_dev(struct xe_device *xe, unsigned int vf_id)

View File

@ -0,0 +1,104 @@
// SPDX-License-Identifier: MIT
/*
* Copyright © 2025 Intel Corporation
*/
#include "xe_device.h"
#include "xe_gt_sriov_pf_control.h"
#include "xe_sriov_pf_control.h"
/**
* xe_sriov_pf_control_pause_vf() - Pause a VF on all GTs.
* @xe: the &xe_device
* @vfid: the VF identifier (can't be 0 == PFID)
*
* This function is for PF only.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_sriov_pf_control_pause_vf(struct xe_device *xe, unsigned int vfid)
{
struct xe_gt *gt;
unsigned int id;
int result = 0;
int err;
for_each_gt(gt, xe, id) {
err = xe_gt_sriov_pf_control_pause_vf(gt, vfid);
result = result ? -EUCLEAN : err;
}
return result;
}
/**
* xe_sriov_pf_control_resume_vf() - Resume a VF on all GTs.
* @xe: the &xe_device
* @vfid: the VF identifier
*
* This function is for PF only.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_sriov_pf_control_resume_vf(struct xe_device *xe, unsigned int vfid)
{
struct xe_gt *gt;
unsigned int id;
int result = 0;
int err;
for_each_gt(gt, xe, id) {
err = xe_gt_sriov_pf_control_resume_vf(gt, vfid);
result = result ? -EUCLEAN : err;
}
return result;
}
/**
* xe_sriov_pf_control_stop_vf - Stop a VF on all GTs.
* @xe: the &xe_device
* @vfid: the VF identifier
*
* This function is for PF only.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_sriov_pf_control_stop_vf(struct xe_device *xe, unsigned int vfid)
{
struct xe_gt *gt;
unsigned int id;
int result = 0;
int err;
for_each_gt(gt, xe, id) {
err = xe_gt_sriov_pf_control_stop_vf(gt, vfid);
result = result ? -EUCLEAN : err;
}
return result;
}
/**
* xe_sriov_pf_control_reset_vf() - Perform a VF reset (FLR).
* @xe: the &xe_device
* @vfid: the VF identifier
*
* This function is for PF only.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_sriov_pf_control_reset_vf(struct xe_device *xe, unsigned int vfid)
{
struct xe_gt *gt;
unsigned int id;
int result = 0;
int err;
for_each_gt(gt, xe, id) {
err = xe_gt_sriov_pf_control_trigger_flr(gt, vfid);
result = result ? -EUCLEAN : err;
}
return result;
}

View File

@ -0,0 +1,16 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2025 Intel Corporation
*/
#ifndef _XE_SRIOV_PF_CONTROL_H_
#define _XE_SRIOV_PF_CONTROL_H_
struct xe_device;
int xe_sriov_pf_control_pause_vf(struct xe_device *xe, unsigned int vfid);
int xe_sriov_pf_control_resume_vf(struct xe_device *xe, unsigned int vfid);
int xe_sriov_pf_control_stop_vf(struct xe_device *xe, unsigned int vfid);
int xe_sriov_pf_control_reset_vf(struct xe_device *xe, unsigned int vfid);
#endif