public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Steffen Rose <ro@emtas.de>
Cc: linux-can@vger.kernel.org
Subject: Re: unsure - socketCAN blocking
Date: Mon, 08 Oct 2012 13:46:06 +0200	[thread overview]
Message-ID: <5072BCFE.5000006@pengutronix.de> (raw)
In-Reply-To: <6309304.MqJsLKDGaO@lisa>

[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]

On 10/08/2012 12:16 PM, Steffen Rose wrote:
> Hello, 
> I'm unsure, what I see.
> 
> I use:
> Virtual box - Host Win 7/Guest kubuntu 
> Linux lisa 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012 x86_64 
> x86_64 x86_64 GNU/Linux
> 
> SocketCAN connector is a EMS CPC-USB.
> 
> On startup, the network works fine.
> In different situation one or both directions (RX/TX) stop it's work.
> My Linux program say:
> 
> 	write: No buffer space available
> 
> It's the write to the socketcan device can0.

Your program probably produces CAN frames faster than they could be
delivered by your CAN hardware. Your choices are:
1) If the write/sendto system call returns with -ENOBUFS,
   add the filedesciptor to poll/select and wait for it to be writeable
   again. For some known, but not yet resolved reasons (a.k.a. bug),
   the poll/select will return immediately, but the write will fail
   again. To workaround this usleep for some milliseconds between
   the write/sendto and the poll/select system call.

2) Increase txqueue length to 10000 or so.
   (ifconfig can0 txqueuelen 10000)
   This avoids to trigger the above bug and your write/sendto will
   block until the queues are free again and your CAN frame will added
   to the send queue. With this workaround poll/select work as expected,
   i.e. when they return the socket is writeable without problems.

Hope that helps,
Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2012-10-08 11:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 10:16 unsure - socketCAN blocking Steffen Rose
2012-10-08 11:46 ` Marc Kleine-Budde [this message]
2012-10-08 14:36   ` Steffen Rose
2012-10-08 14:56     ` Wolfgang Grandegger
2012-10-08 15:00       ` Marc Kleine-Budde
2012-10-08 15:21         ` Steffen Rose
2012-10-08 15:19       ` Steffen Rose

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=5072BCFE.5000006@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=ro@emtas.de \
    /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