Linux CAN drivers development
 help / color / mirror / Atom feed
From: Andri Yngvason <andri.yngvason@marel.com>
To: 朱燚 <zhuyi882004@126.com>,
	mkl@pengutronix.de, wg@grandegger.com, linux-can@vger.kernel.org
Cc: hs@denx.de, mark.jonas@de.bosch.com, tingquan.ruan@cn.bosch.com,
	yi.zhu5@cn.bosch.com
Subject: Re: flexcan missing error state transitions
Date: Mon, 28 Aug 2017 11:23:24 +0000	[thread overview]
Message-ID: <150391940455.32436.2657378736949568599@maxwell> (raw)
In-Reply-To: <376b00a0.1c22.15e1d13e43a.Coremail.zhuyi882004@126.com>

Quoting 朱燚 (2017-08-26 05:46:36)
> > That sounds rather shaky. Wouldn't it be more robust to have the timer be
> > periodic? Besides, over-sampling is preferable in order to avoid missed
> > transitions, right? See diff below.
> I can understand why you feel shaky, but I think use periodic timer will not
> do meaningful work here - just polling state which do not change.
> 
> The reason is flexcan_irq_state() will be called upon any interrupt, that
> already guarantees state is up-to-date if there is traffic on the bus, which
> is the trigger of any possible state transitions. In this case, any kind of
> polling is not required (however, this patch will still do once extra polling,
> which I'd like to avoid as well, but seems no easy solution). Extra polling
> will get the same state as before if there is no more traffic, and if the
> traffic is ongoing, the interrupt will be fired.
> 
> The only case above approach cannot handle is there is only singled out node
> on the bus, where the traffic cannot continue. Although the core will perform
> auto-retransmission, but it will not generate flood of error interrupts,
> instead only generate an ACK error (/+WARN) interrupt, where the FLT_CONF is
> not up-to-date yet when the flexcan_irq_state() been called, and there is no
> trigger to update the state again when the register is changed. That's the
> point of this patch to compensate this trigger by poll once at the right time.
> Extra polling will get the same state too if the bus is still open, and if the
> bus is recovered, the interrupt will be fired again.
> 
> Regarding missed transitions, yes, if user chose a too short delay, then he
> will miss the error passive transition, that's why the delay is configurable
> via DT.
> 
> > > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> > ...
> > > +static void flexcan_update_state_timeout(unsigned long data)
> > > +{
> > > +   struct net_device *dev =3D (struct net_device*)data;
> > > +   struct flexcan_priv *priv =3D netdev_priv(dev);
> > > +   struct flexcan_regs __iomem *regs =3D priv->regs;
> > > +   u32 reg_esr;
> > > +
> > > +   /* update state atomically */
> > > +   disable_irq(dev->irq);
> > > +   reg_esr = flexcan_read(&regs->esr);
> > > +   flexcan_irq_state(dev, reg_esr);
> > You could restart the timer here if the error state is not error-active. Then
> > you would not have the problem of having to choose an interval so carefully.
> Yes, you're right. But I think it is good to think carefully which delay is
> really necessary than just drop a randomly number here. With periodic timer,
> if very short delay assigned, then the performance will be hit, if reasonable
> delay assigned, then unnecessary polling will be done.
> > > +   enable_irq(dev->irq);
> > > +}
> > ...
> 
> I understand that use periodic timer is a more generic approach which even
> possible to replace the interrupt driven on broken core (if want to), but I
> want to avoid unnecessary polling as much as possible (and still get the
> correct state transitions).
> 
> What do you think?

Hi Yi,

I have users who can change the baudrate but they can not change the device
tree. The baudrate can even be changed by service technicians. I.e. it's field
configurable. How would I configure the timeout to work well for rates between
125k and 1M?

Do you think that a periodic timer would load the system more than an IRQ-flood
due to a bad error situation?

Best regards,
Andri

  reply	other threads:[~2017-08-28 11:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-26  5:46 flexcan missing error state transitions 朱燚
2017-08-28 11:23 ` Andri Yngvason [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-08-18  7:47 ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-21 16:18 ` Andri Yngvason
2017-08-21 17:13   ` AW: " Jonas Mark (ST-FIR/ENG1)
2017-08-21 18:21     ` Andri Yngvason
2017-08-22 13:50       ` AW: " Jonas Mark (ST-FIR/ENG1)
2017-08-22 14:06         ` Marc Kleine-Budde
2017-08-27 10:57           ` Wolfgang Grandegger
2017-08-28  4:21             ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-28  8:33               ` Wolfgang Grandegger
2017-08-29  8:49                 ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-29  9:38                   ` Wolfgang Grandegger
2017-08-30  1:39                     ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-29 11:17                   ` Wolfgang Grandegger
2017-08-30  4:22                     ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-30  6:25                       ` Wolfgang Grandegger
2017-08-30  6:50                         ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-30  7:15                           ` Wolfgang Grandegger
2017-08-30  9:05                             ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-30 10:59                               ` Wolfgang Grandegger
2017-08-31  8:33                                 ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-31  9:53                                   ` Wolfgang Grandegger
2017-09-01  8:24                                     ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-29 13:41                   ` Andri Yngvason
2017-08-22 14:14         ` AW: AW: " Andri Yngvason
2017-08-27 12: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=150391940455.32436.2657378736949568599@maxwell \
    --to=andri.yngvason@marel.com \
    --cc=hs@denx.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mark.jonas@de.bosch.com \
    --cc=mkl@pengutronix.de \
    --cc=tingquan.ruan@cn.bosch.com \
    --cc=wg@grandegger.com \
    --cc=yi.zhu5@cn.bosch.com \
    --cc=zhuyi882004@126.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