linux/drivers/net/dsa/sja1105
Vladimir Oltean 08839c06e9 net: dsa: sja1105: Switch to scatter/gather API for SPI
This reworks the SPI transfer implementation to make use of more of the
SPI core features. The main benefit is to avoid the memcpy in
sja1105_xfer_buf().

The memcpy was only needed because the function was transferring a
single buffer at a time. So it needed to copy the caller-provided buffer
at buf + 4, to store the SPI message header in the "headroom" area.

But the SPI core supports scatter-gather messages, comprised of multiple
transfers. We can actually use those to break apart every SPI message
into 2 transfers: one for the header and one for the actual payload.

To keep the behavior the same regarding the chip select signal, it is
necessary to tell the SPI core to de-assert the chip select after each
chunk. This was not needed before, because each spi_message contained
only 1 single transfer.

The meaning of the per-transfer cs_change=1 is:

- If the transfer is the last one of the message, keep CS asserted
- Otherwise, deassert CS

We need to deassert CS in the "otherwise" case, which was implicit
before.

Avoiding the memcpy creates yet another opportunity. The device can't
process more than 256 bytes of SPI payload at a time, so the
sja1105_xfer_long_buf() function used to exist, to split the larger
caller buffer into chunks.

But these chunks couldn't be used as scatter/gather buffers for
spi_message until now, because of that memcpy (we would have needed more
memory for each chunk). So we can now remove the sja1105_xfer_long_buf()
function and have a single implementation for long and short buffers.

Another benefit is lower usage of stack memory. Previously we had to
store 2 SPI buffers for each chunk. Due to the elimination of the
memcpy, we can now send pointers to the actual chunks from the
caller-supplied buffer to the SPI core.

Since the patch merges two functions into a rewritten implementation,
the function prototype was also changed, mainly for cosmetic consistency
with the structures used within it.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-10-15 13:16:57 -04:00
..
Kconfig net: dsa: sja1105: Add dependency for NET_DSA_SJA1105_TAS 2019-09-21 19:41:19 -07:00
Makefile net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105_clocking.c net: dsa: sja1105: Rename sja1105_spi_send_packed_buf to sja1105_xfer_buf 2019-10-02 12:25:11 -04:00
sja1105_dynamic_config.c net: dsa: sja1105: Rename sja1105_spi_send_packed_buf to sja1105_xfer_buf 2019-10-02 12:25:11 -04:00
sja1105_dynamic_config.h net: dsa: sja1105: Plug in support for TCAM searches via the dynamic interface 2019-06-04 11:49:19 -07:00
sja1105_ethtool.c net: dsa: sja1105: Rename sja1105_spi_send_packed_buf to sja1105_xfer_buf 2019-10-02 12:25:11 -04:00
sja1105_main.c net: dsa: sja1105: Move PTP data to its own private structure 2019-10-14 16:45:40 -07:00
sja1105_ptp.c net: dsa: sja1105: Change the PTP command access pattern 2019-10-14 16:45:40 -07:00
sja1105_ptp.h net: dsa: sja1105: Change the PTP command access pattern 2019-10-14 16:45:40 -07:00
sja1105_spi.c net: dsa: sja1105: Switch to scatter/gather API for SPI 2019-10-15 13:16:57 -04:00
sja1105_static_config.c net: dsa: sja1105: Add static config tables for scheduling 2019-09-16 21:32:57 +02:00
sja1105_static_config.h net: dsa: sja1105: Add static config tables for scheduling 2019-09-16 21:32:57 +02:00
sja1105_tas.c net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105_tas.h net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105.h net: dsa: sja1105: Switch to scatter/gather API for SPI 2019-10-15 13:16:57 -04:00