Skip to content

Commit 1f2880b

Browse files
committed
drm/xe/pf: Add SR-IOV PF specific early GT initialization
The PF driver must maintain additional GT level data per each VF. This additional per-VF data will be added in upcoming patches and will include: provisioning configuration (like GGTT space or LMEM allocation sizes or scheduling parameters), monitoring thresholds and counters, and more. As number of supported VFs varies across platforms use flexible array where first entry will contain metadata for the PF itself (if such configuration parameter is applicable for the PF) and all remaining entries will contain data for potential VFs. Reviewed-by: Himal Prasad Ghimiray <[email protected]> Signed-off-by: Michal Wajdeczko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3f11bcc commit 1f2880b

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ xe-y += \
160160
xe_sriov.o
161161

162162
xe-$(CONFIG_PCI_IOV) += \
163+
xe_gt_sriov_pf.o \
163164
xe_gt_sriov_pf_control.o \
164165
xe_gt_sriov_pf_policy.o \
165166
xe_lmtt.o \

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "xe_gt_mcr.h"
3030
#include "xe_gt_pagefault.h"
3131
#include "xe_gt_printk.h"
32+
#include "xe_gt_sriov_pf.h"
3233
#include "xe_gt_sysfs.h"
3334
#include "xe_gt_tlb_invalidation.h"
3435
#include "xe_gt_topology.h"
@@ -311,6 +312,12 @@ int xe_gt_init_early(struct xe_gt *gt)
311312
{
312313
int err;
313314

315+
if (IS_SRIOV_PF(gt_to_xe(gt))) {
316+
err = xe_gt_sriov_pf_init_early(gt);
317+
if (err)
318+
return err;
319+
}
320+
314321
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
315322
if (err)
316323
return err;

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright © 2023-2024 Intel Corporation
4+
*/
5+
6+
#include <drm/drm_managed.h>
7+
8+
#include "xe_gt_sriov_pf.h"
9+
#include "xe_gt_sriov_pf_helpers.h"
10+
11+
/*
12+
* VF's metadata is maintained in the flexible array where:
13+
* - entry [0] contains metadata for the PF (only if applicable),
14+
* - entries [1..n] contain metadata for VF1..VFn::
15+
*
16+
* <--------------------------- 1 + total_vfs ----------->
17+
* +-------+-------+-------+-----------------------+-------+
18+
* | 0 | 1 | 2 | | n |
19+
* +-------+-------+-------+-----------------------+-------+
20+
* | PF | VF1 | VF2 | ... ... | VFn |
21+
* +-------+-------+-------+-----------------------+-------+
22+
*/
23+
static int pf_alloc_metadata(struct xe_gt *gt)
24+
{
25+
unsigned int num_vfs = xe_gt_sriov_pf_get_totalvfs(gt);
26+
27+
gt->sriov.pf.vfs = drmm_kcalloc(&gt_to_xe(gt)->drm, 1 + num_vfs,
28+
sizeof(*gt->sriov.pf.vfs), GFP_KERNEL);
29+
if (!gt->sriov.pf.vfs)
30+
return -ENOMEM;
31+
32+
return 0;
33+
}
34+
35+
/**
36+
* xe_gt_sriov_pf_init_early - Prepare SR-IOV PF data structures on PF.
37+
* @gt: the &xe_gt to initialize
38+
*
39+
* Early initialization of the PF data.
40+
*
41+
* Return: 0 on success or a negative error code on failure.
42+
*/
43+
int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
44+
{
45+
int err;
46+
47+
err = pf_alloc_metadata(gt);
48+
if (err)
49+
return err;
50+
51+
return 0;
52+
}

drivers/gpu/drm/xe/xe_gt_sriov_pf.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2023-2024 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_GT_SRIOV_PF_H_
7+
#define _XE_GT_SRIOV_PF_H_
8+
9+
struct xe_gt;
10+
11+
#ifdef CONFIG_PCI_IOV
12+
int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
13+
#else
14+
static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
15+
{
16+
return 0;
17+
}
18+
#endif
19+
20+
#endif

drivers/gpu/drm/xe/xe_gt_sriov_pf_types.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@
1010

1111
#include "xe_gt_sriov_pf_policy_types.h"
1212

13+
/**
14+
* struct xe_gt_sriov_metadata - GT level per-VF metadata.
15+
*/
16+
struct xe_gt_sriov_metadata {
17+
/* XXX: VF metadata will go here */
18+
};
19+
1320
/**
1421
* struct xe_gt_sriov_pf - GT level PF virtualization data.
1522
* @policy: policy data.
23+
* @vfs: metadata for all VFs.
1624
*/
1725
struct xe_gt_sriov_pf {
1826
struct xe_gt_sriov_pf_policy policy;
27+
struct xe_gt_sriov_metadata *vfs;
1928
};
2029

2130
#endif

0 commit comments

Comments
 (0)