mirror of
https://github.com/torvalds/linux.git
synced 2026-05-21 13:27:57 +02:00
drm/xe: Prepare for running in different SR-IOV modes
We will be adding support for the SR-IOV and driver might be then running, in addition to existing non-virtualized bare-metal mode, also in Physical Function (PF) or Virtual Function (VF) mode. Since these additional modes require some changes to the driver, define enum flag to represent different SR-IOV modes and add a function where we will detect the actual mode in the runtime. We start with a forced bare-metal mode as it is sufficient to enable basic functionality and ensures no impact to existing code. Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Link: https://lore.kernel.org/r/20231115073804.1861-2-michal.wajdeczko@intel.com Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
d6d14854dd
commit
13e5c32c84
|
|
@ -122,6 +122,9 @@ xe-y += xe_bb.o \
|
|||
# graphics hardware monitoring (HWMON) support
|
||||
xe-$(CONFIG_HWMON) += xe_hwmon.o
|
||||
|
||||
# graphics virtualization (SR-IOV) support
|
||||
xe-y += xe_sriov.o
|
||||
|
||||
# i915 Display compat #defines and #includes
|
||||
subdir-ccflags-$(CONFIG_DRM_XE_DISPLAY) += \
|
||||
-I$(srctree)/$(src)/display/ext \
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "xe_platform_types.h"
|
||||
#include "xe_pt_types.h"
|
||||
#include "xe_pmu.h"
|
||||
#include "xe_sriov_types.h"
|
||||
#include "xe_step_types.h"
|
||||
|
||||
#if IS_ENABLED(CONFIG_DRM_XE_DISPLAY)
|
||||
|
|
@ -299,6 +300,12 @@ struct xe_device {
|
|||
struct ttm_resource_manager sys_mgr;
|
||||
} mem;
|
||||
|
||||
/** @sriov: device level virtualization data */
|
||||
struct {
|
||||
/** @sriov.__mode: SR-IOV mode (Don't access directly!) */
|
||||
enum xe_sriov_mode __mode;
|
||||
} sriov;
|
||||
|
||||
/** @usm: unified memory state */
|
||||
struct {
|
||||
/** @asid: convert a ASID to VM */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "xe_module.h"
|
||||
#include "xe_pci_types.h"
|
||||
#include "xe_pm.h"
|
||||
#include "xe_sriov.h"
|
||||
#include "xe_step.h"
|
||||
|
||||
enum toggle_d3cold {
|
||||
|
|
@ -705,6 +706,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
|
||||
pci_set_master(pdev);
|
||||
|
||||
xe_sriov_probe_early(xe, desc->has_sriov);
|
||||
|
||||
err = xe_info_init(xe, desc, subplatform_desc);
|
||||
if (err)
|
||||
goto err_pci_disable;
|
||||
|
|
|
|||
55
drivers/gpu/drm/xe/xe_sriov.c
Normal file
55
drivers/gpu/drm/xe/xe_sriov.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#include "xe_assert.h"
|
||||
#include "xe_sriov.h"
|
||||
|
||||
/**
|
||||
* xe_sriov_mode_to_string - Convert enum value to string.
|
||||
* @mode: the &xe_sriov_mode to convert
|
||||
*
|
||||
* Returns: SR-IOV mode as a user friendly string.
|
||||
*/
|
||||
const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case XE_SRIOV_MODE_NONE:
|
||||
return "none";
|
||||
case XE_SRIOV_MODE_PF:
|
||||
return "SR-IOV PF";
|
||||
case XE_SRIOV_MODE_VF:
|
||||
return "SR-IOV VF";
|
||||
default:
|
||||
return "<invalid>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xe_sriov_probe_early - Probe a SR-IOV mode.
|
||||
* @xe: the &xe_device to probe mode on
|
||||
* @has_sriov: flag indicating hardware support for SR-IOV
|
||||
*
|
||||
* This function should be called only once and as soon as possible during
|
||||
* driver probe to detect whether we are running a SR-IOV Physical Function
|
||||
* (PF) or a Virtual Function (VF) device.
|
||||
*
|
||||
* SR-IOV PF mode detection is based on PCI @dev_is_pf() function.
|
||||
* SR-IOV VF mode detection is based on dedicated MMIO register read.
|
||||
*/
|
||||
void xe_sriov_probe_early(struct xe_device *xe, bool has_sriov)
|
||||
{
|
||||
enum xe_sriov_mode mode = XE_SRIOV_MODE_NONE;
|
||||
|
||||
/* TODO: replace with proper mode detection */
|
||||
xe_assert(xe, !has_sriov);
|
||||
|
||||
xe_assert(xe, !xe->sriov.__mode);
|
||||
xe->sriov.__mode = mode;
|
||||
xe_assert(xe, xe->sriov.__mode);
|
||||
|
||||
if (has_sriov)
|
||||
drm_info(&xe->drm, "Running in %s mode\n",
|
||||
xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
|
||||
}
|
||||
42
drivers/gpu/drm/xe/xe_sriov.h
Normal file
42
drivers/gpu/drm/xe/xe_sriov.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef _XE_SRIOV_H_
|
||||
#define _XE_SRIOV_H_
|
||||
|
||||
#include "xe_assert.h"
|
||||
#include "xe_device_types.h"
|
||||
#include "xe_sriov_types.h"
|
||||
|
||||
const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode);
|
||||
|
||||
void xe_sriov_probe_early(struct xe_device *xe, bool has_sriov);
|
||||
|
||||
static inline enum xe_sriov_mode xe_device_sriov_mode(struct xe_device *xe)
|
||||
{
|
||||
xe_assert(xe, xe->sriov.__mode);
|
||||
return xe->sriov.__mode;
|
||||
}
|
||||
|
||||
static inline bool xe_device_is_sriov_pf(struct xe_device *xe)
|
||||
{
|
||||
return xe_device_sriov_mode(xe) == XE_SRIOV_MODE_PF;
|
||||
}
|
||||
|
||||
static inline bool xe_device_is_sriov_vf(struct xe_device *xe)
|
||||
{
|
||||
return xe_device_sriov_mode(xe) == XE_SRIOV_MODE_VF;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI_IOV
|
||||
#define IS_SRIOV_PF(xe) xe_device_is_sriov_pf(xe)
|
||||
#else
|
||||
#define IS_SRIOV_PF(xe) (typecheck(struct xe_device *, (xe)) && false)
|
||||
#endif
|
||||
#define IS_SRIOV_VF(xe) xe_device_is_sriov_vf(xe)
|
||||
|
||||
#define IS_SRIOV(xe) (IS_SRIOV_PF(xe) || IS_SRIOV_VF(xe))
|
||||
|
||||
#endif
|
||||
28
drivers/gpu/drm/xe/xe_sriov_types.h
Normal file
28
drivers/gpu/drm/xe/xe_sriov_types.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef _XE_SRIOV_TYPES_H_
|
||||
#define _XE_SRIOV_TYPES_H_
|
||||
|
||||
#include <linux/build_bug.h>
|
||||
|
||||
/**
|
||||
* enum xe_sriov_mode - SR-IOV mode
|
||||
* @XE_SRIOV_MODE_NONE: bare-metal mode (non-virtualized)
|
||||
* @XE_SRIOV_MODE_PF: SR-IOV Physical Function (PF) mode
|
||||
* @XE_SRIOV_MODE_VF: SR-IOV Virtual Function (VF) mode
|
||||
*/
|
||||
enum xe_sriov_mode {
|
||||
/*
|
||||
* Note: We don't use default enum value 0 to allow catch any too early
|
||||
* attempt of checking the SR-IOV mode prior to the actual mode probe.
|
||||
*/
|
||||
XE_SRIOV_MODE_NONE = 1,
|
||||
XE_SRIOV_MODE_PF,
|
||||
XE_SRIOV_MODE_VF,
|
||||
};
|
||||
static_assert(XE_SRIOV_MODE_NONE);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user