Skip to contentSkip to conversation

sparc: Add pci32_unmap_page.

PATCH Superseded Kristoffer Glembo 2 participants 3 messages Jan 13, 2011 – Jan 18, 2011 SPARC + UltraSPARC (sparc/sparc64)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/4 sparc: Add pci32_unmap_page.

---
 arch/sparc/kernel/ioport.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/sparc/kernel/ioport.c +8 -0
index cea49c0..1b9f07c 100644
@@ -524,6 +524,13 @@ static dma_addr_t pci32_map_page(struct device *dev, struct page *page,
 	return page_to_phys(page) + offset;
 }
 
+static void pci32_unmap_page(struct device *dev, dma_addr_t ba, size_t size,
+			     enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+	if (dir != PCI_DMA_TODEVICE)
+		mmu_inval_dma_area((unsigned long)phys_to_virt(ba), PAGE_ALIGN(size));
+}
+
 /* Map a set of buffers described by scatterlist in streaming
  * mode for DMA.  This is the scather-gather version of the
  * above pci_map_single interface.  Here the scatter gather list
@@ -646,6 +653,7 @@ struct dma_map_ops pci32_dma_ops = {
 	.alloc_coherent		= pci32_alloc_coherent,
 	.free_coherent		= pci32_free_coherent,
 	.map_page		= pci32_map_page,
+	.unmap_page		= pci32_unmap_page,
 	.map_sg			= pci32_map_sg,
 	.unmap_sg		= pci32_unmap_sg,
 	.sync_single_for_cpu	= pci32_sync_single_for_cpu,
Signature · 1 line
1.6.4.1
#1 lore raw
Quoted 1 line · Kristoffer Glembo

I totally miss _why_ you add this function. Just a small comment in the changelog would help. It may due to my ignorance of all the dma stuff...

Quoted 9 lines
---
 arch/sparc/kernel/ioport.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/sparc/kernel/ioport.c +0 -0
index cea49c0..1b9f07c 100644

arch/sparc/kernel/ioport.c static dma_addr_t pci32_map_page(struct device *dev, struct page *page, · line 532

Quoted 9 lines
arch/sparc/kernel/ioport.c +6 -0
@@ -524,6 +524,13 @@ static dma_addr_t pci32_map_page(struct device *dev, struct page *page,
 	return page_to_phys(page) + offset;
 }
 
+static void pci32_unmap_page(struct device *dev, dma_addr_t ba, size_t size,
+			     enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+	if (dir != PCI_DMA_TODEVICE)
+		mmu_inval_dma_area((unsigned long)phys_to_virt(ba), PAGE_ALIGN(size));
+}

How about a patch that fix it so mmu_inval_dma_area() takes a void * as first argument?
In most cases I see a cast from void * => unsigned long where we call mmu_inval_dma_area().

In sbus_alloc_coherent() we use the result of __get_free_pages() but the general pattern is that the result of __get_free_pages() is cast to the right type when used.

So if we did:

void * va;

va = (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP, order); Then we could remove all the other casts.

Sam

#2 lore raw
In reply to Kristoffer Glembo

Hi Sam,

Sorry for my sluggish replies.

Quoted 7 lines · Sam Ravnborg
Quoted 1 line · Kristoffer Glembo

I totally miss _why_ you add this function. Just a small comment in the changelog would help. It may due to my ignorance of all the dma stuff...

It is part of the DMA API and needed by our ethernet driver. I guess no PCI driver (on sparc) used it before.

Quoted 6 lines

How about a patch that fix it so mmu_inval_dma_area() takes a void * as first argument?
In most cases I see a cast from void * => unsigned long where we call mmu_inval_dma_area().

Ok.

/Kristoffer