All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination
@ 2015-11-12 11:39 Jan Beulich
  2015-11-12 11:45 ` [PATCH 1/2] x86/IO-APIC: fix setup of Xen internally used IRQs Jan Beulich
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2015-11-12 11:39 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Keir Fraser

1: fix setup of Xen internally used IRQs
2: make SET_DEST() easier to use

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] x86/IO-APIC: fix setup of Xen internally used IRQs
  2015-11-12 11:39 [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Jan Beulich
@ 2015-11-12 11:45 ` Jan Beulich
  2015-11-12 11:46 ` [PATCH 2/2] x86/IO-APIC: make SET_DEST() easier to use Jan Beulich
  2015-11-12 12:18 ` [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Andrew Cooper
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2015-11-12 11:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Keir Fraser

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

..., i.e. namely that of a PCI serial card with an IRQ above the
legacy range. This had got broken by the switch to cpumask_any() in
cpu_mask_to_apicid_phys(). Fix this by allowing all CPUs for that IRQ
(such that __setup_vector_irq() will properly update a booting CPU's
vector_irq[], avoiding "No irq handler for vector" messages and the
interrupt not working).

While doing this I also noticed that io_apic_set_pci_routing() can't
be quite right: It sets up the destination _before_ getting a vector
allocated (which on other than systems using the flat APIC mode
affects the possible destinations), and also didn't restrict affinity
to ->arch.cpu_mask (as established by assign_irq_vector()).

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2204,6 +2204,7 @@ int io_apic_set_pci_routing (int ioapic,
 {
     struct irq_desc *desc = irq_to_desc(irq);
     struct IO_APIC_route_entry entry;
+    cpumask_t mask;
     unsigned long flags;
     int vector;
 
@@ -2223,8 +2224,6 @@ int io_apic_set_pci_routing (int ioapic,
 
     entry.delivery_mode = INT_DELIVERY_MODE;
     entry.dest_mode = INT_DEST_MODE;
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-        cpu_mask_to_apicid(TARGET_CPUS));
     entry.trigger = edge_level;
     entry.polarity = active_high_low;
     entry.mask  = 1;
@@ -2240,6 +2239,10 @@ int io_apic_set_pci_routing (int ioapic,
         return vector;
     entry.vector = vector;
 
+    cpumask_and(&mask, desc->arch.cpu_mask, TARGET_CPUS);
+    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
+             cpu_mask_to_apicid(&mask));
+
     apic_printk(APIC_DEBUG, KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry "
 		"(%d-%d -> %#x -> IRQ %d Mode:%i Active:%i)\n", ioapic,
 		mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq,
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -1084,7 +1084,7 @@ void __init smp_intr_init(void)
         vector = alloc_hipriority_vector();
         per_cpu(vector_irq, cpu)[vector] = irq;
         irq_to_desc(irq)->arch.vector = vector;
-        cpumask_copy(irq_to_desc(irq)->arch.cpu_mask, &cpu_online_map);
+        cpumask_setall(irq_to_desc(irq)->arch.cpu_mask);
     }
 
     /* Direct IPI vectors. */




[-- Attachment #2: x86-serial-vector_irq.patch --]
[-- Type: text/plain, Size: 2391 bytes --]

x86/IO-APIC: fix setup of Xen internally used IRQs

..., i.e. namely that of a PCI serial card with an IRQ above the
legacy range. This had got broken by the switch to cpumask_any() in
cpu_mask_to_apicid_phys(). Fix this by allowing all CPUs for that IRQ
(such that __setup_vector_irq() will properly update a booting CPU's
vector_irq[], avoiding "No irq handler for vector" messages and the
interrupt not working).

While doing this I also noticed that io_apic_set_pci_routing() can't
be quite right: It sets up the destination _before_ getting a vector
allocated (which on other than systems using the flat APIC mode
affects the possible destinations), and also didn't restrict affinity
to ->arch.cpu_mask (as established by assign_irq_vector()).

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2204,6 +2204,7 @@ int io_apic_set_pci_routing (int ioapic,
 {
     struct irq_desc *desc = irq_to_desc(irq);
     struct IO_APIC_route_entry entry;
+    cpumask_t mask;
     unsigned long flags;
     int vector;
 
@@ -2223,8 +2224,6 @@ int io_apic_set_pci_routing (int ioapic,
 
     entry.delivery_mode = INT_DELIVERY_MODE;
     entry.dest_mode = INT_DEST_MODE;
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-        cpu_mask_to_apicid(TARGET_CPUS));
     entry.trigger = edge_level;
     entry.polarity = active_high_low;
     entry.mask  = 1;
@@ -2240,6 +2239,10 @@ int io_apic_set_pci_routing (int ioapic,
         return vector;
     entry.vector = vector;
 
+    cpumask_and(&mask, desc->arch.cpu_mask, TARGET_CPUS);
+    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
+             cpu_mask_to_apicid(&mask));
+
     apic_printk(APIC_DEBUG, KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry "
 		"(%d-%d -> %#x -> IRQ %d Mode:%i Active:%i)\n", ioapic,
 		mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq,
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -1084,7 +1084,7 @@ void __init smp_intr_init(void)
         vector = alloc_hipriority_vector();
         per_cpu(vector_irq, cpu)[vector] = irq;
         irq_to_desc(irq)->arch.vector = vector;
-        cpumask_copy(irq_to_desc(irq)->arch.cpu_mask, &cpu_online_map);
+        cpumask_setall(irq_to_desc(irq)->arch.cpu_mask);
     }
 
     /* Direct IPI vectors. */

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] x86/IO-APIC: make SET_DEST() easier to use
  2015-11-12 11:39 [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Jan Beulich
  2015-11-12 11:45 ` [PATCH 1/2] x86/IO-APIC: fix setup of Xen internally used IRQs Jan Beulich
@ 2015-11-12 11:46 ` Jan Beulich
  2015-11-12 12:18 ` [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Andrew Cooper
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2015-11-12 11:46 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Keir Fraser

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

There has been quite a bit of redundancy between the various use sites.
Eliminate that. No change of generated code.

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -958,8 +958,12 @@ static hw_irq_controller ioapic_edge_typ
 #define IOAPIC_EDGE	0
 #define IOAPIC_LEVEL	1
 
-#define SET_DEST(x, y, value) \
-    do { if ( x2apic_enabled ) x = value; else y = value; } while(0)
+#define SET_DEST(ent, mode, val) do { \
+    if (x2apic_enabled) \
+        (ent).dest.dest32 = (val); \
+    else \
+        (ent).dest.mode.mode##_dest = (val); \
+} while (0)
 
 static inline void ioapic_register_intr(int irq, unsigned long trigger)
 {
@@ -1035,8 +1039,7 @@ static void __init setup_IO_APIC_irqs(vo
                 disable_8259A_irq(irq_to_desc(irq));
 
             desc = irq_to_desc(irq);
-            SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-                     cpu_mask_to_apicid(desc->arch.cpu_mask));
+            SET_DEST(entry, logical, cpu_mask_to_apicid(desc->arch.cpu_mask));
             spin_lock_irqsave(&ioapic_lock, flags);
             __ioapic_write_entry(apic, pin, 0, entry);
             set_native_irq_info(irq, TARGET_CPUS);
@@ -1068,8 +1071,7 @@ static void __init setup_ExtINT_IRQ0_pin
      */
     entry.dest_mode = INT_DEST_MODE;
     entry.mask = 0;					/* unmask IRQ now */
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-        cpu_mask_to_apicid(TARGET_CPUS));
+    SET_DEST(entry, logical, cpu_mask_to_apicid(TARGET_CPUS));
     entry.delivery_mode = INT_DELIVERY_MODE;
     entry.polarity = 0;
     entry.trigger = 0;
@@ -1349,8 +1351,7 @@ void disable_IO_APIC(void)
         entry.dest_mode       = 0; /* Physical */
         entry.delivery_mode   = dest_ExtINT; /* ExtInt */
         entry.vector          = 0;
-        SET_DEST(entry.dest.dest32, entry.dest.physical.physical_dest,
-            get_apic_id());
+        SET_DEST(entry, physical, get_apic_id());
 
         /*
          * Add it to the IO-APIC irq-routing table:
@@ -1842,8 +1843,7 @@ static void __init unlock_ExtINT_logic(v
 
     entry1.dest_mode = 0;			/* physical delivery */
     entry1.mask = 0;			/* unmask IRQ now */
-    SET_DEST(entry1.dest.dest32, entry1.dest.physical.physical_dest,
-        hard_smp_processor_id());
+    SET_DEST(entry1, physical, hard_smp_processor_id());
     entry1.delivery_mode = dest_ExtINT;
     entry1.polarity = entry0.polarity;
     entry1.trigger = 0;
@@ -2240,8 +2240,7 @@ int io_apic_set_pci_routing (int ioapic,
     entry.vector = vector;
 
     cpumask_and(&mask, desc->arch.cpu_mask, TARGET_CPUS);
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-             cpu_mask_to_apicid(&mask));
+    SET_DEST(entry, logical, cpu_mask_to_apicid(&mask));
 
     apic_printk(APIC_DEBUG, KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry "
 		"(%d-%d -> %#x -> IRQ %d Mode:%i Active:%i)\n", ioapic,
@@ -2434,8 +2433,7 @@ int ioapic_guest_write(unsigned long phy
     /* Set the vector field to the real vector! */
     rte.vector = desc->arch.vector;
 
-    SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
-             cpu_mask_to_apicid(desc->arch.cpu_mask));
+    SET_DEST(rte, logical, cpu_mask_to_apicid(desc->arch.cpu_mask));
 
     __ioapic_write_entry(apic, pin, 0, rte);
     




[-- Attachment #2: x86-SET_DEST.patch --]
[-- Type: text/plain, Size: 3481 bytes --]

x86/IO-APIC: make SET_DEST() easier to use

There has been quite a bit of redundancy between the various use sites.
Eliminate that. No change of generated code.

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -958,8 +958,12 @@ static hw_irq_controller ioapic_edge_typ
 #define IOAPIC_EDGE	0
 #define IOAPIC_LEVEL	1
 
-#define SET_DEST(x, y, value) \
-    do { if ( x2apic_enabled ) x = value; else y = value; } while(0)
+#define SET_DEST(ent, mode, val) do { \
+    if (x2apic_enabled) \
+        (ent).dest.dest32 = (val); \
+    else \
+        (ent).dest.mode.mode##_dest = (val); \
+} while (0)
 
 static inline void ioapic_register_intr(int irq, unsigned long trigger)
 {
@@ -1035,8 +1039,7 @@ static void __init setup_IO_APIC_irqs(vo
                 disable_8259A_irq(irq_to_desc(irq));
 
             desc = irq_to_desc(irq);
-            SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-                     cpu_mask_to_apicid(desc->arch.cpu_mask));
+            SET_DEST(entry, logical, cpu_mask_to_apicid(desc->arch.cpu_mask));
             spin_lock_irqsave(&ioapic_lock, flags);
             __ioapic_write_entry(apic, pin, 0, entry);
             set_native_irq_info(irq, TARGET_CPUS);
@@ -1068,8 +1071,7 @@ static void __init setup_ExtINT_IRQ0_pin
      */
     entry.dest_mode = INT_DEST_MODE;
     entry.mask = 0;					/* unmask IRQ now */
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-        cpu_mask_to_apicid(TARGET_CPUS));
+    SET_DEST(entry, logical, cpu_mask_to_apicid(TARGET_CPUS));
     entry.delivery_mode = INT_DELIVERY_MODE;
     entry.polarity = 0;
     entry.trigger = 0;
@@ -1349,8 +1351,7 @@ void disable_IO_APIC(void)
         entry.dest_mode       = 0; /* Physical */
         entry.delivery_mode   = dest_ExtINT; /* ExtInt */
         entry.vector          = 0;
-        SET_DEST(entry.dest.dest32, entry.dest.physical.physical_dest,
-            get_apic_id());
+        SET_DEST(entry, physical, get_apic_id());
 
         /*
          * Add it to the IO-APIC irq-routing table:
@@ -1842,8 +1843,7 @@ static void __init unlock_ExtINT_logic(v
 
     entry1.dest_mode = 0;			/* physical delivery */
     entry1.mask = 0;			/* unmask IRQ now */
-    SET_DEST(entry1.dest.dest32, entry1.dest.physical.physical_dest,
-        hard_smp_processor_id());
+    SET_DEST(entry1, physical, hard_smp_processor_id());
     entry1.delivery_mode = dest_ExtINT;
     entry1.polarity = entry0.polarity;
     entry1.trigger = 0;
@@ -2240,8 +2240,7 @@ int io_apic_set_pci_routing (int ioapic,
     entry.vector = vector;
 
     cpumask_and(&mask, desc->arch.cpu_mask, TARGET_CPUS);
-    SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-             cpu_mask_to_apicid(&mask));
+    SET_DEST(entry, logical, cpu_mask_to_apicid(&mask));
 
     apic_printk(APIC_DEBUG, KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry "
 		"(%d-%d -> %#x -> IRQ %d Mode:%i Active:%i)\n", ioapic,
@@ -2434,8 +2433,7 @@ int ioapic_guest_write(unsigned long phy
     /* Set the vector field to the real vector! */
     rte.vector = desc->arch.vector;
 
-    SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
-             cpu_mask_to_apicid(desc->arch.cpu_mask));
+    SET_DEST(rte, logical, cpu_mask_to_apicid(desc->arch.cpu_mask));
 
     __ioapic_write_entry(apic, pin, 0, rte);
     

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination
  2015-11-12 11:39 [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Jan Beulich
  2015-11-12 11:45 ` [PATCH 1/2] x86/IO-APIC: fix setup of Xen internally used IRQs Jan Beulich
  2015-11-12 11:46 ` [PATCH 2/2] x86/IO-APIC: make SET_DEST() easier to use Jan Beulich
@ 2015-11-12 12:18 ` Andrew Cooper
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-11-12 12:18 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Keir Fraser

On 12/11/15 11:39, Jan Beulich wrote:
> 1: fix setup of Xen internally used IRQs
> 2: make SET_DEST() easier to use
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-12 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-12 11:39 [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Jan Beulich
2015-11-12 11:45 ` [PATCH 1/2] x86/IO-APIC: fix setup of Xen internally used IRQs Jan Beulich
2015-11-12 11:46 ` [PATCH 2/2] x86/IO-APIC: make SET_DEST() easier to use Jan Beulich
2015-11-12 12:18 ` [PATCH 0/2] x86/IO-APIC: adjust setting interrupt destination Andrew Cooper

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.