当前位置:网站首页>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;
}
边栏推荐
- Network Engineer required course firewall security zone and basic operation of security policy
- About log traffic monitoring and early warning small project | flag log monitoring script
- [introduction to ROS] - 03 ROS workspace and function pack
- CentOS actual deployment redis
- The best creative drum tool: groove agent 5
- WSL 自动更新 ip hosts 文件
- 最好的創意鼓工具:Groove Agent 5
- 数组的字典排序
- The driver has not received any packets from the server
- Loop structure statement
猜你喜欢

What exactly does Devops mean?

About log traffic monitoring and early warning small project | flask

中小企业数字化转型为什么这么难?

MySQL

亿级搜索系统(优酷视频搜索)的基石,如何保障实时数据质量?v2020

SLAM卡尔曼滤波&&非线性优化

为什么使用 Golang 进行 Web 开发

阻塞隊列 — DelayedWorkQueue源碼分析

About the log traffic monitoring and early warning small project | standardized return of interaction with the database in flask
WSL 自动更新 ip hosts 文件
随机推荐
A simple understanding of B tree
Unable to return to the default page after page Jump
WSL 自动更新 ip hosts 文件
Idea setting background picture (simple)
Loop structure statement
Embedded learning materials and project summary
Detailed explanation of five types of load balancing principle scenarios
Unity points that are vulnerable to pit
手把手教你前后分离架构(五) 系统身份验证实现
最好的创意鼓工具:Groove Agent 5
SLAM卡尔曼滤波&&非线性优化
招聘 | 南京 | TRIOSTUDIO 三厘社 – 室内设计师 / 施工图深化设计师 / 装置/产品设计师 / 实习生等
What is the difference between hubs, switches and routers?
Volatile keyword for concurrent programming
async await
大厂是面对深度分页问题是如何解决的(通俗易懂)
Blend for visual studio overview
Lucene mind map makes search engines no longer difficult to understand
【ROS入门教程】---- 03 单片机、PC主机、ROS通信机制
compiler explorer