* [PATCH] spi: virtio: fix mode bits propagation from device to driver
@ 2026-11-29 20:32 Francesco Valla
2026-11-29 20:36 ` sashiko-bot
2026-11-30 19:20 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Francesco Valla @ 2026-11-29 20:32 UTC (permalink / raw)
To: Mark Brown; +Cc: virtualization, linux-spi, stable, Francesco Valla
The initial value of the device's mode_bits is set with an incorrect
mask, because VIRTIO_SPI_CS_HIGH and VIRTIO_SPI_MODE_LSB_FIRST are not
meant for the propagation of device capabilities but for transfers.
This has the effect of:
- setting SPI_CS_HIGH when the device advertises support for CPOL=0;
- setting SPI_LSB_FIRST when the device advertises support for CPOL=1;
- completely ignoring the CS_HIGH support advertised by the device.
Use the correct VIRTIO_SPI_MF_ macros instead.
While at it, use the correct macros also for the mode_bits assignments
that follow, selecting the ones from the spi namespace (no functional
change there, since their value is the same as the corresponding ones
from the virtio namespace).
Fixes: f98cabe3f6cf ("SPI: Add virtio SPI driver")
Cc: stable@vger.kernel.org
Signed-off-by: Francesco Valla <francesco@valla.it>
---
drivers/spi/spi-virtio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-virtio.c b/drivers/spi/spi-virtio.c
index 2eeb79ff5aa2..66edc4dae02a 100644
--- a/drivers/spi/spi-virtio.c
+++ b/drivers/spi/spi-virtio.c
@@ -265,12 +265,13 @@ static void virtio_spi_read_config(struct virtio_device *vdev)
mode_func_supported =
virtio_cread32(vdev, offsetof(struct virtio_spi_config,
mode_func_supported));
- ctrl->mode_bits = mode_func_supported &
- (VIRTIO_SPI_CS_HIGH | VIRTIO_SPI_MODE_LSB_FIRST);
+ ctrl->mode_bits = 0;
+ if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CS_HIGH)
+ ctrl->mode_bits |= SPI_CS_HIGH;
if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPHA_1)
- ctrl->mode_bits |= VIRTIO_SPI_CPHA;
+ ctrl->mode_bits |= SPI_CPHA;
if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_CPOL_1)
- ctrl->mode_bits |= VIRTIO_SPI_CPOL;
+ ctrl->mode_bits |= SPI_CPOL;
if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LSB_FIRST)
ctrl->mode_bits |= SPI_LSB_FIRST;
if (mode_func_supported & VIRTIO_SPI_MF_SUPPORT_LOOPBACK)
---
base-commit: ca20d5a011d35fc25e328fe31ac47f7aae557c5a
change-id: 20261129-spi-virtio-modebits-fix-10c734535167
Best regards,
--
Francesco Valla <francesco@valla.it>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: virtio: fix mode bits propagation from device to driver
2026-11-29 20:32 [PATCH] spi: virtio: fix mode bits propagation from device to driver Francesco Valla
@ 2026-11-29 20:36 ` sashiko-bot
2026-11-30 19:20 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-29 20:36 UTC (permalink / raw)
To: Francesco Valla; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> The initial value of the device's mode_bits is set with an incorrect
> mask, because VIRTIO_SPI_CS_HIGH and VIRTIO_SPI_MODE_LSB_FIRST are not
> meant for the propagation of device capabilities but for transfers.
> This has the effect of:
>
> - setting SPI_CS_HIGH when the device advertises support for CPOL=0;
> - setting SPI_LSB_FIRST when the device advertises support for CPOL=1;
> - completely ignoring the CS_HIGH support advertised by the device.
>
> Use the correct VIRTIO_SPI_MF_ macros instead.
>
> While at it, use the correct macros also for the mode_bits assignments
> that follow, selecting the ones from the spi namespace (no functional
> change there, since their value is the same as the corresponding ones
> from the virtio namespace).
>
> Fixes: f98cabe3f6cf ("SPI: Add virtio SPI driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Francesco Valla <francesco@valla.it>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129-spi-virtio-modebits-fix-v1-1-0a406aff25f7@valla.it?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: virtio: fix mode bits propagation from device to driver
2026-11-29 20:32 [PATCH] spi: virtio: fix mode bits propagation from device to driver Francesco Valla
2026-11-29 20:36 ` sashiko-bot
@ 2026-11-30 19:20 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-11-30 19:20 UTC (permalink / raw)
To: Francesco Valla; +Cc: virtualization, linux-spi, stable
On Sun, 29 Nov 2026 21:32:16 +0100, Francesco Valla wrote:
> spi: virtio: fix mode bits propagation from device to driver
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4
Thanks!
[1/1] spi: virtio: fix mode bits propagation from device to driver
https://git.kernel.org/broonie/spi/c/4a55c15e6024
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] 3+ messages in thread
end of thread, other threads:[~2026-12-01 11:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 20:32 [PATCH] spi: virtio: fix mode bits propagation from device to driver Francesco Valla
2026-11-29 20:36 ` sashiko-bot
2026-11-30 19:20 ` 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.