netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: Nishanth Menon <nm@ti.com>, <wg@grandegger.com>, <mkl@pengutronix.de>
Cc: <tony@atomide.com>, <tglx@linutronix.de>, <mugunthanvnm@ti.com>,
	<george.cherian@ti.com>, <balbi@ti.com>, <nsekhar@ti.com>,
	<sergei.shtylyov@cogentembedded.com>,
	<linux-omap@vger.kernel.org>, <linux-can@vger.kernel.org>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] can: c_can_platform: Fix c_can_hw_raminit_ti() and add timeout
Date: Tue, 9 Sep 2014 17:45:40 +0300	[thread overview]
Message-ID: <540F1294.9080107@ti.com> (raw)
In-Reply-To: <540F0FEE.2040202@ti.com>

On 09/09/2014 05:34 PM, Nishanth Menon wrote:
> On 09/09/2014 09:31 AM, Roger Quadros wrote:
>> Pass the correct 'mask' and 'value' bits to c_can_hw_raminit_wait_ti().
>> They seem to have been swapped in the usage instances.
>>
>> TI's RAMINIT DONE mechanism is buggy and may not always be
>> set after the START bit is set. So add a timeout mechanism to
>> c_can_hw_raminit_wait_ti().
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>>  drivers/net/can/c_can/c_can_platform.c | 14 +++++++++++---
>>  1 file changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
>> index 109cb44..b144e71 100644
>> --- a/drivers/net/can/c_can/c_can_platform.c
>> +++ b/drivers/net/can/c_can/c_can_platform.c
>> @@ -75,10 +75,18 @@ static void c_can_plat_write_reg_aligned_to_32bit(const struct c_can_priv *priv,
>>  static void c_can_hw_raminit_wait_ti(const struct c_can_priv *priv, u32 mask,
>>  				  u32 val)
>>  {
>> +	int timeout = 0;
>>  	/* We look only at the bits of our instance. */
>>  	val &= mask;
>> -	while ((readl(priv->raminit_ctrlreg) & mask) != val)
>> +	while ((readl(priv->raminit_ctrlreg) & mask) != val) {
>>  		udelay(1);
>> +		timeout++;
>> +
>> +		if (timeout == 1000) {
> 
> How did we come up with this number?

wild guess ;), that it should be set in a few microseconds and the delay is not too
large.

Till I don't hear from hardware guys, it will remain a guess.

> 
>> +			dev_err(&priv->dev->dev, "%s: time out\n", __func__);
>> +			break;
> lets say we did timeout..
> see below:
>> +		}
>> +	}
>>  }
>>  
>>  static void c_can_hw_raminit_ti(const struct c_can_priv *priv, bool enable)
>> @@ -97,14 +105,14 @@ static void c_can_hw_raminit_ti(const struct c_can_priv *priv, bool enable)
>>  	ctrl |= CAN_RAMINIT_DONE_MASK(priv->instance);
>>  	writel(ctrl, priv->raminit_ctrlreg);
>>  	ctrl &= ~CAN_RAMINIT_DONE_MASK(priv->instance);
>> -	c_can_hw_raminit_wait_ti(priv, ctrl, mask);
>> +	c_can_hw_raminit_wait_ti(priv, mask, ctrl);
>>  
>>  	if (enable) {
>>  		/* Set start bit and wait for the done bit. */
>>  		ctrl |= CAN_RAMINIT_START_MASK(priv->instance);
>>  		writel(ctrl, priv->raminit_ctrlreg);
>>  		ctrl |= CAN_RAMINIT_DONE_MASK(priv->instance);
>> -		c_can_hw_raminit_wait_ti(priv, ctrl, mask);
>> +		c_can_hw_raminit_wait_ti(priv, mask, ctrl);
> 
> is it possible for us to continue? does it make sense for us to change
> that void to a int and handle error cascading?

I will verify this first to check if the hardware works or not in the failing case.
Considering we never checked for the DONE bit in our earlier TI releases maybe it works.

But I'll verify and get back.
> 
>>  	}
>>  	spin_unlock(&raminit_lock);
>>  }
>>
> 
> 

cheers,
-roger

  reply	other threads:[~2014-09-09 14:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 14:31 [PATCH v2 0/3] net: can: Use syscon regmap for TI specific RAMINIT register Roger Quadros
2014-09-09 14:31 ` [PATCH v2 1/3] can: c_can_platform: Fix c_can_hw_raminit_ti() and add timeout Roger Quadros
2014-09-09 14:34   ` Marc Kleine-Budde
2014-09-09 14:39     ` Roger Quadros
2014-09-16 14:13       ` Marc Kleine-Budde
2014-09-09 14:34   ` Nishanth Menon
2014-09-09 14:45     ` Roger Quadros [this message]
2014-09-09 14:51       ` Nishanth Menon
2014-09-09 14:54         ` Roger Quadros
2014-09-09 14:31 ` [PATCH v2 2/3] net: can: c_can: Add syscon/regmap RAMINIT mechanism Roger Quadros
2014-09-30 13:26   ` Wolfram Sang
2014-09-30 13:33     ` Roger Quadros
2014-09-30 13:52       ` Wolfram Sang
2014-09-30 13:58         ` Roger Quadros
2014-09-30 14:19           ` Wolfram Sang
2014-09-30 14:22             ` Marc Kleine-Budde
2014-09-30 14:49               ` Wolfram Sang
2014-09-30 15:01                 ` Marc Kleine-Budde
2014-09-30 15:25                   ` Wolfram Sang
2014-09-30 16:04                     ` Marc Kleine-Budde
2014-10-01  8:45                       ` Roger Quadros
2014-10-01  8:47                         ` Marc Kleine-Budde
2014-10-01  9:06                           ` Roger Quadros
2014-10-01 10:01                             ` Marc Kleine-Budde
2014-10-01 10:12                               ` Roger Quadros
2014-10-01 10:26                                 ` Marc Kleine-Budde
2014-10-01 10:43                                   ` Wolfram Sang
2014-10-01 10:57                                     ` Roger Quadros
2014-10-01 11:06                                       ` Marc Kleine-Budde
2014-10-01 11:10                                       ` Wolfram Sang
2014-10-01 11:11                                     ` Marc Kleine-Budde
2014-09-30 13:45     ` Marc Kleine-Budde
2014-09-30 14:02       ` Roger Quadros
2014-09-30 14:11         ` Marc Kleine-Budde
2014-09-09 14:31 ` [PATCH v2 3/3] net: can: c_can: Add support for START pulse in RAMINIT sequence Roger Quadros

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=540F1294.9080107@ti.com \
    --to=rogerq@ti.com \
    --cc=balbi@ti.com \
    --cc=george.cherian@ti.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=nsekhar@ti.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.com \
    --cc=wg@grandegger.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).