All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qing He <qing.he@intel.com>
To: Shohei Fujiwara <fujiwara-sxa@necst.nec.co.jp>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 0/6] MSI-INTx interrupt translation for HVM
Date: Fri, 9 Jan 2009 14:57:16 +0800	[thread overview]
Message-ID: <20090109065716.GA6371@ub-qhe2> (raw)
In-Reply-To: <20090109131737.379F.CB716985@necst.nec.co.jp>

On Fri, 2009-01-09 at 12:26 +0800, Shohei Fujiwara wrote:
> There is the assumption that Guest OS handles all causes which happen
> before Guest OS receives the interrupt. But is the assumption right for
> all OS?
> 
> In the case of level-triggerd interrupt, I/O device asserts interrupt
> line, when the cause of interrupt happens. OS handles the cause,
> I/O device de-asserts interrupt, and OS sends EOI to APICs.
> 
> When I/O APIC receives EOI, I/O APIC re-transmits interrupt to Local APIC 
> if some interrupt line is asserted.
> 
> Some OS might rely on this re-transmittion by I/O APIC. 
> 

> 
> But other OS might have the code like the following:
> 
> 	do {
> 		ret = action->handler(irq, action->dev_id, regs);
> 		if (ret == IRQ_HANDLED) {
> 			status |= action->flags;
> 			retval |= ret;
> 			break;
> 			^^^^^^
> 		}
> 		action = action->next;
> 	} while (action);
> 
Hmm, I think now I understand what you mean. If the guest irq is shared by
a normal IRQ and a MSI-INTx translated IRQ, two sources may assert the
pin while they both get pending. When this irq is injected, if the guest
only handles one irq source each time, and issues EOI right after it
clears the normal IRQ, the MSI is lost. Is it what you mean?

There is logic to avoid this from happening, see
hvm_irq->gsi_assert_count[gsi]. Basically, it's used to count how many
sources have asserted a shared pin. And at the time of  EOI, after the
decrement of the counter, if it's still not 0, the LAPIC is re-asserted.
This may result in some spurious interrupts to guest, but that's better
than losing interrupts.

The sharing of guest irq is generally not a good idea, in fact, this is
not even well supported in current Xen code. You may have seen something
like "girq[ggsi].mirq = mirq". That way, we are already stuck.
Currently, if the number of assigned devices is <= 8, there should be no
sharing, otherwise, very weird things may happen...

Uncommon devices of OS does have the possibility to fail MSI-INTx, for
example, if the device doesn't behave the same way using INTx and MSI,
or the guest OS doesn't always clear guest source before issuing EOI.
That's why I add the per-device disable function: if a device or OS
doesn't work properly, just turn it off. Fortunately, this is extremely
rare.

Btw, AFAIK, Windows handles all irq sources in one ISR, similar to
Linux.

Thanks,
Qing
> 
> This code will work on real machine, because I/O APIC re-transmits
> interrupt, if the cause to be handled remains.  If some OS has the
> code like the above, the assumption isn't right.
> 
> Actually, my concern is whether the assumption is right for Windows,
> or not. Do you know about this, or does your patch works well with
> Windows guest?
> 
> Thanks,
> --
> Shohei Fujiwara
> 
> > Generally, it's easy to "translate" an edged interrupt to a level one,
> > but not the other way.
> > 
> > Thanks,
> > Qing
> > > 
> > > What do you think?
> > > 
> > > Thanks,
> > > --
> > > Shohei Fujiwara
> > > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel

  reply	other threads:[~2009-01-09  6:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08  9:06 [PATCH 0/6] MSI-INTx interrupt translation for HVM Qing He
2009-01-08  9:06 ` [PATCH 1/6] passthrough: MSI-INTx " Qing He
2009-01-08  9:06 ` [PATCH 2/6] ioemu:passthrough: MSI-INTx interrupt translation support Qing He
2009-01-08  9:06 ` [PATCH 3/6] pci: add pci option support for XML-RPC server Qing He
2009-01-08  9:06 ` [PATCH 4/6] pci: add pci option support for XenAPI server Qing He
2009-01-08  9:06 ` [PATCH 5/6] pci: add config options for MSI-INTx translation in HVM Qing He
2009-01-08  9:06 ` [PATCH 6/6] passthough: MSI-INTx translation documentation Qing He
2009-01-08 10:44 ` [PATCH 0/6] MSI-INTx interrupt translation for HVM Shohei Fujiwara
2009-01-08 14:52   ` Qing He
2009-01-09  4:26     ` Shohei Fujiwara
2009-01-09  6:57       ` Qing He [this message]
2009-01-13  9:05         ` Shohei Fujiwara
2009-01-13  9:28           ` Qing He
2009-01-14  6:39             ` Shohei Fujiwara
2009-01-14  7:38               ` Qing He
2009-01-14  8:26                 ` Shohei Fujiwara
2009-01-14  9:17                   ` Qing He
2009-01-15  2:35                     ` Shohei Fujiwara
2009-01-15  6:25                       ` Qing He
2009-01-16  4:34                         ` Shohei Fujiwara
2009-02-27  2:41     ` Shohei Fujiwara
2009-03-01 14:55       ` Keir Fraser
2009-03-02  7:19         ` Shohei Fujiwara
2009-03-02  8:47           ` Keir Fraser
2009-03-02  9:24             ` Qing He
2009-03-02  9:40               ` Keir Fraser
2009-03-02 10:27                 ` Shohei Fujiwara

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=20090109065716.GA6371@ub-qhe2 \
    --to=qing.he@intel.com \
    --cc=fujiwara-sxa@necst.nec.co.jp \
    --cc=xen-devel@lists.xensource.com \
    /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.