Skip to content

Commit 94eae6e

Browse files
mwiniarsrodrigovivi
authored andcommitted
drm/xe/pf: Set VF LMEM BAR size
LMEM is partitioned between multiple VFs and we expect that the more VFs we have, the less LMEM is assigned to each VF. This means that we can achieve full LMEM BAR access without the need to attempt full VF LMEM BAR resize via pci_resize_resource(). Always try to set the largest possible BAR size that allows to fit the number of enabled VFs and inform the user in case the resize attempt is not successful. Signed-off-by: Michał Winiarski <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lucas De Marchi <[email protected]> (cherry picked from commit 32a4d1b) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 55d49f0 commit 94eae6e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

drivers/gpu/drm/xe/regs/xe_bars.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
#define GTTMMADR_BAR 0 /* MMIO + GTT */
99
#define LMEM_BAR 2 /* VRAM */
10+
#define VF_LMEM_BAR 9 /* VF VRAM */
1011

1112
#endif

drivers/gpu/drm/xe/xe_pci_sriov.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
* Copyright © 2023-2024 Intel Corporation
44
*/
55

6+
#include <linux/bitops.h>
7+
#include <linux/pci.h>
8+
9+
#include "regs/xe_bars.h"
610
#include "xe_assert.h"
711
#include "xe_device.h"
812
#include "xe_gt_sriov_pf_config.h"
@@ -128,6 +132,18 @@ static void pf_engine_activity_stats(struct xe_device *xe, unsigned int num_vfs,
128132
}
129133
}
130134

135+
static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs)
136+
{
137+
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
138+
u32 sizes;
139+
140+
sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs);
141+
if (!sizes)
142+
return 0;
143+
144+
return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes));
145+
}
146+
131147
static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
132148
{
133149
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
@@ -158,6 +174,12 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
158174
if (err < 0)
159175
goto failed;
160176

177+
if (IS_DGFX(xe)) {
178+
err = resize_vf_vram_bar(xe, num_vfs);
179+
if (err)
180+
xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err);
181+
}
182+
161183
err = pci_enable_sriov(pdev, num_vfs);
162184
if (err < 0)
163185
goto failed;

0 commit comments

Comments
 (0)