From d9b72fae2617c38c4ddd308099d0b966837573c7 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 29 Sep 2003 04:32:13 -0400 Subject: [PATCH] [ACPI] CONFIG_ACPI_RELAXED_AML from 2.4 http://bugzilla.kernel.org/show_bug.cgi?id=1248 --- drivers/acpi/Kconfig | 12 +++++++++++ drivers/acpi/executer/exfldio.c | 36 ++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf141ce31d4f..59710a1227fe1 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -281,5 +281,17 @@ config ACPI_EFI depends on IA64 default y +config ACPI_RELAXED_AML + bool + depends on ACPI_INTERPRETER + depends on !IA64_SGI_SN + default n + help + If you say `Y' here, the ACPI interpreter will relax its checking + for valid AML and will ignore some AML mistakes, such as off-by-one + errors in region sizes. Some laptops may require this option. In + particular, many Toshiba laptops require this for correct operation + of the AC module. + endmenu diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c index e3173033472e5..7370bb7c71455 100644 --- a/drivers/acpi/executer/exfldio.c +++ b/drivers/acpi/executer/exfldio.c @@ -139,7 +139,41 @@ acpi_ex_setup_region ( field_datum_byte_offset, obj_desc->common_field.access_byte_width, rgn_desc->region.node->name.ascii, rgn_desc->region.length)); - return_ACPI_STATUS (AE_AML_REGION_LIMIT); + #ifdef CONFIG_ACPI_RELAXED_AML + { + /* + * Allow access to the field if it is within the region size + * rounded up to a multiple of the access byte width. This + * overcomes "off-by-one" programming errors in the AML often + * found in Toshiba laptops. These errors were allowed by + * the Microsoft ASL compiler. + */ + u32 rounded_length = ACPI_ROUND_UP(rgn_desc->region.length, + obj_desc->common_field.access_byte_width); + + if (rounded_length < (obj_desc->common_field.base_byte_offset + + field_datum_byte_offset + + obj_desc->common_field.access_byte_width)) { + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } else { + static int warn_once = 1; + if (warn_once) { + // Could also associate a flag with each field, and + // warn once for each field. + ACPI_REPORT_WARNING(( + "The ACPI AML in your computer contains errors, " + "please nag the manufacturer to correct it.\n")); + ACPI_REPORT_WARNING(( + "Allowing relaxed access to fields; " + "turn on CONFIG_ACPI_DEBUG for details.\n")); + warn_once = 0; + } + return_ACPI_STATUS (AE_OK); + } + } + #else + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + #endif } return_ACPI_STATUS (AE_OK); -- 2.53.0