Skip to content

Commit

Permalink
Merge branches 'acpi-processor', 'acpi-cppc', 'acpi-apei' and 'acpi-s…
Browse files Browse the repository at this point in the history
…leep'

* acpi-processor:
  ACPI: enable ACPI_PROCESSOR_IDLE on ARM64
  arm64: add support for ACPI Low Power Idle(LPI)
  drivers: firmware: psci: initialise idle states using ACPI LPI
  cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32, 64}
  arm64: cpuidle: drop __init section marker to arm_cpuidle_init
  ACPI / processor_idle: Add support for Low Power Idle(LPI) states
  ACPI / processor_idle: introduce ACPI_PROCESSOR_CSTATE

* acpi-cppc:
  mailbox: pcc: Add PCC request and free channel declarations
  ACPI / CPPC: Prevent cpc_desc_ptr points to the invalid data
  ACPI: CPPC: Return error if _CPC is invalid on a CPU

* acpi-apei:
  ACPI / APEI: Add Boot Error Record Table (BERT) support
  ACPI / einj: Make error paths more talkative
  ACPI / einj: Convert EINJ_PFX to proper pr_fmt

* acpi-sleep:
  ACPI: Execute _PTS before system reboot
  • Loading branch information
Rafael J. Wysocki committed Jul 25, 2016
5 parents f6bc0a1 + 8fc85c6 + 866ae69 + a3e2acc + 2c85025 commit 6149dff
Show file tree
Hide file tree
Showing 19 changed files with 868 additions and 159 deletions.
3 changes: 3 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.

bootmem_debug [KNL] Enable bootmem allocator debug messages.

bert_disable [ACPI]
Disable BERT OS support on buggy BIOSes.

bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
bttv.radio= Most important insmod options are available as
kernel args too.
Expand Down
20 changes: 19 additions & 1 deletion arch/arm64/kernel/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
* published by the Free Software Foundation.
*/

#include <linux/acpi.h>
#include <linux/cpuidle.h>
#include <linux/cpu_pm.h>
#include <linux/of.h>
#include <linux/of_device.h>

#include <asm/cpuidle.h>
#include <asm/cpu_ops.h>

int __init arm_cpuidle_init(unsigned int cpu)
int arm_cpuidle_init(unsigned int cpu)
{
int ret = -EOPNOTSUPP;

Expand All @@ -39,3 +42,18 @@ int arm_cpuidle_suspend(int index)

return cpu_ops[cpu]->cpu_suspend(index);
}

#ifdef CONFIG_ACPI

#include <acpi/processor.h>

int acpi_processor_ffh_lpi_probe(unsigned int cpu)
{
return arm_cpuidle_init(cpu);
}

int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
{
return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
}
#endif
6 changes: 5 additions & 1 deletion drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ config ACPI_CPU_FREQ_PSS
bool
select THERMAL

config ACPI_PROCESSOR_CSTATE
def_bool y
depends on IA64 || X86

config ACPI_PROCESSOR_IDLE
bool
select CPU_IDLE
Expand All @@ -234,7 +238,7 @@ config ACPI_CPPC_LIB
config ACPI_PROCESSOR
tristate "Processor"
depends on X86 || IA64 || ARM64
select ACPI_PROCESSOR_IDLE if X86 || IA64
select ACPI_PROCESSOR_IDLE
select ACPI_CPU_FREQ_PSS if X86 || IA64
default y
help
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/apei/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o

apei-y := apei-base.o hest.o erst.o
apei-y := apei-base.o hest.o erst.o bert.o
2 changes: 1 addition & 1 deletion drivers/acpi/apei/apei-internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* apei-internal.h - ACPI Platform Error Interface internal
* definations.
* definitions.
*/

#ifndef APEI_INTERNAL_H
Expand Down
150 changes: 150 additions & 0 deletions drivers/acpi/apei/bert.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* APEI Boot Error Record Table (BERT) support
*
* Copyright 2011 Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* Under normal circumstances, when a hardware error occurs, the error
* handler receives control and processes the error. This gives OSPM a
* chance to process the error condition, report it, and optionally attempt
* recovery. In some cases, the system is unable to process an error.
* For example, system firmware or a management controller may choose to
* reset the system or the system might experience an uncontrolled crash
* or reset.The boot error source is used to report unhandled errors that
* occurred in a previous boot. This mechanism is described in the BERT
* table.
*
* For more information about BERT, please refer to ACPI Specification
* version 4.0, section 17.3.1
*
* This file is licensed under GPLv2.
*
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/io.h>

