From da6cf00fd16199c89b99d77a4f2361135b16eaf6 Mon Sep 17 00:00:00 2001 From: "H. Nestler" <81570977+H-Nestler@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:16:07 +0200 Subject: [PATCH 1/3] Fix ATC_DST_PER_MSB for sama5d3 Only the upper nibble of interface identifire (id) should put into CFG bits 15 and 14 (ATC_DST_PER_MSB), because the lower four bits are always in bits 3 to 0 (ATC_DST_PER). Same for ATC_SRC_PER_MSB. Typically effect of this bug are loosing charcters on serial output with DMA enabled, because the flow controller would connect with wrong interface. --- drivers/dma/at_hdmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 5ab54f174e87e8..53cd620e66e070 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -179,9 +179,9 @@ #define ATC_DPIP_HOLE GENMASK(15, 0) #define ATC_DPIP_BOUNDARY GENMASK(25, 16) -#define ATC_SRC_PER_ID(id) (FIELD_PREP(ATC_SRC_PER_MSB, (id)) | \ +#define ATC_SRC_PER_ID(id) (FIELD_PREP(ATC_SRC_PER_MSB, ATC_PER_MSB(id)) | \ FIELD_PREP(ATC_SRC_PER, (id))) -#define ATC_DST_PER_ID(id) (FIELD_PREP(ATC_DST_PER_MSB, (id)) | \ +#define ATC_DST_PER_ID(id) (FIELD_PREP(ATC_DST_PER_MSB, ATC_PER_MSB(id)) | \ FIELD_PREP(ATC_DST_PER, (id))) From 01b2954a54758e2dd723c3da432aff6afc8f7283 Mon Sep 17 00:00:00 2001 From: "H. Nestler" <81570977+H-Nestler@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:25:09 +0200 Subject: [PATCH 2/3] at_hdmac: double setup tx len (sama5d3) atdma_sg->len and desc->sg[i].len are the same pointer to variable "len". Only need once. --- drivers/dma/at_hdmac.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 53cd620e66e070..94e8cda31f96fb 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1306,7 +1306,6 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, atdma_sg->len = len; total_len += len; - desc->sg[i].len = len; atdma_lli_chain(desc, i); } break; From 036bb16eb89543ab77aebe25758713aca6273a70 Mon Sep 17 00:00:00 2001 From: "H. Nestler" <81570977+H-Nestler@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:53:41 +0200 Subject: [PATCH 3/3] at_hdmac: Always use atdma_sg->len for desc->sg[i].len Sometime was used "atdma_sg->len", other cases was used "desc->sg[i].len". Use same coding style for all settings of descriptor length. --- drivers/dma/at_hdmac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 5ab54f174e87e8..69517dedeef3ae 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1008,7 +1008,7 @@ atc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, lli->ctrla = ctrla | xfer_count; lli->ctrlb = ctrlb; - desc->sg[i].len = xfer_count << src_width; + atdma_sg->len = xfer_count << src_width; atdma_lli_chain(desc, i); } @@ -1352,7 +1352,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, len >> reg_width; lli->ctrlb = ctrlb; - desc->sg[i].len = len; + atdma_sg->len = len; total_len += len; atdma_lli_chain(desc, i); @@ -1453,7 +1453,7 @@ atc_dma_cyclic_fill_desc(struct dma_chan *chan, struct at_desc *desc, FIELD_PREP(ATC_DST_WIDTH, reg_width) | FIELD_PREP(ATC_SRC_WIDTH, reg_width) | period_len >> reg_width; - desc->sg[i].len = period_len; + atdma_sg->len = period_len; return 0; }