Skip to contentSkip to conversation

virtio-input: reset device when going to sleep

PATCH New Jian Jun Chen 1 participant 1 message Aug 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-input: reset device when going to sleep

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.

---
 drivers/virtio/virtio_input.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/virtio/virtio_input.c +4 -0
index 3a0468f2ceb0..20ea660bf1fc 100644
@@ -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;
 }
Signature · 1 line
2.17.1