xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: remove open-coded IO-APIC RTE reads/writes
@ 2012-09-18 15:59 Jan Beulich
  2012-09-18 17:00 ` Keir Fraser
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-09-18 15:59 UTC (permalink / raw)
  To: xen-devel

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

This improves readability, not the least through doing away with a
couple of ugly casts.

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -225,9 +225,8 @@ void __ioapic_write_entry(
 {
     void (*write)(unsigned int, unsigned int, unsigned int)
         = raw ? __io_apic_write : io_apic_write;
-    union entry_union eu = {{0, 0}};
+    union entry_union eu = { .entry = e };
 
-    eu.entry = e;
     (*write)(apic, 0x11 + 2*pin, eu.w2);
     (*write)(apic, 0x10 + 2*pin, eu.w1);
 }
@@ -2384,8 +2383,7 @@ int ioapic_guest_write(unsigned long phy
     SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
              cpu_mask_to_apicid(desc->arch.cpu_mask));
 
-    io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&rte) + 0));
-    io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&rte) + 1));
+    __ioapic_write_entry(apic, pin, 0, rte);
     
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
@@ -2414,7 +2412,6 @@ void dump_ioapic_irq_info(void)
     struct irq_pin_list *entry;
     struct IO_APIC_route_entry rte;
     unsigned int irq, pin, printed = 0;
-    unsigned long flags;
 
     if ( !irq_2_pin )
         return;
@@ -2436,10 +2433,7 @@ void dump_ioapic_irq_info(void)
 
             printk("      Apic 0x%02x, Pin %2d: ", entry->apic, pin);
 
-            spin_lock_irqsave(&ioapic_lock, flags);
-            *(((int *)&rte) + 0) = io_apic_read(entry->apic, 0x10 + 2 * pin);
-            *(((int *)&rte) + 1) = io_apic_read(entry->apic, 0x11 + 2 * pin);
-            spin_unlock_irqrestore(&ioapic_lock, flags);
+            rte = ioapic_read_entry(entry->apic, pin, 0);
 
             printk("vec=%02x delivery=%-5s dest=%c status=%d "
                    "polarity=%d irr=%d trig=%c mask=%d dest_id:%d\n",




[-- Attachment #2: x86-ioapic-rw-entry.patch --]
[-- Type: text/plain, Size: 1889 bytes --]

x86: remove open-coded IO-APIC RTE reads/writes

This improves readability, not the least through doing away with a
couple of ugly casts.

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

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -225,9 +225,8 @@ void __ioapic_write_entry(
 {
     void (*write)(unsigned int, unsigned int, unsigned int)
         = raw ? __io_apic_write : io_apic_write;
-    union entry_union eu = {{0, 0}};
+    union entry_union eu = { .entry = e };
 
-    eu.entry = e;
     (*write)(apic, 0x11 + 2*pin, eu.w2);
     (*write)(apic, 0x10 + 2*pin, eu.w1);
 }
@@ -2384,8 +2383,7 @@ int ioapic_guest_write(unsigned long phy
     SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
              cpu_mask_to_apicid(desc->arch.cpu_mask));
 
-    io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&rte) + 0));
-    io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&rte) + 1));
+    __ioapic_write_entry(apic, pin, 0, rte);
     
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
@@ -2414,7 +2412,6 @@ void dump_ioapic_irq_info(void)
     struct irq_pin_list *entry;
     struct IO_APIC_route_entry rte;
     unsigned int irq, pin, printed = 0;
-    unsigned long flags;
 
     if ( !irq_2_pin )
         return;
@@ -2436,10 +2433,7 @@ void dump_ioapic_irq_info(void)
 
             printk("      Apic 0x%02x, Pin %2d: ", entry->apic, pin);
 
-            spin_lock_irqsave(&ioapic_lock, flags);
-            *(((int *)&rte) + 0) = io_apic_read(entry->apic, 0x10 + 2 * pin);
-            *(((int *)&rte) + 1) = io_apic_read(entry->apic, 0x11 + 2 * pin);
-            spin_unlock_irqrestore(&ioapic_lock, flags);
+            rte = ioapic_read_entry(entry->apic, pin, 0);
 
             printk("vec=%02x delivery=%-5s dest=%c status=%d "
                    "polarity=%d irr=%d trig=%c mask=%d dest_id:%d\n",

[-- 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] 2+ messages in thread

end of thread, other threads:[~2012-09-18 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18 15:59 [PATCH] x86: remove open-coded IO-APIC RTE reads/writes Jan Beulich
2012-09-18 17:00 ` Keir Fraser

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).