当前位置:网站首页>ion_ mmap
ion_ mmap
2022-06-11 01:05:00 【wmzjzwlzs】
static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
{
struct ion_buffer *buffer = dmabuf->priv;
int ret = 0;
if (!buffer->heap->ops->map_user) {
pr_err("%s: this heap does not define a method for mapping to userspace\n",
__func__);
return -EINVAL;
}
if (!(buffer->flags & ION_FLAG_CACHED))
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
mutex_lock(&buffer->lock);
/* now map it to userspace */
ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
mutex_unlock(&buffer->lock);
if (ret)
pr_err("%s: failure mapping buffer to userspace\n",
__func__);
return ret;
}
int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
struct vm_area_struct *vma)
{
struct sg_table *table = buffer->sg_table;
unsigned long addr = vma->vm_start;
unsigned long offset = vma->vm_pgoff * PAGE_SIZE;
struct scatterlist *sg;
int i;
int ret;
for_each_sg(table->sgl, sg, table->nents, i) {
struct page *page = sg_page(sg);
unsigned long remainder = vma->vm_end - addr;
unsigned long len = sg->length;
if (offset >= sg->length) {
offset -= sg->length;
continue;
} else if (offset) {
page += offset / PAGE_SIZE;
len = sg->length - offset;
offset = 0;
}
len = min(len, remainder);
ret = remap_pfn_range(vma, addr, page_to_pfn(page), len,
vma->vm_page_prot);
if (ret)
return ret;
addr += len;
if (addr >= vma->vm_end)
return 0;
}
return 0;
}
边栏推荐
- Embedded learning materials and project summary
- Solid basic knowledge + correct method is the key to quickly read the source code
- Block queue - delayedworkqueue Source Analysis
- Kwai handled more than 54000 illegal accounts: how to crack down on illegal accounts on the platform
- ion_dma_buf_begin_cpu_access
- Deploy netron services through kubernetes and specify model files at startup
- MySQL
- 扎实的基础知识+正确的方法是快速阅读源码的关键
- oracle带xy字段值的关系表同步到pg数据库转为几何字段
- How to solve the deep paging problem in large factories (easy to understand)
猜你喜欢

Load balancing strategy graphic explanation

C语言实现设置桌面壁纸

如何保证消息的顺序性、消息不丢失、不被重复消费

compiler explorer

MESI cache consistency protocol for concurrent programming

Dynamic programming classical topic triangle shortest path

Pirate OJ 148 String inversion

Automated test series

The best creative drum tool: groove agent 5

What is MYCAT? Get to know you quickly
随机推荐
【NVIDIA驱动的顽固问题】---- /dev/sdax:clean,xxx/xxx files,xxx/xxx blocks ---- 最全解决方法
zabbix离线安装
Locks in sqlserver
cosine 相似度计算总结
The principle and source code interpretation of executor thread pool in concurrent programming
oracle带xy字段值的关系表同步到pg数据库转为几何字段
Dynamic programming classical topic triangle shortest path
BlindWaterMar报错No module named cv2
pytorch分类问题总结
Unity 容易被坑的点
What is thread in concurrent programming
适配器模式
compiler explorer
数组的字典排序
About log traffic monitoring and early warning small project | database management tool: migrate
【ROS入门教程】---- 03 ROS基本概念及指令
LeetCode 8. String to integer (ATOI) (medium, string)
[persistent problems of NVIDIA driver] - - /dev/sdax:clean, xxx/xxx files, xxx/xxx blocks - the most complete solution
Controltemplate in WPF
A simple understanding of B tree