Skip to content
  • Miles Chen's avatar
    lib/dma-debug.c: fix incorrect pfn calculation · 3aaabbf1
    Miles Chen authored
    dma-debug reports the following warning:
    
      WARNING: CPU: 3 PID: 298 at kernel-4.4/lib/dma-debug.c:604
      debug _dma_assert_idle+0x1a8/0x230()
      DMA-API: cpu touching an active dma mapped cacheline [cln=0x00000882300]
      CPU: 3 PID: 298 Comm: vold Tainted: G        W  O    4.4.22+ #1
      Hardware name: MT6739 (DT)
      Call trace:
        debug_dma_assert_idle+0x1a8/0x230
        wp_page_copy.isra.96+0x118/0x520
        do_wp_page+0x4fc/0x534
        handle_mm_fault+0xd4c/0x1310
        do_page_fault+0x1c8/0x394
        do_mem_abort+0x50/0xec
    
    I found that debug_dma_alloc_coherent() and debug_dma_free_coherent()
    assume that dma_alloc_coherent() always returns a linear address.
    
    However it's possible that dma_alloc_coherent() returns a non-linear
    address.  In this case, page_to_pfn(virt_to_page(virt)) will return an
    incorrect pfn.  If the pfn is valid and mapped as a COW page, we will
    hit the warning when doing wp_page_copy().
    
    Fix this by calculating pfn for linear and non-linear addresses...
    3aaabbf1