Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sickcodes/2c62b829fdb2d9f98f547e27dd1c85f5 to your computer and use it in GitHub Desktop.
Save sickcodes/2c62b829fdb2d9f98f547e27dd1c85f5 to your computer and use it in GitHub Desktop.
Patch for evdi branch rockorequin-sickcodes-microhobby-patch-1.7.x for kernel 5.12
diff --git a/module/evdi_drv.c b/module/evdi_drv.c
index d364efa..3428158 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..1edac71 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.
+ */
+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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment