File fixes_for_4.17.patch of Package virtualbox.8026

In kernel 4.17, pci_get_bus_and_slot() has been removed in favor of
pci_get_domain_bus_and_slot(). It appears that VirtualBox only uses
domain number 0, thus pci_get_domain_bus_and_slot(0, bus, devfn)
is a suitable replacement for pci_get_bus_and_slot(bus, devfn).

The resulting code compiles; however, I do not use PCI passthru, which
I think means that I have not actually tested the code.

This patch released under a combined MIT/GPLv2 license.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>

Index: VirtualBox-5.1.38/src/VBox/Additions/linux/drm/vbox_ttm.c
===================================================================
--- VirtualBox-5.1.38.orig/src/VBox/Additions/linux/drm/vbox_ttm.c
+++ VirtualBox-5.1.38/src/VBox/Additions/linux/drm/vbox_ttm.c
@@ -237,20 +237,29 @@ static struct ttm_backend_func vbox_tt_b
     .destroy = &vbox_ttm_backend_destroy,
 };
 
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+static struct ttm_tt *vbox_ttm_tt_create(struct ttm_buffer_object *bo,
+					 u32 page_flags)
+#else
 static struct ttm_tt *vbox_ttm_tt_create(struct ttm_bo_device *bdev,
                  unsigned long size, uint32_t page_flags,
                  struct page *dummy_read_page)
+#endif
 {
-    struct ttm_tt *tt;
+	struct ttm_tt *tt;
 
-    tt = kzalloc(sizeof(struct ttm_tt), GFP_KERNEL);
-    if (tt == NULL)
-        return NULL;
-    tt->func = &vbox_tt_backend_func;
-    if (ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
-        kfree(tt);
-        return NULL;
+	tt = kzalloc(sizeof(struct ttm_tt), GFP_KERNEL);
+	if (tt == NULL)
+		return NULL;
+
+	tt->func = &vbox_tt_backend_func;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+	if (ttm_tt_init(tt, bo, page_flags)) {
+#else
+	if (ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
+#endif
+		kfree(tt);
+		return NULL;
     }
     return tt;
 }
@@ -259,24 +268,19 @@ static struct ttm_tt *vbox_ttm_tt_create
 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
 static int vbox_ttm_tt_populate(struct ttm_tt *ttm)
 {
-    return ttm_pool_populate(ttm);
+	return ttm_pool_populate(ttm);
 }
 # else
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
-static int vbox_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
-{
-    return ttm_pool_populate(ttm, ctx);
-}
-#else
-static int vbox_ttm_tt_populate(struct ttm_tt *ttm)
+static int vbox_ttm_tt_populate(struct ttm_tt *ttm,
+				struct ttm_operation_ctx *ctx)
 {
-	return ttm_pool_populate(ttm);
+	return ttm_pool_populate(ttm, ctx);
 }
-#endif
+# endif
 
 static void vbox_ttm_tt_unpopulate(struct ttm_tt *ttm)
 {
-    ttm_pool_unpopulate(ttm);
+	ttm_pool_unpopulate(ttm);
 }
 #endif
 
@@ -457,9 +461,13 @@ int vbox_bo_create(struct drm_device *de
     acc_size = ttm_bo_dma_acc_size(&vbox->ttm.bdev, size,
                        sizeof(struct vbox_bo));
 
-    ret = ttm_bo_init(&vbox->ttm.bdev, &vboxbo->bo, size,
-              ttm_bo_type_device, &vboxbo->placement,
-              align >> PAGE_SHIFT, false, NULL, acc_size,
+	ret = ttm_bo_init(&vbox->ttm.bdev, &vboxbo->bo, size,
+			  ttm_bo_type_device, &vboxbo->placement,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+			  align >> PAGE_SHIFT, false, acc_size,
+#else
+			  align >> PAGE_SHIFT, false, NULL, acc_size,
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) || defined(RHEL_73)
               NULL,
 #endif
openSUSE Build Service is sponsored by