Thierry Reding
2018-Jan-11 21:44 UTC
[Nouveau] [PATCH 1/5] drm/prime: Remove duplicate forward declaration
From: Thierry Reding <treding at nvidia.com> struct device is forward-declared twice. Remove the second instance. Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk> Signed-off-by: Thierry Reding <treding at nvidia.com> --- include/drm/drm_prime.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h index 9cd9e36f77b5..59ccab402e85 100644 --- a/include/drm/drm_prime.h +++ b/include/drm/drm_prime.h @@ -59,8 +59,6 @@ struct drm_device; struct drm_gem_object; struct drm_file; -struct device; - struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags); -- 2.15.1
Thierry Reding
2018-Jan-11 21:44 UTC
[Nouveau] [PATCH 2/5] drm/prime: Export more helpers for drivers
From: Thierry Reding <treding at nvidia.com>
Export some more of the helpers in order to allow drivers to more fine-
grainedly select which helpers to use. This gives drivers an easy way to
reuse a lot of the code in the helpers while at the same time allowing
them to provide their own implementation for other functions in struct
dma_buf_ops.
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
drivers/gpu/drm/drm_prime.c | 23 +++++++++++++----------
include/drm/drm_prime.h | 12 ++++++++++++
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 9a17725b0f7a..f9903e6b59f6 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -180,9 +180,8 @@ static int drm_prime_lookup_buf_handle(struct
drm_prime_file_private *prime_fpri
return -ENOENT;
}
-static int drm_gem_map_attach(struct dma_buf *dma_buf,
- struct device *target_dev,
- struct dma_buf_attachment *attach)
+int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev,
+ struct dma_buf_attachment *attach)
{
struct drm_prime_attachment *prime_attach;
struct drm_gem_object *obj = dma_buf->priv;
@@ -200,9 +199,10 @@ static int drm_gem_map_attach(struct dma_buf *dma_buf,
return dev->driver->gem_prime_pin(obj);
}
+EXPORT_SYMBOL(drm_gem_map_attach);
-static void drm_gem_map_detach(struct dma_buf *dma_buf,
- struct dma_buf_attachment *attach)
+void drm_gem_map_detach(struct dma_buf *dma_buf,
+ struct dma_buf_attachment *attach)
{
struct drm_prime_attachment *prime_attach = attach->priv;
struct drm_gem_object *obj = dma_buf->priv;
@@ -228,6 +228,7 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf,
kfree(prime_attach);
attach->priv = NULL;
}
+EXPORT_SYMBOL(drm_gem_map_detach);
void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private
*prime_fpriv,
struct dma_buf *dma_buf)
@@ -254,8 +255,8 @@ void drm_prime_remove_buf_handle_locked(struct
drm_prime_file_private *prime_fpr
}
}
-static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
- enum dma_data_direction dir)
+struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
+ enum dma_data_direction dir)
{
struct drm_prime_attachment *prime_attach = attach->priv;
struct drm_gem_object *obj = attach->dmabuf->priv;
@@ -291,13 +292,15 @@ static struct sg_table *drm_gem_map_dma_buf(struct
dma_buf_attachment *attach,
return sgt;
}
+EXPORT_SYMBOL(drm_gem_map_dma_buf);
-static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
- struct sg_table *sgt,
- enum dma_data_direction dir)
+void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
+ struct sg_table *sgt,
+ enum dma_data_direction dir)
{
/* nothing to be done here */
}
+EXPORT_SYMBOL(drm_gem_unmap_dma_buf);
/**
* drm_gem_dmabuf_export - dma_buf export implementation for GEM
diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
index 59ccab402e85..3a9706815773 100644
--- a/include/drm/drm_prime.h
+++ b/include/drm/drm_prime.h
@@ -50,8 +50,10 @@ struct drm_prime_file_private {
struct rb_root handles;
};
+enum dma_data_direction;
struct device;
+struct dma_buf_attachment;
struct dma_buf_export_info;
struct dma_buf;
@@ -59,6 +61,16 @@ struct drm_device;
struct drm_gem_object;
struct drm_file;
+int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev,
+ struct dma_buf_attachment *attach);
+void drm_gem_map_detach(struct dma_buf *dma_buf,
+ struct dma_buf_attachment *attach);
+struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
+ enum dma_data_direction dir);
+void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
+ struct sg_table *sgt,
+ enum dma_data_direction dir);
+
struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj,
int flags);
--
2.15.1
Thierry Reding
2018-Jan-11 21:44 UTC
[Nouveau] [PATCH 3/5] drm/nouveau: Provide custom struct dma_buf_ops
From: Thierry Reding <treding at nvidia.com>
Instead of relying on the DRM PRIME helpers to provide all of the
DMA-BUF operations, provide a custom version of struct dma_buf_ops to
allow additional functionality to be implemented.
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +-
drivers/gpu/drm/nouveau/nouveau_gem.h | 15 +--
drivers/gpu/drm/nouveau/nouveau_prime.c | 157 +++++++++++++++++++++++++-------
3 files changed, 135 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 56fe261b6268..3ce2f02e9e58 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1081,15 +1081,12 @@ driver_stub = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
- .gem_prime_export = drm_gem_prime_export,
- .gem_prime_import = drm_gem_prime_import,
+ .gem_prime_export = nouveau_gem_prime_export,
+ .gem_prime_import = nouveau_gem_prime_import,
.gem_prime_pin = nouveau_gem_prime_pin,
- .gem_prime_res_obj = nouveau_gem_prime_res_obj,
.gem_prime_unpin = nouveau_gem_prime_unpin,
+ .gem_prime_res_obj = nouveau_gem_prime_res_obj,
.gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
- .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
- .gem_prime_vmap = nouveau_gem_prime_vmap,
- .gem_prime_vunmap = nouveau_gem_prime_vunmap,
.gem_free_object_unlocked = nouveau_gem_object_del,
.gem_open_object = nouveau_gem_object_open,
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h
b/drivers/gpu/drm/nouveau/nouveau_gem.h
index fe39998f65cc..eb55c1eb1d9f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.h
@@ -32,13 +32,14 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *,
void *,
extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
struct drm_file *);
-extern int nouveau_gem_prime_pin(struct drm_gem_object *);
+struct dma_buf *nouveau_gem_prime_export(struct drm_device *dev,
+ struct drm_gem_object *obj,
+ int flags);
+struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *drm,
+ struct dma_buf *buf);
+int nouveau_gem_prime_pin(struct drm_gem_object *obj);
+void nouveau_gem_prime_unpin(struct drm_gem_object *obj);
struct reservation_object *nouveau_gem_prime_res_obj(struct drm_gem_object *);
-extern void nouveau_gem_prime_unpin(struct drm_gem_object *);
-extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object
*);
-extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
- struct drm_device *, struct dma_buf_attachment *, struct sg_table *);
-extern void *nouveau_gem_prime_vmap(struct drm_gem_object *);
-extern void nouveau_gem_prime_vunmap(struct drm_gem_object *, void *);
+struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj);
#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 1fefc93af1d7..63cf4aca2d8e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -23,69 +23,152 @@
*/
#include <drm/drmP.h>
+#include <drm/drm_legacy.h>
#include <linux/dma-buf.h>
#include "nouveau_drv.h"
#include "nouveau_gem.h"
-struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj)
+static void *nouveau_gem_prime_kmap_atomic(struct dma_buf *buf,
+ unsigned long page)
{
- struct nouveau_bo *nvbo = nouveau_gem_object(obj);
- int npages = nvbo->bo.num_pages;
+ return NULL;
+}
- return drm_prime_pages_to_sg(nvbo->bo.ttm->pages, npages);
+static void nouveau_gem_prime_kunmap_atomic(struct dma_buf *buf,
+ unsigned long page, void *addr)
+{
}
-void *nouveau_gem_prime_vmap(struct drm_gem_object *obj)
+static void *nouveau_gem_prime_kmap(struct dma_buf *buf, unsigned long page)
{
- struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+ return NULL;
+}
+
+static void nouveau_gem_prime_kunmap(struct dma_buf *buf, unsigned long page,
+ void *addr)
+{
+}
+
+static void *nouveau_gem_prime_vmap(struct dma_buf *buf)
+{
+ struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
int ret;
- ret = ttm_bo_kmap(&nvbo->bo, 0, nvbo->bo.num_pages,
- &nvbo->dma_buf_vmap);
+ ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages,
&bo->dma_buf_vmap);
if (ret)
return ERR_PTR(ret);
- return nvbo->dma_buf_vmap.virtual;
+ return bo->dma_buf_vmap.virtual;
}
-void nouveau_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
+static void nouveau_gem_prime_vunmap(struct dma_buf *buf, void *vaddr)
{
- struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+ struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
+
+ ttm_bo_kunmap(&bo->dma_buf_vmap);
+}
+
+static const struct dma_buf_ops nouveau_gem_prime_dmabuf_ops = {
+ .attach = drm_gem_map_attach,
+ .detach = drm_gem_map_detach,
+ .map_dma_buf = drm_gem_map_dma_buf,
+ .unmap_dma_buf = drm_gem_unmap_dma_buf,
+ .release = drm_gem_dmabuf_release,
+ .map_atomic = nouveau_gem_prime_kmap_atomic,
+ .unmap_atomic = nouveau_gem_prime_kunmap_atomic,
+ .map = nouveau_gem_prime_kmap,
+ .unmap = nouveau_gem_prime_kunmap,
+ .vmap = nouveau_gem_prime_vmap,
+ .vunmap = nouveau_gem_prime_vunmap,
+};
+
+struct dma_buf *nouveau_gem_prime_export(struct drm_device *dev,
+ struct drm_gem_object *obj,
+ int flags)
+{
+ DEFINE_DMA_BUF_EXPORT_INFO(info);
+
+ info.exp_name = KBUILD_MODNAME;
+ info.owner = dev->driver->fops->owner;
+ info.ops = &nouveau_gem_prime_dmabuf_ops;
+ info.size = obj->size;
+ info.flags = flags;
+ info.priv = obj;
+
+ if (dev->driver->gem_prime_res_obj)
+ info.resv = dev->driver->gem_prime_res_obj(obj);
- ttm_bo_kunmap(&nvbo->dma_buf_vmap);
+ return drm_gem_dmabuf_export(dev, &info);
}
-struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device
*dev,
- struct dma_buf_attachment *attach,
- struct sg_table *sg)
+struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev,
+ struct dma_buf *buf)
{
struct nouveau_drm *drm = nouveau_drm(dev);
- struct nouveau_bo *nvbo;
- struct reservation_object *robj = attach->dmabuf->resv;
- u32 flags = 0;
+ struct dma_buf_attachment *attach;
+ struct drm_gem_object *obj;
+ u32 flags = TTM_PL_FLAG_TT;
+ struct nouveau_bo *bo;
+ struct sg_table *sgt;
int ret;
- flags = TTM_PL_FLAG_TT;
+ if (buf->ops == &nouveau_gem_prime_dmabuf_ops) {
+ obj = buf->priv;
+
+ if (obj->dev == dev) {
+ /*
+ * Importing a DMA-BUF exported from our own GEM
+ * increases the reference count on the GEM itself
+ * instead of the f_count of the DMA-BUF.
+ */
+ drm_gem_object_get(obj);
+ return obj;
+ }
+ }
- ww_mutex_lock(&robj->lock, NULL);
- ret = nouveau_bo_new(&drm->client, attach->dmabuf->size, 0,
flags, 0, 0,
- sg, robj, &nvbo);
- ww_mutex_unlock(&robj->lock);
- if (ret)
- return ERR_PTR(ret);
+ attach = dma_buf_attach(buf, dev->dev);
+ if (IS_ERR(attach))
+ return ERR_CAST(attach);
- nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_GART;
+ get_dma_buf(buf);
- /* Initialize the embedded gem-object. We return a single gem-reference
- * to the caller, instead of a normal nouveau_bo ttm reference. */
- ret = drm_gem_object_init(dev, &nvbo->gem, nvbo->bo.mem.size);
- if (ret) {
- nouveau_bo_ref(NULL, &nvbo);
- return ERR_PTR(-ENOMEM);
+ sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
+ if (IS_ERR(sgt)) {
+ ret = PTR_ERR(sgt);
+ goto detach;
}
- return &nvbo->gem;
+ ww_mutex_lock(&attach->dmabuf->resv->lock, NULL);
+ ret = nouveau_bo_new(&drm->client, attach->dmabuf->size, 0,
flags, 0,
+ 0, sgt, attach->dmabuf->resv, &bo);
+ ww_mutex_unlock(&attach->dmabuf->resv->lock);
+ if (ret)
+ goto unmap;
+
+ bo->valid_domains = NOUVEAU_GEM_DOMAIN_GART;
+
+ /*
+ * Initialize the embedded GEM object. We return a single GEM reference
+ * to the caller, instead of a normal nouveau_bo TTM reference.
+ */
+ ret = drm_gem_object_init(dev, &bo->gem, bo->bo.mem.size);
+ if (ret)
+ goto unref;
+
+ bo->gem.import_attach = attach;
+
+ return &bo->gem;
+
+unref:
+ nouveau_bo_ref(NULL, &bo);
+unmap:
+ dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
+detach:
+ dma_buf_detach(buf, attach);
+ dma_buf_put(buf);
+
+ return ERR_PTR(ret);
}
int nouveau_gem_prime_pin(struct drm_gem_object *obj)
@@ -114,3 +197,11 @@ struct reservation_object *nouveau_gem_prime_res_obj(struct
drm_gem_object *obj)
return nvbo->bo.resv;
}
+
+struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj)
+{
+ struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+ int npages = nvbo->bo.num_pages;
+
+ return drm_prime_pages_to_sg(nvbo->bo.ttm->pages, npages);
+}
--
2.15.1
Thierry Reding
2018-Jan-11 21:44 UTC
[Nouveau] [PATCH 4/5] drm/nouveau: prime: Implement mmap()
From: Thierry Reding <treding at nvidia.com>
Provide an implementation of mmap() for PRIME exported buffers. This
allows userspace to map these buffers and access them using the CPU.
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
drivers/gpu/drm/nouveau/nouveau_prime.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 63cf4aca2d8e..5d885d7cb059 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -50,6 +50,37 @@ static void nouveau_gem_prime_kunmap(struct dma_buf *buf,
unsigned long page,
{
}
+static inline u64 nouveau_bo_mmap_offset(struct nouveau_bo *bo)
+{
+ return drm_vma_node_offset_addr(&bo->bo.vma_node) >> PAGE_SHIFT;
+}
+
+static int nouveau_gem_prime_mmap(struct dma_buf *buf,
+ struct vm_area_struct *vma)
+{
+ struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
+ struct drm_gem_object *obj = buf->priv;
+ int ret;
+
+ /* check for valid size */
+ if (obj->size < vma->vm_end - vma->vm_start)
+ return -EINVAL;
+
+ vma->vm_pgoff += nouveau_bo_mmap_offset(bo);
+
+ if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
+ return drm_legacy_mmap(vma->vm_file, vma);
+
+ ret = drm_vma_node_allow(&obj->vma_node,
vma->vm_file->private_data);
+ if (ret)
+ return ret;
+
+ ret = ttm_bo_mmap(vma->vm_file, vma, bo->bo.bdev);
+ drm_vma_node_revoke(&obj->vma_node, vma->vm_file->private_data);
+
+ return ret;
+}
+
static void *nouveau_gem_prime_vmap(struct dma_buf *buf)
{
struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
@@ -79,6 +110,7 @@ static const struct dma_buf_ops nouveau_gem_prime_dmabuf_ops
= {
.unmap_atomic = nouveau_gem_prime_kunmap_atomic,
.map = nouveau_gem_prime_kmap,
.unmap = nouveau_gem_prime_kunmap,
+ .mmap = nouveau_gem_prime_mmap,
.vmap = nouveau_gem_prime_vmap,
.vunmap = nouveau_gem_prime_vunmap,
};
--
2.15.1
Thierry Reding
2018-Jan-11 21:44 UTC
[Nouveau] [PATCH 5/5] drm/nouveau: prime: Implement cache maintenance
From: Thierry Reding <treding at nvidia.com>
Implement the ->begin_cpu_access() and ->end_cpu_access() callbacks to
allow userspace to invalidate the cache before accessing a buffer that
is exported using PRIME and flush the cache after modifying the buffer
through its userspace mapping.
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
drivers/gpu/drm/nouveau/nouveau_prime.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 5d885d7cb059..a3a586ce864c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -29,6 +29,26 @@
#include "nouveau_drv.h"
#include "nouveau_gem.h"
+static int nouveau_gem_prime_begin_cpu_access(struct dma_buf *buf,
+ enum dma_data_direction direction)
+{
+ struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
+
+ nouveau_bo_sync_for_cpu(bo);
+
+ return 0;
+}
+
+static int nouveau_gem_prime_end_cpu_access(struct dma_buf *buf,
+ enum dma_data_direction direction)
+{
+ struct nouveau_bo *bo = nouveau_gem_object(buf->priv);
+
+ nouveau_bo_sync_for_device(bo);
+
+ return 0;
+}
+
static void *nouveau_gem_prime_kmap_atomic(struct dma_buf *buf,
unsigned long page)
{
@@ -106,6 +126,8 @@ static const struct dma_buf_ops nouveau_gem_prime_dmabuf_ops
= {
.map_dma_buf = drm_gem_map_dma_buf,
.unmap_dma_buf = drm_gem_unmap_dma_buf,
.release = drm_gem_dmabuf_release,
+ .begin_cpu_access = nouveau_gem_prime_begin_cpu_access,
+ .end_cpu_access = nouveau_gem_prime_end_cpu_access,
.map_atomic = nouveau_gem_prime_kmap_atomic,
.unmap_atomic = nouveau_gem_prime_kunmap_atomic,
.map = nouveau_gem_prime_kmap,
--
2.15.1
Daniel Vetter
2018-Jan-12 08:56 UTC
[Nouveau] [PATCH 2/5] drm/prime: Export more helpers for drivers
On Thu, Jan 11, 2018 at 10:44:17PM +0100, Thierry Reding wrote:> From: Thierry Reding <treding at nvidia.com> > > Export some more of the helpers in order to allow drivers to more fine- > grainedly select which helpers to use. This gives drivers an easy way to > reuse a lot of the code in the helpers while at the same time allowing > them to provide their own implementation for other functions in struct > dma_buf_ops. > > Signed-off-by: Thierry Reding <treding at nvidia.com>Same request as with the amd one: Pls supply a bit of kerneldoc and maybe polished intro section. Otherwise lgtm. -Daniel> --- > drivers/gpu/drm/drm_prime.c | 23 +++++++++++++---------- > include/drm/drm_prime.h | 12 ++++++++++++ > 2 files changed, 25 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c > index 9a17725b0f7a..f9903e6b59f6 100644 > --- a/drivers/gpu/drm/drm_prime.c > +++ b/drivers/gpu/drm/drm_prime.c > @@ -180,9 +180,8 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri > return -ENOENT; > } > > -static int drm_gem_map_attach(struct dma_buf *dma_buf, > - struct device *target_dev, > - struct dma_buf_attachment *attach) > +int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev, > + struct dma_buf_attachment *attach) > { > struct drm_prime_attachment *prime_attach; > struct drm_gem_object *obj = dma_buf->priv; > @@ -200,9 +199,10 @@ static int drm_gem_map_attach(struct dma_buf *dma_buf, > > return dev->driver->gem_prime_pin(obj); > } > +EXPORT_SYMBOL(drm_gem_map_attach); > > -static void drm_gem_map_detach(struct dma_buf *dma_buf, > - struct dma_buf_attachment *attach) > +void drm_gem_map_detach(struct dma_buf *dma_buf, > + struct dma_buf_attachment *attach) > { > struct drm_prime_attachment *prime_attach = attach->priv; > struct drm_gem_object *obj = dma_buf->priv; > @@ -228,6 +228,7 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf, > kfree(prime_attach); > attach->priv = NULL; > } > +EXPORT_SYMBOL(drm_gem_map_detach); > > void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, > struct dma_buf *dma_buf) > @@ -254,8 +255,8 @@ void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpr > } > } > > -static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, > - enum dma_data_direction dir) > +struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, > + enum dma_data_direction dir) > { > struct drm_prime_attachment *prime_attach = attach->priv; > struct drm_gem_object *obj = attach->dmabuf->priv; > @@ -291,13 +292,15 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, > > return sgt; > } > +EXPORT_SYMBOL(drm_gem_map_dma_buf); > > -static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, > - struct sg_table *sgt, > - enum dma_data_direction dir) > +void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, > + struct sg_table *sgt, > + enum dma_data_direction dir) > { > /* nothing to be done here */ > } > +EXPORT_SYMBOL(drm_gem_unmap_dma_buf); > > /** > * drm_gem_dmabuf_export - dma_buf export implementation for GEM > diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h > index 59ccab402e85..3a9706815773 100644 > --- a/include/drm/drm_prime.h > +++ b/include/drm/drm_prime.h > @@ -50,8 +50,10 @@ struct drm_prime_file_private { > struct rb_root handles; > }; > > +enum dma_data_direction; > struct device; > > +struct dma_buf_attachment; > struct dma_buf_export_info; > struct dma_buf; > > @@ -59,6 +61,16 @@ struct drm_device; > struct drm_gem_object; > struct drm_file; > > +int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev, > + struct dma_buf_attachment *attach); > +void drm_gem_map_detach(struct dma_buf *dma_buf, > + struct dma_buf_attachment *attach); > +struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, > + enum dma_data_direction dir); > +void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, > + struct sg_table *sgt, > + enum dma_data_direction dir); > + > struct dma_buf *drm_gem_prime_export(struct drm_device *dev, > struct drm_gem_object *obj, > int flags); > -- > 2.15.1 > > _______________________________________________ > Nouveau mailing list > Nouveau at lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/nouveau-- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Maybe Matching Threads
- [PATCH 2/5] drm/prime: Export more helpers for drivers
- [PATCH v3 2/3] drm: plumb attaching dev thru to prime_pin/unpin
- [PATCH v3 2/3] drm: plumb attaching dev thru to prime_pin/unpin
- [PATCH v3 2/3] drm: plumb attaching dev thru to prime_pin/unpin
- [PATCH 20/20] drm: Remove obsolete GEM and PRIME callbacks from struct drm_driver