mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
virtio_input: Improve freeze handling
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> Message-Id: <20250812095118.3622717-1-ying01.gao@samsung.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
24fc631539
commit
528d92bfc0
@ -360,11 +360,15 @@ static int virtinput_freeze(struct virtio_device *vdev)
|
|||||||
{
|
{
|
||||||
struct virtio_input *vi = vdev->priv;
|
struct virtio_input *vi = vdev->priv;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
spin_lock_irqsave(&vi->lock, flags);
|
spin_lock_irqsave(&vi->lock, flags);
|
||||||
vi->ready = false;
|
vi->ready = false;
|
||||||
spin_unlock_irqrestore(&vi->lock, flags);
|
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);
|
vdev->config->del_vqs(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user