xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86: start PCI IRQs Xen uses from Dom0-invoked io_apic_set_pci_routing()
Date: Wed, 31 Mar 2010 09:18:20 +0100	[thread overview]
Message-ID: <4BB3216C0200007800038133@vpn.id2.novell.com> (raw)

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

When using a serial port from an add-in PCI card, and that IRQ is (as
usual) outside of the legacy range (0...15), Xen would never really
enable the IRQ, as at the time setup_irq() runs the handler for the
IRQ still is &no_irq_type. Consequently, once the trigger mode and
polarity of the interrupt become known to Xen, it should start such
IRQ(s) it uses for itself.

The question is whether the same should also be done in
ioapic_guest_write(): Legacy kernels don't use PHYSDEVOP_setup_gsi
(and hence don't trigger the code path modified). 

Note however that even when a kernel is using PHYSDEVOP_setup_gsi in
the way the pv-ops kernel currently does, there's still no guarantee
that the call would ever be issued for IRQs Xen may be using, since
this happens only when devices get enabled. For Xen's purposes, this
function should be called for *all* device IRQs, regardless of
whether those would actually be (attempted to be) used by the kernel,
i.e. in a subsys_initcall() from drivers/acpi/pci_irq.c iterating
over all PCI devices and doing mostly what acpi_pci_irq_enable() does
except for calling this function in place of acpi_register_gsi(). The
downside of this approach is that without extra filtering in Xen
(based on a hint from Dom0), vectors will then get up even for IRQs
that are unused by both hypervisor and kernel.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-03-22.orig/xen/arch/x86/io_apic.c	2010-03-22 00:00:00.000000000 +0100
+++ 2010-03-22/xen/arch/x86/io_apic.c	2010-03-23 15:48:14.000000000 +0100
@@ -2113,6 +2113,7 @@ int __init io_apic_get_redir_entries (in
 
 int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low)
 {
+    struct irq_desc *desc = irq_to_desc(irq);
     struct IO_APIC_route_entry entry;
     unsigned long flags;
     int vector;
@@ -2166,6 +2167,11 @@ int io_apic_set_pci_routing (int ioapic,
     set_native_irq_info(irq, TARGET_CPUS);
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
+    spin_lock(&desc->lock);
+    if (!(desc->status & (IRQ_DISABLED | IRQ_GUEST)))
+        desc->handler->startup(irq);
+    spin_unlock(&desc->lock);
+
     return 0;
 }
 




[-- Attachment #2: x86-startup-irq-from-setup-gsi.patch --]
[-- Type: text/plain, Size: 2219 bytes --]

When using a serial port from an add-in PCI card, and that IRQ is (as
usual) outside of the legacy range (0...15), Xen would never really
enable the IRQ, as at the time setup_irq() runs the handler for the
IRQ still is &no_irq_type. Consequently, once the trigger mode and
polarity of the interrupt become known to Xen, it should start such
IRQ(s) it uses for itself.

The question is whether the same should also be done in
ioapic_guest_write(): Legacy kernels don't use PHYSDEVOP_setup_gsi
(and hence don't trigger the code path modified). 

Note however that even when a kernel is using PHYSDEVOP_setup_gsi in
the way the pv-ops kernel currently does, there's still no guarantee
that the call would ever be issued for IRQs Xen may be using, since
this happens only when devices get enabled. For Xen's purposes, this
function should be called for *all* device IRQs, regardless of
whether those would actually be (attempted to be) used by the kernel,
i.e. in a subsys_initcall() from drivers/acpi/pci_irq.c iterating
over all PCI devices and doing mostly what acpi_pci_irq_enable() does
except for calling this function in place of acpi_register_gsi(). The
downside of this approach is that without extra filtering in Xen
(based on a hint from Dom0), vectors will then get up even for IRQs
that are unused by both hypervisor and kernel.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-03-22.orig/xen/arch/x86/io_apic.c	2010-03-22 00:00:00.000000000 +0100
+++ 2010-03-22/xen/arch/x86/io_apic.c	2010-03-23 15:48:14.000000000 +0100
@@ -2113,6 +2113,7 @@ int __init io_apic_get_redir_entries (in
 
 int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low)
 {
+    struct irq_desc *desc = irq_to_desc(irq);
     struct IO_APIC_route_entry entry;
     unsigned long flags;
     int vector;
@@ -2166,6 +2167,11 @@ int io_apic_set_pci_routing (int ioapic,
     set_native_irq_info(irq, TARGET_CPUS);
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
+    spin_lock(&desc->lock);
+    if (!(desc->status & (IRQ_DISABLED | IRQ_GUEST)))
+        desc->handler->startup(irq);
+    spin_unlock(&desc->lock);
+
     return 0;
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2010-03-31  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31  8:18 Jan Beulich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-03-23 15:12 [PATCH] x86: start PCI IRQs Xen uses from Dom0-invoked io_apic_set_pci_routing() Jan Beulich

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=4BB3216C0200007800038133@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --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 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).