qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 11/22] i8259: Update IRQ state after reset
Date: Sun, 02 Oct 2011 18:27:48 +0200	[thread overview]
Message-ID: <4E889104.2090600@web.de> (raw)
In-Reply-To: <CAAu8pHt3zGodeLMNtOcbgbCi8VWbkiV6wyp2heE0p7yiOdaY7Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

On 2011-10-01 09:31, Blue Swirl wrote:
> On Sat, Oct 1, 2011 at 6:47 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2011-09-30 22:47, Blue Swirl wrote:
>>> That part of the discussion is obsolete (or at least uninteresting
>>> here). For example this message has a relevant example:
>>> http://lists.nongnu.org/archive/html/qemu-devel/2009-06/msg01081.html
>>>
>>> It's about VM restore, but the situation is similar during reset.
>>
>> Actually, that is not comparable as we are entering the device's
>> quiescent state.
> 
> It is. Here's an example for the reset case based on the Paul's original one.
> 
> Because devices are reset in unpredictable order that they should not
> be communicating with other devices (e.g. by modifying IRQ lines).
> 
> Consider a system with a device (DEV) and a level triggered interrupt
> controller (PIC1) with the ability to toggle the level where
> triggering happens, chained to a rising edge triggered interrupt
> controller (PIC2).
> 
> (DEV) ->  (PIC1) -> (PIC2)
> 
> Before reset, DEV output is high, PIC1 has the interrupt unmasked (but
> high) and the trigger level is configured as active low, PIC2 has no
> pending interrupts.
> 
> We now reset, so the state should be that DEV output is low, PIC1 has
> masked all interrupts and its input set to active high, and PIC2 has
> no pending interrupts. Devices are reset in the order PIC2, DEV, PIC1.
> 
> If devices toggle their interrupts on reset then we get incorrect
> state after the reset:
> 
> PIC2 is reset to the desired no-interrupts-pending state.
> 
> DEV is reset. This lowers the IRQ, which is passed to PIC1. PIC1 still
> has the old interrupt mask and level set to active low, so it passes
> the IRQ through to PIC2, which detects the edge event and marks the
> interrupt as pending.
> 
> PIC1 is reset, updates the new mask, sets the input level to active
> high and lowers its output. However this event does not clear the
> internal PIC2 pending interrupt flag, so machine state will be wrong
> after reset.
> 
> Therefore it is incorrect to perform any qemu_irq activities during
> reset (also VM restore like the original example), don't you agree?

A rather odd but valid counterexample. Have you seen such a setup already?

But I'll provide a real example where the model "no IRQ change
propagated on reset, devices handle this internally" fails as well:

PIC -> CPU

We have a level-triggered active-high line in this case. When the CPU is
reset, it "somehow" knows that it is attached to the PIC and assumes
that this device is reset as well. Therefore, the CPU clears its cached
input state on reset. That works if both devices are actually reset. But
it fails if only the CPU is reset while the PIC output is active.

That's likely the reason why MIPS and PPC/PREP do no touch the cached
interrupt line state on reset but expect that the source will inform
them whenever the line goes down - e.g. due to reset.

The conflict we are in with the current reset model is hard-coding the
board wiring and source knowledge into sink device models vs.
propagating reset states. I agree that both have their corner cases.

