Last active
April 5, 2021 08:05
-
-
Save rockorequin/f61fcb0217194997a2a3e8c4da260e4c to your computer and use it in GitHub Desktop.
Patch for evdi branch rockorequin-sickcodes-microhobby-patch-1.7.x for kernel 5.12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/module/evdi_drv.c b/module/evdi_drv.c | |
index d364efa..fbbdb9e 100644 | |
--- a/module/evdi_drv.c | |
+++ b/module/evdi_drv.c | |
@@ -84,6 +84,18 @@ static void evdi_disable_vblank(__always_unused struct drm_device *dev, | |
} | |
#endif | |
+#if KERNEL_VERSION(5, 12, 0) >= LINUX_VERSION_CODE | |
+// This has become an internal function in 5.12, so copy it here | |
+static int drm_gem_dumb_destroy(struct drm_file *file, | |
+ __always_unused struct drm_device *dev, | |
+ u32 handle) | |
+{ | |
+ return drm_gem_handle_delete(file, handle); | |
+} | |
+#endif | |
+ | |
+ | |
+ | |
static struct drm_driver driver = { | |
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE || defined(EL8) | |
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC, | |
diff --git a/module/evdi_gem.c b/module/evdi_gem.c | |
index de5e35e..fe2353d 100644 | |
--- a/module/evdi_gem.c | |
+++ b/module/evdi_gem.c | |
@@ -29,6 +29,47 @@ static const struct vm_operations_struct evdi_gem_vm_ops = { | |
}; | |
#endif | |
+#if KERNEL_VERSION(5, 12, 0) <= LINUX_VERSION_CODE | |
+// This was removed from 5.12 so copy it here | |
+/** | |
+ * drm_prime_sg_to_page_addr_arrays - convert an sg table into a page array | |
+ * @sgt: scatter-gather table to convert | |
+ * @pages: optional array of page pointers to store the page array in | |
+ * @addrs: optional array to store the dma bus address of each page | |
+ * @max_entries: size of both the passed-in arrays | |
+ * | |
+ * Exports an sg table into an array of pages and addresses. This is currently | |
+ * required by the TTM driver in order to do correct fault handling. | |
+ * | |
+ * Drivers can use this in their &drm_driver.gem_prime_import_sg_table | |
+ * implementation. | |
+ */ | |
+static int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, | |
+ dma_addr_t *addrs, int max_entries) | |
+{ | |
+ struct sg_dma_page_iter dma_iter; | |
+ struct sg_page_iter page_iter; | |
+ struct page **p = pages; | |
+ dma_addr_t *a = addrs; | |
+ | |
+ if (pages) { | |
+ for_each_sgtable_page(sgt, &page_iter, 0) { | |
+ if (WARN_ON(p - pages >= max_entries)) | |
+ return -1; | |
+ *p++ = sg_page_iter_page(&page_iter); | |
+ } | |
+ } | |
+ if (addrs) { | |
+ for_each_sgtable_dma_page(sgt, &dma_iter, 0) { | |
+ if (WARN_ON(a - addrs >= max_entries)) | |
+ return -1; | |
+ *a++ = sg_page_iter_dma_address(&dma_iter); | |
+ } | |
+ } | |
+ | |
+ return 0; | |
+} | |
+#endif | |
uint32_t evdi_gem_object_handle_lookup(struct drm_file *filp, | |
struct drm_gem_object *obj) |
Hey nice work between you and SickCodes. Can I assume that this covers both 5.11 and 5.12?
I see just 5.12 up there...
This is just for 5.12, assuming you have 5.11 already working. The one for 5.11 that I published is at https://gist.github.com/rockorequin/9f16d3dd2a3278c3d19d7871a72a4092 and they are used in DisplayLink/evdi#249
BUT it looks like Displaylink have finally published an official driver for 5.11: see DisplayLink/evdi#275 for more details.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey nice work between you and SickCodes. Can I assume that this covers both 5.11 and 5.12?