From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public•gmane.org>
To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public•gmane.org>
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public•gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org
Subject: Re: [PATCH] CAN: Add Flexcan CAN controller driver
Date: Thu, 22 Jul 2010 11:44:53 +0200 [thread overview]
Message-ID: <4C481315.5040200@grandegger.com> (raw)
In-Reply-To: <4C481064.8090809-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On 07/22/2010 11:33 AM, Marc Kleine-Budde wrote:
> Wolfgang Grandegger wrote:
>> On 07/21/2010 10:42 PM, Marc Kleine-Budde wrote:
>>> Marc Kleine-Budde wrote:
>>>> Wolfgang Grandegger wrote:
>>>>> I realized a few issues. You can add my "acked-by" when they are fixed.
>>>> thanks for the review.
>>> [...]
>>>
>>>>>> +static void flexcan_poll_err_frame(struct net_device *dev,
>>>>>> + struct can_frame *cf, u32 reg_esr)
>>>>>> +{
>>>>>> + struct flexcan_priv *priv = netdev_priv(dev);
>>>>>> + int error_warning = 0, rx_errors = 0, tx_errors = 0;
>>>>>> +
>>>>>> + if (reg_esr & FLEXCAN_ESR_BIT1_ERR) {
>>>>>> + rx_errors = 1;
>>>>>> + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
>>>>>> + cf->data[2] |= CAN_ERR_PROT_BIT1;
>>>>>> + }
>>>>>> +
>>>>>> + if (reg_esr & FLEXCAN_ESR_BIT0_ERR) {
>>>>>> + rx_errors = 1;
>>>>>> + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
>>>>>> + cf->data[2] |= CAN_ERR_PROT_BIT0;
>>>>>> + }
>>>>>> +
>>>>>> + if (reg_esr & FLEXCAN_ESR_FRM_ERR) {
>>>>>> + rx_errors = 1;
>>>>>> + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
>>>>>> + cf->data[2] |= CAN_ERR_PROT_FORM;
>>>>>> + }
>>>>>> +
>>>>>> + if (reg_esr & FLEXCAN_ESR_STF_ERR) {
>>>>>> + rx_errors = 1;
>>>>>> + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
>>>>>> + cf->data[2] |= CAN_ERR_PROT_STUFF;
>>>>>> + }
>>>>>> +
>>>>>> +
>>>>>> + if (reg_esr & FLEXCAN_ESR_ACK_ERR) {
>>>>>> + tx_errors = 1;
>>>>>> + cf->can_id |= CAN_ERR_ACK;
>>>>> This is a bus-error as well. Therefore I think it should be:
>>>>>
>>>>> if (reg_esr & FLEXCAN_ESR_ACK_ERR) {
>>>>> tx_errors = 1;
>>>>> cf->can_id |= CAN_ERR_ACK;
>>>>> cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
>>>>> cf->data[3] |= CAN_ERR_PROT_LOC_ACK; /* ACK slot */
>>>>> }
>>>>>
>>>>> I need to check what CAN_ERR_ACK is intended for. Then, cf->can_id could
>>>>> be preset with "CAN_ERR_PROT | CAN_ERR_BUSERROR" at the beginning.
>>> This controller issues an ACK error if there are no other nodes on the
>>> CAN bus to send a ACK that the message has been received. Or all
>>> remaining Nodes are in bus off state.
>>
>> Mainly this bus error can cause the infamous IRQ and message flooding
>> when no cable is connected.
>
> No cable connected can (if your node doesn't have an activated on baord
> termination) result in no termination at all, and this may result in a
> different error.
>
> At least it does on the at91. I haven't checked with the flexcan.
>
> The subtile difference is that the CAN controller isn't allowed to go
> into bus-off with a proper terminated bus when it recevies no ACKs, but
> going to bus off on a not terminated bus is okay.
>
>>> From the datasheet:
>>> "This bit indicates that an acknowledge (ACK) error has been detected by
>>> the transmitter node; that is, a dominant bit has not been detected
>>> during the ACK SLOT."
>>
>> That's what the above error describes, like on the SJA1000, apart from
>> setting CAN_ERR_ACK. Setting CAN_ERR_ACK is somehow bogus, but just
>> leave it for the time being. I will fix it globally when time permits.
>
> Now I'm confused. What's the meaning of CAN_ERR_ACK? When should it be used?
The type of the error is already defined via "CAN_ERR_PROT |
CAN_ERR_BUSERROR". The details of "CAN_ERR_PROT" are described in
data[2..3]. Just for the ACK errors we have CAN_ERR_ACK, but not for the
other bus errors and I ask myself why CAN_ERR_ACK was introduced.
If it does not have another meaning, I tend to remove it (only the AT91
driver actually uses it).
Wolfgang.
next prev parent reply other threads:[~2010-07-22 9:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-14 22:00 [PATCH] CAN: Add Flexcan CAN controller driver Marc Kleine-Budde
[not found] ` <1279144811-12251-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-07-15 9:37 ` Wolfgang Grandegger
[not found] ` <4C3ED6F5.7040606-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-07-15 10:06 ` Marc Kleine-Budde
[not found] ` <4C3EDDB1.5040109-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-07-15 10:21 ` Wolfgang Grandegger
2010-07-15 18:38 ` Wolfgang Grandegger
[not found] ` <4C3F55A9.8030307-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-07-16 13:21 ` Marc Kleine-Budde
[not found] ` <4C405CEC.3000701-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-07-21 20:42 ` Marc Kleine-Budde
[not found] ` <4C475BA6.3030505-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-07-22 9:25 ` Wolfgang Grandegger
[not found] ` <4C480E7E.70607-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-07-22 9:33 ` Marc Kleine-Budde
[not found] ` <4C481064.8090809-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-07-22 9:44 ` Wolfgang Grandegger [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-07-22 16:40 Marc Kleine-Budde
2010-07-22 19:29 ` David Miller
2010-07-25 11:24 ` Oliver Hartkopp
2010-07-25 12:01 ` Marc Kleine-Budde
2010-06-17 14:21 Marc Kleine-Budde
[not found] ` <1276784480-32340-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-06-17 19:12 ` 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=4C481315.5040200@grandegger.com \
--to=wg-5yr1bzd7o62+xt7jha+gda@public$(echo .)gmane.org \
--cc=mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public$(echo .)gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public$(echo .)gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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