x86/IO-APIC: consolidate / complete #define-s
diff mbox series

Message ID 5CA35BD00200007800223E49@prv1-mh.provo.novell.com
State New, archived
Headers show
Series
  • x86/IO-APIC: consolidate / complete #define-s
Related show

Commit Message

Jan Beulich April 2, 2019, 12:55 p.m. UTC
Drop redundant ones from apic.h. Add delivery mode mask. Use them in
place of open coded hex numbers.

Take the opportunity and modify a helper function's parameters to be
just unsigned int. Also drop the bogus double underscore from its name,
as it and all its callers get touched anyway.

No functional change.

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

Comments

Andrew Cooper April 2, 2019, 12:57 p.m. UTC | #1
On 02/04/2019 13:55, Jan Beulich wrote:
> Drop redundant ones from apic.h. Add delivery mode mask. Use them in
> place of open coded hex numbers.
>
> Take the opportunity and modify a helper function's parameters to be
> just unsigned int. Also drop the bogus double underscore from its name,
> as it and all its callers get touched anyway.
>
> No functional change.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Wei Liu April 2, 2019, 1:32 p.m. UTC | #2
On Tue, Apr 02, 2019 at 06:55:44AM -0600, Jan Beulich wrote:
> Drop redundant ones from apic.h. Add delivery mode mask. Use them in
> place of open coded hex numbers.
> 
> Take the opportunity and modify a helper function's parameters to be
> just unsigned int. Also drop the bogus double underscore from its name,
> as it and all its callers get touched anyway.
> 
> No functional change.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

Patch
diff mbox series

--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -410,7 +410,8 @@  void free_ioapic_entries(struct IO_APIC_
     xfree(ioapic_entries);
 }
 
-static void __modify_IO_APIC_irq (unsigned int irq, unsigned long enable, unsigned long disable)
+static void modify_IO_APIC_irq(unsigned int irq, unsigned int enable,
+                               unsigned int disable)
 {
     struct irq_pin_list *entry = irq_2_pin + irq;
     unsigned int pin, reg;
@@ -432,25 +433,25 @@  static void __modify_IO_APIC_irq (unsign
 /* mask = 1 */
 static void __mask_IO_APIC_irq (unsigned int irq)
 {
-    __modify_IO_APIC_irq(irq, 0x00010000, 0);
+    modify_IO_APIC_irq(irq, IO_APIC_REDIR_MASKED, 0);
 }
 
 /* mask = 0 */
 static void __unmask_IO_APIC_irq (unsigned int irq)
 {
-    __modify_IO_APIC_irq(irq, 0, 0x00010000);
+    modify_IO_APIC_irq(irq, 0, IO_APIC_REDIR_MASKED);
 }
 
 /* trigger = 0 */
 static void __edge_IO_APIC_irq (unsigned int irq)
 {
-    __modify_IO_APIC_irq(irq, 0, 0x00008000);
+    modify_IO_APIC_irq(irq, 0, IO_APIC_REDIR_LEVEL_TRIGGER);
 }
 
 /* trigger = 1 */
 static void __level_IO_APIC_irq (unsigned int irq)
 {
-    __modify_IO_APIC_irq(irq, 0x00008000, 0);
+    modify_IO_APIC_irq(irq, IO_APIC_REDIR_LEVEL_TRIGGER, 0);
 }
 
 static void mask_IO_APIC_irq(struct irq_desc *desc)
@@ -571,7 +572,7 @@  set_ioapic_affinity_irq(struct irq_desc
             io_apic_write(entry->apic, 0x10 + 1 + pin*2, dest);
             data = io_apic_read(entry->apic, 0x10 + pin*2);
             data &= ~IO_APIC_REDIR_VECTOR_MASK;
-            data |= desc->arch.vector & 0xFF;
+            data |= MASK_INSR(desc->arch.vector, IO_APIC_REDIR_VECTOR_MASK);
             io_apic_modify(entry->apic, 0x10 + pin*2, data);
 
             if (!entry->next)
--- a/xen/include/asm-x86/apic.h
+++ b/xen/include/asm-x86/apic.h
@@ -16,10 +16,6 @@ 
 
 #define	SET_APIC_LOGICAL_ID(x)	(((x)<<24))
 
-#define IO_APIC_REDIR_VECTOR_MASK	0x000FF
-#define IO_APIC_REDIR_DEST_LOGICAL	0x00800
-#define IO_APIC_REDIR_DEST_PHYSICAL	0x00000
-
 /* Possible APIC states */
 enum apic_mode {
     APIC_MODE_INVALID,  /* Not set yet */
--- a/xen/include/asm-x86/io_apic.h
+++ b/xen/include/asm-x86/io_apic.h
@@ -21,6 +21,7 @@ 
 
 /* I/O Unit Redirection Table */
 #define IO_APIC_REDIR_VECTOR_MASK   0x000FF
+#define IO_APIC_REDIR_DELIV_MODE_MASK 0x00700
 #define IO_APIC_REDIR_DEST_LOGICAL  0x00800
 #define IO_APIC_REDIR_DEST_PHYSICAL 0x00000
 #define IO_APIC_REDIR_SEND_PENDING  (1 << 12)