From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPfEi-0005yk-EM for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPfEY-0005cc-Fb for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:38:20 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:49291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPfEY-0005aQ-5X for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:38:10 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Mar 2014 21:38:09 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id E2DA917D8041 for ; Mon, 17 Mar 2014 21:38:49 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2HLbt4Q44892192 for ; Mon, 17 Mar 2014 21:37:55 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2HLc6Tl030304 for ; Mon, 17 Mar 2014 15:38:07 -0600 From: Christian Borntraeger Date: Mon, 17 Mar 2014 22:38:27 +0100 Message-Id: <1395092307-42208-5-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1395092307-42208-1-git-send-email-borntraeger@de.ibm.com> References: <1395092307-42208-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PULL 4/4] s390x/sclpconsole-lm: Fix and simplify irq setup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Peter Maydell Cc: qemu-devel , Alexander Graf , Christian Borntraeger , Jens Freimann , Cornelia Huck , Richard Henderson valgrind complains about a memory leak in irq setup of sclpconsole: ==42117== 8 bytes in 1 blocks are definitely lost in loss record 89of 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) [...] We dont need the indirection of an qemu irq to inject an slcp interrupt. Fixes a valgrind error and makes the code simpler. Signed-off-by: Christian Borntraeger Acked-by: Heinz Graalfs --- hw/char/sclpconsole-lm.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 9339067..a2dc1c6 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -41,7 +41,6 @@ typedef struct SCLPConsoleLM { uint32_t write_errors; /* errors writing to char layer */ uint32_t length; /* length of byte stream in buffer */ uint8_t buf[SIZE_CONSOLE_BUFFER]; - qemu_irq irq_console_read; } SCLPConsoleLM; /* @@ -68,13 +67,15 @@ static int chr_can_read(void *opaque) return 0; } -static void receive_from_chr_layer(SCLPConsoleLM *scon, const uint8_t *buf, - int size) +static void chr_read(void *opaque, const uint8_t *buf, int size) { + SCLPConsoleLM *scon = opaque; + assert(size == 1); if (*buf == '\r' || *buf == '\n') { scon->event.event_pending = true; + sclp_service_interrupt(0); return; } scon->buf[scon->length] = *buf; @@ -84,20 +85,6 @@ static void receive_from_chr_layer(SCLPConsoleLM *scon, const uint8_t *buf, } } -/* - * Send data from a char device over to the guest - */ -static void chr_read(void *opaque, const uint8_t *buf, int size) -{ - SCLPConsoleLM *scon = opaque; - - receive_from_chr_layer(scon, buf, size); - if (scon->event.event_pending) { - /* trigger SCLP read operation */ - qemu_irq_raise(scon->irq_console_read); - } -} - /* functions to be called by event facility */ static bool can_handle_event(uint8_t type) @@ -298,11 +285,6 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *ebh) return SCLP_RC_NORMAL_COMPLETION; } -static void trigger_console_data(void *opaque, int n, int level) -{ - sclp_service_interrupt(0); -} - /* functions for live migration */ static const VMStateDescription vmstate_sclplmconsole = { @@ -338,7 +320,6 @@ static int console_init(SCLPEvent *event) if (scon->chr) { qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon); } - scon->irq_console_read = *qemu_allocate_irqs(trigger_console_data, NULL, 1); return 0; } -- 1.8.4.2