Skip to content

Commit 026769f

Browse files
Introduce explicit OOT module mode in backport script
1. Add -k / --create-oot option (with --create-oot compatibility alias) 2. Keep default create-tree behavior as non-oot (exclude oot patches) 3. Make oot mode apply all patches, including oot patches using ./backport.sh -k 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 oot-module-only flow. Signed-off-by: Pravalika Gurram <pravalika.gurram@intel.com>
1 parent cb5cf3e commit 026769f

4 files changed

Lines changed: 269 additions & 48 deletions

File tree

README.md

Lines changed: 47 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. |-k, --create-oot| Create tree for OOT modules and apply all patches including oot 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/oot/`.
51+
- `./backport.sh -c base`: applies only `backport/patches/base/`.
52+
- `./backport.sh -k` or `./backport.sh --create-oot`: applies all patches including `backport/patches/oot/`.
53+
54+
### Examples
55+
56+
```bash
57+
# default tree (base + features, no oot)
58+
./backport.sh
59+
60+
# base-only tree
61+
./backport.sh -c base
62+
63+
# oot module (all patches + oot patches)
64+
./backport.sh -k
65+
```
4666

4767
# Debugging
4868

@@ -88,6 +108,7 @@ Place the patch in the appropriate directory based on patch type:
88108
```
89109
backport/patches/
90110
├── base/ # All fixes and patches merged in drm-tip
111+
├── oot/ # oot-module specific patches
91112
└── features/ # Feature patches under review
92113
├── eu-debug/
93114
├── sriov/
@@ -96,12 +117,14 @@ backport/patches/
96117

97118
#### Placement Rules:
98119
- **`backport/patches/base/`** - For all fixes and patches already merged in drm-tip
120+
- **`backport/patches/oot/`** - For oot-module-specific patches
99121
- **`backport/patches/features/<feature-name>/`** - For new feature patches under review
100122
- Place feature patches in the appropriate feature subdirectory
101123
- If the feature directory doesn't exist, create one with a descriptive name
102124

103125
**Examples:**
104126
- Bug fix → `backport/patches/base/0001-fix-memory-leak.patch`
127+
- OOT update → `backport/patches/oot/0001-update-oot-build.patch`
105128
- SR-IOV feature → `backport/patches/features/sriov/0001-add-sriov-support.patch`
106129
- EU Debug feature → `backport/patches/features/eu-debug/0001-enable-eu-debug.patch`
107130

@@ -110,6 +133,9 @@ backport/patches/
110133
# For base patches
111134
cp <your-patch>.patch backport/patches/base/
112135

