Skip to content

Commit 8893790

Browse files
edgariglpm215
authored andcommitted
dma/xlnx-zdma: Reorg to fix CUR_DSCR
Reorganize the descriptor handling so that CUR_DSCR always points to the next descriptor to be processed. Signed-off-by: Edgar E. Iglesias <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Francisco Iglesias <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent 4ec037f commit 8893790

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

hw/dma/xlnx-zdma.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,28 @@ static void zdma_load_src_descriptor(XlnxZDMA *s)
333333
}
334334
}
335335

336+
static void zdma_update_descr_addr(XlnxZDMA *s, bool type,
337+
unsigned int basereg)
338+
{
339+
uint64_t addr, next;
340+
341+
if (type == DTYPE_LINEAR) {
342+
addr = zdma_get_regaddr64(s, basereg);
343+
next = addr + sizeof(s->dsc_dst);
344+
} else {
345+
addr = zdma_get_regaddr64(s, basereg);
346+
addr += sizeof(s->dsc_dst);
347+
address_space_read(s->dma_as, addr, s->attr, (void *) &next, 8);
348+
}
349+
350+
zdma_put_regaddr64(s, basereg, next);
351+
}
352+
336353
static void zdma_load_dst_descriptor(XlnxZDMA *s)
337354
{
338355
uint64_t dst_addr;
339356
unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, POINT_TYPE);
357+
bool dst_type;
340358

341359
if (ptype == PT_REG) {
342360
memcpy(&s->dsc_dst, &s->regs[R_ZDMA_CH_DST_DSCR_WORD0],
@@ -349,24 +367,10 @@ static void zdma_load_dst_descriptor(XlnxZDMA *s)
349367
if (!zdma_load_descriptor(s, dst_addr, &s->dsc_dst)) {
350368
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, AXI_RD_DST_DSCR, true);
351369
}
352-
}
353-
354-
static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,
355-
unsigned int basereg)
356-
{
357-
uint64_t addr, next;
358370

359-
if (type == DTYPE_LINEAR) {
360-
next = zdma_get_regaddr64(s, basereg);
361-
next += sizeof(s->dsc_dst);
362-
zdma_put_regaddr64(s, basereg, next);
363-
} else {
364-
addr = zdma_get_regaddr64(s, basereg);
365-
addr += sizeof(s->dsc_dst);
366-
address_space_read(s->dma_as, addr, s->attr, &next, 8);
367-
zdma_put_regaddr64(s, basereg, next);
368-
}
369-
return next;
371+
/* Advance the descriptor pointer. */
372+
dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3, TYPE);
373+
zdma_update_descr_addr(s, dst_type, R_ZDMA_CH_DST_CUR_DSCR_LSB);
370374
}
371375

372376
static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
@@ -387,14 +391,7 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
387391
dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
388392
SIZE);
389393
if (dst_size == 0 && ptype == PT_MEM) {
390-
uint64_t next;
391-
bool dst_type = FIELD_EX32(s->dsc_dst.words[3],
392-
ZDMA_CH_DST_DSCR_WORD3,
393-
TYPE);
394-
395-
next = zdma_update_descr_addr(s, dst_type,
396-
R_ZDMA_CH_DST_CUR_DSCR_LSB);
397-
zdma_load_descriptor(s, next, &s->dsc_dst);
394+
zdma_load_dst_descriptor(s);
398395
dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
399396
SIZE);
400397
}

0 commit comments

Comments
 (0)