Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ARM] Remove '__address' from scatterlist and convert to DMA API

The old __address element in struct scatterlist remained from older
kernels because the ARM DMA emulation code made use of it. Move
this field into struct dma_struct, and convert DMA emulation code
to setup a SG entry as required.

Also, convert DMA emulation code to use the new DMA API rather
than the PCI DMA API.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Russell King and committed by
Russell King
7cdad482 333c9624

+31 -28
+13 -9
arch/arm/kernel/dma-isa.c
··· 18 18 */ 19 19 #include <linux/ioport.h> 20 20 #include <linux/init.h> 21 - #include <linux/pci.h> 21 + #include <linux/dma-mapping.h> 22 22 23 23 #include <asm/dma.h> 24 24 #include <asm/io.h> ··· 65 65 { 66 66 if (dma->invalid) { 67 67 unsigned long address, length; 68 - unsigned int mode, direction; 68 + unsigned int mode; 69 + enum dma_data_direction direction; 69 70 70 71 mode = channel & 3; 71 72 switch (dma->dma_mode & DMA_MODE_MASK) { 72 73 case DMA_MODE_READ: 73 74 mode |= ISA_DMA_MODE_READ; 74 - direction = PCI_DMA_FROMDEVICE; 75 + direction = DMA_FROM_DEVICE; 75 76 break; 76 77 77 78 case DMA_MODE_WRITE: 78 79 mode |= ISA_DMA_MODE_WRITE; 79 - direction = PCI_DMA_TODEVICE; 80 + direction = DMA_TO_DEVICE; 80 81 break; 81 82 82 83 case DMA_MODE_CASCADE: 83 84 mode |= ISA_DMA_MODE_CASCADE; 84 - direction = PCI_DMA_BIDIRECTIONAL; 85 + direction = DMA_BIDIRECTIONAL; 85 86 break; 86 87 87 88 default: 88 - direction = PCI_DMA_NONE; 89 + direction = DMA_NONE; 89 90 break; 90 91 } 91 92 92 - if (!dma->using_sg) { 93 + if (!dma->sg) { 93 94 /* 94 95 * Cope with ISA-style drivers which expect cache 95 96 * coherence. 96 97 */ 97 - dma->buf.dma_address = pci_map_single(NULL, 98 - dma->buf.__address, dma->buf.length, 98 + dma->sg = &dma->buf; 99 + dma->sgcount = 1; 100 + dma->buf.length = dma->count; 101 + dma->buf.dma_address = dma_map_single(NULL, 102 + dma->addr, dma->count, 99 103 direction); 100 104 } 101 105
+4 -9
arch/arm/kernel/dma.c
··· 123 123 124 124 dma->sg = sg; 125 125 dma->sgcount = nr_sg; 126 - dma->using_sg = 1; 127 126 dma->invalid = 1; 128 127 } 129 128 ··· 138 139 printk(KERN_ERR "dma%d: altering DMA address while " 139 140 "DMA active\n", channel); 140 141 141 - dma->sg = &dma->buf; 142 - dma->sgcount = 1; 143 - dma->buf.__address = addr; 144 - dma->using_sg = 0; 142 + dma->sg = NULL; 143 + dma->addr = addr; 145 144 dma->invalid = 1; 146 145 } 147 146 ··· 155 158 printk(KERN_ERR "dma%d: altering DMA count while " 156 159 "DMA active\n", channel); 157 160 158 - dma->sg = &dma->buf; 159 - dma->sgcount = 1; 160 - dma->buf.length = count; 161 - dma->using_sg = 0; 161 + dma->sg = NULL; 162 + dma->count = count; 162 163 dma->invalid = 1; 163 164 } 164 165
+11 -8
arch/arm/mach-rpc/dma.c
··· 13 13 #include <linux/mman.h> 14 14 #include <linux/init.h> 15 15 #include <linux/interrupt.h> 16 - #include <linux/pci.h> 16 + #include <linux/dma-mapping.h> 17 17 18 18 #include <asm/page.h> 19 19 #include <asm/dma.h> ··· 148 148 * Cope with ISA-style drivers which expect cache 149 149 * coherence. 150 150 */ 151 - if (!dma->using_sg) { 152 - dma->buf.dma_address = pci_map_single(NULL, 153 - dma->buf.__address, dma->buf.length, 151 + if (!dma->sg) { 152 + dma->sg = &dma->buf; 153 + dma->sgcount = 1; 154 + dma->buf.length = dma->count; 155 + dma->buf.dma_address = dma_map_single(NULL, 156 + dma->addr, dma->count, 154 157 dma->dma_mode == DMA_MODE_READ ? 155 - PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 158 + DMA_FROM_DEVICE : DMA_TO_DEVICE); 156 159 } 157 160 158 161 iomd_writeb(DMA_CR_C, dma_base + CR); ··· 242 239 unsigned int fiqhandler_length; 243 240 struct pt_regs regs; 244 241 245 - if (dma->using_sg) 242 + if (dma->sg) 246 243 BUG(); 247 244 248 245 if (dma->dma_mode == DMA_MODE_READ) { ··· 255 252 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start; 256 253 } 257 254 258 - regs.ARM_r9 = dma->buf.length; 259 - regs.ARM_r10 = (unsigned long)dma->buf.__address; 255 + regs.ARM_r9 = dma->count; 256 + regs.ARM_r10 = (unsigned long)dma->addr; 260 257 regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE; 261 258 262 259 if (claim_fiq(&fh)) {
+3 -1
include/asm-arm/mach/dma.h
··· 25 25 }; 26 26 27 27 struct dma_struct { 28 + void *addr; /* single DMA address */ 29 + unsigned long count; /* single DMA size */ 28 30 struct scatterlist buf; /* single DMA */ 29 31 int sgcount; /* number of DMA SG */ 30 32 struct scatterlist *sg; /* DMA Scatter-Gather List */ 31 33 32 34 unsigned int active:1; /* Transfer active */ 33 35 unsigned int invalid:1; /* Address/Count changed */ 34 - unsigned int using_sg:1; /* using scatter list? */ 36 + 35 37 dmamode_t dma_mode; /* DMA mode */ 36 38 int speed; /* DMA speed */ 37 39
-1
include/asm-arm/scatterlist.h
··· 9 9 unsigned int offset; /* buffer offset */ 10 10 dma_addr_t dma_address; /* dma address */ 11 11 unsigned int length; /* length */ 12 - char *__address; /* for set_dma_addr */ 13 12 }; 14 13 15 14 /*