diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-04-07 11:15:50 -0700 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-04-07 11:15:50 -0700 |
commit | 454abcc57f1d48a976291bc4af73b5f087e21d70 (patch) | |
tree | 5bba999ea3f31527da02b60604531cc5fb52ea57 /arch/powerpc/mm/dma-noncoherent.c | |
parent | 88aab9341a315d81118be6b41c45e4fe32b94bc1 (diff) | |
parent | 6221f222c0ebf1acdf7abcf927178f40e1a65e2a (diff) | |
download | blackbird-op-linux-454abcc57f1d48a976291bc4af73b5f087e21d70.tar.gz blackbird-op-linux-454abcc57f1d48a976291bc4af73b5f087e21d70.zip |
Merge commit 'v2.6.39-rc2' into spi/merge
Diffstat (limited to 'arch/powerpc/mm/dma-noncoherent.c')
-rw-r--r-- | arch/powerpc/mm/dma-noncoherent.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/powerpc/mm/dma-noncoherent.c b/arch/powerpc/mm/dma-noncoherent.c index 757c0bed9a91..b42f76c4948d 100644 --- a/arch/powerpc/mm/dma-noncoherent.c +++ b/arch/powerpc/mm/dma-noncoherent.c @@ -399,3 +399,23 @@ void __dma_sync_page(struct page *page, unsigned long offset, #endif } EXPORT_SYMBOL(__dma_sync_page); + +/* + * Return the PFN for a given cpu virtual address returned by + * __dma_alloc_coherent. This is used by dma_mmap_coherent() + */ +unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr) +{ + /* This should always be populated, so we don't test every + * level. If that fails, we'll have a nice crash which + * will be as good as a BUG_ON() + */ + pgd_t *pgd = pgd_offset_k(cpu_addr); + pud_t *pud = pud_offset(pgd, cpu_addr); + pmd_t *pmd = pmd_offset(pud, cpu_addr); + pte_t *ptep = pte_offset_kernel(pmd, cpu_addr); + + if (pte_none(*ptep) || !pte_present(*ptep)) + return 0; + return pte_pfn(*ptep); +} |