From patchwork Thu Apr 28 12:04:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 93209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A21DFB6F4E for ; Thu, 28 Apr 2011 22:04:50 +1000 (EST) Received: from localhost ([::1]:57946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFPxe-0002or-AO for incoming@patchwork.ozlabs.org; Thu, 28 Apr 2011 08:04:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:60998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFPxE-0002nC-DH for qemu-devel@nongnu.org; Thu, 28 Apr 2011 08:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFPxD-0002dx-6X for qemu-devel@nongnu.org; Thu, 28 Apr 2011 08:04:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFPxC-0002dm-RF for qemu-devel@nongnu.org; Thu, 28 Apr 2011 08:04:19 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3SC4IMu003140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Apr 2011 08:04:18 -0400 Received: from playa.tlv.redhat.com (dhcp-3-110.tlv.redhat.com [10.35.3.110]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3SC4Fm3003428 for ; Thu, 28 Apr 2011 08:04:17 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Thu, 28 Apr 2011 15:04:12 +0300 Message-Id: <1303992254-4940-2-git-send-email-alevy@redhat.com> In-Reply-To: <1303992254-4940-1-git-send-email-alevy@redhat.com> References: <1303992254-4940-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Instead of calling flush_queued_data when unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as a have_data for callbackee. --- hw/virtio-serial-bus.c | 11 +++++++++-- hw/virtio-serial.h | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 6227379..8556e08 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port) return 0; } +static void bh_virtio_serial_flush_queued_data(void *opaque) +{ + VirtIOSerialPort *port = opaque; + + flush_queued_data(port); +} + void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle) { if (!port) { @@ -295,8 +302,7 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle) if (throttle) { return; } - - flush_queued_data(port); + qemu_bh_schedule(port->bh); } /* Guest wants to notify us of some event */ @@ -724,6 +730,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) bool plugging_port0; port->vser = bus->vser; + port->bh = qemu_bh_new(bh_virtio_serial_flush_queued_data, port); /* * Is the first console port we're seeing? If so, put it up at diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h index 5eb948e..0fa03d1 100644 --- a/hw/virtio-serial.h +++ b/hw/virtio-serial.h @@ -119,6 +119,11 @@ struct VirtIOSerialPort { uint32_t iov_idx; uint64_t iov_offset; + /* + * When unthrottling we use a buttomhalf to call flush_queued_data. + */ + QEMUBH *bh; + /* Identify if this is a port that binds with hvc in the guest */ uint8_t is_console;