From: Alexander Stein <alexander.stein@systec-electronic.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>,
Efim Monjak <emonjak@lipowsky.de>,
linux-can@vger.kernel.org
Subject: Re: at91 driver lost CAN messages
Date: Mon, 20 Mar 2017 08:38:24 +0100 [thread overview]
Message-ID: <3175996.kn8FdFnuFm@ws-stein> (raw)
In-Reply-To: <85ad9a0c-50be-f7b1-4465-ecfdce02df75@pengutronix.de>
On Thursday 16 March 2017 11:18:33, Marc Kleine-Budde wrote:
> On 03/16/2017 10:58 AM, Alexander Stein wrote:
> >>> Let's see if I get time to cook rx-offload on a USB driver.
> >>
> >> That would be highly appreciated :-)
> >
> > Mh, at a first glance I don't know how to do that, actually. AFAICS
> > rx-offload does not support 'pushing' struct can_frame into the
> > queue, only pulling from rx-offload. There is no fixed connection
> > bewteen the internal can device structure and CAN frames, like
> > hardware message boxes. In order to use
> > can_rx_offload_irq_offload_fifo() to insert (mostly) a single
> > can_frame I would need to store the last urb. I think I need to add a
> > function similar to can_rx_offload_irq_queue_err_skb(), e.g.
> > can_rx_offload_irq_queue_skb, but without scheduling. This should be
> > done once the urb was completly read.
>
> Does your device support multiple CAN frames per USB?
Yes, it does. Although this will happen rarely actually. As several URBs are
submitted at once, each URB should only deliver a single CAN frame as this is
much faster. So in order to receive more CAN frames per URB the USB host (or
driver) needs to be delayed for long time so the CAN frames queue up on the
device itself.
> Maybe rename
>
> > int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload,
> > struct sk_buff *skb)
> into can_rx_offload_irq_queue_skb() or
>
> can_rx_offload_irq_queue_skb_schedule() and fix the race condition:
> > int can_rx_offload_irq_queue_skb(struct can_rx_offload *offload, struct
> > sk_buff *skb) {
>
> take spinlock
>
> > if (skb_queue_len(&offload->skb_queue) >
> >
> > offload->skb_queue_len_max)
>
> release in case of error
>
> > return -ENOMEM;
> >
> > skb_queue_tail(&offload->skb_queue, skb);
>
> use unlocked variant of skb_queue_tail, i.e. __skb_queue_tail()
>
> release spin lock
>
> > can_rx_offload_schedule(offload);
> >
> > return 0;
> >
> > }
>
> Then factor all but the can_rx_offload_schedule(offload) call into a
> separate function.
I will think about this. I'm afraid but currently I can't do anything about
that. But this will only work for (USB) CAN drivers though. Ethernet USB
drivers also suffer from the out-of-order issue as they also push their SKB in
IRQ context. I've seen reorder warnings in wireshark on a direct link iperf
transfer.
Best regards,
Alexander
--
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
alexander.stein@systec-electronic.com
Legal and Commercial Address:
Am Windrad 2
08468 Heinsdorfergrund
Germany
Office: +49 (0) 3765 38600-0
Fax: +49 (0) 3765 38600-4100
Managing Directors:
Director Technology/CEO: Dipl.-Phys. Siegmar Schmidt;
Director Commercial Affairs/COO: Dipl. Ing. (FH) Armin von Collrepp
Commercial Registry:
Amtsgericht Chemnitz, HRB 28082; USt.-Id Nr. DE150534010
next prev parent reply other threads:[~2017-03-20 7:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 13:48 at91 driver lost CAN messages Efim Monjak
2017-03-11 23:06 ` Oliver Hartkopp
2017-03-13 6:54 ` Alexander Stein
2017-03-13 9:47 ` Marc Kleine-Budde
2017-03-16 8:01 ` Oliver Hartkopp
2017-03-16 8:34 ` Marc Kleine-Budde
2017-03-16 9:06 ` Alexander Stein
2017-03-16 9:09 ` Oliver Hartkopp
2017-03-16 9:58 ` Alexander Stein
2017-03-16 10:18 ` Marc Kleine-Budde
2017-03-20 7:38 ` Alexander Stein [this message]
2017-03-16 9:07 ` Oliver Hartkopp
2017-03-16 9:24 ` Efim Monjak
2017-03-16 9:32 ` Marc Kleine-Budde
2017-03-16 10:06 ` Efim Monjak
2017-03-16 10:11 ` Marc Kleine-Budde
2017-03-13 9:47 ` Marc Kleine-Budde
2017-03-13 12:55 ` Efim Monjak
2017-03-13 13:11 ` Marc Kleine-Budde
2017-03-13 15:17 ` Efim Monjak
2017-03-13 14:23 ` 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=3175996.kn8FdFnuFm@ws-stein \
--to=alexander.stein@systec-electronic.com \
--cc=emonjak@lipowsky.de \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
/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.