|
52 | 52 | #include <asm/io-unit.h>
|
53 | 53 | #include <asm/leon.h>
|
54 | 54 |
|
55 |
| -/* This function must make sure that caches and memory are coherent after DMA |
56 |
| - * On LEON systems without cache snooping it flushes the entire D-CACHE. |
57 |
| - */ |
58 |
| -static inline void dma_make_coherent(unsigned long pa, unsigned long len) |
59 |
| -{ |
60 |
| - if (sparc_cpu_model == sparc_leon) { |
61 |
| - if (!sparc_leon3_snooping_enabled()) |
62 |
| - leon_flush_dcache_all(); |
63 |
| - } |
64 |
| -} |
65 |
| - |
66 | 55 | static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
|
67 | 56 | static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
|
68 | 57 | unsigned long size, char *name);
|
@@ -311,68 +300,19 @@ arch_initcall(sparc_register_ioport);
|
311 | 300 |
|
312 | 301 | #endif /* CONFIG_SBUS */
|
313 | 302 |
|
314 |
| - |
315 |
| -/* Allocate and map kernel buffer using consistent mode DMA for a device. |
316 |
| - * hwdev should be valid struct pci_dev pointer for PCI devices. |
317 |
| - */ |
318 |
| -void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, |
319 |
| - gfp_t gfp, unsigned long attrs) |
320 |
| -{ |
321 |
| - unsigned long addr; |
322 |
| - void *va; |
323 |
| - |
324 |
| - if (!size || size > 256 * 1024) /* __get_free_pages() limit */ |
325 |
| - return NULL; |
326 |
| - |
327 |
| - size = PAGE_ALIGN(size); |
328 |
| - va = (void *) __get_free_pages(gfp | __GFP_ZERO, get_order(size)); |
329 |
| - if (!va) { |
330 |
| - printk("%s: no %zd pages\n", __func__, size >> PAGE_SHIFT); |
331 |
| - return NULL; |
332 |
| - } |
333 |
| - |
334 |
| - addr = sparc_dma_alloc_resource(dev, size); |
335 |
| - if (!addr) |
336 |
| - goto err_nomem; |
337 |
| - |
338 |
| - srmmu_mapiorange(0, virt_to_phys(va), addr, size); |
339 |
| - |
340 |
| - *dma_handle = virt_to_phys(va); |
341 |
| - return (void *)addr; |
342 |
| - |
343 |
| -err_nomem: |
344 |
| - free_pages((unsigned long)va, get_order(size)); |
345 |
| - return NULL; |
346 |
| -} |
347 |
| - |
348 |
| -/* Free and unmap a consistent DMA buffer. |
349 |
| - * cpu_addr is what was returned arch_dma_alloc, size must be the same as what |
350 |
| - * was passed into arch_dma_alloc, and likewise dma_addr must be the same as |
351 |
| - * what *dma_ndler was set to. |
| 303 | +/* |
| 304 | + * IIep is write-through, not flushing on cpu to device transfer. |
352 | 305 | *
|
353 |
| - * References to the memory and mappings associated with cpu_addr/dma_addr |
354 |
| - * past this call are illegal. |
| 306 | + * On LEON systems without cache snooping, the entire D-CACHE must be flushed to |
| 307 | + * make DMA to cacheable memory coherent. |
355 | 308 | */
|
356 |
| -void arch_dma_free(struct device *dev, size_t size, void *cpu_addr, |
357 |
| - dma_addr_t dma_addr, unsigned long attrs) |
358 |
| -{ |
359 |
| - size = PAGE_ALIGN(size); |
360 |
| - |
361 |
| - if (!sparc_dma_free_resource(cpu_addr, size)) |
362 |
| - return; |
363 |
| - |
364 |
| - dma_make_coherent(dma_addr, size); |
365 |
| - srmmu_unmapiorange((unsigned long)cpu_addr, size); |
366 |
| - free_pages((unsigned long)phys_to_virt(dma_addr), get_order(size)); |
367 |
| -} |
368 |
| - |
369 |
| -/* IIep is write-through, not flushing on cpu to device transfer. */ |
370 |
| - |
371 | 309 | void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
|
372 | 310 | enum dma_data_direction dir)
|
373 | 311 | {
|
374 |
| - if (dir != PCI_DMA_TODEVICE) |
375 |
| - dma_make_coherent(paddr, PAGE_ALIGN(size)); |
| 312 | + if (dir != PCI_DMA_TODEVICE && |
| 313 | + sparc_cpu_model == sparc_leon && |
| 314 | + !sparc_leon3_snooping_enabled()) |
| 315 | + leon_flush_dcache_all(); |
376 | 316 | }
|
377 | 317 |
|
378 | 318 | #ifdef CONFIG_PROC_FS
|
|
0 commit comments