diff options
author | David S. Miller <davem@davemloft.net> | 2008-08-27 21:40:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-29 05:15:07 -0400 |
commit | 4b1c5df2af38b2681b7c1a058534d17c54aaf6cf (patch) | |
tree | 3fd9131a506185fa942865cc5e54ecf274a3b5fb | |
parent | b1387c35bef6da55f6f2c27dfb748c86a4ef7ef9 (diff) |
sparc32: Make mmu_map_dma_area and mmu_unmap_dma_area take a device pointer.
This lets us kill this "map it in every IOMMU" crazy code, and also
some of the final references to sbus_root.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc/include/asm/dma.h | 8 | ||||
-rw-r--r-- | arch/sparc/kernel/ioport.c | 4 | ||||
-rw-r--r-- | arch/sparc/mm/io-unit.c | 14 | ||||
-rw-r--r-- | arch/sparc/mm/iommu.c | 10 | ||||
-rw-r--r-- | arch/sparc/mm/sun4c.c | 6 |
5 files changed, 19 insertions, 23 deletions
diff --git a/arch/sparc/include/asm/dma.h b/arch/sparc/include/asm/dma.h index ee4ac181bf2f..d1ae56be9fa6 100644 --- a/arch/sparc/include/asm/dma.h +++ b/arch/sparc/include/asm/dma.h | |||
@@ -131,11 +131,11 @@ BTFIXUPDEF_CALL(void, mmu_release_scsi_sgl, struct device *, struct scatterlist | |||
131 | * know if we are mapping RAM or I/O, so it has to be an additional argument | 131 | * know if we are mapping RAM or I/O, so it has to be an additional argument |
132 | * to a separate mapping function for CPU visible mappings. | 132 | * to a separate mapping function for CPU visible mappings. |
133 | */ | 133 | */ |
134 | BTFIXUPDEF_CALL(int, mmu_map_dma_area, dma_addr_t *, unsigned long, unsigned long, int len) | 134 | BTFIXUPDEF_CALL(int, mmu_map_dma_area, struct device *, dma_addr_t *, unsigned long, unsigned long, int len) |
135 | BTFIXUPDEF_CALL(void, mmu_unmap_dma_area, unsigned long busa, int len) | 135 | BTFIXUPDEF_CALL(void, mmu_unmap_dma_area, struct device *, unsigned long busa, int len) |
136 | 136 | ||
137 | #define mmu_map_dma_area(pba,va,a,len) BTFIXUP_CALL(mmu_map_dma_area)(pba,va,a,len) | 137 | #define mmu_map_dma_area(dev,pba,va,a,len) BTFIXUP_CALL(mmu_map_dma_area)(dev,pba,va,a,len) |
138 | #define mmu_unmap_dma_area(ba,len) BTFIXUP_CALL(mmu_unmap_dma_area)(ba,len) | 138 | #define mmu_unmap_dma_area(dev,ba,len) BTFIXUP_CALL(mmu_unmap_dma_area)(dev,ba,len) |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | #endif /* !(_ASM_SPARC_DMA_H) */ | 141 | #endif /* !(_ASM_SPARC_DMA_H) */ |
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 82ef20161910..d65fb9b06688 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -339,7 +339,7 @@ void *sbus_alloc_consistent(struct device *dev, long len, u32 *dma_addrp) | |||
339 | * XXX That's where sdev would be used. Currently we load | 339 | * XXX That's where sdev would be used. Currently we load |
340 | * all iommu tables with the same translations. | 340 | * all iommu tables with the same translations. |
341 | */ | 341 | */ |
342 | if (mmu_map_dma_area(dma_addrp, va, res->start, len_total) != 0) | 342 | if (mmu_map_dma_area(dev, dma_addrp, va, res->start, len_total) != 0) |
343 | goto err_noiommu; | 343 | goto err_noiommu; |
344 | 344 | ||
345 | res->name = op->node->name; | 345 | res->name = op->node->name; |
@@ -384,7 +384,7 @@ void sbus_free_consistent(struct device *dev, long n, void *p, u32 ba) | |||
384 | 384 | ||
385 | /* mmu_inval_dma_area(va, n); */ /* it's consistent, isn't it */ | 385 | /* mmu_inval_dma_area(va, n); */ /* it's consistent, isn't it */ |
386 | pgv = virt_to_page(p); | 386 | pgv = virt_to_page(p); |
387 | mmu_unmap_dma_area(ba, n); | 387 | mmu_unmap_dma_area(dev, ba, n); |
388 | 388 | ||
389 | __free_pages(pgv, get_order(n)); | 389 | __free_pages(pgv, get_order(n)); |
390 | } | 390 | } |
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index 6b469820fb92..0f97ab30df3f 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c | |||
@@ -186,12 +186,12 @@ static void iounit_release_scsi_sgl(struct device *dev, struct scatterlist *sg, | |||
186 | } | 186 | } |
187 | 187 | ||
188 | #ifdef CONFIG_SBUS | 188 | #ifdef CONFIG_SBUS |
189 | static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, int len) | 189 | static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va, __u32 addr, int len) |
190 | { | 190 | { |
191 | struct iounit_struct *iounit = dev->archdata.iommu; | ||
191 | unsigned long page, end; | 192 | unsigned long page, end; |
192 | pgprot_t dvma_prot; | 193 | pgprot_t dvma_prot; |
193 | iopte_t *iopte; | 194 | iopte_t *iopte; |
194 | struct sbus_bus *sbus; | ||
195 | 195 | ||
196 | *pba = addr; | 196 | *pba = addr; |
197 | 197 | ||
@@ -213,12 +213,8 @@ static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, in | |||
213 | 213 | ||
214 | i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT); | 214 | i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT); |
215 | 215 | ||
216 | for_each_sbus(sbus) { | 216 | iopte = (iopte_t *)(iounit->page_table + i); |
217 | struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu; | 217 | *iopte = MKIOPTE(__pa(page)); |
218 | |||
219 | iopte = (iopte_t *)(iounit->page_table + i); | ||
220 | *iopte = MKIOPTE(__pa(page)); | ||
221 | } | ||
222 | } | 218 | } |
223 | addr += PAGE_SIZE; | 219 | addr += PAGE_SIZE; |
224 | va += PAGE_SIZE; | 220 | va += PAGE_SIZE; |
@@ -229,7 +225,7 @@ static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, in | |||
229 | return 0; | 225 | return 0; |
230 | } | 226 | } |
231 | 227 | ||
232 | static void iounit_unmap_dma_area(unsigned long addr, int len) | 228 | static void iounit_unmap_dma_area(struct device *dev, unsigned long addr, int len) |
233 | { | 229 | { |
234 | /* XXX Somebody please fill this in */ | 230 | /* XXX Somebody please fill this in */ |
235 | } | 231 | } |
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 832d99f33470..2970cea877b1 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c | |||
@@ -334,11 +334,11 @@ static void iommu_release_scsi_sgl(struct device *dev, struct scatterlist *sg, i | |||
334 | } | 334 | } |
335 | 335 | ||
336 | #ifdef CONFIG_SBUS | 336 | #ifdef CONFIG_SBUS |
337 | static int iommu_map_dma_area(dma_addr_t *pba, unsigned long va, | 337 | static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va, |
338 | unsigned long addr, int len) | 338 | unsigned long addr, int len) |
339 | { | 339 | { |
340 | struct iommu_struct *iommu = dev->archdata.iommu; | ||
340 | unsigned long page, end; | 341 | unsigned long page, end; |
341 | struct iommu_struct *iommu = sbus_root->ofdev.dev.archdata.iommu; | ||
342 | iopte_t *iopte = iommu->page_table; | 342 | iopte_t *iopte = iommu->page_table; |
343 | iopte_t *first; | 343 | iopte_t *first; |
344 | int ioptex; | 344 | int ioptex; |
@@ -401,9 +401,9 @@ static int iommu_map_dma_area(dma_addr_t *pba, unsigned long va, | |||
401 | return 0; | 401 | return 0; |
402 | } | 402 | } |
403 | 403 | ||
404 | static void iommu_unmap_dma_area(unsigned long busa, int len) | 404 | static void iommu_unmap_dma_area(struct device *dev, unsigned long busa, int len) |
405 | { | 405 | { |
406 | struct iommu_struct *iommu = sbus_root->ofdev.dev.archdata.iommu; | 406 | struct iommu_struct *iommu = dev->archdata.iommu; |
407 | iopte_t *iopte = iommu->page_table; | 407 | iopte_t *iopte = iommu->page_table; |
408 | unsigned long end; | 408 | unsigned long end; |
409 | int ioptex = (busa - iommu->start) >> PAGE_SHIFT; | 409 | int ioptex = (busa - iommu->start) >> PAGE_SHIFT; |
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c index 65af3119f5ac..f289e7ce902e 100644 --- a/arch/sparc/mm/sun4c.c +++ b/arch/sparc/mm/sun4c.c | |||
@@ -532,8 +532,8 @@ static inline void sun4c_init_ss2_cache_bug(void) | |||
532 | } | 532 | } |
533 | 533 | ||
534 | /* Addr is always aligned on a page boundary for us already. */ | 534 | /* Addr is always aligned on a page boundary for us already. */ |
535 | static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va, | 535 | static int sun4c_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va, |
536 | unsigned long addr, int len) | 536 | unsigned long addr, int len) |
537 | { | 537 | { |
538 | unsigned long page, end; | 538 | unsigned long page, end; |
539 | 539 | ||
@@ -555,7 +555,7 @@ static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va, | |||
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | static void sun4c_unmap_dma_area(unsigned long busa, int len) | 558 | static void sun4c_unmap_dma_area(struct device *dev, unsigned long busa, int len) |
559 | { | 559 | { |
560 | /* Fortunately for us, bus_addr == uncached_virt in sun4c. */ | 560 | /* Fortunately for us, bus_addr == uncached_virt in sun4c. */ |
561 | /* XXX Implement this */ | 561 | /* XXX Implement this */ |