Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1736013
| From | Wolfram Sang <wsa+renesas@sang-engineering.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH v5 4/6] i2c: sh_mobile: use helper to decide if DMA is useful |
| Date | 2017-09-20 21:10 +0200 |
| Message-ID | <urSxH-79x-9@gated-at.bofh.it> (permalink) |
| References | <urSxH-79x-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This ensures that we fall back to PIO if the message length is too small
for DMA being useful. Otherwise, we use DMA. A bounce buffer might be
applied by the helper if the original message buffer is not DMA safe.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-sh_mobile.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 6f2aaeb7c4fa15..b76399d8a3abd3 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -145,6 +145,7 @@ struct sh_mobile_i2c_data {
struct dma_chan *dma_rx;
struct scatterlist sg;
enum dma_data_direction dma_direction;
+ u8 *dma_buf;
};
struct sh_mobile_dt_config {
@@ -548,6 +549,8 @@ static void sh_mobile_i2c_dma_callback(void *data)
pd->pos = pd->msg->len;
pd->stop_after_dma = true;
+ i2c_release_dma_safe_msg_buf(pd->msg, pd->dma_buf);
+
iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
}
@@ -608,7 +611,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
if (IS_ERR(chan))
return;
- dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir);
+ dma_addr = dma_map_single(chan->device->dev, pd->dma_buf, pd->msg->len, dir);
if (dma_mapping_error(chan->device->dev, dma_addr)) {
dev_dbg(pd->dev, "dma map failed, using PIO\n");
return;
@@ -665,7 +668,8 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
pd->pos = -1;
pd->sr = 0;
- if (pd->msg->len > 8)
+ pd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8);
+ if (pd->dma_buf)
sh_mobile_i2c_xfer_dma(pd);
/* Enable all interrupts to begin with */
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH v5 0/6] i2c: document DMA handling and add helpers for it Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
[RFC PATCH v5 4/6] i2c: sh_mobile: use helper to decide if DMA is useful Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
[RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
Re: [RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling Jonathan Cameron <Jonathan.Cameron@huawei.com> - 2017-09-21 16:10 +0200
Re: [RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling Jonathan Cameron <Jonathan.Cameron@huawei.com> - 2017-09-21 16:10 +0200
Re: [RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling Wolfram Sang <wsa@the-dreams.de> - 2017-09-21 16:20 +0200
Re: [RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling Jonathan Cameron <Jonathan.Cameron@huawei.com> - 2017-09-21 16:40 +0200
[RFC PATCH v5 5/6] i2c: rcar: skip DMA if buffer is not safe Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
[RFC PATCH v5 1/6] i2c: add a message flag for DMA safe buffers Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
[RFC PATCH v5 3/6] i2c: add docs to clarify DMA handling Wolfram Sang <wsa+renesas@sang-engineering.com> - 2017-09-20 21:10 +0200
Re: [RFC PATCH v5 3/6] i2c: add docs to clarify DMA handling Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-09-20 22:00 +0200
Re: [RFC PATCH v5 3/6] i2c: add docs to clarify DMA handling Jonathan Cameron <Jonathan.Cameron@huawei.com> - 2017-09-21 16:10 +0200
csiph-web