revert: vc8000e: support mmap in fops

Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
This commit is contained in:
Han Gao
2024-03-06 18:52:18 +08:00
committed by Han Gao/Revy/Rabenda
parent 618138e424
commit dda416a8b2

View File

@@ -2610,63 +2610,12 @@ static int hantrovcmd_release(struct inode *inode, struct file *filp)
return 0;
}
static bool hantroenc_cmdbuf_range(size_t addr, size_t size);
static int mmap_cmdbuf_mem(struct file *file, struct vm_area_struct *vma)
{
size_t size = vma->vm_end - vma->vm_start;
phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
/* Does it even fit in phys_addr_t? */
if (offset >> PAGE_SHIFT != vma->vm_pgoff)
return -EINVAL;
/* It's illegal to wrap around the end of the physical address space. */
if (offset + (phys_addr_t)size - 1 < offset)
return -EINVAL;
vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
size,
vma->vm_page_prot);
/* Remap-pfn-range will mark the range VM_IO */
if (remap_pfn_range(vma,
vma->vm_start,
vma->vm_pgoff,
size,
vma->vm_page_prot))
{
return -EAGAIN;
}
return 0;
}
static int mmap_mem(struct file *file, struct vm_area_struct *vma)
{
size_t size = vma->vm_end - vma->vm_start;
phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
if (hantroenc_cmdbuf_range(offset, size))
{
return mmap_cmdbuf_mem(file, vma);
}
else
{
return -EINVAL;
/*TODO: need check if not need enc,in this condition*/
//return allocator_mmap(file,vma);
}
}
/* VFS methods */
static struct file_operations hantrovcmd_fops = {
.owner= THIS_MODULE,
.open = hantrovcmd_open,
.release = hantrovcmd_release,
.unlocked_ioctl = hantrovcmd_ioctl,
.mmap = mmap_mem,
.fasync = NULL,
};
@@ -4669,17 +4618,3 @@ static void vcmd_reset(void)
vcmd_reset_asic(hantrovcmd_data);
}
}
static bool hantroenc_cmdbuf_range(size_t addr, size_t size)
{
bool bInRange;
bInRange = (addr >= vcmd_buf_mem_pool.busAddress &&
(addr - vcmd_buf_mem_pool.busAddress + size) <= CMDBUF_POOL_TOTAL_SIZE) ||
(addr >= vcmd_status_buf_mem_pool.busAddress &&
(addr - vcmd_status_buf_mem_pool.busAddress + size) <= CMDBUF_POOL_TOTAL_SIZE) ||
(addr >= vcmd_registers_mem_pool.busAddress &&
(addr - vcmd_status_buf_mem_pool.busAddress + size) <= CMDBUF_VCMD_REGISTER_TOTAL_SIZE);
return bInRange;
}