linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Evans <tom_usenet@optusnet.com.au>
To: "Viktor Babrian" <babrian.viktor@renyi.mta.hu>,
	"Heinz-Jürgen Oertel" <hj.oertel@t-online.de>
Cc: linux-can@vger.kernel.org
Subject: Re: c_can: (newbie) high system load when frame not acked?
Date: Tue, 13 Jan 2015 12:19:46 +1100	[thread overview]
Message-ID: <54B472B2.4010300@optusnet.com.au> (raw)
In-Reply-To: <alpine.DEB.2.02.1501121948370.28201@login>

On 13/01/15 05:50, Viktor Babrian wrote:
> Hi there,
>
> thanks for the quick answer
>> please check
>> http://www.can-wiki.info/doku.php?id=can_faq:problem_solving_questions
> checks out, thanks
>
>> Yes, retransmission is what the CAN controller always does if no other node
>> is connected and gives a ACK to a correct received message
>
> my main concern is the high system load it causes

You're using a "am3359 board (having DCAN CAN controller)". I'm not familiar 
with that chip.

 > # ip link set can1 type can bitrate 500000 triple-sampling on

Does it have a "berr-reporting" option, can you turn it off and does it make 
it any better?

Searching ... you're probably using:

http://lxr.free-electrons.com/source/drivers/net/can/c_can/c_can.c

It has "CAN_CTRLMODE_BERR_REPORTING", but turning that off doesn't prevent the 
interrupts. It just prevents it from calling "netif_receive_skb(skb)" with the 
error information from the poll. It configures the interrupts this way:

     /* enable status change, error and module interrupts */
     #define CONTROL_IRQMSK  (CONTROL_EIE | CONTROL_IE | CONTROL_SIE)

Maybe you can turn the error interrupts off and still have it function. Maybe 
it won't (may be required for bus off recovery).

I'm familiar with the problems with Freescale FlexCAN controllers. They can't 
generate interrupts on CAN state-changes, so the driver writers enable *ALL* 
error interrupts so as to track the state changes. Not many people use or need 
this facility.

The consequence (depending on the CPU and Linux build options) is 10%-100% CPU 
utilisation when there's nothing to ACK the packet, and a higher figure again 
when the bus isn't terminated.

CAN is meant to be used in cars or factories. Running with only one node or a 
disconnected bus is not a "normal" condition, so the hardware and drivers 
don't handle those conditions well.

I'd recommend running a shell script that periodically monitors the CAN 
interrupt rate (or opens an error socket and monitors the error rate) and if 
it detects this situation to just disables the CAN bus for a while or until 
the user fixes the problem.

If you read through the following it might give you enough understanding to 
change your driver, or find another solution.

https://community.freescale.com/thread/333839

Read my final post in that thread.

Search the linux-can list for the series of posts titled "[PATCH] Consolidate 
and unify state change handling" starting 2014-10-20:

http://article.gmane.org/gmane.linux.can/7165

There have also been proposed patches to recognise when there's a "flood" of 
error interrupts and to limit the rate, but possibly not for your driver.

Tom


  reply	other threads:[~2015-01-13  1:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 17:54 [PATCH v5 3/5] can: mscan: Consolidate and unify state change handling Andri Yngvason
2015-01-12 17:18 ` c_can: (newbie) high system load when frame not acked? Viktor Babrian
     [not found]   ` <1735533.0yOonAfCy1@heinz>
2015-01-12 18:50     ` Viktor Babrian
2015-01-13  1:19       ` Tom Evans [this message]
2015-01-13 15:10         ` Viktor Babrian
2015-01-13 15:16           ` Marc Kleine-Budde
2015-01-13 15:54             ` Viktor Babrian
2015-01-13 15:55               ` Marc Kleine-Budde
2015-01-13 15:32           ` Andri Yngvason
2015-01-14  1:35             ` Tom Evans
2015-01-14  9:55               ` Andri Yngvason
2015-01-15  0:29                 ` Tom Evans
2015-01-18 18:30             ` [PATCH 3.19-rc3] c_can: SIE disabled when berr-reporting is off to reduce irq flood Viktor Babrian
2015-01-18 18:34               ` Marc Kleine-Budde
2015-01-18 18:52                 ` Viktor Babrian
2015-01-18 18:56                   ` Marc Kleine-Budde
2015-01-19 11:32                     ` Viktor Babrian
2015-01-19 22:35                 ` Tom Evans
2015-01-18 19:01               ` [PATCH 3.19-rc3] c_can: end transmission on network stop Viktor Babrian
2015-01-20 14:39                 ` 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=54B472B2.4010300@optusnet.com.au \
    --to=tom_usenet@optusnet.com.au \
    --cc=babrian.viktor@renyi.mta.hu \
    --cc=hj.oertel@t-online.de \
    --cc=linux-can@vger.kernel.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 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).