From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [Qemu-devel] Re: >2 serial ports? Date: Mon, 22 Mar 2010 11:02:30 +0200 Message-ID: <4BA73226.6030704@redhat.com> References: <4BA094FE.6020109@msgid.tls.msk.ru> <4BA09E41.7000300@redhat.com> <201003171118.09873.paul@codesourcery.com> <4BA72BC5.1020303@msgid.tls.msk.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Paul Brook , qemu-devel@nongnu.org, Gerd Hoffmann , KVM list To: Michael Tokarev Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60490 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634Ab0CVJCr (ORCPT ); Mon, 22 Mar 2010 05:02:47 -0400 In-Reply-To: <4BA72BC5.1020303@msgid.tls.msk.ru> Sender: kvm-owner@vger.kernel.org List-ID: On 03/22/2010 10:35 AM, Michael Tokarev wrote: > Paul Brook wrote at Wed, 17 Mar 2010 11:18:09 +0000: > >>> Oh, well, yes, I remember. qemu is more strict on ISA irq sharing now. >>> A bit too strict. >>> >>> /me goes dig out a old patch which never made it upstream for some >>> reason I forgot. Attached. >>> >> This is wrong. Two devices should never be manipulating the same qemu_irq >> object. If you want multiple devices connected to the same IRQ then you need >> an explicit multiplexer. e.g. arm_timer.c:sp804_set_irq. >> > So... what we have to do here? > > I've looked at the mentioned routine, here it is: > > /* Merge the IRQs from the two component devices. */ > static void sp804_set_irq(void *opaque, int irq, int level) > { > sp804_state *s = (sp804_state *)opaque; > > s->level[irq] = level; > qemu_set_irq(s->irq, s->level[0] || s->level[1]); > } > > But I know nothing about qemu internals, so don't quite > understand how to do this in case of serial ports. I > see it is tracking two timers and raises the irq level > if at least one half is raised... That to say - I've > got the idea, but how to apply it to serial ports? > Two devices have the same s->irq. Give each on its own qemu_irq, and feed it into a multiplexer that ORs them together and sends the result to the interrupt controller's qemu_irq: S1 ----qemu_irq---->+------+ | mux +---qemu_irq-----> irq controller S2 ----qemu_irq---->+------+ (the ascii art will come out all wrong, I know it) -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NtdX3-0004VJ-Nd for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:02:45 -0400 Received: from [199.232.76.173] (port=33056 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtdX3-0004VB-13 for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:02:45 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NtdX2-00056w-0A for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:02:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59144) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NtdX1-00056s-LN for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:02:43 -0400 Message-ID: <4BA73226.6030704@redhat.com> Date: Mon, 22 Mar 2010 11:02:30 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: >2 serial ports? References: <4BA094FE.6020109@msgid.tls.msk.ru> <4BA09E41.7000300@redhat.com> <201003171118.09873.paul@codesourcery.com> <4BA72BC5.1020303@msgid.tls.msk.ru> In-Reply-To: <4BA72BC5.1020303@msgid.tls.msk.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: Gerd Hoffmann , Paul Brook , KVM list , qemu-devel@nongnu.org On 03/22/2010 10:35 AM, Michael Tokarev wrote: > Paul Brook wrote at Wed, 17 Mar 2010 11:18:09 +0000: > >>> Oh, well, yes, I remember. qemu is more strict on ISA irq sharing now. >>> A bit too strict. >>> >>> /me goes dig out a old patch which never made it upstream for some >>> reason I forgot. Attached. >>> >> This is wrong. Two devices should never be manipulating the same qemu_irq >> object. If you want multiple devices connected to the same IRQ then you need >> an explicit multiplexer. e.g. arm_timer.c:sp804_set_irq. >> > So... what we have to do here? > > I've looked at the mentioned routine, here it is: > > /* Merge the IRQs from the two component devices. */ > static void sp804_set_irq(void *opaque, int irq, int level) > { > sp804_state *s = (sp804_state *)opaque; > > s->level[irq] = level; > qemu_set_irq(s->irq, s->level[0] || s->level[1]); > } > > But I know nothing about qemu internals, so don't quite > understand how to do this in case of serial ports. I > see it is tracking two timers and raises the irq level > if at least one half is raised... That to say - I've > got the idea, but how to apply it to serial ports? > Two devices have the same s->irq. Give each on its own qemu_irq, and feed it into a multiplexer that ORs them together and sends the result to the interrupt controller's qemu_irq: S1 ----qemu_irq---->+------+ | mux +---qemu_irq-----> irq controller S2 ----qemu_irq---->+------+ (the ascii art will come out all wrong, I know it) -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.