Skip to content

Commit d36678f

Browse files
lunnwsakernel
authored andcommitted
i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
Recent changes to the DMA code has resulting in the IMX driver failing I2C transfers when the buffer has been vmalloc. Only perform DMA transfers if the message has the I2C_M_DMA_SAFE flag set, indicating the client is providing a buffer which is DMA safe. This is a minimal fix for stable. The I2C core provides helpers to allocate a bounce buffer. For a fuller fix the master should make use of these helpers. Fixes: 4544b9f ("dma-mapping: Add vmap checks to dma_map_single()") Signed-off-by: Andrew Lunn <[email protected]> Acked-by: Oleksij Rempel <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 7d8ccf4 commit d36678f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,8 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs,
11321132
int i, result;
11331133
unsigned int temp;
11341134
int block_data = msgs->flags & I2C_M_RECV_LEN;
1135-
int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data;
1135+
int use_dma = i2c_imx->dma && msgs->flags & I2C_M_DMA_SAFE &&
1136+
msgs->len >= DMA_THRESHOLD && !block_data;
11361137

11371138
dev_dbg(&i2c_imx->adapter.dev,
11381139
"<%s> write slave address: addr=0x%x\n",
@@ -1298,7 +1299,8 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
12981299
result = i2c_imx_read(i2c_imx, &msgs[i], is_lastmsg, atomic);
12991300
} else {
13001301
if (!atomic &&
1301-
i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD)
1302+
i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD &&
1303+
msgs[i].flags & I2C_M_DMA_SAFE)
13021304
result = i2c_imx_dma_write(i2c_imx, &msgs[i]);
13031305
else
13041306
result = i2c_imx_write(i2c_imx, &msgs[i], atomic);

0 commit comments

Comments
 (0)