2 * pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * 1. Support more than one IRQ resource entry per link device (index).
28 * 2. Implement start/stop mechanism and use ACPI Bus Driver facilities
29 * for IRQ management (e.g. start()->_SRS).
32 #include <linux/syscore_ops.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/types.h>
37 #include <linux/spinlock.h>
39 #include <linux/pci.h>
40 #include <linux/mutex.h>
41 #include <linux/slab.h>
42 #include <linux/acpi.h>
46 #define _COMPONENT ACPI_PCI_COMPONENT
47 ACPI_MODULE_NAME("pci_link");
48 #define ACPI_PCI_LINK_CLASS "pci_irq_routing"
49 #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
50 #define ACPI_PCI_LINK_FILE_INFO "info"
51 #define ACPI_PCI_LINK_FILE_STATUS "state"
52 #define ACPI_PCI_LINK_MAX_POSSIBLE 16
54 static int acpi_pci_link_add(struct acpi_device
*device
,
55 const struct acpi_device_id
*not_used
);
56 static void acpi_pci_link_remove(struct acpi_device
*device
);
58 static const struct acpi_device_id link_device_ids
[] = {
63 static struct acpi_scan_handler pci_link_handler
= {
64 .ids
= link_device_ids
,
65 .attach
= acpi_pci_link_add
,
66 .detach
= acpi_pci_link_remove
,
70 * If a link is initialized, we never change its active and initialized
71 * later even the link is disable. Instead, we just repick the active irq
73 struct acpi_pci_link_irq
{
74 u8 active
; /* Current IRQ */
75 u8 triggering
; /* All IRQs */
76 u8 polarity
; /* All IRQs */
79 u8 possible
[ACPI_PCI_LINK_MAX_POSSIBLE
];
84 struct acpi_pci_link
{
85 struct list_head list
;
86 struct acpi_device
*device
;
87 struct acpi_pci_link_irq irq
;
91 static LIST_HEAD(acpi_link_list
);
92 static DEFINE_MUTEX(acpi_link_lock
);
94 /* --------------------------------------------------------------------------
95 PCI Link Device Management
96 -------------------------------------------------------------------------- */
99 * set context (link) possible list from resource list
101 static acpi_status
acpi_pci_link_check_possible(struct acpi_resource
*resource
,
104 struct acpi_pci_link
*link
= context
;
107 switch (resource
->type
) {
108 case ACPI_RESOURCE_TYPE_START_DEPENDENT
:
109 case ACPI_RESOURCE_TYPE_END_TAG
:
111 case ACPI_RESOURCE_TYPE_IRQ
:
113 struct acpi_resource_irq
*p
= &resource
->data
.irq
;
114 if (!p
|| !p
->interrupt_count
) {
115 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
116 "Blank _PRS IRQ resource\n"));
120 (i
< p
->interrupt_count
121 && i
< ACPI_PCI_LINK_MAX_POSSIBLE
); i
++) {
122 if (!p
->interrupts
[i
]) {
123 printk(KERN_WARNING PREFIX
124 "Invalid _PRS IRQ %d\n",
128 link
->irq
.possible
[i
] = p
->interrupts
[i
];
129 link
->irq
.possible_count
++;
131 link
->irq
.triggering
= p
->triggering
;
132 link
->irq
.polarity
= p
->polarity
;
133 link
->irq
.resource_type
= ACPI_RESOURCE_TYPE_IRQ
;
136 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ
:
138 struct acpi_resource_extended_irq
*p
=
139 &resource
->data
.extended_irq
;
140 if (!p
|| !p
->interrupt_count
) {
141 printk(KERN_WARNING PREFIX
142 "Blank _PRS EXT IRQ resource\n");
146 (i
< p
->interrupt_count
147 && i
< ACPI_PCI_LINK_MAX_POSSIBLE
); i
++) {
148 if (!p
->interrupts
[i
]) {
149 printk(KERN_WARNING PREFIX
150 "Invalid _PRS IRQ %d\n",
154 link
->irq
.possible
[i
] = p
->interrupts
[i
];
155 link
->irq
.possible_count
++;
157 link
->irq
.triggering
= p
->triggering
;
158 link
->irq
.polarity
= p
->polarity
;
159 link
->irq
.resource_type
= ACPI_RESOURCE_TYPE_EXTENDED_IRQ
;
163 printk(KERN_ERR PREFIX
"_PRS resource type 0x%x isn't an IRQ\n",
168 return AE_CTRL_TERMINATE
;
171 static int acpi_pci_link_get_possible(struct acpi_pci_link
*link
)
175 status
= acpi_walk_resources(link
->device
->handle
, METHOD_NAME__PRS
,
176 acpi_pci_link_check_possible
, link
);
177 if (ACPI_FAILURE(status
)) {
178 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _PRS"));
182 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
183 "Found %d possible IRQs\n",
184 link
->irq
.possible_count
));
189 static acpi_status
acpi_pci_link_check_current(struct acpi_resource
*resource
,
194 switch (resource
->type
) {
195 case ACPI_RESOURCE_TYPE_START_DEPENDENT
:
196 case ACPI_RESOURCE_TYPE_END_TAG
:
198 case ACPI_RESOURCE_TYPE_IRQ
:
200 struct acpi_resource_irq
*p
= &resource
->data
.irq
;
201 if (!p
|| !p
->interrupt_count
) {
203 * IRQ descriptors may have no IRQ# bits set,
204 * particularly those those w/ _STA disabled
206 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
207 "Blank _CRS IRQ resource\n"));
210 *irq
= p
->interrupts
[0];
213 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ
:
215 struct acpi_resource_extended_irq
*p
=
216 &resource
->data
.extended_irq
;
217 if (!p
|| !p
->interrupt_count
) {
219 * extended IRQ descriptors must
220 * return at least 1 IRQ
222 printk(KERN_WARNING PREFIX
223 "Blank _CRS EXT IRQ resource\n");
226 *irq
= p
->interrupts
[0];
231 printk(KERN_ERR PREFIX
"_CRS resource type 0x%x isn't an IRQ\n",
236 return AE_CTRL_TERMINATE
;
240 * Run _CRS and set link->irq.active
246 static int acpi_pci_link_get_current(struct acpi_pci_link
*link
)
252 link
->irq
.active
= 0;
254 /* in practice, status disabled is meaningless, ignore it */
256 /* Query _STA, set link->device->status */
257 result
= acpi_bus_get_status(link
->device
);
259 printk(KERN_ERR PREFIX
"Unable to read status\n");
263 if (!link
->device
->status
.enabled
) {
264 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link disabled\n"));
270 * Query and parse _CRS to get the current IRQ assignment.
273 status
= acpi_walk_resources(link
->device
->handle
, METHOD_NAME__CRS
,
274 acpi_pci_link_check_current
, &irq
);
275 if (ACPI_FAILURE(status
)) {
276 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _CRS"));
281 if (acpi_strict
&& !irq
) {
282 printk(KERN_ERR PREFIX
"_CRS returned 0\n");
286 link
->irq
.active
= irq
;
288 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link at IRQ %d \n", link
->irq
.active
));
294 static int acpi_pci_link_set(struct acpi_pci_link
*link
, int irq
)
299 struct acpi_resource res
;
300 struct acpi_resource end
;
302 struct acpi_buffer buffer
= { 0, NULL
};
307 resource
= kzalloc(sizeof(*resource
) + 1, irqs_disabled() ? GFP_ATOMIC
: GFP_KERNEL
);
311 buffer
.length
= sizeof(*resource
) + 1;
312 buffer
.pointer
= resource
;
314 switch (link
->irq
.resource_type
) {
315 case ACPI_RESOURCE_TYPE_IRQ
:
316 resource
->res
.type
= ACPI_RESOURCE_TYPE_IRQ
;
317 resource
->res
.length
= sizeof(struct acpi_resource
);
318 resource
->res
.data
.irq
.triggering
= link
->irq
.triggering
;
319 resource
->res
.data
.irq
.polarity
=
321 if (link
->irq
.triggering
== ACPI_EDGE_SENSITIVE
)
322 resource
->res
.data
.irq
.sharable
=
325 resource
->res
.data
.irq
.sharable
= ACPI_SHARED
;
326 resource
->res
.data
.irq
.interrupt_count
= 1;
327 resource
->res
.data
.irq
.interrupts
[0] = irq
;
330 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ
:
331 resource
->res
.type
= ACPI_RESOURCE_TYPE_EXTENDED_IRQ
;
332 resource
->res
.length
= sizeof(struct acpi_resource
);
333 resource
->res
.data
.extended_irq
.producer_consumer
=
335 resource
->res
.data
.extended_irq
.triggering
=
336 link
->irq
.triggering
;
337 resource
->res
.data
.extended_irq
.polarity
=
339 if (link
->irq
.triggering
== ACPI_EDGE_SENSITIVE
)
340 resource
->res
.data
.irq
.sharable
=
343 resource
->res
.data
.irq
.sharable
= ACPI_SHARED
;
344 resource
->res
.data
.extended_irq
.interrupt_count
= 1;
345 resource
->res
.data
.extended_irq
.interrupts
[0] = irq
;
346 /* ignore resource_source, it's optional */
349 printk(KERN_ERR PREFIX
"Invalid Resource_type %d\n", link
->irq
.resource_type
);
354 resource
->end
.type
= ACPI_RESOURCE_TYPE_END_TAG
;
355 resource
->end
.length
= sizeof(struct acpi_resource
);
357 /* Attempt to set the resource */
358 status
= acpi_set_current_resources(link
->device
->handle
, &buffer
);
360 /* check for total failure */
361 if (ACPI_FAILURE(status
)) {
362 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _SRS"));
367 /* Query _STA, set device->status */
368 result
= acpi_bus_get_status(link
->device
);
370 printk(KERN_ERR PREFIX
"Unable to read status\n");
373 if (!link
->device
->status
.enabled
) {
374 printk(KERN_WARNING PREFIX
375 "%s [%s] disabled and referenced, BIOS bug\n",
376 acpi_device_name(link
->device
),
377 acpi_device_bid(link
->device
));
380 /* Query _CRS, set link->irq.active */
381 result
= acpi_pci_link_get_current(link
);
387 * Is current setting not what we set?
388 * set link->irq.active
390 if (link
->irq
.active
!= irq
) {
392 * policy: when _CRS doesn't return what we just _SRS
393 * assume _SRS worked and override _CRS value.
395 printk(KERN_WARNING PREFIX
396 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
397 acpi_device_name(link
->device
),
398 acpi_device_bid(link
->device
), link
->irq
.active
, irq
);
399 link
->irq
.active
= irq
;
402 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Set IRQ %d\n", link
->irq
.active
));
409 /* --------------------------------------------------------------------------
410 PCI Link IRQ Management
411 -------------------------------------------------------------------------- */
414 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
415 * Link Devices to move the PIRQs around to minimize sharing.
417 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
418 * that the BIOS has already set to active. This is necessary because
419 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that
420 * if the BIOS doesn't set a Link Device active, ACPI needs to program it
421 * even if acpi_irq_nobalance is set.
423 * A tables of penalties avoids directing PCI interrupts to well known
424 * ISA IRQs. Boot params are available to over-ride the default table:
426 * List interrupts that are free for PCI use.
429 * List interrupts that should not be used for PCI:
432 * Note that PCI IRQ routers have a list of possible IRQs,
433 * which may not include the IRQs this table says are available.
435 * Since this heuristic can't tell the difference between a link
436 * that no device will attach to, vs. a link which may be shared
437 * by multiple active devices -- it is not optimal.
439 * If interrupt performance is that important, get an IO-APIC system
440 * with a pin dedicated to each device. Or for that matter, an MSI
444 #define ACPI_MAX_IRQS 256
445 #define ACPI_MAX_ISA_IRQ 16
447 #define PIRQ_PENALTY_PCI_AVAILABLE (0)
448 #define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
449 #define PIRQ_PENALTY_PCI_USING (16*16*16)
450 #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
451 #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
452 #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
454 static int acpi_irq_penalty
[ACPI_MAX_IRQS
] = {
455 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ0 timer */
456 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ1 keyboard */
457 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ2 cascade */
458 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ3 serial */
459 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ4 serial */
460 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ5 sometimes SoundBlaster */
461 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ6 */
462 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ7 parallel, spurious */
463 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ8 rtc, sometimes */
464 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ9 PCI, often acpi */
465 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ10 PCI */
466 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ11 PCI */
467 PIRQ_PENALTY_ISA_USED
, /* IRQ12 mouse */
468 PIRQ_PENALTY_ISA_USED
, /* IRQ13 fpe, sometimes */
469 PIRQ_PENALTY_ISA_USED
, /* IRQ14 ide0 */
470 PIRQ_PENALTY_ISA_USED
, /* IRQ15 ide1 */
474 int __init
acpi_irq_penalty_init(void)
476 struct acpi_pci_link
*link
;
480 * Update penalties to facilitate IRQ balancing.
482 list_for_each_entry(link
, &acpi_link_list
, list
) {
485 * reflect the possible and active irqs in the penalty table --
486 * useful for breaking ties.
488 if (link
->irq
.possible_count
) {
490 PIRQ_PENALTY_PCI_POSSIBLE
/
491 link
->irq
.possible_count
;
493 for (i
= 0; i
< link
->irq
.possible_count
; i
++) {
494 if (link
->irq
.possible
[i
] < ACPI_MAX_ISA_IRQ
)
495 acpi_irq_penalty
[link
->irq
.
500 } else if (link
->irq
.active
) {
501 acpi_irq_penalty
[link
->irq
.active
] +=
502 PIRQ_PENALTY_PCI_POSSIBLE
;
505 /* Add a penalty for the SCI */
506 acpi_irq_penalty
[acpi_gbl_FADT
.sci_interrupt
] += PIRQ_PENALTY_PCI_USING
;
510 static int acpi_irq_balance
= -1; /* 0: static, 1: balance */
512 static int acpi_pci_link_allocate(struct acpi_pci_link
*link
)
517 if (link
->irq
.initialized
) {
518 if (link
->refcnt
== 0)
519 /* This means the link is disabled but initialized */
520 acpi_pci_link_set(link
, link
->irq
.active
);
525 * search for active IRQ in list of possible IRQs.
527 for (i
= 0; i
< link
->irq
.possible_count
; ++i
) {
528 if (link
->irq
.active
== link
->irq
.possible
[i
])
532 * forget active IRQ that is not in possible list
534 if (i
== link
->irq
.possible_count
) {
536 printk(KERN_WARNING PREFIX
"_CRS %d not found"
537 " in _PRS\n", link
->irq
.active
);
538 link
->irq
.active
= 0;
542 * if active found, use it; else pick entry from end of possible list.
544 if (link
->irq
.active
)
545 irq
= link
->irq
.active
;
547 irq
= link
->irq
.possible
[link
->irq
.possible_count
- 1];
549 if (acpi_irq_balance
|| !link
->irq
.active
) {
551 * Select the best IRQ. This is done in reverse to promote
552 * the use of IRQs 9, 10, 11, and >15.
554 for (i
= (link
->irq
.possible_count
- 1); i
>= 0; i
--) {
555 if (acpi_irq_penalty
[irq
] >
556 acpi_irq_penalty
[link
->irq
.possible
[i
]])
557 irq
= link
->irq
.possible
[i
];
561 /* Attempt to enable the link device at this IRQ. */
562 if (acpi_pci_link_set(link
, irq
)) {
563 printk(KERN_ERR PREFIX
"Unable to set IRQ for %s [%s]. "
564 "Try pci=noacpi or acpi=off\n",
565 acpi_device_name(link
->device
),
566 acpi_device_bid(link
->device
));
569 acpi_irq_penalty
[link
->irq
.active
] += PIRQ_PENALTY_PCI_USING
;
570 printk(KERN_WARNING PREFIX
"%s [%s] enabled at IRQ %d\n",
571 acpi_device_name(link
->device
),
572 acpi_device_bid(link
->device
), link
->irq
.active
);
575 link
->irq
.initialized
= 1;
580 * acpi_pci_link_allocate_irq
581 * success: return IRQ >= 0
584 int acpi_pci_link_allocate_irq(acpi_handle handle
, int index
, int *triggering
,
585 int *polarity
, char **name
)
588 struct acpi_device
*device
;
589 struct acpi_pci_link
*link
;
591 result
= acpi_bus_get_device(handle
, &device
);
593 printk(KERN_ERR PREFIX
"Invalid link device\n");
597 link
= acpi_driver_data(device
);
599 printk(KERN_ERR PREFIX
"Invalid link context\n");
603 /* TBD: Support multiple index (IRQ) entries per Link Device */
605 printk(KERN_ERR PREFIX
"Invalid index %d\n", index
);
609 mutex_lock(&acpi_link_lock
);
610 if (acpi_pci_link_allocate(link
)) {
611 mutex_unlock(&acpi_link_lock
);
615 if (!link
->irq
.active
) {
616 mutex_unlock(&acpi_link_lock
);
617 printk(KERN_ERR PREFIX
"Link active IRQ is 0!\n");
621 mutex_unlock(&acpi_link_lock
);
624 *triggering
= link
->irq
.triggering
;
626 *polarity
= link
->irq
.polarity
;
628 *name
= acpi_device_bid(link
->device
);
629 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
630 "Link %s is referenced\n",
631 acpi_device_bid(link
->device
)));
632 return (link
->irq
.active
);
636 * We don't change link's irq information here. After it is reenabled, we
637 * continue use the info
639 int acpi_pci_link_free_irq(acpi_handle handle
)
641 struct acpi_device
*device
;
642 struct acpi_pci_link
*link
;
645 result
= acpi_bus_get_device(handle
, &device
);
647 printk(KERN_ERR PREFIX
"Invalid link device\n");
651 link
= acpi_driver_data(device
);
653 printk(KERN_ERR PREFIX
"Invalid link context\n");
657 mutex_lock(&acpi_link_lock
);
658 if (!link
->irq
.initialized
) {
659 mutex_unlock(&acpi_link_lock
);
660 printk(KERN_ERR PREFIX
"Link isn't initialized\n");
665 * The Link reference count allows us to _DISable an unused link
666 * and suspend time, and set it again on resume.
667 * However, 2.6.12 still has irq_router.resume
668 * which blindly restores the link state.
669 * So we disable the reference count method
670 * to prevent duplicate acpi_pci_link_set()
671 * which would harm some systems
675 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
676 "Link %s is dereferenced\n",
677 acpi_device_bid(link
->device
)));
679 if (link
->refcnt
== 0)
680 acpi_evaluate_object(link
->device
->handle
, "_DIS", NULL
, NULL
);
682 mutex_unlock(&acpi_link_lock
);
683 return (link
->irq
.active
);
686 /* --------------------------------------------------------------------------
688 -------------------------------------------------------------------------- */
690 static int acpi_pci_link_add(struct acpi_device
*device
,
691 const struct acpi_device_id
*not_used
)
694 struct acpi_pci_link
*link
;
698 link
= kzalloc(sizeof(struct acpi_pci_link
), GFP_KERNEL
);
702 link
->device
= device
;
703 strcpy(acpi_device_name(device
), ACPI_PCI_LINK_DEVICE_NAME
);
704 strcpy(acpi_device_class(device
), ACPI_PCI_LINK_CLASS
);
705 device
->driver_data
= link
;
707 mutex_lock(&acpi_link_lock
);
708 result
= acpi_pci_link_get_possible(link
);
712 /* query and set link->irq.active */
713 acpi_pci_link_get_current(link
);
715 printk(KERN_INFO PREFIX
"%s [%s] (IRQs", acpi_device_name(device
),
716 acpi_device_bid(device
));
717 for (i
= 0; i
< link
->irq
.possible_count
; i
++) {
718 if (link
->irq
.active
== link
->irq
.possible
[i
]) {
719 printk(KERN_CONT
" *%d", link
->irq
.possible
[i
]);
722 printk(KERN_CONT
" %d", link
->irq
.possible
[i
]);
725 printk(KERN_CONT
")");
728 printk(KERN_CONT
" *%d", link
->irq
.active
);
730 if (!link
->device
->status
.enabled
)
731 printk(KERN_CONT
", disabled.");
733 printk(KERN_CONT
"\n");
735 list_add_tail(&link
->list
, &acpi_link_list
);
738 /* disable all links -- to be activated on use */
739 acpi_evaluate_object(device
->handle
, "_DIS", NULL
, NULL
);
740 mutex_unlock(&acpi_link_lock
);
745 return result
< 0 ? result
: 1;
748 static int acpi_pci_link_resume(struct acpi_pci_link
*link
)
750 if (link
->refcnt
&& link
->irq
.active
&& link
->irq
.initialized
)
751 return (acpi_pci_link_set(link
, link
->irq
.active
));
756 static void irqrouter_resume(void)
758 struct acpi_pci_link
*link
;
760 list_for_each_entry(link
, &acpi_link_list
, list
) {
761 acpi_pci_link_resume(link
);
765 static void acpi_pci_link_remove(struct acpi_device
*device
)
767 struct acpi_pci_link
*link
;
769 link
= acpi_driver_data(device
);
771 mutex_lock(&acpi_link_lock
);
772 list_del(&link
->list
);
773 mutex_unlock(&acpi_link_lock
);
779 * modify acpi_irq_penalty[] from cmdline
781 static int __init
acpi_irq_penalty_update(char *str
, int used
)
785 for (i
= 0; i
< 16; i
++) {
789 retval
= get_option(&str
, &irq
);
792 break; /* no number found */
797 if (irq
>= ARRAY_SIZE(acpi_irq_penalty
))
801 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
803 acpi_irq_penalty
[irq
] = PIRQ_PENALTY_PCI_AVAILABLE
;
805 if (retval
!= 2) /* no next number */
812 * We'd like PNP to call this routine for the
813 * single ISA_USED value for each legacy device.
814 * But instead it calls us with each POSSIBLE setting.
815 * There is no ISA_POSSIBLE weight, so we simply use
816 * the (small) PCI_USING penalty.
818 void acpi_penalize_isa_irq(int irq
, int active
)
820 if (irq
>= 0 && irq
< ARRAY_SIZE(acpi_irq_penalty
)) {
822 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
824 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_PCI_USING
;
829 * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with
830 * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for
833 void acpi_penalize_sci_irq(int irq
, int trigger
, int polarity
)
835 if (irq
>= 0 && irq
< ARRAY_SIZE(acpi_irq_penalty
)) {
836 if (trigger
!= ACPI_MADT_TRIGGER_LEVEL
||
837 polarity
!= ACPI_MADT_POLARITY_ACTIVE_LOW
)
838 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_ALWAYS
;
840 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_PCI_USING
;
845 * Over-ride default table to reserve additional IRQs for use by ISA
846 * e.g. acpi_irq_isa=5
847 * Useful for telling ACPI how not to interfere with your ISA sound card.
849 static int __init
acpi_irq_isa(char *str
)
851 return acpi_irq_penalty_update(str
, 1);
854 __setup("acpi_irq_isa=", acpi_irq_isa
);
857 * Over-ride default table to free additional IRQs for use by PCI
858 * e.g. acpi_irq_pci=7,15
859 * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
861 static int __init
acpi_irq_pci(char *str
)
863 return acpi_irq_penalty_update(str
, 0);
866 __setup("acpi_irq_pci=", acpi_irq_pci
);
868 static int __init
acpi_irq_nobalance_set(char *str
)
870 acpi_irq_balance
= 0;
874 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set
);
876 static int __init
acpi_irq_balance_set(char *str
)
878 acpi_irq_balance
= 1;
882 __setup("acpi_irq_balance", acpi_irq_balance_set
);
884 static struct syscore_ops irqrouter_syscore_ops
= {
885 .resume
= irqrouter_resume
,
888 void __init
acpi_pci_link_init(void)
893 if (acpi_irq_balance
== -1) {
894 /* no command line switch: enable balancing in IOAPIC mode */
895 if (acpi_irq_model
== ACPI_IRQ_MODEL_IOAPIC
)
896 acpi_irq_balance
= 1;
898 acpi_irq_balance
= 0;
900 register_syscore_ops(&irqrouter_syscore_ops
);
901 acpi_scan_add_handler(&pci_link_handler
);