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: flexcan missing error state transitions
Date: Wed, 30 Aug 2017 09:05:27 +0000	[thread overview]
Message-ID: <db68b0a396574fe7883f962863804a4a@SGPMBX1017.APAC.bosch.com> (raw)
In-Reply-To: <5faf942d-4680-45a7-74f2-208a2b9f73f8@grandegger.com>

Hello Wolfgang,

> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
> Sent: Wednesday, August 30, 2017 3:16 PM
> 
> Hello ZHU Yi,
> 
> Am 30.08.2017 um 08:50 schrieb ZHU Yi (ST-FIR/ENG1-Zhu):
> > Hello Wolfgang,
> >
> >> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
> >> Sent: Wednesday, August 30, 2017 2:26 PM
> >>
> >> Am 30.08.2017 um 06:22 schrieb ZHU Yi (ST-FIR/ENG1-Zhu):
> >>>
> >>>> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
> >>>> Sent: Tuesday, August 29, 2017 7:17 PM
> >>>>
> >>>> Am 29.08.2017 um 10:49 schrieb ZHU Yi (ST-FIR/ENG1-Zhu):
> >>>> [...]
> >>>>
> >>>> For the legacy FLEXCAN_QUIRK_BROKEN_ERR_STATE we do not want to
> >>>> disable
> >>>> bus error interrupts as well. To handle that properly, I think we need
> >>> I'm not sure why we do not want to disable error interrupt for legacy broken
> core,
> >>> I think if this approach works for both (with/without warning irq) core, then
> >>> disable the interrupts helps avoid flooding.
> >>
> >> How does it work if no cable is connected?  On a legacy device (with
> >> broken [TR]WRN_INT), no interrupt will arrive other than the bus error
> >> interrupt. Maybe I have missed something. Unfortunately, I do not have
> >> any Flexcan device at hand to check myself.
> > The bus error interrupt means error counter changed, and we can derive correct
> > state from that. Ah, the node needs to try to send something, otherwise,
> > the state will not change, but this is valid for all can controllers.
> 
> Of course, we can always read the error counter on demand. But no
> interrupt will be triggered after the send. How should the state change
> then be realized?
The error interrupt will always be triggered after the send, because the
auto-retransmission will keep getting Ack error if the cable is not connected,
that's where the interrupt flooding come from (and the flooding won't stop
until the cable is connected again).

After the cable is connected, and there're error conditions, e.g., bus short,
the node would eventually go to bus off, in this case, the flooding will stop
when it enter bus off state.

So if auto-retransmission is enabled, then the error interrupt will be generated,
and we can use this to realize the state change. 

As we understood so far, flexcan core does not have register to disable
auto-retransmission. Is this understanding correct?

> 
> >>>>> One more thing regarding patch 2 is, it doesn't rely on error warning
> >>>>> can be reported by [TR]WRN_INT, because this state can also be reported
> >>>>> upon the _any_ interrupt. Only bus-off state needs to have dedicated
> >>>>> interrupt line (is this true for all flexcan core?)
> >>>>
> >>>> I don't think so. How should it work if no cable is connected? Anyway,
> >>>> the patch seems not to be to lenghty.
> >>> I disabled the [TR]WRN_INT on i.MX6 by change
> >>> (http://elixir.free-
> electrons.com/linux/latest/source/drivers/net/can/flexcan.c#L88)
> >>> to:
> >>> #define FLEXCAN_CTRL_ERR_STATE FLEXCAN_CTRL_BOFF_MSK
> >>> and tested with the patch, seems the state transitions still works fine.
> >>
> >> With no cable connected?
> > Yes,
> > 1. Unplug the cable will change to error passive
> 
> No cable is connected. Then do an "ifconfig canX up". Then send  a
> message. The state should change from "active->warning->passive", but
> that's only realized by the driver if an interrupt is received. On
> legacy cores, the bus error interrupt does the trigger. Can you show the
> output of "dmesg| grep flexcan" with "CONFIG_CAN_DEBUG_DEVICES=y" for
> that scenario, or even better the output of:
> 
>    # candump -e -td any,0:0,#FFFFFFFF
> 
> > 2. plug back the cable will eventually change to error active
> > 3. unplug the cable while the bus is recovering to error warning / error active,
> > it will report error passive again
> > 4. repeat plug/unplug the cable and watched the state change as expected
> 
> It may report something, but only if the TX done interrupt occurs.

**Test with [TR]WRN_INT enabled:**
# dmesg | grep flexcan
[    1.560695] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    1.570075] flexcan 2090000.flexcan: can_rx_offload_init_queue: skb_queue_len_max=512
[    1.570660] flexcan 2090000.flexcan: device registered (reg_base=e0a78000, irq=34)
[    6.126129] flexcan 2090000.flexcan mob0: renamed from can0
[  103.057132] flexcan 2090000.flexcan mob0: writing ctrl=0x013a2007
[  103.057161] flexcan 2090000.flexcan mob0: flexcan_set_bittiming: mcr=0x5980000f ctrl=0x013a2007
[  103.057178] flexcan 2090000.flexcan mob0: flexcan_chip_start: writing mcr=0x59a3023f
[  103.057193] flexcan 2090000.flexcan mob0: flexcan_chip_start: writing ctrl=0x013a2057
[  103.057291] flexcan 2090000.flexcan mob0: flexcan_chip_start: reading mcr=0x40a3023f ctrl=0x013aec57
[  163.925178] flexcan 2090000.flexcan mob0: New error state: 1
[  163.926220] flexcan 2090000.flexcan mob0: New error state: 2

# candump -e -td any,0:0,#FFFFFFFF
 (000.000000)  mob0  20000004   [8]  00 08 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}
 (000.001048)  mob0  20000004   [8]  00 20 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-passive}

**Test with [TR]WRN_INT disabled:**
# dmesg | grep flexcan
[    1.561154] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    1.570532] flexcan 2090000.flexcan: can_rx_offload_init_queue: skb_queue_len_max=512
[    1.571125] flexcan 2090000.flexcan: device registered (reg_base=e0a78000, irq=34)
[    6.115142] flexcan 2090000.flexcan mob0: renamed from can0
[   35.931121] flexcan 2090000.flexcan mob0: writing ctrl=0x013a2007
[   35.931149] flexcan 2090000.flexcan mob0: flexcan_set_bittiming: mcr=0x5980000f ctrl=0x013a2007
[   35.931166] flexcan 2090000.flexcan mob0: flexcan_chip_start: writing mcr=0x59a3023f
[   35.931182] flexcan 2090000.flexcan mob0: flexcan_chip_start: writing ctrl=0x013a2057
[   35.931279] flexcan 2090000.flexcan mob0: flexcan_chip_start: reading mcr=0x40a3023f ctrl=0x013ae057
[   64.660324] flexcan 2090000.flexcan mob0: New error state: 1
[   64.661362] flexcan 2090000.flexcan mob0: New error state: 2

# candump -e -td any,0:0,#FFFFFFFF
 (000.000000)  mob0  20000004   [8]  00 08 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}
 (000.001050)  mob0  20000004   [8]  00 20 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-passive}

Best regards
Yi

  reply	other threads:[~2017-08-30  9:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18  7:47 flexcan missing error state transitions 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-22 19:03           ` AW: " Jonas Mark (ST-FIR/ENG1)
2017-08-24  9:40             ` ZHU Yi (ST-FIR/ENG1-Zhu)
2017-08-25 17:16               ` Andri Yngvason
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) [this message]
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
2017-08-26  5:46 朱燚
2017-08-28 11:23 ` Andri Yngvason

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=db68b0a396574fe7883f962863804a4a@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.