136+
# For oot patches
137+
cp <your-patch>.patch backport/patches/oot/
138+
113139
# For feature patches
114140
cp <your-patch>.patch backport/patches/features/<feature-name>
115141
```
@@ -147,6 +173,24 @@ After successful tree generation, verify your changes:
147173
- Create a pull request with clear description
148174
- Reference upstream commit or mailing list discussion
149175

176+
## Adding OOT Patches
177+
178+
Use this flow when creating patches specifically for OOT packaging.
179+
180+
1. Create the change in the generated `kernel/` tree and export it as a patch.
181+
```bash
182+
cd kernel
183+
git format-patch -N1 <commit-hash> --zero-commit
184+
```
185+
186+
2. Place the generated patch under `backport/patches/oot/` and add it to the `series` file.
187+
188+
3. Run oot module creation:
189+
```bash
190+
./backport.sh -k
191+
```
192+
This applies all patches including oot module patches.
193+
150194
# License
151195

152196
This work is a subset of the Linux kernel as such we keep the kernel's

backport.sh

Lines changed: 89 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,50 @@ 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,k
26+
LONG=create-tree:delete-tree,help,reset-tree,override,create-oot
2727
OPTS=$(getopt -a --options $SHORT --longoptions $LONG -- "$@")
2828

2929
flavor="features"
3030
is_existing_tree=0
3131
is_override=0
3232
xkb_tag=""
33+
is_oot_tree=0
34+
requested_flavor=""
3335

3436
usage () {
3537
echo ""
36-
echo "Usage: $0 [-c|--create-tree] [-d|--delete-tree] [-r|--reset-tree]"
38+
echo "Usage: $0 [-c|--create-tree] [-d|--delete-tree] [-r|--reset-tree] [-k|--create-oot]"
3739
echo ""
3840
echo "Options:"
3941
echo " -c, --create-tree Create kernel tree based on given option <base/features>"
4042
echo " -d, --delete-tree Delete the tree"
4143
echo " -r, --reset-tree Delete the existing tree and re-create it"
4244
echo " -o, --override Overrides the existing tree"
45+
echo " -k, --create-oot Create oot tree (includes oot patches)"
4346
exit 1
4447
}
4548

4649
apply_patches() {
4750
echo "Applying local patches"
4851
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
52+
# Ignore comments/blank lines from series
53+
case "$p" in
54+
""|\#*)
5655
continue
57-
else
58-
break
59-
fi
60-
;;
56+
;;
6157
esac
58+
59+
# Patch selection policy:
60+
# - default: apply all except oot
61+
# - -c base: apply only base patches
62+
# - -k/--create-oot: apply all patches including oot
63+
if [[ "$flavor" == "base" ]]; then
64+
[[ "$p" == *"/base/"* ]] || continue
65+
elif [[ $is_oot_tree -eq 0 ]]; then
66+
[[ "$p" == *"/oot/"* ]] && continue
67+
fi
68+
6269
git am -q -s "$WORKING_DIR/$p"
6370
if [ $? -ne 0 ]; then
6471
echo "Failed to apply patch $p"
@@ -140,43 +147,80 @@ delete_kernel_tree () {
140147
}
141148

142149
xkb_tag=$(git -C $WORKING_DIR describe --always --tags)
150+
143151
if [ ! $# -gt 0 ]; then
144152
echo "No option provided, so proceeding with create-tree"
145-
create_kernel_tree
153+
create_kernel_tree
146154
fi
147155

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
156+
eval set -- "$OPTS"
157+
action="create"
155158

156-
case $1 in
157-
-c|--create-tree|-o|--override)
158-
if [ ! $# -gt 1 ]; then
159-
echo "No option provided for creating the tree"
159+
while true; do
160+
case "$1" in
161+
-c|--create-tree)
162+
if [ -n "$2" ] && [ "$2" != "--" ] && [[ "$2" != -* ]]; then
163+
requested_flavor="$2"
164+
shift 2
160165
else
161-
flavor=$2
166+
shift
162167
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;;
168+
;;
169+
-k|--create-oot)
170+
is_oot_tree=1
171+
shift
172+
;;
173+
-o|--override)
174+
is_override=1
175+
shift
176+
;;
177+
-d|--delete-tree)
178+
action="delete"
179+
shift
180+
;;
170181
-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
182+
action="reset"
183+
shift
184+
;;
185+
-h|--help)
186+
usage
187+
;;
188+
--)
189+
shift
190+
break
191+
;;
192+
*)
193+
echo "Invalid option: $1"
194+
usage
195+
;;
196+
esac
182197
done
198+
199+
if [ "$is_oot_tree" -eq 1 ]; then
200+
flavor="oot"
201+
elif [ -n "$requested_flavor" ]; then
202+
flavor="$requested_flavor"
203+
fi
204+
205+
case "$action" in
206+
create)
207+
echo "Creating the tree with $flavor"
208+
create_kernel_tree
209+
exit
210+
;;
211+
delete)
212+
echo "Deleting the tree"
213+
delete_kernel_tree
214+
exit
215+
;;
216+
reset)
217+
echo "Deleting the existing tree and re-creating it"
218+
delete_kernel_tree
219+
create_kernel_tree
220+
exit
221+
;;
222+
*)
223+
echo "Invalid option"
224+
usage
225+
;;
226+
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: 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+

0 commit comments

Comments
 (0)