linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Stanislav Meduna <stano@meduna.org>,
	wg@grandegger.com, linux-can@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>
Subject: Re: FlexCAN on i.MX28 interrupt flooding retrying send
Date: Fri, 07 Mar 2014 09:46:11 +0100	[thread overview]
Message-ID: <53198753.8000900@pengutronix.de> (raw)
In-Reply-To: <53197E8A.5050409@meduna.org>

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

On 03/07/2014 09:08 AM, Stanislav Meduna wrote:
> Hi,
> 
> I am using a FlexCAN CAN controller on a Freescale i.MX28 platform [1].
> If a packet is being sent when the bus is disconnected, I am getting
> an interrupt flooed that basically kills the machine.
> 
> This is _not_ the same problem as [2] - my kernel already has
> the fix.
> 
> The first interrupt comes with ESR 0x00028652, i.e.
> 
> TXWRN_INT
> BIT1_ERR
> STF_ERR
> TX_WRN
> TXRX
> FLT_CONF error passive
> ERR_INT
> 
> The next ones come the same without the acked TXWRN_INT.
> Reading the ESR again immediately after acking gives
> 0x00000250, i.e.
> 
> TX_WRN
> TXRX
> FLT_CONF error passive
> 
> so everything ackable has actually been acked.
> 
> I think that the problem is that the FlexCAN tries to retransmit
> the frame indefinitely. Each retry senses the bus in the invalid
> state (BIT1_ERR) and immediately fires a new ERR_INT. To verify
> this I aborted the transmitted frame in the error state in the
> interrupt handler
> 
> #define FLEXCAN_ESR_ERR_TRANSMIT \
> 	(FLEXCAN_ESR_BIT1_ERR | FLEXCAN_ESR_BIT0_ERR | FLEXCAN_ESR_ACK_ERR)
> 
> if (reg_esr & FLEXCAN_ESR_ERR_TRANSMIT) {
> 
> 	/* In case of a transmission error the packet is retried and
> 	 * if the error persists, we will get another interrupt right
> 	 * away. Abort the transmission - a lost packet is better than
> 	 * an irq storm.
> 	 */
> 	if(printk_ratelimit())
> 		netdev_err(dev, "Aborted transmission, ESR %08x\n", reg_esr);
> 
> 	can_get_echo_skb(dev, 0);
> 	flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
> 		&regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
> 	netif_wake_queue(dev);
> }
> 
> and the problem disappeared as expected. However, the correct
> way is probably to retry during some reasonable (configurable?)
> time interval.
> 
> What puzzles me is that I did not found any other instance
> of this problem in the relevant mailing lists, only the original [2].
> 
> I am using the 3.4.77 kernel with the realtime patches, but the
> code in the latest mainline looks the same in this respect.
> Maybe the realtime patches change some bevaviour, but I don't
> think they affect the core problem. I am not really an expert
> in the network devices, NAPI etc - maybe in that case the error
> interrupt should be disabled and re-enabled only if the
> error condition goes away? - I don't know...

Your kernel is missing the patch:

e358784 can: flexcan: fix mx28 detection by rearanging OF match table

With this patch the CAN core properly detected as an mx28, so that bus
errors stay disabled (unless you enable them). If you need bus errors to
detect not connected CAN busses, you need another patchset berr_limit,
which is not yet mainline. I can repost it here, if you need it.

Marc

-- 
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 --]

  parent reply	other threads:[~2014-03-07  8:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07  8:08 FlexCAN on i.MX28 interrupt flooding retrying send Stanislav Meduna
2014-03-07  8:16 ` Marc Kleine-Budde
2014-03-07  8:40   ` Wolfgang Grandegger
     [not found]     ` <OF203965D8.128520F3-ON86257C94.004FA84A-86257C94.0050AF36@notes.cat.com>
2014-03-07 15:36       ` Wolfgang Grandegger
2014-03-07  8:32 ` Matthias Klein
2014-03-07  8:46 ` Marc Kleine-Budde [this message]
2014-03-07 13:36   ` Stanislav Meduna
2014-03-07 13:54     ` Marc Kleine-Budde
     [not found]       ` <OFA84C0F6D.092C777B-ON86257C94.004E3F0B-86257C94.004F1F2D@notes.cat.com>
2014-03-07 14:40         ` Marc Kleine-Budde
2014-03-07 15:55     ` Wolfgang Grandegger

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=53198753.8000900@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=stano@meduna.org \
    --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).