Skip to contentSkip to conversation

MIPS: Reinstate plat_map_dma_mem_page()

PATCH In review Kevin Cernekee 2 participants 2 messages Oct 10, 2010 – Oct 11, 2010 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 MIPS: Reinstate plat_map_dma_mem_page()

[Patch is against linux-queue.git]

plat_map_dma_mem_page() is required in order to translate a "struct page" directly to a physical address. plat_map_dma_mem() is not effective on HIGHMEM pages.

---
 .../include/asm/mach-cavium-octeon/dma-coherence.h |    6 ++++++
 arch/mips/include/asm/mach-generic/dma-coherence.h |    6 ++++++
 arch/mips/include/asm/mach-ip27/dma-coherence.h    |    8 ++++++++
 arch/mips/include/asm/mach-ip32/dma-coherence.h    |   13 +++++++++++++
 arch/mips/include/asm/mach-jazz/dma-coherence.h    |    6 ++++++
 .../mips/include/asm/mach-loongson/dma-coherence.h |    6 ++++++
 arch/mips/include/asm/mach-powertv/dma-coherence.h |    6 ++++++
 7 files changed, 51 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +6 -0
index a3f6676..dfdcf49 100644
@@ -23,6 +23,12 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	BUG();
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	BUG();
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
arch/mips/include/asm/mach-generic/dma-coherence.h +6 -0
index 8259966..8da9807 100644
@@ -17,6 +17,12 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	return virt_to_phys(addr);
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	return page_to_phys(page);
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
arch/mips/include/asm/mach-ip27/dma-coherence.h +8 -0
index 2a55c55..016d098 100644
@@ -26,6 +26,14 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	return pa;
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	dma_addr_t pa = dev_to_baddr(dev, page_to_phys(page));
+
+	return pa;
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
arch/mips/include/asm/mach-ip32/dma-coherence.h +13 -0
index f204a1f..c8fb5aa 100644
@@ -37,6 +37,19 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	return pa;
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	dma_addr_t pa;
+
+	pa = page_to_phys(page) & RAM_OFFSET_MASK;
+
+	if (dev == NULL)
+		pa += CRIME_HI_MEM_BASE;
+
+	return pa;
+}
+
 /* This is almost certainly wrong but it's what dma-ip32.c used to use  */
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
arch/mips/include/asm/mach-jazz/dma-coherence.h +6 -0
index f2bc39a..302101b 100644
@@ -17,6 +17,12 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t
 	return vdma_alloc(virt_to_phys(addr), size);
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	return vdma_alloc(page_to_phys(page), PAGE_SIZE);
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
arch/mips/include/asm/mach-loongson/dma-coherence.h +6 -0
index 8daeaee..981c75f 100644
@@ -19,6 +19,12 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	return virt_to_phys(addr) | 0x80000000;
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+					       struct page *page)
+{
+	return page_to_phys(page) | 0x80000000;
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
arch/mips/include/asm/mach-powertv/dma-coherence.h +6 -0
index 647de8c..f76029c 100644
@@ -70,6 +70,12 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 		return phys_to_dma(virt_to_phys(addr));
 }
 
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+	struct page *page)
+{
+	return phys_to_dma(page_to_phys(page));
+}
+
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 5 lines · Kevin Cernekee

[Patch is against linux-queue.git]

plat_map_dma_mem_page() is required in order to translate a "struct page" directly to a physical address. plat_map_dma_mem() is not effective on HIGHMEM pages.

Seems to make sense. I've folded your patch into patch 6 of David Daney's series and fixed up the resulting reject in patch 8.

Thanks!

Ralf