#include "apei-internal.h"

#undef pr_fmt
#define pr_fmt(fmt) "BERT: " fmt

static int bert_disable;

static void __init bert_print_all(struct acpi_bert_region *region,
unsigned int region_len)
{
struct acpi_hest_generic_status *estatus =
(struct acpi_hest_generic_status *)region;
int remain = region_len;
u32 estatus_len;

if (!estatus->block_status)
return;

while (remain > sizeof(struct acpi_bert_region)) {
if (cper_estatus_check(estatus)) {
pr_err(FW_BUG "Invalid error record.\n");
return;
}

estatus_len = cper_estatus_len(estatus);
if (remain < estatus_len) {
pr_err(FW_BUG "Truncated status block (length: %u).\n",
estatus_len);
return;
}

pr_info_once("Error records from previous boot:\n");

cper_estatus_print(KERN_INFO HW_ERR, estatus);

/*
* Because the boot error source is "one-time polled" type,
* clear Block Status of current Generic Error Status Block,
* once it's printed.
*/
estatus->block_status = 0;

estatus = (void *)estatus + estatus_len;
/* No more error records. */
if (!estatus->block_status)
return;

remain -= estatus_len;
}
}

static int __init setup_bert_disable(char *str)
{
bert_disable = 1;

return 0;
}
__setup("bert_disable", setup_bert_disable);

static int __init bert_check_table(struct acpi_table_bert *bert_tab)
{
if (bert_tab->header.length < sizeof(struct acpi_table_bert) ||
bert_tab->region_length < sizeof(struct acpi_bert_region))
return -EINVAL;

return 0;
}

static int __init bert_init(void)
{
struct acpi_bert_region *boot_error_region;
struct acpi_table_bert *bert_tab;
unsigned int region_len;
acpi_status status;
int rc = 0;

if (acpi_disabled)
return 0;

if (bert_disable) {
pr_info("Boot Error Record Table support is disabled.\n");
return 0;
}

status = acpi_get_table(ACPI_SIG_BERT, 0, (struct acpi_table_header **)&bert_tab);
if (status == AE_NOT_FOUND)
return 0;

if (ACPI_FAILURE(status)) {
pr_err("get table failed, %s.\n", acpi_format_exception(status));
return -EINVAL;
}

rc = bert_check_table(bert_tab);
if (rc) {
pr_err(FW_BUG "table invalid.\n");
return rc;
}

region_len = bert_tab->region_length;
if (!request_mem_region(bert_tab->address, region_len, "APEI BERT")) {
pr_err("Can't request iomem region <%016llx-%016llx>.\n",
(unsigned long long)bert_tab->address,
(unsigned long long)bert_tab->address + region_len - 1);
return -EIO;
}

boot_error_region = ioremap_cache(bert_tab->address, region_len);
if (boot_error_region) {
bert_print_all(boot_error_region, region_len);
iounmap(boot_error_region);
} else {
rc = -ENOMEM;
}

release_mem_region(bert_tab->address, region_len);

return rc;
}

late_initcall(bert_init);
57 changes: 36 additions & 21 deletions drivers/acpi/apei/einj.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

#include "apei-internal.h"

#define EINJ_PFX "EINJ: "
#undef pr_fmt
#define pr_fmt(fmt) "EINJ: " fmt

