2023-10-29 17:01:34

by Martin Povišer

[permalink] [raw]
Subject: [PATCH] dmaengine: apple-admac: Keep upper bits of REG_BUS_WIDTH

From: Hector Martin <[email protected]>

For RX channels, REG_BUS_WIDTH seems to default to a value of 0xf00, and
macOS preserves the upper bits when setting the configuration in the
lower ones. If we reset the upper bits to 0, this causes framing errors
on suspend/resume (the data stream "tears" and channels get swapped
around). Keeping the upper bits untouched, like the macOS driver does,
fixes this issue.

Signed-off-by: Hector Martin <[email protected]>
Reviewed-by: Martin Povišer <[email protected]>
Signed-off-by: Martin Povišer <[email protected]>
---
drivers/dma/apple-admac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 5b63996640d9..9588773dd2eb 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -57,6 +57,8 @@

#define REG_BUS_WIDTH(ch) (0x8040 + (ch) * 0x200)

+#define BUS_WIDTH_WORD_SIZE GENMASK(3, 0)
+#define BUS_WIDTH_FRAME_SIZE GENMASK(7, 4)
#define BUS_WIDTH_8BIT 0x00
#define BUS_WIDTH_16BIT 0x01
#define BUS_WIDTH_32BIT 0x02
@@ -740,7 +742,8 @@ static int admac_device_config(struct dma_chan *chan,
struct admac_data *ad = adchan->host;
bool is_tx = admac_chan_direction(adchan->no) == DMA_MEM_TO_DEV;
int wordsize = 0;
- u32 bus_width = 0;
+ u32 bus_width = readl_relaxed(ad->base + REG_BUS_WIDTH(adchan->no)) &
+ ~(BUS_WIDTH_WORD_SIZE | BUS_WIDTH_FRAME_SIZE);

switch (is_tx ? config->dst_addr_width : config->src_addr_width) {
case DMA_SLAVE_BUSWIDTH_1_BYTE:
--
2.38.3


2023-10-29 17:11:15

by Martin Povišer

[permalink] [raw]
Subject: Re: [PATCH] dmaengine: apple-admac: Keep upper bits of REG_BUS_WIDTH


> On 29. 10. 2023, at 18:00, Martin Povišer <[email protected]> wrote:
>
> From: Hector Martin <[email protected]>
>
> For RX channels, REG_BUS_WIDTH seems to default to a value of 0xf00, and
> macOS preserves the upper bits when setting the configuration in the
> lower ones. If we reset the upper bits to 0, this causes framing errors
> on suspend/resume (the data stream "tears" and channels get swapped
> around). Keeping the upper bits untouched, like the macOS driver does,
> fixes this issue.
>
> Signed-off-by: Hector Martin <[email protected]>
> Reviewed-by: Martin Povišer <[email protected]>
> Signed-off-by: Martin Povišer <[email protected]>
> ---

Please take up v2 instead. I slipped in the wrong email address in here,
which I don’t want to subscribe for kernel spam with.

https://lore.kernel.org/dmaengine/[email protected]/T/#u

Thanks!

Kind regards,
Martin