All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup
@ 2026-09-15 20:24 Francesco Valla
  2026-09-15 20:24 ` [PATCH 1/2] spi: virtio: fix max frequency setting Francesco Valla
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Francesco Valla @ 2026-09-15 20:24 UTC (permalink / raw)
  To: Haixu Cui, Mark Brown
  Cc: virtualization, linux-spi, linux-kernel, Francesco Valla

Hello,

while developing a virtio-spi device, I noticed that the spi-virtio
driver in not honoring the indication on the maximum transfer frequency
supported by the device that this one indicates using the config space.
Patch 1 contains a fix for that.

While at it, I did a minor cleanup inside the function parsing the
config space, where a value was stored into the driver's private data
without a further usage, wasting (a very tiny amount of) memory.

This was tested against a (still unreleased) virtio device running on
a Cortex-M33, with remoteproc as virtio transport.

Regards,
Francesco

Signed-off-by: Francesco Valla <francesco@valla.it>
---
Francesco Valla (2):
      spi: virtio: fix max frequency setting
      spi: virtio: drop unused field from private data

 drivers/spi/spi-virtio.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
---
base-commit: 9b87fdc9af2fbfcdb5c24a64139685ef80f6573f
change-id: 20260915-virtio-spi-fix2-ed832a0c069e

Best regards,
--  
Francesco Valla <francesco@valla.it>


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

* [PATCH 1/2] spi: virtio: fix max frequency setting
  2026-09-15 20:24 [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Francesco Valla
@ 2026-09-15 20:24 ` Francesco Valla
  2026-09-15 20:51   ` sashiko-bot
  2026-09-15 20:24 ` [PATCH 2/2] spi: virtio: drop unused field from private data Francesco Valla
  2026-09-17 14:54 ` [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Francesco Valla @ 2026-09-15 20:24 UTC (permalink / raw)
  To: Haixu Cui, Mark Brown
  Cc: virtualization, linux-spi, linux-kernel, Francesco Valla

The maximum transfer frequency is read from the virtio config space but
never propagated to the SPI framework logic. Fix this behavior and drop
the useless setting copy from the driver's private data.

Fixes: f98cabe3f6cf ("SPI: Add virtio SPI driver")
Signed-off-by: Francesco Valla <francesco@valla.it>
---
 drivers/spi/spi-virtio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/spi/spi-virtio.c b/drivers/spi/spi-virtio.c
index 2256dfec5407..033268908bca 100644
--- a/drivers/spi/spi-virtio.c
+++ b/drivers/spi/spi-virtio.c
@@ -33,8 +33,6 @@ struct virtio_spi_priv {
 	struct virtqueue *vq;
 	/* Copy of config space mode_func_supported */
 	u32 mode_func_supported;
-	/* Copy of config space max_freq_hz */
-	u32 max_freq_hz;
 };
 
 static void virtio_spi_msg_done(struct virtqueue *vq)
@@ -304,7 +302,7 @@ static void virtio_spi_read_config(struct virtio_device *vdev)
 		virtio_cread32(vdev, offsetof(struct virtio_spi_config,
 					      bits_per_word_mask));
 
-	priv->max_freq_hz =
+	ctrl->max_speed_hz =
 		virtio_cread32(vdev, offsetof(struct virtio_spi_config,
 					      max_freq_hz));
 }

-- 
2.55.0


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

* [PATCH 2/2] spi: virtio: drop unused field from private data
  2026-09-15 20:24 [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Francesco Valla
  2026-09-15 20:24 ` [PATCH 1/2] spi: virtio: fix max frequency setting Francesco Valla
