aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/40-linux-5.13-support.patch
blob: e95e240492088125b7d32fb88b6840e0da9be5d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
Subject: Fix build errors with linux 5.13
Origin: upstream, https://www.virtualbox.org/browser/vbox/trunk
Bug: https://bugs.launchpad.net/bugs/1929193

diff -urpN virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_drv.h virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_drv.h
--- virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_drv.h	2021-04-28 16:24:47.000000000 +0000
+++ virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_drv.h	2021-06-23 10:08:44.431714404 +0000
@@ -46,20 +41,20 @@
  * Evaluates to true if the linux kernel version is equal or higher to the
  * one specfied. */
 #define RTLNX_VER_MIN(a_Major, a_Minor, a_Patch) \
-    (LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
 
 /** @def RTLNX_VER_MAX
  * Evaluates to true if the linux kernel version is less to the one specfied
  * (exclusive). */
 #define RTLNX_VER_MAX(a_Major, a_Minor, a_Patch) \
-    (LINUX_VERSION_CODE < KERNEL_VERSION(a_Major, a_Minor, a_Patch))
+	(LINUX_VERSION_CODE < KERNEL_VERSION(a_Major, a_Minor, a_Patch))
 
 /** @def RTLNX_VER_RANGE
  * Evaluates to true if the linux kernel version is equal or higher to the given
  * minimum version and less (but not equal) to the maximum version (exclusive). */
 #define RTLNX_VER_RANGE(a_MajorMin, a_MinorMin, a_PatchMin,  a_MajorMax, a_MinorMax, a_PatchMax) \
-    (   LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
-     && LINUX_VERSION_CODE <  KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
+	(   LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
+	 && LINUX_VERSION_CODE <  KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
 
 
 /** @def RTLNX_RHEL_MIN
@@ -70,7 +65,7 @@
  */
 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
 # define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) \
-     ((RHEL_MAJOR) > (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor)))
+	 ((RHEL_MAJOR) > (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor)))
 #else
 # define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) (0)
 #endif
@@ -83,7 +78,7 @@
  */
 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
 # define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) \
-     ((RHEL_MAJOR) < (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) < (a_iMinor)))
+	 ((RHEL_MAJOR) < (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) < (a_iMinor)))
 #else
 # define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) (0)
 #endif
@@ -95,7 +90,7 @@
  */
 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
 # define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin,  a_iMajorMax, a_iMinorMax) \
-     (RTLNX_RHEL_MIN(a_iMajorMin, a_iMinorMin) && RTLNX_RHEL_MAX(a_iMajorMax, a_iMinorMax))
+	 (RTLNX_RHEL_MIN(a_iMajorMin, a_iMinorMin) && RTLNX_RHEL_MAX(a_iMajorMax, a_iMinorMax))
 #else
 # define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin,  a_iMajorMax, a_iMinorMax)  (0)
 #endif
@@ -173,7 +168,9 @@
 #include <drm/ttm/ttm_bo_api.h>
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
+#if RTLNX_VER_MAX(5,13,0)
 #include <drm/ttm/ttm_memory.h>
+#endif
 #if RTLNX_VER_MAX(5,12,0)
 # include <drm/ttm/ttm_module.h>
 #endif
@@ -222,7 +219,7 @@ static inline void drm_gem_object_put(st
 				 VBVA_ADAPTER_INFORMATION_SIZE)
 #define GUEST_HEAP_SIZE   VBVA_ADAPTER_INFORMATION_SIZE
 #define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \
-				sizeof(HGSMIHOSTFLAGS))
+				sizeof(struct hgsmi_host_flags))
 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
 
 /** How frequently we refresh if the guest is not providing dirty rectangles. */
@@ -232,7 +229,7 @@ static inline void drm_gem_object_put(st
 static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size,
 				 gfp_t flags)
 {
-    return devm_kzalloc(dev, n * size, flags);
+	return devm_kzalloc(dev, n * size, flags);
 }
 #endif
 
