Skip to content

Commit fa4e998

Browse files
Russell KingRussell King
authored andcommitted
[ARM] dma: RiscPC: don't modify DMA SG entries
We should not be modifying the scatterlist passed to us from the driver code; doing so breaks assumptions made by the DMA API code, and could cause problems if the driver retries a transfer using an old scatterlist. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 308d333 commit fa4e998

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎arch/arm/mach-rpc/dma.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct iomd_dma {
3232
unsigned long base; /* Controller base address */
3333
int irq; /* Controller IRQ */
3434
struct scatterlist cur_sg; /* Current controller buffer */
35+
dma_addr_t dma_addr;
36+
unsigned int dma_len;
3537
};
3638

3739
#if 0
@@ -57,10 +59,10 @@ static void iomd_get_next_sg(struct scatterlist *sg, struct iomd_dma *idma)
5759
unsigned long end, offset, flags = 0;
5860

5961
if (idma->dma.sg) {
60-
sg->dma_address = idma->dma.sg->dma_address;
62+
sg->dma_address = idma->dma_addr;
6163
offset = sg->dma_address & ~PAGE_MASK;
6264

63-
end = offset + idma->dma.sg->length;
65+
end = offset + idma->dma_len;
6466

6567
if (end > PAGE_SIZE)
6668
end = PAGE_SIZE;
@@ -70,12 +72,14 @@ static void iomd_get_next_sg(struct scatterlist *sg, struct iomd_dma *idma)
7072

7173
sg->length = end - TRANSFER_SIZE;
7274

73-
idma->dma.sg->length -= end - offset;
74-
idma->dma.sg->dma_address += end - offset;
75+
idma->dma_len -= end - offset;
76+
idma->dma_addr += end - offset;
7577

76-
if (idma->dma.sg->length == 0) {
78+
if (idma->dma_len == 0) {
7779
if (idma->dma.sgcount > 1) {
7880
idma->dma.sg = sg_next(idma->dma.sg);
81+
idma->dma_addr = idma->dma.sg->dma_address;
82+
idma->dma_len = idma->dma.sg->length;
7983
idma->dma.sgcount--;
8084
} else {
8185
idma->dma.sg = NULL;

0 commit comments

Comments
 (0)