All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 2/4] spi, spi_mxc: do not hang in spi_xchg_single
Date: Thu, 29 May 2014 07:12:25 +0200	[thread overview]
Message-ID: <5386C1B9.7000009@gmail.com> (raw)
In-Reply-To: <1401272177-16107-3-git-send-email-hs@denx.de>

Am 28.05.2014 12:16, schrieb Heiko Schocher:
> if status register do never set MXC_CSPICTRL_TC, spi_xchg_single
> endless loops. Add a timeout here to prevent endless hang.

As I've never seen this, yet: Any idea what goes wrong if this happens?

Thanks

Dirk

> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Dirk Behme <dirk.behme@gmail.com>
> Cc: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
> ---
>   drivers/spi/mxc_spi.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
> index f3f029d..3cd93cf 100644
> --- a/drivers/spi/mxc_spi.c
> +++ b/drivers/spi/mxc_spi.c
> @@ -212,6 +212,7 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen,
>   	int nbytes = DIV_ROUND_UP(bitlen, 8);
>   	u32 data, cnt, i;
>   	struct cspi_regs *regs = (struct cspi_regs *)mxcs->base;
> +	int timeout;
>
>   	debug("%s: bitlen %d dout 0x%x din 0x%x\n",
>   		__func__, bitlen, (u32)dout, (u32)din);
> @@ -272,9 +273,12 @@ int spi_xchg_single(struct spi_slave *slave, unsigned int bitlen,
>   	reg_write(&regs->ctrl, mxcs->ctrl_reg |
>   		MXC_CSPICTRL_EN | MXC_CSPICTRL_XCH);
>
> +	timeout = 10000;
>   	/* Wait until the TC (Transfer completed) bit is set */
> -	while ((reg_read(&regs->stat) & MXC_CSPICTRL_TC) == 0)
> -		;
> +	while (timeout && ((reg_read(&regs->stat) & MXC_CSPICTRL_TC) == 0)) {
> +		timeout--;
> +		udelay(10);
> +	}
>
>   	/* Transfer completed, clear any pending request */
>   	reg_write(&regs->stat, MXC_CSPICTRL_TC | MXC_CSPICTRL_RXOVF);
>

  parent reply	other threads:[~2014-05-29  5:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28 10:16 [U-Boot] [PATCH v1 0/4] arm, imx6: add aristainetos board support Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 1/4] arm, imx6: add mxc_iomux_set_gpr_register function Heiko Schocher
2014-07-11 11:10   ` Stefano Babic
2014-07-11 13:00     ` Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 2/4] spi, spi_mxc: do not hang in spi_xchg_single Heiko Schocher
2014-05-28 11:09   ` Jagan Teki
2014-05-29  5:12   ` Dirk Behme [this message]
2014-05-29  5:22     ` Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 3/4] i.MX6: add enable_spi_clk() Heiko Schocher
2014-07-11 11:14   ` Stefano Babic
2014-07-11 13:22   ` Fabio Estevam
2014-07-15  8:15     ` Stefano Babic
2014-05-28 10:16 ` [U-Boot] [PATCH v1 4/4] arm, imx6: add aristainetos board Heiko Schocher
2014-07-11 12:26   ` Stefano Babic
2014-07-11 14:12     ` Heiko Schocher

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=5386C1B9.7000009@gmail.com \
    --to=dirk.behme@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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.