aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-05-15 16:05:16 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-18 02:38:55 -0400
commite5198075c67a22ec9a09565b1ce88d3d3f5ba855 (patch)
tree3d4ea0efd8575e677509b022e649c62d4786ed55 /arch/x86/kernel
parentb5710ce92a8cf8e3fc0ffc230cfdbfa23463f1c8 (diff)
x86, apic: introduce io_apic_irq_attr
according to Ingo, io_apic irq-setup related functions have too many parameters with a repetitive signature. So reduce related funcs to get less params by passing a pointer to a newly defined io_apic_irq_attr structure. v2: io_apic_irq ==> irq_attr triggering ==> trigger v3: add set_io_apic_irq_attr [ Impact: cleanup ] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Len Brown <lenb@kernel.org> LKML-Reference: <4A08ACD3.2070401@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/acpi/boot.c22
-rw-r--r--arch/x86/kernel/apic/io_apic.c43
2 files changed, 37 insertions, 28 deletions
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index dcfbc3ab9e46..4af63dfb0f06 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -523,7 +523,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
523 * success: return IRQ number (>=0) 523 * success: return IRQ number (>=0)
524 * failure: return < 0 524 * failure: return < 0
525 */ 525 */
526int acpi_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity) 526int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
527{ 527{
528 unsigned int irq; 528 unsigned int irq;
529 unsigned int plat_gsi = gsi; 529 unsigned int plat_gsi = gsi;
@@ -533,14 +533,14 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
533 * Make sure all (legacy) PCI IRQs are set as level-triggered. 533 * Make sure all (legacy) PCI IRQs are set as level-triggered.
534 */ 534 */
535 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { 535 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
536 if (triggering == ACPI_LEVEL_SENSITIVE) 536 if (trigger == ACPI_LEVEL_SENSITIVE)
537 eisa_set_level_irq(gsi); 537 eisa_set_level_irq(gsi);
538 } 538 }
539#endif 539#endif
540 540
541#ifdef CONFIG_X86_IO_APIC 541#ifdef CONFIG_X86_IO_APIC
542 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { 542 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
543 plat_gsi = mp_register_gsi(dev, gsi, triggering, polarity); 543 plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
544 } 544 }
545#endif 545#endif
546 acpi_gsi_to_irq(plat_gsi, &irq); 546 acpi_gsi_to_irq(plat_gsi, &irq);
@@ -1156,7 +1156,7 @@ void __init mp_config_acpi_legacy_irqs(void)
1156 } 1156 }
1157} 1157}
1158 1158
1159static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int triggering, 1159static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
1160 int polarity) 1160 int polarity)
1161{ 1161{
1162#ifdef CONFIG_X86_MPPARSE 1162#ifdef CONFIG_X86_MPPARSE
@@ -1181,7 +1181,7 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int triggering,
1181 /* print the entry should happen on mptable identically */ 1181 /* print the entry should happen on mptable identically */
1182 mp_irq.type = MP_INTSRC; 1182 mp_irq.type = MP_INTSRC;
1183 mp_irq.irqtype = mp_INT; 1183 mp_irq.irqtype = mp_INT;
1184 mp_irq.irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | 1184 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
1185 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); 1185 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1186 mp_irq.srcbus = number; 1186 mp_irq.srcbus = number;
1187 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); 1187 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
@@ -1194,10 +1194,11 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int triggering,
1194 return 0; 1194 return 0;
1195} 1195}
1196 1196
1197int mp_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity) 1197int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
1198{ 1198{
1199 int ioapic; 1199 int ioapic;
1200 int ioapic_pin; 1200 int ioapic_pin;
1201 struct io_apic_irq_attr irq_attr;
1201 1202
1202 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) 1203 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1203 return gsi; 1204 return gsi;
@@ -1225,11 +1226,12 @@ int mp_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
1225 ioapic_pin); 1226 ioapic_pin);
1226 return gsi; 1227 return gsi;
1227 } 1228 }
1228 mp_config_acpi_gsi(dev, gsi, triggering, polarity); 1229 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
1229 1230
1230 io_apic_set_pci_routing(dev, ioapic, ioapic_pin, gsi, 1231 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
1231 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1, 1232 trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
1232 polarity == ACPI_ACTIVE_HIGH ? 0 : 1); 1233 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1234 io_apic_set_pci_routing(dev, gsi, &irq_attr);
1233 1235
1234 return gsi; 1236 return gsi;
1235} 1237}
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 74d2b480a20b..ce1ac74baa73 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1096,8 +1096,7 @@ static int pin_2_irq(int idx, int apic, int pin)
1096 * Not an __init, possibly needed by modules 1096 * Not an __init, possibly needed by modules
1097 */ 1097 */
1098int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin, 1098int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
1099 int *ioapic, int *ioapic_pin, 1099 struct io_apic_irq_attr *irq_attr)
1100 int *trigger, int *polarity)
1101{ 1100{
1102 int apic, i, best_guess = -1; 1101 int apic, i, best_guess = -1;
1103 1102
@@ -1127,10 +1126,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
1127 continue; 1126 continue;
1128 1127
1129 if (pin == (mp_irqs[i].srcbusirq & 3)) { 1128 if (pin == (mp_irqs[i].srcbusirq & 3)) {
1130 *ioapic = apic; 1129 set_io_apic_irq_attr(irq_attr, apic,
1131 *ioapic_pin = mp_irqs[i].dstirq; 1130 mp_irqs[i].dstirq,
1132 *trigger = irq_trigger(i); 1131 irq_trigger(i),
1133 *polarity = irq_polarity(i); 1132 irq_polarity(i));
1134 return irq; 1133 return irq;
1135 } 1134 }
1136 /* 1135 /*
@@ -1138,10 +1137,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
1138 * best-guess fuzzy result for broken mptables. 1137 * best-guess fuzzy result for broken mptables.
1139 */ 1138 */
1140 if (best_guess < 0) { 1139 if (best_guess < 0) {
1141 *ioapic = apic; 1140 set_io_apic_irq_attr(irq_attr, apic,
1142 *ioapic_pin = mp_irqs[i].dstirq; 1141 mp_irqs[i].dstirq,
1143 *trigger = irq_trigger(i); 1142 irq_trigger(i),
1144 *polarity = irq_polarity(i); 1143 irq_polarity(i));
1145 best_guess = irq; 1144 best_guess = irq;
1146 } 1145 }
1147 } 1146 }
@@ -3865,13 +3864,16 @@ int __init arch_probe_nr_irqs(void)
3865} 3864}
3866#endif 3865#endif
3867 3866
3868static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq, 3867static int __io_apic_set_pci_routing(struct device *dev, int irq,
3869 int triggering, int polarity) 3868 struct io_apic_irq_attr *irq_attr)
3870{ 3869{
3871 struct irq_desc *desc; 3870 struct irq_desc *desc;
3872 struct irq_cfg *cfg; 3871 struct irq_cfg *cfg;
3873 int node; 3872 int node;
3873 int ioapic, pin;
3874 int trigger, polarity;
3874 3875
3876 ioapic = irq_attr->ioapic;
3875 if (!IO_APIC_IRQ(irq)) { 3877 if (!IO_APIC_IRQ(irq)) {
3876 apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n", 3878 apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n",
3877 ioapic); 3879 ioapic);
@@ -3889,6 +3891,10 @@ static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, in
3889 return 0; 3891 return 0;
3890 } 3892 }
3891 3893
3894 pin = irq_attr->ioapic_pin;
3895 trigger = irq_attr->trigger;
3896 polarity = irq_attr->polarity;
3897
3892 /* 3898 /*
3893 * IRQs < 16 are already in the irq_2_pin[] map 3899 * IRQs < 16 are already in the irq_2_pin[] map
3894 */ 3900 */
@@ -3897,20 +3903,22 @@ static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, in
3897 add_pin_to_irq_node(cfg, node, ioapic, pin); 3903 add_pin_to_irq_node(cfg, node, ioapic, pin);
3898 } 3904 }
3899 3905
3900 setup_IO_APIC_irq(ioapic, pin, irq, desc, triggering, polarity); 3906 setup_IO_APIC_irq(ioapic, pin, irq, desc, trigger, polarity);
3901 3907
3902 return 0; 3908 return 0;
3903} 3909}
3904 3910
3905int io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq, 3911int io_apic_set_pci_routing(struct device *dev, int irq,
3906 int triggering, int polarity) 3912 struct io_apic_irq_attr *irq_attr)
3907{ 3913{
3908 3914 int ioapic, pin;
3909 /* 3915 /*
3910 * Avoid pin reprogramming. PRTs typically include entries 3916 * Avoid pin reprogramming. PRTs typically include entries
3911 * with redundant pin->gsi mappings (but unique PCI devices); 3917 * with redundant pin->gsi mappings (but unique PCI devices);
3912 * we only program the IOAPIC on the first. 3918 * we only program the IOAPIC on the first.
3913 */ 3919 */
3920 ioapic = irq_attr->ioapic;
3921 pin = irq_attr->ioapic_pin;
3914 if (test_bit(pin, mp_ioapic_routing[ioapic].pin_programmed)) { 3922 if (test_bit(pin, mp_ioapic_routing[ioapic].pin_programmed)) {
3915 pr_debug("Pin %d-%d already programmed\n", 3923 pr_debug("Pin %d-%d already programmed\n",
3916 mp_ioapics[ioapic].apicid, pin); 3924 mp_ioapics[ioapic].apicid, pin);
@@ -3918,8 +3926,7 @@ int io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq,
3918 } 3926 }
3919 set_bit(pin, mp_ioapic_routing[ioapic].pin_programmed); 3927 set_bit(pin, mp_ioapic_routing[ioapic].pin_programmed);
3920 3928
3921 return __io_apic_set_pci_routing(dev, ioapic, pin, irq, 3929 return __io_apic_set_pci_routing(dev, irq, irq_attr);
3922 triggering, polarity);
3923} 3930}
3924 3931
3925/* -------------------------------------------------------------------------- 3932/* --------------------------------------------------------------------------