linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Matthias Klein <matthias.klein@optimeas.de>,
	wg@grandegger.com, linux-can@vger.kernel.org,
	support@karo-electronics.de
Cc: bigeasy@linutronix.de
Subject: Re: [PATCH 2/5] net: can: flexcan: disable error interrupts in non ERR-Active state
Date: Sat, 26 Jul 2014 00:17:00 +0200	[thread overview]
Message-ID: <53D2D75C.2040607@pengutronix.de> (raw)
In-Reply-To: <1406312202-2542-2-git-send-email-matthias.klein@optimeas.de>

[-- Attachment #1: Type: text/plain, Size: 3104 bytes --]

On 07/25/2014 08:16 PM, Matthias Klein wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> 
> On imx53 I receive continuously STF_ERR error interrupts after sending a
> CAN frame on an open BUS.
> This patch disables error interrupts once we leave the ERR-Active state
> since I doubt further error interrupts are of any interest especially if
> they render the system unresponsible.

For some use cases and users this is important. However I think we all
don't want to have an unresponsive system. Have a look the "can:
berr_limit support" series [1], which introduces a configurable time-out
before the error interrupts are re-enabled.

[1] http://comments.gmane.org/gmane.linux.can/4070

The series needs some polishing and there are some open questions to
address.

Marc

> According to the manual in this case the system remains in passive state
> and RX-err counter is >127 and won't increment any further and so it
> won't enter BUS-Off state. Once the system receives a CAN message, the
> RX-error counter should by set to 119 … 127 which brings the CAN module
> back to ERR-active state which then should activate error reporting
> again.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Matthias Klein <matthias.klein@optimeas.de>
> ---
>  drivers/net/can/flexcan.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index f677b49..2b98da2 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -628,7 +628,17 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
>  		napi_complete(napi);
>  		/* enable IRQs */
>  		flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> -		flexcan_write(priv->reg_ctrl_default, &regs->ctrl);
> +		/*
> +		 * On an open CAN-bus the iMX51 keeps reporting the STF_ERR
> +		 * event after an attempt to send a CAN message. This will
> +		 * disable further error reports (or that one that keeps
> +		 * nagging) once we leave the ERR-Active state.
> +		 */
> +		if (reg_esr & FLEXCAN_ESR_FLT_CONF_MASK)
> +			flexcan_write(priv->reg_ctrl_default &
> +					~FLEXCAN_CTRL_ERR_MSK, &regs->ctrl);
> +		else
> +			flexcan_write(priv->reg_ctrl_default, &regs->ctrl);
>  	}
>  
>  	return work_done;
> @@ -656,8 +666,8 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
>  	 * - bus error IRQ and bus error reporting is activated
>  	 */
>  	if ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) ||
> -	    (reg_esr & FLEXCAN_ESR_ERR_STATE) ||
> -	    flexcan_has_and_handle_berr(priv, reg_esr)) {
> +	    (reg_esr & FLEXCAN_ESR_ERR_ALL)) {
> +
>  		/*
>  		 * The error bits are cleared on read,
>  		 * save them for later use.
> 

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

  reply	other threads:[~2014-07-25 22:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25 18:16 [PATCH 1/5] net: can: flexcan: provide propper return code in ISR Matthias Klein
2014-07-25 18:16 ` [PATCH 2/5] net: can: flexcan: disable error interrupts in non ERR-Active state Matthias Klein
2014-07-25 22:17   ` Marc Kleine-Budde [this message]
2014-07-25 18:16 ` [PATCH 3/5] net: can: flexcan: handle state passive -> warning transition Matthias Klein
2014-07-25 22:21   ` Marc Kleine-Budde
2014-07-25 18:16 ` [PATCH 4/5] net: can: flexcan: wait for completion when entering freeze mode Matthias Klein
2014-07-25 18:50   ` Sebastian Andrzej Siewior
2014-07-25 18:51   ` [PATCH] net: can: flexcan: reset the error counter after leaving passive state Sebastian Andrzej Siewior
2014-07-25 20:46     ` Marc Kleine-Budde
2014-07-25 18:16 ` [PATCH 5/5] net: can: flexcan: fix for wrong TX error count behaviour on i.MX53 Matthias Klein
2014-07-25 22:31 ` [PATCH 1/5] net: can: flexcan: provide propper return code in ISR Marc Kleine-Budde

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=53D2D75C.2040607@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=matthias.klein@optimeas.de \
    --cc=support@karo-electronics.de \
    --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).