Commit 9a90e098 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (27 commits)
  ACPI: Don't let acpi_pad needlessly mark TSC unstable
  drivers/acpi/sleep.h: Checkpatch cleanup
  ACPI: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
  ACPI: delete unused c-state promotion/demotion data strucutures
  ACPI: video: fix acpi_backlight=video
  ACPI: EC: Use kmemdup
  drivers/acpi: use kasprintf
  ACPI, APEI, EINJ injection parameters support
  Add x64 support to debugfs
  ACPI, APEI, Use ERST for persistent storage of MCE
  ACPI, APEI, Error Record Serialization Table (ERST) support
  ACPI, APEI, Generic Hardware Error Source memory error support
  ACPI, APEI, UEFI Common Platform Error Record (CPER) header
  Unified UUID/GUID definition
  ACPI Hardware Error Device (PNP0C33) support
  ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_first setup
  ACPI, APEI, Document for APEI
  ACPI, APEI, EINJ support
  ACPI, APEI, HEST table parsing
  ACPI, APEI, APEI supporting infrastructure
  ...
parents d372e7fe d3b38333
APEI Error INJection
~~~~~~~~~~~~~~~~~~~~
EINJ provides a hardware error injection mechanism
It is very useful for debugging and testing of other APEI and RAS features.
To use EINJ, make sure the following are enabled in your kernel
configuration:
CONFIG_DEBUG_FS
CONFIG_ACPI_APEI
CONFIG_ACPI_APEI_EINJ
The user interface of EINJ is debug file system, under the
directory apei/einj. The following files are provided.
- available_error_type
Reading this file returns the error injection capability of the
platform, that is, which error types are supported. The error type
definition is as follow, the left field is the error type value, the
right field is error description.
0x00000001 Processor Correctable
0x00000002 Processor Uncorrectable non-fatal
0x00000004 Processor Uncorrectable fatal
0x00000008 Memory Correctable
0x00000010 Memory Uncorrectable non-fatal
0x00000020 Memory Uncorrectable fatal
0x00000040 PCI Express Correctable
0x00000080 PCI Express Uncorrectable fatal
0x00000100 PCI Express Uncorrectable non-fatal
0x00000200 Platform Correctable
0x00000400 Platform Uncorrectable non-fatal
0x00000800 Platform Uncorrectable fatal
The format of file contents are as above, except there are only the
available error type lines.
- error_type
This file is used to set the error type value. The error type value
is defined in "available_error_type" description.
- error_inject
Write any integer to this file to trigger the error
injection. Before this, please specify all necessary error
parameters.
- param1
This file is used to set the first error parameter value. Effect of
parameter depends on error_type specified. For memory error, this is
physical memory address.
- param2
This file is used to set the second error parameter value. Effect of
parameter depends on error_type specified. For memory error, this is
physical memory address mask.
For more information about EINJ, please refer to ACPI specification
version 4.0, section 17.5.
...@@ -145,11 +145,10 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -145,11 +145,10 @@ and is between 256 and 4096 characters. It is defined in the file
acpi= [HW,ACPI,X86] acpi= [HW,ACPI,X86]
Advanced Configuration and Power Interface Advanced Configuration and Power Interface
Format: { force | off | ht | strict | noirq | rsdt } Format: { force | off | strict | noirq | rsdt }
force -- enable ACPI if default was off force -- enable ACPI if default was off
off -- disable ACPI if default was on off -- disable ACPI if default was on
noirq -- do not use ACPI for IRQ routing noirq -- do not use ACPI for IRQ routing
ht -- run only enough ACPI to enable Hyper Threading
strict -- Be less tolerant of platforms that are not strict -- Be less tolerant of platforms that are not
strictly ACPI specification compliant. strictly ACPI specification compliant.
rsdt -- prefer RSDT over (default) XSDT rsdt -- prefer RSDT over (default) XSDT
...@@ -758,6 +757,10 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -758,6 +757,10 @@ and is between 256 and 4096 characters. It is defined in the file
Default value is 0. Default value is 0.
Value can be changed at runtime via /selinux/enforce. Value can be changed at runtime via /selinux/enforce.
erst_disable [ACPI]
Disable Error Record Serialization Table (ERST)
support.
ether= [HW,NET] Ethernet cards parameters ether= [HW,NET] Ethernet cards parameters
This option is obsoleted by the "netdev=" option, which This option is obsoleted by the "netdev=" option, which
has equivalent usage. See its documentation for details. has equivalent usage. See its documentation for details.
...@@ -852,6 +855,11 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -852,6 +855,11 @@ and is between 256 and 4096 characters. It is defined in the file
hd= [EIDE] (E)IDE hard drive subsystem geometry hd= [EIDE] (E)IDE hard drive subsystem geometry
Format: <cyl>,<head>,<sect> Format: <cyl>,<head>,<sect>
hest_disable [ACPI]
Disable Hardware Error Source Table (HEST) support;
corresponding firmware-first mode error processing
logic will be disabled.
highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact
size of <nn>. This works even on boxes that have no size of <nn>. This works even on boxes that have no
highmem otherwise. This also works to reduce highmem highmem otherwise. This also works to reduce highmem
......
...@@ -94,7 +94,6 @@ ia64_acpi_release_global_lock (unsigned int *lock) ...@@ -94,7 +94,6 @@ ia64_acpi_release_global_lock (unsigned int *lock)
#define acpi_noirq 0 /* ACPI always enabled on IA64 */ #define acpi_noirq 0 /* ACPI always enabled on IA64 */
#define acpi_pci_disabled 0 /* ACPI PCI always enabled on IA64 */ #define acpi_pci_disabled 0 /* ACPI PCI always enabled on IA64 */
#define acpi_strict 1 /* no ACPI spec workarounds on IA64 */ #define acpi_strict 1 /* no ACPI spec workarounds on IA64 */
#define acpi_ht 0 /* no HT-only mode on IA64 */
#endif #endif
#define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */ #define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */
static inline void disable_acpi(void) { } static inline void disable_acpi(void) { }
......
...@@ -335,8 +335,11 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl) ...@@ -335,8 +335,11 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
} }
struct pci_bus * __devinit struct pci_bus * __devinit
pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) pci_acpi_scan_root(struct acpi_pci_root *root)
{ {
struct acpi_device *device = root->device;
int domain = root->segment;
int bus = root->secondary.start;
struct pci_controller *controller; struct pci_controller *controller;
unsigned int windows = 0; unsigned int windows = 0;
struct pci_bus *pbus; struct pci_bus *pbus;
......
...@@ -85,7 +85,6 @@ extern int acpi_ioapic; ...@@ -85,7 +85,6 @@ extern int acpi_ioapic;
extern int acpi_noirq; extern int acpi_noirq;
extern int acpi_strict; extern int acpi_strict;
extern int acpi_disabled; extern int acpi_disabled;
extern int acpi_ht;
extern int acpi_pci_disabled; extern int acpi_pci_disabled;
extern int acpi_skip_timer_override; extern int acpi_skip_timer_override;
extern int acpi_use_timer_override; extern int acpi_use_timer_override;
...@@ -97,7 +96,6 @@ void acpi_pic_sci_set_trigger(unsigned int, u16); ...@@ -97,7 +96,6 @@ void acpi_pic_sci_set_trigger(unsigned int, u16);
static inline void disable_acpi(void) static inline void disable_acpi(void)
{ {
acpi_disabled = 1; acpi_disabled = 1;
acpi_ht = 0;
acpi_pci_disabled = 1; acpi_pci_disabled = 1;
acpi_noirq = 1; acpi_noirq = 1;
} }
......
...@@ -225,5 +225,13 @@ extern void mcheck_intel_therm_init(void); ...@@ -225,5 +225,13 @@ extern void mcheck_intel_therm_init(void);
static inline void mcheck_intel_therm_init(void) { } static inline void mcheck_intel_therm_init(void) { }
#endif #endif
/*
* Used by APEI to report memory error via /dev/mcelog
*/
struct cper_sec_mem_err;
extern void apei_mce_report_mem_error(int corrected,
struct cper_sec_mem_err *mem_err);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_X86_MCE_H */ #endif /* _ASM_X86_MCE_H */
...@@ -63,7 +63,6 @@ EXPORT_SYMBOL(acpi_disabled); ...@@ -63,7 +63,6 @@ EXPORT_SYMBOL(acpi_disabled);
int acpi_noirq; /* skip ACPI IRQ initialization */ int acpi_noirq; /* skip ACPI IRQ initialization */
int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
EXPORT_SYMBOL(acpi_pci_disabled); EXPORT_SYMBOL(acpi_pci_disabled);
int acpi_ht __initdata = 1; /* enable HT */
int acpi_lapic; int acpi_lapic;
int acpi_ioapic; int acpi_ioapic;
...@@ -1501,9 +1500,8 @@ void __init acpi_boot_table_init(void) ...@@ -1501,9 +1500,8 @@ void __init acpi_boot_table_init(void)
/* /*
* If acpi_disabled, bail out * If acpi_disabled, bail out
* One exception: acpi=ht continues far enough to enumerate LAPICs
*/ */
if (acpi_disabled && !acpi_ht) if (acpi_disabled)
return; return;
/* /*
...@@ -1534,9 +1532,8 @@ int __init early_acpi_boot_init(void) ...@@ -1534,9 +1532,8 @@ int __init early_acpi_boot_init(void)
{ {
/* /*
* If acpi_disabled, bail out * If acpi_disabled, bail out
* One exception: acpi=ht continues far enough to enumerate LAPICs
*/ */
if (acpi_disabled && !acpi_ht) if (acpi_disabled)
return 1; return 1;
/* /*
...@@ -1554,9 +1551,8 @@ int __init acpi_boot_init(void) ...@@ -1554,9 +1551,8 @@ int __init acpi_boot_init(void)
/* /*
* If acpi_disabled, bail out * If acpi_disabled, bail out
* One exception: acpi=ht continues far enough to enumerate LAPICs
*/ */
if (acpi_disabled && !acpi_ht) if (acpi_disabled)
return 1; return 1;
acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
...@@ -1591,21 +1587,12 @@ static int __init parse_acpi(char *arg) ...@@ -1591,21 +1587,12 @@ static int __init parse_acpi(char *arg)
/* acpi=force to over-ride black-list */ /* acpi=force to over-ride black-list */
else if (strcmp(arg, "force") == 0) { else if (strcmp(arg, "force") == 0) {
acpi_force = 1; acpi_force = 1;
acpi_ht = 1;
acpi_disabled = 0; acpi_disabled = 0;
} }
/* acpi=strict disables out-of-spec workarounds */ /* acpi=strict disables out-of-spec workarounds */
else if (strcmp(arg, "strict") == 0) { else if (strcmp(arg, "strict") == 0) {
acpi_strict = 1; acpi_strict = 1;
} }
/* Limit ACPI just to boot-time to enable HT */
else if (strcmp(arg, "ht") == 0) {
if (!acpi_force) {
printk(KERN_WARNING "acpi=ht will be removed in Linux-2.6.35\n");
disable_acpi();
}
acpi_ht = 1;
}
/* acpi=rsdt use RSDT instead of XSDT */ /* acpi=rsdt use RSDT instead of XSDT */
else if (strcmp(arg, "rsdt") == 0) { else if (strcmp(arg, "rsdt") == 0) {
acpi_rsdt_forced = 1; acpi_rsdt_forced = 1;
......
...@@ -162,8 +162,6 @@ static int __init acpi_sleep_setup(char *str) ...@@ -162,8 +162,6 @@ static int __init acpi_sleep_setup(char *str)
#endif #endif
if (strncmp(str, "old_ordering", 12) == 0) if (strncmp(str, "old_ordering", 12) == 0)
acpi_old_suspend_ordering(); acpi_old_suspend_ordering();
if (strncmp(str, "sci_force_enable", 16) == 0)
acpi_set_sci_en_on_resume();
str = strchr(str, ','); str = strchr(str, ',');
if (str != NULL) if (str != NULL)
str += strspn(str, ", \t"); str += strspn(str, ", \t");
......
...@@ -7,3 +7,5 @@ obj-$(CONFIG_X86_MCE_THRESHOLD) += threshold.o ...@@ -7,3 +7,5 @@ obj-$(CONFIG_X86_MCE_THRESHOLD) += threshold.o
obj-$(CONFIG_X86_MCE_INJECT) += mce-inject.o obj-$(CONFIG_X86_MCE_INJECT) += mce-inject.o
obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.o obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.o
obj-$(CONFIG_ACPI_APEI) += mce-apei.o
/*
* Bridge between MCE and APEI
*
* On some machine, corrected memory errors are reported via APEI
* generic hardware error source (GHES) instead of corrected Machine
* Check. These corrected memory errors can be reported to user space
* through /dev/mcelog via faking a corrected Machine Check, so that
* the error memory page can be offlined by /sbin/mcelog if the error
* count for one page is beyond the threshold.
*
* For fatal MCE, save MCE record into persistent storage via ERST, so
* that the MCE record can be logged after reboot via ERST.
*
* Copyright 2010 Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/cper.h>
#include <acpi/apei.h>
#include <asm/mce.h>
#include "mce-internal.h"
void apei_mce_report_mem_error(int corrected, struct cper_sec_mem_err *mem_err)
{
struct mce m;
/* Only corrected MC is reported */
if (!corrected)
return;
mce_setup(&m);
m.bank = 1;
/* Fake a memory read corrected error with unknown channel */
m.status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | 0x9f;
m.addr = mem_err->physical_addr;
mce_log(&m);
mce_notify_irq();
}
EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
#define CPER_CREATOR_MCE \
UUID_LE(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \
0x64, 0x90, 0xb8, 0x9d)
#define CPER_SECTION_TYPE_MCE \
UUID_LE(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \
0x04, 0x4a, 0x38, 0xfc)
/*
* CPER specification (in UEFI specification 2.3 appendix N) requires
* byte-packed.
*/
struct cper_mce_record {
struct cper_record_header hdr;
struct cper_section_descriptor sec_hdr;
struct mce mce;
} __packed;
int apei_write_mce(struct mce *m)
{
struct cper_mce_record rcd;
memset(&rcd, 0, sizeof(rcd));
memcpy(rcd.hdr.signature, CPER_SIG_RECORD, CPER_SIG_SIZE);
rcd.hdr.revision = CPER_RECORD_REV;
rcd.hdr.signature_end = CPER_SIG_END;
rcd.hdr.section_count = 1;
rcd.hdr.error_severity = CPER_SER_FATAL;
/* timestamp, platform_id, partition_id are all invalid */
rcd.hdr.validation_bits = 0;
rcd.hdr.record_length = sizeof(rcd);
rcd.hdr.creator_id = CPER_CREATOR_MCE;
rcd.hdr.notification_type = CPER_NOTIFY_MCE;
rcd.hdr.record_id = cper_next_record_id();
rcd.hdr.flags = CPER_HW_ERROR_FLAGS_PREVERR;
rcd.sec_hdr.section_offset = (void *)&rcd.mce - (void *)&rcd;
rcd.sec_hdr.section_length = sizeof(rcd.mce);
rcd.sec_hdr.revision = CPER_SEC_REV;
/* fru_id and fru_text is invalid */
rcd.sec_hdr.validation_bits = 0;
rcd.sec_hdr.flags = CPER_SEC_PRIMARY;
rcd.sec_hdr.section_type = CPER_SECTION_TYPE_MCE;
rcd.sec_hdr.section_severity = CPER_SER_FATAL;
memcpy(&rcd.mce, m, sizeof(*m));
return erst_write(&rcd.hdr);
}
ssize_t apei_read_mce(struct mce *m, u64 *record_id)
{
struct cper_mce_record rcd;
ssize_t len;
len = erst_read_next(&rcd.hdr, sizeof(rcd));
if (len <= 0)
return len;
/* Can not skip other records in storage via ERST unless clear them */
else if (len != sizeof(rcd) ||
uuid_le_cmp(rcd.hdr.creator_id, CPER_CREATOR_MCE)) {
if (printk_ratelimit())
pr_warning(
"MCE-APEI: Can not skip the unknown record in ERST");
return -EIO;
}
memcpy(m, &rcd.mce, sizeof(*m));
*record_id = rcd.hdr.record_id;
return sizeof(*m);
}
/* Check whether there is record in ERST */
int apei_check_mce(void)
{
return erst_get_record_count();
}
int apei_clear_mce(u64 record_id)
{
return erst_clear(record_id);
}
...@@ -28,3 +28,26 @@ extern int mce_ser; ...@@ -28,3 +28,26 @@ extern int mce_ser;
extern struct mce_bank *mce_banks; extern struct mce_bank *mce_banks;
#ifdef CONFIG_ACPI_APEI
int apei_write_mce(struct mce *m);
ssize_t apei_read_mce(struct mce *m, u64 *record_id);
int apei_check_mce(void);
int apei_clear_mce(u64 record_id);
#else
static inline int apei_write_mce(struct mce *m)
{
return -EINVAL;
}
static inline ssize_t apei_read_mce(struct mce *m, u64 *record_id)
{
return 0;
}
static inline int apei_check_mce(void)
{
return 0;
}
static inline int apei_clear_mce(u64 record_id)
{
return -EINVAL;
}
#endif
...@@ -264,7 +264,7 @@ static void wait_for_panic(void) ...@@ -264,7 +264,7 @@ static void wait_for_panic(void)
static void mce_panic(char *msg, struct mce *final, char *exp) static void mce_panic(char *msg, struct mce *final, char *exp)
{ {
int i; int i, apei_err = 0;
if (!fake_panic) { if (!fake_panic) {
/* /*
...@@ -287,8 +287,11 @@ static void mce_panic(char *msg, struct mce *final, char *exp) ...@@ -287,8 +287,11 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
struct mce *m = &mcelog.entry[i]; struct mce *m = &mcelog.entry[i];
if (!(m->status & MCI_STATUS_VAL)) if (!(m->status & MCI_STATUS_VAL))
continue; continue;
if (!(m->status & MCI_STATUS_UC)) if (!(m->status & MCI_STATUS_UC)) {
print_mce(m); print_mce(m);
if (!apei_err)
apei_err = apei_write_mce(m);
}
} }
/* Now print uncorrected but with the final one last */ /* Now print uncorrected but with the final one last */
for (i = 0; i < MCE_LOG_LEN; i++) { for (i = 0; i < MCE_LOG_LEN; i++) {
...@@ -297,11 +300,17 @@ static void mce_panic(char *msg, struct mce *final, char *exp) ...@@ -297,11 +300,17 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
continue; continue;
if (!(m->status & MCI_STATUS_UC)) if (!(m->status & MCI_STATUS_UC))
continue; continue;
if (!final || memcmp(m, final, sizeof(struct mce))) if (!final || memcmp(m, final, sizeof(struct mce))) {
print_mce(m); print_mce(m);
if (!apei_err)
apei_err = apei_write_mce(m);
} }
if (final) }
if (final) {
print_mce(final); print_mce(final);
if (!apei_err)
apei_err = apei_write_mce(final);
}
if (cpu_missing) if (cpu_missing)
printk(KERN_EMERG "Some CPUs didn't answer in synchronization\n"); printk(KERN_EMERG "Some CPUs didn't answer in synchronization\n");
print_mce_tail(); print_mce_tail();
...@@ -1493,6 +1502,43 @@ static void collect_tscs(void *data) ...@@ -1493,6 +1502,43 @@ static void collect_tscs(void *data)
rdtscll(cpu_tsc[smp_processor_id()]); rdtscll(cpu_tsc[smp_processor_id()]);
} }
static int mce_apei_read_done;
/* Collect MCE record of previous boot in persistent storage via APEI ERST. */
static int __mce_read_apei(char __user **ubuf, size_t usize)
{
int rc;
u64 record_id;
struct mce m;
if (usize < sizeof(struct mce))
return -EINVAL;
rc = apei_read_mce(&m, &record_id);
/* Error or no more MCE record */
if (rc <= 0) {
mce_apei_read_done = 1;
return rc;
}
rc = -EFAULT;
if (copy_to_user(*ubuf, &m, sizeof(struct mce)))
return rc;
/*
* In fact, we should have cleared the record after that has
* been flushed to the disk or sent to network in
* /sbin/mcelog, but we have no interface to support that now,
* so just clear it to avoid duplication.
*/
rc = apei_clear_mce(record_id);
if (rc) {
mce_apei_read_done = 1;
return rc;
}
*ubuf += sizeof(struct mce);
return 0;
}
static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
loff_t *off) loff_t *off)
{ {
...@@ -1506,15 +1552,19 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, ...@@ -1506,15 +1552,19 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
return -ENOMEM; return -ENOMEM;
mutex_lock(&mce_read_mutex); mutex_lock(&mce_read_mutex);
if (!mce_apei_read_done) {
err = __mce_read_apei(&buf, usize);
if (err || buf != ubuf)
goto out;
}
next = rcu_dereference_check_mce(mcelog.next); next = rcu_dereference_check_mce(mcelog.next);
/* Only supports full reads right now */ /* Only supports full reads right now */
if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { err = -EINVAL;
mutex_unlock(&mce_read_mutex); if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce))
kfree(cpu_tsc); goto out;
return -EINVAL;
}
err = 0; err = 0;
prev = 0; prev = 0;
...@@ -1562,10 +1612,15 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, ...@@ -1562,10 +1612,15 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
memset(&mcelog.entry[i], 0, sizeof(struct mce)); memset(&mcelog.entry[i], 0, sizeof(struct mce));
} }
} }
if (err)
err = -EFAULT;
out:
mutex_unlock(&mce_read_mutex); mutex_unlock(&mce_read_mutex);
kfree(cpu_tsc); kfree(cpu_tsc);
return err ? -EFAULT : buf - ubuf; return err ? err : buf - ubuf;
} }
static unsigned int mce_poll(struct file *file, poll_table *wait) static unsigned int mce_poll(struct file *file, poll_table *wait)
...@@ -1573,6 +1628,8 @@ static unsigned int mce_poll(struct file *file, poll_table *wait) ...@@ -1573,6 +1628,8 @@ static unsigned int mce_poll(struct file *file, poll_table *wait)
poll_wait(file, &mce_wait, wait); poll_wait(file, &mce_wait, wait);
if (rcu_dereference_check_mce(mcelog.next)) if (rcu_dereference_check_mce(mcelog.next))
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
if (!mce_apei_read_done && apei_check_mce())
return POLLIN | POLLRDNORM;
return 0; return 0;
} }
......
...@@ -1390,7 +1390,6 @@ __init void lguest_init(void) ...@@ -1390,7 +1390,6 @@ __init void lguest_init(void)
#endif #endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
acpi_disabled = 1; acpi_disabled = 1;
acpi_ht = 0;
#endif #endif
/* /*
......
...@@ -224,8 +224,11 @@ get_current_resources(struct acpi_device *device, int busnum, ...@@ -224,8 +224,11 @@ get_current_resources(struct acpi_device *device, int busnum,
return; return;
} }
struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum) struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
{ {
struct acpi_device *device = root->device;
int domain = root->segment;
int busnum = root->secondary.start;
struct pci_bus *bus; struct pci_bus *bus;
struct pci_sysdata *sd; struct pci_sysdata *sd;
int node; int node;
......
...@@ -360,4 +360,13 @@ config ACPI_SBS ...@@ -360,4 +360,13 @@ config ACPI_SBS
To compile this driver as a module, choose M here: To compile this driver as a module, choose M here:
the modules will be called sbs and sbshc. the modules will be called sbs and sbshc.
config ACPI_HED
tristate "Hardware Error Device"
help
This driver supports the Hardware Error Device (PNP0C33),
which is used to report some hardware errors notified via
SCI, mainly the corrected errors.
source "drivers/acpi/apei/Kconfig"
endif # ACPI endif # ACPI
...@@ -19,7 +19,7 @@ obj-y += acpi.o \ ...@@ -19,7 +19,7 @@ obj-y += acpi.o \
# All the builtin files are in the "acpi." module_param namespace. # All the builtin files are in the "acpi." module_param namespace.
acpi-y += osl.o utils.o reboot.o acpi-y += osl.o utils.o reboot.o
acpi-y += hest.o acpi-y += atomicio.o
# sleep related files # sleep related files
acpi-y += wakeup.o acpi-y += wakeup.o
...@@ -59,6 +59,7 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o ...@@ -59,6 +59,7 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o obj-$(CONFIG_ACPI_SBS) += sbshc.o
obj-$(CONFIG_ACPI_SBS) += sbs.o obj-$(CONFIG_ACPI_SBS) += sbs.o
obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o
obj-$(CONFIG_ACPI_HED) += hed.o
# processor has its own "processor." module_param namespace # processor has its own "processor." module_param namespace
processor-y := processor_driver.o processor_throttling.o processor-y := processor_driver.o processor_throttling.o
...@@ -66,3 +67,5 @@ processor-y += processor_idle.o processor_thermal.o ...@@ -66,3 +67,5 @@ processor-y += processor_idle.o processor_thermal.o
processor-$(CONFIG_CPU_FREQ) += processor_perflib.o processor-$(CONFIG_CPU_FREQ) += processor_perflib.o
obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
obj-$(CONFIG_ACPI_APEI) += apei/
...@@ -43,6 +43,10 @@ static DEFINE_MUTEX(isolated_cpus_lock); ...@@ -43,6 +43,10 @@ static DEFINE_MUTEX(isolated_cpus_lock);
#define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1) #define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1)
#define CPUID5_ECX_INTERRUPT_BREAK (0x2) #define CPUID5_ECX_INTERRUPT_BREAK (0x2)
static unsigned long power_saving_mwait_eax; static unsigned long power_saving_mwait_eax;
static unsigned char tsc_detected_unstable;
static unsigned char tsc_marked_unstable;
static void power_saving_mwait_init(void) static void power_saving_mwait_init(void)
{ {
unsigned int eax, ebx, ecx, edx; unsigned int eax, ebx, ecx, edx;
...@@ -87,8 +91,8 @@ static void power_saving_mwait_init(void) ...@@ -87,8 +91,8 @@ static void power_saving_mwait_init(void)
/*FALL THROUGH*/ /*FALL THROUGH*/
default: default:
/* TSC could halt in idle, so notify users */ /* TSC could halt in idle */
mark_tsc_unstable("TSC halts in idle"); tsc_detected_unstable = 1;
} }
#endif #endif
} }
...@@ -178,6 +182,11 @@ static int power_saving_thread(void *data) ...@@ -178,6 +182,11 @@ static int power_saving_thread(void *data)
expire_time = jiffies + HZ * (100 - idle_pct) / 100; expire_time = jiffies + HZ * (100 - idle_pct) / 100;
while (!need_resched()) { while (!need_resched()) {
if (tsc_detected_unstable && !tsc_marked_unstable) {
/* TSC could halt in idle, so notify users */
mark_tsc_unstable("TSC halts in idle");
tsc_marked_unstable = 1;
}
local_irq_disable(); local_irq_disable();
cpu = smp_processor_id(); cpu = smp_processor_id();
clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
......
...@@ -69,7 +69,7 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ...@@ -69,7 +69,7 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
acpi_status acpi_enable(void) acpi_status acpi_enable(void)
{ {
acpi_status status = AE_OK; acpi_status status;
ACPI_FUNCTION_TRACE(acpi_enable); ACPI_FUNCTION_TRACE(acpi_enable);
...@@ -84,7 +84,9 @@ acpi_status acpi_enable(void) ...@@ -84,7 +84,9 @@ acpi_status acpi_enable(void)
if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
ACPI_DEBUG_PRINT((ACPI_DB_INIT, ACPI_DEBUG_PRINT((ACPI_DB_INIT,
"System is already in ACPI mode\n")); "System is already in ACPI mode\n"));
} else { return_ACPI_STATUS(AE_OK);
}
/* Transition to ACPI mode */ /* Transition to ACPI mode */
status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
...@@ -94,11 +96,18 @@ acpi_status acpi_enable(void) ...@@ -94,11 +96,18 @@ acpi_status acpi_enable(void)
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
/* Sanity check that transition succeeded */
if (acpi_hw_get_mode() != ACPI_SYS_MODE_ACPI) {
ACPI_ERROR((AE_INFO,
"Hardware did not enter ACPI mode"));
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
}
ACPI_DEBUG_PRINT((ACPI_DB_INIT, ACPI_DEBUG_PRINT((ACPI_DB_INIT,
"Transition to ACPI mode successful\n")); "Transition to ACPI mode successful\n"));
}
return_ACPI_STATUS(status); return_ACPI_STATUS(AE_OK);
} }
ACPI_EXPORT_SYMBOL(acpi_enable) ACPI_EXPORT_SYMBOL(acpi_enable)
......
...@@ -63,7 +63,6 @@ acpi_status acpi_hw_set_mode(u32 mode) ...@@ -63,7 +63,6 @@ acpi_status acpi_hw_set_mode(u32 mode)
{ {
acpi_status status; acpi_status status;
u32 retry;
ACPI_FUNCTION_TRACE(hw_set_mode); ACPI_FUNCTION_TRACE(hw_set_mode);
...@@ -125,24 +124,7 @@ acpi_status acpi_hw_set_mode(u32 mode) ...@@ -125,24 +124,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
/*
* Some hardware takes a LONG time to switch modes. Give them 3 sec to
* do so, but allow faster systems to proceed more quickly.
*/
retry = 3000;
while (retry) {
if (acpi_hw_get_mode() == mode) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Mode %X successfully enabled\n",
mode));
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
}
acpi_os_stall(1000);
retry--;
}
ACPI_ERROR((AE_INFO, "Hardware did not change modes"));
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
} }
/******************************************************************************* /*******************************************************************************
......
config ACPI_APEI
bool "ACPI Platform Error Interface (APEI)"
depends on X86
help
APEI allows to report errors (for example from the chipset)
to the operating system. This improves NMI handling
especially. In addition it supports error serialization and
error injection.
config ACPI_APEI_GHES
tristate "APEI Generic Hardware Error Source"
depends on ACPI_APEI && X86
select ACPI_HED
help
Generic Hardware Error Source provides a way to report
platform hardware errors (such as that from chipset). It
works in so called "Firmware First" mode, that is, hardware
errors are reported to firmware firstly, then reported to
Linux by firmware. This way, some non-standard hardware
error registers or non-standard hardware link can be checked
by firmware to produce more valuable hardware error
information for Linux.
config ACPI_APEI_EINJ
tristate "APEI Error INJection (EINJ)"
depends on ACPI_APEI && DEBUG_FS
help
EINJ provides a hardware error injection mechanism, it is
mainly used for debugging and testing the other parts of
APEI and some other RAS features.
obj-$(CONFIG_ACPI_APEI) += apei.o
obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
apei-y := apei-base.o hest.o cper.o erst.o
This diff is collapsed.
/*
* apei-internal.h - ACPI Platform Error Interface internal
* definations.
*/
#ifndef APEI_INTERNAL_H
#define APEI_INTERNAL_H
#include <linux/cper.h>
struct apei_exec_context;
typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
#define APEI_EXEC_INS_ACCESS_REGISTER 0x0001
struct apei_exec_ins_type {
u32 flags;
apei_exec_ins_func_t run;
};
struct apei_exec_context {
u32 ip;
u64 value;
u64 var1;
u64 var2;
u64 src_base;
u64 dst_base;
struct apei_exec_ins_type *ins_table;
u32 instructions;
struct acpi_whea_header *action_table;
u32 entries;
};
void apei_exec_ctx_init(struct apei_exec_context *ctx,
struct apei_exec_ins_type *ins_table,
u32 instructions,
struct acpi_whea_header *action_table,
u32 entries);
static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
u64 input)
{
ctx->value = input;
}
static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
{
return ctx->value;
}
int apei_exec_run(struct apei_exec_context *ctx, u8 action);
/* Common instruction implementation */
/* IP has been set in instruction function */
#define APEI_EXEC_SET_IP 1
int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
int apei_exec_read_register(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
int apei_exec_read_register_value(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
int apei_exec_write_register(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
int apei_exec_write_register_value(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
int apei_exec_noop(struct apei_exec_context *ctx,
struct acpi_whea_header *entry);
int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
struct apei_resources {
struct list_head iomem;
struct list_head ioport;
};
static inline void apei_resources_init(struct apei_resources *resources)
{
INIT_LIST_HEAD(&resources->iomem);
INIT_LIST_HEAD(&resources->ioport);
}
void apei_resources_fini(struct apei_resources *resources);
int apei_resources_sub(struct apei_resources *resources1,
struct apei_resources *resources2);
int apei_resources_request(struct apei_resources *resources,
const char *desc);
void apei_resources_release(struct apei_resources *resources);
int apei_exec_collect_resources(struct apei_exec_context *ctx,
struct apei_resources *resources);
struct dentry;
struct dentry *apei_get_debugfs_dir(void);
#define apei_estatus_for_each_section(estatus, section) \
for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
(void *)section - (void *)estatus < estatus->data_length; \
section = (void *)(section+1) + section->error_data_length)
static inline u32 apei_estatus_len(struct acpi_hest_generic_status *estatus)
{
if (estatus->raw_data_length)
return estatus->raw_data_offset + \
estatus->raw_data_length;
else
return sizeof(*estatus) + estatus->data_length;
}
int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus);
int apei_estatus_check(const struct acpi_hest_generic_status *estatus);
#endif
/*
* UEFI Common Platform Error Record (CPER) support
*
* Copyright (C) 2010, Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* CPER is the format used to describe platform hardware error by
* various APEI tables, such as ERST, BERT and HEST etc.
*
* For more information about CPER, please refer to Appendix N of UEFI
* Specification version 2.3.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/time.h>
#include <linux/cper.h>
#include <linux/acpi.h>
/*
* CPER record ID need to be unique even after reboot, because record
* ID is used as index for ERST storage, while CPER records from
* multiple boot may co-exist in ERST.
*/
u64 cper_next_record_id(void)
{
static atomic64_t seq;
if (!atomic64_read(&seq))
atomic64_set(&seq, ((u64)get_seconds()) << 32);
return atomic64_inc_return(&seq);
}
EXPORT_SYMBOL_GPL(cper_next_record_id);
int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus)
{
if (estatus->data_length &&
estatus->data_length < sizeof(struct acpi_hest_generic_data))
return -EINVAL;
if (estatus->raw_data_length &&
estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length)
return -EINVAL;
return 0;
}
EXPORT_SYMBOL_GPL(apei_estatus_check_header);
int apei_estatus_check(const struct acpi_hest_generic_status *estatus)
{
struct acpi_hest_generic_data *gdata;
unsigned int data_len, gedata_len;
int rc;
rc = apei_estatus_check_header(estatus);
if (rc)
return rc;
data_len = estatus->data_length;
gdata = (struct acpi_hest_generic_data *)(estatus + 1);
while (data_len > sizeof(*gdata)) {
gedata_len = gdata->error_data_length;
if (gedata_len > data_len - sizeof(*gdata))
return -EINVAL;
data_len -= gedata_len + sizeof(*gdata);
}
if (data_len)
return -EINVAL;
return 0;
}
EXPORT_SYMBOL_GPL(apei_estatus_check);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* APEI Hardware Error Souce Table support
*
* HEST describes error sources in detail; communicates operational
* parameters (i.e. severity levels, masking bits, and threshold
* values) to Linux as necessary. It also allows the BIOS to report
* non-standard error sources to Linux (for example, chipset-specific
* error registers).
*
* For more information about HEST, please refer to ACPI Specification
* version 4.0, section 17.3.2.
*
* Copyright 2009 Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/kdebug.h>
#include <linux/highmem.h>
#include <linux/io.h>
#include <acpi/apei.h>
#include "apei-internal.h"
#define HEST_PFX "HEST: "
int hest_disable;
EXPORT_SYMBOL_GPL(hest_disable);
/* HEST table parsing */
static struct acpi_table_hest *hest_tab;
static int hest_void_parse(struct acpi_hest_header *hest_hdr, void *data)
{
return 0;
}
static int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
[ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */
[ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1,
[ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi),
[ACPI_HEST_TYPE_AER_ROOT_PORT] = sizeof(struct acpi_hest_aer_root),
[ACPI_HEST_TYPE_AER_ENDPOINT] = sizeof(struct acpi_hest_aer),
[ACPI_HEST_TYPE_AER_BRIDGE] = sizeof(struct acpi_hest_aer_bridge),
[ACPI_HEST_TYPE_GENERIC_ERROR] = sizeof(struct acpi_hest_generic),
};
static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
{
u16 hest_type = hest_hdr->type;
int len;
if (hest_type >= ACPI_HEST_TYPE_RESERVED)
return 0;
len = hest_esrc_len_tab[hest_type];
if (hest_type == ACPI_HEST_TYPE_IA32_CORRECTED_CHECK) {
struct acpi_hest_ia_corrected *cmc;
cmc = (struct acpi_hest_ia_corrected *)hest_hdr;
len = sizeof(*cmc) + cmc->num_hardware_banks *
sizeof(struct acpi_hest_ia_error_bank);
} else if (hest_type == ACPI_HEST_TYPE_IA32_CHECK) {
struct acpi_hest_ia_machine_check *mc;
mc = (struct acpi_hest_ia_machine_check *)hest_hdr;
len = sizeof(*mc) + mc->num_hardware_banks *
sizeof(struct acpi_hest_ia_error_bank);
}
BUG_ON(len == -1);
return len;
};
int apei_hest_parse(apei_hest_func_t func, void *data)
{
struct acpi_hest_header *hest_hdr;
int i, rc, len;
if (hest_disable)
return -EINVAL;
hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
for (i = 0; i < hest_tab->error_source_count; i++) {
len = hest_esrc_len(hest_hdr);
if (!len) {
pr_warning(FW_WARN HEST_PFX
"Unknown or unused hardware error source "
"type: %d for hardware error source: %d.\n",
hest_hdr->type, hest_hdr->source_id);
return -EINVAL;
}
if ((void *)hest_hdr + len >
(void *)hest_tab + hest_tab->header.length) {
pr_warning(FW_BUG HEST_PFX
"Table contents overflow for hardware error source: %d.\n",
hest_hdr->source_id);
return -EINVAL;
}
rc = func(hest_hdr, data);
if (rc)
return rc;
hest_hdr = (void *)hest_hdr + len;
}
return 0;
}
EXPORT_SYMBOL_GPL(apei_hest_parse);
static int __init setup_hest_disable(char *str)
{
hest_disable = 1;
return 0;
}
__setup("hest_disable", setup_hest_disable);
static int __init hest_init(void)
{
acpi_status status;
int rc = -ENODEV;
if (acpi_disabled)
goto err;
if (hest_disable) {
pr_info(HEST_PFX "HEST tabling parsing is disabled.\n");
goto err;
}
status = acpi_get_table(ACPI_SIG_HEST, 0,
(struct acpi_table_header **)&hest_tab);
if (status == AE_NOT_FOUND) {
pr_info(HEST_PFX "Table is not found!\n");
goto err;
} else if (ACPI_FAILURE(status)) {
const char *msg = acpi_format_exception(status);
pr_err(HEST_PFX "Failed to get table, %s\n", msg);
rc = -EINVAL;
goto err;
}
rc = apei_hest_parse(hest_void_parse, NULL);
if (rc)
goto err;
pr_info(HEST_PFX "HEST table parsing is initialized.\n");
return 0;
err:
hest_disable = 1;
return rc;
}
subsys_initcall(hest_init);
/*
* atomicio.c - ACPI IO memory pre-mapping/post-unmapping, then
* accessing in atomic context.
*
* This is used for NMI handler to access IO memory area, because
* ioremap/iounmap can not be used in NMI handler. The IO memory area
* is pre-mapped in process context and accessed in NMI handler.
*
* Copyright (C) 2009-2010, Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/io.h>
#include <linux/kref.h>
#include <linux/rculist.h>
#include <linux/interrupt.h>
#include <acpi/atomicio.h>
#define ACPI_PFX "ACPI: "
static LIST_HEAD(acpi_iomaps);
/*
* Used for mutual exclusion between writers of acpi_iomaps list, for
* synchronization between readers and writer, RCU is used.
*/
static DEFINE_SPINLOCK(acpi_iomaps_lock);
struct acpi_iomap {
struct list_head list;
void __iomem *vaddr;
unsigned long size;
phys_addr_t paddr;
struct kref ref;
};
/* acpi_iomaps_lock or RCU read lock must be held before calling */
static struct acpi_iomap *__acpi_find_iomap(phys_addr_t paddr,
unsigned long size)
{
struct acpi_iomap *map;
list_for_each_entry_rcu(map, &acpi_iomaps, list) {
if (map->paddr + map->size >= paddr + size &&
map->paddr <= paddr)
return map;
}
return NULL;
}
/*
* Atomic "ioremap" used by NMI handler, if the specified IO memory
* area is not pre-mapped, NULL will be returned.
*
* acpi_iomaps_lock or RCU read lock must be held before calling
*/
static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
unsigned long size)
{
struct acpi_iomap *map;
map = __acpi_find_iomap(paddr, size);
if (map)
return map->vaddr + (paddr - map->paddr);
else
return NULL;
}
/* acpi_iomaps_lock must be held before calling */
static void __iomem *__acpi_try_ioremap(phys_addr_t paddr,
unsigned long size)
{
struct acpi_iomap *map;
map = __acpi_find_iomap(paddr, size);
if (map) {
kref_get(&map->ref);
return map->vaddr + (paddr - map->paddr);
} else
return NULL;
}
/*
* Used to pre-map the specified IO memory area. First try to find
* whether the area is already pre-mapped, if it is, increase the
* reference count (in __acpi_try_ioremap) and return; otherwise, do
* the real ioremap, and add the mapping into acpi_iomaps list.
*/
static void __iomem *acpi_pre_map(phys_addr_t paddr,
unsigned long size)
{
void __iomem *vaddr;
struct acpi_iomap *map;
unsigned long pg_sz, flags;
phys_addr_t pg_off;
spin_lock_irqsave(&acpi_iomaps_lock, flags);
vaddr = __acpi_try_ioremap(paddr, size);
spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
if (vaddr)
return vaddr;
pg_off = paddr & PAGE_MASK;
pg_sz = ((paddr + size + PAGE_SIZE - 1) & PAGE_MASK) - pg_off;
vaddr = ioremap(pg_off, pg_sz);
if (!vaddr)
return NULL;
map = kmalloc(sizeof(*map), GFP_KERNEL);
if (!map)
goto err_unmap;
INIT_LIST_HEAD(&map->list);
map->paddr = pg_off;
map->size = pg_sz;
map->vaddr = vaddr;
kref_init(&map->ref);
spin_lock_irqsave(&acpi_iomaps_lock, flags);
vaddr = __acpi_try_ioremap(paddr, size);
if (vaddr) {
spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
iounmap(map->vaddr);
kfree(map);
return vaddr;
}
list_add_tail_rcu(&map->list, &acpi_iomaps);
spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
return vaddr + (paddr - pg_off);
err_unmap:
iounmap(vaddr);
return NULL;
}
/* acpi_iomaps_lock must be held before calling */
static void __acpi_kref_del_iomap(struct kref *ref)
{
struct acpi_iomap *map;
map = container_of(ref, struct acpi_iomap, ref);
list_del_rcu(&map->list);
}
/*
* Used to post-unmap the specified IO memory area. The iounmap is
* done only if the reference count goes zero.
*/
static void acpi_post_unmap(phys_addr_t paddr, unsigned long size)
{
struct acpi_iomap *map;
unsigned long flags;
int del;
spin_lock_irqsave(&acpi_iomaps_lock, flags);
map = __acpi_find_iomap(paddr, size);
BUG_ON(!map);
del = kref_put(&map->ref, __acpi_kref_del_iomap);
spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
if (!del)
return;
synchronize_rcu();
iounmap(map->vaddr);
kfree(map);
}
/* In NMI handler, should set silent = 1 */
static int acpi_check_gar(struct acpi_generic_address *reg,
u64 *paddr, int silent)
{
u32 width, space_id;
width = reg->bit_width;
space_id = reg->space_id;
/* Handle possible alignment issues */
memcpy(paddr, &reg->address, sizeof(*paddr));
if (!*paddr) {
if (!silent)
pr_warning(FW_BUG ACPI_PFX
"Invalid physical address in GAR [0x%llx/%u/%u]\n",
*paddr, width, space_id);
return -EINVAL;
}
if ((width != 8) && (width != 16) && (width != 32) && (width != 64)) {
if (!silent)
pr_warning(FW_BUG ACPI_PFX
"Invalid bit width in GAR [0x%llx/%u/%u]\n",
*paddr, width, space_id);
return -EINVAL;
}
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
if (!silent)
pr_warning(FW_BUG ACPI_PFX
"Invalid address space type in GAR [0x%llx/%u/%u]\n",
*paddr, width, space_id);
return -EINVAL;
}
return 0;
}
/* Pre-map, working on GAR */
int acpi_pre_map_gar(struct acpi_generic_address *reg)
{
u64 paddr;
void __iomem *vaddr;
int rc;
if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return 0;
rc = acpi_check_gar(reg, &paddr, 0);
if (rc)
return rc;
vaddr = acpi_pre_map(paddr, reg->bit_width / 8);
if (!vaddr)
return -EIO;
return 0;
}
EXPORT_SYMBOL_GPL(acpi_pre_map_gar);
/* Post-unmap, working on GAR */
int acpi_post_unmap_gar(struct acpi_generic_address *reg)
{
u64 paddr;
int rc;
if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return 0;
rc = acpi_check_gar(reg, &paddr, 0);
if (rc)
return rc;
acpi_post_unmap(paddr, reg->bit_width / 8);
return 0;
}
EXPORT_SYMBOL_GPL(acpi_post_unmap_gar);
/*
* Can be used in atomic (including NMI) or process context. RCU read
* lock can only be released after the IO memory area accessing.
*/
static int acpi_atomic_read_mem(u64 paddr, u64 *val, u32 width)
{
void __iomem *addr;
rcu_read_lock();
addr = __acpi_ioremap_fast(paddr, width);
switch (width) {
case 8:
*val = readb(addr);
break;
case 16:
*val = readw(addr);
break;
case 32:
*val = readl(addr);
break;
case 64:
*val = readq(addr);
break;
default:
return -EINVAL;
}
rcu_read_unlock();
return 0;
}
static int acpi_atomic_write_mem(u64 paddr, u64 val, u32 width)
{
void __iomem *addr;
rcu_read_lock();
addr = __acpi_ioremap_fast(paddr, width);
switch (width) {
case 8:
writeb(val, addr);
break;
case 16:
writew(val, addr);
break;
case 32:
writel(val, addr);
break;
case 64:
writeq(val, addr);
break;
default:
return -EINVAL;
}
rcu_read_unlock();
return 0;
}
/* GAR accessing in atomic (including NMI) or process context */
int acpi_atomic_read(u64 *val, struct acpi_generic_address *reg)
{
u64 paddr;
int rc;
rc = acpi_check_gar(reg, &paddr, 1);
if (rc)
return rc;
*val = 0;
switch (reg->space_id) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
return acpi_atomic_read_mem(paddr, val, reg->bit_width);
case ACPI_ADR_SPACE_SYSTEM_IO:
return acpi_os_read_port(paddr, (u32 *)val, reg->bit_width);
default:
return -EINVAL;
}
}
EXPORT_SYMBOL_GPL(acpi_atomic_read);
int acpi_atomic_write(u64 val, struct acpi_generic_address *reg)
{
u64 paddr;
int rc;
rc = acpi_check_gar(reg, &paddr, 1);
if (rc)
return rc;
switch (reg->space_id) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
return acpi_atomic_write_mem(paddr, val, reg->bit_width);
case ACPI_ADR_SPACE_SYSTEM_IO:
return acpi_os_write_port(paddr, val, reg->bit_width);
default:
return -EINVAL;
}
}
EXPORT_SYMBOL_GPL(acpi_atomic_write);
...@@ -1027,10 +1027,9 @@ int __init acpi_ec_ecdt_probe(void) ...@@ -1027,10 +1027,9 @@ int __init acpi_ec_ecdt_probe(void)
/* Don't trust ECDT, which comes from ASUSTek */ /* Don't trust ECDT, which comes from ASUSTek */
if (!EC_FLAGS_VALIDATE_ECDT) if (!EC_FLAGS_VALIDATE_ECDT)
goto install; goto install;
saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); saved_ec = kmemdup(boot_ec, sizeof(struct acpi_ec), GFP_KERNEL);
if (!saved_ec) if (!saved_ec)
return -ENOMEM; return -ENOMEM;
memcpy(saved_ec, boot_ec, sizeof(struct acpi_ec));
/* fall through */ /* fall through */
} }
......
/*
* ACPI Hardware Error Device (PNP0C33) Driver
*
* Copyright (C) 2010, Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* ACPI Hardware Error Device is used to report some hardware errors
* notified via SCI, mainly the corrected errors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <acpi/hed.h>
static struct acpi_device_id acpi_hed_ids[] = {
{"PNP0C33", 0},
{"", 0},
};
MODULE_DEVICE_TABLE(acpi, acpi_hed_ids);
static acpi_handle hed_handle;
static BLOCKING_NOTIFIER_HEAD(acpi_hed_notify_list);
int register_acpi_hed_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&acpi_hed_notify_list, nb);
}
EXPORT_SYMBOL_GPL(register_acpi_hed_notifier);
void unregister_acpi_hed_notifier(struct notifier_block *nb)
{
blocking_notifier_chain_unregister(&acpi_hed_notify_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
/*
* SCI to report hardware error is forwarded to the listeners of HED,
* it is used by HEST Generic Hardware Error Source with notify type
* SCI.
*/
static void acpi_hed_notify(struct acpi_device *device, u32 event)
{
blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
}
static int __devinit acpi_hed_add(struct acpi_device *device)
{
/* Only one hardware error device */
if (hed_handle)
return -EINVAL;
hed_handle = device->handle;
return 0;
}
static int __devexit acpi_hed_remove(struct acpi_device *device, int type)
{
hed_handle = NULL;
return 0;
}
static struct acpi_driver acpi_hed_driver = {
.name = "hardware_error_device",
.class = "hardware_error",
.ids = acpi_hed_ids,
.ops = {
.add = acpi_hed_add,
.remove = acpi_hed_remove,
.notify = acpi_hed_notify,
},
};
static int __init acpi_hed_init(void)
{
if (acpi_disabled)
return -ENODEV;
if (acpi_bus_register_driver(&acpi_hed_driver) < 0)
return -ENODEV;
return 0;
}
static void __exit acpi_hed_exit(void)
{
acpi_bus_unregister_driver(&acpi_hed_driver);
}
module_init(acpi_hed_init);
module_exit(acpi_hed_exit);
ACPI_MODULE_NAME("hed");
MODULE_AUTHOR("Huang Ying");
MODULE_DESCRIPTION("ACPI Hardware Error Device Driver");
MODULE_LICENSE("GPL");
#include <linux/acpi.h>
#include <linux/pci.h>
#define PREFIX "ACPI: "
static inline unsigned long parse_acpi_hest_ia_machine_check(struct acpi_hest_ia_machine_check *p)
{
return sizeof(*p) +
(sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks);
}
static inline unsigned long parse_acpi_hest_ia_corrected(struct acpi_hest_ia_corrected *p)
{
return sizeof(*p) +
(sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks);
}
static inline unsigned long parse_acpi_hest_ia_nmi(struct acpi_hest_ia_nmi *p)
{
return sizeof(*p);
}
static inline unsigned long parse_acpi_hest_generic(struct acpi_hest_generic *p)
{
return sizeof(*p);
}
static inline unsigned int hest_match_pci(struct acpi_hest_aer_common *p, struct pci_dev *pci)
{
return (0 == pci_domain_nr(pci->bus) &&
p->bus == pci->bus->number &&
p->device == PCI_SLOT(pci->devfn) &&
p->function == PCI_FUNC(pci->devfn));
}
static unsigned long parse_acpi_hest_aer(void *hdr, int type, struct pci_dev *pci, int *firmware_first)
{
struct acpi_hest_aer_common *p = hdr + sizeof(struct acpi_hest_header);
unsigned long rc=0;
u8 pcie_type = 0;
u8 bridge = 0;
switch (type) {
case ACPI_HEST_TYPE_AER_ROOT_PORT:
rc = sizeof(struct acpi_hest_aer_root);
pcie_type = PCI_EXP_TYPE_ROOT_PORT;
break;
case ACPI_HEST_TYPE_AER_ENDPOINT:
rc = sizeof(struct acpi_hest_aer);
pcie_type = PCI_EXP_TYPE_ENDPOINT;
break;
case ACPI_HEST_TYPE_AER_BRIDGE:
rc = sizeof(struct acpi_hest_aer_bridge);
if ((pci->class >> 16) == PCI_BASE_CLASS_BRIDGE)
bridge = 1;
break;
}
if (p->flags & ACPI_HEST_GLOBAL) {
if ((pci->is_pcie && (pci->pcie_type == pcie_type)) || bridge)
*firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
}
else
if (hest_match_pci(p, pci))
*firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
return rc;
}
static int acpi_hest_firmware_first(struct acpi_table_header *stdheader, struct pci_dev *pci)
{
struct acpi_table_hest *hest = (struct acpi_table_hest *)stdheader;
void *p = (void *)hest + sizeof(*hest); /* defined by the ACPI 4.0 spec */
struct acpi_hest_header *hdr = p;
int i;
int firmware_first = 0;
static unsigned char printed_unused = 0;
static unsigned char printed_reserved = 0;
for (i=0, hdr=p; p < (((void *)hest) + hest->header.length) && i < hest->error_source_count; i++) {
switch (hdr->type) {
case ACPI_HEST_TYPE_IA32_CHECK:
p += parse_acpi_hest_ia_machine_check(p);
break;
case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
p += parse_acpi_hest_ia_corrected(p);
break;
case ACPI_HEST_TYPE_IA32_NMI:
p += parse_acpi_hest_ia_nmi(p);
break;
/* These three should never appear */
case ACPI_HEST_TYPE_NOT_USED3:
case ACPI_HEST_TYPE_NOT_USED4:
case ACPI_HEST_TYPE_NOT_USED5:
if (!printed_unused) {
printk(KERN_DEBUG PREFIX
"HEST Error Source list contains an obsolete type (%d).\n", hdr->type);
printed_unused = 1;
}
break;
case ACPI_HEST_TYPE_AER_ROOT_PORT:
case ACPI_HEST_TYPE_AER_ENDPOINT:
case ACPI_HEST_TYPE_AER_BRIDGE:
p += parse_acpi_hest_aer(p, hdr->type, pci, &firmware_first);
break;
case ACPI_HEST_TYPE_GENERIC_ERROR:
p += parse_acpi_hest_generic(p);
break;
/* These should never appear either */
case ACPI_HEST_TYPE_RESERVED:
default:
if (!printed_reserved) {
printk(KERN_DEBUG PREFIX
"HEST Error Source list contains a reserved type (%d).\n", hdr->type);
printed_reserved = 1;
}
break;
}
}
return firmware_first;
}
int acpi_hest_firmware_first_pci(struct pci_dev *pci)
{
acpi_status status = AE_NOT_FOUND;
struct acpi_table_header *hest = NULL;
if (acpi_disabled)
return 0;
status = acpi_get_table(ACPI_SIG_HEST, 1, &hest);
if (ACPI_SUCCESS(status)) {
if (acpi_hest_firmware_first(hest, pci)) {
return 1;
}
}
return 0;
}
EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci);
...@@ -120,7 +120,8 @@ acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) ...@@ -120,7 +120,8 @@ acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
struct acpi_pci_root *root; struct acpi_pci_root *root;
list_for_each_entry(root, &acpi_pci_roots, node) list_for_each_entry(root, &acpi_pci_roots, node)
if ((root->segment == (u16) seg) && (root->bus_nr == (u16) bus)) if ((root->segment == (u16) seg) &&
(root->secondary.start == (u16) bus))
return root->device->handle; return root->device->handle;
return NULL; return NULL;
} }
...@@ -154,7 +155,7 @@ EXPORT_SYMBOL_GPL(acpi_is_root_bridge); ...@@ -154,7 +155,7 @@ EXPORT_SYMBOL_GPL(acpi_is_root_bridge);
static acpi_status static acpi_status
get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
{ {
int *busnr = data; struct resource *res = data;
struct acpi_resource_address64 address; struct acpi_resource_address64 address;
if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
...@@ -164,28 +165,27 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) ...@@ -164,28 +165,27 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
acpi_resource_to_address64(resource, &address); acpi_resource_to_address64(resource, &address);
if ((address.address_length > 0) && if ((address.address_length > 0) &&
(address.resource_type == ACPI_BUS_NUMBER_RANGE)) (address.resource_type == ACPI_BUS_NUMBER_RANGE)) {
*busnr = address.minimum; res->start = address.minimum;
res->end = address.minimum + address.address_length - 1;
}
return AE_OK; return AE_OK;
} }
static acpi_status try_get_root_bridge_busnr(acpi_handle handle, static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
unsigned long long *bus) struct resource *res)
{ {
acpi_status status; acpi_status status;
int busnum;
busnum = -1; res->start = -1;
status = status =
acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_walk_resources(handle, METHOD_NAME__CRS,
get_root_bridge_busnr_callback, &busnum); get_root_bridge_busnr_callback, res);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return status; return status;
/* Check if we really get a bus number from _CRS */ if (res->start == -1)
if (busnum == -1)
return AE_ERROR; return AE_ERROR;
*bus = busnum;
return AE_OK; return AE_OK;
} }
...@@ -429,34 +429,47 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -429,34 +429,47 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
struct acpi_device *child; struct acpi_device *child;
u32 flags, base_flags; u32 flags, base_flags;
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root)
return -ENOMEM;
segment = 0; segment = 0;
status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL,
&segment); &segment);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
printk(KERN_ERR PREFIX "can't evaluate _SEG\n"); printk(KERN_ERR PREFIX "can't evaluate _SEG\n");
return -ENODEV; result = -ENODEV;
goto end;
} }
/* Check _CRS first, then _BBN. If no _BBN, default to zero. */ /* Check _CRS first, then _BBN. If no _BBN, default to zero. */
bus = 0; root->secondary.flags = IORESOURCE_BUS;
status = try_get_root_bridge_busnr(device->handle, &bus); status = try_get_root_bridge_busnr(device->handle, &root->secondary);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
/*
* We need both the start and end of the downstream bus range
* to interpret _CBA (MMCONFIG base address), so it really is
* supposed to be in _CRS. If we don't find it there, all we
* can do is assume [_BBN-0xFF] or [0-0xFF].
*/
root->secondary.end = 0xFF;
printk(KERN_WARNING FW_BUG PREFIX
"no secondary bus range in _CRS\n");
status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, &bus); status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, &bus);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { if (ACPI_SUCCESS(status))
printk(KERN_ERR PREFIX root->secondary.start = bus;
"no bus number in _CRS and can't evaluate _BBN\n"); else if (status == AE_NOT_FOUND)
return -ENODEV; root->secondary.start = 0;
else {
printk(KERN_ERR PREFIX "can't evaluate _BBN\n");
result = -ENODEV;
goto end;
} }
} }
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root)
return -ENOMEM;
INIT_LIST_HEAD(&root->node); INIT_LIST_HEAD(&root->node);
root->device = device; root->device = device;
root->segment = segment & 0xFFFF; root->segment = segment & 0xFFFF;
root->bus_nr = bus & 0xFF;
strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
device->driver_data = root; device->driver_data = root;
...@@ -475,9 +488,9 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -475,9 +488,9 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
/* TBD: Locking */ /* TBD: Locking */
list_add_tail(&root->node, &acpi_pci_roots); list_add_tail(&root->node, &acpi_pci_roots);
printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n", printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
acpi_device_name(device), acpi_device_bid(device), acpi_device_name(device), acpi_device_bid(device),
root->segment, root->bus_nr); root->segment, &root->secondary);
/* /*
* Scan the Root Bridge * Scan the Root Bridge
...@@ -486,11 +499,11 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -486,11 +499,11 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
* PCI namespace does not get created until this call is made (and * PCI namespace does not get created until this call is made (and
* thus the root bridge's pci_dev does not exist). * thus the root bridge's pci_dev does not exist).
*/ */
root->bus = pci_acpi_scan_root(device, segment, bus); root->bus = pci_acpi_scan_root(root);
if (!root->bus) { if (!root->bus) {
printk(KERN_ERR PREFIX printk(KERN_ERR PREFIX
"Bus %04x:%02x not present in PCI namespace\n", "Bus %04x:%02x not present in PCI namespace\n",
root->segment, root->bus_nr); root->segment, (unsigned int)root->secondary.start);
result = -ENODEV; result = -ENODEV;
goto end; goto end;
} }
......
...@@ -727,18 +727,8 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) ...@@ -727,18 +727,8 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
break; break;
} }
if (pr->power.states[i].promotion.state)
seq_printf(seq, "promotion[C%zd] ",
(pr->power.states[i].promotion.state -
pr->power.states));
else
seq_puts(seq, "promotion[--] "); seq_puts(seq, "promotion[--] ");
if (pr->power.states[i].demotion.state)
seq_printf(seq, "demotion[C%zd] ",
(pr->power.states[i].demotion.state -
pr->power.states));
else
seq_puts(seq, "demotion[--] "); seq_puts(seq, "demotion[--] ");
seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n", seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
...@@ -869,6 +859,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, ...@@ -869,6 +859,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
struct acpi_processor *pr; struct acpi_processor *pr;
struct acpi_processor_cx *cx = cpuidle_get_statedata(state); struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
ktime_t kt1, kt2; ktime_t kt1, kt2;
s64 idle_time_ns;
s64 idle_time; s64 idle_time;
s64 sleep_ticks = 0; s64 sleep_ticks = 0;
...@@ -910,12 +901,14 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, ...@@ -910,12 +901,14 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
sched_clock_idle_sleep_event(); sched_clock_idle_sleep_event();
acpi_idle_do_entry(cx); acpi_idle_do_entry(cx);
kt2 = ktime_get_real(); kt2 = ktime_get_real();
idle_time = ktime_to_us(ktime_sub(kt2, kt1)); idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1));
idle_time = idle_time_ns;
do_div(idle_time, NSEC_PER_USEC);
sleep_ticks = us_to_pm_timer_ticks(idle_time); sleep_ticks = us_to_pm_timer_ticks(idle_time);
/* Tell the scheduler how much we idled: */ /* Tell the scheduler how much we idled: */
sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); sched_clock_idle_wakeup_event(idle_time_ns);
local_irq_enable(); local_irq_enable();
current_thread_info()->status |= TS_POLLING; current_thread_info()->status |= TS_POLLING;
...@@ -943,6 +936,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, ...@@ -943,6 +936,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
struct acpi_processor *pr; struct acpi_processor *pr;
struct acpi_processor_cx *cx = cpuidle_get_statedata(state); struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
ktime_t kt1, kt2; ktime_t kt1, kt2;
s64 idle_time_ns;
s64 idle_time; s64 idle_time;
s64 sleep_ticks = 0; s64 sleep_ticks = 0;
...@@ -1025,11 +1019,13 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, ...@@ -1025,11 +1019,13 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
spin_unlock(&c3_lock); spin_unlock(&c3_lock);
} }
kt2 = ktime_get_real(); kt2 = ktime_get_real();
idle_time = ktime_to_us(ktime_sub(kt2, kt1)); idle_time_ns = ktime_to_us(ktime_sub(kt2, kt1));
idle_time = idle_time_ns;
do_div(idle_time, NSEC_PER_USEC);
sleep_ticks = us_to_pm_timer_ticks(idle_time); sleep_ticks = us_to_pm_timer_ticks(idle_time);
/* Tell the scheduler how much we idled: */ /* Tell the scheduler how much we idled: */
sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); sched_clock_idle_wakeup_event(idle_time_ns);
local_irq_enable(); local_irq_enable();
current_thread_info()->status |= TS_POLLING; current_thread_info()->status |= TS_POLLING;
......
...@@ -80,22 +80,6 @@ static int acpi_sleep_prepare(u32 acpi_state) ...@@ -80,22 +80,6 @@ static int acpi_sleep_prepare(u32 acpi_state)
#ifdef CONFIG_ACPI_SLEEP #ifdef CONFIG_ACPI_SLEEP
static u32 acpi_target_sleep_state = ACPI_STATE_S0; static u32 acpi_target_sleep_state = ACPI_STATE_S0;
/*
* According to the ACPI specification the BIOS should make sure that ACPI is
* enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
* some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
* on such systems during resume. Unfortunately that doesn't help in
* particularly pathological cases in which SCI_EN has to be set directly on
* resume, although the specification states very clearly that this flag is
* owned by the hardware. The set_sci_en_on_resume variable will be set in such
* cases.
*/
static bool set_sci_en_on_resume;
void __init acpi_set_sci_en_on_resume(void)
{
set_sci_en_on_resume = true;
}
/* /*
* ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
...@@ -253,11 +237,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state) ...@@ -253,11 +237,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
break; break;
} }
/* If ACPI is not enabled by the BIOS, we need to enable it here. */ /* This violates the spec but is required for bug compatibility. */
if (set_sci_en_on_resume)
acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
else
acpi_enable();
/* Reprogram control registers and execute _BFS */ /* Reprogram control registers and execute _BFS */
acpi_leave_sleep_state_prep(acpi_state); acpi_leave_sleep_state_prep(acpi_state);
...@@ -346,12 +327,6 @@ static int __init init_old_suspend_ordering(const struct dmi_system_id *d) ...@@ -346,12 +327,6 @@ static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
return 0; return 0;
} }
static int __init init_set_sci_en_on_resume(const struct dmi_system_id *d)
{
set_sci_en_on_resume = true;
return 0;
}
static struct dmi_system_id __initdata acpisleep_dmi_table[] = { static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
{ {
.callback = init_old_suspend_ordering, .callback = init_old_suspend_ordering,
...@@ -370,22 +345,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { ...@@ -370,22 +345,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
}, },
}, },
{ {
.callback = init_set_sci_en_on_resume,
.ident = "Apple MacBook 1,1",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Apple MacMini 1,1",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
},
},
{
.callback = init_old_suspend_ordering, .callback = init_old_suspend_ordering,
.ident = "Asus Pundit P1-AH2 (M2N8L motherboard)", .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
.matches = { .matches = {
...@@ -394,94 +353,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { ...@@ -394,94 +353,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
}, },
}, },
{ {
.callback = init_set_sci_en_on_resume,
.ident = "Toshiba Satellite L300",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard HP G7000 Notebook PC",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP G7000 Notebook PC"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard HP Pavilion dv3 Notebook PC",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv3 Notebook PC"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard Pavilion dv4",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard Pavilion dv7",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv7"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard Compaq Presario C700 Notebook PC",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "Compaq Presario C700 Notebook PC"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Hewlett-Packard Compaq Presario CQ40 Notebook PC",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "Compaq Presario CQ40 Notebook PC"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Lenovo ThinkPad T410",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T410"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Lenovo ThinkPad T510",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T510"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Lenovo ThinkPad W510",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W510"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Lenovo ThinkPad X201[s]",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201"),
},
},
{
.callback = init_old_suspend_ordering, .callback = init_old_suspend_ordering,
.ident = "Panasonic CF51-2L", .ident = "Panasonic CF51-2L",
.matches = { .matches = {
...@@ -490,30 +361,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { ...@@ -490,30 +361,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
}, },
}, },
{
.callback = init_set_sci_en_on_resume,
.ident = "Dell Studio 1558",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1558"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Dell Studio 1557",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1557"),
},
},
{
.callback = init_set_sci_en_on_resume,
.ident = "Dell Studio 1555",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1555"),
},
},
{}, {},
}; };
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */
......
extern u8 sleep_states[]; extern u8 sleep_states[];
extern int acpi_suspend (u32 state); extern int acpi_suspend(u32 state);
extern void acpi_enable_wakeup_device_prep(u8 sleep_state); extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state); extern void acpi_enable_wakeup_device(u8 sleep_state);
......
...@@ -213,7 +213,7 @@ acpi_table_parse_entries(char *id, ...@@ -213,7 +213,7 @@ acpi_table_parse_entries(char *id,
unsigned long table_end; unsigned long table_end;
acpi_size tbl_size; acpi_size tbl_size;
if (acpi_disabled && !acpi_ht) if (acpi_disabled)
return -ENODEV; return -ENODEV;
if (!handler) if (!handler)
...@@ -280,7 +280,7 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler) ...@@ -280,7 +280,7 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler)
struct acpi_table_header *table = NULL; struct acpi_table_header *table = NULL;
acpi_size tbl_size; acpi_size tbl_size;
if (acpi_disabled && !acpi_ht) if (acpi_disabled)
return -ENODEV; return -ENODEV;
if (!handler) if (!handler)
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <acpi/video.h>
#define PREFIX "ACPI: " #define PREFIX "ACPI: "
...@@ -65,11 +66,6 @@ ...@@ -65,11 +66,6 @@
#define MAX_NAME_LEN 20 #define MAX_NAME_LEN 20
#define ACPI_VIDEO_DISPLAY_CRT 1
#define ACPI_VIDEO_DISPLAY_TV 2
#define ACPI_VIDEO_DISPLAY_DVI 3
#define ACPI_VIDEO_DISPLAY_LCD 4
#define _COMPONENT ACPI_VIDEO_COMPONENT #define _COMPONENT ACPI_VIDEO_COMPONENT
ACPI_MODULE_NAME("video"); ACPI_MODULE_NAME("video");
...@@ -1007,11 +1003,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) ...@@ -1007,11 +1003,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
result = acpi_video_init_brightness(device); result = acpi_video_init_brightness(device);
if (result) if (result)
return; return;
name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
if (!name) if (!name)
return; return;
count++;
sprintf(name, "acpi_video%d", count++);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = device->brightness->count - 3; props.max_brightness = device->brightness->count - 3;
device->backlight = backlight_device_register(name, NULL, device, device->backlight = backlight_device_register(name, NULL, device,
...@@ -1067,10 +1063,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) ...@@ -1067,10 +1063,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
if (device->cap._DCS && device->cap._DSS) { if (device->cap._DCS && device->cap._DSS) {
static int count; static int count;
char *name; char *name;
name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
if (!name) if (!name)
return; return;
sprintf(name, "acpi_video%d", count++); count++;
device->output_dev = video_output_register(name, device->output_dev = video_output_register(name,
NULL, device, &acpi_output_properties); NULL, device, &acpi_output_properties);
kfree(name); kfree(name);
...@@ -1747,12 +1743,28 @@ acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id ...@@ -1747,12 +1743,28 @@ acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id
return NULL; return NULL;
} }
static int
acpi_video_get_device_type(struct acpi_video_bus *video,
unsigned long device_id)
{
struct acpi_video_enumerated_device *ids;
int i;
for (i = 0; i < video->attached_count; i++) {
ids = &video->attached_array[i];
if ((ids->value.int_val & 0xffff) == device_id)
return ids->value.int_val;
}
return 0;
}
static int static int
acpi_video_bus_get_one_device(struct acpi_device *device, acpi_video_bus_get_one_device(struct acpi_device *device,
struct acpi_video_bus *video) struct acpi_video_bus *video)
{ {
unsigned long long device_id; unsigned long long device_id;
int status; int status, device_type;
struct acpi_video_device *data; struct acpi_video_device *data;
struct acpi_video_device_attrib* attribute; struct acpi_video_device_attrib* attribute;
...@@ -1797,8 +1809,25 @@ acpi_video_bus_get_one_device(struct acpi_device *device, ...@@ -1797,8 +1809,25 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
} }
if(attribute->bios_can_detect) if(attribute->bios_can_detect)
data->flags.bios = 1; data->flags.bios = 1;
} else } else {
/* Check for legacy IDs */
device_type = acpi_video_get_device_type(video,
device_id);
/* Ignore bits 16 and 18-20 */
switch (device_type & 0xffe2ffff) {
case ACPI_VIDEO_DISPLAY_LEGACY_MONITOR:
data->flags.crt = 1;
break;
case ACPI_VIDEO_DISPLAY_LEGACY_PANEL:
data->flags.lcd = 1;
break;
case ACPI_VIDEO_DISPLAY_LEGACY_TV:
data->flags.tvout = 1;
break;
default:
data->flags.unknown = 1; data->flags.unknown = 1;
}
}
acpi_video_device_bind(video, data); acpi_video_device_bind(video, data);
acpi_video_device_find_cap(data); acpi_video_device_find_cap(data);
...@@ -2032,6 +2061,71 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) ...@@ -2032,6 +2061,71 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
return result; return result;
} }
int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
void **edid)
{
struct acpi_video_bus *video;
struct acpi_video_device *video_device;
union acpi_object *buffer = NULL;
acpi_status status;
int i, length;
if (!device || !acpi_driver_data(device))
return -EINVAL;
video = acpi_driver_data(device);
for (i = 0; i < video->attached_count; i++) {
video_device = video->attached_array[i].bind_info;
length = 256;
if (!video_device)
continue;
if (type) {
switch (type) {
case ACPI_VIDEO_DISPLAY_CRT:
if (!video_device->flags.crt)
continue;
break;
case ACPI_VIDEO_DISPLAY_TV:
if (!video_device->flags.tvout)
continue;
break;
case ACPI_VIDEO_DISPLAY_DVI:
if (!video_device->flags.dvi)
continue;
break;
case ACPI_VIDEO_DISPLAY_LCD:
if (!video_device->flags.lcd)
continue;
break;
}
} else if (video_device->device_id != device_id) {
continue;
}
status = acpi_video_device_EDID(video_device, &buffer, length);
if (ACPI_FAILURE(status) || !buffer ||
buffer->type != ACPI_TYPE_BUFFER) {
length = 128;
status = acpi_video_device_EDID(video_device, &buffer,
length);
if (ACPI_FAILURE(status) || !buffer ||
buffer->type != ACPI_TYPE_BUFFER) {
continue;
}
}
*edid = buffer->buffer.pointer;
return length;
}
return -ENODEV;
}
EXPORT_SYMBOL(acpi_video_get_edid);
static int static int
acpi_video_bus_get_devices(struct acpi_video_bus *video, acpi_video_bus_get_devices(struct acpi_video_bus *video,
struct acpi_device *device) struct acpi_device *device)
......
...@@ -250,7 +250,7 @@ static int __init acpi_backlight(char *str) ...@@ -250,7 +250,7 @@ static int __init acpi_backlight(char *str)
ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR;
if (!strcmp("video", str)) if (!strcmp("video", str))
acpi_video_support |= acpi_video_support |=
ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO; ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO;
} }
return 1; return 1;
} }
......
...@@ -130,4 +130,21 @@ static inline int aer_osc_setup(struct pcie_device *pciedev) ...@@ -130,4 +130,21 @@ static inline int aer_osc_setup(struct pcie_device *pciedev)
} }
#endif #endif
#ifdef CONFIG_ACPI_APEI
extern int pcie_aer_get_firmware_first(struct pci_dev *pci_dev);
#else
static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev)
{
if (pci_dev->__aer_firmware_first_valid)
return pci_dev->__aer_firmware_first;
return 0;
}
#endif
static inline void pcie_aer_force_firmware_first(struct pci_dev *pci_dev,
int enable)
{
pci_dev->__aer_firmware_first = !!enable;
pci_dev->__aer_firmware_first_valid = 1;
}
#endif /* _AERDRV_H_ */ #endif /* _AERDRV_H_ */
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/pci-acpi.h> #include <linux/pci-acpi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <acpi/apei.h>
#include "aerdrv.h" #include "aerdrv.h"
/** /**
...@@ -53,3 +54,79 @@ int aer_osc_setup(struct pcie_device *pciedev) ...@@ -53,3 +54,79 @@ int aer_osc_setup(struct pcie_device *pciedev)
return 0; return 0;
} }
#ifdef CONFIG_ACPI_APEI
static inline int hest_match_pci(struct acpi_hest_aer_common *p,
struct pci_dev *pci)
{
return (0 == pci_domain_nr(pci->bus) &&
p->bus == pci->bus->number &&
p->device == PCI_SLOT(pci->devfn) &&
p->function == PCI_FUNC(pci->devfn));
}
struct aer_hest_parse_info {
struct pci_dev *pci_dev;
int firmware_first;
};
static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
{
struct aer_hest_parse_info *info = data;
struct acpi_hest_aer_common *p;
u8 pcie_type = 0;
u8 bridge = 0;
int ff = 0;
switch (hest_hdr->type) {
case ACPI_HEST_TYPE_AER_ROOT_PORT:
pcie_type = PCI_EXP_TYPE_ROOT_PORT;
break;
case ACPI_HEST_TYPE_AER_ENDPOINT:
pcie_type = PCI_EXP_TYPE_ENDPOINT;
break;
case ACPI_HEST_TYPE_AER_BRIDGE:
if ((info->pci_dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
bridge = 1;
break;
default:
return 0;
}
p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
if (p->flags & ACPI_HEST_GLOBAL) {
if ((info->pci_dev->is_pcie &&
info->pci_dev->pcie_type == pcie_type) || bridge)
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
} else
if (hest_match_pci(p, info->pci_dev))
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
info->firmware_first = ff;
return 0;
}
static void aer_set_firmware_first(struct pci_dev *pci_dev)
{
int rc;
struct aer_hest_parse_info info = {
.pci_dev = pci_dev,
.firmware_first = 0,
};
rc = apei_hest_parse(aer_hest_parse, &info);
if (rc)
pci_dev->__aer_firmware_first = 0;
else
pci_dev->__aer_firmware_first = info.firmware_first;
pci_dev->__aer_firmware_first_valid = 1;
}
int pcie_aer_get_firmware_first(struct pci_dev *dev)
{
if (!dev->__aer_firmware_first_valid)
aer_set_firmware_first(dev);
return dev->__aer_firmware_first;
}
#endif
...@@ -36,7 +36,7 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev) ...@@ -36,7 +36,7 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev)
u16 reg16 = 0; u16 reg16 = 0;
int pos; int pos;
if (dev->aer_firmware_first) if (pcie_aer_get_firmware_first(dev))
return -EIO; return -EIO;
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
...@@ -63,7 +63,7 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev) ...@@ -63,7 +63,7 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev)
u16 reg16 = 0; u16 reg16 = 0;
int pos; int pos;
if (dev->aer_firmware_first) if (pcie_aer_get_firmware_first(dev))
return -EIO; return -EIO;
pos = pci_pcie_cap(dev); pos = pci_pcie_cap(dev);
...@@ -771,7 +771,7 @@ void aer_isr(struct work_struct *work) ...@@ -771,7 +771,7 @@ void aer_isr(struct work_struct *work)
*/ */
int aer_init(struct pcie_device *dev) int aer_init(struct pcie_device *dev)
{ {
if (dev->port->aer_firmware_first) { if (pcie_aer_get_firmware_first(dev->port)) {
dev_printk(KERN_DEBUG, &dev->device, dev_printk(KERN_DEBUG, &dev->device,
"PCIe errors handled by platform firmware.\n"); "PCIe errors handled by platform firmware.\n");
goto out; goto out;
...@@ -785,7 +785,7 @@ int aer_init(struct pcie_device *dev) ...@@ -785,7 +785,7 @@ int aer_init(struct pcie_device *dev)
if (forceload) { if (forceload) {
dev_printk(KERN_DEBUG, &dev->device, dev_printk(KERN_DEBUG, &dev->device,
"aerdrv forceload requested.\n"); "aerdrv forceload requested.\n");
dev->port->aer_firmware_first = 0; pcie_aer_force_firmware_first(dev->port, 0);
return 0; return 0;
} }
return -ENXIO; return -ENXIO;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/pci-aspm.h> #include <linux/pci-aspm.h>
#include <acpi/acpi_hest.h>
#include "pci.h" #include "pci.h"
#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
...@@ -904,12 +903,6 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev) ...@@ -904,12 +903,6 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
pdev->is_hotplug_bridge = 1; pdev->is_hotplug_bridge = 1;
} }
static void set_pci_aer_firmware_first(struct pci_dev *pdev)
{
if (acpi_hest_firmware_first_pci(pdev))
pdev->aer_firmware_first = 1;
}
#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
/** /**
...@@ -939,7 +932,6 @@ int pci_setup_device(struct pci_dev *dev) ...@@ -939,7 +932,6 @@ int pci_setup_device(struct pci_dev *dev)
dev->multifunction = !!(hdr_type & 0x80); dev->multifunction = !!(hdr_type & 0x80);
dev->error_state = pci_channel_io_normal; dev->error_state = pci_channel_io_normal;
set_pcie_port_type(dev); set_pcie_port_type(dev);
set_pci_aer_firmware_first(dev);
list_for_each_entry(slot, &dev->bus->slots, list) list_for_each_entry(slot, &dev->bus->slots, list)
if (PCI_SLOT(dev->devfn) == slot->number) if (PCI_SLOT(dev->devfn) == slot->number)
......
...@@ -277,8 +277,10 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_x32, debugfs_u32_get, debugfs_u32_set, "0x%08llx\n" ...@@ -277,8 +277,10 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_x32, debugfs_u32_get, debugfs_u32_set, "0x%08llx\n"
DEFINE_SIMPLE_ATTRIBUTE(fops_x32_ro, debugfs_u32_get, NULL, "0x%08llx\n"); DEFINE_SIMPLE_ATTRIBUTE(fops_x32_ro, debugfs_u32_get, NULL, "0x%08llx\n");
DEFINE_SIMPLE_ATTRIBUTE(fops_x32_wo, NULL, debugfs_u32_set, "0x%08llx\n"); DEFINE_SIMPLE_ATTRIBUTE(fops_x32_wo, NULL, debugfs_u32_set, "0x%08llx\n");
DEFINE_SIMPLE_ATTRIBUTE(fops_x64, debugfs_u64_get, debugfs_u64_set, "0x%016llx\n");
/* /*
* debugfs_create_x{8,16,32} - create a debugfs file that is used to read and write an unsigned {8,16,32}-bit value * debugfs_create_x{8,16,32,64} - create a debugfs file that is used to read and write an unsigned {8,16,32,64}-bit value
* *
* These functions are exactly the same as the above functions (but use a hex * These functions are exactly the same as the above functions (but use a hex
* output for the decimal challenged). For details look at the above unsigned * output for the decimal challenged). For details look at the above unsigned
...@@ -357,6 +359,23 @@ struct dentry *debugfs_create_x32(const char *name, mode_t mode, ...@@ -357,6 +359,23 @@ struct dentry *debugfs_create_x32(const char *name, mode_t mode,
} }
EXPORT_SYMBOL_GPL(debugfs_create_x32); EXPORT_SYMBOL_GPL(debugfs_create_x32);
/**
* debugfs_create_x64 - create a debugfs file that is used to read and write an unsigned 64-bit value
* @name: a pointer to a string containing the name of the file to create.
* @mode: the permission that the file should have
* @parent: a pointer to the parent dentry for this file. This should be a
* directory dentry if set. If this parameter is %NULL, then the
* file will be created in the root of the debugfs filesystem.
* @value: a pointer to the variable that the file should read to and write
* from.
*/
struct dentry *debugfs_create_x64(const char *name, mode_t mode,
struct dentry *parent, u64 *value)
{
return debugfs_create_file(name, mode, parent, value, &fops_x64);
}
EXPORT_SYMBOL_GPL(debugfs_create_x64);
static int debugfs_size_t_set(void *data, u64 val) static int debugfs_size_t_set(void *data, u64 val)
{ {
......
...@@ -373,7 +373,7 @@ struct acpi_pci_root { ...@@ -373,7 +373,7 @@ struct acpi_pci_root {
struct acpi_pci_id id; struct acpi_pci_id id;
struct pci_bus *bus; struct pci_bus *bus;
u16 segment; u16 segment;
u8 bus_nr; struct resource secondary; /* downstream bus range */
u32 osc_support_set; /* _OSC state of support bits */ u32 osc_support_set; /* _OSC state of support bits */
u32 osc_control_set; /* _OSC state of control bits */ u32 osc_control_set; /* _OSC state of control bits */
......
...@@ -104,8 +104,7 @@ int acpi_pci_bind_root(struct acpi_device *device); ...@@ -104,8 +104,7 @@ int acpi_pci_bind_root(struct acpi_device *device);
/* Arch-defined function to add a bus to the system */ /* Arch-defined function to add a bus to the system */
struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root);
int bus);
void pci_acpi_crs_quirks(void); void pci_acpi_crs_quirks(void);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
......
#ifndef __ACPI_HEST_H
#define __ACPI_HEST_H
#include <linux/pci.h>
#ifdef CONFIG_ACPI
extern int acpi_hest_firmware_first_pci(struct pci_dev *pci);
#else
static inline int acpi_hest_firmware_first_pci(struct pci_dev *pci) { return 0; }
#endif
#endif
/*
* apei.h - ACPI Platform Error Interface
*/
#ifndef ACPI_APEI_H
#define ACPI_APEI_H
#include <linux/acpi.h>
#include <linux/cper.h>
#include <asm/ioctls.h>
#define APEI_ERST_INVALID_RECORD_ID 0xffffffffffffffffULL
#define APEI_ERST_CLEAR_RECORD _IOW('E', 1, u64)
#define APEI_ERST_GET_RECORD_COUNT _IOR('E', 2, u32)
#ifdef __KERNEL__
extern int hest_disable;
extern int erst_disable;
typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data);
int apei_hest_parse(apei_hest_func_t func, void *data);
int erst_write(const struct cper_record_header *record);
ssize_t erst_get_record_count(void);
int erst_get_next_record_id(u64 *record_id);
ssize_t erst_read(u64 record_id, struct cper_record_header *record,
size_t buflen);
ssize_t erst_read_next(struct cper_record_header *record, size_t buflen);
int erst_clear(u64 record_id);
#endif
#endif
#ifndef ACPI_ATOMIC_IO_H
#define ACPI_ATOMIC_IO_H
int acpi_pre_map_gar(struct acpi_generic_address *reg);
int acpi_post_unmap_gar(struct acpi_generic_address *reg);
int acpi_atomic_read(u64 *val, struct acpi_generic_address *reg);
int acpi_atomic_write(u64 val, struct acpi_generic_address *reg);
#endif
/*
* hed.h - ACPI Hardware Error Device
*
* Copyright (C) 2009, Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* This file is released under the GPLv2.
*/
#ifndef ACPI_HED_H
#define ACPI_HED_H
#include <linux/notifier.h>
int register_acpi_hed_notifier(struct notifier_block *nb);
void unregister_acpi_hed_notifier(struct notifier_block *nb);
#endif
This diff is collapsed.
This diff is collapsed.
...@@ -254,7 +254,6 @@ int acpi_resources_are_enforced(void); ...@@ -254,7 +254,6 @@ int acpi_resources_are_enforced(void);
void __init acpi_no_s4_hw_signature(void); void __init acpi_no_s4_hw_signature(void);
void __init acpi_old_suspend_ordering(void); void __init acpi_old_suspend_ordering(void);
void __init acpi_s4_no_nvs(void); void __init acpi_s4_no_nvs(void);
void __init acpi_set_sci_en_on_resume(void);
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
struct acpi_osc_context { struct acpi_osc_context {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment