Re: [PATCH v4 05/13] iio: dac: ad5686: fix overlapping DMA buffers in I2C read
From: Rodrigo Alencar
Date: Wed Apr 29 2026 - 09:20:05 EST
On 26/04/29 02:07PM, Rodrigo Alencar via B4 Relay wrote:
> From: Rodrigo Alencar <rodrigo.alencar@xxxxxxxxxx>
>
> The TX and RX buffers in ad5686_i2c_read() both reference data[0], causing
> byte d8[1] to be shared between the TX buffer and the RX buffer. I2C
> controller drivers that map all message buffers for DMA before initiating
> the hardware transaction will map overlapping memory ranges with
> conflicting DMA directions (DMA_TO_DEVICE and DMA_FROM_DEVICE). This issue
> was reported by sashiko.
Do we need a proper reported-by tag here?
> Fixes: 4177381b4401 ("iio:dac:ad5686: Add AD5671R/75R/94/94R/95R/96/96R support")
> Signed-off-by: Rodrigo Alencar <rdealencar@xxxxxxxxx>
> ---
> drivers/iio/dac/ad5696-i2c.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
> index d3327bca0e07..d3b46496d67d 100644
> --- a/drivers/iio/dac/ad5696-i2c.c
> +++ b/drivers/iio/dac/ad5696-i2c.c
> @@ -26,7 +26,7 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
> .addr = i2c->addr,
> .flags = i2c->flags | I2C_M_RD,
> .len = 2,
> - .buf = (char *)&st->data[0].d16,
> + .buf = (char *)&st->data[1].d16,
> },
> };
> int ret;
> @@ -39,7 +39,7 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
> if (ret < 0)
> return ret;
>
> - return be16_to_cpu(st->data[0].d16);
> + return be16_to_cpu(st->data[1].d16);
> }
>
> static int ad5686_i2c_write(struct ad5686_state *st,
>
> --
> 2.43.0
>
>
--
Kind regards,
Rodrigo Alencar