Skip to content

Commit d7d496b

Browse files
Introduce explicit DKMS mode in backport script
1. Add -m / --dkms option (with -dkms compatibility alias) 2. Keep default create-tree behavior as non-DKMS (exclude dkms patches) 3. Make DKMS mode apply all patches, including dkms patches using ./backport.sh -m 4. Update README usage/options and examples to document new behavior 5. This helps other components continue working on full-kernel integration instead of being forced into DKMS-only flow. Signed-off-by: Pravalika Gurram <pravalika.gurram@intel.com>
1 parent 5d4774a commit d7d496b

4 files changed

Lines changed: 256 additions & 48 deletions

File tree

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,29 @@ backport.sh < options >
4040
||options |description |
4141
|-- |--|--|
4242
|1. |create-tree| Create kernel tree based on given option <base/features> (default)|
43-
|2. |delete-tree| Delete the tree|
44-
|3. |reset-tree| Delete the existing tree and re-create it|
45-
|4. |override| Overrides existing tree|
43+
|2. |-m, --dkms| Create DKMS tree and apply all patches including dkms patches|
44+
|3. |delete-tree| Delete the tree|
45+
|4. |reset-tree| Delete the existing tree and re-create it|
46+
|5. |override| Overrides existing tree|
47+
48+
### Patch application modes
49+
50+
- `./backport.sh` (default): applies all patches except `backport/patches/dkms/`.
51+
- `./backport.sh -c base`: applies only `backport/patches/base/`.
52+
- `./backport.sh -m` or `./backport.sh --dkms`: applies all patches including `backport/patches/dkms/`.
53+
54+
### Examples
55+
56+
```bash
57+
# default tree (base + features, no dkms)
58+
./backport.sh
59+
60+
# base-only tree
61+
./backport.sh -c base
62+
63+
# dkms tree (all patches + dkms)
64+
./backport.sh -m
65+
```
4666

4767
# Debugging
4868

backport.sh

Lines changed: 100 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,61 @@ fi
2222

2323
KERNEL="linux-${KERNEL_TAG/v}"
2424

25-
SHORT=:c,d,h,r,o
26-
LONG=create-tree:delete-tree,help,reset-tree,override
25+
SHORT=:c,d,h,r,o,m
26+
LONG=create-tree:delete-tree,help,reset-tree,override,dkms
27+
28+
args=()
29+
for i in "$@"; do
30+
if [ "$i" = "-dkms" ]; then
31+
args+=("--dkms")
32+
else
33+
args+=("$i")
34+
fi
35+
done
36+
set -- "${args[@]}"
37+
2738
OPTS=$(getopt -a --options $SHORT --longoptions $LONG -- "$@")
2839

2940
flavor="features"
3041
is_existing_tree=0
3142
is_override=0
3243
xkb_tag=""
44+
is_oot_tree=0
45+
requested_flavor=""
3346

3447
usage () {
3548
echo ""
36-
echo "Usage: $0 [-c|--create-tree] [-d|--delete-tree] [-r|--reset-tree]"
49+
echo "Usage: $0 [-c|--create-tree] [-d|--delete-tree] [-r|--reset-tree] [-m|--dkms]"
3750
echo ""
3851
echo "Options:"
3952
echo " -c, --create-tree Create kernel tree based on given option <base/features>"
4053
echo " -d, --delete-tree Delete the tree"
4154
echo " -r, --reset-tree Delete the existing tree and re-create it"
4255
echo " -o, --override Overrides the existing tree"
56+
echo " -m, --dkms Create dkms tree (includes dkms patches)"
4357
exit 1
4458
}
4559

