2019-05-27 14:55:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
|
|
|
|
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
|
|
|
|
* Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
|
|
|
|
*
|
2020-11-05 10:06:00 +08:00
|
|
|
* TBD:
|
|
|
|
* 1. Support more than one IRQ resource entry per link device (index).
|
2005-04-17 06:20:36 +08:00
|
|
|
* 2. Implement start/stop mechanism and use ACPI Bus Driver facilities
|
|
|
|
* for IRQ management (e.g. start()->_SRS).
|
|
|
|
*/
|
|
|
|
|
2021-02-20 02:17:44 +08:00
|
|
|
#define pr_fmt(fmt) "ACPI: PCI: " fmt
|
|
|
|
|
2011-03-13 05:16:51 +08:00
|
|
|
#include <linux/syscore_ops.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/pci.h>
|
2006-04-27 17:25:00 +08:00
|
|
|
#include <linux/mutex.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2013-12-03 08:49:16 +08:00
|
|
|
#include <linux/acpi.h>
|
2016-04-18 01:36:53 +08:00
|
|
|
#include <linux/irq.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-12-17 17:28:31 +08:00
|
|
|
#include "internal.h"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
|
|
|
|
#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
|
2009-02-18 05:00:40 +08:00
|
|
|
#define ACPI_PCI_LINK_MAX_POSSIBLE 16
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
static int acpi_pci_link_add(struct acpi_device *device,
|
|
|
|
const struct acpi_device_id *not_used);
|
|
|
|
static void acpi_pci_link_remove(struct acpi_device *device);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-01-11 00:15:36 +08:00
|
|
|
static const struct acpi_device_id link_device_ids[] = {
|
2007-07-23 20:44:41 +08:00
|
|
|
{"PNP0C0F", 0},
|
|
|
|
{"", 0},
|
|
|
|
};
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
static struct acpi_scan_handler pci_link_handler = {
|
2007-07-23 20:44:41 +08:00
|
|
|
.ids = link_device_ids,
|
2013-01-30 21:27:37 +08:00
|
|
|
.attach = acpi_pci_link_add,
|
|
|
|
.detach = acpi_pci_link_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2005-07-28 11:02:00 +08:00
|
|
|
/*
|
|
|
|
* If a link is initialized, we never change its active and initialized
|
|
|
|
* later even the link is disable. Instead, we just repick the active irq
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
struct acpi_pci_link_irq {
|
2015-12-10 00:18:28 +08:00
|
|
|
u32 active; /* Current IRQ */
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
u8 triggering; /* All IRQs */
|
2009-02-18 05:00:40 +08:00
|
|
|
u8 polarity; /* All IRQs */
|
2005-08-05 12:44:28 +08:00
|
|
|
u8 resource_type;
|
|
|
|
u8 possible_count;
|
2015-12-10 00:18:28 +08:00
|
|
|
u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
|
2005-08-05 12:44:28 +08:00
|
|
|
u8 initialized:1;
|
|
|
|
u8 reserved:7;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_pci_link {
|
2009-02-18 05:00:55 +08:00
|
|
|
struct list_head list;
|
2009-02-18 05:00:40 +08:00
|
|
|
struct acpi_device *device;
|
|
|
|
struct acpi_pci_link_irq irq;
|
|
|
|
int refcnt;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-02-18 05:00:55 +08:00
|
|
|
static LIST_HEAD(acpi_link_list);
|
2007-10-25 00:24:42 +08:00
|
|
|
static DEFINE_MUTEX(acpi_link_lock);
|
ACPI/PCI: pci_link: penalize SCI correctly
Ondrej reported that IRQs stopped working in v4.7 on several
platforms. A typical scenario, from Ondrej's VT82C694X/694X, is:
ACPI: Using PIC for interrupt routing
ACPI: PCI Interrupt Link [LNKA] (IRQs 1 3 4 5 6 7 10 *11 12 14 15)
ACPI: No IRQ available for PCI Interrupt Link [LNKA]
8139too 0000:00:0f.0: PCI INT A: no GSI
We're using PIC routing, so acpi_irq_balance == 0, and LNKA is already
active at IRQ 11. In that case, acpi_pci_link_allocate() only tries
to use the active IRQ (IRQ 11) which also happens to be the SCI.
We should penalize the SCI by PIRQ_PENALTY_PCI_USING, but
irq_get_trigger_type(11) returns something other than
IRQ_TYPE_LEVEL_LOW, so we penalize it by PIRQ_PENALTY_ISA_ALWAYS
instead, which makes acpi_pci_link_allocate() assume the IRQ isn't
available and give up.
Add acpi_penalize_sci_irq() so platforms can tell us the SCI IRQ,
trigger, and polarity directly and we don't have to depend on
irq_get_trigger_type().
Fixes: 103544d86976 (ACPI,PCI,IRQ: reduce resource requirements)
Link: http://lkml.kernel.org/r/201609251512.05657.linux@rainbow-software.org
Reported-by: Ondrej Zary <linux@rainbow-software.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Tested-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-10-24 12:31:31 +08:00
|
|
|
static int sci_irq = -1, sci_penalty;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
PCI Link Device Management
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set context (link) possible list from resource list
|
|
|
|
*/
|
2009-02-18 05:00:40 +08:00
|
|
|
static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
|
|
|
|
void *context)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-10-01 06:28:50 +08:00
|
|
|
struct acpi_pci_link *link = context;
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle handle = link->device->handle;
|
2009-02-18 05:00:45 +08:00
|
|
|
u32 i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-22 12:25:18 +08:00
|
|
|
switch (resource->type) {
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
|
2008-07-15 23:42:57 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_END_TAG:
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_IRQ:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
|
|
|
struct acpi_resource_irq *p = &resource->data.irq;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
if (!p || !p->interrupt_count) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle,
|
|
|
|
"Blank _PRS IRQ resource\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
for (i = 0;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
(i < p->interrupt_count
|
2005-08-05 12:44:28 +08:00
|
|
|
&& i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
|
|
|
|
if (!p->interrupts[i]) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_debug(handle,
|
|
|
|
"Invalid _PRS IRQ %d\n",
|
|
|
|
p->interrupts[i]);
|
2005-08-05 12:44:28 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
link->irq.possible[i] = p->interrupts[i];
|
|
|
|
link->irq.possible_count++;
|
|
|
|
}
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
link->irq.triggering = p->triggering;
|
|
|
|
link->irq.polarity = p->polarity;
|
|
|
|
link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ;
|
2005-08-05 12:44:28 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
struct acpi_resource_extended_irq *p =
|
2005-08-05 12:44:28 +08:00
|
|
|
&resource->data.extended_irq;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
if (!p || !p->interrupt_count) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_debug(handle,
|
|
|
|
"Blank _PRS EXT IRQ resource\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-08-05 12:44:28 +08:00
|
|
|
}
|
|
|
|
for (i = 0;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
(i < p->interrupt_count
|
2005-08-05 12:44:28 +08:00
|
|
|
&& i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
|
|
|
|
if (!p->interrupts[i]) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_debug(handle,
|
|
|
|
"Invalid _PRS IRQ %d\n",
|
|
|
|
p->interrupts[i]);
|
2005-08-05 12:44:28 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
link->irq.possible[i] = p->interrupts[i];
|
|
|
|
link->irq.possible_count++;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
link->irq.triggering = p->triggering;
|
|
|
|
link->irq.polarity = p->polarity;
|
|
|
|
link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
|
2005-08-05 12:44:28 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
default:
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_debug(handle, "_PRS resource type 0x%x is not IRQ\n",
|
|
|
|
resource->type);
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_CTRL_TERMINATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle handle = link->device->handle;
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-02-20 02:16:10 +08:00
|
|
|
status = acpi_walk_resources(handle, METHOD_NAME__PRS,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_pci_link_check_possible, link);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "_PRS not present or invalid");
|
2018-02-23 13:43:44 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Found %d possible IRQs\n",
|
|
|
|
link->irq.possible_count);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-06-27 12:41:40 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-02-18 05:00:40 +08:00
|
|
|
static acpi_status acpi_pci_link_check_current(struct acpi_resource *resource,
|
|
|
|
void *context)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-02-18 05:00:45 +08:00
|
|
|
int *irq = context;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-22 12:25:18 +08:00
|
|
|
switch (resource->type) {
|
2008-07-15 23:42:57 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
|
|
|
|
case ACPI_RESOURCE_TYPE_END_TAG:
|
|
|
|
return AE_OK;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_IRQ:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
|
|
|
struct acpi_resource_irq *p = &resource->data.irq;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
if (!p || !p->interrupt_count) {
|
2005-08-05 12:44:28 +08:00
|
|
|
/*
|
|
|
|
* IRQ descriptors may have no IRQ# bits set,
|
|
|
|
* particularly those those w/ _STA disabled
|
|
|
|
*/
|
2021-02-20 02:16:10 +08:00
|
|
|
pr_debug("Blank _CRS IRQ resource\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-08-05 12:44:28 +08:00
|
|
|
}
|
|
|
|
*irq = p->interrupts[0];
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
struct acpi_resource_extended_irq *p =
|
2005-08-05 12:44:28 +08:00
|
|
|
&resource->data.extended_irq;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
if (!p || !p->interrupt_count) {
|
2005-08-05 12:44:28 +08:00
|
|
|
/*
|
|
|
|
* extended IRQ descriptors must
|
|
|
|
* return at least 1 IRQ
|
|
|
|
*/
|
2021-02-20 02:16:10 +08:00
|
|
|
pr_debug("Blank _CRS EXT IRQ resource\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-08-05 12:44:28 +08:00
|
|
|
}
|
|
|
|
*irq = p->interrupts[0];
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-01-27 06:23:38 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
default:
|
2021-02-20 02:16:10 +08:00
|
|
|
pr_debug("_CRS resource type 0x%x is not IRQ\n",
|
|
|
|
resource->type);
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-15 23:42:57 +08:00
|
|
|
|
2006-06-27 12:41:40 +08:00
|
|
|
return AE_CTRL_TERMINATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run _CRS and set link->irq.active
|
|
|
|
*
|
|
|
|
* return value:
|
|
|
|
* 0 - success
|
|
|
|
* !0 - failure
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
static int acpi_pci_link_get_current(struct acpi_pci_link *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle handle = link->device->handle;
|
2009-02-18 05:00:45 +08:00
|
|
|
acpi_status status;
|
2021-02-20 02:16:10 +08:00
|
|
|
int result = 0;
|
2005-08-05 12:44:28 +08:00
|
|
|
int irq = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
link->irq.active = 0;
|
|
|
|
|
|
|
|
/* in practice, status disabled is meaningless, ignore it */
|
|
|
|
if (acpi_strict) {
|
|
|
|
/* Query _STA, set link->device->status */
|
|
|
|
result = acpi_bus_get_status(link->device);
|
|
|
|
if (result) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_err(handle, "Unable to read status\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!link->device->status.enabled) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Link disabled\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-05 10:06:00 +08:00
|
|
|
/*
|
|
|
|
* Query and parse _CRS to get the current IRQ assignment.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2021-02-20 02:16:10 +08:00
|
|
|
status = acpi_walk_resources(handle, METHOD_NAME__CRS,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_pci_link_check_current, &irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2021-03-06 02:41:44 +08:00
|
|
|
acpi_evaluation_failure_warn(handle, "_CRS", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
result = -ENODEV;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (acpi_strict && !irq) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_err(handle, "_CRS returned 0\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
result = -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
link->irq.active = irq;
|
|
|
|
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Link at IRQ %d \n", link->irq.active);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
end:
|
2006-06-27 12:41:40 +08:00
|
|
|
return result;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct {
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_resource res;
|
|
|
|
struct acpi_resource end;
|
|
|
|
} *resource;
|
|
|
|
struct acpi_buffer buffer = { 0, NULL };
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle handle = link->device->handle;
|
|
|
|
acpi_status status;
|
|
|
|
int result;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-18 05:00:50 +08:00
|
|
|
if (!irq)
|
2006-06-27 12:41:40 +08:00
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-12-20 04:56:11 +08:00
|
|
|
resource = kzalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
|
2005-08-05 12:44:28 +08:00
|
|
|
if (!resource)
|
2006-06-27 12:41:40 +08:00
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
buffer.length = sizeof(*resource) + 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
buffer.pointer = resource;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
switch (link->irq.resource_type) {
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_IRQ:
|
|
|
|
resource->res.type = ACPI_RESOURCE_TYPE_IRQ;
|
2005-04-17 06:20:36 +08:00
|
|
|
resource->res.length = sizeof(struct acpi_resource);
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
resource->res.data.irq.triggering = link->irq.triggering;
|
|
|
|
resource->res.data.irq.polarity =
|
|
|
|
link->irq.polarity;
|
|
|
|
if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
|
2019-02-16 05:36:19 +08:00
|
|
|
resource->res.data.irq.shareable =
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_EXCLUSIVE;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2019-02-16 05:36:19 +08:00
|
|
|
resource->res.data.irq.shareable = ACPI_SHARED;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
resource->res.data.irq.interrupt_count = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
resource->res.data.irq.interrupts[0] = irq;
|
|
|
|
break;
|
2005-08-05 12:44:28 +08:00
|
|
|
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
|
|
|
resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
|
2005-04-17 06:20:36 +08:00
|
|
|
resource->res.length = sizeof(struct acpi_resource);
|
2005-08-05 12:44:28 +08:00
|
|
|
resource->res.data.extended_irq.producer_consumer =
|
|
|
|
ACPI_CONSUMER;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
resource->res.data.extended_irq.triggering =
|
|
|
|
link->irq.triggering;
|
|
|
|
resource->res.data.extended_irq.polarity =
|
|
|
|
link->irq.polarity;
|
|
|
|
if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
|
2020-04-13 21:09:49 +08:00
|
|
|
resource->res.data.extended_irq.shareable =
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_EXCLUSIVE;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2020-04-13 21:09:49 +08:00
|
|
|
resource->res.data.extended_irq.shareable = ACPI_SHARED;
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
resource->res.data.extended_irq.interrupt_count = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
resource->res.data.extended_irq.interrupts[0] = irq;
|
|
|
|
/* ignore resource_source, it's optional */
|
|
|
|
break;
|
|
|
|
default:
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_err(handle, "Invalid resource type %d\n",
|
|
|
|
link->irq.resource_type);
|
2005-04-17 06:20:36 +08:00
|
|
|
result = -EINVAL;
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
}
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
|
2013-03-24 03:16:37 +08:00
|
|
|
resource->end.length = sizeof(struct acpi_resource);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Attempt to set the resource */
|
2006-05-20 04:54:42 +08:00
|
|
|
status = acpi_set_current_resources(link->device->handle, &buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* check for total failure */
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2021-03-06 02:41:44 +08:00
|
|
|
acpi_evaluation_failure_warn(handle, "_SRS", status);
|
2005-04-17 06:20:36 +08:00
|
|
|
result = -ENODEV;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query _STA, set device->status */
|
|
|
|
result = acpi_bus_get_status(link->device);
|
|
|
|
if (result) {
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_err(handle, "Unable to read status\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto end;
|
|
|
|
}
|
2021-02-20 02:16:10 +08:00
|
|
|
if (!link->device->status.enabled)
|
|
|
|
acpi_handle_warn(handle, "Disabled and referenced, BIOS bug\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Query _CRS, set link->irq.active */
|
|
|
|
result = acpi_pci_link_get_current(link);
|
|
|
|
if (result) {
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is current setting not what we set?
|
|
|
|
* set link->irq.active
|
|
|
|
*/
|
|
|
|
if (link->irq.active != irq) {
|
|
|
|
/*
|
|
|
|
* policy: when _CRS doesn't return what we just _SRS
|
|
|
|
* assume _SRS worked and override _CRS value.
|
|
|
|
*/
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_warn(handle, "BIOS reported IRQ %d, using IRQ %d\n",
|
|
|
|
link->irq.active, irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
link->irq.active = irq;
|
|
|
|
}
|
|
|
|
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Set IRQ %d\n", link->irq.active);
|
2005-08-05 12:44:28 +08:00
|
|
|
|
|
|
|
end:
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(resource);
|
2006-06-27 12:41:40 +08:00
|
|
|
return result;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
PCI Link IRQ Management
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
|
|
|
|
* Link Devices to move the PIRQs around to minimize sharing.
|
2020-11-05 10:06:00 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
|
|
|
|
* that the BIOS has already set to active. This is necessary because
|
|
|
|
* ACPI has no automatic means of knowing what ISA IRQs are used. Note that
|
|
|
|
* if the BIOS doesn't set a Link Device active, ACPI needs to program it
|
|
|
|
* even if acpi_irq_nobalance is set.
|
|
|
|
*
|
|
|
|
* A tables of penalties avoids directing PCI interrupts to well known
|
|
|
|
* ISA IRQs. Boot params are available to over-ride the default table:
|
|
|
|
*
|
|
|
|
* List interrupts that are free for PCI use.
|
|
|
|
* acpi_irq_pci=n[,m]
|
|
|
|
*
|
|
|
|
* List interrupts that should not be used for PCI:
|
|
|
|
* acpi_irq_isa=n[,m]
|
|
|
|
*
|
|
|
|
* Note that PCI IRQ routers have a list of possible IRQs,
|
|
|
|
* which may not include the IRQs this table says are available.
|
2020-11-05 10:06:00 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Since this heuristic can't tell the difference between a link
|
|
|
|
* that no device will attach to, vs. a link which may be shared
|
|
|
|
* by multiple active devices -- it is not optimal.
|
|
|
|
*
|
|
|
|
* If interrupt performance is that important, get an IO-APIC system
|
|
|
|
* with a pin dedicated to each device. Or for that matter, an MSI
|
|
|
|
* enabled system.
|
|
|
|
*/
|
|
|
|
|
2016-04-18 01:36:54 +08:00
|
|
|
#define ACPI_MAX_ISA_IRQS 16
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
|
|
|
|
#define PIRQ_PENALTY_PCI_USING (16*16*16)
|
|
|
|
#define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
|
|
|
|
#define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
|
|
|
|
#define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
|
|
|
|
|
2016-04-18 01:36:54 +08:00
|
|
|
static int acpi_isa_irq_penalty[ACPI_MAX_ISA_IRQS] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
|
|
|
|
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
|
|
|
|
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
|
2005-08-05 12:44:28 +08:00
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */
|
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */
|
2005-04-17 06:20:36 +08:00
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */
|
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
|
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
|
|
|
|
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */
|
2016-04-18 01:36:53 +08:00
|
|
|
0, /* IRQ9 PCI, often acpi */
|
|
|
|
0, /* IRQ10 PCI */
|
|
|
|
0, /* IRQ11 PCI */
|
2009-02-18 05:00:40 +08:00
|
|
|
PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
|
|
|
|
PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
|
|
|
|
PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
|
|
|
|
PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
|
2016-02-24 20:55:38 +08:00
|
|
|
/* >IRQ15 */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2016-04-18 01:36:53 +08:00
|
|
|
static int acpi_irq_pci_sharing_penalty(int irq)
|
|
|
|
{
|
|
|
|
struct acpi_pci_link *link;
|
|
|
|
int penalty = 0;
|
2016-06-29 16:27:35 +08:00
|
|
|
int i;
|
2016-04-18 01:36:53 +08:00
|
|
|
|
|
|
|
list_for_each_entry(link, &acpi_link_list, list) {
|
|
|
|
/*
|
|
|
|
* If a link is active, penalize its IRQ heavily
|
|
|
|
* so we try to choose a different IRQ.
|
|
|
|
*/
|
|
|
|
if (link->irq.active && link->irq.active == irq)
|
|
|
|
penalty += PIRQ_PENALTY_PCI_USING;
|
2016-06-29 16:27:35 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* penalize the IRQs PCI might use, but not as severely.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < link->irq.possible_count; i++)
|
|
|
|
if (link->irq.possible[i] == irq)
|
|
|
|
penalty += PIRQ_PENALTY_PCI_POSSIBLE /
|
|
|
|
link->irq.possible_count;
|
2016-04-18 01:36:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return penalty;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acpi_irq_get_penalty(int irq)
|
|
|
|
{
|
|
|
|
int penalty = 0;
|
|
|
|
|
ACPI/PCI: pci_link: penalize SCI correctly
Ondrej reported that IRQs stopped working in v4.7 on several
platforms. A typical scenario, from Ondrej's VT82C694X/694X, is:
ACPI: Using PIC for interrupt routing
ACPI: PCI Interrupt Link [LNKA] (IRQs 1 3 4 5 6 7 10 *11 12 14 15)
ACPI: No IRQ available for PCI Interrupt Link [LNKA]
8139too 0000:00:0f.0: PCI INT A: no GSI
We're using PIC routing, so acpi_irq_balance == 0, and LNKA is already
active at IRQ 11. In that case, acpi_pci_link_allocate() only tries
to use the active IRQ (IRQ 11) which also happens to be the SCI.
We should penalize the SCI by PIRQ_PENALTY_PCI_USING, but
irq_get_trigger_type(11) returns something other than
IRQ_TYPE_LEVEL_LOW, so we penalize it by PIRQ_PENALTY_ISA_ALWAYS
instead, which makes acpi_pci_link_allocate() assume the IRQ isn't
available and give up.
Add acpi_penalize_sci_irq() so platforms can tell us the SCI IRQ,
trigger, and polarity directly and we don't have to depend on
irq_get_trigger_type().
Fixes: 103544d86976 (ACPI,PCI,IRQ: reduce resource requirements)
Link: http://lkml.kernel.org/r/201609251512.05657.linux@rainbow-software.org
Reported-by: Ondrej Zary <linux@rainbow-software.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Tested-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-10-24 12:31:31 +08:00
|
|
|
if (irq == sci_irq)
|
|
|
|
penalty += sci_penalty;
|
2016-04-18 01:36:53 +08:00
|
|
|
|
2016-06-29 16:27:37 +08:00
|
|
|
if (irq < ACPI_MAX_ISA_IRQS)
|
|
|
|
return penalty + acpi_isa_irq_penalty[irq];
|
|
|
|
|
ACPI/PCI: pci_link: penalize SCI correctly
Ondrej reported that IRQs stopped working in v4.7 on several
platforms. A typical scenario, from Ondrej's VT82C694X/694X, is:
ACPI: Using PIC for interrupt routing
ACPI: PCI Interrupt Link [LNKA] (IRQs 1 3 4 5 6 7 10 *11 12 14 15)
ACPI: No IRQ available for PCI Interrupt Link [LNKA]
8139too 0000:00:0f.0: PCI INT A: no GSI
We're using PIC routing, so acpi_irq_balance == 0, and LNKA is already
active at IRQ 11. In that case, acpi_pci_link_allocate() only tries
to use the active IRQ (IRQ 11) which also happens to be the SCI.
We should penalize the SCI by PIRQ_PENALTY_PCI_USING, but
irq_get_trigger_type(11) returns something other than
IRQ_TYPE_LEVEL_LOW, so we penalize it by PIRQ_PENALTY_ISA_ALWAYS
instead, which makes acpi_pci_link_allocate() assume the IRQ isn't
available and give up.
Add acpi_penalize_sci_irq() so platforms can tell us the SCI IRQ,
trigger, and polarity directly and we don't have to depend on
irq_get_trigger_type().
Fixes: 103544d86976 (ACPI,PCI,IRQ: reduce resource requirements)
Link: http://lkml.kernel.org/r/201609251512.05657.linux@rainbow-software.org
Reported-by: Ondrej Zary <linux@rainbow-software.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Tested-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-10-24 12:31:31 +08:00
|
|
|
return penalty + acpi_irq_pci_sharing_penalty(irq);
|
2016-04-18 01:36:53 +08:00
|
|
|
}
|
|
|
|
|
2016-06-29 16:27:36 +08:00
|
|
|
int __init acpi_irq_penalty_init(void)
|
|
|
|
{
|
|
|
|
struct acpi_pci_link *link;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update penalties to facilitate IRQ balancing.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(link, &acpi_link_list, list) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reflect the possible and active irqs in the penalty table --
|
|
|
|
* useful for breaking ties.
|
|
|
|
*/
|
|
|
|
if (link->irq.possible_count) {
|
|
|
|
int penalty =
|
|
|
|
PIRQ_PENALTY_PCI_POSSIBLE /
|
|
|
|
link->irq.possible_count;
|
|
|
|
|
|
|
|
for (i = 0; i < link->irq.possible_count; i++) {
|
|
|
|
if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)
|
|
|
|
acpi_isa_irq_penalty[link->irq.
|
|
|
|
possible[i]] +=
|
|
|
|
penalty;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (link->irq.active &&
|
|
|
|
(link->irq.active < ACPI_MAX_ISA_IRQS)) {
|
|
|
|
acpi_isa_irq_penalty[link->irq.active] +=
|
|
|
|
PIRQ_PENALTY_PCI_POSSIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-06 07:17:52 +08:00
|
|
|
static int acpi_irq_balance = -1; /* 0: static, 1: balance */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
static int acpi_pci_link_allocate(struct acpi_pci_link *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle handle = link->device->handle;
|
2005-08-05 12:44:28 +08:00
|
|
|
int irq;
|
|
|
|
int i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-28 11:02:00 +08:00
|
|
|
if (link->irq.initialized) {
|
|
|
|
if (link->refcnt == 0)
|
|
|
|
/* This means the link is disabled but initialized */
|
|
|
|
acpi_pci_link_set(link, link->irq.active);
|
2006-06-27 12:41:40 +08:00
|
|
|
return 0;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* search for active IRQ in list of possible IRQs.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < link->irq.possible_count; ++i) {
|
|
|
|
if (link->irq.active == link->irq.possible[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* forget active IRQ that is not in possible list
|
|
|
|
*/
|
|
|
|
if (i == link->irq.possible_count) {
|
|
|
|
if (acpi_strict)
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_warn(handle, "_CRS %d not found in _PRS\n",
|
|
|
|
link->irq.active);
|
2005-04-17 06:20:36 +08:00
|
|
|
link->irq.active = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if active found, use it; else pick entry from end of possible list.
|
|
|
|
*/
|
2009-02-18 05:00:40 +08:00
|
|
|
if (link->irq.active)
|
2005-04-17 06:20:36 +08:00
|
|
|
irq = link->irq.active;
|
2009-02-18 05:00:40 +08:00
|
|
|
else
|
2005-04-17 06:20:36 +08:00
|
|
|
irq = link->irq.possible[link->irq.possible_count - 1];
|
|
|
|
|
|
|
|
if (acpi_irq_balance || !link->irq.active) {
|
|
|
|
/*
|
|
|
|
* Select the best IRQ. This is done in reverse to promote
|
|
|
|
* the use of IRQs 9, 10, 11, and >15.
|
|
|
|
*/
|
|
|
|
for (i = (link->irq.possible_count - 1); i >= 0; i--) {
|
2016-04-18 01:36:53 +08:00
|
|
|
if (acpi_irq_get_penalty(irq) >
|
|
|
|
acpi_irq_get_penalty(link->irq.possible[i]))
|
2005-04-17 06:20:36 +08:00
|
|
|
irq = link->irq.possible[i];
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 01:36:53 +08:00
|
|
|
if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle,
|
|
|
|
"No IRQ available. Try pci=noacpi or acpi=off\n");
|
2015-09-17 14:02:45 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Attempt to enable the link device at this IRQ. */
|
|
|
|
if (acpi_pci_link_set(link, irq)) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle,
|
|
|
|
"Unable to set IRQ. Try pci=noacpi or acpi=off\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2016-10-24 12:31:32 +08:00
|
|
|
if (link->irq.active < ACPI_MAX_ISA_IRQS)
|
|
|
|
acpi_isa_irq_penalty[link->irq.active] +=
|
|
|
|
PIRQ_PENALTY_PCI_USING;
|
|
|
|
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_info(handle, "Enabled at IRQ %d\n",
|
|
|
|
link->irq.active);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
link->irq.initialized = 1;
|
2006-06-27 12:41:40 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-07-28 11:02:00 +08:00
|
|
|
* acpi_pci_link_allocate_irq
|
2005-04-17 06:20:36 +08:00
|
|
|
* success: return IRQ >= 0
|
|
|
|
* failure: return -1
|
|
|
|
*/
|
2009-02-18 05:00:40 +08:00
|
|
|
int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
|
|
|
|
int *polarity, char **name)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-12-04 00:37:10 +08:00
|
|
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
2009-02-18 05:00:45 +08:00
|
|
|
struct acpi_pci_link *link;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-12-04 00:37:10 +08:00
|
|
|
if (!device) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Invalid link device\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-10-01 06:28:50 +08:00
|
|
|
link = acpi_driver_data(device);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!link) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Invalid link context\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* TBD: Support multiple index (IRQ) entries per Link Device */
|
|
|
|
if (index) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Invalid index %d\n", index);
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_lock(&acpi_link_lock);
|
2005-07-28 11:02:00 +08:00
|
|
|
if (acpi_pci_link_allocate(link)) {
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!link->irq.active) {
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Link active IRQ is 0!\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
link->refcnt++;
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-10-01 07:03:00 +08:00
|
|
|
if (triggering)
|
|
|
|
*triggering = link->irq.triggering;
|
|
|
|
if (polarity)
|
|
|
|
*polarity = link->irq.polarity;
|
2005-08-05 12:44:28 +08:00
|
|
|
if (name)
|
|
|
|
*name = acpi_device_bid(link->device);
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Link is referenced\n");
|
2019-08-19 21:53:24 +08:00
|
|
|
return link->irq.active;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-07-28 11:02:00 +08:00
|
|
|
/*
|
|
|
|
* We don't change link's irq information here. After it is reenabled, we
|
|
|
|
* continue use the info
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
int acpi_pci_link_free_irq(acpi_handle handle)
|
2005-07-28 11:02:00 +08:00
|
|
|
{
|
2021-12-04 00:37:10 +08:00
|
|
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
2009-02-18 05:00:45 +08:00
|
|
|
struct acpi_pci_link *link;
|
2005-07-28 11:02:00 +08:00
|
|
|
|
2021-12-04 00:37:10 +08:00
|
|
|
if (!device) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Invalid link device\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-01 06:28:50 +08:00
|
|
|
link = acpi_driver_data(device);
|
2005-07-28 11:02:00 +08:00
|
|
|
if (!link) {
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Invalid link context\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
|
|
|
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_lock(&acpi_link_lock);
|
2005-07-28 11:02:00 +08:00
|
|
|
if (!link->irq.initialized) {
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle_err(handle, "Link isn't initialized\n");
|
2006-06-27 12:41:40 +08:00
|
|
|
return -1;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
2005-08-03 23:00:11 +08:00
|
|
|
#ifdef FUTURE_USE
|
|
|
|
/*
|
|
|
|
* The Link reference count allows us to _DISable an unused link
|
|
|
|
* and suspend time, and set it again on resume.
|
|
|
|
* However, 2.6.12 still has irq_router.resume
|
|
|
|
* which blindly restores the link state.
|
|
|
|
* So we disable the reference count method
|
|
|
|
* to prevent duplicate acpi_pci_link_set()
|
|
|
|
* which would harm some systems
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
link->refcnt--;
|
2005-08-03 23:00:11 +08:00
|
|
|
#endif
|
2021-02-20 02:16:10 +08:00
|
|
|
acpi_handle_debug(handle, "Link is dereferenced\n");
|
2005-07-28 11:02:00 +08:00
|
|
|
|
2009-02-18 05:00:40 +08:00
|
|
|
if (link->refcnt == 0)
|
2008-10-17 22:49:50 +08:00
|
|
|
acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL);
|
2009-02-18 05:00:40 +08:00
|
|
|
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2019-08-19 21:53:24 +08:00
|
|
|
return link->irq.active;
|
2005-07-28 11:02:00 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
Driver Interface
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
static int acpi_pci_link_add(struct acpi_device *device,
|
|
|
|
const struct acpi_device_id *not_used)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_handle handle = device->handle;
|
2009-02-18 05:00:45 +08:00
|
|
|
struct acpi_pci_link *link;
|
2021-02-20 02:17:44 +08:00
|
|
|
int result;
|
2009-02-18 05:00:45 +08:00
|
|
|
int i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-12-20 04:56:11 +08:00
|
|
|
link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!link)
|
2006-06-27 12:41:40 +08:00
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
link->device = device;
|
|
|
|
strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
|
|
|
|
strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
|
2008-09-23 05:37:34 +08:00
|
|
|
device->driver_data = link;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_lock(&acpi_link_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
result = acpi_pci_link_get_possible(link);
|
|
|
|
if (result)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
/* query and set link->irq.active */
|
|
|
|
acpi_pci_link_get_current(link);
|
|
|
|
|
2021-02-20 02:17:44 +08:00
|
|
|
pr_info("Interrupt link %s configured for IRQ %d\n",
|
|
|
|
acpi_device_bid(device), link->irq.active);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < link->irq.possible_count; i++) {
|
2021-02-20 02:17:44 +08:00
|
|
|
if (link->irq.active != link->irq.possible[i])
|
|
|
|
acpi_handle_debug(handle, "Possible IRQ %d\n",
|
|
|
|
link->irq.possible[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (!link->device->status.enabled)
|
2021-02-20 02:17:44 +08:00
|
|
|
pr_info("Interrupt link %s disabled\n", acpi_device_bid(device));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-18 05:00:55 +08:00
|
|
|
list_add_tail(&link->list, &acpi_link_list);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
end:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* disable all links -- to be activated on use */
|
2021-02-20 02:17:44 +08:00
|
|
|
acpi_evaluate_object(handle, "_DIS", NULL, NULL);
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
kfree(link);
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
return result < 0 ? result : 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
static int acpi_pci_link_resume(struct acpi_pci_link *link)
|
2005-08-02 03:37:54 +08:00
|
|
|
{
|
|
|
|
if (link->refcnt && link->irq.active && link->irq.initialized)
|
2006-06-27 12:41:40 +08:00
|
|
|
return (acpi_pci_link_set(link, link->irq.active));
|
2009-02-18 05:00:40 +08:00
|
|
|
|
|
|
|
return 0;
|
2005-08-02 03:37:54 +08:00
|
|
|
}
|
|
|
|
|
2011-03-13 05:16:51 +08:00
|
|
|
static void irqrouter_resume(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-02-18 05:00:45 +08:00
|
|
|
struct acpi_pci_link *link;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-18 05:00:55 +08:00
|
|
|
list_for_each_entry(link, &acpi_link_list, list) {
|
2005-08-02 03:37:54 +08:00
|
|
|
acpi_pci_link_resume(link);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
static void acpi_pci_link_remove(struct acpi_device *device)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-02-18 05:00:45 +08:00
|
|
|
struct acpi_pci_link *link;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-01 06:28:50 +08:00
|
|
|
link = acpi_driver_data(device);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_lock(&acpi_link_lock);
|
2009-02-18 05:00:55 +08:00
|
|
|
list_del(&link->list);
|
2006-04-27 17:25:00 +08:00
|
|
|
mutex_unlock(&acpi_link_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
kfree(link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-18 01:36:54 +08:00
|
|
|
* modify acpi_isa_irq_penalty[] from cmdline
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
static int __init acpi_irq_penalty_update(char *str, int used)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
int retval;
|
|
|
|
int irq;
|
2016-04-18 01:36:54 +08:00
|
|
|
int new_penalty;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
retval = get_option(&str, &irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!retval)
|
|
|
|
break; /* no number found */
|
|
|
|
|
2016-04-18 01:36:54 +08:00
|
|
|
/* see if this is a ISA IRQ */
|
|
|
|
if ((irq < 0) || (irq >= ACPI_MAX_ISA_IRQS))
|
2016-02-24 20:55:38 +08:00
|
|
|
continue;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (used)
|
2016-10-24 12:31:30 +08:00
|
|
|
new_penalty = acpi_isa_irq_penalty[irq] +
|
2016-04-18 01:36:54 +08:00
|
|
|
PIRQ_PENALTY_ISA_USED;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2016-04-18 01:36:54 +08:00
|
|
|
new_penalty = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-04-18 01:36:54 +08:00
|
|
|
acpi_isa_irq_penalty[irq] = new_penalty;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (retval != 2) /* no next number */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We'd like PNP to call this routine for the
|
|
|
|
* single ISA_USED value for each legacy device.
|
|
|
|
* But instead it calls us with each POSSIBLE setting.
|
|
|
|
* There is no ISA_POSSIBLE weight, so we simply use
|
|
|
|
* the (small) PCI_USING penalty.
|
|
|
|
*/
|
2005-04-01 13:07:31 +08:00
|
|
|
void acpi_penalize_isa_irq(int irq, int active)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-04-18 01:36:54 +08:00
|
|
|
if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
|
2016-10-24 12:31:30 +08:00
|
|
|
acpi_isa_irq_penalty[irq] +=
|
2016-06-29 16:27:38 +08:00
|
|
|
(active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-09-17 14:02:45 +08:00
|
|
|
bool acpi_isa_irq_available(int irq)
|
|
|
|
{
|
2016-04-18 01:36:54 +08:00
|
|
|
return irq >= 0 && (irq >= ARRAY_SIZE(acpi_isa_irq_penalty) ||
|
2016-04-18 01:36:53 +08:00
|
|
|
acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
|
2015-09-17 14:02:45 +08:00
|
|
|
}
|
|
|
|
|
ACPI/PCI: pci_link: penalize SCI correctly
Ondrej reported that IRQs stopped working in v4.7 on several
platforms. A typical scenario, from Ondrej's VT82C694X/694X, is:
ACPI: Using PIC for interrupt routing
ACPI: PCI Interrupt Link [LNKA] (IRQs 1 3 4 5 6 7 10 *11 12 14 15)
ACPI: No IRQ available for PCI Interrupt Link [LNKA]
8139too 0000:00:0f.0: PCI INT A: no GSI
We're using PIC routing, so acpi_irq_balance == 0, and LNKA is already
active at IRQ 11. In that case, acpi_pci_link_allocate() only tries
to use the active IRQ (IRQ 11) which also happens to be the SCI.
We should penalize the SCI by PIRQ_PENALTY_PCI_USING, but
irq_get_trigger_type(11) returns something other than
IRQ_TYPE_LEVEL_LOW, so we penalize it by PIRQ_PENALTY_ISA_ALWAYS
instead, which makes acpi_pci_link_allocate() assume the IRQ isn't
available and give up.
Add acpi_penalize_sci_irq() so platforms can tell us the SCI IRQ,
trigger, and polarity directly and we don't have to depend on
irq_get_trigger_type().
Fixes: 103544d86976 (ACPI,PCI,IRQ: reduce resource requirements)
Link: http://lkml.kernel.org/r/201609251512.05657.linux@rainbow-software.org
Reported-by: Ondrej Zary <linux@rainbow-software.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Tested-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-10-24 12:31:31 +08:00
|
|
|
void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
|
|
|
|
{
|
|
|
|
sci_irq = irq;
|
|
|
|
|
|
|
|
if (trigger == ACPI_MADT_TRIGGER_LEVEL &&
|
|
|
|
polarity == ACPI_MADT_POLARITY_ACTIVE_LOW)
|
|
|
|
sci_penalty = PIRQ_PENALTY_PCI_USING;
|
|
|
|
else
|
|
|
|
sci_penalty = PIRQ_PENALTY_ISA_ALWAYS;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Over-ride default table to reserve additional IRQs for use by ISA
|
|
|
|
* e.g. acpi_irq_isa=5
|
|
|
|
* Useful for telling ACPI how not to interfere with your ISA sound card.
|
|
|
|
*/
|
|
|
|
static int __init acpi_irq_isa(char *str)
|
|
|
|
{
|
|
|
|
return acpi_irq_penalty_update(str, 1);
|
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__setup("acpi_irq_isa=", acpi_irq_isa);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Over-ride default table to free additional IRQs for use by PCI
|
|
|
|
* e.g. acpi_irq_pci=7,15
|
|
|
|
* Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
|
|
|
|
*/
|
|
|
|
static int __init acpi_irq_pci(char *str)
|
|
|
|
{
|
|
|
|
return acpi_irq_penalty_update(str, 0);
|
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__setup("acpi_irq_pci=", acpi_irq_pci);
|
|
|
|
|
|
|
|
static int __init acpi_irq_nobalance_set(char *str)
|
|
|
|
{
|
|
|
|
acpi_irq_balance = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
|
|
|
|
|
2008-12-10 03:45:30 +08:00
|
|
|
static int __init acpi_irq_balance_set(char *str)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
acpi_irq_balance = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
__setup("acpi_irq_balance", acpi_irq_balance_set);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-03-13 05:16:51 +08:00
|
|
|
static struct syscore_ops irqrouter_syscore_ops = {
|
2005-08-05 12:44:28 +08:00
|
|
|
.resume = irqrouter_resume,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2013-01-30 21:27:37 +08:00
|
|
|
void __init acpi_pci_link_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
if (acpi_noirq)
|
2013-01-30 21:27:37 +08:00
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-11-06 07:17:52 +08:00
|
|
|
if (acpi_irq_balance == -1) {
|
|
|
|
/* no command line switch: enable balancing in IOAPIC mode */
|
|
|
|
if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
|
|
|
|
acpi_irq_balance = 1;
|
|
|
|
else
|
|
|
|
acpi_irq_balance = 0;
|
|
|
|
}
|
2013-01-30 21:27:37 +08:00
|
|
|
register_syscore_ops(&irqrouter_syscore_ops);
|
|
|
|
acpi_scan_add_handler(&pci_link_handler);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|