From: Sjur Brændeland <sjur.brandel...@stericsson.com>

Remove buffers from the out-queue when a rproc_serial device
is removed. Rproc_serial communicates with remote processors
that may crash and leave buffers in the out-queue. But the
virtio_console device is not supposed to leave buffers in the
out-queue when a port is removed, so in this case throw a
warning.

Signed-off-by: Sjur Brændeland <sjur.brandel...@stericsson.com>
---
 drivers/char/virtio_console.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 9ebadcb..3fa036a 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1521,6 +1521,16 @@ static void remove_port_data(struct port *port)
        /* Remove buffers we queued up for the Host to send us data in. */
        while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
                free_buf(buf, true);
+
+       /*
+        * Check the out-queue for buffers. For VIRTIO_CONSOLE it is a
+        * bug if this happens. But for RPROC_SERIAL the remote processor
+        * may have crashed, leaving buffers hanging in the out-queue.
+        */
+       while ((buf = virtqueue_detach_unused_buf(port->out_vq))) {
+               WARN_ON_ONCE(!is_rproc_serial(port->portdev->vdev));
+               free_buf(buf, true);
+       }
 }
 
 /*
-- 
1.7.9.5

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to