blob: e95e240492088125b7d32fb88b6840e0da9be5d4 [file] [log] [blame]
Andrew Geissler69721092021-07-23 12:57:00 -04001Subject: Fix build errors with linux 5.13
2Origin: upstream, https://www.virtualbox.org/browser/vbox/trunk
3Bug: https://bugs.launchpad.net/bugs/1929193
4
5diff -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
6--- virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_drv.h 2021-04-28 16:24:47.000000000 +0000
7+++ virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_drv.h 2021-06-23 10:08:44.431714404 +0000
8@@ -46,20 +41,20 @@
9 * Evaluates to true if the linux kernel version is equal or higher to the
10 * one specfied. */
11 #define RTLNX_VER_MIN(a_Major, a_Minor, a_Patch) \
12- (LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
13+ (LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
14
15 /** @def RTLNX_VER_MAX
16 * Evaluates to true if the linux kernel version is less to the one specfied
17 * (exclusive). */
18 #define RTLNX_VER_MAX(a_Major, a_Minor, a_Patch) \
19- (LINUX_VERSION_CODE < KERNEL_VERSION(a_Major, a_Minor, a_Patch))
20+ (LINUX_VERSION_CODE < KERNEL_VERSION(a_Major, a_Minor, a_Patch))
21
22 /** @def RTLNX_VER_RANGE
23 * Evaluates to true if the linux kernel version is equal or higher to the given
24 * minimum version and less (but not equal) to the maximum version (exclusive). */
25 #define RTLNX_VER_RANGE(a_MajorMin, a_MinorMin, a_PatchMin, a_MajorMax, a_MinorMax, a_PatchMax) \
26- ( LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
27- && LINUX_VERSION_CODE < KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
28+ ( LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
29+ && LINUX_VERSION_CODE < KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
30
31
32 /** @def RTLNX_RHEL_MIN
33@@ -70,7 +65,7 @@
34 */
35 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
36 # define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) \
37- ((RHEL_MAJOR) > (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor)))
38+ ((RHEL_MAJOR) > (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor)))
39 #else
40 # define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) (0)
41 #endif
42@@ -83,7 +78,7 @@
43 */
44 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
45 # define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) \
46- ((RHEL_MAJOR) < (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) < (a_iMinor)))
47+ ((RHEL_MAJOR) < (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) < (a_iMinor)))
48 #else
49 # define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) (0)
50 #endif
51@@ -95,7 +90,7 @@
52 */
53 #if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
54 # define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin, a_iMajorMax, a_iMinorMax) \
55- (RTLNX_RHEL_MIN(a_iMajorMin, a_iMinorMin) && RTLNX_RHEL_MAX(a_iMajorMax, a_iMinorMax))
56+ (RTLNX_RHEL_MIN(a_iMajorMin, a_iMinorMin) && RTLNX_RHEL_MAX(a_iMajorMax, a_iMinorMax))
57 #else
58 # define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin, a_iMajorMax, a_iMinorMax) (0)
59 #endif
60@@ -173,7 +168,9 @@
61 #include <drm/ttm/ttm_bo_api.h>
62 #include <drm/ttm/ttm_bo_driver.h>
63 #include <drm/ttm/ttm_placement.h>
64+#if RTLNX_VER_MAX(5,13,0)
65 #include <drm/ttm/ttm_memory.h>
66+#endif
67 #if RTLNX_VER_MAX(5,12,0)
68 # include <drm/ttm/ttm_module.h>
69 #endif
70@@ -222,7 +219,7 @@ static inline void drm_gem_object_put(st
71 VBVA_ADAPTER_INFORMATION_SIZE)
72 #define GUEST_HEAP_SIZE VBVA_ADAPTER_INFORMATION_SIZE
73 #define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \
74- sizeof(HGSMIHOSTFLAGS))
75+ sizeof(struct hgsmi_host_flags))
76 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
77
78 /** How frequently we refresh if the guest is not providing dirty rectangles. */
79@@ -232,7 +229,7 @@ static inline void drm_gem_object_put(st
80 static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size,
81 gfp_t flags)
82 {
83- return devm_kzalloc(dev, n * size, flags);
84+ return devm_kzalloc(dev, n * size, flags);
85 }
86 #endif
87
88@@ -244,7 +241,7 @@ struct vbox_private {
89 u8 __iomem *guest_heap;
90 u8 __iomem *vbva_buffers;
91 struct gen_pool *guest_pool;
92- struct VBVABUFFERCONTEXT *vbva_info;
93+ struct vbva_buf_context *vbva_info;
94 bool any_pitch;
95 u32 num_crtcs;
96 /** Amount of available VRAM, including space used for buffers. */
97@@ -252,7 +249,7 @@ struct vbox_private {
98 /** Amount of available VRAM, not including space used for buffers. */
99 u32 available_vram_size;
100 /** Array of structures for receiving mode hints. */
101- VBVAMODEHINT *last_mode_hints;
102+ struct vbva_modehint *last_mode_hints;
103
104 struct vbox_fbdev *fbdev;
105
106@@ -263,7 +260,11 @@ struct vbox_private {
107 struct drm_global_reference mem_global_ref;
108 struct ttm_bo_global_ref bo_global_ref;
109 #endif
110+#if RTLNX_VER_MIN(5,13,0)
111+ struct ttm_device bdev;
112+#else
113 struct ttm_bo_device bdev;
114+#endif
115 bool mm_initialised;
116 } ttm;
117
118diff -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
119--- virtualbox-6.1.22-dfsg.orig/src/VBox/Additions/linux/drm/vbox_ttm.c 2021-04-28 16:24:47.000000000 +0000
120+++ virtualbox-6.1.22-dfsg/src/VBox/Additions/linux/drm/vbox_ttm.c 2021-06-23 10:08:07.164057918 +0000
121@@ -48,7 +43,11 @@
122 #endif
123
124
125+#if RTLNX_VER_MIN(5,13,0)
126+static inline struct vbox_private *vbox_bdev(struct ttm_device *bd)
127+#else
128 static inline struct vbox_private *vbox_bdev(struct ttm_bo_device *bd)
129+#endif
130 {
131 return container_of(bd, struct vbox_private, ttm.bdev);
132 }
133@@ -188,7 +187,7 @@ static int vbox_ttm_io_mem_reserve(struc
134 mem->bus.size = mem->num_pages << PAGE_SHIFT;
135 mem->bus.base = 0;
136 mem->bus.is_iomem = false;
137- if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
138+ if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
139 return -EINVAL;
140 switch (mem->mem_type) {
141 case TTM_PL_SYSTEM:
142@@ -205,8 +204,13 @@ static int vbox_ttm_io_mem_reserve(struc
143 return 0;
144 }
145 #else
146+# if RTLNX_VER_MAX(5,13,0)
147 static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
148 struct ttm_resource *mem)
149+# else /* > 5.13.0 */
150+static int vbox_ttm_io_mem_reserve(struct ttm_device *bdev,
151+ struct ttm_resource *mem)
152+# endif /* > 5.13.0 */
153 {
154 struct vbox_private *vbox = vbox_bdev(bdev);
155 mem->bus.addr = NULL;
156@@ -241,7 +245,12 @@ static int vbox_ttm_io_mem_reserve(struc
157
158
159
160-#if RTLNX_VER_MIN(5,10,0)
161+#if RTLNX_VER_MIN(5,13,0)
162+static void vbox_ttm_io_mem_free(struct ttm_device *bdev,
163+ struct ttm_resource *mem)
164+{
165+}
166+#elif RTLNX_VER_MIN(5,10,0)
167 static void vbox_ttm_io_mem_free(struct ttm_bo_device *bdev,
168 struct ttm_resource *mem)
169 {
170@@ -253,7 +262,13 @@ static void vbox_ttm_io_mem_free(struct
171 }
172 #endif
173
174-#if RTLNX_VER_MIN(5,10,0)
175+#if RTLNX_VER_MIN(5,13,0)
176+static void vbox_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *tt)
177+{
178+ ttm_tt_fini(tt);
179+ kfree(tt);
180+}
181+#elif RTLNX_VER_MIN(5,10,0)
182 static void vbox_ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *tt)
183 {
184 ttm_tt_fini(tt);
185@@ -333,7 +348,11 @@ static int vbox_bo_move(struct ttm_buffe
186 }
187 #endif
188
189+#if RTLNX_VER_MIN(5,13,0)
190+static struct ttm_device_funcs vbox_bo_driver = {
191+#else /* < 5.13.0 */
192 static struct ttm_bo_driver vbox_bo_driver = {
193+#endif /* < 5.13.0 */
194 .ttm_tt_create = vbox_ttm_tt_create,
195 #if RTLNX_VER_MIN(5,10,0)
196 .ttm_tt_destroy = vbox_ttm_tt_destroy,
197@@ -370,14 +389,22 @@ int vbox_mm_init(struct vbox_private *vb
198 {
199 int ret;
200 struct drm_device *dev = vbox->dev;
201+#if RTLNX_VER_MIN(5,13,0)
202+ struct ttm_device *bdev = &vbox->ttm.bdev;
203+#else
204 struct ttm_bo_device *bdev = &vbox->ttm.bdev;
205+#endif
206
207 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
208 ret = vbox_ttm_global_init(vbox);
209 if (ret)
210 return ret;
211 #endif
212+#if RTLNX_VER_MIN(5,13,0)
213+ ret = ttm_device_init(&vbox->ttm.bdev,
214+#else
215 ret = ttm_bo_device_init(&vbox->ttm.bdev,
216+#endif
217 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
218 vbox->ttm.bo_global_ref.ref.object,
219 #endif
220@@ -429,7 +456,11 @@ int vbox_mm_init(struct vbox_private *vb
221 return 0;
222
223 err_device_release:
224+#if RTLNX_VER_MIN(5,13,0)
225+ ttm_device_fini(&vbox->ttm.bdev);
226+#else
227 ttm_bo_device_release(&vbox->ttm.bdev);
228+#endif
229 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
230 err_ttm_global_release:
231 vbox_ttm_global_release(vbox);
232@@ -446,7 +477,11 @@ void vbox_mm_fini(struct vbox_private *v
233 #else
234 arch_phys_wc_del(vbox->fb_mtrr);
235 #endif
236+#if RTLNX_VER_MIN(5,13,0)
237+ ttm_device_fini(&vbox->ttm.bdev);
238+#else
239 ttm_bo_device_release(&vbox->ttm.bdev);
240+#endif
241 #if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
242 vbox_ttm_global_release(vbox);
243 #endif
244@@ -528,7 +563,9 @@ int vbox_bo_create(struct drm_device *de
245 {
246 struct vbox_private *vbox = dev->dev_private;
247 struct vbox_bo *vboxbo;
248+#if RTLNX_VER_MAX(5,13,0)
249 size_t acc_size;
250+#endif
251 int ret;
252
253 vboxbo = kzalloc(sizeof(*vboxbo), GFP_KERNEL);
254@@ -551,16 +588,20 @@ int vbox_bo_create(struct drm_device *de
255
256 vbox_ttm_placement(vboxbo, VBOX_MEM_TYPE_VRAM | VBOX_MEM_TYPE_SYSTEM);
257
258+#if RTLNX_VER_MAX(5,13,0)
259 acc_size = ttm_bo_dma_acc_size(&vbox->ttm.bdev, size,
260 sizeof(struct vbox_bo));
261+#endif
262
263 ret = ttm_bo_init(&vbox->ttm.bdev, &vboxbo->bo, size,
264 ttm_bo_type_device, &vboxbo->placement,
265 #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)
266 align >> PAGE_SHIFT, false, NULL, acc_size,
267-#else
268+#elif RTLNX_VER_MAX(5,13,0) /* < 5.13.0 */
269 align >> PAGE_SHIFT, false, acc_size,
270-#endif
271+#else /* > 5.13.0 */
272+ align >> PAGE_SHIFT, false,
273+#endif /* > 5.13.0 */
274 #if RTLNX_VER_MIN(3,18,0) || RTLNX_RHEL_MAJ_PREREQ(7,2)
275 NULL, NULL, vbox_bo_ttm_destroy);
276 #else