Skip to contentSkip to conversation

usage of dma_common_mmap

DISCUSSION Malte Vesper 1 participant 1 message Mar 29, 2015

lore
Share & tools
lore
#0 lore raw

Hello,

I am trying to use dma_mmap_attrs . However I keep getting the following error:

mmap:6420 map pfn RAM range req uncached-minus for [mem 0xfd0000000-0xfd0000fff], got write-back

Assuming that dma_common_map is used
(http://lxr.free-electrons.com/source/drivers/base/dma-mapping.c#L246) I tracked the error source to be comming from: remap_pfn_range After struding the codeflow I think that this macro is the culprit:

12 #define pgprot_noncached(prot) \
13 ((boot_cpu_data.x86 >
3) \
14 ? (__pgprot(pgprot_val(prot)
| \
15 cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS))) \
16 : (prot))

since the "got write-back" is calculated from the memory address I assume I can not change that bit.
Could anyone explain to me, why the page protection depends on boot_cpu_data?

Googling turned up further hints
http://comments.gmane.org/gmane.linux.kernel.mm/125059. Is this a Bug or am I missing something?
How do I correctly use dma_mmap_attrs? Currently I try:

mmap function:

    return dma_mmap_attrs(&pcidev->dev, vma, buffer->memoryAddress,
    buffer->dmaAddress, BUF_SIZE, 0);

testfile:

         char* fpath = "/proc/myDevice";
         uint64_t* buffer;
         int filepointer = open(fpath, O_RDWR);

         if(filepointer < 0) {
             printf("Could not open %s.\n", fpath);
             return -1;
         }

         buffer = (uint64_t*) mmap(0, 4096, PROT_READ | PROT_WRITE,
    MAP_PRIVATE, filepointer, 0);

Thanks for any help,
Malte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150329/ac2ed550/attachment.html