Skip to content

spi: spi-message transformation framework

[email protected] linux-spi 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 2 repliesIn review
  2. v25 patches 5 repliesSuperseded
  3. v13 patches 13 repliesSuperseded

Changelog from the cover letter

V1->V2: initial split of different transforms into separate patches
but only spi_split_transfer_maxsize was implemented
V2->V3: complete set of transforms implemented in V1 and also merge
transforms was implemented
also contains several fixes based on feedback by Andy Shevchenko minimized code required inside spi-bcm2835 removing all of the

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8spi: core: added spi_resource managementdrivers/spi/spi.c include/linux/spi/spi.h+127 -00 replies
2/8spi: core: add spi_replace_transfers methoddrivers/spi/spi.c include/linux/spi/spi.h+177 -00 replies
3/8spi: core: add spi_split_transfers_maxsizedrivers/spi/spi.c include/linux/spi/spi.h+126 -01 reply
4/8spi: core: added spi_split_transfers_unaligneddrivers/spi/spi.c include/linux/spi/spi.h+219 -01 reply
5/8spi: core: add spi_merge_transfers methoddrivers/spi/spi.c include/linux/spi/spi.h+236 -00 replies
6/8spi: core: add spi_master.translate_messagedrivers/spi/spi.c include/linux/spi/spi.h+19 -00 replies
7/8spi: core: add spi_master.min_dma_len and supporting methodsdrivers/spi/spi.c include/linux/spi/spi.h+79 -10 replies
8/8spi: bcm2835: move to spi-core methods translate_message and can_dmadrivers/spi/spi-bcm2835.c+19 -390 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/8] spi: spi-message transformation framework

From: Martin Sperl <[email protected]>

This patchset implements a spi-message transformation framework in SPI-core, that allows drivers to transfor individual spi messages into something that can more easily get handled by the HW.

This would typically be used for HW which has some limitations on DMA alignment or max transfer sizes.

This patchset implements at this very moment:
* splitting transfers longer than 60k in size into multiple transfers.
* splitting misalligned transfers (there are probably multiple variations necessary for different HW)
* mergeing multiple small transfers into a single transfer

The patch-set essentially is based arround spi resource management on a spi_message basis, which was inspired by devres.

This framework could also get used to handle spi_unmap_buf calls with the framework.

Right now the drivers themselves have to implement spi_master.translate_message, but as soon as the "typical" HW-variations become apparent this may be reduced to assign one of a set of "standard" translation methods to spi_master.translate_message instead, but this may require some additional parametrization of the HW characteristics.

The whole patch set has been tested successfully on a RPI with:
* spi_loopback_test - see below for stats after applying the patch-set
* enc28j60 - note that this driver does do misaligned transfers for rx and for tx resulting in a need to copy data to align the transfer buffers propperly for DMA.
* fb_st7735r - framebuffer playing BigBuckBunny
* mmc-spi with an out of tree patch to work arround the mmc_spi internal dma mapping issues, that inhibits the driver from working correctly - this got introduced with commit 0589342c27944e50 ("of: set dma_mask to point to coherent_dma_mask")

Changelog:
V1->V2: initial split of different transforms into separate patches
but only spi_split_transfer_maxsize was implemented
V2->V3: complete set of transforms implemented in V1 and also merge
transforms was implemented
also contains several fixes based on feedback by Andy Shevchenko minimized code required inside spi-bcm2835 removing all of the

spi_loopback_test produces the following statistics:
==> /sys/class/spi_master/spi32766/statistics/bytes
31840476
==> /sys/class/spi_master/spi32766/statistics/bytes_rx
22629003
==> /sys/class/spi_master/spi32766/statistics/bytes_tx
26926636
==> /sys/class/spi_master/spi32766/statistics/errors
0
==> /sys/class/spi_master/spi32766/statistics/messages
1732
==> /sys/class/spi_master/spi32766/statistics/spi_async
0
==> /sys/class/spi_master/spi32766/statistics/spi_sync
1732
==> /sys/class/spi_master/spi32766/statistics/spi_sync_immediate 1732
==> /sys/class/spi_master/spi32766/statistics/timedout
0
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_0-1 610
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_1024-2047 106
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_128-255 170
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_16-31 313
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_16384-32767 0
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_2048-4095 277
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_2-3 286
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_256-511 48
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_32-63 88
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_32768-65535 464
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_4096-8191 287
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_4-7 143
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_512-1023 158
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_64-127 222
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_65536+ 0
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_8-15 369
==> /sys/class/spi_master/spi32766/statistics/transfer_bytes_histo_8192-16383 20
==> /sys/class/spi_master/spi32766/statistics/transfers
3561
==> /sys/class/spi_master/spi32766/statistics/transfers_merged 540
==> /sys/class/spi_master/spi32766/statistics/transfers_split_maxsize 320
==> /sys/class/spi_master/spi32766/statistics/transfers_split_unaligned 844
==> /sys/class/spi_master/spi32766/statistics/transfers_split_unaligned_copy 492

Martin Sperl (8):
spi: core: added spi_resource management
spi: core: add spi_replace_transfers method
spi: core: add spi_split_transfers_maxsize
spi: core: added spi_split_transfers_unaligned
spi: core: add spi_merge_transfers method
spi: core: add spi_master.translate_message
spi: core: add spi_master.min_dma_len and supporting methods
spi: bcm2835: move to spi-core methods translate_message and can_dma

 drivers/spi/spi-bcm2835.c |   58 +---
 drivers/spi/spi.c         |  848 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/spi/spi.h   |  136 +++++++-
 3 files changed, 1002 insertions(+), 40 deletions(-)

--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html