Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2 Fix up drm_prime.c.



details:   https://anonhg.NetBSD.org/src/rev/a0657c190d23
branches:  trunk
changeset: 1028324:a0657c190d23
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 10:38:22 2021 +0000

description:
Fix up drm_prime.c.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_prime.c         |  39 ++++++++++++++++++++-
 sys/external/bsd/drm2/dist/include/drm/drm_gem.h   |   6 +-
 sys/external/bsd/drm2/dist/include/drm/drm_prime.h |   4 +-
 sys/external/bsd/drm2/include/linux/dma-buf.h      |   3 +-
 4 files changed, 43 insertions(+), 9 deletions(-)

diffs (187 lines):

diff -r 75f833004f06 -r a0657c190d23 sys/external/bsd/drm2/dist/drm/drm_prime.c
--- a/sys/external/bsd/drm2/dist/drm/drm_prime.c        Sun Dec 19 10:38:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_prime.c        Sun Dec 19 10:38:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_prime.c,v 1.13 2021/12/19 01:56:58 riastradh Exp $ */
+/*     $NetBSD: drm_prime.c,v 1.14 2021/12/19 10:38:22 riastradh Exp $ */
 
 /*
  * Copyright © 2012 Red Hat
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_prime.c,v 1.13 2021/12/19 01:56:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_prime.c,v 1.14 2021/12/19 10:38:22 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/dma-buf.h>
@@ -46,6 +46,8 @@
 
 #ifdef __NetBSD__
 
+#include <sys/file.h>
+
 #include <drm/bus_dma_hacks.h>
 
 #include <linux/nbsd-namespace.h>
@@ -471,7 +473,9 @@
 
        drm_dev_get(dev);
        drm_gem_object_get(obj);
+#ifndef __NetBSD__             /* XXX dmabuf share */
        dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;
+#endif
 
        return dma_buf;
 }
@@ -848,12 +852,14 @@
        else
                sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
 
+#ifndef __NetBSD__             /* We map/unmap elsewhere.  */
        if (!dma_map_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir,
                              DMA_ATTR_SKIP_CPU_SYNC)) {
                sg_free_table(sgt);
                kfree(sgt);
                sgt = ERR_PTR(-ENOMEM);
        }
+#endif
 
        return sgt;
 }
@@ -874,8 +880,10 @@
        if (!sgt)
                return;
 
+#ifndef __NetBSD__             /* We map/unmap elsewhere.  */
        dma_unmap_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir,
                           DMA_ATTR_SKIP_CPU_SYNC);
+#endif
        sg_free_table(sgt);
        kfree(sgt);
 }
@@ -931,20 +939,37 @@
  *
  * Drivers can use this as their &drm_driver.gem_prime_mmap callback.
  */
+#ifdef __NetBSD__
+int drm_gem_prime_mmap(struct drm_gem_object *obj, off_t *offp, size_t size,
+    int prot, int *flagsp, int *advicep, struct uvm_object **uobjp,
+    int *maxprotp)
+#else
 int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
+#endif
 {
        struct drm_file *priv;
        struct file *fil;
        int ret;
 
        /* Add the fake offset */
+#ifdef __NetBSD__
+       *offp += drm_vma_node_start(&obj->vma_node);
+#else
        vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
+#endif
 
        if (obj->funcs && obj->funcs->mmap) {
+#ifdef __NetBSD__
+               ret = obj->funcs->mmap(obj, offp, size, prot, flagsp, advicep,
+                   uobjp, maxprotp);
+#else
                ret = obj->funcs->mmap(obj, vma);
+#endif
                if (ret)
                        return ret;
+#ifndef __NetBSD__
                vma->vm_private_data = obj;
+#endif
                drm_gem_object_get(obj);
                return 0;
        }
@@ -958,13 +983,22 @@
 
        /* Used by drm_gem_mmap() to lookup the GEM object */
        priv->minor = obj->dev->primary;
+#ifdef __NetBSD__
+       fil->f_data = priv;
+#else
        fil->private_data = priv;
+#endif
 
        ret = drm_vma_node_allow(&obj->vma_node, priv);
        if (ret)
                goto out;
 
+#ifdef __NetBSD__
+       ret = obj->dev->driver->mmap_object(obj->dev, *offp, size, prot, uobjp,
+           offp, fil);
+#else
        ret = obj->dev->driver->fops->mmap(fil, vma);
+#endif
 
        drm_vma_node_revoke(&obj->vma_node, priv);
 out:
@@ -1180,7 +1214,6 @@
 EXPORT_SYMBOL(drm_gem_prime_import);
 
 #ifdef __NetBSD__
-/**
 
 struct sg_table *
 drm_prime_bus_dmamem_to_sg(bus_dma_tag_t dmat, const bus_dma_segment_t *segs,
diff -r 75f833004f06 -r a0657c190d23 sys/external/bsd/drm2/dist/include/drm/drm_gem.h
--- a/sys/external/bsd/drm2/dist/include/drm/drm_gem.h  Sun Dec 19 10:38:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_gem.h  Sun Dec 19 10:38:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_gem.h,v 1.11 2021/12/19 09:56:03 riastradh Exp $   */
+/*     $NetBSD: drm_gem.h,v 1.12 2021/12/19 10:38:23 riastradh Exp $   */
 
 #ifndef __DRM_GEM_H__
 #define __DRM_GEM_H__
@@ -173,8 +173,8 @@
         * used, the @mmap callback must set vma->vm_ops instead.
         */
 #ifdef __NetBSD__
-       int (*mmap)(struct drm_device *, off_t, size_t, int, struct uvm_object **,
-           voff_t *, struct file *);
+       int (*mmap)(struct drm_gem_object *, off_t *, size_t, int,
+           int *, int *, struct uvm_object **, int *);
 #else
        int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
 #endif
diff -r 75f833004f06 -r a0657c190d23 sys/external/bsd/drm2/dist/include/drm/drm_prime.h
--- a/sys/external/bsd/drm2/dist/include/drm/drm_prime.h        Sun Dec 19 10:38:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_prime.h        Sun Dec 19 10:38:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_prime.h,v 1.4 2021/12/19 01:59:03 riastradh Exp $  */
+/*     $NetBSD: drm_prime.h,v 1.5 2021/12/19 10:38:23 riastradh Exp $  */
 
 /*
  * Copyright © 2012 Red Hat
@@ -88,7 +88,7 @@
 void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr);
 
 #ifdef __NetBSD__
-int gem_prime_mmap(struct drm_gem_object *, off_t *, size_t, int, int *,
+int drm_gem_prime_mmap(struct drm_gem_object *, off_t *, size_t, int, int *,
     int *, struct uvm_object **, int *);
 int drm_gem_dmabuf_mmap(struct dma_buf *, off_t *, size_t, int, int *,
     int *, struct uvm_object **, int *);
diff -r 75f833004f06 -r a0657c190d23 sys/external/bsd/drm2/include/linux/dma-buf.h
--- a/sys/external/bsd/drm2/include/linux/dma-buf.h     Sun Dec 19 10:38:14 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-buf.h     Sun Dec 19 10:38:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma-buf.h,v 1.9 2021/12/19 10:36:47 riastradh Exp $    */
+/*     $NetBSD: dma-buf.h,v 1.10 2021/12/19 10:38:23 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@
 };
 
 struct dma_buf_ops {
+       bool    cache_sgt_mapping;
        int     (*attach)(struct dma_buf *, struct dma_buf_attachment *);
        void    (*detach)(struct dma_buf *, struct dma_buf_attachment *);
        struct sg_table *



Home | Main Index | Thread Index | Old Index