@ 2026-09-15 20:24 ` Francesco Valla
  2026-09-15 20:52   ` sashiko-bot
  2026-09-17 14:54 ` [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Francesco Valla @ 2026-09-15 20:24 UTC (permalink / raw)
  To: Haixu Cui, Mark Brown
  Cc: virtualization, linux-spi, linux-kernel, Francesco Valla

The mode_func_supported field is read from the config space into the
driver's private data, but then never used outside of the function it is
read in. Drop the variable from the private data and parse it from the
stack instead.

Signed-off-by: Francesco Valla <francesco@valla.it>
---
 drivers/spi/spi-virtio.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-virtio.c b/drivers/spi/spi-virtio.c
index 033268908bca..489970ed7eae 100644
--- a/drivers/spi/spi-virtio.c
+++ b/drivers/spi/spi-virtio.c
@@ -31,8 +31,6 @@ struct virtio_spi_priv {
 	struct virtio_device *vdev;
 	/* Pointer to the virtqueue */
 	struct virtqueue *vq;
-	/* Copy of config space mode_func_supported */
-	u32 mode_func_supported;
 };
 
 static void virtio_spi_msg_done(struct virtqueue *vq)
@@ -256,7 +254,7 @@ static int virtio_spi_transfer_one(struct spi_controller *ctrl,
 static void virtio_spi_read_config(struct virtio_device *vdev)
 {
 	struct spi_controller *ctrl = dev_get_drvdata(&vdev->dev);
-	struct virtio_spi_priv *priv = vdev->priv;
+	u32 mode_func_supported;
 	u8 cs_max_number;
 	u8 tx_nbits_supported;
 	u8 rx_nbits_supported;
@@ -266,18 +264,18 @@ static void virtio_spi_read_config(struct virtio_device *vdev)
 	ctrl->num_chipselect = cs_max_number;
 
 	/* Set the mode bits which are understood by this driver */
-	priv->mode_func_supported =
+	mode_func_supported =
 		virtio_cread32(vdev, offsetof(struct virtio_spi_config,
 					      mode_func_supported));
-	ctrl->mode_bits = priv->mode_func_supported &
+	ctrl->mode_bits = mode_func_supported &
 			  (VIRTIO_SPI_CS_HIGH | VIRTIO_SPI_MODE_LSB_FIRST);
-	if (priv->mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPHA_1)
+	if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPHA_1)
 		ctrl->mode_bits |= VIRTIO_SPI_CPHA;
-	if (priv->mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPOL_1)
+	if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPOL_1)
 		ctrl->mode_bits |= VIRTIO_SPI_CPOL;
-	if (priv->mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LSB_FIRST)
+	if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LSB_FIRST)
 		ctrl->mode_bits |= SPI_LSB_FIRST;
-	if (priv->mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LOOPBACK)
+	if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LOOPBACK)
 		ctrl->mode_bits |= SPI_LOOP;
 	tx_nbits_supported =
 		virtio_cread8(vdev, offsetof(struct virtio_spi_config,

-- 
2.55.0


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

* Re: [PATCH 1/2] spi: virtio: fix max frequency setting
  2026-09-15 20:24 ` [PATCH 1/2] spi: virtio: fix max frequency setting Francesco Valla
@ 2026-09-15 20:51   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-09-15 20:51 UTC (permalink / raw)
  To: Francesco Valla; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez

> The maximum transfer frequency is read from the virtio config space but
> never propagated to the SPI framework logic. Fix this behavior and drop
> the useless setting copy from the driver's private data.
> 
> Fixes: f98cabe3f6cf ("SPI: Add virtio SPI driver")
> Signed-off-by: Francesco Valla <francesco@valla.it>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-virtio-spi-fix2-v1-0-7a474cb1b13b@valla.it?part=1


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

* Re: [PATCH 2/2] spi: virtio: drop unused field from private data
  2026-09-15 20:24 ` [PATCH 2/2] spi: virtio: drop unused field from private data Francesco Valla
@ 2026-09-15 20:52   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-09-15 20:52 UTC (permalink / raw)
  To: Francesco Valla; +Cc: Eugenio Perez, Michael S. Tsirkin, virtualization

> The mode_func_supported field is read from the config space into the
> driver's private data, but then never used outside of the function it is
> read in. Drop the variable from the private data and parse it from the
> stack instead.
> 
> Signed-off-by: Francesco Valla <francesco@valla.it>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-virtio-spi-fix2-v1-0-7a474cb1b13b@valla.it?part=2


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

* Re: [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup
  2026-09-15 20:24 [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Francesco Valla
  2026-09-15 20:24 ` [PATCH 1/2] spi: virtio: fix max frequency setting Francesco Valla
  2026-09-15 20:24 ` [PATCH 2/2] spi: virtio: drop unused field from private data Francesco Valla
@ 2026-09-17 14:54 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-09-17 14:54 UTC (permalink / raw)
  To: Haixu Cui, Francesco Valla; +Cc: virtualization, linux-spi, linux-kernel

On Tue, 15 Sep 2026 22:24:35 +0200, Francesco Valla wrote:
> spi: virtio: fix max frequency setting plus minor cleanup
> 
> Hello,
> 
> while developing a virtio-spi device, I noticed that the spi-virtio
> driver in not honoring the indication on the maximum transfer frequency
> supported by the device that this one indicates using the config space.
> Patch 1 contains a fix for that.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4

Thanks!

[1/2] spi: virtio: fix max frequency setting
      https://git.kernel.org/broonie/spi/c/26f42ca8becd
[2/2] spi: virtio: drop unused field from private data
      https://git.kernel.org/broonie/spi/c/62b223cf4334

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2026-09-18  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 20:24 [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Francesco Valla
2026-09-15 20:24 ` [PATCH 1/2] spi: virtio: fix max frequency setting Francesco Valla
2026-09-15 20:51   ` sashiko-bot
2026-09-15 20:24 ` [PATCH 2/2] spi: virtio: drop unused field from private data Francesco Valla
2026-09-15 20:52   ` sashiko-bot
2026-09-17 14:54 ` [PATCH 0/2] spi: virtio: fix max frequency setting plus minor cleanup Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.