cache maintenance for device memory
Random Guy
random.guy.from.russia at gmail.com
Fri Dec 4 19:46:32 EST 2015
Hi syed,
thanks for your response.
On Fri, Dec 4, 2015 at 9:16 AM, sk.syed2 <sk.syed2 at gmail.com> wrote:
>> I have a device with a piece of RAM. That memory is accessible to CPU.
>> I write a driver for that device and it maps device memory directly to
>> userspace processes. This mapping is cacheable. So far so good.
>>
> How did you map this device memory? Using ioremap? What platform is this?
No, I provide mmap for the device file and then I do remap_pfn_range
using vma->vm_pgoff as an offset into the device memory block.
That's custom R&D ARM-based thing.
>> Now I'd like to flush or invalidate cache on specific parts of that memory.
>> If it was just normal system memory I could use streaming DMA API:
>> dma_map_*/dma_sync_*/dma_unmap_*. But the device memory is not
>> a part of system memory and so there are no struct page for its pages,
>> and thus streaming DMA support functions don't work.
>
> Once you map the io memory, you get VAs for that memory and you should be able
> to use dma_sync APIs.
I've looked at the following function calls:
arm_dma_sync_single_for_cpu
-> dma_cache_maint_page
-> __dma_page_dev_to_cpu
and I see them mapping DMA handle to struct page and using that struct page.
I'm sure that will not work, because as I said the device memory is not covered
by struct page's.
More information about the Kernelnewbies
mailing list