Linux userland API discussions
 help / color / mirror / Atom feed
From: Cheng Ming Lin <linchengming884@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-api@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	alvinzhou@mxic.com.tw
Subject: [PATCH v2 0/3] spi: spidev: Allow userspace to request DTR transfers
Date: Tue,  1 Dec 2026 14:51:59 +0800	[thread overview]
Message-ID: <20261201065202.2667609-1-chengminglin@mxic.com.tw> (raw)

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


             reply	other threads:[~2026-12-01  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  6:51 Cheng Ming Lin [this message]
2026-12-01  6:52 ` [PATCH v2 1/3] spi: spidev: Allow userspace to request DTR transfers 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

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=20261201065202.2667609-1-chengminglin@mxic.com.tw \
    --to=linchengming884@gmail.com \
    --cc=alvinzhou@mxic.com.tw \
    --cc=broonie@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=miquel.raynal@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox