All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Alexander Graf <agraf@suse.de>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Joerg Roedel <Joerg.Roedel@amd.com>,
	qemu-devel Developers <qemu-devel@nongnu.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	"Edgar E.Iglesias" <edgar.iglesias@gmail.com>,
	Sebastian Herbszt <herbszt@gmx.de>
Subject: Re: [Qemu-devel] Re: [PATCH 8/8] ahci: fix !msi interrupts
Date: Sat, 22 Jan 2011 15:40:34 +0100	[thread overview]
Message-ID: <20110122144034.GC3960@hall.aurel32.net> (raw)
In-Reply-To: <BEC39B04-DB12-48B4-A6B1-1020E260143A@suse.de>

On Sat, Jan 22, 2011 at 03:32:36PM +0100, Alexander Graf wrote:
> 
> On 22.01.2011, at 15:14, Edgar E. Iglesias wrote:
> 
> > On Sat, Jan 22, 2011 at 02:13:03PM +0100, Aurelien Jarno wrote:
> >> On Tue, Jan 18, 2011 at 01:58:25PM +0100, Jan Kiszka wrote:
> >>> On 2011-01-18 13:05, Alexander Graf wrote:
> >>>> 
> >>>> On 18.01.2011, at 10:08, Gerd Hoffmann wrote:
> >>>> 
> >>>>> Hi,
> >>>>> 
> >>>>>>> Worse might also be that unknown issue that force you to inject an IRQ
> >>>>>>> here. We don't know. That's probably worst.
> >>>>>> 
> >>>>>> Well, IIRC the issue was that usually a level high interrupt line would
> >>>>>> simply retrigger an interrupt after enabling the interrupt line in the
> >>>>>> APIC again.
> >>>>> 
> >>>>> edge triggered interrupts wouldn't though.
> >>>> 
> >>>> The code change doesn't change anything for edge triggered interrupts - they work fine. Only !msi (== level) ones are broken.
> >>>> 
> >>>>> 
> >>>>>> Unless my memory completely fails on me, that didn't happen,
> >>>>>> so I added the manual retrigger on a partial command ACK in ahci code.
> >>>>> 
> >>>>> That re-trigger smells like you are not clearing the interrupt line where you should.  For starters try calling ahci_check_irq() after guest writes to PORT_IRQ_STAT.
> >>>> 
> >>>> The problem happened when I had the following:
> >>>> 
> >>>> ahci irq bits = 0
> >>>> <events happen>
> >>>> ahci irq bits = 1 | 2
> >>>> irq line trigger
> >>>> guest clears 1
> >>>> ahci bits = 2
> >>>> <no irq line trigger, since we're still irq high>
> >>>> 
> >>>> On normal hardware, the high state of the irq line would simply trigger another interrupt in the guest when it gets ACKed on the LAPIC. Somehow it doesn't get triggered here. I don't see why clearing the interrupt line would help? It's not what real hardware would do, no?
> >>>> 
> >>> 
> >>> No, real devices would simply leave the line asserted as long as there
> >>> is a reason to.
> >>> 
> >>> So again my question: With which irqchips do you see this effect, kvm's
> >>> in-kernel model and/or qemu's user space model? If there is an issue
> >>> with retriggering a CPU interrupt while the source is still asserted,
> >>> that probably needs to be fixed.
> >>> 
> >> 
> >> I guess it might be related to a problem identified long time ago on
> >> some targets, and that leads to the following #ifdef in i8259.c:
> >> 
> >> | /* all targets should do this rather than acking the IRQ in the cpu */
> >> | #if defined(TARGET_MIPS) || defined(TARGET_PPC) || defined(TARGET_ALPHA)
> >> 
> >> For your information it has been fixed on MIPS in commit 
> >> 4de9b249d37c1b382cc3e5a21fad1b4a11cec2fa.
> >> 
> >> Basically when an interrupt line is high, the interrupt is getting
> >> delivered to the CPU. This part works correctly on x86. The CPU will
> >> take a corresponding action, basically either disabling the interrupt
> >> at the CPU or controller level or doing something on the device so that
> >> it lower its IRQ line. This new IRQ line level should then propagate
> >> through the various controllers, which should also lower their IRQ line
> >> if no other interrupt line are active. This ACK process should then
> >> continue up to the CPU.
> > 
> > I totally agree.
> > 
> > 
> >> For x86 the interrupt state is cleared as soon as the interrupt is
> >> signaled to the CPU (see cpu-exec.c line 407), therefore if an interrupt
> >> is still pending, it won't be seen by the CPU. It's probably what you
> >> observed with AHCI. 
> > 
> > Yes, essentially, the CPU_INTERRUPT_HARD signal is an input to the CPU.
> > The CPU cannot drive it directly. To lower it, it must take some kind
> > of indirect action (IO or whatever) to clear the condition that is
> > forcing it high. Any assignments to clear or set the CPU_INTERRUPT_HARD
> > signal from within the CPU core are likely wrong..
> > 
> > FWIW, PPC code in cpu-exec.c:443 looks suspicious aswell...
> 
> How's that suspicious? As long as pending_interrupts is only reset on actual interrupt delivery, everything's fine. Interrupts like the decrementor are not level based on some PPCs, so the actual semantics are implementation dependent.
> 

