Re: [PATCH v3 7/9] xen/gntdev: Add initial support for dma-buf UAPI

From: Oleksandr Andrushchenko
Date: Wed Jun 13 2018 - 04:17:35 EST


On 06/13/2018 04:49 AM, Boris Ostrovsky wrote:


On 06/12/2018 09:41 AM, Oleksandr Andrushchenko wrote:

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a09db23e9663..e82660d81d7e 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -48,6 +48,9 @@
 #include <asm/xen/hypercall.h>
  #include "gntdev-common.h"
+#ifdef CONFIG_XEN_GNTDEV_DMABUF
+#include "gntdev-dmabuf.h"
+#endif
  MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Derek G. Murray <Derek.Murray@xxxxxxxxxxxx>, "
@@ -566,6 +569,15 @@ static int gntdev_open(struct inode *inode, struct file *flip)
ÂÂÂÂÂ INIT_LIST_HEAD(&priv->freeable_maps);
ÂÂÂÂÂ mutex_init(&priv->lock);
 +#ifdef CONFIG_XEN_GNTDEV_DMABUF
+ÂÂÂ priv->dmabuf_priv = gntdev_dmabuf_init();
+ÂÂÂ if (IS_ERR(priv->dmabuf_priv)) {
+ÂÂÂÂÂÂÂ ret = PTR_ERR(priv->dmabuf_priv);
+ÂÂÂÂÂÂÂ kfree(priv);
+ÂÂÂÂÂÂÂ return ret;
+ÂÂÂ }
+#endif
+
ÂÂÂÂÂ if (use_ptemod) {
ÂÂÂÂÂÂÂÂÂ priv->mm = get_task_mm(current);
ÂÂÂÂÂÂÂÂÂ if (!priv->mm) {
@@ -616,8 +628,13 @@ static int gntdev_release(struct inode *inode, struct file *flip)
ÂÂÂÂÂ WARN_ON(!list_empty(&priv->freeable_maps));
ÂÂÂÂÂ mutex_unlock(&priv->lock);
 +#ifdef CONFIG_XEN_GNTDEV_DMABUF
+ÂÂÂ gntdev_dmabuf_fini(priv->dmabuf_priv);
+#endif
+
ÂÂÂÂÂ if (use_ptemod)
ÂÂÂÂÂÂÂÂÂ mmu_notifier_unregister(&priv->mn, priv->mm);
+
ÂÂÂÂÂ kfree(priv);
ÂÂÂÂÂ return 0;
 }
@@ -987,6 +1004,107 @@ static long gntdev_ioctl_grant_copy(struct gntdev_priv *priv, void __user *u)
ÂÂÂÂÂ return ret;
 }
 +#ifdef CONFIG_XEN_GNTDEV_DMABUF
+static long
+gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct ioctl_gntdev_dmabuf_exp_from_refs __user *u)


Didn't we agree that this code moves to gntdev-dmabuf.c ?

Sure, didn't think we want IOCTL's code to be moved as well,
but that does make sense - will move all
-boris

Thank you,
Oleksandr