But in order to continue with properly disentangling board knowledge
from generic device models, we should head for the latter variant where
already possible (like in the i8259 case). On the long term, this should
be resolved using a two-stage model where every root of an interrupt
line signals its state down the chain at the end of a reset phase.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2011-10-02 16:27 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-28 11:00 [Qemu-devel] [PATCH 00/22] Rework i8259 and PC interrupt models Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 01/22] pc: Drop useless test from isa_irq_handler Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 02/22] pc: Generalize ISA IRQs to GSIs Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 03/22] pc: Convert GSIState::i8259_irq into array Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 04/22] pc: Fix and clean up PIC-to-APIC IRQ path Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 05/22] i8259: Remove premature inline function attributes Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 06/22] i8259: Drop obsolete prototypes Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 07/22] i8259: Move pic_set_irq1 after pic_update_irq Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 08/22] i8239: Introduce per-PIC output interrupt Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 09/22] i8259: Do not update IRQ output after spurious pic_poll_read Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 10/22] i8259: Reorder intack in pic_read_irq Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 11/22] i8259: Update IRQ state after reset Jan Kiszka
2011-09-28 18:01   ` Blue Swirl
2011-09-28 18:09     ` Peter Maydell
2011-09-28 18:42       ` Blue Swirl
2011-09-28 21:38         ` Peter Maydell
2011-09-29 19:35           ` Blue Swirl
2011-09-28 21:18     ` Jan Kiszka
2011-09-29 19:45       ` Blue Swirl
2011-09-30  6:47         ` Jan Kiszka
2011-09-30  9:14           ` Peter Maydell
2011-09-30 20:52             ` Blue Swirl
2011-09-30 20:47           ` Blue Swirl
2011-10-01  6:47             ` Jan Kiszka
2011-10-01  7:31               ` Blue Swirl
2011-10-02 16:27                 ` Jan Kiszka [this message]
2011-10-02 19:01                   ` Blue Swirl
2011-10-02 16:56                 ` Avi Kivity
2011-10-02 19:13                   ` Blue Swirl
2011-10-02 19:20                     ` Avi Kivity
2011-10-02 19:39                       ` Blue Swirl
2011-10-02 19:44                         ` Avi Kivity
2011-10-02 19:49                           ` Blue Swirl
2011-10-02 19:52                             ` Avi Kivity
2011-10-02 19:59                               ` Blue Swirl
2011-10-02 20:03                                 ` Avi Kivity
2011-10-02 20:11                                   ` Blue Swirl
2011-10-02 20:17                                     ` Avi Kivity
2011-10-02 20:26                                       ` Blue Swirl
2011-10-02 20:31                                         ` Avi Kivity
2011-10-02 20:36                                           ` Blue Swirl
2011-10-02 20:41                                             ` Avi Kivity
2011-10-02 20:55                                               ` Blue Swirl
2011-10-03  7:21                                                 ` Paolo Bonzini
2011-10-04 12:12                                             ` Avi Kivity
2011-10-01 11:20             ` Peter Maydell
2011-10-02 16:39     ` Avi Kivity
2011-10-02 17:46       ` Jan Kiszka
2011-10-02 19:07         ` Avi Kivity
2011-10-02 19:15           ` Blue Swirl
2011-10-02 19:47           ` Jan Kiszka
2011-10-02 19:50             ` Avi Kivity
2011-10-02 19:06       ` Blue Swirl
2011-10-02 19:08         ` Avi Kivity
2011-10-02 19:26           ` Blue Swirl
2011-10-02 19:35             ` Avi Kivity
2011-10-02 19:40               ` Blue Swirl
2011-10-02 19:47                 ` Avi Kivity
2011-10-02 19:52                   ` Blue Swirl
2011-10-02 19:58                     ` Avi Kivity
2011-10-02 20:05                       ` Blue Swirl
2011-10-02 20:14                         ` Avi Kivity
2011-10-02 20:18                           ` Blue Swirl
2011-10-02 20:21                             ` Avi Kivity
2011-10-02 20:30                               ` Blue Swirl
2011-10-02 20:39                                 ` Avi Kivity
2011-10-02 20:53                                   ` Blue Swirl
2011-09-28 11:00 ` [Qemu-devel] [PATCH 12/22] i8259: Switch to per-PIC IRQ update Jan Kiszka
2011-09-28 11:00 ` [Qemu-devel] [PATCH 13/22] i8259: Fix poll command Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 14/22] i8259: Clean up pic_ioport_read Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 15/22] i8259: PREP: Replace pic_intack_read with pic_read_irq Jan Kiszka
2011-09-28 11:15   ` Alexander Graf
2011-09-28 11:01 ` [Qemu-devel] [PATCH 16/22] i8259: Replace PicState::pics_state with master flag Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 17/22] i8259: Eliminate PicState2 Jan Kiszka
2011-09-28 16:23   ` Richard Henderson
2011-09-28 16:29     ` Richard Henderson
2011-09-28 11:01 ` [Qemu-devel] [PATCH 18/22] qdev: Add HEX8 property Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 19/22] i8259: Convert to qdev Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 20/22] i8259: Fix coding style Jan Kiszka
2011-09-28 11:01 ` [Qemu-devel] [PATCH 21/22] monitor: Restrict pic/irq_info to supporting targets Jan Kiszka
2011-09-28 18:19   ` Blue Swirl
2011-09-28 21:26     ` Jan Kiszka
2011-09-29 19:29       ` Blue Swirl
2011-09-30  6:50         ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2011-09-30 20:32           ` Blue Swirl
2011-09-28 11:01 ` [Qemu-devel] [PATCH 22/22] i8259: Move to hw library Jan Kiszka
2011-09-28 18:21   ` Blue Swirl
2011-09-28 21:50     ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2011-09-28 16:39 ` [Qemu-devel] [PATCH 00/22] Rework i8259 and PC interrupt models Richard Henderson
2011-09-28 21:53   ` Jan Kiszka

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=4E889104.2090600@web.de \
    --to=jan.kiszka@web.de \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).