What is the difference between these two functions: `ioremap_uc()` and `set_memory_uc`?

♀尐吖头ヾ 提交于 2019-12-10 17:11:26

问题


When I want to mark memory region as Write Combined (to disable cacheable and use BIU) or Uncacheable through set PAT(Page attribute table - 7bit in PTE), then what do I must to use, and what is the difference between two these functions?

  • Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access types: void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
  • Drivers should use set_memory_[uc|wc] to set access type for RAM ranges: int set_memory_uc(unsigned long addr, int numpages)

Taken from: http://lwn.net/Articles/278994/

Why can't I use the same single function both for PCI BARs and RAM ranges?

Clarification: Does ioremap_uc() get physical address and return virtual address with setting Uncacheable, versus set_memory_uc() which get already virtual address and set Uncacheable for these pages?

Are these codes equal?

void* virt_ptr = ioremap_uc(phys_ptr, size);

and

void* virt_ptr = ioremap(phys_ptr, size);
const int page_size = 4096;
set_memory_uc(virt_ptr, size/page_size);

来源:https://stackoverflow.com/questions/19811237/what-is-the-difference-between-these-two-functions-ioremap-uc-and-set-memo

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