All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] can: enable multi-queue for SocketCAN devices
@ 2018-06-05 18:43 ` Mark Jonas
  0 siblings, 0 replies; 32+ messages in thread
From: Mark Jonas @ 2018-06-05 18:43 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde
  Cc: linux-can, netdev, linux-kernel, hs, yi.zhu5, Mark Jonas

Upon request by Marc Kleine-Budde this patch series does not only
contain our patch to enable enable multi-queue for SocketCAN devices
but also a driver (Companion driver suite) which makes active use of
this feature.

The driver suite implements
  - two CAN interfaces
  - one generic command interfaces
and offers a SocketCAN as well as a char device interface. The
SocketCAN interface supports multi-queue.

The functionality bases on an external peripheral chip named Companion.
It offers two CAN interfaces, each has 8 prioritized transmit FIFOs as
well as one receive FIFO. Besides CAN, undisclosed additional functions
can be accessed through the char device.

A standard SPI interface with two additional lines for flow control is
used. The Companion chip is the SPI slave.

The driver suite consists of three separate drivers. The following
diagram illustrates the dependencies in layers.

           /dev/companion       SocketCAN                User Space
-------------------------------------------------------------------
         +----------------+ +---------------+
         | companion-char | | companion-can |
         +----------------+ +---------------+
         +----------------------------------+
         |          companion-spi           |
         +----------------------------------+
         +----------------------------------+
         |     standard SPI subsystem       |
         +----------------------------------+          Linux Kernel
-------------------------------------------------------------------
               | | | |      | |                            Hardware
            CS-+ | | |      | +-BUSY
            CLK--+ | |      +---REQUEST
            MOSI---+ |
            MISO-----+

companion-spi
   core.c: handles SPI, sysfs entry and interface to upper layer
   protocol-manager.c: handles protocol with the SPI HW
   queue-manager.c: handles buffering and packets scheduling

companion-can
   makes use of multi-queue support and allows to use tc to configure
   the queuing discipline (e.g. mqprio). Together with the SO_PRIORITY
   socket option this allows to specify the FIFO a CAN frame shall be
   sent to.

companion-char
   handles messages to other undisclosed functionality beyond CAN.

Zhu Yi (5):
  can: enable multi-queue for SocketCAN devices
  spi: implement companion-spi driver
  char: implement companion-char driver
  can: implement companion-can driver
  spi,can,char: add companion DT binding documentation

 .../devicetree/bindings/spi/bosch,companion.txt    |   82 ++
 drivers/char/Kconfig                               |    7 +
 drivers/char/Makefile                              |    2 +
 drivers/char/companion-char.c                      |  367 ++++++
 drivers/net/can/Kconfig                            |    8 +
 drivers/net/can/Makefile                           |    1 +
 drivers/net/can/companion-can.c                    |  694 ++++++++++++
 drivers/net/can/dev.c                              |    8 +-
 drivers/spi/Kconfig                                |    2 +
 drivers/spi/Makefile                               |    2 +
 drivers/spi/companion/Kconfig                      |    5 +
 drivers/spi/companion/Makefile                     |    2 +
 drivers/spi/companion/core.c                       | 1189 ++++++++++++++++++++
 drivers/spi/companion/protocol-manager.c           | 1035 +++++++++++++++++
 drivers/spi/companion/protocol-manager.h           |  348 ++++++
 drivers/spi/companion/protocol.h                   |  273 +++++
 drivers/spi/companion/queue-manager.c              |  146 +++
 drivers/spi/companion/queue-manager.h              |  245 ++++
 include/linux/can/dev.h                            |    7 +-
 include/linux/companion.h                          |  258 +++++
 20 files changed, 4677 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/spi/bosch,companion.txt
 create mode 100644 drivers/char/companion-char.c
 create mode 100644 drivers/net/can/companion-can.c
 create mode 100644 drivers/spi/companion/Kconfig
 create mode 100644 drivers/spi/companion/Makefile
 create mode 100644 drivers/spi/companion/core.c
 create mode 100644 drivers/spi/companion/protocol-manager.c
 create mode 100644 drivers/spi/companion/protocol-manager.h
 create mode 100644 drivers/spi/companion/protocol.h
 create mode 100644 drivers/spi/companion/queue-manager.c
 create mode 100644 drivers/spi/companion/queue-manager.h
 create mode 100644 include/linux/companion.h

-- 
2.7.4

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] spi: implement companion-spi driver
@ 2018-06-08  6:56 Jonas Mark (BT-FIR/ENG1)
  2018-06-08  7:05 ` Oleksij Rempel
  0 siblings, 1 reply; 32+ messages in thread
From: Jonas Mark (BT-FIR/ENG1) @ 2018-06-08  6:56 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Andy Shevchenko, Wolfgang Grandegger, Marc Kleine-Budde,
	linux-can, netdev, Linux Kernel Mailing List, Heiko Schocher,
	ZHU Yi (BT-FIR/ENG1-Zhu), Jonas Mark (BT-FIR/ENG1)

Hi Oleksij,