#define SPIN_UNIT 100 /* 100ns */
/* Firmware should respond within 1 milliseconds */
Expand Down Expand Up @@ -179,8 +180,7 @@ static int einj_get_available_error_type(u32 *type)
static int einj_timedout(u64 *t)
{
if ((s64)*t < SPIN_UNIT) {
pr_warning(FW_WARN EINJ_PFX
"Firmware does not respond in time\n");
pr_warning(FW_WARN "Firmware does not respond in time\n");
return 1;
}
*t -= SPIN_UNIT;
Expand Down Expand Up @@ -307,22 +307,20 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
"APEI EINJ Trigger Table");
if (!r) {
pr_err(EINJ_PFX
"Can not request [mem %#010llx-%#010llx] for Trigger table\n",
pr_err("Can not request [mem %#010llx-%#010llx] for Trigger table\n",
(unsigned long long)trigger_paddr,
(unsigned long long)trigger_paddr +
sizeof(*trigger_tab) - 1);
goto out;
}
trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
if (!trigger_tab) {
pr_err(EINJ_PFX "Failed to map trigger table!\n");
pr_err("Failed to map trigger table!\n");
goto out_rel_header;
}
rc = einj_check_trigger_header(trigger_tab);
if (rc) {
pr_warning(FW_BUG EINJ_PFX
"The trigger error action table is invalid\n");
pr_warning(FW_BUG "Invalid trigger error action table.\n");
goto out_rel_header;
}

Expand All @@ -336,16 +334,15 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
table_size - sizeof(*trigger_tab),
"APEI EINJ Trigger Table");
if (!r) {
pr_err(EINJ_PFX
"Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
pr_err("Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
(unsigned long long)trigger_paddr + sizeof(*trigger_tab),
(unsigned long long)trigger_paddr + table_size - 1);
goto out_rel_header;
}
iounmap(trigger_tab);
trigger_tab = ioremap_cache(trigger_paddr, table_size);
if (!trigger_tab) {
pr_err(EINJ_PFX "Failed to map trigger table!\n");
pr_err("Failed to map trigger table!\n");
goto out_rel_entry;
}
trigger_entry = (struct acpi_whea_header *)
Expand Down Expand Up @@ -695,34 +692,42 @@ static int __init einj_init(void)
struct dentry *fentry;
struct apei_exec_context ctx;

if (acpi_disabled)
if (acpi_disabled) {
pr_warn("ACPI disabled.\n");
return -ENODEV;
}

status = acpi_get_table(ACPI_SIG_EINJ, 0,
(struct acpi_table_header **)&einj_tab);
if (status == AE_NOT_FOUND)
if (status == AE_NOT_FOUND) {
pr_warn("EINJ table not found.\n");
return -ENODEV;
}
else if (ACPI_FAILURE(status)) {
const char *msg = acpi_format_exception(status);
pr_err(EINJ_PFX "Failed to get table, %s\n", msg);
pr_err("Failed to get EINJ table: %s\n",
acpi_format_exception(status));
return -EINVAL;
}

rc = einj_check_table(einj_tab);
if (rc) {
pr_warning(FW_BUG EINJ_PFX "EINJ table is invalid\n");
pr_warn(FW_BUG "Invalid EINJ table.n");
return -EINVAL;
}

rc = -ENOMEM;
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
if (!einj_debug_dir)
if (!einj_debug_dir) {
pr_err("Error creating debugfs node.\n");
goto err_cleanup;
}

fentry = debugfs_create_file("available_error_type", S_IRUSR,
einj_debug_dir, NULL,
&available_error_type_fops);
if (!fentry)
goto err_cleanup;

fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
einj_debug_dir, NULL, &error_type_fops);
if (!fentry)
Expand All @@ -735,14 +740,22 @@ static int __init einj_init(void)
apei_resources_init(&einj_resources);
einj_exec_ctx_init(&ctx);
rc = apei_exec_collect_resources(&ctx, &einj_resources);
if (rc)
if (rc) {
pr_err("Error collecting EINJ resources.\n");
goto err_fini;
}

rc = apei_resources_request(&einj_resources, "APEI EINJ");
if (rc)
if (rc) {
pr_err("Error requesting memory/port resources.\n");
goto err_fini;
}

rc = apei_exec_pre_map_gars(&ctx);
if (rc)
if (rc) {
pr_err("Error pre-mapping GARs.\n");
goto err_release;
}

rc = -ENOMEM;
einj_param = einj_get_parameter_address();
Expand Down Expand Up @@ -787,7 +800,7 @@ static int __init einj_init(void)
goto err_unmap;
}

pr_info(EINJ_PFX "Error INJection is initialized.\n");
pr_info("Error INJection is initialized.\n");

return 0;

Expand All @@ -798,13 +811,15 @@ static int __init einj_init(void)
sizeof(struct einj_parameter);

acpi_os_unmap_iomem(einj_param, size);
pr_err("Error creating param extension debugfs nodes.\n");
}
apei_exec_post_unmap_gars(&ctx);
err_release:
apei_resources_release(&einj_resources);
err_fini:
apei_resources_fini(&einj_resources);
err_cleanup:
pr_err("Error creating primary debugfs nodes.\n");
debugfs_remove_recursive(einj_debug_dir);

return rc;
Expand Down
Loading

0 comments on commit 6149dff

Please sign in to comment.