mn10300: make the ASB2305's PCnet32 NIC work by using the PCI bridge's SRAM

Access to the ASB2305's PCnet32 NIC doesn't work correctly because when
the NIC attempts to update the ring buffer flags by DMA, the change to RAM
crops up about 17uS after the interrupt line is asserted. This is almost
certainly due to a bug in the PCI bridge FPGA on that board.

We can get around this by making dma_alloc_coherent() put the ring buffer
in the SRAM attached to the PCI bridge rather than in the SDRAM.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by David Howells and committed by Linus Torvalds 012c79ba 112b4a0b

+17
+17
arch/mn10300/mm/dma-alloc.c
··· 16 #include <linux/pci.h> 17 #include <asm/io.h> 18 19 void *dma_alloc_coherent(struct device *dev, size_t size, 20 dma_addr_t *dma_handle, int gfp) 21 { 22 unsigned long addr; 23 void *ret; 24 25 /* ignore region specifiers */ 26 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); ··· 53 /* write back and evict all cache lines covering this region */ 54 mn10300_dcache_flush_inv_range2(virt_to_phys((void *) addr), PAGE_SIZE); 55 56 *dma_handle = virt_to_bus((void *) addr); 57 return ret; 58 } 59 EXPORT_SYMBOL(dma_alloc_coherent); ··· 64 dma_addr_t dma_handle) 65 { 66 unsigned long addr = (unsigned long) vaddr & ~0x20000000; 67 68 free_pages(addr, get_order(size)); 69 }
··· 16 #include <linux/pci.h> 17 #include <asm/io.h> 18 19 + static unsigned long pci_sram_allocated = 0xbc000000; 20 + 21 void *dma_alloc_coherent(struct device *dev, size_t size, 22 dma_addr_t *dma_handle, int gfp) 23 { 24 unsigned long addr; 25 void *ret; 26 + 27 + printk("dma_alloc_coherent(%s,%zu,,%x)\n", dev_name(dev), size, gfp); 28 + 29 + if (0xbe000000 - pci_sram_allocated >= size) { 30 + size = (size + 255) & ~255; 31 + addr = pci_sram_allocated; 32 + pci_sram_allocated += size; 33 + ret = (void *) addr; 34 + goto done; 35 + } 36 37 /* ignore region specifiers */ 38 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); ··· 41 /* write back and evict all cache lines covering this region */ 42 mn10300_dcache_flush_inv_range2(virt_to_phys((void *) addr), PAGE_SIZE); 43 44 + done: 45 *dma_handle = virt_to_bus((void *) addr); 46 + printk("dma_alloc_coherent() = %p [%x]\n", ret, *dma_handle); 47 return ret; 48 } 49 EXPORT_SYMBOL(dma_alloc_coherent); ··· 50 dma_addr_t dma_handle) 51 { 52 unsigned long addr = (unsigned long) vaddr & ~0x20000000; 53 + 54 + if (addr >= 0x9c000000) 55 + return; 56 57 free_pages(addr, get_order(size)); 58 }