> > > > +               if (slave_is_not_busy(priv))
> > > > +                       return 0;
> > > > +
> > >
> > > > +               udelay(READY_POLL_US_GRAN);
> > >
> > > Should it be atomic?
> > > Can it use read_poll_* type of helpers instead?
> >
> > Yes, it shall be atomic because we need to reduce the latency at
> > detecting the de-assertion of the busy signal. We accept that this will
> > cost CPU time.
> >
> > In case the Companion itself is very busy and does not reply quickly we
> > are have second polling loop below which sleeps longer and is non-atomic.
> 
> I can confirm, this make huge impact on protocol performance. And this
> protocol is not really the speed runner.

The challenge is that the protocol is synchronous and without back to
back transfers.

> you can send dummy message to set CS.
> +	struct spi_transfer t = {
> +		.len = 0,
> +		.cs_change = 1,
> +	};
> 
> +	/* send dummy to trigger CS */
> +	reinit_completion(&priv->fc_complete);
> +	spi_sync_locked(spi, &m);
> 
> see my ancient unfinished code:
> https://patchwork.kernel.org/patch/9418511/

We will check it out.

> In general, this part of the code, can be provided as separate driver
> which should be called as "SPI 5wire protocol". 3 wires for data, 1 -
> chip select, 1 - busy state. Since, the slave cant fit to normal SPI
> requirements, and can't be ready within predictable time, busy signal is
> needed. Providing this as separate driver or part of SPI framework
> should reduce the code for many different drivers.
> 
> The actual datagram on top of your spi companion should go to
> separate driver. There are similar (almost identical designs)
> 
> can :+
> char:+
> dw:  +
> gpio:+--->some_multi_end_mux_protocol--->spi_5wire_protocol->spi--->
> 
> In my knowledge, only data format on top of spi_5wire_protocol is
> different. See my notes for similar topics:
> https://github.com/olerem/icc
> https://github.com/olerem/spi-5wire

With 5-wire protocol you are referencing to CLK, MISO, MOSI, CS (all
standard SPI signals) and an extra BUSY signal. What we implemented is
a 6-wire protocol. There is an additional REQUEST line where the SPI
slave requests a transfer. It is like a level triggered interrupt
request.

Yes, for making it more generic the code in drivers/spi/companion
could be split into a generic 6-wire protocol driver and a multiplexing
protocol on top of it.

How does a slave signal that it has data to be picked up with the
5-wire protocol?

Greetings,
Mark

Building Technologies, Panel Software Fire (BT-FIR/ENG1) 
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118 
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Gert van Iperen, Andreas Bartz, Thomas Quante, Bernhard Schuster

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-07-20 14:34 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 18:43 [PATCH 0/5] can: enable multi-queue for SocketCAN devices Mark Jonas
2018-06-05 18:43 ` Mark Jonas
2018-06-05 18:43 ` [PATCH 1/5] " Mark Jonas
2018-06-05 18:43   ` Mark Jonas
2018-06-05 18:43 ` [PATCH 2/5] spi: implement companion-spi driver Mark Jonas
2018-06-05 18:43   ` Mark Jonas
2018-06-06 18:47   ` Andy Shevchenko
2018-06-07 14:58     ` AW: " Jonas Mark (BT-FIR/ENG1)
2018-06-08  6:03       ` Oleksij Rempel
2018-06-05 18:43 ` [PATCH 3/5] char: implement companion-char driver Mark Jonas
2018-06-05 18:43   ` Mark Jonas
2018-06-05 18:43 ` [PATCH 4/5] can: implement companion-can driver Mark Jonas
2018-06-05 18:43   ` Mark Jonas
2018-06-05 18:44 ` [PATCH 5/5] spi,can,char: add companion DT binding documentation Mark Jonas
2018-06-05 18:44   ` Mark Jonas
2018-06-06 18:06 ` [PATCH 0/5] can: enable multi-queue for SocketCAN devices Andy Shevchenko
2018-06-07  7:22 ` Oliver Hartkopp
2018-06-13 14:37 ` [PATCH v2 " Mark Jonas
2018-06-13 14:37   ` Mark Jonas
2018-06-13 14:37   ` [PATCH v2 1/5] " Mark Jonas
2018-06-13 14:37     ` Mark Jonas
2018-07-20 14:34     ` Marc Kleine-Budde
2018-06-13 14:37   ` [PATCH v2 2/5] spi: implement companion-spi driver Mark Jonas
2018-06-13 14:37     ` Mark Jonas
2018-06-13 14:37   ` [PATCH v2 3/5] char: implement companion-char driver Mark Jonas
2018-06-13 14:37     ` Mark Jonas
2018-06-13 14:37   ` [PATCH v2 4/5] can: implement companion-can driver Mark Jonas
2018-06-13 14:37     ` Mark Jonas
2018-06-13 14:37   ` [PATCH v2 5/5] spi,can,char: add companion DT binding documentation Mark Jonas
2018-06-13 14:37     ` Mark Jonas
2018-06-08  6:56 [PATCH 2/5] spi: implement companion-spi driver Jonas Mark (BT-FIR/ENG1)
2018-06-08  7:05 ` Oleksij Rempel

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.