[PATCH] virtio-input: reset device when going to sleep

From: Jian Jun Chen
Date: Mon Aug 06 2018 - 22:57:22 EST


When going to sleep all virtqueues are deleted, memory used for
descriptor table entries are freed. Device reset is required in
this case to notify the backend driver.

Signed-off-by: Jian Jun Chen <jian.jun.chen@xxxxxxxxx>
---
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 3a0468f2ceb0..20ea660bf1fc 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -332,12 +332,16 @@ static void virtinput_remove(struct virtio_device *vdev)
static int virtinput_freeze(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
+ void *buf;
unsigned long flags;

spin_lock_irqsave(&vi->lock, flags);
vi->ready = false;
spin_unlock_irqrestore(&vi->lock, flags);

+ vdev->config->reset(vdev);
+ while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
+ kfree(buf);
vdev->config->del_vqs(vdev);
return 0;
}
--
2.17.1