aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2023-03-10 11:24:12 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2023-03-10 11:24:12 +0530
commit76a9a78c4ea8c9c4790c9c6c6cb27384332a4d15 (patch)
treefc286308f0b91b1639f9e555cf9fafde98220327
parent1693fb78027439052c0eb4d8d142c6785f8e1ff6 (diff)
Revert "HACK: xen: gntdev: Do mmap() without need of an ioctl()"0/bkp/xen-host-hacks
This reverts commit 1693fb78027439052c0eb4d8d142c6785f8e1ff6. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r--drivers/xen/gntdev-common.h1
-rw-r--r--drivers/xen/gntdev.c58
2 files changed, 5 insertions, 54 deletions
diff --git a/drivers/xen/gntdev-common.h b/drivers/xen/gntdev-common.h
index 115bd9d68715..9c286b2a1900 100644
--- a/drivers/xen/gntdev-common.h
+++ b/drivers/xen/gntdev-common.h
@@ -34,7 +34,6 @@ struct gntdev_priv {
#ifdef CONFIG_XEN_GNTDEV_DMABUF
struct gntdev_dmabuf_priv *dmabuf_priv;
#endif
- bool ioctl_called;
};
struct gntdev_unmap_notify {
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 03a329965d43..bfbf6ec2ef57 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -628,16 +628,6 @@ static int gntdev_release(struct inode *inode, struct file *flip)
return 0;
}
-static void gntdev_ioctl_map_grant_ref_internal(struct gntdev_priv *priv,
- struct ioctl_gntdev_map_grant_ref *op,
- struct gntdev_grant_map *map)
-{
- mutex_lock(&priv->lock);
- gntdev_add_map(priv, map);
- op->index = map->index << PAGE_SHIFT;
- mutex_unlock(&priv->lock);
-}
-
static long gntdev_ioctl_map_grant_ref(struct gntdev_priv *priv,
struct ioctl_gntdev_map_grant_ref __user *u)
{
@@ -662,44 +652,17 @@ static long gntdev_ioctl_map_grant_ref(struct gntdev_priv *priv,
return -EFAULT;
}
- gntdev_ioctl_map_grant_ref_internal(priv, &op, map);
+ mutex_lock(&priv->lock);
+ gntdev_add_map(priv, map);
+ op.index = map->index << PAGE_SHIFT;
+ mutex_unlock(&priv->lock);
if (copy_to_user(u, &op, sizeof(op)) != 0)
return -EFAULT;
- priv->ioctl_called = true;
return 0;
}
-static long gntdev_ioctl_map_grant_ref_nouser(struct gntdev_priv *priv,
- u64 offset, int count)
-{
- struct ioctl_gntdev_map_grant_ref op;
- struct gntdev_grant_map *map;
- int err, i, domid;
-
- domid = offset & 0xf;
- offset >>= 4;
-
- op.count = count;
- if (unlikely(gntdev_test_page_count(op.count)))
- return -EINVAL;
-
- err = -ENOMEM;
- map = gntdev_alloc_map(priv, op.count, 0 /* This is not a dma-buf. */);
- if (!map)
- return err;
-
- for (i = 0; i < count; i++) {
- map->grants[i].domid = domid;
- map->grants[i].ref = offset + i;
- }
-
- gntdev_ioctl_map_grant_ref_internal(priv, &op, map);
-
- return op.index;
-}
-
static long gntdev_ioctl_unmap_grant_ref(struct gntdev_priv *priv,
struct ioctl_gntdev_unmap_grant_ref __user *u)
{
@@ -1073,17 +1036,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
int index = vma->vm_pgoff;
int count = vma_pages(vma);
struct gntdev_grant_map *map;
- int ret, err = -EINVAL;
-
- // Call IOCTL first
- if (!priv->ioctl_called) {
- ret = gntdev_ioctl_map_grant_ref_nouser(priv, index, count);
- if (ret < 0) {
- return ret;
- }
-
- index = vma->vm_pgoff = ret;
- }
+ int err = -EINVAL;
if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED))
return -EINVAL;
@@ -1163,7 +1116,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
goto out_put_map;
}
- priv->ioctl_called = false;
return 0;
unlock_out: