All of lore.kernel.org
 help / color / mirror / Atom feed
From: "ZHU Yi (ST-FIR/ENG1-Zhu)" <Yi.Zhu5@cn.bosch.com>
To: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Andri Yngvason <andri.yngvason@marel.com>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Cc: "hs@denx.de" <hs@denx.de>,
	"RUAN Tingquan (ST-FIR/ENG1-Zhu)" <Tingquan.Ruan@cn.bosch.com>,
	"Jonas Mark (ST-FIR/ENG1)" <Mark.Jonas@de.bosch.com>
Subject: RE: [PATCH 1/6] can: flexcan: fix state transition regression
Date: Fri, 1 Sep 2017 02:48:31 +0000	[thread overview]
Message-ID: <1943d84bc81b47368ce9b312f2d6ab11@SGPMBX1017.APAC.bosch.com> (raw)
In-Reply-To: <ea64fc2b-e94d-3fc0-35ad-3a70d94800e6@grandegger.com>

Hello Wolfgang,

> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
> Sent: Thursday, August 31, 2017 7:37 PM
> 
> Hello ZHU Yi,
> 
> usually a [PATCH 0/x] is coming first telling what the series does. We
> use "git format-patch --cover-letter ..." for that purpose.
OK. Thanks for your hint!
I'll prepare the updated patch series with cover letter later.

> 
> Am 31.08.2017 um 10:24 schrieb ZHU Yi (ST-FIR/ENG1-Zhu):
> [...]
> > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> > index 13f0f21..df4bfb8 100644
> > --- a/drivers/net/can/flexcan.c
> > +++ b/drivers/net/can/flexcan.c
> > @@ -765,8 +765,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
> >   		flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);
> >   	}
> >
> > -	/* state change interrupt */
> > -	if (reg_esr & FLEXCAN_ESR_ERR_STATE)
> > +	/* state change interrupt or broken error state quirk fix is enabled */
> > +	if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
> > +	    (priv->devtype_data->quirks &
> FLEXCAN_QUIRK_BROKEN_ERR_STATE))
> >   		flexcan_irq_state(dev, reg_esr);
> 
> This means that flexcan_irq_state() is called for any interrupt source.
> That's what we had in the pre rx-offload version. Thinking about it:
> do we need that (overhead for RX and TX)? Maybe the following works already:
> 
>  +	if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
>  +	    ((priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_ERR_STATE) &&
>  +		(reg_esr & FLEXCAN_ESR_ERR_STATE)))
I'm not sure that I understood your proposal correctly, the guess is
the second "reg_esr & FLEXCAN_ESR_ERR_STATE" is a typo, do you mean
"reg_esr & FLEXCAN_ESR_BUS_ERR"?

If we only call flexcan_irq_state() upon state + error interrupt, then:
(new core: with    [TR]WRN_INT, e.g., i.MX6,
 old core: without [TR]WRN_INT, e.g., i.MX53)
1. error state increases, enough for both new and old cores.
    active ---> warning ---> passive ---> bus off
                   ^            ^            ^
                WRN_INT/     ERR_INT      BOFF_INT
	        ERR_INT(old core)

2. error state decreases, not enough for both new and old cores.
    active <--- warning <--- passive
       ^           ^
    [TR]X       WRN_INT/
	        [TR]X(old core)
The [TR]X interrupt is required for the state decreases, and the
overhead of them IMHO is not overkill:
1. If flexcan_irq_state() is called when the state is not change,
   then, the overhead is read FLT_CONF and/or read error counter,
   do O(1) calculation and compare the state, then quit.

2. If flexcan_irq_state() is called when the state is changed,
   then, that's what help us to report correct state transitions.

Of course, if flexcan core can generate appropriate state interrupts
in its next version (FlexCAN4?), then we don't need such overhead
at all, but when will this wish come true? :)

Best regards
Yi

  reply	other threads:[~2017-09-01  2:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31  8:24 [PATCH 1/6] can: flexcan: fix state transition regression ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-31 11:37 ` Wolfgang Grandegger
2017-09-01  2:48   ` ZHU Yi (ST-FIR/ENG1-Zhu) [this message]
2017-09-01 15:14     ` Wolfgang Grandegger
2017-09-04 10:01       ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-09-04 11:09         ` Wolfgang Grandegger
2017-09-13  9:33 ZHU Yi (ST-FIR/ENG1-Zhu)

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=1943d84bc81b47368ce9b312f2d6ab11@SGPMBX1017.APAC.bosch.com \
    --to=yi.zhu5@cn.bosch.com \
    --cc=Mark.Jonas@de.bosch.com \
    --cc=Tingquan.Ruan@cn.bosch.com \
    --cc=andri.yngvason@marel.com \
    --cc=hs@denx.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.