All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	Nandor Han <nandor.han@ge.com>
Cc: dan.j.williams@intel.com, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] dmaengine: imx-sdma: Report a DMA_ERROR in status if 'count' or 'dma_address' do not mat
Date: Thu, 12 Oct 2017 16:59:47 +0000	[thread overview]
Message-ID: <20171012170322.GV30097@localhost> (raw)
In-Reply-To: <20170924062641.30187-1-christophe.jaillet@wanadoo.fr>

On Sun, Sep 24, 2017 at 08:26:41AM +0200, Christophe JAILLET wrote:
> All sanity checks in this function set 'sdmac->status = DMA_ERROR' if
> something looks wrong, except if the byte count or the address don't match
> the bus width.
> 
> Fix it and report the error in status in such a case.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Untested, so please review carefuly.
> ---
>  drivers/dma/imx-sdma.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index a67ec1bdc4e0..f0419967eb92 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -1240,26 +1240,31 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
>  		sdmac->chn_count += count;
>  
>  		if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) {
> -			ret =  -EINVAL;
> +			ret = -EINVAL;

this is a style fix and should not be part of this patch

>  			goto err_out;
>  		}
>  
>  		switch (sdmac->word_size) {
>  		case DMA_SLAVE_BUSWIDTH_4_BYTES:
>  			bd->mode.command = 0;
> -			if (count & 3 || sg->dma_address & 3)
> -				return NULL;
> +			if (count & 3 || sg->dma_address & 3) {
> +				ret = -EINVAL;
> +				goto err_out;
> +			}

this looks okay, but then slave configuration comes from different path, so
not sure if not setting was intentional or a miss. Fabio, Nandor??

>  			break;
>  		case DMA_SLAVE_BUSWIDTH_2_BYTES:
>  			bd->mode.command = 2;
> -			if (count & 1 || sg->dma_address & 1)
> -				return NULL;
> +			if (count & 1 || sg->dma_address & 1) {
> +				ret = -EINVAL;
> +				goto err_out;
> +			}
>  			break;
>  		case DMA_SLAVE_BUSWIDTH_1_BYTE:
>  			bd->mode.command = 1;
>  			break;
>  		default:
> -			return NULL;
> +			ret = -EINVAL;
> +			goto err_out;
>  		}
>  
>  		param = BD_DONE | BD_EXTD | BD_CONT;
> -- 
> 2.11.0
> 

-- 
~Vinod

WARNING: multiple messages have this Message-ID (diff)
From: Vinod Koul <vinod.koul@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	Nandor Han <nandor.han@ge.com>
Cc: dan.j.williams@intel.com, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] dmaengine: imx-sdma: Report a DMA_ERROR in status if 'count' or 'dma_address' do not match DMA_SLAVE_BUSWIDTH
Date: Thu, 12 Oct 2017 22:33:22 +0530	[thread overview]
Message-ID: <20171012170322.GV30097@localhost> (raw)
In-Reply-To: <20170924062641.30187-1-christophe.jaillet@wanadoo.fr>

On Sun, Sep 24, 2017 at 08:26:41AM +0200, Christophe JAILLET wrote:
> All sanity checks in this function set 'sdmac->status = DMA_ERROR' if
> something looks wrong, except if the byte count or the address don't match
> the bus width.
> 
> Fix it and report the error in status in such a case.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Untested, so please review carefuly.
> ---
>  drivers/dma/imx-sdma.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index a67ec1bdc4e0..f0419967eb92 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -1240,26 +1240,31 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
>  		sdmac->chn_count += count;
>  
>  		if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) {
> -			ret =  -EINVAL;
> +			ret = -EINVAL;

this is a style fix and should not be part of this patch

>  			goto err_out;
>  		}
>  
>  		switch (sdmac->word_size) {
>  		case DMA_SLAVE_BUSWIDTH_4_BYTES:
>  			bd->mode.command = 0;
> -			if (count & 3 || sg->dma_address & 3)
> -				return NULL;
> +			if (count & 3 || sg->dma_address & 3) {
> +				ret = -EINVAL;
> +				goto err_out;
> +			}

this looks okay, but then slave configuration comes from different path, so
not sure if not setting was intentional or a miss. Fabio, Nandor??

>  			break;
>  		case DMA_SLAVE_BUSWIDTH_2_BYTES:
>  			bd->mode.command = 2;
> -			if (count & 1 || sg->dma_address & 1)
> -				return NULL;
> +			if (count & 1 || sg->dma_address & 1) {
> +				ret = -EINVAL;
> +				goto err_out;
> +			}
>  			break;
>  		case DMA_SLAVE_BUSWIDTH_1_BYTE:
>  			bd->mode.command = 1;
>  			break;
>  		default:
> -			return NULL;
> +			ret = -EINVAL;
> +			goto err_out;
>  		}
>  
>  		param = BD_DONE | BD_EXTD | BD_CONT;
> -- 
> 2.11.0
> 

-- 
~Vinod

  reply	other threads:[~2017-10-12 16:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24  6:26 [PATCH] dmaengine: imx-sdma: Report a DMA_ERROR in status if 'count' or 'dma_address' do not match D Christophe JAILLET
2017-09-24  6:26 ` [PATCH] dmaengine: imx-sdma: Report a DMA_ERROR in status if 'count' or 'dma_address' do not match DMA_SLAVE_BUSWIDTH Christophe JAILLET
2017-10-12 16:59 ` Vinod Koul [this message]
2017-10-12 17:03   ` Vinod Koul

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=20171012170322.GV30097@localhost \
    --to=vinod.koul@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nandor.han@ge.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.