All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: Stephane Grosjean <s.grosjean@peak-system.com>,
	ajneu <ajneu1@gmail.com>,
	linux-can@vger.kernel.org
Subject: Re: Bug? -- NEVER getting controller-problem{back-to-error-active}
Date: Tue, 21 Jun 2016 11:58:35 +0200	[thread overview]
Message-ID: <57690FCB.70603@grandegger.com> (raw)
In-Reply-To: <eccb6d7c-b451-8f8a-d6c1-c2675002d424@peak-system.com>

Hello Stephane,

Am 21.06.2016 um 10:29 schrieb Stephane Grosjean:
> Hi,
>
> The reason of this:
>
>          } else {
>                  /* no error bit (so, no error skb, back to active
> state) */
>                  dev->can.state = CAN_STATE_ERROR_ACTIVE;
>                  pdev->bec.txerr = 0;
>                  pdev->bec.rxerr = 0;
>                  return 0;
>          }
>
> is given by the comment: AFAIR in these times, going (back) to
> ACTIVE_STATE was made like above, by the device driver itself.

Well, in the past we didn't care about *decreasing* state changes but 
new driver should, and this does include the "back-to-error-active" 
message, which is automatically generated by "change_state()". So far, 
only a few driver are using that function:

   $ grep -rl can_change_state .
   ./sja1000/sja1000.c
   ./usb/peak_usb/pcan_usb_fd.c
   ./usb/kvaser_usb.c
   ./flexcan.c
   ./mscan/mscan.c

> The lower condition:
>
>          /* allocate an skb to store the error frame */
>          skb = alloc_can_err_skb(netdev, &cf);
>          if (skb)
>                  can_change_state(netdev, cf, tx_state, rx_state);
>
> uses can_change_state() if and only if "skb" is not NULL, while there
> was no need of any skb to go (back) to ACTIVE_STATE.
>
> So, I suppose that the proposed change should also include something
> like the following one:
>
>           /* allocate an skb to store the error frame */
>           skb = alloc_can_err_skb(netdev, &cf);
> -        if (skb)
> +        if (skb || (new_state == CAN_STATE_ERROR_ACTIVE))
>                   can_change_state(netdev, cf, tx_state, rx_state);

can_change_state() should not be called if "skb" is NULL (because cf is 
not valid).

Wolfgang.

      reply	other threads:[~2016-06-21 10:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20  9:12 Bug? -- NEVER getting controller-problem{back-to-error-active} ajneu
2016-06-20  9:22 ` ajneu
2016-06-20 10:33 ` Wolfgang Grandegger
2016-06-20 12:41   ` ajneu
2016-06-20 13:00   ` ajneu
2016-06-20 13:31     ` Wolfgang Grandegger
2016-06-20 13:53       ` ajneu
2016-06-20 14:28         ` Wolfgang Grandegger
2016-06-21  8:29           ` Stephane Grosjean
2016-06-21  9:58             ` Wolfgang Grandegger [this message]

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=57690FCB.70603@grandegger.com \
    --to=wg@grandegger.com \
    --cc=ajneu1@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=s.grosjean@peak-system.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.