linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sjur.brandeland@stericsson.com
To: Amit Shah <amit.shah@redhat.com>, Rusty Russell <rusty@rustcorp.com.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Masami Hiramatsu" <masami.hiramatsu.pt@hitachi.com>,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org, sjur@brendeland.net,
	"Sjur Brændeland" <sjur.brandeland@stericsson.com>
Subject: 
Date: Wed,  7 Nov 2012 15:22:51 +0100	[thread overview]
Message-ID: <1352298171-21869-1-git-send-email-sjur.brandeland@stericsson.com> (raw)
In-Reply-To: <20121102102047.GE10483@amit.redhat.com>

>From 0ce16d6a0270daebd9972e94a834034a093228b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sjur=20Br=C3=A6ndeland?= <sjur.brandeland@stericsson.com>
Date: Wed, 7 Nov 2012 12:20:07 +0100
Subject: [PATCH] virtio_console:Free buffers from out-queue upon close
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Free pending output buffers from the virtio out-queue when
host has acknowledged port_close. Also removed WARN_ON()
in remove_port_data().

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
Hi Amit,

Note: This patch is compile tested only. I have done the removal
of buffers from out-queue in handle_control_message()
when host has acked the close request. This seems less
racy than doing it in the release function.

I you want to change this further, feel free to take over from
here and refine this.

Thanks,
Sjur

 drivers/char/virtio_console.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 3fa036a..3a5831d 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1522,15 +1522,9 @@ static void remove_port_data(struct port *port)
 	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 pending buffers from the out-queue. */
+	while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
 		free_buf(buf, true);
-	}
 }
 
 /*
@@ -1655,6 +1649,10 @@ static void handle_control_message(struct ports_device *portdev,
 		 */
 		spin_lock_irq(&port->outvq_lock);
 		reclaim_consumed_buffers(port);
+
+		/* Free pending buffers from the out-queue. */
+		while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
+			free_buf(buf, true);
 		spin_unlock_irq(&port->outvq_lock);
 
 		/*
-- 
1.7.5.4


  reply	other threads:[~2012-11-07 13:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15  7:57 [PATCHv7 0/4] virtio_console: Add rproc_serial driver sjur.brandeland
2012-10-15  7:57 ` [PATCHv7 1/4] virtio_console: Free buffer if splice fails sjur.brandeland
2012-10-23  0:12   ` Rusty Russell
2012-10-15  7:57 ` [PATCHv7 2/4] virtio_console: Use kmalloc instead of kzalloc sjur.brandeland
2012-10-23  1:36   ` Rusty Russell
2012-10-15  7:57 ` [PATCHv7 3/4] virtio_console: Merge struct buffer_token into struct port_buffer sjur.brandeland
2012-10-23  0:19   ` Rusty Russell
2012-10-15  7:57 ` [PATCHv7 4/4] virtio_console: Add support for remoteproc serial sjur.brandeland
2012-10-23  1:47   ` Rusty Russell
2012-10-28 21:58     ` Sjur Brændeland
2012-11-01  7:39     ` Amit Shah
2012-11-01 23:22       ` Rusty Russell
2012-11-02 10:20         ` Amit Shah
2012-11-02 10:44           ` Sjur BRENDELAND
2012-11-07 14:22             ` sjur.brandeland [this message]
2012-11-07 13:43               ` [PATCH resend] virtio_console: Free buffers from out-queue upon close sjur.brandeland
2012-11-07 23:58                 ` Rusty Russell
2012-11-08  8:59                   ` Amit Shah
2012-11-08  9:25                     ` Sjur Brændeland
2012-10-22 13:00 ` [PATCHv7 0/4] virtio_console: Add rproc_serial driver Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352298171-21869-1-git-send-email-sjur.brandeland@stericsson.com \
    --to=sjur.brandeland@stericsson.com \
    --cc=amit.shah@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mst@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=sjur@brendeland.net \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).