From: sashiko-bot@kernel.org
To: "Francesco Valla" <francesco@valla.it>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH] spi: virtio: move teardown to .remove()
Date: Sun, 08 Nov 2026 17:49:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-203892@kernel.org> (raw)
In-Reply-To: <20261108-spi_virtio_remove-v1-1-fda5f0996290@valla.it>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] spi: virtio: virtqueue kick before DRIVER_OK in
virtio_spi_restore() [1]
--
commit 30a7d01f20f6ab641d59ca6ce3ddf0209bd0408f
Author: Francesco Valla <francesco@valla.it>
spi: virtio: move teardown to .remove()
This commit replaces devm-managed controller registration and virtqueue
cleanup with an explicit .remove() callback so the virtio device is reset
before the virtio core checks its status during teardown.
> diff --git a/drivers/spi/spi-virtio.c b/drivers/spi/spi-virtio.c
> index 26f9711c99b39..2eeb79ff5aa26 100644
> --- a/drivers/spi/spi-virtio.c
> +++ b/drivers/spi/spi-virtio.c
[ ... ]
> @@ -347,21 +345,26 @@ static int virtio_spi_probe(struct virtio_device *vdev)
> if (ret)
> return dev_err_probe(&vdev->dev, ret, "Cannot setup virtqueues\n");
>
> - /* Register cleanup for virtqueues using devm */
> - ret = devm_add_action_or_reset(&vdev->dev, virtio_spi_del_vq, vdev);
> - if (ret)
> - return dev_err_probe(&vdev->dev, ret, "Cannot register virtqueue cleanup\n");
> -
> virtio_device_ready(vdev);
>
> - /* Use devm version to register controller */
> - ret = devm_spi_register_controller(&vdev->dev, ctrl);
> - if (ret)
> + ret = spi_register_controller(ctrl);
> + if (ret) {
> + virtio_spi_del_vq(vdev);
> return dev_err_probe(&vdev->dev, ret, "Cannot register controller\n");
> + }
>
> return 0;
> }
>
> +static void virtio_spi_remove(struct virtio_device *vdev)
> +{
> + struct spi_controller *ctrl = dev_get_drvdata(&vdev->dev);
> +
> + spi_unregister_controller(ctrl);
> +
> + virtio_spi_del_vq(vdev);
> +}
> +
> static int virtio_spi_freeze(struct device *dev)
> {
> struct spi_controller *ctrl = dev_get_drvdata(dev);
[Severity: High]
This problem wasn't introduced by this patch, but can virtio_spi_restore()
kick the virtqueue before VIRTIO_CONFIG_S_DRIVER_OK is set [1]?
drivers/spi/spi-virtio.c:virtio_spi_restore() {
...
ret = virtio_spi_find_vqs(vdev->priv);
if (ret) {
dev_err(dev, "problem starting vqueue (%d)\n", ret);
return ret;
}
ret = spi_controller_resume(ctrl);
...
}
Unlike virtio_spi_probe(), which calls virtio_device_ready() before
exposing the controller, virtio_spi_restore() calls
spi_controller_resume() without marking the device ready first:
CPU0 CPU1 (kworker)
virtio_spi_restore()
virtio_spi_find_vqs()
spi_controller_resume()
virtio_spi_transfer_one()
virtqueue_kick() <-- before DRIVER_OK
virtio_device_ready()
Unblocking the SPI message pump wakes the kworker to process queued
transfers and kick the virtqueue before the resume path returns to set
DRIVER_OK, violating the virtio specification and risking dropped SPI
transfers or a broken device state on resume. Calling
virtio_device_ready(vdev) before spi_controller_resume(ctrl) would avoid
this.
[1] https://sashiko.dev/#/bug/linux-82cf02b8-4add-4c6f-b6da-ae25c86bd2bf
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-spi_virtio_remove-v1-1-fda5f0996290@valla.it?part=1
next prev parent reply other threads:[~2026-11-08 17:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 17:41 [PATCH] spi: virtio: move teardown to .remove() Francesco Valla
2026-11-08 17:49 ` sashiko-bot [this message]
2026-11-10 0:58 ` 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=sashiko-outbox-203892@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=francesco@valla.it \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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 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.