Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: Introduce and use MP IRQ trigger and polarity defines

MP_IRQDIR_* constants pointed in the right direction but remained unused so
far: It's cleaner to use symbolic values for the IRQ flags in the MP config
table. That also saves some comments.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: jailhouse-dev@googlegroups.com
Link: https://lkml.kernel.org/r/60809926663a1d38e2a5db47d020d6e2e7a70019.1511770314.git.jan.kiszka@siemens.com

authored by

Jan Kiszka and committed by
Thomas Gleixner
a09c5ec0 e348caef

+37 -25
+11 -3
arch/x86/include/asm/mpspec_def.h
··· 128 128 mp_ExtINT = 3 129 129 }; 130 130 131 - #define MP_IRQDIR_DEFAULT 0 132 - #define MP_IRQDIR_HIGH 1 133 - #define MP_IRQDIR_LOW 3 131 + #define MP_IRQPOL_DEFAULT 0x0 132 + #define MP_IRQPOL_ACTIVE_HIGH 0x1 133 + #define MP_IRQPOL_RESERVED 0x2 134 + #define MP_IRQPOL_ACTIVE_LOW 0x3 135 + #define MP_IRQPOL_MASK 0x3 136 + 137 + #define MP_IRQTRIG_DEFAULT 0x0 138 + #define MP_IRQTRIG_EDGE 0x4 139 + #define MP_IRQTRIG_RESERVED 0x8 140 + #define MP_IRQTRIG_LEVEL 0xc 141 + #define MP_IRQTRIG_MASK 0xc 134 142 135 143 #define MP_APIC_ALL 0xFF 136 144
+10 -10
arch/x86/kernel/apic/io_apic.c
··· 800 800 /* 801 801 * Determine IRQ line polarity (high active or low active): 802 802 */ 803 - switch (mp_irqs[idx].irqflag & 0x03) { 804 - case 0: 803 + switch (mp_irqs[idx].irqflag & MP_IRQPOL_MASK) { 804 + case MP_IRQPOL_DEFAULT: 805 805 /* conforms to spec, ie. bus-type dependent polarity */ 806 806 if (test_bit(bus, mp_bus_not_pci)) 807 807 return default_ISA_polarity(idx); 808 808 else 809 809 return default_PCI_polarity(idx); 810 - case 1: 810 + case MP_IRQPOL_ACTIVE_HIGH: 811 811 return IOAPIC_POL_HIGH; 812 - case 2: 812 + case MP_IRQPOL_RESERVED: 813 813 pr_warn("IOAPIC: Invalid polarity: 2, defaulting to low\n"); 814 - case 3: 814 + case MP_IRQPOL_ACTIVE_LOW: 815 815 default: /* Pointless default required due to do gcc stupidity */ 816 816 return IOAPIC_POL_LOW; 817 817 } ··· 845 845 /* 846 846 * Determine IRQ trigger mode (edge or level sensitive): 847 847 */ 848 - switch ((mp_irqs[idx].irqflag >> 2) & 0x03) { 849 - case 0: 848 + switch (mp_irqs[idx].irqflag & MP_IRQTRIG_MASK) { 849 + case MP_IRQTRIG_DEFAULT: 850 850 /* conforms to spec, ie. bus-type dependent trigger mode */ 851 851 if (test_bit(bus, mp_bus_not_pci)) 852 852 trigger = default_ISA_trigger(idx); ··· 854 854 trigger = default_PCI_trigger(idx); 855 855 /* Take EISA into account */ 856 856 return eisa_irq_trigger(idx, bus, trigger); 857 - case 1: 857 + case MP_IRQTRIG_EDGE: 858 858 return IOAPIC_EDGE; 859 - case 2: 859 + case MP_IRQTRIG_RESERVED: 860 860 pr_warn("IOAPIC: Invalid trigger mode 2 defaulting to level\n"); 861 - case 3: 861 + case MP_IRQTRIG_LEVEL: 862 862 default: /* Pointless default required due to do gcc stupidity */ 863 863 return IOAPIC_LEVEL; 864 864 }
+14 -9
arch/x86/kernel/mpparse.c
··· 281 281 int ELCR_fallback = 0; 282 282 283 283 intsrc.type = MP_INTSRC; 284 - intsrc.irqflag = 0; /* conforming */ 284 + intsrc.irqflag = MP_IRQTRIG_DEFAULT | MP_IRQPOL_DEFAULT; 285 285 intsrc.srcbus = 0; 286 286 intsrc.dstapic = mpc_ioapic_id(0); 287 287 ··· 324 324 * copy that information over to the MP table in the 325 325 * irqflag field (level sensitive, active high polarity). 326 326 */ 327 - if (ELCR_trigger(i)) 328 - intsrc.irqflag = 13; 329 - else 330 - intsrc.irqflag = 0; 327 + if (ELCR_trigger(i)) { 328 + intsrc.irqflag = MP_IRQTRIG_LEVEL | 329 + MP_IRQPOL_ACTIVE_HIGH; 330 + } else { 331 + intsrc.irqflag = MP_IRQTRIG_DEFAULT | 332 + MP_IRQPOL_DEFAULT; 333 + } 331 334 } 332 335 333 336 intsrc.srcbusirq = i; ··· 422 419 construct_ioapic_table(mpc_default_type); 423 420 424 421 lintsrc.type = MP_LINTSRC; 425 - lintsrc.irqflag = 0; /* conforming */ 422 + lintsrc.irqflag = MP_IRQTRIG_DEFAULT | MP_IRQPOL_DEFAULT; 426 423 lintsrc.srcbusid = 0; 427 424 lintsrc.srcbusirq = 0; 428 425 lintsrc.destapic = MP_APIC_ALL; ··· 667 664 if (m->irqtype != mp_INT) 668 665 return 0; 669 666 670 - if (m->irqflag != 0x0f) 667 + if (m->irqflag != (MP_IRQTRIG_LEVEL | MP_IRQPOL_ACTIVE_LOW)) 671 668 return 0; 672 669 673 670 /* not legacy */ ··· 676 673 if (mp_irqs[i].irqtype != mp_INT) 677 674 continue; 678 675 679 - if (mp_irqs[i].irqflag != 0x0f) 676 + if (mp_irqs[i].irqflag != (MP_IRQTRIG_LEVEL | 677 + MP_IRQPOL_ACTIVE_LOW)) 680 678 continue; 681 679 682 680 if (mp_irqs[i].srcbus != m->srcbus) ··· 788 784 if (mp_irqs[i].irqtype != mp_INT) 789 785 continue; 790 786 791 - if (mp_irqs[i].irqflag != 0x0f) 787 + if (mp_irqs[i].irqflag != (MP_IRQTRIG_LEVEL | 788 + MP_IRQPOL_ACTIVE_LOW)) 792 789 continue; 793 790 794 791 if (nr_m_spare > 0) {
+2 -3
arch/x86/platform/intel-mid/sfi.c
··· 96 96 pentry->freq_hz, pentry->irq); 97 97 mp_irq.type = MP_INTSRC; 98 98 mp_irq.irqtype = mp_INT; 99 - /* triggering mode edge bit 2-3, active high polarity bit 0-1 */ 100 - mp_irq.irqflag = 5; 99 + mp_irq.irqflag = MP_IRQTRIG_EDGE | MP_IRQPOL_ACTIVE_HIGH; 101 100 mp_irq.srcbus = MP_BUS_ISA; 102 101 mp_irq.srcbusirq = pentry->irq; /* IRQ */ 103 102 mp_irq.dstapic = MP_APIC_ALL; ··· 167 168 totallen, (u32)pentry->phys_addr, pentry->irq); 168 169 mp_irq.type = MP_INTSRC; 169 170 mp_irq.irqtype = mp_INT; 170 - mp_irq.irqflag = 0xf; /* level trigger and active low */ 171 + mp_irq.irqflag = MP_IRQTRIG_LEVEL | MP_IRQPOL_ACTIVE_LOW; 171 172 mp_irq.srcbus = MP_BUS_ISA; 172 173 mp_irq.srcbusirq = pentry->irq; /* IRQ */ 173 174 mp_irq.dstapic = MP_APIC_ALL;