···140140 */141141#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)142142143143+#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)144144+#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)145145+146146+#define page_to_virt(page) __va(page_to_phys(page))147147+143148/*144149 * For port to Hexagon Virtual Machine, MAYBE we check for attempts145150 * to reference reserved HVM space, but in any case, the VM will be
+17-10
arch/hexagon/kernel/dma.c
···11/*22 * DMA implementation for Hexagon33 *44- * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.44+ * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.55 *66 * This program is free software; you can redistribute it and/or modify77 * it under the terms of the GNU General Public License version 2 and···2323#include <linux/genalloc.h>2424#include <asm/dma-mapping.h>2525#include <linux/module.h>2626+#include <asm/page.h>26272728struct dma_map_ops *dma_ops;2829EXPORT_SYMBOL(dma_ops);29303031int bad_dma_address; /* globals are automatically initialized to zero */3232+3333+static inline void *dma_addr_to_virt(dma_addr_t dma_addr)3434+{3535+ return phys_to_virt((unsigned long) dma_addr);3636+}31373238int dma_supported(struct device *dev, u64 mask)3339{···6660{6761 void *ret;68626363+ /*6464+ * Our max_low_pfn should have been backed off by 16MB in6565+ * mm/init.c to create DMA coherent space. Use that as the VA6666+ * for the pool.6767+ */6868+6969 if (coherent_pool == NULL) {7070 coherent_pool = gen_pool_create(PAGE_SHIFT, -1);7171···7967 panic("Can't create %s() memory pool!", __func__);8068 else8169 gen_pool_add(coherent_pool,8282- (PAGE_OFFSET + (max_low_pfn << PAGE_SHIFT)),7070+ pfn_to_virt(max_low_pfn),8371 hexagon_coherent_pool_size, -1);8472 }8573···87758876 if (ret) {8977 memset(ret, 0, size);9090- *dma_addr = (dma_addr_t) (ret - PAGE_OFFSET);7878+ *dma_addr = (dma_addr_t) virt_to_phys(ret);9179 } else9280 *dma_addr = ~0;9381···130118131119 s->dma_length = s->length;132120133133- flush_dcache_range(PAGE_OFFSET + s->dma_address,134134- PAGE_OFFSET + s->dma_address + s->length);121121+ flush_dcache_range(dma_addr_to_virt(s->dma_address),122122+ dma_addr_to_virt(s->dma_address + s->length));135123 }136124137125 return nents;···159147 default:160148 BUG();161149 }162162-}163163-164164-static inline void *dma_addr_to_virt(dma_addr_t dma_addr)165165-{166166- return phys_to_virt((unsigned long) dma_addr);167150}168151169152/**