From: Andri Yngvason <andri.yngvason@marel.com>
To: Wolfgang Grandegger <wg@grandegger.com>, linux-can@vger.kernel.org
Cc: mkl@pengutronix.de
Subject: Re: [PATCH v4 4/6] can: flexcan: Consolidate and unify state change handling.
Date: Mon, 1 Dec 2014 11:09:23 +0000 [thread overview]
Message-ID: <20141201110923.29602.38961@shannon> (raw)
In-Reply-To: <547B7CDD.2080202@grandegger.com>
Quoting Wolfgang Grandegger (2014-11-30 20:23:57)
> On 11/28/2014 01:12 PM, Andri Yngvason wrote:
> > Replacing error state change handling with the new mechanism.
> >
> > Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>
> > ---
> > Changes made since last proposal:
> > can: flexcan: add FLEXCAN_HAS_BROKEN_ERR_STATE for i.MX6
> > can: flexcan: adapt to newer can_change_state
> >
> > drivers/net/can/flexcan.c | 103 +++++++++-------------------------------------
> > 1 file changed, 19 insertions(+), 84 deletions(-)
> >
> > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> > index 60f86bd..9f91735 100644
> > --- a/drivers/net/can/flexcan.c
> > +++ b/drivers/net/can/flexcan.c
> > @@ -266,7 +266,7 @@ static struct flexcan_devtype_data fsl_p1010_devtype_data = {
> > };
> > static struct flexcan_devtype_data fsl_imx28_devtype_data;
> > static struct flexcan_devtype_data fsl_imx6q_devtype_data = {
> > - .features = FLEXCAN_HAS_V10_FEATURES,
> > + .features = FLEXCAN_HAS_V10_FEATURES | FLEXCAN_HAS_BROKEN_ERR_STATE,
>
> Oops, this change is not related to the subject! Anyway, did it cure
> your problems with state handling. Is it required for all i.MX6 cores then?
>
Yeah, I accidentally squashed this; intended to make this a separate patch. This
helps. It has the same effect as enabling berr-reporting. However, this only
cures one of the problems. This does not help with the case where no one else is
sending on the bus.
This problem is not limited to i.MX6. This is a problem for ALL FlexCAN cores.
This is a design flaw in FlexCAN cores. Maybe they did this part on a monday
after a weekend of binge-drinking. In any case, they really messed up with this
one.
I suggest that we remove the FLEXCAN_HAS_BROKEN_ERR_STATE flag and turn on error
interrupts permanently because they ALL have broken error state.
>
> > };
> > static struct flexcan_devtype_data fsl_vf610_devtype_data = {
> > .features = FLEXCAN_HAS_V10_FEATURES | FLEXCAN_HAS_MECR_FEATURES,
> > @@ -577,98 +577,30 @@ static int flexcan_poll_bus_err(struct net_device *dev, u32 reg_esr)
> > return 1;
> > }
> >
> > -static void do_state(struct net_device *dev,
> > - struct can_frame *cf, enum can_state new_state)
> > -{
> > - struct flexcan_priv *priv = netdev_priv(dev);
> > - struct can_berr_counter bec;
> > -
> > - __flexcan_get_berr_counter(dev, &bec);
> > -
> > - switch (priv->can.state) {
> > - case CAN_STATE_ERROR_ACTIVE:
> > - /*
> > - * from: ERROR_ACTIVE
> > - * to : ERROR_WARNING, ERROR_PASSIVE, BUS_OFF
> > - * => : there was a warning int
> > - */
> > - if (new_state >= CAN_STATE_ERROR_WARNING &&
> > - new_state <= CAN_STATE_BUS_OFF) {
> > - netdev_dbg(dev, "Error Warning IRQ\n");
> > - priv->can.can_stats.error_warning++;
> > -
> > - cf->can_id |= CAN_ERR_CRTL;
> > - cf->data[1] = (bec.txerr > bec.rxerr) ?
> > - CAN_ERR_CRTL_TX_WARNING :
> > - CAN_ERR_CRTL_RX_WARNING;
> > - }
> > - case CAN_STATE_ERROR_WARNING: /* fallthrough */
> > - /*
> > - * from: ERROR_ACTIVE, ERROR_WARNING
> > - * to : ERROR_PASSIVE, BUS_OFF
> > - * => : error passive int
> > - */
> > - if (new_state >= CAN_STATE_ERROR_PASSIVE &&
> > - new_state <= CAN_STATE_BUS_OFF) {
> > - netdev_dbg(dev, "Error Passive IRQ\n");
>
> Maybe it's a good idea to have netdev_dbg's for state changes in
> can_change_state() as well. Other opinions? Marc?
>
That might be useful. I'll add it.
>
> Apart from these to comments the patches 1-5 look good (but you should
> drop the 6th).
>
Will do.
--
Andri
next prev parent reply other threads:[~2014-12-01 11:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 12:12 [PATCH v4 4/6] can: flexcan: Consolidate and unify state change handling Andri Yngvason
2014-11-30 20:23 ` Wolfgang Grandegger
2014-12-01 11:09 ` Andri Yngvason [this message]
2014-12-01 11:37 ` Wolfgang Grandegger
2014-12-01 11:51 ` Andri Yngvason
2014-12-01 12:02 ` Wolfgang Grandegger
2014-12-01 12:22 ` Andri Yngvason
2014-12-01 19:42 ` Wolfgang Grandegger
2014-12-02 12:49 ` Marc Kleine-Budde
2014-12-02 13:22 ` Andri Yngvason
2014-12-02 13:25 ` 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=20141201110923.29602.38961@shannon \
--to=andri.yngvason@marel.com \
--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 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).