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>
This commit is contained in:
parent
b5710ce92a
commit
e5198075c6
6 changed files with 66 additions and 47 deletions
|
@ -63,9 +63,26 @@ extern unsigned long io_apic_irqs;
|
||||||
extern void init_VISWS_APIC_irqs(void);
|
extern void init_VISWS_APIC_irqs(void);
|
||||||
extern void setup_IO_APIC(void);
|
extern void setup_IO_APIC(void);
|
||||||
extern void disable_IO_APIC(void);
|
extern void disable_IO_APIC(void);
|
||||||
|
|
||||||
|
struct io_apic_irq_attr {
|
||||||
|
int ioapic;
|
||||||
|
int ioapic_pin;
|
||||||
|
int trigger;
|
||||||
|
int polarity;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void set_io_apic_irq_attr(struct io_apic_irq_attr *irq_attr,
|
||||||
|
int ioapic, int ioapic_pin,
|
||||||
|
int trigger, int polarity)
|
||||||
|
{
|
||||||
|
irq_attr->ioapic = ioapic;
|
||||||
|
irq_attr->ioapic_pin = ioapic_pin;
|
||||||
|
irq_attr->trigger = trigger;
|
||||||
|
irq_attr->polarity = polarity;
|
||||||
|
}
|
||||||
|
|
||||||
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin,
|
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin,
|
||||||
int *ioapic, int *ioapic_pin,
|
struct io_apic_irq_attr *irq_attr);
|
||||||
int *trigger, int *polarity);
|
|
||||||
extern void setup_ioapic_dest(void);
|
extern void setup_ioapic_dest(void);
|
||||||
|
|
||||||
extern void enable_IO_APIC(void);
|
extern void enable_IO_APIC(void);
|
||||||
|
|
|
@ -156,8 +156,9 @@ extern int io_apic_get_version(int ioapic);
|
||||||
extern int io_apic_get_redir_entries(int ioapic);
|
extern int io_apic_get_redir_entries(int ioapic);
|
||||||
#endif /* CONFIG_ACPI */
|
#endif /* CONFIG_ACPI */
|
||||||
|
|
||||||
extern int io_apic_set_pci_routing(struct device *dev, int ioapic, int pin,
|
struct io_apic_irq_attr;
|
||||||
int irq, int edge_level, int active_high_low);
|
extern int io_apic_set_pci_routing(struct device *dev, int irq,
|
||||||
|
struct io_apic_irq_attr *irq_attr);
|
||||||
extern int (*ioapic_renumber_irq)(int ioapic, int irq);
|
extern int (*ioapic_renumber_irq)(int ioapic, int irq);
|
||||||
extern void ioapic_init_mappings(void);
|
extern void ioapic_init_mappings(void);
|
||||||
|
|
||||||
|
|
|
@ -523,7 +523,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
|
||||||
* success: return IRQ number (>=0)
|
* success: return IRQ number (>=0)
|
||||||
* failure: return < 0
|
* failure: return < 0
|
||||||
*/
|
*/
|
||||||
int acpi_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
|
int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
|
||||||
{
|
{
|
||||||
unsigned int irq;
|
unsigned int irq;
|
||||||
unsigned int plat_gsi = gsi;
|
unsigned int plat_gsi = gsi;
|
||||||
|
@ -533,14 +533,14 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
|
||||||
* Make sure all (legacy) PCI IRQs are set as level-triggered.
|
* Make sure all (legacy) PCI IRQs are set as level-triggered.
|
||||||
*/
|
*/
|
||||||
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
|
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
|
||||||
if (triggering == ACPI_LEVEL_SENSITIVE)
|
if (trigger == ACPI_LEVEL_SENSITIVE)
|
||||||
eisa_set_level_irq(gsi);
|
eisa_set_level_irq(gsi);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_X86_IO_APIC
|
#ifdef CONFIG_X86_IO_APIC
|
||||||
if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
|
if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
|
||||||
plat_gsi = mp_register_gsi(dev, gsi, triggering, polarity);
|
plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
acpi_gsi_to_irq(plat_gsi, &irq);
|
acpi_gsi_to_irq(plat_gsi, &irq);
|
||||||
|
@ -1156,7 +1156,7 @@ void __init mp_config_acpi_legacy_irqs(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int triggering,
|
static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
|
||||||
int polarity)
|
int polarity)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_X86_MPPARSE
|
#ifdef CONFIG_X86_MPPARSE
|
||||||
|
@ -1181,7 +1181,7 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int triggering,
|
||||||
/* print the entry should happen on mptable identically */
|
/* print the entry should happen on mptable identically */
|
||||||
mp_irq.type = MP_INTSRC;
|
mp_irq.type = MP_INTSRC;
|
||||||
mp_irq.irqtype = mp_INT;
|
mp_irq.irqtype = mp_INT;
|
||||||
mp_irq.irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
|
mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
|
||||||
(polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
|
(polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
|
||||||
mp_irq.srcbus = number;
|
mp_irq.srcbus = number;
|
||||||
mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
|
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,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mp_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
|
int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
|
||||||
{
|
{
|
||||||
int ioapic;
|
int ioapic;
|
||||||
int ioapic_pin;
|
int ioapic_pin;
|
||||||
|
struct io_apic_irq_attr irq_attr;
|
||||||
|
|
||||||
if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
|
if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
|
||||||
return gsi;
|
return gsi;
|
||||||
|
@ -1225,11 +1226,12 @@ int mp_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity)
|
||||||
ioapic_pin);
|
ioapic_pin);
|
||||||
return gsi;
|
return gsi;
|
||||||
}
|
}
|
||||||
mp_config_acpi_gsi(dev, gsi, triggering, polarity);
|
mp_config_acpi_gsi(dev, gsi, trigger, polarity);
|
||||||
|
|
||||||
io_apic_set_pci_routing(dev, ioapic, ioapic_pin, gsi,
|
set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
|
||||||
triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
|
trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
|
||||||
polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
|
polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
|
||||||
|
io_apic_set_pci_routing(dev, gsi, &irq_attr);
|
||||||
|
|
||||||
return gsi;
|
return gsi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,8 +1096,7 @@ static int pin_2_irq(int idx, int apic, int pin)
|
||||||
* Not an __init, possibly needed by modules
|
* Not an __init, possibly needed by modules
|
||||||
*/
|
*/
|
||||||
int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
|
int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
|
||||||
int *ioapic, int *ioapic_pin,
|
struct io_apic_irq_attr *irq_attr)
|
||||||
int *trigger, int *polarity)
|
|
||||||
{
|
{
|
||||||
int apic, i, best_guess = -1;
|
int apic, i, best_guess = -1;
|
||||||
|
|
||||||
|
@ -1127,10 +1126,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (pin == (mp_irqs[i].srcbusirq & 3)) {
|
if (pin == (mp_irqs[i].srcbusirq & 3)) {
|
||||||
*ioapic = apic;
|
set_io_apic_irq_attr(irq_attr, apic,
|
||||||
*ioapic_pin = mp_irqs[i].dstirq;
|
mp_irqs[i].dstirq,
|
||||||
*trigger = irq_trigger(i);
|
irq_trigger(i),
|
||||||
*polarity = irq_polarity(i);
|
irq_polarity(i));
|
||||||
return irq;
|
return irq;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1138,10 +1137,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
|
||||||
* best-guess fuzzy result for broken mptables.
|
* best-guess fuzzy result for broken mptables.
|
||||||
*/
|
*/
|
||||||
if (best_guess < 0) {
|
if (best_guess < 0) {
|
||||||
*ioapic = apic;
|
set_io_apic_irq_attr(irq_attr, apic,
|
||||||
*ioapic_pin = mp_irqs[i].dstirq;
|
mp_irqs[i].dstirq,
|
||||||
*trigger = irq_trigger(i);
|
irq_trigger(i),
|
||||||
*polarity = irq_polarity(i);
|
irq_polarity(i));
|
||||||
best_guess = irq;
|
best_guess = irq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3865,13 +3864,16 @@ int __init arch_probe_nr_irqs(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq,
|
static int __io_apic_set_pci_routing(struct device *dev, int irq,
|
||||||
int triggering, int polarity)
|
struct io_apic_irq_attr *irq_attr)
|
||||||
{
|
{
|
||||||
struct irq_desc *desc;
|
struct irq_desc *desc;
|
||||||
struct irq_cfg *cfg;
|
struct irq_cfg *cfg;
|
||||||
int node;
|
int node;
|
||||||
|
int ioapic, pin;
|
||||||
|
int trigger, polarity;
|
||||||
|
|
||||||
|
ioapic = irq_attr->ioapic;
|
||||||
if (!IO_APIC_IRQ(irq)) {
|
if (!IO_APIC_IRQ(irq)) {
|
||||||
apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n",
|
apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n",
|
||||||
ioapic);
|
ioapic);
|
||||||
|
@ -3889,6 +3891,10 @@ static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, in
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pin = irq_attr->ioapic_pin;
|
||||||
|
trigger = irq_attr->trigger;
|
||||||
|
polarity = irq_attr->polarity;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IRQs < 16 are already in the irq_2_pin[] map
|
* IRQs < 16 are already in the irq_2_pin[] map
|
||||||
*/
|
*/
|
||||||
|
@ -3897,20 +3903,22 @@ static int __io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, in
|
||||||
add_pin_to_irq_node(cfg, node, ioapic, pin);
|
add_pin_to_irq_node(cfg, node, ioapic, pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_IO_APIC_irq(ioapic, pin, irq, desc, triggering, polarity);
|
setup_IO_APIC_irq(ioapic, pin, irq, desc, trigger, polarity);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq,
|
int io_apic_set_pci_routing(struct device *dev, int irq,
|
||||||
int triggering, int polarity)
|
struct io_apic_irq_attr *irq_attr)
|
||||||
{
|
{
|
||||||
|
int ioapic, pin;
|
||||||
/*
|
/*
|
||||||
* Avoid pin reprogramming. PRTs typically include entries
|
* Avoid pin reprogramming. PRTs typically include entries
|
||||||
* with redundant pin->gsi mappings (but unique PCI devices);
|
* with redundant pin->gsi mappings (but unique PCI devices);
|
||||||
* we only program the IOAPIC on the first.
|
* we only program the IOAPIC on the first.
|
||||||
*/
|
*/
|
||||||
|
ioapic = irq_attr->ioapic;
|
||||||
|
pin = irq_attr->ioapic_pin;
|
||||||
if (test_bit(pin, mp_ioapic_routing[ioapic].pin_programmed)) {
|
if (test_bit(pin, mp_ioapic_routing[ioapic].pin_programmed)) {
|
||||||
pr_debug("Pin %d-%d already programmed\n",
|
pr_debug("Pin %d-%d already programmed\n",
|
||||||
mp_ioapics[ioapic].apicid, pin);
|
mp_ioapics[ioapic].apicid, pin);
|
||||||
|
@ -3918,8 +3926,7 @@ int io_apic_set_pci_routing(struct device *dev, int ioapic, int pin, int irq,
|
||||||
}
|
}
|
||||||
set_bit(pin, mp_ioapic_routing[ioapic].pin_programmed);
|
set_bit(pin, mp_ioapic_routing[ioapic].pin_programmed);
|
||||||
|
|
||||||
return __io_apic_set_pci_routing(dev, ioapic, pin, irq,
|
return __io_apic_set_pci_routing(dev, irq, irq_attr);
|
||||||
triggering, polarity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
|
|
|
@ -1200,14 +1200,11 @@ static int pirq_enable_irq(struct pci_dev *dev)
|
||||||
#ifdef CONFIG_X86_IO_APIC
|
#ifdef CONFIG_X86_IO_APIC
|
||||||
struct pci_dev *temp_dev;
|
struct pci_dev *temp_dev;
|
||||||
int irq;
|
int irq;
|
||||||
int ioapic = -1, ioapic_pin = -1;
|
struct io_apic_irq_attr irq_attr;
|
||||||
int triggering, polarity;
|
|
||||||
|
|
||||||
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
|
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
|
||||||
PCI_SLOT(dev->devfn),
|
PCI_SLOT(dev->devfn),
|
||||||
pin - 1,
|
pin - 1, &irq_attr);
|
||||||
&ioapic, &ioapic_pin,
|
|
||||||
&triggering, &polarity);
|
|
||||||
/*
|
/*
|
||||||
* Busses behind bridges are typically not listed in the MP-table.
|
* Busses behind bridges are typically not listed in the MP-table.
|
||||||
* In this case we have to look up the IRQ based on the parent bus,
|
* In this case we have to look up the IRQ based on the parent bus,
|
||||||
|
@ -1221,9 +1218,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
|
||||||
pin = pci_swizzle_interrupt_pin(dev, pin);
|
pin = pci_swizzle_interrupt_pin(dev, pin);
|
||||||
irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
|
irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
|
||||||
PCI_SLOT(bridge->devfn),
|
PCI_SLOT(bridge->devfn),
|
||||||
pin - 1,
|
pin - 1, &irq_attr);
|
||||||
&ioapic, &ioapic_pin,
|
|
||||||
&triggering, &polarity);
|
|
||||||
if (irq >= 0)
|
if (irq >= 0)
|
||||||
dev_warn(&dev->dev, "using bridge %s "
|
dev_warn(&dev->dev, "using bridge %s "
|
||||||
"INT %c to get IRQ %d\n",
|
"INT %c to get IRQ %d\n",
|
||||||
|
@ -1233,9 +1228,8 @@ static int pirq_enable_irq(struct pci_dev *dev)
|
||||||
}
|
}
|
||||||
dev = temp_dev;
|
dev = temp_dev;
|
||||||
if (irq >= 0) {
|
if (irq >= 0) {
|
||||||
io_apic_set_pci_routing(&dev->dev, ioapic,
|
io_apic_set_pci_routing(&dev->dev, irq,
|
||||||
ioapic_pin, irq,
|
&irq_attr);
|
||||||
triggering, polarity);
|
|
||||||
dev->irq = irq;
|
dev->irq = irq;
|
||||||
dev_info(&dev->dev, "PCI->APIC IRQ transform: "
|
dev_info(&dev->dev, "PCI->APIC IRQ transform: "
|
||||||
"INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
|
"INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
|
||||||
|
|
|
@ -155,15 +155,13 @@ int ibmphp_init_devno(struct slot **cur_slot)
|
||||||
for (loop = 0; loop < len; loop++) {
|
for (loop = 0; loop < len; loop++) {
|
||||||
if ((*cur_slot)->number == rtable->slots[loop].slot &&
|
if ((*cur_slot)->number == rtable->slots[loop].slot &&
|
||||||
(*cur_slot)->bus == rtable->slots[loop].bus) {
|
(*cur_slot)->bus == rtable->slots[loop].bus) {
|
||||||
int ioapic = -1, ioapic_pin = -1;
|
struct io_apic_irq_attr irq_attr;
|
||||||
int triggering, polarity;
|
|
||||||
|
|
||||||
(*cur_slot)->device = PCI_SLOT(rtable->slots[loop].devfn);
|
(*cur_slot)->device = PCI_SLOT(rtable->slots[loop].devfn);
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
(*cur_slot)->irq[i] = IO_APIC_get_PCI_irq_vector((int) (*cur_slot)->bus,
|
(*cur_slot)->irq[i] = IO_APIC_get_PCI_irq_vector((int) (*cur_slot)->bus,
|
||||||
(int) (*cur_slot)->device, i,
|
(int) (*cur_slot)->device, i,
|
||||||
&ioapic, &ioapic_pin,
|
&irq_attr);
|
||||||
&triggering, &polarity);
|
|
||||||
|
|
||||||
debug("(*cur_slot)->irq[0] = %x\n",
|
debug("(*cur_slot)->irq[0] = %x\n",
|
||||||
(*cur_slot)->irq[0]);
|
(*cur_slot)->irq[0]);
|
||||||
|
|
Loading…
Reference in a new issue