adapt more functions to the i915_gem_phys hack
authorjsg <jsg@openbsd.org>
Tue, 8 Aug 2023 10:16:51 +0000 (10:16 +0000)
committerjsg <jsg@openbsd.org>
Tue, 8 Aug 2023 10:16:51 +0000 (10:16 +0000)
linux stashes a dma va in the vm_page pointer part of the scatterlist.
We use a pointer to a struct with the dma tag and map.

sys/dev/pci/drm/i915/gem/i915_gem_phys.c

index 5f73a07..cc496f7 100644 (file)
@@ -205,7 +205,12 @@ i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
 int i915_gem_object_pwrite_phys(struct drm_i915_gem_object *obj,
                                const struct drm_i915_gem_pwrite *args)
 {
+#ifdef __linux__
        void *vaddr = sg_page(obj->mm.pages->sgl) + args->offset;
+#else
+       struct drm_dmamem *dmah = (void *)sg_page(obj->mm.pages->sgl);
+       void *vaddr = dmah->kva + args->offset;
+#endif
        char __user *user_data = u64_to_user_ptr(args->data_ptr);
        struct drm_i915_private *i915 = to_i915(obj->base.dev);
        int err;
@@ -236,7 +241,12 @@ int i915_gem_object_pwrite_phys(struct drm_i915_gem_object *obj,
 int i915_gem_object_pread_phys(struct drm_i915_gem_object *obj,
                               const struct drm_i915_gem_pread *args)
 {
+#ifdef __linux__
        void *vaddr = sg_page(obj->mm.pages->sgl) + args->offset;
+#else
+       struct drm_dmamem *dmah = (void *)sg_page(obj->mm.pages->sgl);
+       void *vaddr = dmah->kva + args->offset;
+#endif
        char __user *user_data = u64_to_user_ptr(args->data_ptr);
        int err;