Revert "ANDROID: dmabuf: Add mmap_count to struct dmabuf"

This reverts commit 9132fbe545.

Reason for revert: mmap_count is no longer used for reporting dma-bufs
and introduces subtle bugs related to changing the vm_ops

Bug: 192459295
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: Id07802e5a3e18918c5c46e31b73be4a594f7dc26
This commit is contained in:
Kalesh Singh
2021-06-30 13:14:17 -04:00
committed by Todd Kjos
parent 32f0fa685c
commit 25c500f2dc
4 changed files with 1 additions and 72 deletions

View File

@@ -50,10 +50,3 @@ KernelVersion: v5.12
Contact: Hridya Valsaraju <hridya@google.com>
Description: This file is read-only and contains a map_counter indicating the
number of distinct device mappings of the attachment.
What: /sys/kernel/dmabuf/buffers/<inode_number>/mmap_count
Date: January 2021
KernelVersion: v5.10
Contact: Kalesh Singh <kaleshsingh@google.com>
Description: This file is read-only and contains a counter indicating the
number of times the buffer has been mmap().

View File

@@ -52,13 +52,6 @@ static ssize_t exporter_name_show(struct dma_buf *dmabuf,
return sysfs_emit(buf, "%s\n", dmabuf->exp_name);
}
static ssize_t mmap_count_show(struct dma_buf *dmabuf,
struct dma_buf_stats_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%d\n", dmabuf->mmap_count);
}
static ssize_t size_show(struct dma_buf *dmabuf,
struct dma_buf_stats_attribute *attr,
char *buf)
@@ -69,13 +62,10 @@ static ssize_t size_show(struct dma_buf *dmabuf,
static struct dma_buf_stats_attribute exporter_name_attribute =
__ATTR_RO(exporter_name);
static struct dma_buf_stats_attribute size_attribute = __ATTR_RO(size);
static struct dma_buf_stats_attribute mmap_count_attribute =
__ATTR_RO(mmap_count);
static struct attribute *dma_buf_stats_default_attrs[] = {
&exporter_name_attribute.attr,
&size_attribute.attr,
&mmap_count_attribute.attr,
NULL,
};
ATTRIBUTE_GROUPS(dma_buf_stats_default);

View File

@@ -149,54 +149,6 @@ static struct file_system_type dma_buf_fs_type = {
.kill_sb = kill_anon_super,
};
#ifdef CONFIG_DMABUF_SYSFS_STATS
static void dma_buf_vma_open(struct vm_area_struct *vma)
{
struct dma_buf *dmabuf = vma->vm_file->private_data;
dmabuf->mmap_count++;
/* call the heap provided vma open() op */
if (dmabuf->exp_vm_ops->open)
dmabuf->exp_vm_ops->open(vma);
}
static void dma_buf_vma_close(struct vm_area_struct *vma)
{
struct dma_buf *dmabuf = vma->vm_file->private_data;
if (dmabuf->mmap_count)
dmabuf->mmap_count--;
/* call the heap provided vma close() op */
if (dmabuf->exp_vm_ops->close)
dmabuf->exp_vm_ops->close(vma);
}
static int dma_buf_do_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
{
/* call this first because the exporter might override vma->vm_ops */
int ret = dmabuf->ops->mmap(dmabuf, vma);
if (ret)
return ret;
/* save the exporter provided vm_ops */
dmabuf->exp_vm_ops = vma->vm_ops;
dmabuf->vm_ops = *(dmabuf->exp_vm_ops);
/* override open() and close() to provide buffer mmap count */
dmabuf->vm_ops.open = dma_buf_vma_open;
dmabuf->vm_ops.close = dma_buf_vma_close;
vma->vm_ops = &dmabuf->vm_ops;
dmabuf->mmap_count++;
return ret;
}
#else /* CONFIG_DMABUF_SYSFS_STATS */
static int dma_buf_do_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
{
return dmabuf->ops->mmap(dmabuf, vma);
}
#endif /* CONFIG_DMABUF_SYSFS_STATS */
static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
{
struct dma_buf *dmabuf;
@@ -215,7 +167,7 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
dmabuf->size >> PAGE_SHIFT)
return -EINVAL;
return dma_buf_do_mmap(dmabuf, vma);
return dmabuf->ops->mmap(dmabuf, vma);
}
static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)

View File

@@ -381,9 +381,6 @@ struct dma_buf_ops {
* @sysfs_entry: for exposing information about this buffer in sysfs.
* The attachment_uid member of @sysfs_entry is protected by dma_resv lock
* and is incremented on each attach.
* @mmap_count: number of times buffer has been mmapped.
* @exp_vm_ops: the vm ops provided by the buffer exporter.
* @vm_ops: the overridden vm_ops used to track mmap_count of the buffer.
*
* This represents a shared buffer, created by calling dma_buf_export(). The
* userspace representation is a normal file descriptor, which can be created by
@@ -427,9 +424,6 @@ struct dma_buf {
unsigned int attachment_uid;
struct kset *attach_stats_kset;
} *sysfs_entry;
int mmap_count;
const struct vm_operations_struct *exp_vm_ops;
struct vm_operations_struct vm_ops;
#endif
};