mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Jonas Rebmann <jre@pengutronix.de>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	kernel@pengutronix.de
Subject: Re: [PATCH 6/7] spi: spidev_test: add option to split message into multiple transfers
Date: Mon, 14 Sep 2026 19:04:04 +0100	[thread overview]
Message-ID: <aqg3FFSZDLe_WI9Q@sirena.org.uk> (raw)
In-Reply-To: <20260914-spi-sun4i-spidev_test-v1-6-72d6a3b38cee@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

On Mon, Sep 14, 2026 at 04:50:45PM +0200, Jonas Rebmann wrote:

> SPI_IOC_MESSAGE() submits a single SPI message containing one or more
> transfers. Introduce an option to allow splitting the message into
> multiple transfers.

> +	size_t bytes_per_word = DIV_ROUND_UP(bits, 8);
> +	int effective_transfers = min_t(int, transfers, DIV_ROUND_UP(len, bytes_per_word));

We divide by this and nothing stops us triggering a divide by 0.

> +	struct spi_ioc_transfer tr[effective_transfers];

This could easily get very big if someone decides to test lots of small
transfers, it's probably worth moving off the stack at this point.

> +	size_t len_per_transfer = ALIGN(DIV_ROUND_UP(len, effective_transfers), bytes_per_word);

The kernel's ALIGN() macro only works for powers of two.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-09-14 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 14:50 [PATCH 0/7] spi: spidev_test: new features Jonas Rebmann
2026-09-14 14:50 ` [PATCH 1/7] spi: spidev_test: include tools/include Jonas Rebmann
2026-09-14 14:50 ` [PATCH 2/7] spi: spidev_test: add compare mode Jonas Rebmann
2026-09-14 17:03   ` Mark Brown
2026-09-14 14:50 ` [PATCH 3/7] spi: spidev_test: allow disabling rx or tx buffers Jonas Rebmann
2026-09-14 17:20   ` Mark Brown
2026-09-14 14:50 ` [PATCH 4/7] spi: spidev_test: don't send 0x0 or 0xff Jonas Rebmann
2026-09-14 17:22   ` Mark Brown
2026-09-14 14:50 ` [PATCH 5/7] spi: spidev_test: send predictable data Jonas Rebmann
2026-09-14 14:50 ` [PATCH 6/7] spi: spidev_test: add option to split message into multiple transfers Jonas Rebmann
2026-09-14 18:04   ` Mark Brown [this message]
2026-09-14 14:50 ` [PATCH 7/7] spi: spidev_test: print TX on error Jonas Rebmann
2026-09-14 18:07   ` Mark Brown

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=aqg3FFSZDLe_WI9Q@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=jre@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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

all inboxes | Powered by JetHome®