Commit c97cdf76 authored by Michal Wajdeczko's avatar Michal Wajdeczko
Browse files

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: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: default avatarMichał Winiarski <michal.winiarski@intel.com>
Link: https://lore.kernel.org/r/20250930233525.201263-2-michal.wajdeczko@intel.com
parent 846a81ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+3 −5
Original line number Diff line number Diff line
@@ -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);
		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)
+104 −0
Original line number Diff line number Diff line
// 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;
}
+16 −0
Original line number Diff line number Diff line
/* 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