Linux userland API discussions
 help / color / mirror / Atom feed
* [PATCH v2 0/3] spi: spidev: Allow userspace to request DTR transfers
@ 2026-12-01  6:51 Cheng Ming Lin
  2026-12-01  6:52 ` [PATCH v2 1/3] " Cheng Ming Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cheng Ming Lin @ 2026-12-01  6:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-api, Miquel Raynal, alvinzhou

The SPI core can perform Double Transfer Rate transfers through
spi_transfer.dtr_mode on controllers advertising dtr_caps, but there
is currently no way for userspace to request them through spidev.

The first patch reuses the last padding byte of struct spi_ioc_transfer
as a flags field, in an anonymous union with pad, and adds
SPI_IOC_XFER_DTR. As SPI_IOC_MESSAGE never checked that byte, flags are
only honoured by a new SPI_IOC_MESSAGE_FLAGS ioctl (number 6), which
older kernels reject with -ENOTTY instead of silently performing a
regular transfer. SPI_IOC_MESSAGE is unchanged. The struct size and
layout are unchanged as well.

The second patch adds a matching -x/--dtr option to spidev_test, which
uses the new ioctl, and the third one documents the new request in
spidev.rst.

I am happy to change the name or number of the new ioctl if something
else is preferred.

Tested in QEMU with a dummy controller, with and without dtr_caps, from
64-bit and 32-bit userspace, and on a kernel without this series.

Changes in v2:
- Add SPI_IOC_MESSAGE_FLAGS instead of interpreting the padding byte in
  SPI_IOC_MESSAGE, which older kernels silently ignore and existing
  users may not initialise (Mark)
- Make flags an anonymous union with pad so that existing users setting
  pad still build (Mark)
- spidev_test: send -x requests with SPI_IOC_MESSAGE_FLAGS and report
  missing kernel support
- Document SPI_IOC_MESSAGE_FLAGS in spidev.rst
- Drop Miquel's Reviewed-by because of the redesign
- Link to v1: https://lore.kernel.org/r/20261130054931.2441438-1-chengminglin@mxic.com.tw

Cheng Ming Lin (3):
  spi: spidev: Allow userspace to request DTR transfers
  spi: spidev_test: Add an option to request DTR transfers
  spi: spidev: Document SPI_IOC_MESSAGE_FLAGS

 Documentation/spi/spidev.rst    | 10 +++++++-
 drivers/spi/spidev.c            | 43 +++++++++++++++++++++++++--------
 include/uapi/linux/spi/spidev.h | 21 ++++++++++++++--
 tools/spi/spidev_test.c         | 20 ++++++++++++---
 4 files changed, 78 insertions(+), 16 deletions(-)


base-commit: 543bc7b4337302ae75119059bdeff6df8eb34b56
-- 
2.25.1


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

end of thread, other threads:[~2026-12-01  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  6:51 [PATCH v2 0/3] spi: spidev: Allow userspace to request DTR transfers Cheng Ming Lin
2026-12-01  6:52 ` [PATCH v2 1/3] " Cheng Ming Lin
2026-12-01  6:52 ` [PATCH v2 2/3] spi: spidev_test: Add an option " Cheng Ming Lin
2026-12-01  6:52 ` [PATCH v2 3/3] spi: spidev: Document SPI_IOC_MESSAGE_FLAGS Cheng Ming Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox