Skip to content

Commit e20c06f

Browse files
Yinghai LuIngo Molnar
authored andcommitted
x86/pci: add 4 more return parameters to IO_APIC_get_PCI_irq_vector()
To prepare those params for pcibios_irq_enable() to call setup_io_apic_routing(). [ Impact: extend function call API to prepare for new functionality ] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Len Brown <lenb@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> LKML-Reference: <4A01C406.2040303@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent bdfe8ac commit e20c06f

4 files changed

Lines changed: 112 additions & 79 deletions

File tree

‎arch/x86/include/asm/hw_irq.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ extern unsigned long io_apic_irqs;
6363
extern void init_VISWS_APIC_irqs(void);
6464
extern void setup_IO_APIC(void);
6565
extern void disable_IO_APIC(void);
66-
extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn);
66+
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin,
67+
int *ioapic, int *ioapic_pin,
68+
int *trigger, int *polarity);
6769
extern void setup_ioapic_dest(void);
6870

6971
extern void enable_IO_APIC(void);

‎arch/x86/kernel/apic/io_apic.c‎

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -873,54 +873,6 @@ static int __init find_isa_irq_apic(int irq, int type)
873873
return -1;
874874
}
875875

876-
/*
877-
* Find a specific PCI IRQ entry.
878-
* Not an __init, possibly needed by modules
879-
*/
880-
static int pin_2_irq(int idx, int apic, int pin);
881-
882-
int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
883-
{
884-
int apic, i, best_guess = -1;
885-
886-
apic_printk(APIC_DEBUG, "querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n",
887-
bus, slot, pin);
888-
if (test_bit(bus, mp_bus_not_pci)) {
889-
apic_printk(APIC_VERBOSE, "PCI BIOS passed nonexistent PCI bus %d!\n", bus);
890-
return -1;
891-
}
892-
for (i = 0; i < mp_irq_entries; i++) {
893-
int lbus = mp_irqs[i].srcbus;
894-
895-
for (apic = 0; apic < nr_ioapics; apic++)
896-
if (mp_ioapics[apic].apicid == mp_irqs[i].dstapic ||
897-
mp_irqs[i].dstapic == MP_APIC_ALL)
898-
break;
899-
900-
if (!test_bit(lbus, mp_bus_not_pci) &&
901-
!mp_irqs[i].irqtype &&
902-
(bus == lbus) &&
903-
(slot == ((mp_irqs[i].srcbusirq >> 2) & 0x1f))) {
904-
int irq = pin_2_irq(i, apic, mp_irqs[i].dstirq);
905-
906-
if (!(apic || IO_APIC_IRQ(irq)))
907-
continue;
908-
909-
if (pin == (mp_irqs[i].srcbusirq & 3))
910-
return irq;
911-
/*
912-
* Use the first all-but-pin matching entry as a
913-
* best-guess fuzzy result for broken mptables.
914-
*/
915-
if (best_guess < 0)
916-
best_guess = irq;
917-
}
918-
}
919-
return best_guess;
920-
}
921-
922-
EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
923-
924876
#if defined(CONFIG_EISA) || defined(CONFIG_MCA)
925877
/*
926878
* EISA Edge/Level control register, ELCR
@@ -1139,6 +1091,65 @@ static int pin_2_irq(int idx, int apic, int pin)
11391091
return irq;
11401092
}
11411093

1094+
/*
1095+
* Find a specific PCI IRQ entry.
1096+
* Not an __init, possibly needed by modules
1097+
*/
1098+
int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
1099+
int *ioapic, int *ioapic_pin,
1100+
int *trigger, int *polarity)
1101+
{
1102+
int apic, i, best_guess = -1;
1103+
1104+
apic_printk(APIC_DEBUG,
1105+
"querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n",
1106+
bus, slot, pin);
1107+
if (test_bit(bus, mp_bus_not_pci)) {
1108+
apic_printk(APIC_VERBOSE,
1109+
"PCI BIOS passed nonexistent PCI bus %d!\n", bus);
1110+
return -1;
1111+
}
1112+
for (i = 0; i < mp_irq_entries; i++) {
1113+
int lbus = mp_irqs[i].srcbus;
1114+
1115+
for (apic = 0; apic < nr_ioapics; apic++)
1116+
if (mp_ioapics[apic].apicid == mp_irqs[i].dstapic ||
1117+
mp_irqs[i].dstapic == MP_APIC_ALL)
1118+
break;
1119+
1120+
if (!test_bit(lbus, mp_bus_not_pci) &&
1121+
!mp_irqs[i].irqtype &&
1122+
(bus == lbus) &&
1123+
(slot == ((mp_irqs[i].srcbusirq >> 2) & 0x1f))) {
1124+
int irq = pin_2_irq(i, apic, mp_irqs[i].dstirq);
1125+
1126+
if (!(apic || IO_APIC_IRQ(irq)))
1127+
continue;
1128+
1129+
if (pin == (mp_irqs[i].srcbusirq & 3)) {
1130+
*ioapic = apic;
1131+
*ioapic_pin = mp_irqs[i].dstirq;
1132+
*trigger = irq_trigger(i);
1133+
*polarity = irq_polarity(i);
1134+
return irq;
1135+
}
1136+
/*
1137+
* Use the first all-but-pin matching entry as a
1138+
* best-guess fuzzy result for broken mptables.
1139+
*/
1140+
if (best_guess < 0) {
1141+
*ioapic = apic;
1142+
*ioapic_pin = mp_irqs[i].dstirq;
1143+
*trigger = irq_trigger(i);
1144+
*polarity = irq_polarity(i);
1145+
best_guess = irq;
1146+
}
1147+
}
1148+
}
1149+
return best_guess;
1150+
}
1151+
EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
1152+
11421153
void lock_vector_lock(void)
11431154
{
11441155
/* Used to the online set of cpus does not change

‎arch/x86/pci/irq.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,16 @@ static void __init pcibios_fixup_irqs(void)
10511051
*/
10521052
if (io_apic_assign_pci_irqs) {
10531053
int irq;
1054+
int ioapic = -1, ioapic_pin = -1;
1055+
int triggering, polarity;
10541056

10551057
/*
10561058
* interrupt pins are numbered starting from 1
10571059
*/
10581060
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
1059-
PCI_SLOT(dev->devfn), pin - 1);
1061+
PCI_SLOT(dev->devfn), pin - 1,
1062+
&ioapic, &ioapic_pin,
1063+
&triggering, &polarity);
10601064
/*
10611065
* Busses behind bridges are typically not listed in the
10621066
* MP-table. In this case we have to look up the IRQ
@@ -1072,7 +1076,10 @@ static void __init pcibios_fixup_irqs(void)
10721076
pin = pci_swizzle_interrupt_pin(dev, pin);
10731077
bus = bridge->bus->number;
10741078
irq = IO_APIC_get_PCI_irq_vector(bus,
1075-
PCI_SLOT(bridge->devfn), pin - 1);
1079+
PCI_SLOT(bridge->devfn),
1080+
pin - 1,
1081+
&ioapic, &ioapic_pin,
1082+
&triggering, &polarity);
10761083
if (irq >= 0)
10771084
dev_warn(&dev->dev,
10781085
"using bridge %s INT %c to "
@@ -1221,8 +1228,14 @@ static int pirq_enable_irq(struct pci_dev *dev)
12211228

12221229
if (io_apic_assign_pci_irqs) {
12231230
int irq;
1231+
int ioapic = -1, ioapic_pin = -1;
1232+
int triggering, polarity;
12241233

1225-
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, PCI_SLOT(dev->devfn), pin - 1);
1234+
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
1235+
PCI_SLOT(dev->devfn),
1236+
pin - 1,
1237+
&ioapic, &ioapic_pin,
1238+
&triggering, &polarity);
12261239
/*
12271240
* Busses behind bridges are typically not listed in the MP-table.
12281241
* In this case we have to look up the IRQ based on the parent bus,
@@ -1235,7 +1248,10 @@ static int pirq_enable_irq(struct pci_dev *dev)
12351248

12361249
pin = pci_swizzle_interrupt_pin(dev, pin);
12371250
irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
1238-
PCI_SLOT(bridge->devfn), pin - 1);
1251+
PCI_SLOT(bridge->devfn),
1252+
pin - 1,
1253+
&ioapic, &ioapic_pin,
1254+
&triggering, &polarity);
12391255
if (irq >= 0)
12401256
dev_warn(&dev->dev, "using bridge %s "
12411257
"INT %c to get IRQ %d\n",

‎drivers/pci/hotplug/ibmphp_core.c‎

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,45 +153,49 @@ int ibmphp_init_devno(struct slot **cur_slot)
153153
return -1;
154154
}
155155
for (loop = 0; loop < len; loop++) {
156-
if ((*cur_slot)->number == rtable->slots[loop].slot) {
157-
if ((*cur_slot)->bus == rtable->slots[loop].bus) {
156+
if ((*cur_slot)->number == rtable->slots[loop].slot &&
157+
(*cur_slot)->bus == rtable->slots[loop].bus) {
158+
int ioapic = -1, ioapic_pin = -1;
159+
int triggering, polarity;
160+
158161
(*cur_slot)->device = PCI_SLOT(rtable->slots[loop].devfn);
159162
for (i = 0; i < 4; i++)
160163
(*cur_slot)->irq[i] = IO_APIC_get_PCI_irq_vector((int) (*cur_slot)->bus,
161-
(int) (*cur_slot)->device, i);
162-
163-
debug("(*cur_slot)->irq[0] = %x\n",
164-
(*cur_slot)->irq[0]);
165-
debug("(*cur_slot)->irq[1] = %x\n",
166-
(*cur_slot)->irq[1]);
167-
debug("(*cur_slot)->irq[2] = %x\n",
168-
(*cur_slot)->irq[2]);
169-
debug("(*cur_slot)->irq[3] = %x\n",
170-
(*cur_slot)->irq[3]);
171-
172-
debug("rtable->exlusive_irqs = %x\n",
164+
(int) (*cur_slot)->device, i.
165+
&ioapic, &ioapic_pin,
166+
&triggering, &polarity);
167+
168+
debug("(*cur_slot)->irq[0] = %x\n",
169+
(*cur_slot)->irq[0]);
170+
debug("(*cur_slot)->irq[1] = %x\n",
171+
(*cur_slot)->irq[1]);
172+
debug("(*cur_slot)->irq[2] = %x\n",
173+
(*cur_slot)->irq[2]);
174+
debug("(*cur_slot)->irq[3] = %x\n",
175+
(*cur_slot)->irq[3]);
176+
177+
debug("rtable->exlusive_irqs = %x\n",
173178
rtable->exclusive_irqs);
174-
debug("rtable->slots[loop].irq[0].bitmap = %x\n",
179+
debug("rtable->slots[loop].irq[0].bitmap = %x\n",
175180
rtable->slots[loop].irq[0].bitmap);
176-
debug("rtable->slots[loop].irq[1].bitmap = %x\n",
181+
debug("rtable->slots[loop].irq[1].bitmap = %x\n",
177182
rtable->slots[loop].irq[1].bitmap);
178-
debug("rtable->slots[loop].irq[2].bitmap = %x\n",
183+
debug("rtable->slots[loop].irq[2].bitmap = %x\n",
179184
rtable->slots[loop].irq[2].bitmap);
180-
debug("rtable->slots[loop].irq[3].bitmap = %x\n",
185+
debug("rtable->slots[loop].irq[3].bitmap = %x\n",
181186
rtable->slots[loop].irq[3].bitmap);
182187

183-
debug("rtable->slots[loop].irq[0].link = %x\n",
188+
debug("rtable->slots[loop].irq[0].link = %x\n",
184189
rtable->slots[loop].irq[0].link);
185-
debug("rtable->slots[loop].irq[1].link = %x\n",
190+
debug("rtable->slots[loop].irq[1].link = %x\n",
186191
rtable->slots[loop].irq[1].link);
187-
debug("rtable->slots[loop].irq[2].link = %x\n",
192+
debug("rtable->slots[loop].irq[2].link = %x\n",
188193
rtable->slots[loop].irq[2].link);
189-
debug("rtable->slots[loop].irq[3].link = %x\n",
194+
debug("rtable->slots[loop].irq[3].link = %x\n",
190195
rtable->slots[loop].irq[3].link);
191-
debug("end of init_devno\n");
192-
kfree(rtable);
193-
return 0;
194-
}
196+
debug("end of init_devno\n");
197+
kfree(rtable);
198+
return 0;
195199
}
196200
}
197201

0 commit comments

Comments
 (0)