All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
To: Juha Lumme <juha.lumme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Fabio Estevam
	<fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA
Date: Wed, 26 Dec 2012 06:06:26 +0100	[thread overview]
Message-ID: <201212260606.26770.marex@denx.de> (raw)
In-Reply-To: <1356498088-31176-1-git-send-email-juha.lumme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Dear Juha Lumme,

> On MX23 the XFER_LEN

XFER_COUNT ;-)

> part in CTRL0 register was improperly OR'd

... during construction of DMA descriptor chain. Instead of being freshly set.

> , and
> because of that too many characters

Bytes

> were being expected from SPI.

expected from SPI during the last DMA cycle.

> This caused a timeout (SSP_TIMEOUT) to happen in the last package

... during the processing of the last DMA descriptor ...

> in the
> DMA chain, and resulted into a corrupted read.

Write too, really ;-)

> This is a workaround for the problem

This is actually a correct fix for the issue.

> , by clearing the XFER_LEN bytes always
> before reading the new size for XFER_LEN.

before setting new XFER_COUNT into the ctrl0 field of DMA control transfer.

> Cc: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
> Cc: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Cc: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
> Signed-off-by: Juha Lumme <juha.lumme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

All but the commit message,

Acked-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>

> ---
>  drivers/spi/spi-mxs.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
> index 86dd04d..265c33f 100644
> --- a/drivers/spi/spi-mxs.c
> +++ b/drivers/spi/spi-mxs.c
> @@ -241,6 +241,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int
> cs, INIT_COMPLETION(spi->c);
> 
>  	ctrl0 = readl(ssp->base + HW_SSP_CTRL0);
> +	ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
>  	ctrl0 |= BM_SSP_CTRL0_DATA_XFER | mxs_spi_cs_to_reg(cs);
> 
>  	if (*first)
> @@ -256,8 +257,10 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int
> cs, if ((sg_count + 1 == sgs) && *last)
>  			ctrl0 |= BM_SSP_CTRL0_IGNORE_CRC;
> 
> -		if (ssp->devid == IMX23_SSP)
> +		if (ssp->devid == IMX23_SSP) {
> +			ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
>  			ctrl0 |= min;
> +		}
> 
>  		dma_xfer[sg_count].pio[0] = ctrl0;
>  		dma_xfer[sg_count].pio[3] = min;

Best regards,
Marek Vasut

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

WARNING: multiple messages have this Message-ID (diff)
From: marex@denx.de (Marek Vasut)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA
Date: Wed, 26 Dec 2012 06:06:26 +0100	[thread overview]
Message-ID: <201212260606.26770.marex@denx.de> (raw)
In-Reply-To: <1356498088-31176-1-git-send-email-juha.lumme@gmail.com>

Dear Juha Lumme,

> On MX23 the XFER_LEN

XFER_COUNT ;-)

> part in CTRL0 register was improperly OR'd

... during construction of DMA descriptor chain. Instead of being freshly set.

> , and
> because of that too many characters

Bytes

> were being expected from SPI.

expected from SPI during the last DMA cycle.

> This caused a timeout (SSP_TIMEOUT) to happen in the last package

... during the processing of the last DMA descriptor ...

> in the
> DMA chain, and resulted into a corrupted read.

Write too, really ;-)

> This is a workaround for the problem

This is actually a correct fix for the issue.

> , by clearing the XFER_LEN bytes always
> before reading the new size for XFER_LEN.

before setting new XFER_COUNT into the ctrl0 field of DMA control transfer.

> Cc: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Shawn Guo <shawn.guo@linaro.org
> Signed-off-by: Juha Lumme <juha.lumme@gmail.com>

All but the commit message,

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/spi/spi-mxs.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
> index 86dd04d..265c33f 100644
> --- a/drivers/spi/spi-mxs.c
> +++ b/drivers/spi/spi-mxs.c
> @@ -241,6 +241,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int
> cs, INIT_COMPLETION(spi->c);
> 
>  	ctrl0 = readl(ssp->base + HW_SSP_CTRL0);
> +	ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
>  	ctrl0 |= BM_SSP_CTRL0_DATA_XFER | mxs_spi_cs_to_reg(cs);
> 
>  	if (*first)
> @@ -256,8 +257,10 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int
> cs, if ((sg_count + 1 == sgs) && *last)
>  			ctrl0 |= BM_SSP_CTRL0_IGNORE_CRC;
> 
> -		if (ssp->devid == IMX23_SSP)
> +		if (ssp->devid == IMX23_SSP) {
> +			ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
>  			ctrl0 |= min;
> +		}
> 
>  		dma_xfer[sg_count].pio[0] = ctrl0;
>  		dma_xfer[sg_count].pio[3] = min;

Best regards,
Marek Vasut

  parent reply	other threads:[~2012-12-26  5:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26  5:01 [PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA Juha Lumme
2012-12-26  5:01 ` Juha Lumme
     [not found] ` <1356498088-31176-1-git-send-email-juha.lumme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-26  5:06   ` Marek Vasut [this message]
2012-12-26  5:06     ` Marek Vasut

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=201212260606.26770.marex@denx.de \
    --to=marex-ynqeqjnshbs@public.gmane.org \
    --cc=fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=juha.lumme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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.