* [PATCH] virtio_input: Improve freeze handling
[not found] <CGME20250812095108epcas5p3aebdbf9e790cd259173d54611652a97b@epcas5p3.samsung.com>
@ 2025-08-12 9:51 ` Ying Gao
[not found] ` <CGME20250825020428epcas5p16a3306486407502504ca75bbe549927e@epcas5p1.samsung.com>
0 siblings, 1 reply; 2+ messages in thread
From: Ying Gao @ 2025-08-12 9:51 UTC (permalink / raw)
To: kraxel, mst, jasowang
Cc: xuanzhuo, eperezma, virtualization, linux-kernel, ying123.xu,
lei19.wang, liping.qi, junnan01.wu, Ying Gao
When executing suspend to ram, if lacking the operations
to reset device and free unused buffers before deleting
a vq, resource leaks and inconsistent device status will
appear.
According to chapter "3.3.1 Driver Requirements: Device Cleanup:"
of virtio-specification:
Driver MUST ensure a virtqueue isn’t live
(by device reset) before removing exposed
buffers.
Therefore, modify the virtinput_freeze function to reset the
device and delete the unused buffers before deleting the
virtqueue, just like virtinput_remove does.
Co-developed-by: Ying Xu <ying123.xu@samsung.com>
Signed-off-by: Ying Xu <ying123.xu@samsung.com>
Co-developed-by: Junnan Wu <junnan01.wu@samsung.com>
Signed-off-by: Junnan Wu <junnan01.wu@samsung.com>
Signed-off-by: Ying Gao <ying01.gao@samsung.com>
---
drivers/virtio/virtio_input.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index a5d63269f20b..d0728285b6ce 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -360,11 +360,15 @@ static int virtinput_freeze(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
unsigned long flags;
+ void *buf;
spin_lock_irqsave(&vi->lock, flags);
vi->ready = false;
spin_unlock_irqrestore(&vi->lock, flags);
+ virtio_reset_device(vdev);
+ while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
+ kfree(buf);
vdev->config->del_vqs(vdev);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH V2 RESEND] virtio_input: Improve freeze handling
[not found] ` <CGME20250825020428epcas5p16a3306486407502504ca75bbe549927e@epcas5p1.samsung.com>
@ 2025-08-25 2:04 ` Ying Gao
0 siblings, 0 replies; 2+ messages in thread
From: Ying Gao @ 2025-08-25 2:04 UTC (permalink / raw)
To: ying01.gao
Cc: eperezma, jasowang, junnan01.wu, kraxel, lei19.wang, linux-kernel,
liping.qi, mst, virtualization, xuanzhuo, ying123.xu
When executing suspend to ram, if lacking the operations
to reset device and free unused buffers before deleting
a vq, resource leaks and inconsistent device status will
appear.
According to chapter "3.3.1 Driver Requirements: Device Cleanup:"
of virtio-specification:
Driver MUST ensure a virtqueue isn’t live
(by device reset) before removing exposed
buffers.
Therefore, modify the virtinput_freeze function to reset the
device and delete the unused buffers before deleting the
virtqueue, just like virtinput_remove does.
Co-developed-by: Ying Xu <ying123.xu@samsung.com>
Signed-off-by: Ying Xu <ying123.xu@samsung.com>
Co-developed-by: Junnan Wu <junnan01.wu@samsung.com>
Signed-off-by: Junnan Wu <junnan01.wu@samsung.com>
Signed-off-by: Ying Gao <ying01.gao@samsung.com>
---
drivers/virtio/virtio_input.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index a5d63269f20b..d0728285b6ce 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -360,11 +360,15 @@ static int virtinput_freeze(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
unsigned long flags;
+ void *buf;
spin_lock_irqsave(&vi->lock, flags);
vi->ready = false;
spin_unlock_irqrestore(&vi->lock, flags);
+ virtio_reset_device(vdev);
+ while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
+ kfree(buf);
vdev->config->del_vqs(vdev);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-25 2:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20250812095108epcas5p3aebdbf9e790cd259173d54611652a97b@epcas5p3.samsung.com>
2025-08-12 9:51 ` [PATCH] virtio_input: Improve freeze handling Ying Gao
[not found] ` <CGME20250825020428epcas5p16a3306486407502504ca75bbe549927e@epcas5p1.samsung.com>
2025-08-25 2:04 ` [PATCH V2 RESEND] " Ying Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).