All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Alexander Stein <alexander.stein@systec-electronic.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: Bitrate and CAN status support for slcan
Date: Sat, 19 Apr 2014 21:24:28 +0200	[thread overview]
Message-ID: <5352CD6C.2090601@hartkopp.net> (raw)
In-Reply-To: <1397573468-7619-1-git-send-email-alexander.stein@systec-electronic.com>

Hello Alexander,

IMO your entire patch set has a major design flaw.

The general serial line discipline concept is a data encapsulation driver
which converts PDUs into a serial line data stream.

If you check other implementations of serial line disciplines from

http://lxr.free-electrons.com/source/include/uapi/linux/tty.h

you'll see that their functionality is to encapsulate datagramms and/or
support different modes for this functionality on the serial line.

There's no interaction on the serial stream triggered by open/close of the
device - which additionally breaks the current userspace, which assumes to be
responsible for the ASCII open/close commands.

And when there are working queues that talk to the serial line, these are e.g.
for line fills to prevent tty hangups.

I don't know if the first CAN frame can get lost when slcand issues the open
command and then switches to the line discipline with the ioctl() ???

Therefore the idea to create the open/close commands in slcan.c *may* prevent
a race condition at startup. Do you know whether the received ASCII characters
remain queued when they are not read by slcand which controls the tty until
the line discipline is switched to slcan.c ??

When this is really needed to prevent this kind of startup glitch the
open/close commands need to be created by newly introduced ioctl() calls, so
that slcand can check if the (new) ioctl() exists to decide if it has to send
the ASCII 'open' command before the ldisc ioctl() OR send the 'open' ioctl()
after the ldisc ioctl().

Same problem with the status polling:
It introduces a functionality which has impacts to statistics depending on the
given poll rate. Are the values consumed with answer to the 'F' command or
does the next polled status represent the same status content?

You introduced an automatism which does not look reliable to me.

What about creating a 'F' command on the serial line when you send a CAN frame
with the CAN_ERR_FLAG set down to the slcan device?
The answer of the slcan device can then be converted to a CAN frame similar to
the way you suggested in patch 5.

Finally the bitrate setting approach is broken too:
1. it breaks the serial line discipline design again
2. there's obviously no race problem which is potentially solved
3. there's no bittiming_const which is needed to fill the bitrate via ip tool

Summary:

- Can you please double check if there's a change for a race condition in the
'open' command before the ldisc ioctl() which may? lead to drop the first CAN
frame? I assume there's no such problem as every other line discipline would
have a similar problem then. And if there's no race there's no need to put
open/close into the driver.

- Remove the bitrate setting stuff
- Don't make the slcan driver depend on the CAN_DEV stuff: It's just
encapsulation which is done in slcan.c - it's no really a CAN controller driver.

Sorry but finally only the 'on demand' retrieval of the SLCAN status via
CAN_ERR_FLAG set in a sent CAN frame looks like a potentially valuable
improvement to me.

Thanks for your contribution & best regards,
Oliver

On 15.04.2014 16:51, Alexander Stein wrote:
> This series adds bitrate selection support. It uses the API described
> in the SLCAN-API which is identical on all listed serial interfaces.
> Thus slcan only supports that limited set of bitrates, as only a bitrate
> index is sent over serial wire.
> Patch 5 also adds support for CAN status polling. This has do be done
> regulrarly from CPU side.
> Tests have been done on a LAWICEL CANUSB device.


  parent reply	other threads:[~2014-04-19 19:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15 14:51 Bitrate and CAN status support for slcan Alexander Stein
2014-04-15 14:51 ` [PATCH 1/5] can: slcan: Fix spinlock variant Alexander Stein
2014-04-22 19:58   ` Oliver Hartkopp
2014-04-24 20:32   ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 2/5] can: slcan: Convert to can_dev interface Alexander Stein
2014-04-17 19:10   ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 3/5] can: slcan: Send open/close command upon interface up/down Alexander Stein
2014-04-15 14:51 ` [PATCH 4/5] can: slcan: Add bitrate change support Alexander Stein
2014-04-17 19:13   ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 5/5] can: slcan: Add CAN status flag support Alexander Stein
2014-04-17 19:22   ` Marc Kleine-Budde
2014-04-19 20:38   ` Oliver Hartkopp
2014-04-19 19:24 ` Oliver Hartkopp [this message]
2014-04-22  7:08   ` Bitrate and CAN status support for slcan Alexander Stein
2014-04-22 19:50     ` Oliver Hartkopp

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=5352CD6C.2090601@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=alexander.stein@systec-electronic.com \
    --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.