linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: alsa-devel@alsa-project.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-i2c@vger.kernel.org, linux-input@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v3 3/4] i2c: sh_mobile: use helper to decide if DMA is useful
Date: Wed, 19 Jul 2017 11:35:45 +0200	[thread overview]
Message-ID: <20170719093544.GN28538@bigcity.dyn.berto.se> (raw)
In-Reply-To: <20170718102339.28726-4-wsa+renesas@sang-engineering.com>

Hi Wolfram,

On 2017-07-18 12:23:38 +0200, Wolfram Sang wrote:
> This ensures that we fall back to PIO if the buffer is too small for DMA
> being useful. Otherwise, we use DMA. A bounce buffer might be applied 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 2e097d97d258bc..19f45bcd9b35ca 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 *bounce_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_bounce_buf(pd->msg, pd->bounce_buf);
> +
>  	iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
>  }
>  
> @@ -595,6 +598,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
>  	struct dma_async_tx_descriptor *txdesc;
>  	dma_addr_t dma_addr;
>  	dma_cookie_t cookie;
> +	u8 *dma_buf = pd->bounce_buf ?: pd->msg->buf;

This looked funny and I had to look it up, I learnt something new today 
:-)

>  
>  	if (PTR_ERR(chan) == -EPROBE_DEFER) {
>  		if (read)
> @@ -608,7 +612,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, 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 +669,7 @@ 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)
> +	if (i2c_check_msg_for_dma(pd->msg, 8, &pd->bounce_buf) == 0)

Maybe the 8 should be declared in a define to explain the value, like 
you do in patch 4/4?

This nitpick aside:

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

>  		sh_mobile_i2c_xfer_dma(pd);
>  
>  	/* Enable all interrupts to begin with */
> -- 
> 2.11.0
> 

-- 
Regards,
Niklas Söderlund

  reply	other threads:[~2017-07-19  9:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 10:23 [PATCH v3 0/4] i2c: document DMA handling and add helpers for it Wolfram Sang
     [not found] ` <20170718102339.28726-1-wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org>
2017-07-18 10:23   ` [PATCH v3 1/4] i2c: add helpers to ease DMA handling Wolfram Sang
2017-07-19  9:28     ` Niklas Söderlund
2017-07-23 11:22     ` Jonathan Cameron
     [not found]       ` <20170723122242.7fd0edf4-tko9wxEg+fIOOJlXag/Snyp2UmYkHbXO@public.gmane.org>
2017-08-16 20:58         ` Wolfram Sang
2017-08-16 14:51     ` Geert Uytterhoeven
2017-08-16 16:06       ` Wolfram Sang
2017-07-18 10:23 ` [PATCH v3 2/4] i2c: add docs to clarify " Wolfram Sang
2017-07-19  9:28   ` Niklas Söderlund
     [not found]   ` <20170718102339.28726-3-wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org>
2017-07-23 11:26     ` Jonathan Cameron
2017-07-18 10:23 ` [PATCH v3 3/4] i2c: sh_mobile: use helper to decide if DMA is useful Wolfram Sang
2017-07-19  9:35   ` Niklas Söderlund [this message]
2017-07-18 10:23 ` [PATCH v3 4/4] i2c: rcar: check for DMA-capable buffers Wolfram Sang
2017-07-19  9:42   ` Niklas Söderlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170719093544.GN28538@bigcity.dyn.berto.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).