4660
apply_patches() {
4761
echo "Applying local patches"
4862
while read p; do
49-
case "$p" in \#*)
50-
if [ ! -z "$flavor" ]; then
51-
echo $p | tr -d "#" | (read name; echo "Applying $name patches..!" >&2)
52-
if [[ "$flavor" == "base" ]]; then
53-
echo "Only base patches will be applied"
54-
flavor=""
55-
fi
63+
# Ignore comments/blank lines from series
64+
case "$p" in
65+
""|\#*)
5666
continue
57-
else
58-
break
59-
fi
60-
;;
67+
;;
6168
esac
69+
70+
# Patch selection policy:
71+
# - default: apply all except dkms
72+
# - -c base: apply only base patches
73+
# - -m/--dkms: apply all patches including dkms
74+
if [[ "$flavor" == "base" ]]; then
75+
[[ "$p" == *"/base/"* ]] || continue
76+
elif [[ $is_oot_tree -eq 0 ]]; then
77+
[[ "$p" == *"/dkms/"* ]] && continue
78+
fi
79+
6280
git am -q -s "$WORKING_DIR/$p"
6381
if [ $? -ne 0 ]; then
6482
echo "Failed to apply patch $p"
@@ -140,43 +158,80 @@ delete_kernel_tree () {
140158
}
141159

142160
xkb_tag=$(git -C $WORKING_DIR describe --always --tags)
161+
143162
if [ ! $# -gt 0 ]; then
144163
echo "No option provided, so proceeding with create-tree"
145-
create_kernel_tree
164+
create_kernel_tree
146165
fi
147166

148-
while [ $# -gt 0 ]; do
149-
for arg in "$@"
150-
do
151-
if [ "$arg" == "--override" ] || [ "$arg" == "-o" ]; then
152-
is_override=1
153-
fi
154-
done
167+
eval set -- "$OPTS"
168+
action="create"
155169

156-
case $1 in
157-
-c|--create-tree|-o|--override)
158-
if [ ! $# -gt 1 ]; then
159-
echo "No option provided for creating the tree"
170+
while true; do
171+
case "$1" in
172+
-c|--create-tree)
173+
if [ -n "$2" ] && [ "$2" != "--" ] && [[ "$2" != -* ]]; then
174+
requested_flavor="$2"
175+
shift 2
160176
else
161-
flavor=$2
177+
shift
162178
fi
163-
echo "Creating the tree with $flavor"
164-
create_kernel_tree
165-
exit;;
166-
-d|--delete-tree)
167-
echo "Deleting the tree"
168-
delete_kernel_tree
169-
exit;;
179+
;;
180+
-m|--dkms)
181+
is_oot_tree=1
182+
shift
183+
;;
184+
-o|--override)
185+
is_override=1
186+
shift
187+
;;
188+
-d|--delete-tree)
189+
action="delete"
190+
shift
191+
;;
170192
-r|--reset-tree)
171-
echo "Deleting the existing tree and re-creating it"
172-
delete_kernel_tree
173-
create_kernel_tree
174-
exit;;
175-
-h|--help)
176-
usage
177-
;;
178-
*)
179-
echo "Invalid option: $1"
180-
usage
181-
esac
193+
action="reset"
194+
shift
195+
;;
196+
-h|--help)
197+
usage
198+
;;
199+
--)
200+
shift
201+
break
202+
;;
203+
*)
204+
echo "Invalid option: $1"
205+
usage
206+
;;
207+
esac
182208
done
209+
210+
if [ "$is_oot_tree" -eq 1 ]; then
211+
flavor="dkms"
212+
elif [ -n "$requested_flavor" ]; then
213+
flavor="$requested_flavor"
214+
fi
215+
216+
case "$action" in
217+
create)
218+
echo "Creating the tree with $flavor"
219+
create_kernel_tree
220+
exit
221+
;;
222+
delete)
223+
echo "Deleting the tree"
224+
delete_kernel_tree
225+
exit
226+
;;
227+
reset)
228+
echo "Deleting the existing tree and re-creating it"
229+
delete_kernel_tree
230+
create_kernel_tree
231+
exit
232+
;;
233+
*)
234+
echo "Invalid option"
235+
usage
236+
;;
237+
esac
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
3+
Date: Thu, 22 Jan 2026 00:00:00 +0000
4+
Subject: [PATCH] drm/xe/pf: Handle VF BAR resize without PCI VF REBAR helpers
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Implement VF BAR resizing via the VF Resizable BAR capability directly
10+
in PCI config space for kernels that lack PCI VF REBAR helper APIs.
11+
12+
Suggested-by: Michał Winiarski <michal.winiarski@intel.com>
13+
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
14+
---
15+
drivers/gpu/drm/xe/xe_pci_sriov.c | 94 +++++++++++++++++++++++++++++--
16+
1 file changed, 90 insertions(+), 4 deletions(-)
17+
18+
diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
19+
index 9ff69c484..1246ffc76 100644
20+
--- a/drivers/gpu/drm/xe/xe_pci_sriov.c
21+
+++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
22+
@@ -82,16 +82,102 @@ static void pf_engine_activity_stats(struct xe_device *xe, unsigned int num_vfs,
23+
}
24+
}
25+
26+
+/*
27+
+ * Backport-only fallback: program VF REBAR directly when PCI-core helpers
28+
+ * are not available.
29+
+ */
30+
+
31+
+#ifndef PCI_EXT_CAP_ID_VF_REBAR
32+
+#define PCI_EXT_CAP_ID_VF_REBAR 0x24 /* VF Resizable BAR */
33+
+#endif
34+
+
35+
+static inline resource_size_t pci_rebar_size_to_bytes(int size)
36+
+{
37+
+ return 1ULL << (size + ilog2((resource_size_t)SZ_1M));
38+
+}
39+
+
40+
+/*
41+
+ * The real 'struct pci_sriov' is PCI-core internal (drivers/pci/pci.h).
42+
+ * This local copy is used only to update pdev->sriov->barsz[].
43+
+ */
44+
+struct pci_sriov {
45+
+ int pos; /* Capability position */
46+
+ int nres; /* Number of resources */
47+
+ u32 cap; /* SR-IOV Capabilities */
48+
+ u16 ctrl; /* SR-IOV Control */
49+
+ u16 total_VFs; /* Total VFs associated with the PF */
50+
+ u16 initial_VFs; /* Initial VFs associated with the PF */
51+
+ u16 num_VFs; /* Number of VFs available */
52+
+ u16 offset; /* First VF Routing ID offset */
53+
+ u16 stride; /* Following VF stride */
54+
+ u16 vf_device; /* VF device ID */
55+
+ u32 pgsz; /* Page size for BAR alignment */
56+
+ u8 link; /* Function Dependency Link */
57+
+ u8 max_VF_buses; /* Max buses consumed by VFs */
58+
+ u16 driver_max_VFs; /* Max num VFs driver supports */
59+
+ struct pci_dev *dev; /* Lowest numbered PF */
60+
+ struct pci_dev *self; /* This PF */
61+
+ u32 class; /* VF device */
62+
+ u8 hdr_type; /* VF header type */
63+
+ u16 subsystem_vendor; /* VF subsystem vendor */
64+
+ u16 subsystem_device; /* VF subsystem device */
65+
+ resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */
66+
+ bool drivers_autoprobe; /* Auto probing of VFs by driver */
67+
+};
68+
+
69+
static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs)
70+
{
71+
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
72+
- u32 sizes;
73+
+ resource_size_t size, total;
74+
+ int pos, i, vf_bar_idx = VF_LMEM_BAR - PCI_IOV_RESOURCES;
75+
+ u32 rebar, ctrl;
76+
+ int err;
77+
78+
- sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs);
79+
- if (!sizes)
80+
+ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_VF_REBAR);
81+
+ if (!pos)
82+
return 0;
83+
84+
- return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes));
85+
+ /* Expecting a single VF resizable BAR, and it to be BAR2. */
86+
+ err = pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
87+
+ if (err)
88+
+ return err;
89+
+
90+
+ if (FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, ctrl) != 1 ||
91+
+ FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, ctrl) != vf_bar_idx) {
92+
+ xe_sriov_warn(xe, "Unexpected resource in VF resizable BAR, skipping resize\\n");
93+
+ return 0;
94+
+ }
95+
+
96+
+ err = pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &rebar);
97+
+ if (err)
98+
+ return err;
99+
+
100+
+ rebar = FIELD_GET(PCI_REBAR_CAP_SIZES, rebar);
101+
+ total = pci_resource_len(pdev, VF_LMEM_BAR);
102+
+
103+
+ while (rebar) {
104+
+ i = __fls(rebar);
105+
+ size = pci_rebar_size_to_bytes(i);
106+
+
107+
+ if (num_vfs && size <= div_u64(total, num_vfs)) {
108+
+ ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
109+
+ ctrl |= i << PCI_REBAR_CTRL_BAR_SHIFT;
110+
+
111+
+ err = pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
112+
+ if (err)
113+
+ return err;
114+
+
115+
+ ((struct pci_sriov *)pdev->sriov)->barsz[vf_bar_idx] = size;
116+
+
117+
+ xe_sriov_info(xe, "VF BAR%d resized to %llu MiB\\n",
118+
+ vf_bar_idx, (unsigned long long)(size >> 20));
119+
+ break;
120+
+ }
121+
+
122+
+ rebar &= ~BIT(i);
123+
+ }
124+
+
125+
+ return 0;
126+
}
127+
128+
static int pf_prepare_vfs_enabling(struct xe_device *xe)
129+
--
130+
2.34.1
131+

series

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,5 @@ backport/patches/features/eu-debug/0001-drm-xe-eudebug-update-eudebug-prelim-fla
343343
backport/patches/features/eu-debug/0001-drm-xe-eudebug-add-eudebug-drm-managed-finalize.patch
344344
backport/patches/features/eu-debug/0001-drm-xe-eudebug-Check-attention-bits-only-once-in-att.patch
345345
backport/patches/features/eu-debug/0001-drm-xe-eudebug-xe_eudebug_init-fixup.patch
346+
#dkms
347+
backport/patches/dkms/0001-drm-xe-pf-Handle-VF-BAR-resize-without-PCI-VF-REBAR-.patch

0 commit comments

Comments
 (0)