Skip to contentSkip to conversation

bcm2835_dma: Fix the ylen loop in TD mode

PATCH Applied Rene Stange 2 participants 2 messages Feb 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 bcm2835_dma: Fix the ylen loop in TD mode

In TD (two dimensions) DMA mode ylen has to be increased by one after reading it from the TXFR_LEN register, because a value of zero has to result in one run through of the ylen loop. This has been tested on a real Raspberry Pi 3 Model B+. In the previous implementation the ylen loop was not passed at all for a value of zero.

---
 hw/dma/bcm2835_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/dma/bcm2835_dma.c +2 -2
index 1e458d7fba..667d951a6f 100644
@@ -70,14 +70,14 @@ static void bcm2835_dma_update(BCM2835DMAState *s, unsigned c)
         ch->stride = ldl_le_phys(&s->dma_as, ch->conblk_ad + 16);
         ch->nextconbk = ldl_le_phys(&s->dma_as, ch->conblk_ad + 20);
 
+        ylen = 1;
         if (ch->ti & BCM2708_DMA_TDMODE) {
             /* 2D transfer mode */
-            ylen = (ch->txfr_len >> 16) & 0x3fff;
+            ylen += (ch->txfr_len >> 16) & 0x3fff;
             xlen = ch->txfr_len & 0xffff;
             dst_stride = ch->stride >> 16;
             src_stride = ch->stride & 0xffff;
         } else {
-            ylen = 1;
             xlen = ch->txfr_len;
             dst_stride = 0;
             src_stride = 0;
Signature · 1 line
2.16.4
Reviewed-by on v2 1/2
#1 lore raw
Quoted 23 lines · Rene Stange

In TD (two dimensions) DMA mode ylen has to be increased by one after reading it from the TXFR_LEN register, because a value of zero has to result in one run through of the ylen loop. This has been tested on a real Raspberry Pi 3 Model B+. In the previous implementation the ylen loop was not passed at all for a value of zero.

---
  hw/dma/bcm2835_dma.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/dma/bcm2835_dma.c +1 -0
index 1e458d7fba..667d951a6f 100644
@@ -70,14 +70,14 @@ static void bcm2835_dma_update(BCM2835DMAState *s, unsigned c)
          ch->stride = ldl_le_phys(&s->dma_as, ch->conblk_ad + 16);
          ch->nextconbk = ldl_le_phys(&s->dma_as, ch->conblk_ad + 20);
 
+        ylen = 1;
          if (ch->ti & BCM2708_DMA_TDMODE) {
              /* 2D transfer mode */

hw/dma/bcm2835_dma.c static void bcm2835_dma_update(BCM2835DMAState *s, unsigned c) · line 83

Quoted 10 lines
hw/dma/bcm2835_dma.c +1 -2
-            ylen = (ch->txfr_len >> 16) & 0x3fff;
+            ylen += (ch->txfr_len >> 16) & 0x3fff;
              xlen = ch->txfr_len & 0xffff;
              dst_stride = ch->stride >> 16;
              src_stride = ch->stride & 0xffff;
          } else {
-            ylen = 1;
              xlen = ch->txfr_len;
              dst_stride = 0;
              src_stride = 0;