It's suspicious because it's not the right place to do that. It should
be done in the interrupt controller. This seems to be already done in
hw/ppc.c when updating pending_interrupts, so this code seems to be
useless.

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2011-01-22 14:40 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 21:13 [Qemu-devel] [PATCH 0/8] Some more AHCI work Alexander Graf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 1/8] ahci: split ICH9 from core Alexander Graf
2010-12-23  8:23   ` Stefan Hajnoczi
2010-12-23 10:32     ` Alexander Graf
2010-12-27 11:51       ` Sebastian Herbszt
2010-12-20 21:13 ` [Qemu-devel] [PATCH 2/8] ahci: split ICH and AHCI even more Alexander Graf
2011-01-18 12:19   ` [Qemu-devel] " Kevin Wolf
2011-02-01 14:12     ` Alexander Graf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 3/8] ahci: send init d2h fis on fis enable Alexander Graf
2011-01-18 12:25   ` [Qemu-devel] " Kevin Wolf
2011-01-18 12:42     ` Alexander Graf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 4/8] ahci: use qiov instead of dma helpers Alexander Graf
2011-01-18 12:35   ` [Qemu-devel] " Kevin Wolf
2011-01-18 12:45     ` Alexander Graf
2011-01-18 13:14       ` Stefan Hajnoczi
2011-01-18 13:30         ` Kevin Wolf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 5/8] ahci: Implement HBA reset Alexander Graf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 6/8] ahci: make number of ports runtime determined Alexander Graf
2011-01-18 12:40   ` [Qemu-devel] " Kevin Wolf
2011-01-18 12:46     ` Alexander Graf
2011-01-18 13:33       ` Kevin Wolf
2011-01-18 13:09     ` Gerd Hoffmann
2010-12-20 21:13 ` [Qemu-devel] [PATCH 7/8] ahci: free dynamically allocated iovs Alexander Graf
2011-01-18 12:41   ` [Qemu-devel] " Kevin Wolf
2010-12-20 21:13 ` [Qemu-devel] [PATCH 8/8] ahci: fix !msi interrupts Alexander Graf
2011-01-17 14:37   ` [Qemu-devel] " Jan Kiszka
2011-01-17 16:00     ` Alexander Graf
2011-01-17 16:03       ` Jan Kiszka
2011-01-17 16:04         ` Alexander Graf
2011-01-17 16:20           ` Jan Kiszka
2011-01-17 16:33             ` Alexander Graf
2011-01-17 16:48               ` Jan Kiszka
2011-01-17 16:50                 ` Alexander Graf
2011-01-18  9:08               ` Gerd Hoffmann
2011-01-18 12:05                 ` Alexander Graf
2011-01-18 12:58                   ` Jan Kiszka
2011-01-22 13:13                     ` Aurelien Jarno
2011-01-22 14:14                       ` Edgar E. Iglesias
2011-01-22 14:32                         ` Alexander Graf
2011-01-22 14:40                           ` Aurelien Jarno [this message]
2011-01-23  3:34                             ` Edgar E. Iglesias
2011-01-22 14:28                       ` Alexander Graf
2011-01-22 14:34                         ` Aurelien Jarno
2011-01-18 13:02                   ` Gerd Hoffmann
2011-01-17 13:25 ` [Qemu-devel] [PATCH 0/8] Some more AHCI work Gerd Hoffmann

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=20110122144034.GC3960@hall.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=Joerg.Roedel@amd.com \
    --cc=agraf@suse.de \
    --cc=edgar.iglesias@gmail.com \
    --cc=herbszt@gmx.de \
    --cc=jan.kiszka@siemens.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.