check if the mapped memory supports write combining

余生长醉 提交于 2019-12-12 03:37:23

问题


I write a kernel driver which exposes to the user space my I/O device. Using mmap the application gets virtual address to write into the device. Since i want the application write uses a big PCIe transaction, the driver maps this memory to be write combining. According to the memory type (write-combining or non-cached) the application applies an optimal method to work with the device.

But, some architectures do not support write-combining or may support but just for part of the memory space. Hence, it is important that the kernel driver tell to application if it succeeded to map the memory to be write-combining or not.

I need a generic way to check in the kernel driver if the memory it mapped (or going to map) is write-combining or not. How can i do it?

here is part of my code:

vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); io_remap_pfn_range(vma, vma->vm_start, pfn, PAGE_SIZE, vma->vm_page_prot);


回答1:


First, you can find out if an architecture supports write-combining at compile time, with the macro ARCH_HAS_IOREMAP_WC. See, for instance, here.

At run-time, you can check the return values from ioremap_wc, or set_memory_wc and friends for success or not.



来源:https://stackoverflow.com/questions/35862717/check-if-the-mapped-memory-supports-write-combining

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!