Skip to content

Commit

Permalink
i2c: qcom-geni: Fix GPI DMA buffer sync-back
Browse files Browse the repository at this point in the history
commit 8689b80 upstream.

Fix i2c transfers using GPI DMA mode for all message types that do not set
the I2C_M_DMA_SAFE flag (e.g. SMBus "read byte").

In this case a bounce buffer is returned by i2c_get_dma_safe_msg_buf(),
and it has to synced back to the message after the transfer is done.

Add missing assignment of dma buffer in geni_i2c_gpi().

Set xferred in i2c_put_dma_safe_msg_buf() to true in case of no error to
ensure the sync-back of this dma buffer to the message.

Fixes: d870355 ("i2c: qcom-geni: Add support for GPI DMA")
Signed-off-by: Robin Reckmann <robin.reckmann@gmail.com>
Tested-by: Luca Weiss <luca.weiss@fairphone.com>
Tested-by: Caleb Connolly <caleb@connolly.tech>
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
robin-reckmann authored and gregkh committed Aug 25, 2022
1 parent 7dfea65 commit 8f89e5c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/i2c/busses/i2c-qcom-geni.c
Expand Up @@ -484,12 +484,12 @@ static void geni_i2c_gpi_unmap(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
{
if (tx_buf) {
dma_unmap_single(gi2c->se.dev->parent, tx_addr, msg->len, DMA_TO_DEVICE);
i2c_put_dma_safe_msg_buf(tx_buf, msg, false);
i2c_put_dma_safe_msg_buf(tx_buf, msg, !gi2c->err);
}

if (rx_buf) {
dma_unmap_single(gi2c->se.dev->parent, rx_addr, msg->len, DMA_FROM_DEVICE);
i2c_put_dma_safe_msg_buf(rx_buf, msg, false);
i2c_put_dma_safe_msg_buf(rx_buf, msg, !gi2c->err);
}
}

Expand Down Expand Up @@ -553,6 +553,7 @@ static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
desc->callback_param = gi2c;

dmaengine_submit(desc);
*buf = dma_buf;
*dma_addr_p = addr;

return 0;
Expand Down

0 comments on commit 8f89e5c

Please sign in to comment.