From patchwork Fri Mar 14 15:17:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 330345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6B6642C00B5 for ; Sat, 15 Mar 2014 02:18:59 +1100 (EST) Received: from localhost ([::1]:45280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTsu-0005Th-V9 for incoming@patchwork.ozlabs.org; Fri, 14 Mar 2014 11:18:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTrE-0001oH-DI for qemu-devel@nongnu.org; Fri, 14 Mar 2014 11:17:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOTqx-0004so-AY for qemu-devel@nongnu.org; Fri, 14 Mar 2014 11:17:12 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:58296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTqx-0004sK-0L for qemu-devel@nongnu.org; Fri, 14 Mar 2014 11:16:55 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Mar 2014 15:16:53 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Mar 2014 15:16:51 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 490B71B08066 for ; Fri, 14 Mar 2014 15:16:39 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2EFGdeH65536006 for ; Fri, 14 Mar 2014 15:16:39 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2EFGoEW001265 for ; Fri, 14 Mar 2014 09:16:51 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s2EFGoxK001262; Fri, 14 Mar 2014 09:16:50 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 8421F122443E; Fri, 14 Mar 2014 16:16:50 +0100 (CET) From: Christian Borntraeger To: qemu-devel Date: Fri, 14 Mar 2014 16:17:11 +0100 Message-Id: <1394810232-9079-4-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1394810232-9079-1-git-send-email-borntraeger@de.ibm.com> References: <1394810232-9079-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14031415-4966-0000-0000-000008BC32C9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.106 Cc: Cornelia Huck , Christian Borntraeger , Jens Freimann , Alexander Graf , Richard Henderson Subject: [Qemu-devel] [PATCH 3/4] s390x/sclpconsole: Fix and simplify interrupt injection 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 valgrind complains about a memory leak in irq setup of sclpconsole: ==42117== 8 bytes in 1 blocks are definitely lost in loss record 89 of 833 ==42117== at 0x4031AFE: malloc (vg_replace_malloc.c:292) ==42117== by 0x8022F855: malloc_and_trace (vl.c:2715) ==42117== by 0x4145569: g_malloc (in /usr/lib64/libglib-2.0.so.0.3400.2) ==42117== by 0x800F696D: qemu_extend_irqs (irq.c:51) ==42117== by 0x800F6AF7: qemu_allocate_irqs (irq.c:68) ==42117== by 0x800F5685: console_init (sclpconsole.c:235) ==42117== by 0x80297C79: event_realize (event-facility.c:386) ==42117== by 0x80105071: device_set_realized (qdev.c:693) ==42117== by 0x801CDC4B: property_set_bool (object.c:1337) ==42117== by 0x801CBD7F: object_property_set (object.c:819) [...] Turns out that we actually dont need the indirection, so trigger the sclp interrupt directly. Signed-off-by: Christian Borntraeger Acked-by: Heinz Graalfs --- hw/char/sclpconsole.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index 16d77c5..ce40673 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -36,7 +36,6 @@ typedef struct SCLPConsole { uint32_t iov_bs; /* offset in buf for char layer read operation */ uint32_t iov_data_len; /* length of byte stream in buffer */ uint32_t iov_sclp_rest; /* length of byte stream not read via SCLP */ - qemu_irq irq_read_vt220; } SCLPConsole; /* character layer call-back functions */ @@ -49,11 +48,12 @@ static int chr_can_read(void *opaque) return SIZE_BUFFER_VT220 - scon->iov_data_len; } -/* Receive n bytes from character layer, save in iov buffer, - * and set event pending */ -static void receive_from_chr_layer(SCLPConsole *scon, const uint8_t *buf, - int size) +/* Send data from a char device over to the guest */ +static void chr_read(void *opaque, const uint8_t *buf, int size) { + SCLPConsole *scon = opaque; + + assert(scon); /* read data must fit into current buffer */ assert(size <= SIZE_BUFFER_VT220 - scon->iov_data_len); @@ -63,18 +63,7 @@ static void receive_from_chr_layer(SCLPConsole *scon, const uint8_t *buf, scon->iov_sclp_rest += size; scon->iov_bs += size; scon->event.event_pending = true; -} - -/* Send data from a char device over to the guest */ -static void chr_read(void *opaque, const uint8_t *buf, int size) -{ - SCLPConsole *scon = opaque; - - assert(scon); - - receive_from_chr_layer(scon, buf, size); - /* trigger SCLP read operation */ - qemu_irq_raise(scon->irq_read_vt220); + sclp_service_interrupt(0); } /* functions to be called by event facility */ @@ -192,11 +181,6 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr) return rc; } -static void trigger_ascii_console_data(void *opaque, int n, int level) -{ - sclp_service_interrupt(0); -} - static const VMStateDescription vmstate_sclpconsole = { .name = "sclpconsole", .version_id = 0, @@ -232,8 +216,6 @@ static int console_init(SCLPEvent *event) qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon); } - scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data, - NULL, 1); return 0; }