@@ -244,7 +241,7 @@ struct vbox_private {
 	u8 __iomem *guest_heap;
 	u8 __iomem *vbva_buffers;
 	struct gen_pool *guest_pool;
-	struct VBVABUFFERCONTEXT *vbva_info;
+	struct vbva_buf_context *vbva_info;
 	bool any_pitch;
 	u32 num_crtcs;
 	/** Amount of available VRAM, including space used for buffers. */
@@ -252,7 +249,7 @@ struct vbox_private {
 	/** Amount of available VRAM, not including space used for buffers. */
 	u32 available_vram_size;
 	/** Array of structures for receiving mode hints. */
-	VBVAMODEHINT *last_mode_hints;
+	struct vbva_modehint *last_mode_hints;
 
 	struct vbox_fbdev *fbdev;
 
@@ -263,7 +260,11 @@ struct vbox_private {
 		struct drm_global_reference mem_global_ref;
 		struct ttm_bo_global_ref bo_global_ref;
 #endif
+#if RTLNX_VER_MIN(5,13,0) 
+		struct ttm_device bdev; 
+#else
 		struct ttm_bo_device bdev;
+#endif
 		bool mm_initialised;
 	} ttm;
 
diff -urpN virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_ttm.c virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_ttm.c
--- virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_ttm.c	2021-04-28 16:24:47.000000000 +0000
+++ virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_ttm.c	2021-06-23 10:08:07.164057918 +0000
@@ -48,7 +43,11 @@
 #endif
 
 
+#if RTLNX_VER_MIN(5,13,0)
+static inline struct vbox_private *vbox_bdev(struct ttm_device *bd)
+#else
 static inline struct vbox_private *vbox_bdev(struct ttm_bo_device *bd)
+#endif
 {
 	return container_of(bd, struct vbox_private, ttm.bdev);
 }
@@ -188,7 +187,7 @@ static int vbox_ttm_io_mem_reserve(struc
 	mem->bus.size = mem->num_pages << PAGE_SHIFT;
 	mem->bus.base = 0;
 	mem->bus.is_iomem = false;
-	if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
+	 if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
 		return -EINVAL;
 	switch (mem->mem_type) {
 	case TTM_PL_SYSTEM:
@@ -205,8 +204,13 @@ static int vbox_ttm_io_mem_reserve(struc
 	return 0;
 }
 #else
+# if RTLNX_VER_MAX(5,13,0)
 static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
 				   struct ttm_resource *mem)
+# else /* > 5.13.0 */
+static int vbox_ttm_io_mem_reserve(struct ttm_device *bdev,
+				   struct ttm_resource *mem)
+# endif /* > 5.13.0 */
 {
 	struct vbox_private *vbox = vbox_bdev(bdev);
 	mem->bus.addr = NULL;
@@ -241,7 +245,12 @@ static int vbox_ttm_io_mem_reserve(struc
 
 
 
-#if RTLNX_VER_MIN(5,10,0)
+#if RTLNX_VER_MIN(5,13,0)
+static void vbox_ttm_io_mem_free(struct ttm_device *bdev,
+				 struct ttm_resource *mem)
+{
+}
+#elif RTLNX_VER_MIN(5,10,0)
 static void vbox_ttm_io_mem_free(struct ttm_bo_device *bdev,
 				 struct ttm_resource *mem)
 {
@@ -253,7 +262,13 @@ static void vbox_ttm_io_mem_free(struct
 }
 #endif
 
-#if RTLNX_VER_MIN(5,10,0)
+#if RTLNX_VER_MIN(5,13,0)
+static void vbox_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *tt)
+{
+	ttm_tt_fini(tt);
+	kfree(tt);
+}
+#elif RTLNX_VER_MIN(5,10,0)
 static void vbox_ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *tt)
 {
 	ttm_tt_fini(tt);
@@ -333,7 +348,11 @@ static int vbox_bo_move(struct ttm_buffe
 }
 #endif
 
+#if RTLNX_VER_MIN(5,13,0)
+static struct ttm_device_funcs vbox_bo_driver = {
+#else /* < 5.13.0 */
 static struct ttm_bo_driver vbox_bo_driver = {
+#endif /* < 5.13.0 */
 	.ttm_tt_create = vbox_ttm_tt_create,
 #if RTLNX_VER_MIN(5,10,0)
 	.ttm_tt_destroy = vbox_ttm_tt_destroy,
@@ -370,14 +389,22 @@ int vbox_mm_init(struct vbox_private *vb
 {
 	int ret;
 	struct drm_device *dev = vbox->dev;
+#if RTLNX_VER_MIN(5,13,0)
+	struct ttm_device *bdev = &vbox->ttm.bdev;
+#else
 	struct ttm_bo_device *bdev = &vbox->ttm.bdev;
+#endif
 
 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
 	ret = vbox_ttm_global_init(vbox);
 	if (ret)
 		return ret;
 #endif
+#if RTLNX_VER_MIN(5,13,0)
+	ret = ttm_device_init(&vbox->ttm.bdev,
+#else
 	ret = ttm_bo_device_init(&vbox->ttm.bdev,
+#endif
 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
 				 vbox->ttm.bo_global_ref.ref.object,
 #endif
@@ -429,7 +456,11 @@ int vbox_mm_init(struct vbox_private *vb
 	return 0;
 
 err_device_release:
+#if RTLNX_VER_MIN(5,13,0)
+	ttm_device_fini(&vbox->ttm.bdev);
+#else
 	ttm_bo_device_release(&vbox->ttm.bdev);
+#endif
 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
 err_ttm_global_release:
 	vbox_ttm_global_release(vbox);
@@ -446,7 +477,11 @@ void vbox_mm_fini(struct vbox_private *v
 #else
 	arch_phys_wc_del(vbox->fb_mtrr);
 #endif
+#if RTLNX_VER_MIN(5,13,0)
+        ttm_device_fini(&vbox->ttm.bdev);
+#else
 	ttm_bo_device_release(&vbox->ttm.bdev);
+#endif
 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
 	vbox_ttm_global_release(vbox);
 #endif
@@ -528,7 +563,9 @@ int vbox_bo_create(struct drm_device *de
 {
 	struct vbox_private *vbox = dev->dev_private;
 	struct vbox_bo *vboxbo;
+#if RTLNX_VER_MAX(5,13,0)
 	size_t acc_size;
+#endif
 	int ret;
 
 	vboxbo = kzalloc(sizeof(*vboxbo), GFP_KERNEL);
@@ -551,16 +588,20 @@ int vbox_bo_create(struct drm_device *de
 
 	vbox_ttm_placement(vboxbo, VBOX_MEM_TYPE_VRAM | VBOX_MEM_TYPE_SYSTEM);
 
+#if RTLNX_VER_MAX(5,13,0)
 	acc_size = ttm_bo_dma_acc_size(&vbox->ttm.bdev, size,
 				       sizeof(struct vbox_bo));
+#endif
 
 	ret = ttm_bo_init(&vbox->ttm.bdev, &vboxbo->bo, size,
 			  ttm_bo_type_device, &vboxbo->placement,
 #if RTLNX_VER_MAX(4,17,0) && !RTLNX_RHEL_MAJ_PREREQ(7,6) && !RTLNX_SUSE_MAJ_PREREQ(15,1) && !RTLNX_SUSE_MAJ_PREREQ(12,5)
 			  align >> PAGE_SHIFT, false, NULL, acc_size,
-#else
+#elif RTLNX_VER_MAX(5,13,0) /* < 5.13.0 */
 			  align >> PAGE_SHIFT, false, acc_size,
-#endif
+#else /* > 5.13.0 */
+			  align >> PAGE_SHIFT, false,
+#endif /* > 5.13.0 */
 #if RTLNX_VER_MIN(3,18,0) || RTLNX_RHEL_MAJ_PREREQ(7,2)
 			  NULL, NULL, vbox_bo_ttm_destroy);
 #else