From 80b28810cc98aadc80e7ce8cc155a774a7ada8ca Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:38:28 +0800 Subject: ACPICA: Linuxize: reduce divergences for 20160212 release The patch reduces source code differences between the Linux kernel and the ACPICA upstream so that the linuxized ACPICA 20160212 release can be applied with reduced human intervention. Signed-off-by: Lv Zheng [ rjw: White space damage fixes ] Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c index d4aa8b6..2de8adb 100644 --- a/drivers/acpi/acpica/nsinit.c +++ b/drivers/acpi/acpica/nsinit.c @@ -602,7 +602,6 @@ acpi_ns_init_one_device(acpi_handle obj_handle, info->flags = ACPI_IGNORE_RETURN_VALUE; status = acpi_ns_evaluate(info); - if (ACPI_SUCCESS(status)) { walk_info->num_INI++; } diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c index 75cdb87..b5e2b0a 100644 --- a/drivers/acpi/acpica/nsload.c +++ b/drivers/acpi/acpica/nsload.c @@ -123,8 +123,8 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node) (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_ns_delete_namespace_by_owner(acpi_gbl_root_table_list. tables[table_index].owner_id); - acpi_tb_release_owner_id(table_index); + acpi_tb_release_owner_id(table_index); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 814d5f8..bef06c9 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -582,7 +582,7 @@ static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; acpi_status acpi_os_predefined_override(const struct acpi_predefined_names *init_val, - char **new_val) + acpi_string *new_val) { if (!init_val || !new_val) return AE_BAD_PARAMETER; diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index d1e34d1..6026308 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -96,7 +96,7 @@ acpi_physical_address acpi_os_get_root_pointer(void); #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override acpi_status acpi_os_predefined_override(const struct acpi_predefined_names *init_val, - char **new_val); + acpi_string *new_val); #endif #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override -- cgit v0.10.2 From f1974b484f9d070623215b4f461f3420b4fbbd07 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:38:35 +0800 Subject: ACPICA: Linuxize: Remove useless platform headers Some platform headers were added to Linux during previous release cycles, but they are not useful in Linux, so drop them. Signed-off-by: Lv Zheng [ rjw: Changelog ] Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/platform/acmsvcex.h b/include/acpi/platform/acmsvcex.h deleted file mode 100644 index 28084a1..0000000 --- a/include/acpi/platform/acmsvcex.h +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * Name: acmsvcex.h - Extra VC specific defines, etc. - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#ifndef __ACMSVCEX_H__ -#define __ACMSVCEX_H__ - -/* Debug support. */ - -#ifdef _DEBUG -#define _CRTDBG_MAP_ALLOC /* Enables specific file/lineno for leaks */ -#include -#endif - -#endif /* __ACMSVCEX_H__ */ diff --git a/include/acpi/platform/acwinex.h b/include/acpi/platform/acwinex.h deleted file mode 100644 index a00b3e4..0000000 --- a/include/acpi/platform/acwinex.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * - * Name: acwinex.h - Extra OS specific defines, etc. - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#ifndef __ACWINEX_H__ -#define __ACWINEX_H__ - -/* Windows uses VC */ - -#endif /* __ACWINEX_H__ */ -- cgit v0.10.2 From c7200ffe432c6544b373f08fab33dc8e9b92516c Mon Sep 17 00:00:00 2001 From: Aleksey Makarov Date: Thu, 24 Mar 2016 09:38:42 +0800 Subject: ACPICA: Headers: Add new constants for the DBG2 ACPI table ACPICA commit 1607b69238df9c1b2940262a17aa94ec49033278 Link: https://github.com/acpica/acpica/commit/1607b692 Signed-off-by: Aleksey Makarov . Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index a4ef625..7702b27 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -321,7 +321,7 @@ struct acpi_csrt_descriptor { * DBG2 - Debug Port Table 2 * Version 0 (Both main table and subtables) * - * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012. + * Conforms to "Microsoft Debug Port Table 2 (DBG2)", December 10, 2015 * ******************************************************************************/ @@ -371,6 +371,11 @@ struct acpi_dbg2_device { #define ACPI_DBG2_16550_COMPATIBLE 0x0000 #define ACPI_DBG2_16550_SUBSET 0x0001 +#define ACPI_DBG2_ARM_PL011 0x0003 +#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D +#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E +#define ACPI_DBG2_ARM_DCC 0x000F +#define ACPI_DBG2_BCM2835 0x0010 #define ACPI_DBG2_1394_STANDARD 0x0000 -- cgit v0.10.2 From 29a3f38e4452b2ec9686927bd290a1048ab6ab07 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:38:49 +0800 Subject: ACPICA: Headers: Minor update for SPCR ACPI table ACPICA commit f3caa7f2e63be31f7fb8dbccabffbb70c29c3021 Update version number and date of specification document. Point to DBG2 table for some constants. Link: https://github.com/acpica/acpica/commit/f3caa7f2 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 7702b27..e9d3cc1 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -1107,10 +1107,10 @@ struct acpi_table_slic { /******************************************************************************* * * SPCR - Serial Port Console Redirection table - * Version 1 + * Version 2 * * Conforms to "Serial Port Console Redirection Table", - * Version 1.00, January 11, 2002 + * Version 1.03, August 10, 2015 * ******************************************************************************/ @@ -1142,6 +1142,8 @@ struct acpi_table_spcr { #define ACPI_SPCR_DO_NOT_DISABLE (1) +/* Values for Interface Type: See the definition of the DBG2 table */ + /******************************************************************************* * * SPMI - Server Platform Management Interface table -- cgit v0.10.2 From 7cd55c76f35ffb9aa0a3062be0e3b2f66babfcd0 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:38:57 +0800 Subject: ACPICA: ACPI 6.1: Updates for the HEST ACPI table ACPICA commit 7e81afb625f5184000713de2b1f280e73251bc03 Additional structure for the generic error entry. Some additional constants/flags. With assistance from Abdulhamid, Harb Link: https://github.com/acpica/acpica/commit/7e81afb6 Reviewed-by: Harb Abdulhamid Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 16e0136..b7c96b7 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -427,7 +427,8 @@ enum acpi_hest_types { ACPI_HEST_TYPE_AER_ENDPOINT = 7, ACPI_HEST_TYPE_AER_BRIDGE = 8, ACPI_HEST_TYPE_GENERIC_ERROR = 9, - ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ + ACPI_HEST_TYPE_GENERIC_ERROR_V2 = 10, + ACPI_HEST_TYPE_RESERVED = 11 /* 11 and greater are reserved */ }; /* @@ -506,7 +507,11 @@ enum acpi_hest_notify_types { ACPI_HEST_NOTIFY_NMI = 4, ACPI_HEST_NOTIFY_CMCI = 5, /* ACPI 5.0 */ ACPI_HEST_NOTIFY_MCE = 6, /* ACPI 5.0 */ - ACPI_HEST_NOTIFY_RESERVED = 7 /* 7 and greater are reserved */ + ACPI_HEST_NOTIFY_GPIO = 7, /* ACPI 6.0 */ + ACPI_HEST_NOTIFY_SEA = 8, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_SEI = 9, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_GSIV = 10, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_RESERVED = 11 /* 11 and greater are reserved */ }; /* Values for config_write_enable bitfield above */ @@ -603,6 +608,24 @@ struct acpi_hest_generic { u32 error_block_length; }; +/* 10: Generic Hardware Error Source, version 2 */ + +struct acpi_hest_generic_v2 { + struct acpi_hest_header header; + u16 related_source_id; + u8 reserved; + u8 enabled; + u32 records_to_preallocate; + u32 max_sections_per_record; + u32 max_raw_data_length; + struct acpi_generic_address error_status_address; + struct acpi_hest_notify notify; + u32 error_block_length; + struct acpi_generic_address read_ack_register; + u64 read_ack_preserve; + u64 read_ack_write; +}; + /* Generic Error Status block */ struct acpi_hest_generic_status { @@ -634,6 +657,33 @@ struct acpi_hest_generic_data { u8 fru_text[20]; }; +/* Extension for revision 0x0300 */ + +struct acpi_hest_generic_data_v300 { + u8 section_type[16]; + u32 error_severity; + u16 revision; + u8 validation_bits; + u8 flags; + u32 error_data_length; + u8 fru_id[16]; + u8 fru_text[20]; + u64 time_stamp; +}; + +/* Values for error_severity above */ + +#define ACPI_HEST_GEN_ERROR_RECOVERABLE 0 +#define ACPI_HEST_GEN_ERROR_FATAL 1 +#define ACPI_HEST_GEN_ERROR_CORRECTED 2 +#define ACPI_HEST_GEN_ERROR_NONE 3 + +/* Flags for validation_bits above */ + +#define ACPI_HEST_GEN_VALID_FRU_ID (1) +#define ACPI_HEST_GEN_VALID_FRU_STRING (1<<1) +#define ACPI_HEST_GEN_VALID_TIMESTAMP (1<<2) + /******************************************************************************* * * MADT - Multiple APIC Description Table -- cgit v0.10.2 From 4ac78baf88d85c49883fcc87d31198ebe408e54d Mon Sep 17 00:00:00 2001 From: Al Stone Date: Thu, 24 Mar 2016 09:39:07 +0800 Subject: ACPICA: IORT: Add in support for the SMMUv3 subtable ACPICA commit 9f7c3e148f440049615e2791d73b292f65692d7e The most recent version of the IORT specification adds in a definition for a subtable to describe SMMUv3 devices; there is already a subtable for SMMUv1/v2 devices. Add in the definition of the subtable, add in the code to compile it, and add in a template for it. Link: https://github.com/acpica/acpica/commit/9f7c3e14 Signed-off-by: Al Stone Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index e9d3cc1..d6bd377 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -660,7 +660,7 @@ struct acpi_ibft_target { * IORT - IO Remapping Table * * Conforms to "IO Remapping Table System Software on ARM Platforms", - * Document number: ARM DEN 0049A, 2015 + * Document number: ARM DEN 0049B, October 2015 * ******************************************************************************/ @@ -690,7 +690,8 @@ enum acpi_iort_node_type { ACPI_IORT_NODE_ITS_GROUP = 0x00, ACPI_IORT_NODE_NAMED_COMPONENT = 0x01, ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02, - ACPI_IORT_NODE_SMMU = 0x03 + ACPI_IORT_NODE_SMMU = 0x03, + ACPI_IORT_NODE_SMMU_V3 = 0x04 }; struct acpi_iort_id_mapping { @@ -780,6 +781,23 @@ struct acpi_iort_smmu { #define ACPI_IORT_SMMU_DVM_SUPPORTED (1) #define ACPI_IORT_SMMU_COHERENT_WALK (1<<1) +struct acpi_iort_smmu_v3 { + u64 base_address; /* SMMUv3 base address */ + u32 flags; + u32 reserved; + u64 vatos_address; + u32 model; /* O: generic SMMUv3 */ + u32 event_gsiv; + u32 pri_gsiv; + u32 gerr_gsiv; + u32 sync_gsiv; +}; + +/* Masks for Flags field above */ + +#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE (1) +#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE (1<<1) + /******************************************************************************* * * IVRS - I/O Virtualization Reporting Structure -- cgit v0.10.2 From 138a95547ab04f5f9d49bfb12bd764f7a7edbcf4 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:14 +0800 Subject: ACPICA: ACPI 6.1: Update NFIT table for additional new fields ACPICA commit bc81a4494d7648a496e0a82f0d27562103ee1ec1 Changes the NFIT Control Region. Link: https://github.com/acpica/acpica/commit/bc81a449 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index b7c96b7..912dff9 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -984,7 +984,7 @@ struct acpi_msct_proximity { /******************************************************************************* * - * NFIT - NVDIMM Interface Table (ACPI 6.0) + * NFIT - NVDIMM Interface Table (ACPI 6.0+) * Version 1 * ******************************************************************************/ @@ -1065,6 +1065,7 @@ struct acpi_nfit_memory_map { #define ACPI_NFIT_MEM_NOT_ARMED (1<<3) /* 03: Memory Device is not armed */ #define ACPI_NFIT_MEM_HEALTH_OBSERVED (1<<4) /* 04: Memory Device observed SMART/health events */ #define ACPI_NFIT_MEM_HEALTH_ENABLED (1<<5) /* 05: SMART/health events enabled */ +#define ACPI_NFIT_MEM_MAP_FAILED (1<<6) /* 06: Mapping to SPA failed */ /* 2: Interleave Structure */ @@ -1096,7 +1097,10 @@ struct acpi_nfit_control_region { u16 subsystem_vendor_id; u16 subsystem_device_id; u16 subsystem_revision_id; - u8 reserved[6]; /* Reserved, must be zero */ + u8 valid_fields; + u8 manufacturing_location; + u16 manufacturing_date; + u8 reserved[2]; /* Reserved, must be zero */ u32 serial_number; u16 code; u16 windows; @@ -1111,7 +1115,11 @@ struct acpi_nfit_control_region { /* Flags */ -#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ +#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ + +/* valid_fields bits */ + +#define ACPI_NFIT_CONTROL_MFG_INFO_VALID (1) /* Manufacturing fields are valid */ /* 5: NVDIMM Block Data Window Region Structure */ -- cgit v0.10.2 From 3a9ca4d5f179b19919679171240e9ba3ea0c5df9 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:21 +0800 Subject: ACPICA: Headers: Update DMAR table for October 2014 I/O spec ACPICA commit 454b2ea5f0c254e97612e15994f7d4734a7931ea Adds two flags to the DMAR table. Link: https://github.com/acpica/acpica/commit/454b2ea5 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index d6bd377..c93dbad 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -404,7 +404,7 @@ struct acpi_table_dbgp { * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 2.2, Sept. 2013 + * Version 2.3, October 2014 * ******************************************************************************/ @@ -418,6 +418,8 @@ struct acpi_table_dmar { /* Masks for Flags field above */ #define ACPI_DMAR_INTR_REMAP (1) +#define ACPI_DMAR_X2APIC_OPT_OUT (1<<1) +#define ACPI_DMAR_X2APIC_MODE (1<<2) /* DMAR subtable header */ -- cgit v0.10.2 From b94cd8118c057933127f28e9a3bc79cc92de9714 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:28 +0800 Subject: ACPICA: Tables: Update FADT handling ACPICA commit bca0c4cb063ee488c543e6f160fe89679a2338d6 Update a warning message simplify versioning for "table too big" case. Link: https://github.com/acpica/acpica/commit/bca0c4cb Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index a79e4f3..f63f3fd 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -385,14 +385,15 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) { /* * Check if the FADT is larger than the largest table that we expect - * (the ACPI 5.0 version). If so, truncate the table, and issue - * a warning. + * (typically the current ACPI specification version). If so, truncate + * the table, and issue a warning. */ if (length > sizeof(struct acpi_table_fadt)) { ACPI_BIOS_WARNING((AE_INFO, - "FADT (revision %u) is longer than ACPI 5.0 version, " + "FADT (revision %u) is longer than %s length, " "truncating length %u to %u", - table->revision, length, + table->revision, ACPI_FADT_CONFORMANCE, + length, (u32)sizeof(struct acpi_table_fadt))); } @@ -646,9 +647,12 @@ static void acpi_tb_convert_fadt(void) if ((address64->address && !length) || (!address64->address && length)) { ACPI_BIOS_WARNING((AE_INFO, - "Optional FADT field %s has zero address or length: " - "0x%8.8X%8.8X/0x%X", - name, + "Optional FADT field %s has valid %s but zero %s: " + "0x%8.8X%8.8X/0x%X", name, + (length ? "Length" : + "Address"), + (length ? "Address" : + "Length"), ACPI_FORMAT_UINT64 (address64->address), length)); diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h index 0cb1a00..c19700e 100644 --- a/include/acpi/actbl.h +++ b/include/acpi/actbl.h @@ -223,7 +223,7 @@ struct acpi_table_facs { /******************************************************************************* * * FADT - Fixed ACPI Description Table (Signature "FACP") - * Version 4 + * Version 6 * ******************************************************************************/ @@ -413,4 +413,6 @@ struct acpi_table_desc { #define ACPI_FADT_V5_SIZE (u32) (ACPI_FADT_OFFSET (hypervisor_id)) #define ACPI_FADT_V6_SIZE (u32) (sizeof (struct acpi_table_fadt)) +#define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" + #endif /* __ACTBL_H__ */ -- cgit v0.10.2 From a88e0ce6beffb5ba1df8930f2f0112024f2a215e Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:36 +0800 Subject: ACPICA: ACPI 6.1: Add full support for this version of ACPI spec ACPICA commit 5f21bddaa2cec035ca80608803ce2f0858d4f387 Small changes: 1) A couple new predefined names 2) New _HID values 3) New subtable for HEST Link: https://github.com/acpica/acpica/commit/5f21bdda Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index 5faeab4..4ca426b 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h @@ -523,6 +523,9 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = { METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0), + {{"_FIT", METHOD_0ARGS, + METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, /* ACPI 6.0 */ + {{"_FIX", METHOD_0ARGS, METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */ PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), @@ -1053,6 +1056,12 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = { METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER)}}, + {{"_WPC", METHOD_0ARGS, + METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* ACPI 6.1 */ + + {{"_WPP", METHOD_0ARGS, + METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* ACPI 6.1 */ + PACKAGE_INFO(0, 0, 0, 0, 0, 0) /* Table terminator */ }; #else diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c index 6ba65b0..efd7988 100644 --- a/drivers/acpi/acpica/utdecode.c +++ b/drivers/acpi/acpica/utdecode.c @@ -446,7 +446,7 @@ const char *acpi_ut_get_mutex_name(u32 mutex_id) /* Names for Notify() values, used for debug output */ -static const char *acpi_gbl_generic_notify[ACPI_NOTIFY_MAX + 1] = { +static const char *acpi_gbl_generic_notify[ACPI_GENERIC_NOTIFY_MAX + 1] = { /* 00 */ "Bus Check", /* 01 */ "Device Check", /* 02 */ "Device Wake", @@ -459,49 +459,53 @@ static const char *acpi_gbl_generic_notify[ACPI_NOTIFY_MAX + 1] = { /* 09 */ "Device PLD Check", /* 0A */ "Reserved", /* 0B */ "System Locality Update", - /* 0C */ "Shutdown Request", + /* 0C */ "Shutdown Request", + /* Reserved in ACPI 6.0 */ /* 0D */ "System Resource Affinity Update" }; -static const char *acpi_gbl_device_notify[4] = { +static const char *acpi_gbl_device_notify[5] = { /* 80 */ "Status Change", /* 81 */ "Information Change", /* 82 */ "Device-Specific Change", - /* 83 */ "Device-Specific Change" + /* 83 */ "Device-Specific Change", + /* 84 */ "Reserved" }; -static const char *acpi_gbl_processor_notify[4] = { +static const char *acpi_gbl_processor_notify[5] = { /* 80 */ "Performance Capability Change", /* 81 */ "C-State Change", /* 82 */ "Throttling Capability Change", - /* 83 */ "Device-Specific Change" + /* 83 */ "Guaranteed Change", + /* 84 */ "Minimum Excursion" }; -static const char *acpi_gbl_thermal_notify[4] = { +static const char *acpi_gbl_thermal_notify[5] = { /* 80 */ "Thermal Status Change", /* 81 */ "Thermal Trip Point Change", /* 82 */ "Thermal Device List Change", - /* 83 */ "Thermal Relationship Change" + /* 83 */ "Thermal Relationship Change", + /* 84 */ "Reserved" }; const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type) { - /* 00 - 0D are common to all object types */ + /* 00 - 0D are "common to all object types" (from ACPI Spec) */ - if (notify_value <= ACPI_NOTIFY_MAX) { + if (notify_value <= ACPI_GENERIC_NOTIFY_MAX) { return (acpi_gbl_generic_notify[notify_value]); } - /* 0D - 7F are reserved */ + /* 0E - 7F are reserved */ if (notify_value <= ACPI_MAX_SYS_NOTIFY) { return ("Reserved"); } - /* 80 - 83 are per-object-type */ + /* 80 - 84 are per-object-type */ - if (notify_value <= 0x83) { + if (notify_value <= ACPI_SPECIFIC_NOTIFY_MAX) { switch (type) { case ACPI_TYPE_ANY: case ACPI_TYPE_DEVICE: diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 912dff9..796d6ba 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -236,7 +236,8 @@ enum acpi_einj_actions { ACPI_EINJ_CHECK_BUSY_STATUS = 6, ACPI_EINJ_GET_COMMAND_STATUS = 7, ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS = 8, - ACPI_EINJ_ACTION_RESERVED = 9, /* 9 and greater are reserved */ + ACPI_EINJ_GET_EXECUTE_TIMINGS = 9, + ACPI_EINJ_ACTION_RESERVED = 10, /* 10 and greater are reserved */ ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */ }; @@ -348,7 +349,8 @@ enum acpi_erst_actions { ACPI_ERST_GET_ERROR_RANGE = 13, ACPI_ERST_GET_ERROR_LENGTH = 14, ACPI_ERST_GET_ERROR_ATTRIBUTES = 15, - ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */ + ACPI_ERST_EXECUTE_TIMINGS = 16, + ACPI_ERST_ACTION_RESERVED = 17 /* 17 and greater are reserved */ }; /* Values for Instruction field above */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index db46546..140886e 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -630,7 +630,8 @@ typedef u64 acpi_integer; #define ACPI_NOTIFY_SHUTDOWN_REQUEST (u8) 0x0C #define ACPI_NOTIFY_AFFINITY_UPDATE (u8) 0x0D -#define ACPI_NOTIFY_MAX 0x0D +#define ACPI_GENERIC_NOTIFY_MAX 0x0D +#define ACPI_SPECIFIC_NOTIFY_MAX 0x84 /* * Types associated with ACPI names and objects. The first group of -- cgit v0.10.2 From 28a9a69bdf36f639df9820592eb2ce2e99002338 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:44 +0800 Subject: ACPICA: iASL/Headers: Fix incorrect definition of FPDT table ACPICA commit f30ba83711bcb860f9b17dd36d0bcc5242a4ef91 ACPICA BZ 1249. Link: https://github.com/acpica/acpica/commit/f30ba837 Link: https://bugs.acpica.org/show_bug.cgi?id=1249 Reported-by: Greg Elkin Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index ddf5e66..f12f4bb 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h @@ -184,7 +184,7 @@ struct acpi_table_fpdt { struct acpi_table_header header; /* Common ACPI table header */ }; -/* FPDT subtable header */ +/* FPDT subtable header (Performance Record Structure) */ struct acpi_fpdt_header { u16 type; @@ -205,19 +205,15 @@ enum acpi_fpdt_type { /* 0: Firmware Basic Boot Performance Record */ -struct acpi_fpdt_boot { +struct acpi_fpdt_boot_pointer { struct acpi_fpdt_header header; u8 reserved[4]; - u64 reset_end; - u64 load_start; - u64 startup_start; - u64 exit_services_entry; - u64 exit_services_exit; + u64 address; }; /* 1: S3 Performance Table Pointer Record */ -struct acpi_fpdt_s3pt_ptr { +struct acpi_fpdt_s3pt_pointer { struct acpi_fpdt_header header; u8 reserved[4]; u64 address; @@ -225,7 +221,7 @@ struct acpi_fpdt_s3pt_ptr { /* * S3PT - S3 Performance Table. This table is pointed to by the - * FPDT S3 Pointer Record above. + * S3 Pointer Record above. */ struct acpi_table_s3pt { u8 signature[4]; /* "S3PT" */ @@ -233,34 +229,43 @@ struct acpi_table_s3pt { }; /* - * S3PT Subtables + * S3PT Subtables (Not part of the actual FPDT) */ -struct acpi_s3pt_header { - u16 type; - u8 length; - u8 revision; -}; -/* Values for Type field above */ +/* Values for Type field in S3PT header */ enum acpi_s3pt_type { ACPI_S3PT_TYPE_RESUME = 0, - ACPI_S3PT_TYPE_SUSPEND = 1 + ACPI_S3PT_TYPE_SUSPEND = 1, + ACPI_FPDT_BOOT_PERFORMANCE = 2 }; struct acpi_s3pt_resume { - struct acpi_s3pt_header header; + struct acpi_fpdt_header header; u32 resume_count; u64 full_resume; u64 average_resume; }; struct acpi_s3pt_suspend { - struct acpi_s3pt_header header; + struct acpi_fpdt_header header; u64 suspend_start; u64 suspend_end; }; +/* + * FPDT Boot Performance Record (Not part of the actual FPDT) + */ +struct acpi_fpdt_boot { + struct acpi_fpdt_header header; + u8 reserved[4]; + u64 reset_end; + u64 load_start; + u64 startup_start; + u64 exit_services_entry; + u64 exit_services_exit; +}; + /******************************************************************************* * * GTDT - Generic Timer Description Table (ACPI 5.1) -- cgit v0.10.2 From 890b090ef5ab6f0a125b8668c49d734442333d3c Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:51 +0800 Subject: ACPICA: Intepreter: Add object extensions to Concatenate operand ACPICA commit 60d9cfd403a9824199b971597c930f6f563e5c71 Allows all object types to be used with Concatenate. Objects other than Int/Str/Buf are convert to a string that contains the type of the object. Improves the utility of the Printf and Fprintf macros. Adds a new file, exconcat.c Link: https://github.com/acpica/acpica/commit/60d9cfd4 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index f682374..188597f 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile @@ -43,6 +43,7 @@ acpi-y += \ evxfregn.o acpi-y += \ + exconcat.o \ exconfig.o \ exconvrt.o \ excreate.o \ diff --git a/drivers/acpi/acpica/exconcat.c b/drivers/acpi/acpica/exconcat.c new file mode 100644 index 0000000..553e014 --- /dev/null +++ b/drivers/acpi/acpica/exconcat.c @@ -0,0 +1,439 @@ +/****************************************************************************** + * + * Module Name: exconcat - Concatenate-type AML operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include +#include "accommon.h" +#include "acinterp.h" +#include "amlresrc.h" + +#define _COMPONENT ACPI_EXECUTER +ACPI_MODULE_NAME("exconcat") + +/* Local Prototypes */ +static acpi_status +acpi_ex_convert_to_object_type_string(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc); + +/******************************************************************************* + * + * FUNCTION: acpi_ex_do_concatenate + * + * PARAMETERS: operand0 - First source object + * operand1 - Second source object + * actual_return_desc - Where to place the return object + * walk_state - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects with the ACPI-defined conversion + * rules as necessary. + * NOTE: + * Per the ACPI spec (up to 6.1), Concatenate only supports Integer, + * String, and Buffer objects. However, we support all objects here + * as an extension. This improves the usefulness of both Concatenate + * and the Printf/Fprintf macros. The extension returns a string + * describing the object type for the other objects. + * 02/2016. + * + ******************************************************************************/ + +acpi_status +acpi_ex_do_concatenate(union acpi_operand_object *operand0, + union acpi_operand_object *operand1, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state *walk_state) +{ + union acpi_operand_object *local_operand0 = operand0; + union acpi_operand_object *local_operand1 = operand1; + union acpi_operand_object *temp_operand1 = NULL; + union acpi_operand_object *return_desc; + char *buffer; + acpi_object_type operand0_type; + acpi_object_type operand1_type; + acpi_status status; + + ACPI_FUNCTION_TRACE(ex_do_concatenate); + + /* Operand 0 preprocessing */ + + switch (operand0->common.type) { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + operand0_type = operand0->common.type; + break; + + default: + + /* For all other types, get the "object type" string */ + + status = + acpi_ex_convert_to_object_type_string(operand0, + &local_operand0); + if (ACPI_FAILURE(status)) { + goto cleanup; + } + + operand0_type = ACPI_TYPE_STRING; + break; + } + + /* Operand 1 preprocessing */ + + switch (operand1->common.type) { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + operand1_type = operand1->common.type; + break; + + default: + + /* For all other types, get the "object type" string */ + + status = + acpi_ex_convert_to_object_type_string(operand1, + &local_operand1); + if (ACPI_FAILURE(status)) { + goto cleanup; + } + + operand1_type = ACPI_TYPE_STRING; + break; + } + + /* + * Convert the second operand if necessary. The first operand (0) + * determines the type of the second operand (1) (See the Data Types + * section of the ACPI specification). Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (operand0_type) { + case ACPI_TYPE_INTEGER: + + status = + acpi_ex_convert_to_integer(local_operand1, &temp_operand1, + 16); + break; + + case ACPI_TYPE_BUFFER: + + status = + acpi_ex_convert_to_buffer(local_operand1, &temp_operand1); + break; + + case ACPI_TYPE_STRING: + + switch (operand1_type) { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Other types have already been converted to string */ + + status = + acpi_ex_convert_to_string(local_operand1, + &temp_operand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + default: + + status = AE_OK; + break; + } + break; + + default: + + ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", + operand0->common.type)); + status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE(status)) { + goto cleanup; + } + + /* Take care with any newly created operand objects */ + + if ((local_operand1 != operand1) && (local_operand1 != temp_operand1)) { + acpi_ut_remove_reference(local_operand1); + } + + local_operand1 = temp_operand1; + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform + * the concatenation. + * + * There are three cases to handle, as per the ACPI spec: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (operand0_type) { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + return_desc = acpi_ut_create_buffer_object((acpi_size) + ACPI_MUL_2 + (acpi_gbl_integer_byte_width)); + if (!return_desc) { + status = AE_NO_MEMORY; + goto cleanup; + } + + buffer = (char *)return_desc->buffer.pointer; + + /* Copy the first integer, LSB first */ + + memcpy(buffer, &operand0->integer.value, + acpi_gbl_integer_byte_width); + + /* Copy the second integer (LSB first) after the first */ + + memcpy(buffer + acpi_gbl_integer_byte_width, + &local_operand1->integer.value, + acpi_gbl_integer_byte_width); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + return_desc = acpi_ut_create_string_object(((acpi_size) + local_operand0-> + string.length + + local_operand1-> + string.length)); + if (!return_desc) { + status = AE_NO_MEMORY; + goto cleanup; + } + + buffer = return_desc->string.pointer; + + /* Concatenate the strings */ + + strcpy(buffer, local_operand0->string.pointer); + strcat(buffer, local_operand1->string.pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + return_desc = acpi_ut_create_buffer_object(((acpi_size) + operand0->buffer. + length + + local_operand1-> + buffer.length)); + if (!return_desc) { + status = AE_NO_MEMORY; + goto cleanup; + } + + buffer = (char *)return_desc->buffer.pointer; + + /* Concatenate the buffers */ + + memcpy(buffer, operand0->buffer.pointer, + operand0->buffer.length); + memcpy(buffer + operand0->buffer.length, + local_operand1->buffer.pointer, + local_operand1->buffer.length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", + operand0->common.type)); + status = AE_AML_INTERNAL; + goto cleanup; + } + + *actual_return_desc = return_desc; + +cleanup: + if (local_operand0 != operand0) { + acpi_ut_remove_reference(local_operand0); + } + + if (local_operand1 != operand1) { + acpi_ut_remove_reference(local_operand1); + } + + return_ACPI_STATUS(status); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ex_convert_to_object_type_string + * + * PARAMETERS: obj_desc - Object to be converted + * return_desc - Where to place the return object + * + * RETURN: Status + * + * DESCRIPTION: Convert an object of arbitrary type to a string object that + * contains the namestring for the object. Used for the + * concatenate operator. + * + ******************************************************************************/ + +static acpi_status +acpi_ex_convert_to_object_type_string(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc) +{ + union acpi_operand_object *return_desc; + const char *type_string; + + type_string = acpi_ut_get_type_name(obj_desc->common.type); + + return_desc = acpi_ut_create_string_object(((acpi_size) strlen(type_string) + 9)); /* 9 For "[ Object]" */ + if (!return_desc) { + return (AE_NO_MEMORY); + } + + strcpy(return_desc->string.pointer, "["); + strcat(return_desc->string.pointer, type_string); + strcat(return_desc->string.pointer, " Object]"); + + *result_desc = return_desc; + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ex_concat_template + * + * PARAMETERS: operand0 - First source object + * operand1 - Second source object + * actual_return_desc - Where to place the return object + * walk_state - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +acpi_status +acpi_ex_concat_template(union acpi_operand_object *operand0, + union acpi_operand_object *operand1, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state * walk_state) +{ + acpi_status status; + union acpi_operand_object *return_desc; + u8 *new_buf; + u8 *end_tag; + acpi_size length0; + acpi_size length1; + acpi_size new_length; + + ACPI_FUNCTION_TRACE(ex_concat_template); + + /* + * Find the end_tag descriptor in each resource template. + * Note1: returned pointers point TO the end_tag, not past it. + * Note2: zero-length buffers are allowed; treated like one end_tag + */ + + /* Get the length of the first resource template */ + + status = acpi_ut_get_resource_end_tag(operand0, &end_tag); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); + + /* Get the length of the second resource template */ + + status = acpi_ut_get_resource_end_tag(operand1, &end_tag); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer); + + /* Combine both lengths, minimum size will be 2 for end_tag */ + + new_length = length0 + length1 + sizeof(struct aml_resource_end_tag); + + /* Create a new buffer object for the result (with one end_tag) */ + + return_desc = acpi_ut_create_buffer_object(new_length); + if (!return_desc) { + return_ACPI_STATUS(AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * end_tag descriptor is copied from Operand1. + */ + new_buf = return_desc->buffer.pointer; + memcpy(new_buf, operand0->buffer.pointer, length0); + memcpy(new_buf + length0, operand1->buffer.pointer, length1); + + /* Insert end_tag and set the checksum to zero, means "ignore checksum" */ + + new_buf[new_length - 1] = 0; + new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *actual_return_desc = return_desc; + return_ACPI_STATUS(AE_OK); +} diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c index db30ae4..4f7e667 100644 --- a/drivers/acpi/acpica/exmisc.c +++ b/drivers/acpi/acpica/exmisc.c @@ -45,7 +45,6 @@ #include "accommon.h" #include "acinterp.h" #include "amlcode.h" -#include "amlresrc.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME("exmisc") @@ -140,295 +139,6 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, /******************************************************************************* * - * FUNCTION: acpi_ex_concat_template - * - * PARAMETERS: operand0 - First source object - * operand1 - Second source object - * actual_return_desc - Where to place the return object - * walk_state - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two resource templates - * - ******************************************************************************/ - -acpi_status -acpi_ex_concat_template(union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state) -{ - acpi_status status; - union acpi_operand_object *return_desc; - u8 *new_buf; - u8 *end_tag; - acpi_size length0; - acpi_size length1; - acpi_size new_length; - - ACPI_FUNCTION_TRACE(ex_concat_template); - - /* - * Find the end_tag descriptor in each resource template. - * Note1: returned pointers point TO the end_tag, not past it. - * Note2: zero-length buffers are allowed; treated like one end_tag - */ - - /* Get the length of the first resource template */ - - status = acpi_ut_get_resource_end_tag(operand0, &end_tag); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); - - /* Get the length of the second resource template */ - - status = acpi_ut_get_resource_end_tag(operand1, &end_tag); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer); - - /* Combine both lengths, minimum size will be 2 for end_tag */ - - new_length = length0 + length1 + sizeof(struct aml_resource_end_tag); - - /* Create a new buffer object for the result (with one end_tag) */ - - return_desc = acpi_ut_create_buffer_object(new_length); - if (!return_desc) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* - * Copy the templates to the new buffer, 0 first, then 1 follows. One - * end_tag descriptor is copied from Operand1. - */ - new_buf = return_desc->buffer.pointer; - memcpy(new_buf, operand0->buffer.pointer, length0); - memcpy(new_buf + length0, operand1->buffer.pointer, length1); - - /* Insert end_tag and set the checksum to zero, means "ignore checksum" */ - - new_buf[new_length - 1] = 0; - new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; - - /* Return the completed resource template */ - - *actual_return_desc = return_desc; - return_ACPI_STATUS(AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_ex_do_concatenate - * - * PARAMETERS: operand0 - First source object - * operand1 - Second source object - * actual_return_desc - Where to place the return object - * walk_state - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. - * - ******************************************************************************/ - -acpi_status -acpi_ex_do_concatenate(union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state) -{ - union acpi_operand_object *local_operand1 = operand1; - union acpi_operand_object *return_desc; - char *new_buf; - const char *type_string; - acpi_status status; - - ACPI_FUNCTION_TRACE(ex_do_concatenate); - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism. - */ - switch (operand0->common.type) { - case ACPI_TYPE_INTEGER: - - status = - acpi_ex_convert_to_integer(operand1, &local_operand1, 16); - break; - - case ACPI_TYPE_STRING: - /* - * Per the ACPI spec, Concatenate only supports int/str/buf. - * However, we support all objects here as an extension. - * This improves the usefulness of the Printf() macro. - * 12/2015. - */ - switch (operand1->common.type) { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - status = - acpi_ex_convert_to_string(operand1, &local_operand1, - ACPI_IMPLICIT_CONVERT_HEX); - break; - - default: - /* - * Just emit a string containing the object type. - */ - type_string = - acpi_ut_get_type_name(operand1->common.type); - - local_operand1 = acpi_ut_create_string_object(((acpi_size) strlen(type_string) + 9)); /* 9 For "[Object]" */ - if (!local_operand1) { - status = AE_NO_MEMORY; - goto cleanup; - } - - strcpy(local_operand1->string.pointer, "["); - strcat(local_operand1->string.pointer, type_string); - strcat(local_operand1->string.pointer, " Object]"); - status = AE_OK; - break; - } - break; - - case ACPI_TYPE_BUFFER: - - status = acpi_ex_convert_to_buffer(operand1, &local_operand1); - break; - - default: - - ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", - operand0->common.type)); - status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE(status)) { - goto cleanup; - } - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - - /* - * There are three cases to handle: - * - * 1) Two Integers concatenated to produce a new Buffer - * 2) Two Strings concatenated to produce a new String - * 3) Two Buffers concatenated to produce a new Buffer - */ - switch (operand0->common.type) { - case ACPI_TYPE_INTEGER: - - /* Result of two Integers is a Buffer */ - /* Need enough buffer space for two integers */ - - return_desc = acpi_ut_create_buffer_object((acpi_size) - ACPI_MUL_2 - (acpi_gbl_integer_byte_width)); - if (!return_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - new_buf = (char *)return_desc->buffer.pointer; - - /* Copy the first integer, LSB first */ - - memcpy(new_buf, &operand0->integer.value, - acpi_gbl_integer_byte_width); - - /* Copy the second integer (LSB first) after the first */ - - memcpy(new_buf + acpi_gbl_integer_byte_width, - &local_operand1->integer.value, - acpi_gbl_integer_byte_width); - break; - - case ACPI_TYPE_STRING: - - /* Result of two Strings is a String */ - - return_desc = acpi_ut_create_string_object(((acpi_size) - operand0->string. - length + - local_operand1-> - string.length)); - if (!return_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - new_buf = return_desc->string.pointer; - - /* Concatenate the strings */ - - strcpy(new_buf, operand0->string.pointer); - strcat(new_buf, local_operand1->string.pointer); - break; - - case ACPI_TYPE_BUFFER: - - /* Result of two Buffers is a Buffer */ - - return_desc = acpi_ut_create_buffer_object(((acpi_size) - operand0->buffer. - length + - local_operand1-> - buffer.length)); - if (!return_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - new_buf = (char *)return_desc->buffer.pointer; - - /* Concatenate the buffers */ - - memcpy(new_buf, operand0->buffer.pointer, - operand0->buffer.length); - memcpy(new_buf + operand0->buffer.length, - local_operand1->buffer.pointer, - local_operand1->buffer.length); - break; - - default: - - /* Invalid object type, should not happen here */ - - ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", - operand0->common.type)); - status = AE_AML_INTERNAL; - goto cleanup; - } - - *actual_return_desc = return_desc; - -cleanup: - if (local_operand1 != operand1) { - acpi_ut_remove_reference(local_operand1); - } - return_ACPI_STATUS(status); -} - -/******************************************************************************* - * * FUNCTION: acpi_ex_do_math_op * * PARAMETERS: opcode - AML opcode -- cgit v0.10.2 From d8aa069a35b40150abb00658be91dcb284648a04 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:39:58 +0800 Subject: ACPICA: Interpreter: Update some function headers, no functional change ACPICA commit e068948f49eb61a78c211028976a174604c5644a Fix some issues in the exutils.c file. Link: https://github.com/acpica/acpica/commit/e068948f Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c index 4d44bc1..425f133 100644 --- a/drivers/acpi/acpica/exutils.c +++ b/drivers/acpi/acpica/exutils.c @@ -301,8 +301,8 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base) * * FUNCTION: acpi_ex_eisa_id_to_string * - * PARAMETERS: compressed_id - EISAID to be converted - * out_string - Where to put the converted string (8 bytes) + * PARAMETERS: out_string - Where to put the converted string (8 bytes) + * compressed_id - EISAID to be converted * * RETURN: None * @@ -354,7 +354,7 @@ void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id) * possible 64-bit integer. * value - Value to be converted * - * RETURN: None, string + * RETURN: Converted string in out_string * * DESCRIPTION: Convert a 64-bit integer to decimal string representation. * Assumes string buffer is large enough to hold the string. The @@ -384,9 +384,9 @@ void acpi_ex_integer_to_string(char *out_string, u64 value) * FUNCTION: acpi_ex_pci_cls_to_string * * PARAMETERS: out_string - Where to put the converted string (7 bytes) - * PARAMETERS: class_code - PCI class code to be converted (3 bytes) + * class_code - PCI class code to be converted (3 bytes) * - * RETURN: None + * RETURN: Converted string in out_string * * DESCRIPTION: Convert 3-bytes PCI class code to string representation. * Return buffer must be large enough to hold the string. The @@ -417,7 +417,7 @@ void acpi_ex_pci_cls_to_string(char *out_string, u8 class_code[3]) * * PARAMETERS: space_id - ID to be validated * - * RETURN: TRUE if valid/supported ID. + * RETURN: TRUE if space_id is a valid/supported ID. * * DESCRIPTION: Validate an operation region space_ID. * -- cgit v0.10.2 From fe0f8765dfd224775db1df9b878bfeb6121cbe6c Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:05 +0800 Subject: ACPICA: iASL: Cleanup/optimization for ToPLD macro support ACPICA commit 0e6125401cf38427d5376f4bafbfb3d5a40f8467 Use local variables for access to string/value Op fields. Move duplicate PLD string tables to a single common table. Link: https://github.com/acpica/acpica/commit/0e612540 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 51b073b..54b42a5 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -361,6 +361,15 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects); #endif /* ACPI_DEBUGGER */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +ACPI_GLOBAL(const char, *acpi_gbl_pld_panel_list[]); +ACPI_GLOBAL(const char, *acpi_gbl_pld_vertical_position_list[]); +ACPI_GLOBAL(const char, *acpi_gbl_pld_horizontal_position_list[]); +ACPI_GLOBAL(const char, *acpi_gbl_pld_shape_list[]); + +#endif + /***************************************************************************** * * Application globals diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 48fffcf..d45899c 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -221,6 +221,49 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +/* to_pld macro: compile/disassemble strings */ + +const char *acpi_gbl_pld_panel_list[] = { + "TOP", + "BOTTOM", + "LEFT", + "RIGHT", + "FRONT", + "BACK", + "UNKNOWN", + NULL +}; + +const char *acpi_gbl_pld_vertical_position_list[] = { + "UPPER", + "CENTER", + "LOWER", + NULL +}; + +const char *acpi_gbl_pld_horizontal_position_list[] = { + "LEFT", + "CENTER", + "RIGHT", + NULL +}; + +const char *acpi_gbl_pld_shape_list[] = { + "ROUND", + "OVAL", + "SQUARE", + "VERTICALRECTANGLE", + "HORIZONTALRECTANGLE", + "VERTICALTRAPEZOID", + "HORIZONTALTRAPEZOID", + "UNKNOWN", + "CHAMFERED", + NULL +}; +#endif + /* Public globals */ ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) -- cgit v0.10.2 From 2156510f300f9ac70a024994acb5235ebd4ee087 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:12 +0800 Subject: ACPICA: Cleanup some invocation indentations, no functional change ACPICA commit 9ed98dc36645aaeba11967722951156650d94f47 For consistency, cleanup function invocations. Link: https://github.com/acpica/acpica/commit/9ed98dc3 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c index 9047f28..fde5a09 100644 --- a/drivers/acpi/acpica/nsprepkg.c +++ b/drivers/acpi/acpica/nsprepkg.c @@ -179,6 +179,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info, if (ACPI_FAILURE(status)) { return (status); } + elements++; } break; @@ -225,6 +226,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info, return (status); } } + elements++; } break; @@ -569,11 +571,13 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info, if (sub_package->package.count < expected_count) { goto package_too_small; } + if (sub_package->package.count < package->ret_info.count1) { expected_count = package->ret_info.count1; goto package_too_small; } + if (expected_count == 0) { /* * Either the num_entries element was originally zero or it was @@ -661,6 +665,7 @@ acpi_ns_check_package_elements(struct acpi_evaluate_info *info, if (ACPI_FAILURE(status)) { return (status); } + this_element++; } @@ -671,6 +676,7 @@ acpi_ns_check_package_elements(struct acpi_evaluate_info *info, if (ACPI_FAILURE(status)) { return (status); } + this_element++; } -- cgit v0.10.2 From 95df7b5e4c9c7a6b1e75d7bbc16ac19ee2784379 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:19 +0800 Subject: ACPICA: Headers: Update generation of the ACPICA library ACPICA commit 0af0f9092dcc3db6c05875eae68965fda333ad7f For windows only, ensure that debug output is disabled for the "release" (non-debug) case. Link: https://github.com/acpica/acpica/commit/0af0f909 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 7c0595b..72f85b4 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -66,17 +66,28 @@ * *****************************************************************************/ +/* Common application configuration. All single threaded except for acpi_exec. */ + +#if (defined ACPI_ASL_COMPILER) || \ + (defined ACPI_BIN_APP) || \ + (defined ACPI_DUMP_APP) || \ + (defined ACPI_HELP_APP) || \ + (defined ACPI_NAMES_APP) || \ + (defined ACPI_SRC_APP) || \ + (defined ACPI_XTRACT_APP) || \ + (defined ACPI_EXAMPLE_APP) +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + /* iASL configuration */ #ifdef ACPI_ASL_COMPILER -#define ACPI_APPLICATION #define ACPI_DEBUG_OUTPUT #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_LARGE_NAMESPACE_NODE #define ACPI_DATA_TABLE_DISASSEMBLY -#define ACPI_SINGLE_THREADED #define ACPI_32BIT_PHYSICAL_ADDRESS - #define ACPI_DISASSEMBLER 1 #endif @@ -89,21 +100,6 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -/* - * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example - * configuration. All single threaded. - */ -#if (defined ACPI_BIN_APP) || \ - (defined ACPI_DUMP_APP) || \ - (defined ACPI_HELP_APP) || \ - (defined ACPI_NAMES_APP) || \ - (defined ACPI_SRC_APP) || \ - (defined ACPI_XTRACT_APP) || \ - (defined ACPI_EXAMPLE_APP) -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED -#endif - /* acpi_help configuration. Error messages disabled. */ #ifdef ACPI_HELP_APP @@ -138,11 +134,16 @@ #define ACPI_REDUCED_HARDWARE 1 #endif -/* Linkable ACPICA library */ +/* Linkable ACPICA library. Two versions, one with full debug. */ #ifdef ACPI_LIBRARY #define ACPI_USE_LOCAL_CACHE -#define ACPI_FULL_DEBUG +#define ACPI_DEBUGGER 1 +#define ACPI_DISASSEMBLER 1 + +#ifdef _DEBUG +#define ACPI_DEBUG_OUTPUT +#endif #endif /* Common for all ACPICA applications */ -- cgit v0.10.2 From 53c78d75d8a4615e5c2f1d9fe94f25e049f0e61b Mon Sep 17 00:00:00 2001 From: Will Miles Date: Thu, 24 Mar 2016 09:40:26 +0800 Subject: ACPICA: Add support for QNX 6.6 platform ACPICA commit 37a1dec2391272251e59948c16c60713183ae78f Link: https://github.com/acpica/acpica/commit/37a1dec2 Signed-off-by: Will Miles Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 72f85b4..86b5a84 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -219,6 +219,9 @@ #elif defined(__HAIKU__) #include "achaiku.h" +#elif defined(__QNX__) +#include "acqnx.h" + #else /* Unknown environment */ diff --git a/tools/power/acpi/os_specific/service_layers/osunixmap.c b/tools/power/acpi/os_specific/service_layers/osunixmap.c index 3818fd0..cbfbce1 100644 --- a/tools/power/acpi/os_specific/service_layers/osunixmap.c +++ b/tools/power/acpi/os_specific/service_layers/osunixmap.c @@ -54,7 +54,7 @@ ACPI_MODULE_NAME("osunixmap") #ifndef O_BINARY #define O_BINARY 0 #endif -#if defined(_dragon_fly) || defined(_free_BSD) +#if defined(_dragon_fly) || defined(_free_BSD) || defined(_QNX) #define MMAP_FLAGS MAP_SHARED #else #define MMAP_FLAGS MAP_PRIVATE -- cgit v0.10.2 From 3a05be7575a46cf3b16abb77e1072afa13307a1b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:33 +0800 Subject: ACPICA: Utilities: Update for strtoul64 merger ACPICA commit 795e136d2ac77c1c8b091fba019b5fe36a44a323 Fixes a problem with the merger of the two internal versions of this function. Make the maximum integer width (32-bit or 64-bit) a parameter to the function so that it no longer exclusively uses the integer width specified in the DSDT/SSDT. ACPICA BZ 1260 Link: https://github.com/acpica/acpica/commit/795e136d Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index e43ab6f..7422ff7 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -175,7 +175,14 @@ void acpi_ut_strlwr(char *src_string); int acpi_ut_stricmp(char *string1, char *string2); -acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); +acpi_status +acpi_ut_strtoul64(char *string, + u32 base, u32 max_integer_byte_width, u64 *ret_integer); + +/* Values for max_integer_byte_width above */ + +#define ACPI_MAX32_BYTE_WIDTH 4 +#define ACPI_MAX64_BYTE_WIDTH 8 /* * utglobal - Global data structures and procedures diff --git a/drivers/acpi/acpica/dbconvert.c b/drivers/acpi/acpica/dbconvert.c index 68f4e0f4..c79c5fb 100644 --- a/drivers/acpi/acpica/dbconvert.c +++ b/drivers/acpi/acpica/dbconvert.c @@ -277,7 +277,9 @@ acpi_db_convert_to_object(acpi_object_type type, default: object->type = ACPI_TYPE_INTEGER; - status = acpi_ut_strtoul64(string, 16, &object->integer.value); + status = + acpi_ut_strtoul64(string, 16, acpi_gbl_integer_byte_width, + &object->integer.value); break; } diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index 0b9f2c1..d0d16da 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c @@ -124,7 +124,9 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, * of ACPI 3.0) is that the to_integer() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - status = acpi_ut_strtoul64((char *)pointer, flags, &result); + status = acpi_ut_strtoul64((char *)pointer, flags, + acpi_gbl_integer_byte_width, + &result); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index 878e8fb..256f56c 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c @@ -79,7 +79,8 @@ acpi_ns_convert_to_integer(union acpi_operand_object *original_object, /* String-to-Integer conversion */ status = acpi_ut_strtoul64(original_object->string.pointer, - ACPI_ANY_BASE, &value); + ACPI_ANY_BASE, + acpi_gbl_integer_byte_width, &value); if (ACPI_FAILURE(status)) { return (status); } diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c index d5c3adf..3465fe2 100644 --- a/drivers/acpi/acpica/utnonansi.c +++ b/drivers/acpi/acpica/utnonansi.c @@ -205,37 +205,41 @@ acpi_ut_safe_strncat(char *dest, * * FUNCTION: acpi_ut_strtoul64 * - * PARAMETERS: string - Null terminated string - * base - Radix of the string: 16 or ACPI_ANY_BASE; - * ACPI_ANY_BASE means 'in behalf of to_integer' - * ret_integer - Where the converted integer is returned + * PARAMETERS: string - Null terminated string + * base - Radix of the string: 16 or 10 or + * ACPI_ANY_BASE + * max_integer_byte_width - Maximum allowable integer,in bytes: + * 4 or 8 (32 or 64 bits) + * ret_integer - Where the converted integer is + * returned * * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the current mode - * of the interpreter. + * 32-bit or 64-bit conversion, depending on the input integer + * size (often the current mode of the interpreter). * - * NOTES: acpi_gbl_integer_byte_width should be set to the proper width. + * NOTES: Negative numbers are not supported, as they are not supported + * by ACPI. + * + * acpi_gbl_integer_byte_width should be set to the proper width. * For the core ACPICA code, this width depends on the DSDT - * version. For iASL, the default byte width is always 8. + * version. For iASL, the default byte width is always 8 for the + * parser, but error checking is performed later to flag cases + * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. * * Does not support Octal strings, not needed at this time. * - * There is an earlier version of the function after this one, - * below. It is slightly different than this one, and the two - * may eventually may need to be merged. (01/2016). - * ******************************************************************************/ -acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) +acpi_status +acpi_ut_strtoul64(char *string, + u32 base, u32 max_integer_byte_width, u64 *ret_integer) { u32 this_digit = 0; u64 return_value = 0; u64 quotient; u64 dividend; - u32 to_integer_op = (base == ACPI_ANY_BASE); - u32 mode32 = (acpi_gbl_integer_byte_width == 4); u8 valid_digits = 0; u8 sign_of0x = 0; u8 term = 0; @@ -244,6 +248,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) switch (base) { case ACPI_ANY_BASE: + case 10: case 16: break; @@ -265,9 +270,9 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) string++; } - if (to_integer_op) { + if (base == ACPI_ANY_BASE) { /* - * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. * We need to determine if it is decimal or hexadecimal. */ if ((*string == '0') && (tolower((int)*(string + 1)) == 'x')) { @@ -284,7 +289,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) /* Any string left? Check that '0x' is not followed by white space. */ if (!(*string) || isspace((int)*string) || *string == '\t') { - if (to_integer_op) { + if (base == ACPI_ANY_BASE) { goto error_exit; } else { goto all_done; @@ -292,10 +297,11 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) } /* - * Perform a 32-bit or 64-bit conversion, depending upon the current - * execution mode of the interpreter + * Perform a 32-bit or 64-bit conversion, depending upon the input + * byte width */ - dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + dividend = (max_integer_byte_width <= ACPI_MAX32_BYTE_WIDTH) ? + ACPI_UINT32_MAX : ACPI_UINT64_MAX; /* Main loop: convert the string to a 32- or 64-bit integer */ @@ -323,7 +329,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) } if (term) { - if (to_integer_op) { + if (base == ACPI_ANY_BASE) { goto error_exit; } else { break; @@ -338,12 +344,13 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) valid_digits++; - if (sign_of0x - && ((valid_digits > 16) - || ((valid_digits > 8) && mode32))) { + if (sign_of0x && ((valid_digits > 16) || + ((valid_digits > 8) + && (max_integer_byte_width <= + ACPI_MAX32_BYTE_WIDTH)))) { /* * This is to_integer operation case. - * No any restrictions for string-to-integer conversion, + * No restrictions for string-to-integer conversion, * see ACPI spec. */ goto error_exit; @@ -355,7 +362,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) "ient, NULL); if (return_value > quotient) { - if (to_integer_op) { + if (base == ACPI_ANY_BASE) { goto error_exit; } else { break; @@ -378,7 +385,8 @@ all_done: return_ACPI_STATUS(AE_OK); error_exit: - /* Base was set/validated above */ + + /* Base was set/validated above (10 or 16) */ if (base == 10) { return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); @@ -388,8 +396,7 @@ error_exit: } #ifdef _OBSOLETE_FUNCTIONS -/* TBD: use version in ACPICA main code base? */ -/* DONE: 01/2016 */ +/* Removed: 01/2016 */ /******************************************************************************* * diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index da44458..9c2db0e 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c @@ -286,7 +286,8 @@ int ap_dump_table_by_address(char *ascii_address) /* Convert argument to an integer physical address */ - status = acpi_ut_strtoul64(ascii_address, 0, &long_address); + status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &long_address); if (ACPI_FAILURE(status)) { acpi_log_error("%s: Could not convert to a physical address\n", ascii_address); diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c index c3c0915..7692e6b 100644 --- a/tools/power/acpi/tools/acpidump/apmain.c +++ b/tools/power/acpi/tools/acpidump/apmain.c @@ -209,7 +209,8 @@ static int ap_do_options(int argc, char **argv) case 'r': /* Dump tables from specified RSDP */ status = - acpi_ut_strtoul64(acpi_gbl_optarg, 0, + acpi_ut_strtoul64(acpi_gbl_optarg, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &gbl_rsdp_base); if (ACPI_FAILURE(status)) { acpi_log_error -- cgit v0.10.2 From 0dfaaa3d51df011c16279bb010bff90f45b6d62c Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:40 +0800 Subject: ACPICA: All: const keyword changes across the ACPICA source ACPICA commit a240cbb93647bddf525b3daf6e9d31b8b9bca34e Integrated most changes proposed by net_BSD. >From joerg@net_BSD.org (Joerg Sonnenberger) ACPICA BZ 732. Link: https://github.com/acpica/acpica/commit/a240cbb9 Link: https://bugs.acpica.org/show_bug.cgi?id=732 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index 993af9e..9e2e080 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h @@ -53,7 +53,7 @@ #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ struct acpi_db_command_info { - char *name; /* Command Name */ + const char *name; /* Command Name */ u8 min_args; /* Minimum arguments required */ }; @@ -64,7 +64,7 @@ struct acpi_db_command_help { }; struct acpi_db_argument_info { - char *name; /* Argument Name */ + const char *name; /* Argument Name */ }; struct acpi_db_execute_walk { diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 54b42a5..fded776 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -187,6 +187,8 @@ extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; extern const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS]; extern const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS]; extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; +extern const char acpi_gbl_lower_hex_digits[]; +extern const char acpi_gbl_upper_hex_digits[]; extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; #ifdef ACPI_DBG_TRACK_ALLOCATIONS diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h index bae1a35..8b09d28 100644 --- a/drivers/acpi/acpica/acinterp.h +++ b/drivers/acpi/acpica/acinterp.h @@ -67,7 +67,7 @@ typedef const struct acpi_exdump_info { u8 opcode; u8 offset; - char *name; + const char *name; } acpi_exdump_info; diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index 022d69c..f33a4ba 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h @@ -206,9 +206,10 @@ void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth); void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level); void -acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component); +acpi_ns_dump_pathname(acpi_handle handle, + const char *msg, u32 level, u32 component); -void acpi_ns_print_pathname(u32 num_segments, char *pathname); +void acpi_ns_print_pathname(u32 num_segments, const char *pathname); acpi_status acpi_ns_dump_one_object(acpi_handle obj_handle, diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h index 7da639d..fc30577 100644 --- a/drivers/acpi/acpica/acparser.h +++ b/drivers/acpi/acpica/acparser.h @@ -139,7 +139,7 @@ acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, */ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); -char *acpi_ps_get_opcode_name(u16 opcode); +const char *acpi_ps_get_opcode_name(u16 opcode); u8 acpi_ps_get_argument_count(u32 op_type); diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h index 5dd58be..83e9a29 100644 --- a/drivers/acpi/acpica/acresrc.h +++ b/drivers/acpi/acpica/acresrc.h @@ -124,7 +124,7 @@ typedef enum { typedef const struct acpi_rsdump_info { u8 opcode; u8 offset; - char *name; + const char *name; const char **pointer; } acpi_rsdump_info; @@ -209,7 +209,7 @@ acpi_rs_get_prs_method_data(struct acpi_namespace_node *node, acpi_status acpi_rs_get_method_data(acpi_handle handle, - char *path, struct acpi_buffer *ret_buffer); + const char *path, struct acpi_buffer *ret_buffer); acpi_status acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h index b3b386e..6235642 100644 --- a/drivers/acpi/acpica/acstruct.h +++ b/drivers/acpi/acpica/acstruct.h @@ -184,7 +184,7 @@ struct acpi_evaluate_info { /* The first 3 elements are passed by the caller to acpi_ns_evaluate */ struct acpi_namespace_node *prefix_node; /* Input: starting node */ - char *relative_pathname; /* Input: path relative to prefix_node */ + const char *relative_pathname; /* Input: path relative to prefix_node */ union acpi_operand_object **parameters; /* Input: argument list */ struct acpi_namespace_node *node; /* Resolved node (prefix_node:relative_pathname) */ diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 7422ff7..4ff971c 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -273,7 +273,8 @@ acpi_ut_trace(u32 line_number, void acpi_ut_trace_ptr(u32 line_number, const char *function_name, - const char *module_name, u32 component_id, void *pointer); + const char *module_name, + u32 component_id, const void *pointer); void acpi_ut_trace_u32(u32 line_number, @@ -283,7 +284,8 @@ acpi_ut_trace_u32(u32 line_number, void acpi_ut_trace_str(u32 line_number, const char *function_name, - const char *module_name, u32 component_id, char *string); + const char *module_name, + u32 component_id, const char *string); void acpi_ut_exit(u32 line_number, @@ -342,12 +344,12 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list); */ acpi_status acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, - char *path, + const char *path, u32 expected_return_btypes, union acpi_operand_object **return_desc); acpi_status -acpi_ut_evaluate_numeric_object(char *object_name, +acpi_ut_evaluate_numeric_object(const char *object_name, struct acpi_namespace_node *device_node, u64 *value); @@ -533,7 +535,7 @@ void acpi_ut_set_integer_width(u8 revision); void acpi_ut_display_init_pathname(u8 type, struct acpi_namespace_node *obj_handle, - char *path); + const char *path); #endif /* @@ -635,7 +637,7 @@ void acpi_ut_dump_allocation_info(void); void acpi_ut_dump_allocations(u32 component, const char *module); acpi_status -acpi_ut_create_list(char *list_name, +acpi_ut_create_list(const char *list_name, u16 object_size, struct acpi_memory_list **return_cache); #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c index 417c02a..f53cb30 100644 --- a/drivers/acpi/acpica/dbinput.c +++ b/drivers/acpi/acpica/dbinput.c @@ -57,12 +57,12 @@ static u32 acpi_db_get_line(char *input_buffer); static u32 acpi_db_match_command(char *user_command); -static void acpi_db_display_command_info(char *command, u8 display_all); +static void acpi_db_display_command_info(const char *command, u8 display_all); static void acpi_db_display_help(char *command); static u8 -acpi_db_match_command_help(char *command, +acpi_db_match_command_help(const char *command, const struct acpi_db_command_help *help); /* @@ -348,7 +348,7 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = { ******************************************************************************/ static u8 -acpi_db_match_command_help(char *command, +acpi_db_match_command_help(const char *command, const struct acpi_db_command_help *help) { char *invocation = help->invocation; @@ -402,7 +402,7 @@ acpi_db_match_command_help(char *command, * ******************************************************************************/ -static void acpi_db_display_command_info(char *command, u8 display_all) +static void acpi_db_display_command_info(const char *command, u8 display_all) { const struct acpi_db_command_help *next; u8 matched; @@ -656,8 +656,9 @@ static u32 acpi_db_match_command(char *user_command) } for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++) { - if (strstr(acpi_gbl_db_commands[i].name, user_command) == - acpi_gbl_db_commands[i].name) { + if (strstr + (ACPI_CAST_PTR(char, acpi_gbl_db_commands[i].name), + user_command) == acpi_gbl_db_commands[i].name) { return (i); } } diff --git a/drivers/acpi/acpica/dbutils.c b/drivers/acpi/acpica/dbutils.c index b37a2c7..ae80106 100644 --- a/drivers/acpi/acpica/dbutils.c +++ b/drivers/acpi/acpica/dbutils.c @@ -56,8 +56,6 @@ acpi_status acpi_db_second_pass_parse(union acpi_parse_object *root); void acpi_db_dump_buffer(u32 address); #endif -static char *gbl_hex_to_ascii = "0123456789ABCDEF"; - /******************************************************************************* * * FUNCTION: acpi_db_match_argument @@ -82,8 +80,9 @@ acpi_db_match_argument(char *user_argument, } for (i = 0; arguments[i].name; i++) { - if (strstr(arguments[i].name, user_argument) == - arguments[i].name) { + if (strstr(ACPI_CAST_PTR(char, arguments[i].name), + ACPI_CAST_PTR(char, + user_argument)) == arguments[i].name) { return (i); } } @@ -339,7 +338,7 @@ void acpi_db_uint32_to_hex_string(u32 value, char *buffer) buffer[8] = '\0'; for (i = 7; i >= 0; i--) { - buffer[i] = gbl_hex_to_ascii[value & 0x0F]; + buffer[i] = acpi_gbl_upper_hex_digits[value & 0x0F]; value = value >> 4; } } diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 63924d1..17d61c6 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c @@ -538,7 +538,8 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj, void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj) { - acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; + const acpi_name *reg_name_ptr = + ACPI_CAST_PTR(acpi_name, METHOD_NAME__REG); struct acpi_namespace_node *method_node; struct acpi_namespace_node *node; union acpi_operand_object *region_obj2; diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c index ee30974..fce6b2e 100644 --- a/drivers/acpi/acpica/exdump.c +++ b/drivers/acpi/acpica/exdump.c @@ -55,9 +55,9 @@ ACPI_MODULE_NAME("exdump") */ #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* Local prototypes */ -static void acpi_ex_out_string(char *title, char *value); +static void acpi_ex_out_string(const char *title, const char *value); -static void acpi_ex_out_pointer(char *title, void *value); +static void acpi_ex_out_pointer(const char *title, const void *value); static void acpi_ex_dump_object(union acpi_operand_object *obj_desc, @@ -365,8 +365,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, struct acpi_exdump_info *info) { u8 *target; - char *name; - const char *reference_name; + const char *name; u8 count; union acpi_operand_object *start; union acpi_operand_object *data = NULL; @@ -459,9 +458,9 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, case ACPI_EXD_REFERENCE: - reference_name = acpi_ut_get_reference_name(obj_desc); acpi_ex_out_string("Class Name", - ACPI_CAST_PTR(char, reference_name)); + acpi_ut_get_reference_name + (obj_desc)); acpi_ex_dump_reference_obj(obj_desc); break; @@ -934,12 +933,12 @@ acpi_ex_dump_operands(union acpi_operand_object **operands, * ******************************************************************************/ -static void acpi_ex_out_string(char *title, char *value) +static void acpi_ex_out_string(const char *title, const char *value) { acpi_os_printf("%20s : %s\n", title, value); } -static void acpi_ex_out_pointer(char *title, void *value) +static void acpi_ex_out_pointer(const char *title, const void *value) { acpi_os_printf("%20s : %p\n", title, value); } diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index a01ddb3..7caaaf3 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -504,9 +504,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) * Evaluate the \_Sx namespace object containing the register values * for this state */ - info->relative_pathname = ACPI_CAST_PTR(char, - acpi_gbl_sleep_state_names - [sleep_state]); + info->relative_pathname = acpi_gbl_sleep_state_names[sleep_state]; status = acpi_ns_evaluate(info); if (ACPI_FAILURE(status)) { diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 697af81..426a630 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -107,9 +107,10 @@ acpi_status acpi_ns_root_initialize(void) continue; } - status = acpi_ns_lookup(NULL, init_val->name, init_val->type, - ACPI_IMODE_LOAD_PASS2, - ACPI_NS_NO_UPSEARCH, NULL, &new_node); + status = + acpi_ns_lookup(NULL, (char *)init_val->name, init_val->type, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &new_node); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Could not create predefined name %s", diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index af236e3..ce1f860 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c @@ -81,7 +81,7 @@ acpi_ns_get_max_depth(acpi_handle obj_handle, * ******************************************************************************/ -void acpi_ns_print_pathname(u32 num_segments, char *pathname) +void acpi_ns_print_pathname(u32 num_segments, const char *pathname) { u32 i; @@ -114,6 +114,9 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname) acpi_os_printf("]\n"); } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/* Not used at this time, perhaps later */ + /******************************************************************************* * * FUNCTION: acpi_ns_dump_pathname @@ -131,7 +134,8 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname) ******************************************************************************/ void -acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component) +acpi_ns_dump_pathname(acpi_handle handle, + const char *msg, u32 level, u32 component) { ACPI_FUNCTION_TRACE(ns_dump_pathname); @@ -148,6 +152,7 @@ acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component) acpi_os_printf("\n"); return_VOID; } +#endif /******************************************************************************* * diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c index cfd17a4..177b05b 100644 --- a/drivers/acpi/acpica/psopinfo.c +++ b/drivers/acpi/acpica/psopinfo.c @@ -158,7 +158,7 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) * ******************************************************************************/ -char *acpi_ps_get_opcode_name(u16 opcode) +const char *acpi_ps_get_opcode_name(u16 opcode) { #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c index 23a17c8..5ffdb56 100644 --- a/drivers/acpi/acpica/rsdump.c +++ b/drivers/acpi/acpica/rsdump.c @@ -52,17 +52,17 @@ ACPI_MODULE_NAME("rsdump") * All functions in this module are used by the AML Debugger only */ /* Local prototypes */ -static void acpi_rs_out_string(char *title, char *value); +static void acpi_rs_out_string(const char *title, const char *value); -static void acpi_rs_out_integer8(char *title, u8 value); +static void acpi_rs_out_integer8(const char *title, u8 value); -static void acpi_rs_out_integer16(char *title, u16 value); +static void acpi_rs_out_integer16(const char *title, u16 value); -static void acpi_rs_out_integer32(char *title, u32 value); +static void acpi_rs_out_integer32(const char *title, u32 value); -static void acpi_rs_out_integer64(char *title, u64 value); +static void acpi_rs_out_integer64(const char *title, u64 value); -static void acpi_rs_out_title(char *title); +static void acpi_rs_out_title(const char *title); static void acpi_rs_dump_byte_list(u16 length, u8 *data); @@ -208,7 +208,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) { u8 *target = NULL; u8 *previous_target; - char *name; + const char *name; u8 count; /* First table entry must contain the table length (# of table entries) */ @@ -248,10 +248,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) case ACPI_RSD_UINT8: if (table->pointer) { - acpi_rs_out_string(name, ACPI_CAST_PTR(char, - table-> - pointer - [*target])); + acpi_rs_out_string(name, + table->pointer[*target]); } else { acpi_rs_out_integer8(name, ACPI_GET8(target)); } @@ -276,26 +274,20 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) case ACPI_RSD_1BITFLAG: - acpi_rs_out_string(name, ACPI_CAST_PTR(char, - table-> - pointer[*target & - 0x01])); + acpi_rs_out_string(name, + table->pointer[*target & 0x01]); break; case ACPI_RSD_2BITFLAG: - acpi_rs_out_string(name, ACPI_CAST_PTR(char, - table-> - pointer[*target & - 0x03])); + acpi_rs_out_string(name, + table->pointer[*target & 0x03]); break; case ACPI_RSD_3BITFLAG: - acpi_rs_out_string(name, ACPI_CAST_PTR(char, - table-> - pointer[*target & - 0x07])); + acpi_rs_out_string(name, + table->pointer[*target & 0x07]); break; case ACPI_RSD_SHORTLIST: @@ -481,7 +473,7 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_out_string(char *title, char *value) +static void acpi_rs_out_string(const char *title, const char *value) { acpi_os_printf("%27s : %s", title, value); @@ -491,30 +483,30 @@ static void acpi_rs_out_string(char *title, char *value) acpi_os_printf("\n"); } -static void acpi_rs_out_integer8(char *title, u8 value) +static void acpi_rs_out_integer8(const char *title, u8 value) { acpi_os_printf("%27s : %2.2X\n", title, value); } -static void acpi_rs_out_integer16(char *title, u16 value) +static void acpi_rs_out_integer16(const char *title, u16 value) { acpi_os_printf("%27s : %4.4X\n", title, value); } -static void acpi_rs_out_integer32(char *title, u32 value) +static void acpi_rs_out_integer32(const char *title, u32 value) { acpi_os_printf("%27s : %8.8X\n", title, value); } -static void acpi_rs_out_integer64(char *title, u64 value) +static void acpi_rs_out_integer64(const char *title, u64 value) { acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); } -static void acpi_rs_out_title(char *title) +static void acpi_rs_out_title(const char *title) { acpi_os_printf("%27s : ", title); diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c index cf06e49..e0d6023 100644 --- a/drivers/acpi/acpica/rsutils.c +++ b/drivers/acpi/acpica/rsutils.c @@ -671,7 +671,7 @@ acpi_rs_get_aei_method_data(struct acpi_namespace_node *node, acpi_status acpi_rs_get_method_data(acpi_handle handle, - char *path, struct acpi_buffer *ret_buffer) + const char *path, struct acpi_buffer *ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index f63f3fd..635d951 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -53,7 +53,7 @@ static void acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, u8 space_id, u8 byte_width, - u64 address, char *register_name, u8 flags); + u64 address, const char *register_name, u8 flags); static void acpi_tb_convert_fadt(void); @@ -65,7 +65,7 @@ acpi_tb_select_address(char *register_name, u32 address32, u64 address64); /* Table for conversion of FADT to common internal format and FADT validation */ typedef struct acpi_fadt_info { - char *name; + const char *name; u16 address64; u16 address32; u16 length; @@ -192,7 +192,7 @@ static void acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, u8 space_id, u8 byte_width, - u64 address, char *register_name, u8 flags) + u64 address, const char *register_name, u8 flags) { u8 bit_width; @@ -468,7 +468,7 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) static void acpi_tb_convert_fadt(void) { - char *name; + const char *name; struct acpi_generic_address *address64; u32 address32; u8 length; diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 1cfc5f6..5744222 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c @@ -51,13 +51,9 @@ ACPI_MODULE_NAME("utdebug") #ifdef ACPI_DEBUG_OUTPUT -static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF; -static char *acpi_gbl_fn_entry_str = "----Entry"; -static char *acpi_gbl_fn_exit_str = "----Exit-"; - -/* Local prototypes */ - -static const char *acpi_ut_trim_function_name(const char *function_name); +static acpi_thread_id acpi_gbl_previous_thread_id = (acpi_thread_id) 0xFFFFFFFF; +static const char *acpi_gbl_function_entry_prefix = "----Entry"; +static const char *acpi_gbl_function_exit_prefix = "----Exit-"; /******************************************************************************* * @@ -178,14 +174,14 @@ acpi_debug_print(u32 requested_debug_level, * Thread tracking and context switch notification */ thread_id = acpi_os_get_thread_id(); - if (thread_id != acpi_gbl_prev_thread_id) { + if (thread_id != acpi_gbl_previous_thread_id) { if (ACPI_LV_THREADS & acpi_dbg_level) { acpi_os_printf ("\n**** Context Switch from TID %u to TID %u ****\n\n", - (u32)acpi_gbl_prev_thread_id, (u32)thread_id); + (u32)acpi_gbl_previous_thread_id, (u32)thread_id); } - acpi_gbl_prev_thread_id = thread_id; + acpi_gbl_previous_thread_id = thread_id; acpi_gbl_nesting_level = 0; } @@ -287,7 +283,8 @@ acpi_ut_trace(u32 line_number, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, - component_id, "%s\n", acpi_gbl_fn_entry_str); + component_id, "%s\n", + acpi_gbl_function_entry_prefix); } } @@ -312,7 +309,8 @@ ACPI_EXPORT_SYMBOL(acpi_ut_trace) void acpi_ut_trace_ptr(u32 line_number, const char *function_name, - const char *module_name, u32 component_id, void *pointer) + const char *module_name, + u32 component_id, const void *pointer) { acpi_gbl_nesting_level++; @@ -323,8 +321,8 @@ acpi_ut_trace_ptr(u32 line_number, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, - component_id, "%s %p\n", acpi_gbl_fn_entry_str, - pointer); + component_id, "%s %p\n", + acpi_gbl_function_entry_prefix, pointer); } } @@ -348,7 +346,7 @@ acpi_ut_trace_ptr(u32 line_number, void acpi_ut_trace_str(u32 line_number, const char *function_name, - const char *module_name, u32 component_id, char *string) + const char *module_name, u32 component_id, const char *string) { acpi_gbl_nesting_level++; @@ -359,8 +357,8 @@ acpi_ut_trace_str(u32 line_number, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, - component_id, "%s %s\n", acpi_gbl_fn_entry_str, - string); + component_id, "%s %s\n", + acpi_gbl_function_entry_prefix, string); } } @@ -396,7 +394,7 @@ acpi_ut_trace_u32(u32 line_number, acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, component_id, "%s %08X\n", - acpi_gbl_fn_entry_str, integer); + acpi_gbl_function_entry_prefix, integer); } } @@ -427,7 +425,8 @@ acpi_ut_exit(u32 line_number, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, - component_id, "%s\n", acpi_gbl_fn_exit_str); + component_id, "%s\n", + acpi_gbl_function_exit_prefix); } if (acpi_gbl_nesting_level) { @@ -467,14 +466,14 @@ acpi_ut_status_exit(u32 line_number, acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, component_id, "%s %s\n", - acpi_gbl_fn_exit_str, + acpi_gbl_function_exit_prefix, acpi_format_exception(status)); } else { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, component_id, "%s ****Exception****: %s\n", - acpi_gbl_fn_exit_str, + acpi_gbl_function_exit_prefix, acpi_format_exception(status)); } } @@ -514,7 +513,7 @@ acpi_ut_value_exit(u32 line_number, acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, component_id, "%s %8.8X%8.8X\n", - acpi_gbl_fn_exit_str, + acpi_gbl_function_exit_prefix, ACPI_FORMAT_UINT64(value)); } @@ -552,8 +551,8 @@ acpi_ut_ptr_exit(u32 line_number, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { acpi_debug_print(ACPI_LV_FUNCTIONS, line_number, function_name, module_name, - component_id, "%s %p\n", acpi_gbl_fn_exit_str, - ptr); + component_id, "%s %p\n", + acpi_gbl_function_exit_prefix, ptr); } if (acpi_gbl_nesting_level) { diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index 17b9f3e..7bad13f 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c @@ -69,7 +69,7 @@ ACPI_MODULE_NAME("uteval") acpi_status acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, - char *path, + const char *path, u32 expected_return_btypes, union acpi_operand_object **return_desc) { @@ -204,7 +204,7 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ut_evaluate_numeric_object(char *object_name, +acpi_ut_evaluate_numeric_object(const char *object_name, struct acpi_namespace_node *device_node, u64 *value) { diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index d45899c..dd3fd7f 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -80,6 +80,11 @@ const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS] = { "_S4D" }; +/* Hex-to-ascii */ + +const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef"; +const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF"; + /******************************************************************************* * * Namespace globals diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index d938c27..389de3b 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c @@ -361,7 +361,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object, void acpi_ut_display_init_pathname(u8 type, struct acpi_namespace_node *obj_handle, - char *path) + const char *path) { acpi_status status; struct acpi_buffer buffer; diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c index 8c218ad..208d71a 100644 --- a/drivers/acpi/acpica/utprint.c +++ b/drivers/acpi/acpica/utprint.c @@ -67,11 +67,6 @@ static char *acpi_ut_format_number(char *string, static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper); -/* Module globals */ - -static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef"; -static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF"; - /******************************************************************************* * * FUNCTION: acpi_ut_bound_string_length diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c index 60c406a..0df07df 100644 --- a/drivers/acpi/acpica/uttrack.c +++ b/drivers/acpi/acpica/uttrack.c @@ -90,7 +90,7 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, ******************************************************************************/ acpi_status -acpi_ut_create_list(char *list_name, +acpi_ut_create_list(const char *list_name, u16 object_size, struct acpi_memory_list **return_cache) { struct acpi_memory_list *cache; diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 140886e..b9a8b72 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -995,7 +995,7 @@ struct acpi_buffer { * Predefined Namespace items */ struct acpi_predefined_names { - char *name; + const char *name; u8 type; char *val; }; @@ -1228,7 +1228,7 @@ struct acpi_mem_space_context { * struct acpi_memory_list is used only if the ACPICA local cache is enabled */ struct acpi_memory_list { - char *list_name; + const char *list_name; void *list_head; u16 object_size; u16 max_depth; -- cgit v0.10.2 From 7447bc1e69bafab72ef69a7f054bb1e5f9ff908d Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:40:48 +0800 Subject: ACPICA: iASL/Disassembler: Improve handling of unresolved methods ACPICA commit 16cd0872a070c8d3b16b8b13c1fc90a443a6b6fe If the definition of a control method cannot be found (probably it is in another module/SSDT), the disassembler must try to guess at the number of arguments to that method. This change improves the guessing heuristic. Link: https://github.com/acpica/acpica/commit/16cd0872 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 9562a10..083b16a 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -1096,6 +1096,7 @@ struct acpi_external_list { #define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */ #define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */ #define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */ +#define ACPI_EXT_ORIGIN_FROM_OPCODE 0x10 /* External came from a External() opcode */ struct acpi_external_file { char *path; -- cgit v0.10.2 From a8d1e1c063b0b1c91a9415f5cb09e37a75bce809 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:40:56 +0800 Subject: ACPICA: Utilities: Add ACPI_IS_POWER_OF_TWO() ACPICA commit cbcb77565c5032dd48e19b3a8a8b8704c5f29faf This patch adds a macro ACPI_IS_POWER_OF_TWO, which can be used to detect if a number is a power of two. Lv Zheng. Link: https://github.com/acpica/acpica/commit/cbcb7756 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index 411c18b..b461f55 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -260,6 +260,10 @@ #define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1)) +/* Generic (power-of-two) rounding */ + +#define ACPI_IS_POWER_OF_TWO(a) (((a) & ((a) - 1)) == 0) + /* * Bitmask creation * Bit positions start at zero. -- cgit v0.10.2 From 0461f34e16b39b083f289d27d2355df9d5ba1420 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:02 +0800 Subject: Utilities: Fix missing parentheses in ACPI_GET_BITS()/ACPI_SET_BITS() Some compilers require parentheses to be enforced in the macro definition, so that the macro caller side can be simpler. This patch fixes this kind of macro issue in ACPI_SET_BITS()/ACPI_GET_BITS(). Lv Zheng. Link: https://bugs.acpica.org/show_bug.cgi?id=1268 Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index b461f55..73f6653 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -287,10 +287,10 @@ /* Generic bitfield macros and masks */ #define ACPI_GET_BITS(source_ptr, position, mask) \ - ((*source_ptr >> position) & mask) + ((*(source_ptr) >> (position)) & (mask)) #define ACPI_SET_BITS(target_ptr, position, mask, value) \ - (*target_ptr |= ((value & mask) << position)) + (*(target_ptr) |= (((value) & (mask)) << (position))) #define ACPI_1BIT_MASK 0x00000001 #define ACPI_2BIT_MASK 0x00000003 -- cgit v0.10.2 From 920de6ebfab865a5bb2bcc60f6998aa270300b95 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:09 +0800 Subject: ACPICA: Hardware: Enhance acpi_hw_validate_register() with access_width/bit_offset awareness ACPICA commit 997a90f810a4cb78604ef2e187611a181b498286 This patch enhances acpi_hw_validate_register() to sanitize register accesses with awareness of access_width and bit_offset. Lv Zheng. Link: https://github.com/acpica/acpica/commit/997a90f8 Link: https://bugs.acpica.org/show_bug.cgi?id=1240 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 5ba0498..035fb52 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -83,6 +83,8 @@ acpi_status acpi_hw_validate_register(struct acpi_generic_address *reg, u8 max_bit_width, u64 *address) { + u8 bit_width; + u8 access_width; /* Must have a valid pointer to a GAS structure */ @@ -109,23 +111,26 @@ acpi_hw_validate_register(struct acpi_generic_address *reg, return (AE_SUPPORT); } - /* Validate the bit_width */ + /* Validate the access_width */ - if ((reg->bit_width != 8) && - (reg->bit_width != 16) && - (reg->bit_width != 32) && (reg->bit_width != max_bit_width)) { + if (reg->access_width > 4) { ACPI_ERROR((AE_INFO, - "Unsupported register bit width: 0x%X", - reg->bit_width)); + "Unsupported register access width: 0x%X", + reg->access_width)); return (AE_SUPPORT); } - /* Validate the bit_offset. Just a warning for now. */ + /* Validate the bit_width, convert access_width into number of bits */ - if (reg->bit_offset != 0) { + access_width = reg->access_width ? reg->access_width : 1; + access_width = 1 << (access_width + 2); + bit_width = + ACPI_ROUND_UP(reg->bit_offset + reg->bit_width, access_width); + if (max_bit_width < bit_width) { ACPI_WARNING((AE_INFO, - "Unsupported register bit offset: 0x%X", - reg->bit_offset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + max_bit_width, bit_width)); + return (AE_SUPPORT); } return (AE_OK); -- cgit v0.10.2 From 78542058f522076c888822735d8fc9bd93cfd586 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:32 +0800 Subject: ACPICA: Interpreter: Fix wrong conditions for acpi_ev_install_region_handlers() invocation ACPICA commit 9a6ecc9ec9ee067cad51eec539230bf494421d76 Since AE_ALREADY_EXISTS has already been converted to AE_OK in acpi_ev_install_region_handlers(), this patch simplies a return value check. Lv Zheng. Link: https://github.com/acpica/acpica/commit/9a6ecc9e Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c index 3151968..ac71abc 100644 --- a/drivers/acpi/acpica/tbxfload.c +++ b/drivers/acpi/acpica/tbxfload.c @@ -82,7 +82,7 @@ acpi_status __init acpi_load_tables(void) * their customized default region handlers. */ status = acpi_ev_install_region_handlers(); - if (ACPI_FAILURE(status) && status != AE_ALREADY_EXISTS) { + if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "During Region initialization")); return_ACPI_STATUS(status); -- cgit v0.10.2 From ca4fc02714f046cbdc8c0ee4af6733b6231e57dc Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:39 +0800 Subject: ACPICA: Tables: Fix wrong MLC condition for dynamic table loading ACPICA commit 5798cd6171ea38bcf4594d0ccc78870784776ba5 The patch corrects wrong condition before group MLC is disabled. Link: https://github.com/acpica/acpica/commit/5798cd61 Link: https://bugs.acpica.org/show_bug.cgi?id=1262 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index f741613..a1d177d 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c @@ -118,7 +118,9 @@ acpi_ex_add_table(u32 table_index, /* Execute any module-level code that was found in the table */ acpi_ex_exit_interpreter(); - acpi_ns_exec_module_code_list(); + if (acpi_gbl_group_module_level_code) { + acpi_ns_exec_module_code_list(); + } acpi_ex_enter_interpreter(); /* -- cgit v0.10.2 From d1461a1b506e4a2df9f703c5f39f765b65c9672e Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:47 +0800 Subject: ACPICA: Events: Fix an issue that _REG association can happen before namespace is initialized ACPICA commit c508f8592efaa0d8197f26d7fee6382c5ac8e383 Current code flow cannot ensure _REG association can happen after the namespace is initialized, so we move _REG association to where _REG was about to run to fix this issue. This issue is detected when acpi_ev_initialize_region() is invoked during the table loading. And this is one of the most important the root cause why ACPICA table loading is split into 2 load passes. Lv Zheng. Link: https://github.com/acpica/acpica/commit/c508f859 Link: https://bugs.acpica.org/show_bug.cgi?id=1252 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index 010cf81..17f2217 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h @@ -198,8 +198,6 @@ void acpi_ev_detach_region(union acpi_operand_object *region_obj, u8 acpi_ns_is_locked); -void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj); - void acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, acpi_adr_space_type space_id, u32 function); diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 17d61c6..4c6f795 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c @@ -526,82 +526,59 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj, /******************************************************************************* * - * FUNCTION: acpi_ev_associate_reg_method + * FUNCTION: acpi_ev_execute_reg_method * * PARAMETERS: region_obj - Region object + * function - Passed to _REG: On (1) or Off (0) * * RETURN: Status * - * DESCRIPTION: Find and associate _REG method to a region + * DESCRIPTION: Execute _REG method for a region * ******************************************************************************/ -void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj) +acpi_status +acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) { + struct acpi_evaluate_info *info; + union acpi_operand_object *args[3]; + union acpi_operand_object *region_obj2; const acpi_name *reg_name_ptr = ACPI_CAST_PTR(acpi_name, METHOD_NAME__REG); struct acpi_namespace_node *method_node; struct acpi_namespace_node *node; - union acpi_operand_object *region_obj2; acpi_status status; - ACPI_FUNCTION_TRACE(ev_associate_reg_method); + ACPI_FUNCTION_TRACE(ev_execute_reg_method); + + if (!acpi_gbl_namespace_initialized || + region_obj->region.handler == NULL) { + return_ACPI_STATUS(AE_OK); + } region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { - return_VOID; + return_ACPI_STATUS(AE_NOT_EXIST); } + /* + * Find any "_REG" method associated with this region definition. + * The method should always be updated as this function may be + * invoked after a namespace change. + */ node = region_obj->region.node->parent; - - /* Find any "_REG" method associated with this region definition */ - status = acpi_ns_search_one_scope(*reg_name_ptr, node, ACPI_TYPE_METHOD, &method_node); if (ACPI_SUCCESS(status)) { /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed + * The _REG method is optional and there can be only one per + * region definition. This will be executed when the handler is + * attached or removed. */ region_obj2->extra.method_REG = method_node; } - - return_VOID; -} - -/******************************************************************************* - * - * FUNCTION: acpi_ev_execute_reg_method - * - * PARAMETERS: region_obj - Region object - * function - Passed to _REG: On (1) or Off (0) - * - * RETURN: Status - * - * DESCRIPTION: Execute _REG method for a region - * - ******************************************************************************/ - -acpi_status -acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) -{ - struct acpi_evaluate_info *info; - union acpi_operand_object *args[3]; - union acpi_operand_object *region_obj2; - acpi_status status; - - ACPI_FUNCTION_TRACE(ev_execute_reg_method); - - region_obj2 = acpi_ns_get_secondary_object(region_obj); - if (!region_obj2) { - return_ACPI_STATUS(AE_NOT_EXIST); - } - - if (region_obj2->extra.method_REG == NULL || - region_obj->region.handler == NULL || - !acpi_gbl_namespace_initialized) { + if (region_obj2->extra.method_REG == NULL) { return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index fda869c..6972ab4 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c @@ -518,7 +518,6 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, return_ACPI_STATUS(AE_OK); } - acpi_ev_associate_reg_method(region_obj); region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED; node = region_obj->region.node->parent; -- cgit v0.10.2 From 2d3349de8072baf2c2dd096664fa818d5339bb5a Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 09:41:54 +0800 Subject: ACPICA: Namespace: Reorder \_SB._INI to make sure it is evaluated before _REG evaluations ACPICA commit f005ee6b90d152c1f499efcca6b771a93903cb55 This patch splits \_SB._INI evaluation from device initialization code, so that it can be performed before PCI_Config _REG evaluations. This is required for the device enumeration process. Some named objects are initialized in \_SB._INI and PCI_Config _REG evaluations may use uninitialized named objects because of the order issue. This must be fixed before fixing ECDT order issue. There are existing tables allowing ECDT EC to be used for the entire device enumeration process, but the enabling of ECDT EC is done in \_SB._INI. Thus \_SB._INI must be the first control method evaluated in the device enumeration process. Normally, the order should be automatically ensured by the device enumeration process itself (for example, PCI_Config _REGs are evaluated by the PCI bus driver when the driver is probed by the enumeration process), but since the process is split on Linux (partially done in Linux, partially done in ACPICA), we need to ensure this with special logics in order to be regression safe. Lv Zheng. Link: https://github.com/acpica/acpica/commit/f005ee6b Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c index 2de8adb..36643a8 100644 --- a/drivers/acpi/acpica/nsinit.c +++ b/drivers/acpi/acpica/nsinit.c @@ -140,6 +140,7 @@ acpi_status acpi_ns_initialize_devices(u32 flags) { acpi_status status = AE_OK; struct acpi_device_walk_info info; + acpi_handle handle; ACPI_FUNCTION_TRACE(ns_initialize_devices); @@ -190,6 +191,27 @@ acpi_status acpi_ns_initialize_devices(u32 flags) if (ACPI_SUCCESS(status)) { info.num_INI++; } + + /* + * Execute \_SB._INI. + * There appears to be a strict order requirement for \_SB._INI, + * which should be evaluated before any _REG evaluations. + */ + status = acpi_get_handle(NULL, "\\_SB", &handle); + if (ACPI_SUCCESS(status)) { + memset(info.evaluate_info, 0, + sizeof(struct acpi_evaluate_info)); + info.evaluate_info->prefix_node = handle; + info.evaluate_info->relative_pathname = + METHOD_NAME__INI; + info.evaluate_info->parameters = NULL; + info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE; + + status = acpi_ns_evaluate(info.evaluate_info); + if (ACPI_SUCCESS(status)) { + info.num_INI++; + } + } } /* @@ -198,6 +220,12 @@ acpi_status acpi_ns_initialize_devices(u32 flags) * Note: Any objects accessed by the _REG methods will be automatically * initialized, even if they contain executable AML (see the call to * acpi_ns_initialize_objects below). + * + * Note: According to the ACPI specification, we actually needn't execute + * _REG for system_memory/system_io operation regions, but for PCI_Config + * operation regions, it is required to evaluate _REG for those on a PCI + * root bus that doesn't contain _BBN object. So this code is kept here + * in order not to break things. */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -592,32 +620,37 @@ acpi_ns_init_one_device(acpi_handle obj_handle, * Note: We know there is an _INI within this subtree, but it may not be * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname - (ACPI_TYPE_METHOD, device_node, METHOD_NAME__INI)); - - memset(info, 0, sizeof(struct acpi_evaluate_info)); - info->prefix_node = device_node; - info->relative_pathname = METHOD_NAME__INI; - info->parameters = NULL; - info->flags = ACPI_IGNORE_RETURN_VALUE; - - status = acpi_ns_evaluate(info); - if (ACPI_SUCCESS(status)) { - walk_info->num_INI++; - } + if (!ACPI_COMPARE_NAME(device_node->name.ascii, "_SB_") || + device_node->parent != acpi_gbl_root_node) { + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_METHOD, device_node, + METHOD_NAME__INI)); + + memset(info, 0, sizeof(struct acpi_evaluate_info)); + info->prefix_node = device_node; + info->relative_pathname = METHOD_NAME__INI; + info->parameters = NULL; + info->flags = ACPI_IGNORE_RETURN_VALUE; + + status = acpi_ns_evaluate(info); + if (ACPI_SUCCESS(status)) { + walk_info->num_INI++; + } #ifdef ACPI_DEBUG_OUTPUT - else if (status != AE_NOT_FOUND) { + else if (status != AE_NOT_FOUND) { - /* Ignore error and move on to next device */ + /* Ignore error and move on to next device */ - char *scope_name = - acpi_ns_get_normalized_pathname(device_node, TRUE); + char *scope_name = + acpi_ns_get_normalized_pathname(device_node, TRUE); - ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution", - scope_name)); - ACPI_FREE(scope_name); - } + ACPI_EXCEPTION((AE_INFO, status, + "during %s._INI execution", + scope_name)); + ACPI_FREE(scope_name); + } #endif + } /* Ignore errors from above */ -- cgit v0.10.2 From 8804f2525a56261b93576a1900185ac2691d138a Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 24 Mar 2016 09:42:01 +0800 Subject: ACPICA: Update version to 20160318 ACPICA commit e714615fda31cce3df9cfd95ee03c1f2c74b2b5e Version 20160318. Link: https://github.com/acpica/acpica/commit/e714615f Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 1755697..83583a2 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160108 +#define ACPI_CA_VERSION 0x20160318 #include #include -- cgit v0.10.2 From 3db80c230da15ceb1a526438b458058abcd53800 Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 7 Feb 2016 10:00:31 -0500 Subject: ACPI: implement Generic Event Device Generic Event Device described in ACPI 6.1 allows platforms to handle platform interrupts in ACPI ASL statements. It borrows constructs like _EVT from GPIO events. All interrupts are listed in _CRS and the handler is written in _EVT method. Here is an example. Device (GED0) { Name (_HID, "ACPI0013") Name (_UID, 0) Name(_CRS, ResourceTemplate () { Interrupt(ResourceConsumer, Edge, ActiveHigh, Shared, , , ) {123} }) Method (_EVT, 1) { if (Lequal(123, Arg0)) { } } } Wake capability has not been implemented yet. Signed-off-by: Sinan Kaya Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index edeb2d1..5a65f85 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -47,6 +47,7 @@ acpi-$(CONFIG_ARM_AMBA) += acpi_amba.o acpi-y += int340x_thermal.o acpi-y += power.o acpi-y += event.o +acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o acpi-y += sysfs.o acpi-y += property.o acpi-$(CONFIG_X86) += acpi_cmos_rtc.o diff --git a/drivers/acpi/evged.c b/drivers/acpi/evged.c new file mode 100644 index 0000000..9c0a868 --- /dev/null +++ b/drivers/acpi/evged.c @@ -0,0 +1,156 @@ +/* + * Generic Event Device for ACPI. + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only 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. + * + * Generic Event Device allows platforms to handle interrupts in ACPI + * ASL statements. It follows very similar to _EVT method approach + * from GPIO events. All interrupts are listed in _CRS and the handler + * is written in _EVT method. Here is an example. + * + * Device (GED0) + * { + * + * Name (_HID, "ACPI0013") + * Name (_UID, 0) + * Method (_CRS, 0x0, Serialized) + * { + * Name (RBUF, ResourceTemplate () + * { + * Interrupt(ResourceConsumer, Edge, ActiveHigh, Shared, , , ) + * {123} + * } + * }) + * + * Method (_EVT, 1) { + * if (Lequal(123, Arg0)) + * { + * } + * } + * } + * + */ + +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "acpi-ged" + +struct acpi_ged_event { + struct list_head node; + struct device *dev; + unsigned int gsi; + unsigned int irq; + acpi_handle handle; +}; + +static irqreturn_t acpi_ged_irq_handler(int irq, void *data) +{ + struct acpi_ged_event *event = data; + acpi_status acpi_ret; + + acpi_ret = acpi_execute_simple_method(event->handle, NULL, event->gsi); + if (ACPI_FAILURE(acpi_ret)) + dev_err_once(event->dev, "IRQ method execution failed\n"); + + return IRQ_HANDLED; +} + +static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares, + void *context) +{ + struct acpi_ged_event *event; + unsigned int irq; + unsigned int gsi; + unsigned int irqflags = IRQF_ONESHOT; + struct device *dev = context; + acpi_handle handle = ACPI_HANDLE(dev); + acpi_handle evt_handle; + struct resource r; + struct acpi_resource_irq *p = &ares->data.irq; + struct acpi_resource_extended_irq *pext = &ares->data.extended_irq; + + if (ares->type == ACPI_RESOURCE_TYPE_END_TAG) + return AE_OK; + + if (!acpi_dev_resource_interrupt(ares, 0, &r)) { + dev_err(dev, "unable to parse IRQ resource\n"); + return AE_ERROR; + } + if (ares->type == ACPI_RESOURCE_TYPE_IRQ) + gsi = p->interrupts[0]; + else + gsi = pext->interrupts[0]; + + irq = r.start; + + if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) { + dev_err(dev, "cannot locate _EVT method\n"); + return AE_ERROR; + } + + dev_info(dev, "GED listening GSI %u @ IRQ %u\n", gsi, irq); + + event = devm_kzalloc(dev, sizeof(*event), GFP_KERNEL); + if (!event) + return AE_ERROR; + + event->gsi = gsi; + event->dev = dev; + event->irq = irq; + event->handle = evt_handle; + + if (r.flags & IORESOURCE_IRQ_SHAREABLE) + irqflags |= IRQF_SHARED; + + if (devm_request_threaded_irq(dev, irq, NULL, acpi_ged_irq_handler, + irqflags, "ACPI:Ged", event)) { + dev_err(dev, "failed to setup event handler for irq %u\n", irq); + return AE_ERROR; + } + + return AE_OK; +} + +static int ged_probe(struct platform_device *pdev) +{ + acpi_status acpi_ret; + + acpi_ret = acpi_walk_resources(ACPI_HANDLE(&pdev->dev), "_CRS", + acpi_ged_request_interrupt, &pdev->dev); + if (ACPI_FAILURE(acpi_ret)) { + dev_err(&pdev->dev, "unable to parse the _CRS record\n"); + return -EINVAL; + } + + return 0; +} + +static const struct acpi_device_id ged_acpi_ids[] = { + {"ACPI0013"}, + {}, +}; + +static struct platform_driver ged_driver = { + .probe = ged_probe, + .driver = { + .name = MODULE_NAME, + .acpi_match_table = ACPI_PTR(ged_acpi_ids), + }, +}; + +module_platform_driver(ged_driver); +MODULE_LICENSE("GPL v2"); -- cgit v0.10.2 From 1373718194ebebc43c00d8f117e03885749495b0 Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Tue, 22 Mar 2016 08:51:10 +0800 Subject: ACPI / PM: Introduce efi poweroff for HW-full platforms without _S5 The problem is Linux registers pm_power_off = efi_power_off only if we are in hardware reduced mode. Actually, what we also want is to do this when ACPI S5 is simply not supported on non-legacy platforms. Since some future Intel platforms are HW-full mode where the DSDT fails to supply an _S5 object(without SLP_TYP), we should let such kind of platform to leverage efi runtime service to poweroff. This patch uses efi power off as first choice when S5 is unavailable, even if there is a customized poweroff(driver provided, eg). Meanwhile, the legacy platforms will not be affected because there is no path for them to overwrite the pm_power_off to efi power off. Suggested-by: Len Brown Reviewed-by: Matt Fleming Signed-off-by: Chen Yu Signed-off-by: Rafael J. Wysocki diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index ab50ada..818d12a 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -373,5 +373,5 @@ bool efi_reboot_required(void) bool efi_poweroff_required(void) { - return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || acpi_no_s5; } diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 2a8b596..7a2e4d4 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -26,6 +26,11 @@ #include "internal.h" #include "sleep.h" +/* + * Some HW-full platforms do not have _S5, so they may need + * to leverage efi power off for a shutdown. + */ +bool acpi_no_s5; static u8 sleep_states[ACPI_S_STATE_COUNT]; static void acpi_sleep_tts_switch(u32 acpi_state) @@ -882,6 +887,8 @@ int __init acpi_sleep_init(void) sleep_states[ACPI_STATE_S5] = 1; pm_power_off_prepare = acpi_power_off_prepare; pm_power_off = acpi_power_off; + } else { + acpi_no_s5 = true; } supported[0] = 0; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 06ed7e5..4d2e67f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -278,6 +278,7 @@ void acpi_irq_stats_init(void); extern u32 acpi_irq_handled; extern u32 acpi_irq_not_handled; extern unsigned int acpi_sci_irq; +extern bool acpi_no_s5; #define INVALID_ACPI_IRQ ((unsigned)-1) static inline bool acpi_sci_irq_valid(void) { -- cgit v0.10.2 From 0e1affe41bdd7b1bef64c007d260e142bcaef220 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 10:42:47 +0800 Subject: ACPI 2.0 / ECDT: Split EC_FLAGS_HANDLERS_INSTALLED This patch splits EC_FLAGS_HANDLERS_INSTALLED so that address space handler can be installed when it is not possible to install GPE handler during early stage. This patch also tunes address space handler installation, making it happening earlier than GPE handler installation for the same purpose. Since acpi_ec_start()/acpi_ec_stop() will be entered multiple times after applying this change, it is also required to protect acpi_enable_gpe()/ acpi_disable_gpe() invocations. Link: https://bugzilla.kernel.org/show_bug.cgi?id=112911 Signed-off-by: Lv Zheng Tested-by: Chris Bainbridge Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index b420fb4..b8f474b 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -105,8 +105,8 @@ enum ec_command { enum { EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_QUERY_GUARDING, /* Guard for SCI_EVT check */ - EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and - * OpReg are installed */ + EC_FLAGS_GPE_HANDLER_INSTALLED, /* GPE handler installed */ + EC_FLAGS_EC_HANDLER_INSTALLED, /* OpReg handler installed */ EC_FLAGS_STARTED, /* Driver is started */ EC_FLAGS_STOPPED, /* Driver is stopped */ EC_FLAGS_COMMAND_STORM, /* GPE storms occurred to the @@ -367,7 +367,8 @@ static inline void acpi_ec_clear_gpe(struct acpi_ec *ec) static void acpi_ec_submit_request(struct acpi_ec *ec) { ec->reference_count++; - if (ec->reference_count == 1) + if (test_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags) && + ec->reference_count == 1) acpi_ec_enable_gpe(ec, true); } @@ -376,7 +377,8 @@ static void acpi_ec_complete_request(struct acpi_ec *ec) bool flushed = false; ec->reference_count--; - if (ec->reference_count == 0) + if (test_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags) && + ec->reference_count == 0) acpi_ec_disable_gpe(ec, true); flushed = acpi_ec_flushed(ec); if (flushed) @@ -1287,52 +1289,64 @@ static int ec_install_handlers(struct acpi_ec *ec) { acpi_status status; - if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) - return 0; - status = acpi_install_gpe_raw_handler(NULL, ec->gpe, - ACPI_GPE_EDGE_TRIGGERED, - &acpi_ec_gpe_handler, ec); - if (ACPI_FAILURE(status)) - return -ENODEV; - acpi_ec_start(ec, false); - status = acpi_install_address_space_handler(ec->handle, - ACPI_ADR_SPACE_EC, - &acpi_ec_space_handler, - NULL, ec); - if (ACPI_FAILURE(status)) { - if (status == AE_NOT_FOUND) { - /* - * Maybe OS fails in evaluating the _REG object. - * The AE_NOT_FOUND error will be ignored and OS - * continue to initialize EC. - */ - pr_err("Fail in evaluating the _REG object" - " of EC device. Broken bios is suspected.\n"); - } else { - acpi_ec_stop(ec, false); - acpi_remove_gpe_handler(NULL, ec->gpe, - &acpi_ec_gpe_handler); - return -ENODEV; + + if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { + status = acpi_install_address_space_handler(ec->handle, + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler, + NULL, ec); + if (ACPI_FAILURE(status)) { + if (status == AE_NOT_FOUND) { + /* + * Maybe OS fails in evaluating the _REG + * object. The AE_NOT_FOUND error will be + * ignored and OS * continue to initialize + * EC. + */ + pr_err("Fail in evaluating the _REG object" + " of EC device. Broken bios is suspected.\n"); + } else { + acpi_ec_stop(ec, false); + return -ENODEV; + } + } + set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); + } + + if (!test_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags)) { + status = acpi_install_gpe_raw_handler(NULL, ec->gpe, + ACPI_GPE_EDGE_TRIGGERED, + &acpi_ec_gpe_handler, ec); + /* This is not fatal as we can poll EC events */ + if (ACPI_SUCCESS(status)) { + set_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags); + if (test_bit(EC_FLAGS_STARTED, &ec->flags) && + ec->reference_count >= 1) + acpi_ec_enable_gpe(ec, true); } } - set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); return 0; } static void ec_remove_handlers(struct acpi_ec *ec) { - if (!test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) - return; acpi_ec_stop(ec, false); - if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) - pr_err("failed to remove space handler\n"); - if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, - &acpi_ec_gpe_handler))) - pr_err("failed to remove gpe handler\n"); - clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); + + if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { + if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, + ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) + pr_err("failed to remove space handler\n"); + clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); + } + + if (test_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags)) { + if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, + &acpi_ec_gpe_handler))) + pr_err("failed to remove gpe handler\n"); + clear_bit(EC_FLAGS_GPE_HANDLER_INSTALLED, &ec->flags); + } } static int acpi_ec_add(struct acpi_device *device) @@ -1434,7 +1448,7 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context) int __init acpi_boot_ec_enable(void) { - if (!boot_ec || test_bit(EC_FLAGS_HANDLERS_INSTALLED, &boot_ec->flags)) + if (!boot_ec) return 0; if (!ec_install_handlers(boot_ec)) { first_ec = boot_ec; -- cgit v0.10.2 From 59f0aa9480cfef9173a648cec4537addc5f3ad94 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 10:42:53 +0800 Subject: ACPI 2.0 / ECDT: Remove early namespace reference from EC All operation region accesses are allowed by AML interpreter when AML is executed, so actually BIOSen are responsible to avoid the operation region accesses in AML before OSPM has prepared an operation region driver. This is done via _REG control method. So AML code normally sets a global named object REGC to 1 when _REG(3, 1) is evaluated. Then what is ECDT? Quoting from ACPI spec 6.0, 5.2.15 Embedded Controller Boot Resources Table (ECDT): "The presence of this table allows OSPM to provide Embedded Controller operation region space access before the namespace has been evaluated." Spec also suggests a compatible mean to indicate the early EC access availability: Device (EC) { Name (REGC, Ones) Method (_REG, 2) { If (LEqual (Arg0, 3)) { Store (Arg1, REGC) } } Method (ECAV) { If (LEqual (REGC, Ones)) { If (LGreaterEqual (_REV, 2)) { Return (One) } Else { Return (Zero) } } Else { Return (REGC) } } } In this way, it allows EC accesses to happen before EC._REG(3, 1) is invoked. But ECAV is not the only way practical BIOSen using to indicate the early EC access availibility, the known variations include: 1. Setting REGC to One in \_SB._INI when _REV >= 2. Since \_SB._INI is the first control method evaluated by OSPM during the enumeration, this allows EC accesses to happen for the entire enumeration process before the namespace EC is enumerated. 2. Initialize REGC to One by default, this even allows EC accesses to happen during the table loading. Linux is now broken around ECDT support during the long term bug fixing work because it has merged many wrong ECDT bug fixes (see details below). Linux currently uses namespace EC's settings instead of ECDT settings when ECDT is detected. This apparently will result in namespace walk and _CRS/_GPE/_REG evaluations. Such stuffs could only happen after namespace is ready, while ECDT is purposely to be used before namespace is ready. The wrong bug fixing story is: 1. Link 1: At Linux ACPI early stages, "no _Lxx/_Exx/_Qxx evaluation can happen before the namespace is ready" are not ensured by ACPICA core and Linux. This is currently ensured by deferred enabling of GPE and defered registering of EC query methods (acpi_ec_register_query_methods). 2. Link 2: Reporters reported buggy ECDTs, expecting quirks for the platform. Originally, the quirk is simple, only doing things with ECDT. Bug 9399 and 12461 are platforms (Asus L4R, Asus M6R, MSI MS-171F) reported to have wrong ECDT IO port addresses, the port addresses are reversed. Bug 11880 is a platform (Asus X50GL) reported to have 0 valued port addresses, we can see that all EC accesses are protected by ECAV on this platform, so actually no early EC accesses is required by this platform. 3. Link 3: But when the bug fixing developer was requested to provide a handy and non-quirk bug fix, he tried to use correct EC settings from namespace and broke the spec purpose. We can even see that the developer was suffered from many regrssions. One interesting one is 14086, where the actual root cause obviously should be: _REG is evaluated too early. But unfortunately, the bug is fixed in a totally wrong way. So everything goes wrong from these commits: Commit: c6cb0e878446c79f42e7833d7bb69ed6bfbb381f Subject: ACPI: EC: Don't trust ECDT tables from ASUS Commit: a5032bfdd9c80e0231a6324661e123818eb46ecd Subject: ACPI: EC: Always parse EC device This patch reverts Linux behavior to simple ECDT quirk support in order to stop early _CRS/_GPE/_REG evaluations. For Bug 9399, 12461, since it is reported that the platforms require early EC accesses, this patch restores the simple ECDT quirks for them. For Bug 11880, since it is not reported that the platform requires early EC accesses and its ACPI tables contain correct ECAV, we choose an ECDT enumeration failure for this platform. Link 1: https://bugzilla.kernel.org/show_bug.cgi?id=9916 http://bugzilla.kernel.org/show_bug.cgi?id=10100 https://lkml.org/lkml/2008/2/25/282 Link 2: https://bugzilla.kernel.org/show_bug.cgi?id=9399 https://bugzilla.kernel.org/show_bug.cgi?id=12461 https://bugzilla.kernel.org/show_bug.cgi?id=11880 Link 3: https://bugzilla.kernel.org/show_bug.cgi?id=11884 https://bugzilla.kernel.org/show_bug.cgi?id=14081 https://bugzilla.kernel.org/show_bug.cgi?id=14086 https://bugzilla.kernel.org/show_bug.cgi?id=14446 Link 4: https://bugzilla.kernel.org/show_bug.cgi?id=112911 Signed-off-by: Lv Zheng Tested-by: Chris Bainbridge Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index b8f474b..0e70181 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -175,10 +175,9 @@ static void acpi_ec_event_processor(struct work_struct *work); struct acpi_ec *boot_ec, *first_ec; EXPORT_SYMBOL(first_ec); -static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */ -static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ +static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */ /* -------------------------------------------------------------------------- * Logging/Debugging @@ -1358,11 +1357,12 @@ static int acpi_ec_add(struct acpi_device *device) strcpy(acpi_device_class(device), ACPI_EC_CLASS); /* Check for boot EC */ - if (boot_ec && - (boot_ec->handle == device->handle || - boot_ec->handle == ACPI_ROOT_OBJECT)) { + if (boot_ec) { ec = boot_ec; boot_ec = NULL; + ec_remove_handlers(ec); + if (first_ec == ec) + first_ec = NULL; } else { ec = make_acpi_ec(); if (!ec) @@ -1462,20 +1462,6 @@ static const struct acpi_device_id ec_device_ids[] = { {"", 0}, }; -/* Some BIOS do not survive early DSDT scan, skip it */ -static int ec_skip_dsdt_scan(const struct dmi_system_id *id) -{ - EC_FLAGS_SKIP_DSDT_SCAN = 1; - return 0; -} - -/* ASUStek often supplies us with broken ECDT, validate it */ -static int ec_validate_ecdt(const struct dmi_system_id *id) -{ - EC_FLAGS_VALIDATE_ECDT = 1; - return 0; -} - #if 0 /* * Some EC firmware variations refuses to respond QR_EC when SCI_EVT is not @@ -1517,30 +1503,29 @@ static int ec_clear_on_resume(const struct dmi_system_id *id) return 0; } +static int ec_correct_ecdt(const struct dmi_system_id *id) +{ + pr_debug("Detected system needing ECDT address correction.\n"); + EC_FLAGS_CORRECT_ECDT = 1; + return 0; +} + static struct dmi_system_id ec_dmi_table[] __initdata = { { - ec_skip_dsdt_scan, "Compal JFL92", { - DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), - DMI_MATCH(DMI_BOARD_NAME, "JFL92") }, NULL}, + ec_correct_ecdt, "Asus L4R", { + DMI_MATCH(DMI_BIOS_VERSION, "1008.006"), + DMI_MATCH(DMI_PRODUCT_NAME, "L4R"), + DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL}, + { + ec_correct_ecdt, "Asus M6R", { + DMI_MATCH(DMI_BIOS_VERSION, "0207"), + DMI_MATCH(DMI_PRODUCT_NAME, "M6R"), + DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL}, { - ec_validate_ecdt, "MSI MS-171F", { + ec_correct_ecdt, "MSI MS-171F", { DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star"), DMI_MATCH(DMI_PRODUCT_NAME, "MS-171F"),}, NULL}, { - ec_validate_ecdt, "ASUS hardware", { - DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL}, - { - ec_validate_ecdt, "ASUS hardware", { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL}, - { - ec_skip_dsdt_scan, "HP Folio 13", { - DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13"),}, NULL}, - { - ec_validate_ecdt, "ASUS hardware", { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek Computer Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),}, NULL}, - { ec_clear_on_resume, "Samsung hardware", { DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, {}, @@ -1548,8 +1533,8 @@ static struct dmi_system_id ec_dmi_table[] __initdata = { int __init acpi_ec_ecdt_probe(void) { + int ret = 0; acpi_status status; - struct acpi_ec *saved_ec = NULL; struct acpi_table_ecdt *ecdt_ptr; boot_ec = make_acpi_ec(); @@ -1561,67 +1546,45 @@ int __init acpi_ec_ecdt_probe(void) dmi_check_system(ec_dmi_table); status = acpi_get_table(ACPI_SIG_ECDT, 1, (struct acpi_table_header **)&ecdt_ptr); - if (ACPI_SUCCESS(status)) { - pr_info("EC description table is found, configuring boot EC\n"); - boot_ec->command_addr = ecdt_ptr->control.address; - boot_ec->data_addr = ecdt_ptr->data.address; - boot_ec->gpe = ecdt_ptr->gpe; - boot_ec->handle = ACPI_ROOT_OBJECT; - acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, - &boot_ec->handle); - /* Don't trust ECDT, which comes from ASUSTek */ - if (!EC_FLAGS_VALIDATE_ECDT) - goto install; - saved_ec = kmemdup(boot_ec, sizeof(struct acpi_ec), GFP_KERNEL); - if (!saved_ec) - return -ENOMEM; - /* fall through */ + if (ACPI_FAILURE(status)) { + ret = -ENODEV; + goto error; } - if (EC_FLAGS_SKIP_DSDT_SCAN) { - kfree(saved_ec); - return -ENODEV; + if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) { + /* + * Asus X50GL: + * https://bugzilla.kernel.org/show_bug.cgi?id=11880 + */ + ret = -ENODEV; + goto error; } - /* This workaround is needed only on some broken machines, - * which require early EC, but fail to provide ECDT */ - pr_debug("Look up EC in DSDT\n"); - status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, - boot_ec, NULL); - /* Check that acpi_get_devices actually find something */ - if (ACPI_FAILURE(status) || !boot_ec->handle) - goto error; - if (saved_ec) { - /* try to find good ECDT from ASUSTek */ - if (saved_ec->command_addr != boot_ec->command_addr || - saved_ec->data_addr != boot_ec->data_addr || - saved_ec->gpe != boot_ec->gpe || - saved_ec->handle != boot_ec->handle) - pr_info("ASUSTek keeps feeding us with broken " - "ECDT tables, which are very hard to workaround. " - "Trying to use DSDT EC info instead. Please send " - "output of acpidump to linux-acpi@vger.kernel.org\n"); - kfree(saved_ec); - saved_ec = NULL; + pr_info("EC description table is found, configuring boot EC\n"); + if (EC_FLAGS_CORRECT_ECDT) { + /* + * Asus L4R, Asus M6R + * https://bugzilla.kernel.org/show_bug.cgi?id=9399 + * MSI MS-171F + * https://bugzilla.kernel.org/show_bug.cgi?id=12461 + */ + boot_ec->command_addr = ecdt_ptr->data.address; + boot_ec->data_addr = ecdt_ptr->control.address; } else { - /* We really need to limit this workaround, the only ASUS, - * which needs it, has fake EC._INI method, so use it as flag. - * Keep boot_ec struct as it will be needed soon. - */ - if (!dmi_name_in_vendors("ASUS") || - !acpi_has_method(boot_ec->handle, "_INI")) - return -ENODEV; + boot_ec->command_addr = ecdt_ptr->control.address; + boot_ec->data_addr = ecdt_ptr->data.address; } -install: - if (!ec_install_handlers(boot_ec)) { + boot_ec->gpe = ecdt_ptr->gpe; + boot_ec->handle = ACPI_ROOT_OBJECT; + ret = ec_install_handlers(boot_ec); + if (!ret) first_ec = boot_ec; - return 0; - } error: - kfree(boot_ec); - kfree(saved_ec); - boot_ec = NULL; - return -ENODEV; + if (ret) { + kfree(boot_ec); + boot_ec = NULL; + } + return ret; } static int param_set_event_clearing(const char *val, struct kernel_param *kp) -- cgit v0.10.2 From fe6cbea0f096bfdb7eafdc7b937570cea8fca00e Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 10:43:00 +0800 Subject: ACPI 2.0 / ECDT: Enable correct ECDT initialization order With wrong ECDT fixes reverted, it is possible to put ECDT probing before acpi_enable_subsystem(). But the ultimate purpose of ECDT re-enabling is to put the ECDT probing before the namespace initialization (acpi_load_tables()). This patch achieves this with protections so that we can enable it later when all necessary corrections are upstreamed. Link 4: https://bugzilla.kernel.org/show_bug.cgi?id=112911 Signed-off-by: Lv Zheng Tested-by: Chris Bainbridge Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index c068c82..31e8da6 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -925,11 +925,13 @@ void __init acpi_early_init(void) goto error0; } - status = acpi_load_tables(); - if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX - "Unable to load the System Description Tables\n"); - goto error0; + if (acpi_gbl_group_module_level_code) { + status = acpi_load_tables(); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX + "Unable to load the System Description Tables\n"); + goto error0; + } } #ifdef CONFIG_X86 @@ -995,17 +997,10 @@ static int __init acpi_bus_init(void) acpi_os_initialize1(); - status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); - if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX - "Unable to start the ACPI Interpreter\n"); - goto error1; - } - /* * ACPI 2.0 requires the EC driver to be loaded and work before - * the EC device is found in the namespace (i.e. before acpi_initialize_objects() - * is called). + * the EC device is found in the namespace (i.e. before + * acpi_load_tables() is called). * * This is accomplished by looking for the ECDT table, and getting * the EC parameters out of that. @@ -1013,6 +1008,22 @@ static int __init acpi_bus_init(void) status = acpi_ec_ecdt_probe(); /* Ignore result. Not having an ECDT is not fatal. */ + if (!acpi_gbl_group_module_level_code) { + status = acpi_load_tables(); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX + "Unable to load the System Description Tables\n"); + goto error1; + } + } + + status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX + "Unable to start the ACPI Interpreter\n"); + goto error1; + } + status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); -- cgit v0.10.2 From 3d4b7ae96d81dc8ed4ecd556118b632c2707ff08 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 10:43:08 +0800 Subject: ACPI 2.0 / AML: Improve module level execution by moving the If/Else/While execution to per-table basis This experiment moves module level If/Else/While executions to per-table basis. If regressions are found against the enabling of this experimental improvement, this patch is the only one that should get bisected out. Please report the regressions to the kernel bugzilla for further root causing. Link: https://bugzilla.kernel.org/show_bug.cgi?id=112911 Signed-off-by: Lv Zheng Tested-by: Chris Bainbridge Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 1755697..3d910e5 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -192,7 +192,7 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_do_not_use_xsdt, FALSE); /* * Optionally support group module level code. */ -ACPI_INIT_GLOBAL(u8, acpi_gbl_group_module_level_code, TRUE); +ACPI_INIT_GLOBAL(u8, acpi_gbl_group_module_level_code, FALSE); /* * Optionally use 32-bit FADT addresses if and when there is a conflict -- cgit v0.10.2 From 60438d9a1ef4176d79739efadee122afe92904b8 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 24 Mar 2016 13:01:28 +0800 Subject: tools/power/acpi: close file only if it is open The logic on the test for a valid fd to close is incorrect. This was just a mistake and was pointed out by Colin Ian King. Link: https://patchwork.kernel.org/patch/8620201/ Original-by: Colin Ian King Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c index d070fcc..a88ac45 100644 --- a/tools/power/acpi/tools/acpidbg/acpidbg.c +++ b/tools/power/acpi/tools/acpidbg/acpidbg.c @@ -375,7 +375,7 @@ void usage(FILE *file, char *progname) int main(int argc, char **argv) { - int fd = 0; + int fd = -1; int ch; int len; int ret = EXIT_SUCCESS; @@ -430,7 +430,7 @@ int main(int argc, char **argv) acpi_aml_loop(fd); exit: - if (fd < 0) + if (fd >= 0) close(fd); if (acpi_aml_batch_cmd) free(acpi_aml_batch_cmd); -- cgit v0.10.2 From c68ae33e7fb4a010f9a48af3e4b87089dca96551 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Thu, 24 Mar 2016 13:15:20 +0100 Subject: ACPI / utils: Rename acpi_dev_present() acpi_dev_present() was originally named after pci_dev_present() to signify the similarity of the two functions. However Rafael J. Wysocki pointed out that the exported function acpi_dev_present() is easily confused with the non-exported acpi_device_is_present(). Additionally in ACPI parlance the term "present" usually refers to the "device is present" bit returned by the _STA control method, yet acpi_dev_present() merely checks presence in the namespace. It does not invoke _STA at all, let alone check the "device is present" bit. As suggested by Rafael, rename the function to acpi_dev_found() and adjust all existing call sites. Signed-off-by: Lukas Wunner Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 050673f..ac832bf 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -707,7 +707,7 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs) EXPORT_SYMBOL(acpi_check_dsm); /** - * acpi_dev_present - Detect presence of a given ACPI device in the system. + * acpi_dev_found - Detect presence of a given ACPI device in the namespace. * @hid: Hardware ID of the device. * * Return %true if the device was present at the moment of invocation. @@ -719,7 +719,7 @@ EXPORT_SYMBOL(acpi_check_dsm); * instead). Calling from module_init() is fine (which is synonymous * with device_initcall()). */ -bool acpi_dev_present(const char *hid) +bool acpi_dev_found(const char *hid) { struct acpi_device_bus_id *acpi_device_bus_id; bool found = false; @@ -734,7 +734,7 @@ bool acpi_dev_present(const char *hid) return found; } -EXPORT_SYMBOL(acpi_dev_present); +EXPORT_SYMBOL(acpi_dev_found); /* * acpi_backlight= handling, this is done here rather then in video_detect.c diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 14362a8..a84fd15 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -87,7 +87,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, int rev, int func, .package.elements = (eles) \ } -bool acpi_dev_present(const char *hid); +bool acpi_dev_found(const char *hid); #ifdef CONFIG_ACPI diff --git a/include/linux/apple-gmux.h b/include/linux/apple-gmux.h index b2d32e0..714186d 100644 --- a/include/linux/apple-gmux.h +++ b/include/linux/apple-gmux.h @@ -35,7 +35,7 @@ */ static inline bool apple_gmux_present(void) { - return acpi_dev_present(GMUX_ACPI_HID); + return acpi_dev_found(GMUX_ACPI_HID); } #else /* !CONFIG_APPLE_GMUX */ diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c index 59ab6ce..f0955fd 100644 --- a/sound/pci/hda/thinkpad_helper.c +++ b/sound/pci/hda/thinkpad_helper.c @@ -13,7 +13,7 @@ static void (*old_vmaster_hook)(void *, int); static bool is_thinkpad(struct hda_codec *codec) { return (codec->core.subsystem_id >> 16 == 0x17aa) && - (acpi_dev_present("LEN0068") || acpi_dev_present("IBM0068")); + (acpi_dev_found("LEN0068") || acpi_dev_found("IBM0068")); } static void update_tpacpi_mute_led(void *private_data, int enabled) diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index e609f08..ac60b04 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -296,7 +296,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) if (!drv) return -ENOMEM; - drv->ts3a227e_present = acpi_dev_present("104C227E"); + drv->ts3a227e_present = acpi_dev_found("104C227E"); if (!drv->ts3a227e_present) { /* no need probe TI jack detection chip */ snd_soc_card_cht.aux_dev = NULL; diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c index 2a6f808..3f2c1ea 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5645.c +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c @@ -357,7 +357,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(snd_soc_cards); i++) { - if (acpi_dev_present(snd_soc_cards[i].codec_id)) { + if (acpi_dev_found(snd_soc_cards[i].codec_id)) { dev_dbg(&pdev->dev, "found codec %s\n", snd_soc_cards[i].codec_id); card = snd_soc_cards[i].soc_card; -- cgit v0.10.2 From 9f9de69d754cc9f8f2d8c21bb92275d95ddb3c77 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Thu, 24 Mar 2016 13:15:20 +0100 Subject: eeepc-wmi: Use acpi_dev_found() Use shiny new acpi_dev_found() and remove all the boilerplate to search for a particular ACPI device. No functional change. Signed-off-by: Lukas Wunner Acked-by: Darren Hart Signed-off-by: Rafael J. Wysocki diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c index 14fd2ec..17b365f 100644 --- a/drivers/platform/x86/eeepc-wmi.c +++ b/drivers/platform/x86/eeepc-wmi.c @@ -204,30 +204,10 @@ static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code, } } -static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level, - void *context, void **retval) -{ - pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID); - *(bool *)context = true; - return AE_CTRL_TERMINATE; -} - -static int eeepc_wmi_check_atkd(void) -{ - acpi_status status; - bool found = false; - - status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device, - &found, NULL); - - if (ACPI_FAILURE(status) || !found) - return 0; - return -1; -} - static int eeepc_wmi_probe(struct platform_device *pdev) { - if (eeepc_wmi_check_atkd()) { + if (acpi_dev_found(EEEPC_ACPI_HID)) { + pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID); pr_warn("WMI device present, but legacy ATKD device is also " "present and enabled\n"); pr_warn("You probably booted with acpi_osi=\"Linux\" or " -- cgit v0.10.2 From 8c92a75e5086e85000deeb05f6f852446c8f758a Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Thu, 24 Mar 2016 13:15:20 +0100 Subject: acer-wmi: Use acpi_dev_found() Use shiny new acpi_dev_found() and remove all the boilerplate to search for a particular ACPI device. No functional change. Signed-off-by: Lukas Wunner Reviewed-by: Lee, Chun-Yi Acked-by: Darren Hart Signed-off-by: Rafael J. Wysocki diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 1062fa4..79d64ea 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -793,15 +793,6 @@ static acpi_status __init AMW0_find_mailled(void) return AE_OK; } -static int AMW0_set_cap_acpi_check_device_found __initdata; - -static acpi_status __init AMW0_set_cap_acpi_check_device_cb(acpi_handle handle, - u32 level, void *context, void **retval) -{ - AMW0_set_cap_acpi_check_device_found = 1; - return AE_OK; -} - static const struct acpi_device_id norfkill_ids[] __initconst = { { "VPC2004", 0}, { "IBM0068", 0}, @@ -816,9 +807,10 @@ static int __init AMW0_set_cap_acpi_check_device(void) const struct acpi_device_id *id; for (id = norfkill_ids; id->id[0]; id++) - acpi_get_devices(id->id, AMW0_set_cap_acpi_check_device_cb, - NULL, NULL); - return AMW0_set_cap_acpi_check_device_found; + if (acpi_dev_found(id->id)) + return true; + + return false; } static acpi_status __init AMW0_set_capabilities(void) -- cgit v0.10.2 From 5ae74f2cc2f150c1a5cee54cabbd71dd0661285a Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 11 Apr 2016 10:13:18 +0800 Subject: ACPI / tables: Move table override mechanisms to tables.c This patch moves acpi_os_table_override() and acpi_os_physical_table_override() to tables.c. Along with the mechanisms, acpi_initrd_initialize_tables() is also moved to tables.c to form a static function. The following functions are renamed according to this change: 1. acpi_initrd_override() -> renamed to early_acpi_table_init(), which invokes acpi_table_initrd_init() 2. acpi_os_physical_table_override() -> which invokes acpi_table_initrd_override() 3. acpi_initialize_initrd_tables() -> renamed to acpi_table_initrd_scan() Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 2367ae0..902a6f7 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1139,7 +1139,7 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); #if defined(CONFIG_ACPI) && defined(CONFIG_BLK_DEV_INITRD) - acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start); + early_acpi_table_init((void *)initrd_start, initrd_end - initrd_start); #endif vsmp_init(); diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 7c18847..1b0e6fd 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -20,7 +20,6 @@ #define PREFIX "ACPI: " -void acpi_initrd_initialize_tables(void); acpi_status acpi_os_initialize1(void); void init_acpi_device_notify(void); int acpi_scan_init(void); diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 814d5f8..0796ad9 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -602,280 +602,6 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } -static void acpi_table_taint(struct acpi_table_header *table) -{ - pr_warn(PREFIX - "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n", - table->signature, table->oem_table_id); - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); -} - -#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE -#include -#include - -static u64 acpi_tables_addr; -static int all_tables_size; - -/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ -static u8 __init acpi_table_checksum(u8 *buffer, u32 length) -{ - u8 sum = 0; - u8 *end = buffer + length; - - while (buffer < end) - sum = (u8) (sum + *(buffer++)); - return sum; -} - -/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ -static const char * const table_sigs[] = { - ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, - ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, - ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, - ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, - ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, - ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, - ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, - ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, - ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; - -#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) - -#define ACPI_OVERRIDE_TABLES 64 -static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES]; -static DECLARE_BITMAP(acpi_initrd_installed, ACPI_OVERRIDE_TABLES); - -#define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT) - -void __init acpi_initrd_override(void *data, size_t size) -{ - int sig, no, table_nr = 0, total_offset = 0; - long offset = 0; - struct acpi_table_header *table; - char cpio_path[32] = "kernel/firmware/acpi/"; - struct cpio_data file; - - if (data == NULL || size == 0) - return; - - for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { - file = find_cpio_data(cpio_path, data, size, &offset); - if (!file.data) - break; - - data += offset; - size -= offset; - - if (file.size < sizeof(struct acpi_table_header)) { - pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n", - cpio_path, file.name); - continue; - } - - table = file.data; - - for (sig = 0; table_sigs[sig]; sig++) - if (!memcmp(table->signature, table_sigs[sig], 4)) - break; - - if (!table_sigs[sig]) { - pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n", - cpio_path, file.name); - continue; - } - if (file.size != table->length) { - pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n", - cpio_path, file.name); - continue; - } - if (acpi_table_checksum(file.data, table->length)) { - pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n", - cpio_path, file.name); - continue; - } - - pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n", - table->signature, cpio_path, file.name, table->length); - - all_tables_size += table->length; - acpi_initrd_files[table_nr].data = file.data; - acpi_initrd_files[table_nr].size = file.size; - table_nr++; - } - if (table_nr == 0) - return; - - acpi_tables_addr = - memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT, - all_tables_size, PAGE_SIZE); - if (!acpi_tables_addr) { - WARN_ON(1); - return; - } - /* - * Only calling e820_add_reserve does not work and the - * tables are invalid (memory got used) later. - * memblock_reserve works as expected and the tables won't get modified. - * But it's not enough on X86 because ioremap will - * complain later (used by acpi_os_map_memory) that the pages - * that should get mapped are not marked "reserved". - * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area) - * works fine. - */ - memblock_reserve(acpi_tables_addr, all_tables_size); - arch_reserve_mem_area(acpi_tables_addr, all_tables_size); - - /* - * early_ioremap only can remap 256k one time. If we map all - * tables one time, we will hit the limit. Need to map chunks - * one by one during copying the same as that in relocate_initrd(). - */ - for (no = 0; no < table_nr; no++) { - unsigned char *src_p = acpi_initrd_files[no].data; - phys_addr_t size = acpi_initrd_files[no].size; - phys_addr_t dest_addr = acpi_tables_addr + total_offset; - phys_addr_t slop, clen; - char *dest_p; - - total_offset += size; - - while (size) { - slop = dest_addr & ~PAGE_MASK; - clen = size; - if (clen > MAP_CHUNK_SIZE - slop) - clen = MAP_CHUNK_SIZE - slop; - dest_p = early_ioremap(dest_addr & PAGE_MASK, - clen + slop); - memcpy(dest_p + slop, src_p, clen); - early_iounmap(dest_p, clen + slop); - src_p += clen; - dest_addr += clen; - size -= clen; - } - } -} - -acpi_status -acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address *address, u32 *length) -{ - int table_offset = 0; - int table_index = 0; - struct acpi_table_header *table; - u32 table_length; - - *length = 0; - *address = 0; - if (!acpi_tables_addr) - return AE_OK; - - while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { - table = acpi_os_map_memory(acpi_tables_addr + table_offset, - ACPI_HEADER_SIZE); - if (table_offset + table->length > all_tables_size) { - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - WARN_ON(1); - return AE_OK; - } - - table_length = table->length; - - /* Only override tables matched */ - if (test_bit(table_index, acpi_initrd_installed) || - memcmp(existing_table->signature, table->signature, 4) || - memcmp(table->oem_table_id, existing_table->oem_table_id, - ACPI_OEM_TABLE_ID_SIZE)) { - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - goto next_table; - } - - *length = table_length; - *address = acpi_tables_addr + table_offset; - acpi_table_taint(existing_table); - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - set_bit(table_index, acpi_initrd_installed); - break; - -next_table: - table_offset += table_length; - table_index++; - } - return AE_OK; -} - -void __init acpi_initrd_initialize_tables(void) -{ - int table_offset = 0; - int table_index = 0; - u32 table_length; - struct acpi_table_header *table; - - if (!acpi_tables_addr) - return; - - while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { - table = acpi_os_map_memory(acpi_tables_addr + table_offset, - ACPI_HEADER_SIZE); - if (table_offset + table->length > all_tables_size) { - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - WARN_ON(1); - return; - } - - table_length = table->length; - - /* Skip RSDT/XSDT which should only be used for override */ - if (test_bit(table_index, acpi_initrd_installed) || - ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) || - ACPI_COMPARE_NAME(table->signature, ACPI_SIG_XSDT)) { - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - goto next_table; - } - - acpi_table_taint(table); - acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - acpi_install_table(acpi_tables_addr + table_offset, TRUE); - set_bit(table_index, acpi_initrd_installed); -next_table: - table_offset += table_length; - table_index++; - } -} -#else -acpi_status -acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address *address, - u32 *table_length) -{ - *table_length = 0; - *address = 0; - return AE_OK; -} - -void __init acpi_initrd_initialize_tables(void) -{ -} -#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */ - -acpi_status -acpi_os_table_override(struct acpi_table_header *existing_table, - struct acpi_table_header **new_table) -{ - if (!existing_table || !new_table) - return AE_BAD_PARAMETER; - - *new_table = NULL; - -#ifdef CONFIG_ACPI_CUSTOM_DSDT - if (strncmp(existing_table->signature, "DSDT", 4) == 0) - *new_table = (struct acpi_table_header *)AmlCode; -#endif - if (*new_table != NULL) - acpi_table_taint(existing_table); - return AE_OK; -} - static irqreturn_t acpi_irq(int irq, void *dev_id) { u32 handled; diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index f49c024..2e74dbf 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "internal.h" #define ACPI_MAX_TABLES 128 @@ -433,6 +435,294 @@ static void __init check_multiple_madt(void) return; } +static void acpi_table_taint(struct acpi_table_header *table) +{ + pr_warn("Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n", + table->signature, table->oem_table_id); + add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); +} + +#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +static u64 acpi_tables_addr; +static int all_tables_size; + +/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ +static u8 __init acpi_table_checksum(u8 *buffer, u32 length) +{ + u8 sum = 0; + u8 *end = buffer + length; + + while (buffer < end) + sum = (u8) (sum + *(buffer++)); + return sum; +} + +/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ +static const char * const table_sigs[] = { + ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, + ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, + ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, + ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, + ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, + ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, + ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, + ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, + ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; + +#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) + +#define ACPI_OVERRIDE_TABLES 64 +static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES]; +static DECLARE_BITMAP(acpi_initrd_installed, ACPI_OVERRIDE_TABLES); + +#define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT) + +static void __init acpi_table_initrd_init(void *data, size_t size) +{ + int sig, no, table_nr = 0, total_offset = 0; + long offset = 0; + struct acpi_table_header *table; + char cpio_path[32] = "kernel/firmware/acpi/"; + struct cpio_data file; + + if (data == NULL || size == 0) + return; + + for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { + file = find_cpio_data(cpio_path, data, size, &offset); + if (!file.data) + break; + + data += offset; + size -= offset; + + if (file.size < sizeof(struct acpi_table_header)) { + pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n", + cpio_path, file.name); + continue; + } + + table = file.data; + + for (sig = 0; table_sigs[sig]; sig++) + if (!memcmp(table->signature, table_sigs[sig], 4)) + break; + + if (!table_sigs[sig]) { + pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n", + cpio_path, file.name); + continue; + } + if (file.size != table->length) { + pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n", + cpio_path, file.name); + continue; + } + if (acpi_table_checksum(file.data, table->length)) { + pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n", + cpio_path, file.name); + continue; + } + + pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n", + table->signature, cpio_path, file.name, table->length); + + all_tables_size += table->length; + acpi_initrd_files[table_nr].data = file.data; + acpi_initrd_files[table_nr].size = file.size; + table_nr++; + } + if (table_nr == 0) + return; + + acpi_tables_addr = + memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT, + all_tables_size, PAGE_SIZE); + if (!acpi_tables_addr) { + WARN_ON(1); + return; + } + /* + * Only calling e820_add_reserve does not work and the + * tables are invalid (memory got used) later. + * memblock_reserve works as expected and the tables won't get modified. + * But it's not enough on X86 because ioremap will + * complain later (used by acpi_os_map_memory) that the pages + * that should get mapped are not marked "reserved". + * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area) + * works fine. + */ + memblock_reserve(acpi_tables_addr, all_tables_size); + arch_reserve_mem_area(acpi_tables_addr, all_tables_size); + + /* + * early_ioremap only can remap 256k one time. If we map all + * tables one time, we will hit the limit. Need to map chunks + * one by one during copying the same as that in relocate_initrd(). + */ + for (no = 0; no < table_nr; no++) { + unsigned char *src_p = acpi_initrd_files[no].data; + phys_addr_t size = acpi_initrd_files[no].size; + phys_addr_t dest_addr = acpi_tables_addr + total_offset; + phys_addr_t slop, clen; + char *dest_p; + + total_offset += size; + + while (size) { + slop = dest_addr & ~PAGE_MASK; + clen = size; + if (clen > MAP_CHUNK_SIZE - slop) + clen = MAP_CHUNK_SIZE - slop; + dest_p = early_ioremap(dest_addr & PAGE_MASK, + clen + slop); + memcpy(dest_p + slop, src_p, clen); + early_iounmap(dest_p, clen + slop); + src_p += clen; + dest_addr += clen; + size -= clen; + } + } +} + +static acpi_status +acpi_table_initrd_override(struct acpi_table_header *existing_table, + acpi_physical_address *address, u32 *length) +{ + int table_offset = 0; + int table_index = 0; + struct acpi_table_header *table; + u32 table_length; + + *length = 0; + *address = 0; + if (!acpi_tables_addr) + return AE_OK; + + while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { + table = acpi_os_map_memory(acpi_tables_addr + table_offset, + ACPI_HEADER_SIZE); + if (table_offset + table->length > all_tables_size) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + WARN_ON(1); + return AE_OK; + } + + table_length = table->length; + + /* Only override tables matched */ + if (test_bit(table_index, acpi_initrd_installed) || + memcmp(existing_table->signature, table->signature, 4) || + memcmp(table->oem_table_id, existing_table->oem_table_id, + ACPI_OEM_TABLE_ID_SIZE)) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + goto next_table; + } + + *length = table_length; + *address = acpi_tables_addr + table_offset; + acpi_table_taint(existing_table); + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + set_bit(table_index, acpi_initrd_installed); + break; + +next_table: + table_offset += table_length; + table_index++; + } + return AE_OK; +} + +static void __init acpi_table_initrd_scan(void) +{ + int table_offset = 0; + int table_index = 0; + u32 table_length; + struct acpi_table_header *table; + + if (!acpi_tables_addr) + return; + + while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { + table = acpi_os_map_memory(acpi_tables_addr + table_offset, + ACPI_HEADER_SIZE); + if (table_offset + table->length > all_tables_size) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + WARN_ON(1); + return; + } + + table_length = table->length; + + /* Skip RSDT/XSDT which should only be used for override */ + if (test_bit(table_index, acpi_initrd_installed) || + ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) || + ACPI_COMPARE_NAME(table->signature, ACPI_SIG_XSDT)) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + goto next_table; + } + + acpi_table_taint(table); + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + acpi_install_table(acpi_tables_addr + table_offset, TRUE); + set_bit(table_index, acpi_initrd_installed); +next_table: + table_offset += table_length; + table_index++; + } +} +#else +static void __init acpi_table_initrd_init(void *data, size_t size) +{ +} + +static acpi_status +acpi_table_initrd_override(struct acpi_table_header *existing_table, + acpi_physical_address *address, + u32 *table_length) +{ + *table_length = 0; + *address = 0; + return AE_OK; +} + +static void __init acpi_table_initrd_scan(void) +{ +} +#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */ + +acpi_status +acpi_os_physical_table_override(struct acpi_table_header *existing_table, + acpi_physical_address *address, + u32 *table_length) +{ + return acpi_table_initrd_override(existing_table, address, + table_length); +} + +acpi_status +acpi_os_table_override(struct acpi_table_header *existing_table, + struct acpi_table_header **new_table) +{ + if (!existing_table || !new_table) + return AE_BAD_PARAMETER; + + *new_table = NULL; + +#ifdef CONFIG_ACPI_CUSTOM_DSDT + if (strncmp(existing_table->signature, "DSDT", 4) == 0) + *new_table = (struct acpi_table_header *)AmlCode; +#endif + if (*new_table != NULL) + acpi_table_taint(existing_table); + return AE_OK; +} + +void __init early_acpi_table_init(void *data, size_t size) +{ + acpi_table_initrd_init(data, size); +} + /* * acpi_table_init() * @@ -457,7 +747,7 @@ int __init acpi_table_init(void) status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); if (ACPI_FAILURE(status)) return -EINVAL; - acpi_initrd_initialize_tables(); + acpi_table_initrd_scan(); check_multiple_madt(); return 0; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 06ed7e5..7718c04 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -190,14 +190,6 @@ static inline int acpi_debugger_notify_command_complete(void) } #endif -#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE -void acpi_initrd_override(void *data, size_t size); -#else -static inline void acpi_initrd_override(void *data, size_t size) -{ -} -#endif - #define BAD_MADT_ENTRY(entry, end) ( \ (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) @@ -216,6 +208,7 @@ void acpi_boot_table_init (void); int acpi_mps_check (void); int acpi_numa_init (void); +void early_acpi_table_init(void *data, size_t size); int acpi_table_init (void); int acpi_table_parse(char *id, acpi_tbl_table_handler handler); int __init acpi_parse_entries(char *id, unsigned long table_size, @@ -596,6 +589,7 @@ static inline const char *acpi_dev_name(struct acpi_device *adev) return NULL; } +static inline void early_acpi_table_init(void *data, size_t size) { } static inline void acpi_early_init(void) { } static inline void acpi_subsystem_init(void) { } -- cgit v0.10.2 From af06f8b7a102417e93dc57ee7affb9fedcf5d83f Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 11 Apr 2016 10:13:27 +0800 Subject: ACPI / x86: Cleanup initrd related code In arch/x86/kernel/setup.c, the #ifdef kept for CONFIG_ACPI actually is related to the accessibility of initrd_start/initrd_end, so the stub should be provided from this source file and should only be dependent on CONFIG_BLK_DEV_INITRD. Note that when ACPI=n and BLK_DEV_INITRD=y, early_initrd_acpi_init() is still a stub because of the stub prepared for early_acpi_table_init(). Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 902a6f7..c4e7b39 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -398,6 +398,11 @@ static void __init reserve_initrd(void) memblock_free(ramdisk_image, ramdisk_end - ramdisk_image); } + +static void __init early_initrd_acpi_init(void) +{ + early_acpi_table_init((void *)initrd_start, initrd_end - initrd_start); +} #else static void __init early_reserve_initrd(void) { @@ -405,6 +410,9 @@ static void __init early_reserve_initrd(void) static void __init reserve_initrd(void) { } +static void __init early_initrd_acpi_init(void) +{ +} #endif /* CONFIG_BLK_DEV_INITRD */ static void __init parse_setup_data(void) @@ -1138,9 +1146,7 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); -#if defined(CONFIG_ACPI) && defined(CONFIG_BLK_DEV_INITRD) - early_acpi_table_init((void *)initrd_start, initrd_end - initrd_start); -#endif + early_initrd_acpi_init(); vsmp_init(); -- cgit v0.10.2 From 5d8813271f8a7c86027afb2ef554f2a5a9ba7c15 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 11 Apr 2016 10:13:33 +0800 Subject: ACPI / tables: Convert initrd table override to table upgrade mechanism This patch converts the initrd table override mechanism to the table upgrade mechanism by restricting its usage to the tables released with compatibility and more recent revision. This use case has been encouraged by the ACPI specification: 1. OEMID: An OEM-supplied string that identifies the OEM. 2. OEM Table ID: An OEM-supplied string that the OEM uses to identify the particular data table. This field is particularly useful when defining a definition block to distinguish definition block functions. OEM assigns each dissimilar table a new OEM Table Id. 3. OEM Revision: An OEM-supplied revision number. Larger numbers are assumed to be newer revisions. For OEMs, good practices will ensure consistency when assigning OEMID and OEM Table ID fields in any table. The intent of these fields is to allow for a binary control system that support services can use. Because many support function can be automated, it is useful when a tool can programatically determine which table release is a compatible and more recent revision of a prior table on the same OEMID and OEM Table ID. The facility can now be used by the vendors to upgrade wrong tables for bug fixing purpose, thus lockdep disabling taint is not suitable for it and it should be a default 'y' option to implement the spec encouraged use case. Note that, by implementing table upgrade inside of ACPICA itself, it is possible to remove acpi_table_initrd_override() and tables can be upgraded by acpi_install_table() automatically. Though current ACPICA impelentation hasn't implemented this, this patched changes the table flag setting timing to allow this to be implemented in ACPICA without changing the code here. Documentation of initrd override mechanism is upgraded accordingly. Original-by: Octavian Purdila Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/Documentation/acpi/initrd_table_override.txt b/Documentation/acpi/initrd_table_override.txt index 35c3f54..eb651a6 100644 --- a/Documentation/acpi/initrd_table_override.txt +++ b/Documentation/acpi/initrd_table_override.txt @@ -1,5 +1,5 @@ -Overriding ACPI tables via initrd -================================= +Upgrading ACPI tables via initrd +================================ 1) Introduction (What is this about) 2) What is this for @@ -9,12 +9,14 @@ Overriding ACPI tables via initrd 1) What is this about --------------------- -If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to -override nearly any ACPI table provided by the BIOS with an instrumented, -modified one. +If the ACPI_TABLE_UPGRADE compile option is true, it is possible to +upgrade the ACPI execution environment that is defined by the ACPI tables +via upgrading the ACPI tables provided by the BIOS with an instrumented, +modified, more recent version one, or installing brand new ACPI tables. -For a full list of ACPI tables that can be overridden, take a look at -the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in drivers/acpi/osl.c +For a full list of ACPI tables that can be upgraded/installed, take a look +at the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in +drivers/acpi/tables.c. All ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should be overridable, except: - ACPI_SIG_RSDP (has a signature of 6 bytes) @@ -25,17 +27,20 @@ Both could get implemented as well. 2) What is this for ------------------- -Please keep in mind that this is a debug option. -ACPI tables should not get overridden for productive use. -If BIOS ACPI tables are overridden the kernel will get tainted with the -TAINT_OVERRIDDEN_ACPI_TABLE flag. -Complain to your platform/BIOS vendor if you find a bug which is so sever -that a workaround is not accepted in the Linux kernel. +Complain to your platform/BIOS vendor if you find a bug which is so severe +that a workaround is not accepted in the Linux kernel. And this facility +allows you to upgrade the buggy tables before your platform/BIOS vendor +releases an upgraded BIOS binary. -Still, it can and should be enabled in any kernel, because: - - There is no functional change with not instrumented initrds - - It provides a powerful feature to easily debug and test ACPI BIOS table - compatibility with the Linux kernel. +This facility can be used by platform/BIOS vendors to provide a Linux +compatible environment without modifying the underlying platform firmware. + +This facility also provides a powerful feature to easily debug and test +ACPI BIOS table compatibility with the Linux kernel by modifying old +platform provided ACPI tables or inserting new ACPI tables. + +It can and should be enabled in any kernel because there is no functional +change with not instrumented initrds. 3) How does it work @@ -50,23 +55,31 @@ iasl -d *.dat # For example add this statement into a _PRT (PCI Routing Table) function # of the DSDT: Store("HELLO WORLD", debug) +# And increase the OEM Revision. For example, before modification: +DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000000) +# After modification: +DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000001) iasl -sa dsdt.dsl # Add the raw ACPI tables to an uncompressed cpio archive. -# They must be put into a /kernel/firmware/acpi directory inside the -# cpio archive. -# The uncompressed cpio archive must be the first. -# Other, typically compressed cpio archives, must be -# concatenated on top of the uncompressed one. +# They must be put into a /kernel/firmware/acpi directory inside the cpio +# archive. Note that if the table put here matches a platform table +# (similar Table Signature, and similar OEMID, and similar OEM Table ID) +# with a more recent OEM Revision, the platform table will be upgraded by +# this table. If the table put here doesn't match a platform table +# (dissimilar Table Signature, or dissimilar OEMID, or dissimilar OEM Table +# ID), this table will be appended. mkdir -p kernel/firmware/acpi cp dsdt.aml kernel/firmware/acpi -# A maximum of: #define ACPI_OVERRIDE_TABLES 10 -# tables are currently allowed (see osl.c): +# A maximum of "NR_ACPI_INITRD_TABLES (64)" tables are currently allowed +# (see osl.c): iasl -sa facp.dsl iasl -sa ssdt1.dsl cp facp.aml kernel/firmware/acpi cp ssdt1.aml kernel/firmware/acpi -# Create the uncompressed cpio archive and concatenate the original initrd -# on top: +# The uncompressed cpio archive must be the first. Other, typically +# compressed cpio archives, must be concatenated on top of the uncompressed +# one. Following command creates the uncompressed cpio archive and +# concatenates the original initrd on top: find kernel | cpio -H newc --create > /boot/instrumented_initrd cat /boot/initrd >>/boot/instrumented_initrd # reboot with increased acpi debug level, e.g. boot params: diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 82b96ee..b225c4b 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -311,12 +311,12 @@ config ACPI_CUSTOM_DSDT bool default ACPI_CUSTOM_DSDT_FILE != "" -config ACPI_INITRD_TABLE_OVERRIDE - bool "ACPI tables override via initrd" +config ACPI_TABLE_UPGRADE + bool "Allow upgrading ACPI tables via initrd" depends on BLK_DEV_INITRD && X86 - default n + default y help - This option provides functionality to override arbitrary ACPI tables + This option provides functionality to upgrade arbitrary ACPI tables via initrd. No functional change if no ACPI tables are passed via initrd, therefore it's safe to say Y. See Documentation/acpi/initrd_table_override.txt for details diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 2e74dbf..08795fb 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -442,7 +442,7 @@ static void acpi_table_taint(struct acpi_table_header *table) add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); } -#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +#ifdef CONFIG_ACPI_TABLE_UPGRADE static u64 acpi_tables_addr; static int all_tables_size; @@ -471,9 +471,9 @@ static const char * const table_sigs[] = { #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) -#define ACPI_OVERRIDE_TABLES 64 -static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES]; -static DECLARE_BITMAP(acpi_initrd_installed, ACPI_OVERRIDE_TABLES); +#define NR_ACPI_INITRD_TABLES 64 +static struct cpio_data __initdata acpi_initrd_files[NR_ACPI_INITRD_TABLES]; +static DECLARE_BITMAP(acpi_initrd_installed, NR_ACPI_INITRD_TABLES); #define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT) @@ -488,7 +488,7 @@ static void __init acpi_table_initrd_init(void *data, size_t size) if (data == NULL || size == 0) return; - for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { + for (no = 0; no < NR_ACPI_INITRD_TABLES; no++) { file = find_cpio_data(cpio_path, data, size, &offset); if (!file.data) break; @@ -611,19 +611,30 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table, table_length = table->length; /* Only override tables matched */ - if (test_bit(table_index, acpi_initrd_installed) || - memcmp(existing_table->signature, table->signature, 4) || + if (memcmp(existing_table->signature, table->signature, 4) || + memcmp(table->oem_id, existing_table->oem_id, + ACPI_OEM_ID_SIZE) || memcmp(table->oem_table_id, existing_table->oem_table_id, ACPI_OEM_TABLE_ID_SIZE)) { acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); goto next_table; } + /* + * Mark the table to avoid being used in + * acpi_table_initrd_scan() and check the revision. + */ + if (test_and_set_bit(table_index, acpi_initrd_installed) || + existing_table->oem_revision >= table->oem_revision) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + goto next_table; + } *length = table_length; *address = acpi_tables_addr + table_offset; - acpi_table_taint(existing_table); + pr_info("Table Upgrade: override [%4.4s-%6.6s-%8.8s]\n", + table->signature, table->oem_id, + table->oem_table_id); acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); - set_bit(table_index, acpi_initrd_installed); break; next_table: @@ -655,17 +666,26 @@ static void __init acpi_table_initrd_scan(void) table_length = table->length; /* Skip RSDT/XSDT which should only be used for override */ - if (test_bit(table_index, acpi_initrd_installed) || - ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) || + if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) || ACPI_COMPARE_NAME(table->signature, ACPI_SIG_XSDT)) { acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); goto next_table; } + /* + * Mark the table to avoid being used in + * acpi_table_initrd_override(). Though this is not possible + * because override is disabled in acpi_install_table(). + */ + if (test_and_set_bit(table_index, acpi_initrd_installed)) { + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + goto next_table; + } - acpi_table_taint(table); + pr_info("Table Upgrade: install [%4.4s-%6.6s-%8.8s]\n", + table->signature, table->oem_id, + table->oem_table_id); acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); acpi_install_table(acpi_tables_addr + table_offset, TRUE); - set_bit(table_index, acpi_initrd_installed); next_table: table_offset += table_length; table_index++; @@ -689,7 +709,7 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table, static void __init acpi_table_initrd_scan(void) { } -#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */ +#endif /* CONFIG_ACPI_TABLE_UPGRADE */ acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, -- cgit v0.10.2 From 702b07fcc9b264c9afd372676bbdd50a762dcde0 Mon Sep 17 00:00:00 2001 From: Lukasz Anaczkowski Date: Thu, 21 Apr 2016 11:29:00 +0200 Subject: ACPI / SRAT: fix SRAT parsing order with both LAPIC and X2APIC present SRAT maps APIC ID to proximity domains ids (PXM). Mapping from PXM to NUMA node ids is based on order of entries in SRAT table. SRAT table has just LAPIC entires or mix of LAPIC and X2APIC entries. As long as there are only LAPIC entires, mapping from proximity domain id to NUMA node id is as assumed by BIOS. However, once APIC entries are mixed, X2APIC entries would be first mapped which causes unexpected NUMA node mapping. To fix that, change parsing to check each entry against both LAPIC and X2APIC so mapping is in the SRAT/PXM order. This is supplemental change to the fix made by commit d81056b5278 (Handle apic/x2apic entries in MADT in correct order) and using the mechanism introduced by 9b3fedd (ACPI / tables: Add acpi_subtable_proc to ACPI table parsers). Fixes: d81056b5278 (Handle apic/x2apic entries in MADT in correct order) Signed-off-by: Lukasz Anaczkowski [ rjw : Subject & changelog ] Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 72b6e9e..d176e0e 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -327,10 +327,18 @@ int __init acpi_numa_init(void) /* SRAT: Static Resource Affinity Table */ if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { - acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY, - acpi_parse_x2apic_affinity, 0); - acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, - acpi_parse_processor_affinity, 0); + struct acpi_subtable_proc srat_proc[2]; + + memset(srat_proc, 0, sizeof(srat_proc)); + srat_proc[0].id = ACPI_SRAT_TYPE_CPU_AFFINITY; + srat_proc[0].handler = acpi_parse_processor_affinity; + srat_proc[1].id = ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY; + srat_proc[1].handler = acpi_parse_x2apic_affinity; + + acpi_table_parse_entries_array(ACPI_SIG_SRAT, + sizeof(struct acpi_table_srat), + srat_proc, ARRAY_SIZE(srat_proc), 0); + cnt = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); -- cgit v0.10.2 From 6df795ff139a85eba8767a1504414c41e8814a1a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 15 Apr 2016 08:53:41 +0100 Subject: ACPI / ARM64: Don't enable ACPI by default on ARM64 If ACPI is selectable it is enabled by default. This is a good choice for architectures where the overwhelming majority of systems use ACPI like x86 and IA-64 but is less clear for architectures where it's less common like ARM64. Change the default selection so that it's only done explicitly on those architectures where ACPI is universally used. Signed-off-by: Mark Brown Acked-by: Catalin Marinas Acked-by: Hanjun Guo Acked-by: Olof Johansson Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 82b96ee..2fcf87a 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -8,7 +8,7 @@ menuconfig ACPI depends on IA64 || X86 || (ARM64 && EXPERT) depends on PCI select PNP - default y + default y if (IA64 || X86) help Advanced Configuration and Power Interface (ACPI) support for Linux requires an ACPI-compliant platform (hardware/firmware), -- cgit v0.10.2 From 46bcc6b1f3f77ff0a5b88b87a6be5954ed0c3ce6 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 15 Apr 2016 08:53:42 +0100 Subject: ACPI / ARM64: Remove EXPERT dependency for ACPI on ARM64 When ACPI was originally merged for arm64 it had only been tested on emulators and not on real physical platforms and no platforms were relying on it. This meant that there were concerns that there might be serious issues attempting to use it on practical systems so it had a dependency on EXPERT added to warn people that it was in an early stage of development with very little practical testing. Since then things have moved on a bit. We have seen people testing on real hardware and now have people starting to produce some platforms (the most prominent being the 96boards Cello) which only have ACPI support and which build and run to some useful extent with mainline. This is not to say that ACPI support or support for these systems is completely done, there are still areas being worked on such as PCI, but at this point it seems that we can be reasonably sure that ACPI will be viable for use on ARM64 and that the already merged support works for the cases it handles. For the AMD Seattle based platforms support outside of PCI has been fairly complete in mainline a few releases now. This is also not to say that we don't have vendors working with ACPI who are trying do things that we would not consider optimal but it does not appear that the EXPERT dependency is having a substantial impact on these vendors. Given all this it seems that at this point the EXPERT dependency mainly creates inconvenience for users with systems that are doing the right thing and gets in the way of including the ACPI code in the testing that people are doing on mainline. Removing it should help our ongoing testing cover those platforms with only ACPI support and help ensure that when ACPI code is merged any problems it causes for other users are more easily discovered. Signed-off-by: Mark Brown Acked-by: Graeme Gregory Acked-by: Ard Biesheuvel Reviewed-by: Al Stone Acked-by: Hanjun Guo Acked-by: Catalin Marinas Acked-by: Roy Franz Acked-by: Olof Johansson Acked-by: Timur Tabi Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 2fcf87a..fa0d319 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -5,7 +5,7 @@ menuconfig ACPI bool "ACPI (Advanced Configuration and Power Interface) Support" depends on !IA64_HP_SIM - depends on IA64 || X86 || (ARM64 && EXPERT) + depends on IA64 || X86 || ARM64 depends on PCI select PNP default y if (IA64 || X86) -- cgit v0.10.2 From 2b13f01b90fc07334911b424709901bb88517746 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 15 Apr 2016 08:53:43 +0100 Subject: arm64: defconfig: Enable ACPI Enable ACPI by default to support testing of ACPI only systems and ensure that defconfig will boot on anything, for arm64 this is not done in Kconfig since a very large proportion of arm64 systems have no ACPI at all. Signed-off-by: Mark Brown Acked-by: Catalin Marinas Acked-by: Hanjun Guo Acked-by: Roy Franz Signed-off-by: Rafael J. Wysocki diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index a44ef99..c5e0132 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -264,6 +264,7 @@ CONFIG_PHY_RCAR_GEN3_USB2=y CONFIG_PHY_HI6220_USB=y CONFIG_PHY_XGENE=y CONFIG_ARM_SCPI_PROTOCOL=y +CONFIG_ACPI=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y CONFIG_FANOTIFY=y -- cgit v0.10.2 From cdd9a6b2a7461021a5ee24bc130592c1bdc54cd8 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 19 Apr 2016 18:27:46 -0700 Subject: ACPI / APD: Remove CLK_IS_ROOT This flag is a no-op now (see commit 47b0eeb3dc8a "clk: Deprecate CLK_IS_ROOT", 2016-02-02) so remove it. Signed-off-by: Stephen Boyd Acked-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c index f245bf3..1daf9c4 100644 --- a/drivers/acpi/acpi_apd.c +++ b/drivers/acpi/acpi_apd.c @@ -62,8 +62,7 @@ static int acpi_apd_setup(struct apd_private_data *pdata) if (dev_desc->fixed_clk_rate) { clk = clk_register_fixed_rate(&pdata->adev->dev, dev_name(&pdata->adev->dev), - NULL, CLK_IS_ROOT, - dev_desc->fixed_clk_rate); + NULL, 0, dev_desc->fixed_clk_rate); clk_register_clkdev(clk, NULL, dev_name(&pdata->adev->dev)); pdata->clk = clk; } -- cgit v0.10.2 From 628e35baa8e1e19217eb11b6ccfa96c273757d18 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 19 Apr 2016 18:28:38 -0700 Subject: ACPI / amba: Remove CLK_IS_ROOT This flag is a no-op now (see commit 47b0eeb3dc8a "clk: Deprecate CLK_IS_ROOT", 2016-02-02) so remove it. Signed-off-by: Stephen Boyd Acked-by: Graeme Gregory Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c index 2a61b54..7f77c07 100644 --- a/drivers/acpi/acpi_amba.c +++ b/drivers/acpi/acpi_amba.c @@ -35,8 +35,7 @@ static void amba_register_dummy_clk(void) if (amba_dummy_clk) return; - amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, - CLK_IS_ROOT, 0); + amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, 0, 0); clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL); } -- cgit v0.10.2 From f6a4790a5471d7cba406d87f6b41323f40bb93d2 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Wed, 27 Apr 2016 20:45:02 +0800 Subject: video / backlight: add two APIs for drivers to use It is useful to get the backlight device's pointer and use it to set backlight in some cases(the following patch will make use of it) so add the two APIs and export them. Signed-off-by: Aaron Lu Acked-by: Jingoo Han Signed-off-by: Rafael J. Wysocki diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index bddc8b1..18901b9 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -164,18 +164,10 @@ static ssize_t brightness_show(struct device *dev, return sprintf(buf, "%d\n", bd->props.brightness); } -static ssize_t brightness_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +int backlight_device_set_brightness(struct backlight_device *bd, + unsigned long brightness) { - int rc; - struct backlight_device *bd = to_backlight_device(dev); - unsigned long brightness; - - rc = kstrtoul(buf, 0, &brightness); - if (rc) - return rc; - - rc = -ENXIO; + int rc = -ENXIO; mutex_lock(&bd->ops_lock); if (bd->ops) { @@ -185,7 +177,7 @@ static ssize_t brightness_store(struct device *dev, pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; backlight_update_status(bd); - rc = count; + rc = 0; } } mutex_unlock(&bd->ops_lock); @@ -194,6 +186,23 @@ static ssize_t brightness_store(struct device *dev, return rc; } +EXPORT_SYMBOL(backlight_device_set_brightness); + +static ssize_t brightness_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int rc; + struct backlight_device *bd = to_backlight_device(dev); + unsigned long brightness; + + rc = kstrtoul(buf, 0, &brightness); + if (rc) + return rc; + + rc = backlight_device_set_brightness(bd, brightness); + + return rc ? rc : count; +} static DEVICE_ATTR_RW(brightness); static ssize_t type_show(struct device *dev, struct device_attribute *attr, @@ -380,7 +389,7 @@ struct backlight_device *backlight_device_register(const char *name, } EXPORT_SYMBOL(backlight_device_register); -bool backlight_device_registered(enum backlight_type type) +struct backlight_device *backlight_device_get_by_type(enum backlight_type type) { bool found = false; struct backlight_device *bd; @@ -394,7 +403,13 @@ bool backlight_device_registered(enum backlight_type type) } mutex_unlock(&backlight_dev_list_mutex); - return found; + return found ? bd : NULL; +} +EXPORT_SYMBOL(backlight_device_get_by_type); + +bool backlight_device_registered(enum backlight_type type) +{ + return backlight_device_get_by_type(type) ? true : false; } EXPORT_SYMBOL(backlight_device_registered); diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 1e7a69a..f46b88f 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -144,6 +144,8 @@ extern void backlight_force_update(struct backlight_device *bd, extern bool backlight_device_registered(enum backlight_type type); extern int backlight_register_notifier(struct notifier_block *nb); extern int backlight_unregister_notifier(struct notifier_block *nb); +extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); +extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness); #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) -- cgit v0.10.2 From 01c3664de62f89f6777e59173ad8e20b5a4c267f Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Wed, 27 Apr 2016 20:45:03 +0800 Subject: video / backlight: remove the backlight_device_registered API Since we will need the backlight_device_get_by_type API, we can use it instead of the backlight_device_registered API whenever necessary so remove the backlight_device_registered API. Signed-off-by: Aaron Lu Acked-by: Jingoo Han Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 1316ddd..3d13276 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -358,7 +358,7 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void) if (!(video_caps & ACPI_VIDEO_BACKLIGHT)) return acpi_backlight_vendor; - if (acpi_osi_is_win8() && backlight_device_registered(BACKLIGHT_RAW)) + if (acpi_osi_is_win8() && backlight_device_get_by_type(BACKLIGHT_RAW)) return acpi_backlight_native; return acpi_backlight_video; diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 18901b9..288318a 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -407,12 +407,6 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type) } EXPORT_SYMBOL(backlight_device_get_by_type); -bool backlight_device_registered(enum backlight_type type) -{ - return backlight_device_get_by_type(type) ? true : false; -} -EXPORT_SYMBOL(backlight_device_registered); - /** * backlight_device_unregister - unregisters a backlight device object. * @bd: the backlight device object to be unregistered and freed. diff --git a/include/linux/backlight.h b/include/linux/backlight.h index f46b88f..5f2fd61 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -141,7 +141,6 @@ extern void devm_backlight_device_unregister(struct device *dev, struct backlight_device *bd); extern void backlight_force_update(struct backlight_device *bd, enum backlight_update_reason reason); -extern bool backlight_device_registered(enum backlight_type type); extern int backlight_register_notifier(struct notifier_block *nb); extern int backlight_unregister_notifier(struct notifier_block *nb); extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); -- cgit v0.10.2 From 059500940defe285222d3b189b366dfe7f299cae Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Wed, 27 Apr 2016 20:45:04 +0800 Subject: ACPI/video: export acpi_video_get_levels The acpi_video_get_levels is useful for other drivers, i.e. the to-be-added int3406 thermal driver, so export it. Signed-off-by: Aaron Lu Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 4361bc9..3d5b8a0 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -191,19 +191,6 @@ struct acpi_video_device_cap { u8 _DDC:1; /* Return the EDID for this device */ }; -struct acpi_video_brightness_flags { - u8 _BCL_no_ac_battery_levels:1; /* no AC/Battery levels in _BCL */ - u8 _BCL_reversed:1; /* _BCL package is in a reversed order */ - u8 _BQC_use_index:1; /* _BQC returns an index value */ -}; - -struct acpi_video_device_brightness { - int curr; - int count; - int *levels; - struct acpi_video_brightness_flags flags; -}; - struct acpi_video_device { unsigned long device_id; struct acpi_video_device_flags flags; @@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = { */ static int -acpi_video_device_lcd_query_levels(struct acpi_video_device *device, +acpi_video_device_lcd_query_levels(acpi_handle handle, union acpi_object **levels) { int status; @@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, *levels = NULL; - status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer); + status = acpi_evaluate_object(handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) return status; obj = (union acpi_object *)buffer.pointer; @@ -766,36 +753,28 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device, return 0; } - -/* - * Arg: - * device : video output device (LCD, CRT, ..) - * - * Return Value: - * Maximum brightness level - * - * Allocate and initialize device->brightness. - */ - -static int -acpi_video_init_brightness(struct acpi_video_device *device) +int acpi_video_get_levels(struct acpi_device *device, + struct acpi_video_device_brightness **dev_br) { union acpi_object *obj = NULL; int i, max_level = 0, count = 0, level_ac_battery = 0; - unsigned long long level, level_old; union acpi_object *o; struct acpi_video_device_brightness *br = NULL; - int result = -EINVAL; + int result = 0; u32 value; - if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) { + if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle, + &obj))) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available " "LCD brightness level\n")); + result = -ENODEV; goto out; } - if (obj->package.count < 2) + if (obj->package.count < 2) { + result = -EINVAL; goto out; + } br = kzalloc(sizeof(*br), GFP_KERNEL); if (!br) { @@ -861,6 +840,38 @@ acpi_video_init_brightness(struct acpi_video_device *device) "Found unordered _BCL package")); br->count = count; + *dev_br = br; + +out: + kfree(obj); + return result; +out_free: + kfree(br); + goto out; +} +EXPORT_SYMBOL(acpi_video_get_levels); + +/* + * Arg: + * device : video output device (LCD, CRT, ..) + * + * Return Value: + * Maximum brightness level + * + * Allocate and initialize device->brightness. + */ + +static int +acpi_video_init_brightness(struct acpi_video_device *device) +{ + int i, max_level = 0; + unsigned long long level, level_old; + struct acpi_video_device_brightness *br = NULL; + int result = -EINVAL; + + result = acpi_video_get_levels(device->dev, &br); + if (result) + return result; device->brightness = br; /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ @@ -903,17 +914,13 @@ set_level: goto out_free_levels; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "found %d brightness levels\n", count - 2)); - kfree(obj); - return result; + "found %d brightness levels\n", br->count - 2)); + return 0; out_free_levels: kfree(br->levels); -out_free: kfree(br); -out: device->brightness = NULL; - kfree(obj); return result; } diff --git a/include/acpi/video.h b/include/acpi/video.h index 5ca2f2c..a4b96c9 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -4,6 +4,19 @@ #include /* for ENODEV */ #include /* for bool */ +struct acpi_video_brightness_flags { + u8 _BCL_no_ac_battery_levels:1; /* no AC/Battery levels in _BCL */ + u8 _BCL_reversed:1; /* _BCL package is in a reversed order */ + u8 _BQC_use_index:1; /* _BQC returns an index value */ +}; + +struct acpi_video_device_brightness { + int curr; + int count; + int *levels; + struct acpi_video_brightness_flags flags; +}; + struct acpi_device; #define ACPI_VIDEO_CLASS "video" @@ -37,6 +50,8 @@ extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type); * may change over time and should not be cached. */ extern bool acpi_video_handles_brightness_key_presses(void); +extern int acpi_video_get_levels(struct acpi_device *device, + struct acpi_video_device_brightness **dev_br); #else static inline int acpi_video_register(void) { return 0; } static inline void acpi_video_unregister(void) { return; } @@ -56,6 +71,11 @@ static inline bool acpi_video_handles_brightness_key_presses(void) { return false; } +static int acpi_video_get_levels(struct acpi_device *device, + struct acpi_video_device_brightness **dev_br) +{ + return -ENODEV; +} #endif #endif -- cgit v0.10.2 From 6283f97d5fbfdd1e31694d7f6000eb728cdfba77 Mon Sep 17 00:00:00 2001 From: Betty Dall Date: Sat, 30 Apr 2016 10:03:37 -0600 Subject: ACPI / device_sysfs: Add sysfs support for _HRV hardware revision The ACPI _HRV object on the device is used to supply Linux with the device's hardware revision. This is an optional object. Add sysfs support for the _HRV object if it exists on the device. This change allows users to easily find the hardware version of non-PCI hardware by looking at the sysfs 'hrv' file. It is most useful for non-PCI devices because lspci can list the hardware version for PCI devices. Signed-off-by: Betty Dall Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index b9afb47..49cc0cb 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); +static ssize_t +acpi_device_hrv_show(struct device *dev, struct device_attribute *attr, + char *buf) { + struct acpi_device *acpi_dev = to_acpi_device(dev); + acpi_status status; + unsigned long long hrv; + + status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv); + if (ACPI_FAILURE(status)) + return -EIO; + + return sprintf(buf, "%llu\n", hrv); +} +static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL); + static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { struct acpi_device *acpi_dev = to_acpi_device(dev); @@ -541,6 +556,12 @@ int acpi_device_setup_files(struct acpi_device *dev) goto end; } + if (acpi_has_method(dev->handle, "_HRV")) { + result = device_create_file(&dev->dev, &dev_attr_hrv); + if (result) + goto end; + } + if (acpi_has_method(dev->handle, "_STA")) { result = device_create_file(&dev->dev, &dev_attr_status); if (result) @@ -604,6 +625,9 @@ void acpi_device_remove_files(struct acpi_device *dev) if (acpi_has_method(dev->handle, "_SUN")) device_remove_file(&dev->dev, &dev_attr_sun); + if (acpi_has_method(dev->handle, "_HRV")) + device_remove_file(&dev->dev, &dev_attr_hrv); + if (dev->pnp.unique_id) device_remove_file(&dev->dev, &dev_attr_uid); if (dev->pnp.type.bus_address) -- cgit v0.10.2 From 6c0244091e8aa98e7977bdddeab2bb864cff9d91 Mon Sep 17 00:00:00 2001 From: Betty Dall Date: Sat, 30 Apr 2016 10:03:38 -0600 Subject: ACPI / device_sysfs: Change _SUN and _STA show functions error return to EIO The error return from a sysfs show function is passed up through the call chain and visible as the return from the read system call. The show functions for the _STA and _SUN object currently return -ENODEV. This patch changes the return to -EIO. ENODEV makes less sense since the "device' exists or there wouldn't be a sysfs file. Signed-off-by: Betty Dall Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index 49cc0cb..e556a3e 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -467,7 +467,7 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr, status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun); if (ACPI_FAILURE(status)) - return -ENODEV; + return -EIO; return sprintf(buf, "%llu\n", sun); } @@ -496,7 +496,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr, status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return -ENODEV; + return -EIO; return sprintf(buf, "%llu\n", sta); } -- cgit v0.10.2 From a508d954af748bc1f5f1d9174f167a8650fca923 Mon Sep 17 00:00:00 2001 From: Betty Dall Date: Sat, 30 Apr 2016 10:03:39 -0600 Subject: ACPI / device_sysfs: Clean up checkpatch errors Cleaning up two existing checkpatch errors (and 2 warnings) in device_sysfs.c since the file is being changed. The change in acpi_device_setup_files() is changing spaces to a tab. Signed-off-by: Betty Dall Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index e556a3e..7b2c48f 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -35,7 +35,7 @@ static ssize_t acpi_object_path(acpi_handle handle, char *buf) if (result) return result; - result = sprintf(buf, "%s\n", (char*)path.pointer); + result = sprintf(buf, "%s\n", (char *)path.pointer); kfree(path.pointer); return result; } @@ -333,7 +333,8 @@ int acpi_device_modalias(struct device *dev, char *buf, int size) EXPORT_SYMBOL_GPL(acpi_device_modalias); static ssize_t -acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { +acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) +{ return __acpi_device_modalias(to_acpi_device(dev), buf, 1024); } static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); @@ -397,7 +398,8 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); static ssize_t -acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) { +acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) +{ struct acpi_device *acpi_dev = to_acpi_device(dev); return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev)); @@ -568,10 +570,10 @@ int acpi_device_setup_files(struct acpi_device *dev) goto end; } - /* - * If device has _EJ0, 'eject' file is created that is used to trigger - * hot-removal function from userland. - */ + /* + * If device has _EJ0, 'eject' file is created that is used to trigger + * hot-removal function from userland. + */ if (acpi_has_method(dev->handle, "_EJ0")) { result = device_create_file(&dev->dev, &dev_attr_eject); if (result) -- cgit v0.10.2 From 30c9bb0d7603e7b3f4d6a0ea231e1cddae020c32 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:48:20 +0800 Subject: ACPI / osi: Fix an issue that acpi_osi=!* cannot disable ACPICA internal strings The order of the _OSI related functionalities is as follows: acpi_blacklisted() acpi_dmi_osi_linux() acpi_osi_setup() acpi_osi_setup() acpi_update_interfaces() if "!*" <<<<<<<<<<<<<<<<<<<<<<<< parse_args() __setup("acpi_osi=") acpi_osi_setup_linux() acpi_update_interfaces() if "!*" <<<<<<<<<<<<<<<<<<<<<<<< acpi_early_init() acpi_initialize_subsystem() acpi_ut_initialize_interfaces() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ acpi_bus_init() acpi_os_initialize1() acpi_install_interface_handler(acpi_osi_handler) acpi_osi_setup_late() acpi_update_interfaces() for "!" >>>>>>>>>>>>>>>>>>>>>>>> acpi_osi_handler() Since acpi_osi_setup_linux() can override acpi_dmi_osi_linux(), the command line setting can override the DMI detection. That's why acpi_blacklisted() is put before __setup("acpi_osi="). Then we can notice the following wrong invocation order. There are acpi_update_interfaces() (marked by <<<<) calls invoked before acpi_ut_initialize_interfaces() (marked by ^^^^). This makes it impossible to use acpi_osi=!* correctly from OSI DMI table or from the command line. The use of acpi_osi=!* is meant to disable both ACPICA (acpi_gbl_supported_interfaces) and Linux specific strings (osi_setup_entries) while the ACPICA part should have stopped working because of the order issue. This patch fixes this issue by moving acpi_update_interfaces() to where it is invoked for acpi_osi=! (marked by >>>>) as this is ensured to be invoked after acpi_ut_initialize_interfaces() (marked by ^^^^). Linux specific strings are still handled in the original place in order to make the following command line working: acpi_osi=!* acpi_osi="Module Device". Note that since acpi_osi=!* is meant to further disable linux specific string comparing to the acpi_osi=!, there is no such use case in our bug fixing work and hence there is no one using acpi_osi=!* either from the command line or from the DMI quirks, this issue is just a theoretical issue. Fixes: 741d81280ad2 (ACPI: Add facility to remove all _OSI strings) Cc: 3.12+ # 3.12+ Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 814d5f8..f036775 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -135,7 +135,7 @@ static struct osi_linux { unsigned int enable:1; unsigned int dmi:1; unsigned int cmdline:1; - unsigned int default_disabling:1; + u8 default_disabling; } osi_linux = {0, 0, 0, 0}; static u32 acpi_osi_handler(acpi_string interface, u32 supported) @@ -1751,10 +1751,13 @@ void __init acpi_osi_setup(char *str) if (*str == '!') { str++; if (*str == '\0') { - osi_linux.default_disabling = 1; + /* Do not override acpi_osi=!* */ + if (!osi_linux.default_disabling) + osi_linux.default_disabling = + ACPI_DISABLE_ALL_VENDOR_STRINGS; return; } else if (*str == '*') { - acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS); + osi_linux.default_disabling = ACPI_DISABLE_ALL_STRINGS; for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { osi = &osi_setup_entries[i]; osi->enable = false; @@ -1827,10 +1830,13 @@ static void __init acpi_osi_setup_late(void) acpi_status status; if (osi_linux.default_disabling) { - status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); + status = acpi_update_interfaces(osi_linux.default_disabling); if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n"); + printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n", + osi_linux.default_disabling == + ACPI_DISABLE_ALL_STRINGS ? + " and feature groups" : ""); } for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { -- cgit v0.10.2 From dbee890bf69ad62c021e299e24881fdcd1f2c481 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:48:27 +0800 Subject: ACPI / osi: Cleanup _OSI("Linux") related code before introducing new support This patch cleans up OSI code in osl.c to make osi_linux work for OSI strings other than "Linux", so it can be re-used for other purposes. Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index f036775..9f59dd1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -131,12 +131,12 @@ static void __init acpi_osi_setup_late(void); * or boot with "acpi_osi=Linux" */ -static struct osi_linux { - unsigned int enable:1; - unsigned int dmi:1; - unsigned int cmdline:1; +static struct acpi_osi_config { + unsigned int linux_enable:1; + unsigned int linux_dmi:1; + unsigned int linux_cmdline:1; u8 default_disabling; -} osi_linux = {0, 0, 0, 0}; +} osi_config = {0, 0, 0, 0}; static u32 acpi_osi_handler(acpi_string interface, u32 supported) { @@ -144,9 +144,9 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported) printk_once(KERN_NOTICE FW_BUG PREFIX "BIOS _OSI(Linux) query %s%s\n", - osi_linux.enable ? "honored" : "ignored", - osi_linux.cmdline ? " via cmdline" : - osi_linux.dmi ? " via DMI" : ""); + osi_config.linux_enable ? "honored" : "ignored", + osi_config.linux_cmdline ? " via cmdline" : + osi_config.linux_dmi ? " via DMI" : ""); } if (!strcmp("Darwin", interface)) { @@ -1752,12 +1752,12 @@ void __init acpi_osi_setup(char *str) str++; if (*str == '\0') { /* Do not override acpi_osi=!* */ - if (!osi_linux.default_disabling) - osi_linux.default_disabling = + if (!osi_config.default_disabling) + osi_config.default_disabling = ACPI_DISABLE_ALL_VENDOR_STRINGS; return; } else if (*str == '*') { - osi_linux.default_disabling = ACPI_DISABLE_ALL_STRINGS; + osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS; for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { osi = &osi_setup_entries[i]; osi->enable = false; @@ -1782,10 +1782,10 @@ void __init acpi_osi_setup(char *str) static void __init set_osi_linux(unsigned int enable) { - if (osi_linux.enable != enable) - osi_linux.enable = enable; + if (osi_config.linux_enable != enable) + osi_config.linux_enable = enable; - if (osi_linux.enable) + if (osi_config.linux_enable) acpi_osi_setup("Linux"); else acpi_osi_setup("!Linux"); @@ -1795,8 +1795,9 @@ static void __init set_osi_linux(unsigned int enable) static void __init acpi_cmdline_osi_linux(unsigned int enable) { - osi_linux.cmdline = 1; /* cmdline set the default and override DMI */ - osi_linux.dmi = 0; + /* cmdline set the default and override DMI */ + osi_config.linux_cmdline = 1; + osi_config.linux_dmi = 0; set_osi_linux(enable); return; @@ -1809,7 +1810,8 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) if (enable == -1) return; - osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ + /* DMI knows that this box asks OSI(Linux) */ + osi_config.linux_dmi = 1; set_osi_linux(enable); return; @@ -1829,12 +1831,12 @@ static void __init acpi_osi_setup_late(void) int i; acpi_status status; - if (osi_linux.default_disabling) { - status = acpi_update_interfaces(osi_linux.default_disabling); + if (osi_config.default_disabling) { + status = acpi_update_interfaces(osi_config.default_disabling); if (ACPI_SUCCESS(status)) printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n", - osi_linux.default_disabling == + osi_config.default_disabling == ACPI_DISABLE_ALL_STRINGS ? " and feature groups" : ""); } -- cgit v0.10.2 From a707edebadf1230f202000f29b28b7586ada4aa3 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:48:32 +0800 Subject: ACPI / osi: Add acpi_osi=!! to allow reverting acpi_osi=! This patch introduces acpi_osi=!! so that quirks may use it to revert acpi_osi=!. Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 0b3de80..c48f387 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -312,6 +312,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. acpi_osi=!* # remove all strings acpi_osi=! # disable all built-in OS vendor strings + acpi_osi=!! # enable all built-in OS vendor + strings acpi_osi= # disable all strings 'acpi_osi=!' can be used in combination with single or diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 9f59dd1..f801b59 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1763,6 +1763,9 @@ void __init acpi_osi_setup(char *str) osi->enable = false; } return; + } else if (*str == '!') { + osi_config.default_disabling = 0; + return; } enable = false; } -- cgit v0.10.2 From e10cfdc33a0f23dc8449be7267f0a642e96a2a24 Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Tue, 3 May 2016 16:48:39 +0800 Subject: ACPI / osi: Fix default _OSI(Darwin) support The following commit always reports positive value when Apple hardware queries _OSI("Darwin"): Commit: 7bc5a2bad0b8d9d1ac9f7b8b33150e4ddf197334 Subject: ACPI: Support _OSI("Darwin") correctly However since this implementation places the judgement in runtime, it breaks acpi_osi=!Darwin and cannot return unsupported for _OSI("WinXXX") invoked before invoking _OSI("Darwin"). This patch fixes the issues by reverting the wrong support and implementing the default behavior of _OSI("Darwin")/_OSI("WinXXX") on Apple hardware via DMI matching. Fixes: 7bc5a2bad0b8 (ACPI: Support _OSI("Darwin") correctly) Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111 Reported-and-tested-by: Lukas Wunner Signed-off-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 96809cd..45390a9 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -133,6 +133,11 @@ int __init acpi_blacklisted(void) return blacklisted; } #ifdef CONFIG_DMI +static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) +{ + acpi_dmi_osi_darwin(1, d); /* enable */ + return 0; +} static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) { acpi_dmi_osi_linux(1, d); /* enable */ @@ -331,6 +336,24 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, }, + /* + * Enable _OSI("Darwin") for all apple platforms. + */ + { + .callback = dmi_enable_osi_darwin, + .ident = "Apple hardware", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + }, + }, + { + .callback = dmi_enable_osi_darwin, + .ident = "Apple hardware", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), + }, + }, + #ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE /* * DELL XPS 13 (2015) switches sound between HDA and I2S diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index f801b59..1b84e46 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -135,6 +135,9 @@ static struct acpi_osi_config { unsigned int linux_enable:1; unsigned int linux_dmi:1; unsigned int linux_cmdline:1; + unsigned int darwin_enable:1; + unsigned int darwin_dmi:1; + unsigned int darwin_cmdline:1; u8 default_disabling; } osi_config = {0, 0, 0, 0}; @@ -150,13 +153,12 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported) } if (!strcmp("Darwin", interface)) { - /* - * Apple firmware will behave poorly if it receives positive - * answers to "Darwin" and any other OS. Respond positively - * to Darwin and then disable all other vendor strings. - */ - acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); - supported = ACPI_UINT32_MAX; + + printk_once(KERN_NOTICE PREFIX + "BIOS _OSI(Darwin) query %s%s\n", + osi_config.darwin_enable ? "honored" : "ignored", + osi_config.darwin_cmdline ? " via cmdline" : + osi_config.darwin_dmi ? " via DMI" : ""); } return supported; @@ -1783,6 +1785,44 @@ void __init acpi_osi_setup(char *str) } } +static void __init set_osi_darwin(unsigned int enable) +{ + if (osi_config.darwin_enable != enable) + osi_config.darwin_enable = enable; + + if (enable) { + acpi_osi_setup("!"); + acpi_osi_setup("Darwin"); + } else { + acpi_osi_setup("!!"); + acpi_osi_setup("!Darwin"); + } +} + +static void __init acpi_cmdline_osi_darwin(unsigned int enable) +{ + /* cmdline set the default and override DMI */ + osi_config.darwin_cmdline = 1; + osi_config.darwin_dmi = 0; + set_osi_darwin(enable); + + return; +} + +void __init acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d) +{ + printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); + + if (enable == -1) + return; + + /* DMI knows that this box asks OSI(Darwin) */ + osi_config.darwin_dmi = 1; + set_osi_darwin(enable); + + return; +} + static void __init set_osi_linux(unsigned int enable) { if (osi_config.linux_enable != enable) @@ -1870,6 +1910,10 @@ static int __init osi_setup(char *str) acpi_cmdline_osi_linux(1); else if (str && !strcmp("!Linux", str)) acpi_cmdline_osi_linux(0); + else if (str && !strcmp("Darwin", str)) + acpi_cmdline_osi_darwin(1); + else if (str && !strcmp("!Darwin", str)) + acpi_cmdline_osi_darwin(0); else acpi_osi_setup(str); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 06ed7e5..6c7176e 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -360,6 +360,7 @@ extern char acpi_video_backlight_string[]; extern long acpi_is_video_device(acpi_handle handle); extern int acpi_blacklisted(void); extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); +extern void acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d); extern void acpi_osi_setup(char *str); extern bool acpi_osi_is_win8(void); -- cgit v0.10.2 From dc45eb20a83d11ed649169fbe9159ed6bf586c88 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:48:46 +0800 Subject: ACPI / osi: Cleanup OSI handling code to use bool This patch changes "int/unsigned int" to "bool" to simplify the code. Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 45390a9..d7d498a 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -135,12 +135,12 @@ int __init acpi_blacklisted(void) #ifdef CONFIG_DMI static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) { - acpi_dmi_osi_darwin(1, d); /* enable */ + acpi_dmi_osi_darwin(true, d); /* enable */ return 0; } static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) { - acpi_dmi_osi_linux(1, d); /* enable */ + acpi_dmi_osi_linux(true, d); /* enable */ return 0; } static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 1b84e46..e30f325 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1785,11 +1785,9 @@ void __init acpi_osi_setup(char *str) } } -static void __init set_osi_darwin(unsigned int enable) +static void __init set_osi_darwin(bool enable) { - if (osi_config.darwin_enable != enable) - osi_config.darwin_enable = enable; - + osi_config.darwin_enable = !!enable; if (enable) { acpi_osi_setup("!"); acpi_osi_setup("Darwin"); @@ -1799,7 +1797,7 @@ static void __init set_osi_darwin(unsigned int enable) } } -static void __init acpi_cmdline_osi_darwin(unsigned int enable) +static void __init acpi_cmdline_osi_darwin(bool enable) { /* cmdline set the default and override DMI */ osi_config.darwin_cmdline = 1; @@ -1809,13 +1807,10 @@ static void __init acpi_cmdline_osi_darwin(unsigned int enable) return; } -void __init acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d) +void __init acpi_dmi_osi_darwin(bool enable, const struct dmi_system_id *d) { printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); - if (enable == -1) - return; - /* DMI knows that this box asks OSI(Darwin) */ osi_config.darwin_dmi = 1; set_osi_darwin(enable); @@ -1823,12 +1818,10 @@ void __init acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d) return; } -static void __init set_osi_linux(unsigned int enable) +static void __init set_osi_linux(bool enable) { - if (osi_config.linux_enable != enable) - osi_config.linux_enable = enable; - - if (osi_config.linux_enable) + osi_config.linux_enable = !!enable; + if (enable) acpi_osi_setup("Linux"); else acpi_osi_setup("!Linux"); @@ -1836,7 +1829,7 @@ static void __init set_osi_linux(unsigned int enable) return; } -static void __init acpi_cmdline_osi_linux(unsigned int enable) +static void __init acpi_cmdline_osi_linux(bool enable) { /* cmdline set the default and override DMI */ osi_config.linux_cmdline = 1; @@ -1846,13 +1839,10 @@ static void __init acpi_cmdline_osi_linux(unsigned int enable) return; } -void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) +void __init acpi_dmi_osi_linux(bool enable, const struct dmi_system_id *d) { printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); - if (enable == -1) - return; - /* DMI knows that this box asks OSI(Linux) */ osi_config.linux_dmi = 1; set_osi_linux(enable); @@ -1907,13 +1897,13 @@ static void __init acpi_osi_setup_late(void) static int __init osi_setup(char *str) { if (str && !strcmp("Linux", str)) - acpi_cmdline_osi_linux(1); + acpi_cmdline_osi_linux(true); else if (str && !strcmp("!Linux", str)) - acpi_cmdline_osi_linux(0); + acpi_cmdline_osi_linux(false); else if (str && !strcmp("Darwin", str)) - acpi_cmdline_osi_darwin(1); + acpi_cmdline_osi_darwin(true); else if (str && !strcmp("!Darwin", str)) - acpi_cmdline_osi_darwin(0); + acpi_cmdline_osi_darwin(false); else acpi_osi_setup(str); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6c7176e..0ccfeba 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -359,8 +359,8 @@ extern bool wmi_has_guid(const char *guid); extern char acpi_video_backlight_string[]; extern long acpi_is_video_device(acpi_handle handle); extern int acpi_blacklisted(void); -extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); -extern void acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d); +extern void acpi_dmi_osi_linux(bool enable, const struct dmi_system_id *d); +extern void acpi_dmi_osi_darwin(bool enable, const struct dmi_system_id *d); extern void acpi_osi_setup(char *str); extern bool acpi_osi_is_win8(void); -- cgit v0.10.2 From d5a91d74c6d7da2cebadbb9f2d03e56f84d7be62 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:48:53 +0800 Subject: ACPI / osi: Cleanup coding style issues before creating a separate OSI source file This patch performs necessary cleanups before moving OSI support to another file. 1. Change printk into pr_xxx 2. Do not initialize values to 0 3. Do not append additional "return" at the end of the function 4. Remove useless comments which may easily break line breaking rule After fixing the coding style issues, rename functions to make them looking like acpi_osi_xxx. No functional changes. Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index d7d498a..ba1601d 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -135,17 +135,17 @@ int __init acpi_blacklisted(void) #ifdef CONFIG_DMI static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) { - acpi_dmi_osi_darwin(true, d); /* enable */ + acpi_osi_dmi_darwin(true, d); return 0; } static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) { - acpi_dmi_osi_linux(true, d); /* enable */ + acpi_osi_dmi_linux(true, d); return 0; } static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) { - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); + pr_notice(PREFIX "DMI detected: %s\n", d->ident); acpi_osi_setup("!Windows 2006"); acpi_osi_setup("!Windows 2006 SP1"); acpi_osi_setup("!Windows 2006 SP2"); @@ -153,13 +153,13 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) } static int __init dmi_disable_osi_win7(const struct dmi_system_id *d) { - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); + pr_notice(PREFIX "DMI detected: %s\n", d->ident); acpi_osi_setup("!Windows 2009"); return 0; } static int __init dmi_disable_osi_win8(const struct dmi_system_id *d) { - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); + pr_notice(PREFIX "DMI detected: %s\n", d->ident); acpi_osi_setup("!Windows 2012"); return 0; } diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e30f325..1340516 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -139,13 +139,13 @@ static struct acpi_osi_config { unsigned int darwin_dmi:1; unsigned int darwin_cmdline:1; u8 default_disabling; -} osi_config = {0, 0, 0, 0}; +} osi_config; static u32 acpi_osi_handler(acpi_string interface, u32 supported) { if (!strcmp("Linux", interface)) { - printk_once(KERN_NOTICE FW_BUG PREFIX + pr_notice_once(FW_BUG PREFIX "BIOS _OSI(Linux) query %s%s\n", osi_config.linux_enable ? "honored" : "ignored", osi_config.linux_cmdline ? " via cmdline" : @@ -154,7 +154,7 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported) if (!strcmp("Darwin", interface)) { - printk_once(KERN_NOTICE PREFIX + pr_notice_once(PREFIX "BIOS _OSI(Darwin) query %s%s\n", osi_config.darwin_enable ? "honored" : "ignored", osi_config.darwin_cmdline ? " via cmdline" : @@ -1719,15 +1719,15 @@ static int __init acpi_os_name_setup(char *str) __setup("acpi_os_name=", acpi_os_name_setup); -#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ -#define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */ +#define OSI_STRING_LENGTH_MAX 64 +#define OSI_STRING_ENTRIES_MAX 16 -struct osi_setup_entry { +struct acpi_osi_entry { char string[OSI_STRING_LENGTH_MAX]; bool enable; }; -static struct osi_setup_entry +static struct acpi_osi_entry osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { {"Module Device", true}, {"Processor Device", true}, @@ -1737,7 +1737,7 @@ static struct osi_setup_entry void __init acpi_osi_setup(char *str) { - struct osi_setup_entry *osi; + struct acpi_osi_entry *osi; bool enable = true; int i; @@ -1745,7 +1745,7 @@ void __init acpi_osi_setup(char *str) return; if (str == NULL || *str == '\0') { - printk(KERN_INFO PREFIX "_OSI method disabled\n"); + pr_info(PREFIX "_OSI method disabled\n"); acpi_gbl_create_osi_method = FALSE; return; } @@ -1785,7 +1785,7 @@ void __init acpi_osi_setup(char *str) } } -static void __init set_osi_darwin(bool enable) +static void __init __acpi_osi_setup_darwin(bool enable) { osi_config.darwin_enable = !!enable; if (enable) { @@ -1797,57 +1797,43 @@ static void __init set_osi_darwin(bool enable) } } -static void __init acpi_cmdline_osi_darwin(bool enable) +static void __init acpi_osi_setup_darwin(bool enable) { - /* cmdline set the default and override DMI */ osi_config.darwin_cmdline = 1; osi_config.darwin_dmi = 0; - set_osi_darwin(enable); - - return; + __acpi_osi_setup_darwin(enable); } -void __init acpi_dmi_osi_darwin(bool enable, const struct dmi_system_id *d) +void __init acpi_osi_dmi_darwin(bool enable, const struct dmi_system_id *d) { - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); - - /* DMI knows that this box asks OSI(Darwin) */ + pr_notice(PREFIX "DMI detected to setup _OSI(\"Darwin\"): %s\n", + d->ident); osi_config.darwin_dmi = 1; - set_osi_darwin(enable); - - return; + __acpi_osi_setup_darwin(enable); } -static void __init set_osi_linux(bool enable) +static void __init __acpi_osi_setup_linux(bool enable) { osi_config.linux_enable = !!enable; if (enable) acpi_osi_setup("Linux"); else acpi_osi_setup("!Linux"); - - return; } -static void __init acpi_cmdline_osi_linux(bool enable) +static void __init acpi_osi_setup_linux(bool enable) { - /* cmdline set the default and override DMI */ osi_config.linux_cmdline = 1; osi_config.linux_dmi = 0; - set_osi_linux(enable); - - return; + __acpi_osi_setup_linux(enable); } -void __init acpi_dmi_osi_linux(bool enable, const struct dmi_system_id *d) +void __init acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d) { - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); - - /* DMI knows that this box asks OSI(Linux) */ + pr_notice(PREFIX "DMI detected to setup _OSI(\"Linux\"): %s\n", + d->ident); osi_config.linux_dmi = 1; - set_osi_linux(enable); - - return; + __acpi_osi_setup_linux(enable); } /* @@ -1859,7 +1845,7 @@ void __init acpi_dmi_osi_linux(bool enable, const struct dmi_system_id *d) */ static void __init acpi_osi_setup_late(void) { - struct osi_setup_entry *osi; + struct acpi_osi_entry *osi; char *str; int i; acpi_status status; @@ -1868,7 +1854,7 @@ static void __init acpi_osi_setup_late(void) status = acpi_update_interfaces(osi_config.default_disabling); if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n", + pr_info(PREFIX "Disabled all _OSI OS vendors%s\n", osi_config.default_disabling == ACPI_DISABLE_ALL_STRINGS ? " and feature groups" : ""); @@ -1884,12 +1870,12 @@ static void __init acpi_osi_setup_late(void) status = acpi_install_interface(str); if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); + pr_info(PREFIX "Added _OSI(%s)\n", str); } else { status = acpi_remove_interface(str); if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); + pr_info(PREFIX "Deleted _OSI(%s)\n", str); } } } @@ -1897,13 +1883,13 @@ static void __init acpi_osi_setup_late(void) static int __init osi_setup(char *str) { if (str && !strcmp("Linux", str)) - acpi_cmdline_osi_linux(true); + acpi_osi_setup_linux(true); else if (str && !strcmp("!Linux", str)) - acpi_cmdline_osi_linux(false); + acpi_osi_setup_linux(false); else if (str && !strcmp("Darwin", str)) - acpi_cmdline_osi_darwin(true); + acpi_osi_setup_darwin(true); else if (str && !strcmp("!Darwin", str)) - acpi_cmdline_osi_darwin(false); + acpi_osi_setup_darwin(false); else acpi_osi_setup(str); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 0ccfeba..bf0adc6 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -359,8 +359,8 @@ extern bool wmi_has_guid(const char *guid); extern char acpi_video_backlight_string[]; extern long acpi_is_video_device(acpi_handle handle); extern int acpi_blacklisted(void); -extern void acpi_dmi_osi_linux(bool enable, const struct dmi_system_id *d); -extern void acpi_dmi_osi_darwin(bool enable, const struct dmi_system_id *d); +extern void acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d); +extern void acpi_osi_dmi_darwin(bool enable, const struct dmi_system_id *d); extern void acpi_osi_setup(char *str); extern bool acpi_osi_is_win8(void); -- cgit v0.10.2 From e5f660ebef68e3ed1a988ad06ba23562153cee5c Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Tue, 3 May 2016 16:49:01 +0800 Subject: ACPI / osi: Collect _OSI handling into one single file _OSI handling code grows giant and it's time to move them into one file. This patch collects all _OSI handling code into one single file. So that we only have the following functions to be used externally: early_acpi_osi_init(): Used by DMI detections; acpi_osi_init(): Used to initialize OSI command line settings and install Linux specific _OSI handler; acpi_osi_setup(): The API that should be used by the external quirks. acpi_osi_is_win8(): The API is used by the external drivers to determine if BIOS supports Win8. CONFIG_DMI is not useful as stub dmi_check_system() can make everything stub because of strip. No functional changes. Tested-by: Lukas Wunner Tested-by: Chen Yu Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index edeb2d1..345df7f 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -18,7 +18,7 @@ obj-$(CONFIG_ACPI) += acpi.o \ acpica/ # All the builtin files are in the "acpi." module_param namespace. -acpi-y += osl.o utils.o reboot.o +acpi-y += osi.o osl.o utils.o reboot.o acpi-y += nvs.o # Power management related files diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index ba1601d..bdc67ba 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -3,7 +3,7 @@ * * Check to see if the given machine has a known bad ACPI BIOS * or if the BIOS is too old. - * Check given machine against acpi_osi_dmi_table[]. + * Check given machine against acpi_rev_dmi_table[]. * * Copyright (C) 2004 Len Brown * Copyright (C) 2002 Andy Grover @@ -47,7 +47,7 @@ struct acpi_blacklist_item { u32 is_critical_error; }; -static struct dmi_system_id acpi_osi_dmi_table[] __initdata; +static struct dmi_system_id acpi_rev_dmi_table[] __initdata; /* * POLICY: If *anything* doesn't work, put it on the blacklist. @@ -128,41 +128,12 @@ int __init acpi_blacklisted(void) } } - dmi_check_system(acpi_osi_dmi_table); + (void)early_acpi_osi_init(); + dmi_check_system(acpi_rev_dmi_table); return blacklisted; } #ifdef CONFIG_DMI -static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) -{ - acpi_osi_dmi_darwin(true, d); - return 0; -} -static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) -{ - acpi_osi_dmi_linux(true, d); - return 0; -} -static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) -{ - pr_notice(PREFIX "DMI detected: %s\n", d->ident); - acpi_osi_setup("!Windows 2006"); - acpi_osi_setup("!Windows 2006 SP1"); - acpi_osi_setup("!Windows 2006 SP2"); - return 0; -} -static int __init dmi_disable_osi_win7(const struct dmi_system_id *d) -{ - pr_notice(PREFIX "DMI detected: %s\n", d->ident); - acpi_osi_setup("!Windows 2009"); - return 0; -} -static int __init dmi_disable_osi_win8(const struct dmi_system_id *d) -{ - pr_notice(PREFIX "DMI detected: %s\n", d->ident); - acpi_osi_setup("!Windows 2012"); - return 0; -} #ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE static int __init dmi_enable_rev_override(const struct dmi_system_id *d) { @@ -173,187 +144,7 @@ static int __init dmi_enable_rev_override(const struct dmi_system_id *d) } #endif -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { - { - .callback = dmi_disable_osi_vista, - .ident = "Fujitsu Siemens", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), - DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), - }, - }, - { - /* - * There have a NVIF method in MSI GX723 DSDT need call by Nvidia - * driver (e.g. nouveau) when user press brightness hotkey. - * Currently, nouveau driver didn't do the job and it causes there - * have a infinite while loop in DSDT when user press hotkey. - * We add MSI GX723's dmi information to this table for workaround - * this issue. - * Will remove MSI GX723 from the table after nouveau grows support. - */ - .callback = dmi_disable_osi_vista, - .ident = "MSI GX723", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"), - DMI_MATCH(DMI_PRODUCT_NAME, "GX723"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "Sony VGN-NS10J_S", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS10J_S"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "Sony VGN-SR290J", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR290J"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "VGN-NS50B_L", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS50B_L"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "VGN-SR19XN", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "Toshiba Satellite L355", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), - DMI_MATCH(DMI_PRODUCT_VERSION, "Satellite L355"), - }, - }, - { - .callback = dmi_disable_osi_win7, - .ident = "ASUS K50IJ", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "Toshiba P305D", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), - DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P305D"), - }, - }, - { - .callback = dmi_disable_osi_vista, - .ident = "Toshiba NB100", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), - DMI_MATCH(DMI_PRODUCT_NAME, "NB100"), - }, - }, - - /* - * The wireless hotkey does not work on those machines when - * returning true for _OSI("Windows 2012") - */ - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Inspiron 7737", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"), - }, - }, - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Inspiron 7537", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"), - }, - }, - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Inspiron 5437", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5437"), - }, - }, - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Inspiron 3437", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3437"), - }, - }, - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Vostro 3446", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"), - }, - }, - { - .callback = dmi_disable_osi_win8, - .ident = "Dell Vostro 3546", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3546"), - }, - }, - - /* - * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. - * Linux ignores it, except for the machines enumerated below. - */ - - /* - * Without this this EEEpc exports a non working WMI interface, with - * this it exports a working "good old" eeepc_laptop interface, fixing - * both brightness control, and rfkill not working. - */ - { - .callback = dmi_enable_osi_linux, - .ident = "Asus EEE PC 1015PX", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"), - }, - }, - - /* - * Enable _OSI("Darwin") for all apple platforms. - */ - { - .callback = dmi_enable_osi_darwin, - .ident = "Apple hardware", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - }, - }, - { - .callback = dmi_enable_osi_darwin, - .ident = "Apple hardware", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), - }, - }, - +static struct dmi_system_id acpi_rev_dmi_table[] __initdata = { #ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE /* * DELL XPS 13 (2015) switches sound between HDA and I2S diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 7c18847..a8780a2 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -20,6 +20,8 @@ #define PREFIX "ACPI: " +int early_acpi_osi_init(void); +int acpi_osi_init(void); void acpi_initrd_initialize_tables(void); acpi_status acpi_os_initialize1(void); void init_acpi_device_notify(void); diff --git a/drivers/acpi/osi.c b/drivers/acpi/osi.c new file mode 100644 index 0000000..849f9d2 --- /dev/null +++ b/drivers/acpi/osi.c @@ -0,0 +1,522 @@ +/* + * osi.c - _OSI implementation + * + * Copyright (C) 2016 Intel Corporation + * Author: Lv Zheng + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * 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. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* Uncomment next line to get verbose printout */ +/* #define DEBUG */ +#define pr_fmt(fmt) "ACPI: " fmt + +#include +#include +#include +#include + +#include "internal.h" + + +#define OSI_STRING_LENGTH_MAX 64 +#define OSI_STRING_ENTRIES_MAX 16 + +struct acpi_osi_entry { + char string[OSI_STRING_LENGTH_MAX]; + bool enable; +}; + +static struct acpi_osi_config { + u8 default_disabling; + unsigned int linux_enable:1; + unsigned int linux_dmi:1; + unsigned int linux_cmdline:1; + unsigned int darwin_enable:1; + unsigned int darwin_dmi:1; + unsigned int darwin_cmdline:1; +} osi_config; + +static struct acpi_osi_config osi_config; +static struct acpi_osi_entry +osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { + {"Module Device", true}, + {"Processor Device", true}, + {"3.0 _SCP Extensions", true}, + {"Processor Aggregator Device", true}, +}; + +static u32 acpi_osi_handler(acpi_string interface, u32 supported) +{ + if (!strcmp("Linux", interface)) { + pr_notice_once(FW_BUG + "BIOS _OSI(Linux) query %s%s\n", + osi_config.linux_enable ? "honored" : "ignored", + osi_config.linux_cmdline ? " via cmdline" : + osi_config.linux_dmi ? " via DMI" : ""); + } + if (!strcmp("Darwin", interface)) { + pr_notice_once( + "BIOS _OSI(Darwin) query %s%s\n", + osi_config.darwin_enable ? "honored" : "ignored", + osi_config.darwin_cmdline ? " via cmdline" : + osi_config.darwin_dmi ? " via DMI" : ""); + } + + return supported; +} + +void __init acpi_osi_setup(char *str) +{ + struct acpi_osi_entry *osi; + bool enable = true; + int i; + + if (!acpi_gbl_create_osi_method) + return; + + if (str == NULL || *str == '\0') { + pr_info("_OSI method disabled\n"); + acpi_gbl_create_osi_method = FALSE; + return; + } + + if (*str == '!') { + str++; + if (*str == '\0') { + /* Do not override acpi_osi=!* */ + if (!osi_config.default_disabling) + osi_config.default_disabling = + ACPI_DISABLE_ALL_VENDOR_STRINGS; + return; + } else if (*str == '*') { + osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS; + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + osi->enable = false; + } + return; + } else if (*str == '!') { + osi_config.default_disabling = 0; + return; + } + enable = false; + } + + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + if (!strcmp(osi->string, str)) { + osi->enable = enable; + break; + } else if (osi->string[0] == '\0') { + osi->enable = enable; + strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); + break; + } + } +} + +static void __init __acpi_osi_setup_darwin(bool enable) +{ + osi_config.darwin_enable = !!enable; + if (enable) { + acpi_osi_setup("!"); + acpi_osi_setup("Darwin"); + } else { + acpi_osi_setup("!!"); + acpi_osi_setup("!Darwin"); + } +} + +static void __init acpi_osi_setup_darwin(bool enable) +{ + /* Override acpi_osi_dmi_blacklisted() */ + osi_config.darwin_dmi = 0; + osi_config.darwin_cmdline = 1; + __acpi_osi_setup_darwin(enable); +} + +/* + * The story of _OSI(Linux) + * + * From pre-history through Linux-2.6.22, Linux responded TRUE upon a BIOS + * OSI(Linux) query. + * + * Unfortunately, reference BIOS writers got wind of this and put + * OSI(Linux) in their example code, quickly exposing this string as + * ill-conceived and opening the door to an un-bounded number of BIOS + * incompatibilities. + * + * For example, OSI(Linux) was used on resume to re-POST a video card on + * one system, because Linux at that time could not do a speedy restore in + * its native driver. But then upon gaining quick native restore + * capability, Linux has no way to tell the BIOS to skip the time-consuming + * POST -- putting Linux at a permanent performance disadvantage. On + * another system, the BIOS writer used OSI(Linux) to infer native OS + * support for IPMI! On other systems, OSI(Linux) simply got in the way of + * Linux claiming to be compatible with other operating systems, exposing + * BIOS issues such as skipped device initialization. + * + * So "Linux" turned out to be a really poor chose of OSI string, and from + * Linux-2.6.23 onward we respond FALSE. + * + * BIOS writers should NOT query _OSI(Linux) on future systems. Linux will + * complain on the console when it sees it, and return FALSE. To get Linux + * to return TRUE for your system will require a kernel source update to + * add a DMI entry, or boot with "acpi_osi=Linux" + */ +static void __init __acpi_osi_setup_linux(bool enable) +{ + osi_config.linux_enable = !!enable; + if (enable) + acpi_osi_setup("Linux"); + else + acpi_osi_setup("!Linux"); +} + +static void __init acpi_osi_setup_linux(bool enable) +{ + /* Override acpi_osi_dmi_blacklisted() */ + osi_config.linux_dmi = 0; + osi_config.linux_cmdline = 1; + __acpi_osi_setup_linux(enable); +} + +/* + * Modify the list of "OS Interfaces" reported to BIOS via _OSI + * + * empty string disables _OSI + * string starting with '!' disables that string + * otherwise string is added to list, augmenting built-in strings + */ +static void __init acpi_osi_setup_late(void) +{ + struct acpi_osi_entry *osi; + char *str; + int i; + acpi_status status; + + if (osi_config.default_disabling) { + status = acpi_update_interfaces(osi_config.default_disabling); + if (ACPI_SUCCESS(status)) + pr_info("Disabled all _OSI OS vendors%s\n", + osi_config.default_disabling == + ACPI_DISABLE_ALL_STRINGS ? + " and feature groups" : ""); + } + + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + str = osi->string; + if (*str == '\0') + break; + if (osi->enable) { + status = acpi_install_interface(str); + if (ACPI_SUCCESS(status)) + pr_info("Added _OSI(%s)\n", str); + } else { + status = acpi_remove_interface(str); + if (ACPI_SUCCESS(status)) + pr_info("Deleted _OSI(%s)\n", str); + } + } +} + +static int __init osi_setup(char *str) +{ + if (str && !strcmp("Linux", str)) + acpi_osi_setup_linux(true); + else if (str && !strcmp("!Linux", str)) + acpi_osi_setup_linux(false); + else if (str && !strcmp("Darwin", str)) + acpi_osi_setup_darwin(true); + else if (str && !strcmp("!Darwin", str)) + acpi_osi_setup_darwin(false); + else + acpi_osi_setup(str); + + return 1; +} +__setup("acpi_osi=", osi_setup); + +bool acpi_osi_is_win8(void) +{ + return acpi_gbl_osi_data >= ACPI_OSI_WIN_8; +} +EXPORT_SYMBOL(acpi_osi_is_win8); + +static void __init acpi_osi_dmi_darwin(bool enable, + const struct dmi_system_id *d) +{ + pr_notice("DMI detected to setup _OSI(\"Darwin\"): %s\n", d->ident); + osi_config.darwin_dmi = 1; + __acpi_osi_setup_darwin(enable); +} + +void __init acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d) +{ + pr_notice("DMI detected to setup _OSI(\"Linux\"): %s\n", d->ident); + osi_config.linux_dmi = 1; + __acpi_osi_setup_linux(enable); +} + +static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) +{ + acpi_osi_dmi_darwin(true, d); + + return 0; +} + +static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) +{ + acpi_osi_dmi_linux(true, d); + + return 0; +} + +static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) +{ + pr_notice("DMI detected: %s\n", d->ident); + acpi_osi_setup("!Windows 2006"); + acpi_osi_setup("!Windows 2006 SP1"); + acpi_osi_setup("!Windows 2006 SP2"); + + return 0; +} + +static int __init dmi_disable_osi_win7(const struct dmi_system_id *d) +{ + pr_notice("DMI detected: %s\n", d->ident); + acpi_osi_setup("!Windows 2009"); + + return 0; +} + +static int __init dmi_disable_osi_win8(const struct dmi_system_id *d) +{ + pr_notice("DMI detected: %s\n", d->ident); + acpi_osi_setup("!Windows 2012"); + + return 0; +} + +/* + * Linux default _OSI response behavior is determined by this DMI table. + * + * Note that _OSI("Linux")/_OSI("Darwin") determined here can be overridden + * by acpi_osi=!Linux/acpi_osi=!Darwin command line options. + */ +static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { + { + .callback = dmi_disable_osi_vista, + .ident = "Fujitsu Siemens", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), + }, + }, + { + /* + * There have a NVIF method in MSI GX723 DSDT need call by Nvidia + * driver (e.g. nouveau) when user press brightness hotkey. + * Currently, nouveau driver didn't do the job and it causes there + * have a infinite while loop in DSDT when user press hotkey. + * We add MSI GX723's dmi information to this table for workaround + * this issue. + * Will remove MSI GX723 from the table after nouveau grows support. + */ + .callback = dmi_disable_osi_vista, + .ident = "MSI GX723", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"), + DMI_MATCH(DMI_PRODUCT_NAME, "GX723"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "Sony VGN-NS10J_S", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS10J_S"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "Sony VGN-SR290J", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR290J"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "VGN-NS50B_L", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS50B_L"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "VGN-SR19XN", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "Toshiba Satellite L355", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Satellite L355"), + }, + }, + { + .callback = dmi_disable_osi_win7, + .ident = "ASUS K50IJ", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "Toshiba P305D", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), + DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P305D"), + }, + }, + { + .callback = dmi_disable_osi_vista, + .ident = "Toshiba NB100", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), + DMI_MATCH(DMI_PRODUCT_NAME, "NB100"), + }, + }, + + /* + * The wireless hotkey does not work on those machines when + * returning true for _OSI("Windows 2012") + */ + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Inspiron 7737", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"), + }, + }, + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Inspiron 7537", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"), + }, + }, + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Inspiron 5437", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5437"), + }, + }, + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Inspiron 3437", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3437"), + }, + }, + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Vostro 3446", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"), + }, + }, + { + .callback = dmi_disable_osi_win8, + .ident = "Dell Vostro 3546", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3546"), + }, + }, + + /* + * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. + * Linux ignores it, except for the machines enumerated below. + */ + + /* + * Without this this EEEpc exports a non working WMI interface, with + * this it exports a working "good old" eeepc_laptop interface, fixing + * both brightness control, and rfkill not working. + */ + { + .callback = dmi_enable_osi_linux, + .ident = "Asus EEE PC 1015PX", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"), + }, + }, + + /* + * Enable _OSI("Darwin") for all apple platforms. + */ + { + .callback = dmi_enable_osi_darwin, + .ident = "Apple hardware", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + }, + }, + { + .callback = dmi_enable_osi_darwin, + .ident = "Apple hardware", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), + }, + }, + {} +}; + +static __init void acpi_osi_dmi_blacklisted(void) +{ + dmi_check_system(acpi_osi_dmi_table); +} + +int __init early_acpi_osi_init(void) +{ + acpi_osi_dmi_blacklisted(); + + return 0; +} + +int __init acpi_osi_init(void) +{ + acpi_install_interface_handler(acpi_osi_handler); + acpi_osi_setup_late(); + + return 0; +} diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 1340516..29af6b4 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -96,74 +96,6 @@ struct acpi_ioremap { static LIST_HEAD(acpi_ioremaps); static DEFINE_MUTEX(acpi_ioremap_lock); -static void __init acpi_osi_setup_late(void); - -/* - * The story of _OSI(Linux) - * - * From pre-history through Linux-2.6.22, - * Linux responded TRUE upon a BIOS OSI(Linux) query. - * - * Unfortunately, reference BIOS writers got wind of this - * and put OSI(Linux) in their example code, quickly exposing - * this string as ill-conceived and opening the door to - * an un-bounded number of BIOS incompatibilities. - * - * For example, OSI(Linux) was used on resume to re-POST a - * video card on one system, because Linux at that time - * could not do a speedy restore in its native driver. - * But then upon gaining quick native restore capability, - * Linux has no way to tell the BIOS to skip the time-consuming - * POST -- putting Linux at a permanent performance disadvantage. - * On another system, the BIOS writer used OSI(Linux) - * to infer native OS support for IPMI! On other systems, - * OSI(Linux) simply got in the way of Linux claiming to - * be compatible with other operating systems, exposing - * BIOS issues such as skipped device initialization. - * - * So "Linux" turned out to be a really poor chose of - * OSI string, and from Linux-2.6.23 onward we respond FALSE. - * - * BIOS writers should NOT query _OSI(Linux) on future systems. - * Linux will complain on the console when it sees it, and return FALSE. - * To get Linux to return TRUE for your system will require - * a kernel source update to add a DMI entry, - * or boot with "acpi_osi=Linux" - */ - -static struct acpi_osi_config { - unsigned int linux_enable:1; - unsigned int linux_dmi:1; - unsigned int linux_cmdline:1; - unsigned int darwin_enable:1; - unsigned int darwin_dmi:1; - unsigned int darwin_cmdline:1; - u8 default_disabling; -} osi_config; - -static u32 acpi_osi_handler(acpi_string interface, u32 supported) -{ - if (!strcmp("Linux", interface)) { - - pr_notice_once(FW_BUG PREFIX - "BIOS _OSI(Linux) query %s%s\n", - osi_config.linux_enable ? "honored" : "ignored", - osi_config.linux_cmdline ? " via cmdline" : - osi_config.linux_dmi ? " via DMI" : ""); - } - - if (!strcmp("Darwin", interface)) { - - pr_notice_once(PREFIX - "BIOS _OSI(Darwin) query %s%s\n", - osi_config.darwin_enable ? "honored" : "ignored", - osi_config.darwin_cmdline ? " via cmdline" : - osi_config.darwin_dmi ? " via DMI" : ""); - } - - return supported; -} - static void __init acpi_request_region (struct acpi_generic_address *gas, unsigned int length, char *desc) { @@ -1719,185 +1651,6 @@ static int __init acpi_os_name_setup(char *str) __setup("acpi_os_name=", acpi_os_name_setup); -#define OSI_STRING_LENGTH_MAX 64 -#define OSI_STRING_ENTRIES_MAX 16 - -struct acpi_osi_entry { - char string[OSI_STRING_LENGTH_MAX]; - bool enable; -}; - -static struct acpi_osi_entry - osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { - {"Module Device", true}, - {"Processor Device", true}, - {"3.0 _SCP Extensions", true}, - {"Processor Aggregator Device", true}, -}; - -void __init acpi_osi_setup(char *str) -{ - struct acpi_osi_entry *osi; - bool enable = true; - int i; - - if (!acpi_gbl_create_osi_method) - return; - - if (str == NULL || *str == '\0') { - pr_info(PREFIX "_OSI method disabled\n"); - acpi_gbl_create_osi_method = FALSE; - return; - } - - if (*str == '!') { - str++; - if (*str == '\0') { - /* Do not override acpi_osi=!* */ - if (!osi_config.default_disabling) - osi_config.default_disabling = - ACPI_DISABLE_ALL_VENDOR_STRINGS; - return; - } else if (*str == '*') { - osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS; - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - osi->enable = false; - } - return; - } else if (*str == '!') { - osi_config.default_disabling = 0; - return; - } - enable = false; - } - - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - if (!strcmp(osi->string, str)) { - osi->enable = enable; - break; - } else if (osi->string[0] == '\0') { - osi->enable = enable; - strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); - break; - } - } -} - -static void __init __acpi_osi_setup_darwin(bool enable) -{ - osi_config.darwin_enable = !!enable; - if (enable) { - acpi_osi_setup("!"); - acpi_osi_setup("Darwin"); - } else { - acpi_osi_setup("!!"); - acpi_osi_setup("!Darwin"); - } -} - -static void __init acpi_osi_setup_darwin(bool enable) -{ - osi_config.darwin_cmdline = 1; - osi_config.darwin_dmi = 0; - __acpi_osi_setup_darwin(enable); -} - -void __init acpi_osi_dmi_darwin(bool enable, const struct dmi_system_id *d) -{ - pr_notice(PREFIX "DMI detected to setup _OSI(\"Darwin\"): %s\n", - d->ident); - osi_config.darwin_dmi = 1; - __acpi_osi_setup_darwin(enable); -} - -static void __init __acpi_osi_setup_linux(bool enable) -{ - osi_config.linux_enable = !!enable; - if (enable) - acpi_osi_setup("Linux"); - else - acpi_osi_setup("!Linux"); -} - -static void __init acpi_osi_setup_linux(bool enable) -{ - osi_config.linux_cmdline = 1; - osi_config.linux_dmi = 0; - __acpi_osi_setup_linux(enable); -} - -void __init acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d) -{ - pr_notice(PREFIX "DMI detected to setup _OSI(\"Linux\"): %s\n", - d->ident); - osi_config.linux_dmi = 1; - __acpi_osi_setup_linux(enable); -} - -/* - * Modify the list of "OS Interfaces" reported to BIOS via _OSI - * - * empty string disables _OSI - * string starting with '!' disables that string - * otherwise string is added to list, augmenting built-in strings - */ -static void __init acpi_osi_setup_late(void) -{ - struct acpi_osi_entry *osi; - char *str; - int i; - acpi_status status; - - if (osi_config.default_disabling) { - status = acpi_update_interfaces(osi_config.default_disabling); - - if (ACPI_SUCCESS(status)) - pr_info(PREFIX "Disabled all _OSI OS vendors%s\n", - osi_config.default_disabling == - ACPI_DISABLE_ALL_STRINGS ? - " and feature groups" : ""); - } - - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - str = osi->string; - - if (*str == '\0') - break; - if (osi->enable) { - status = acpi_install_interface(str); - - if (ACPI_SUCCESS(status)) - pr_info(PREFIX "Added _OSI(%s)\n", str); - } else { - status = acpi_remove_interface(str); - - if (ACPI_SUCCESS(status)) - pr_info(PREFIX "Deleted _OSI(%s)\n", str); - } - } -} - -static int __init osi_setup(char *str) -{ - if (str && !strcmp("Linux", str)) - acpi_osi_setup_linux(true); - else if (str && !strcmp("!Linux", str)) - acpi_osi_setup_linux(false); - else if (str && !strcmp("Darwin", str)) - acpi_osi_setup_darwin(true); - else if (str && !strcmp("!Darwin", str)) - acpi_osi_setup_darwin(false); - else - acpi_osi_setup(str); - - return 1; -} - -__setup("acpi_osi=", osi_setup); - /* * Disable the auto-serialization of named objects creation methods. * @@ -2017,12 +1770,6 @@ int acpi_resources_are_enforced(void) } EXPORT_SYMBOL(acpi_resources_are_enforced); -bool acpi_osi_is_win8(void) -{ - return acpi_gbl_osi_data >= ACPI_OSI_WIN_8; -} -EXPORT_SYMBOL(acpi_osi_is_win8); - /* * Deallocate the memory for a spinlock. */ @@ -2188,8 +1935,7 @@ acpi_status __init acpi_os_initialize1(void) BUG_ON(!kacpid_wq); BUG_ON(!kacpi_notify_wq); BUG_ON(!kacpi_hotplug_wq); - acpi_install_interface_handler(acpi_osi_handler); - acpi_osi_setup_late(); + acpi_osi_init(); return AE_OK; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index bf0adc6..58f707a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -359,8 +359,6 @@ extern bool wmi_has_guid(const char *guid); extern char acpi_video_backlight_string[]; extern long acpi_is_video_device(acpi_handle handle); extern int acpi_blacklisted(void); -extern void acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d); -extern void acpi_osi_dmi_darwin(bool enable, const struct dmi_system_id *d); extern void acpi_osi_setup(char *str); extern bool acpi_osi_is_win8(void); -- cgit v0.10.2 From 103544d86976338057d6a91f721b49d3acc7df7f Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 17 Apr 2016 13:36:53 -0400 Subject: ACPI,PCI,IRQ: reduce resource requirements Code has been redesigned to calculate penalty requirements on the fly. This significantly simplifies the implementation and removes some of the init calls from x86 architecture. Signed-off-by: Sinan Kaya Acked-by: Bjorn Helgaas Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index ededa90..cc0ba16 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "internal.h" @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) #define ACPI_MAX_IRQS 256 #define ACPI_MAX_ISA_IRQ 16 -#define PIRQ_PENALTY_PCI_AVAILABLE (0) #define PIRQ_PENALTY_PCI_POSSIBLE (16*16) #define PIRQ_PENALTY_PCI_USING (16*16*16) #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16) @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */ PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */ PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */ - PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */ - PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */ - PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */ + 0, /* IRQ9 PCI, often acpi */ + 0, /* IRQ10 PCI */ + 0, /* IRQ11 PCI */ PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */ PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { /* >IRQ15 */ }; +static int acpi_irq_pci_sharing_penalty(int irq) +{ + struct acpi_pci_link *link; + int penalty = 0; + + list_for_each_entry(link, &acpi_link_list, list) { + /* + * If a link is active, penalize its IRQ heavily + * so we try to choose a different IRQ. + */ + if (link->irq.active && link->irq.active == irq) + penalty += PIRQ_PENALTY_PCI_USING; + else { + int i; + + /* + * If a link is inactive, penalize the IRQs it + * might use, but not as severely. + */ + for (i = 0; i < link->irq.possible_count; i++) + if (link->irq.possible[i] == irq) + penalty += PIRQ_PENALTY_PCI_POSSIBLE / + link->irq.possible_count; + } + } + + return penalty; +} + +static int acpi_irq_get_penalty(int irq) +{ + int penalty = 0; + + if (irq < ACPI_MAX_ISA_IRQ) + penalty += acpi_irq_penalty[irq]; + + /* + * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict + * with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be + * use for PCI IRQs. + */ + if (irq == acpi_gbl_FADT.sci_interrupt) { + u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK; + + if (type != IRQ_TYPE_LEVEL_LOW) + penalty += PIRQ_PENALTY_ISA_ALWAYS; + else + penalty += PIRQ_PENALTY_PCI_USING; + } + + penalty += acpi_irq_pci_sharing_penalty(irq); + return penalty; +} + int __init acpi_irq_penalty_init(void) { struct acpi_pci_link *link; @@ -547,12 +601,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) * the use of IRQs 9, 10, 11, and >15. */ for (i = (link->irq.possible_count - 1); i >= 0; i--) { - if (acpi_irq_penalty[irq] > - acpi_irq_penalty[link->irq.possible[i]]) + if (acpi_irq_get_penalty(irq) > + acpi_irq_get_penalty(link->irq.possible[i])) irq = link->irq.possible[i]; } } - if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) { + if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) { printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. " "Try pci=noacpi or acpi=off\n", acpi_device_name(link->device), @@ -568,7 +622,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) acpi_device_bid(link->device)); return -ENODEV; } else { - acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n", acpi_device_name(link->device), acpi_device_bid(link->device), link->irq.active); @@ -800,9 +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used) continue; if (used) - acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; + acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) + + PIRQ_PENALTY_ISA_USED; else - acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE; + acpi_irq_penalty[irq] = 0; if (retval != 2) /* no next number */ break; @@ -819,34 +873,19 @@ static int __init acpi_irq_penalty_update(char *str, int used) */ void acpi_penalize_isa_irq(int irq, int active) { - if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) { - if (active) - acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; - else - acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; - } + if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) + acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) + + active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING; } bool acpi_isa_irq_available(int irq) { return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) || - acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS); + acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS); } -/* - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for - * PCI IRQs. - */ void acpi_penalize_sci_irq(int irq, int trigger, int polarity) { - if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) { - if (trigger != ACPI_MADT_TRIGGER_LEVEL || - polarity != ACPI_MADT_POLARITY_ACTIVE_LOW) - acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS; - else - acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; - } } /* -- cgit v0.10.2 From 5c5087a5539083305f1199f09ac2e7f14d855ff3 Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 17 Apr 2016 13:36:54 -0400 Subject: ACPI,PCI,IRQ: reduce static IRQ array size to 16 Now that the supported number of PCI IRQs are no longer capped with 256, renaming the static array to support ISA IRQs only and removing the MAX_IRQS constant. Signed-off-by: Sinan Kaya Acked-by: Bjorn Helgaas Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index cc0ba16..12ea784 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -438,8 +438,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) * enabled system. */ -#define ACPI_MAX_IRQS 256 -#define ACPI_MAX_ISA_IRQ 16 +#define ACPI_MAX_ISA_IRQS 16 #define PIRQ_PENALTY_PCI_POSSIBLE (16*16) #define PIRQ_PENALTY_PCI_USING (16*16*16) @@ -447,7 +446,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16) #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16) -static int acpi_irq_penalty[ACPI_MAX_IRQS] = { +static int acpi_isa_irq_penalty[ACPI_MAX_ISA_IRQS] = { PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */ @@ -500,8 +499,8 @@ static int acpi_irq_get_penalty(int irq) { int penalty = 0; - if (irq < ACPI_MAX_ISA_IRQ) - penalty += acpi_irq_penalty[irq]; + if (irq < ACPI_MAX_ISA_IRQS) + penalty += acpi_isa_irq_penalty[irq]; /* * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict @@ -541,14 +540,15 @@ int __init acpi_irq_penalty_init(void) link->irq.possible_count; for (i = 0; i < link->irq.possible_count; i++) { - if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) - acpi_irq_penalty[link->irq. + if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS) + acpi_isa_irq_penalty[link->irq. possible[i]] += penalty; } - } else if (link->irq.active) { - acpi_irq_penalty[link->irq.active] += + } else if (link->irq.active && + (link->irq.active < ACPI_MAX_ISA_IRQS)) { + acpi_isa_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_POSSIBLE; } } @@ -831,7 +831,7 @@ static void acpi_pci_link_remove(struct acpi_device *device) } /* - * modify acpi_irq_penalty[] from cmdline + * modify acpi_isa_irq_penalty[] from cmdline */ static int __init acpi_irq_penalty_update(char *str, int used) { @@ -840,24 +840,24 @@ static int __init acpi_irq_penalty_update(char *str, int used) for (i = 0; i < 16; i++) { int retval; int irq; + int new_penalty; retval = get_option(&str, &irq); if (!retval) break; /* no number found */ - if (irq < 0) - continue; - - if (irq >= ARRAY_SIZE(acpi_irq_penalty)) + /* see if this is a ISA IRQ */ + if ((irq < 0) || (irq >= ACPI_MAX_ISA_IRQS)) continue; if (used) - acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) + - PIRQ_PENALTY_ISA_USED; + new_penalty = acpi_irq_get_penalty(irq) + + PIRQ_PENALTY_ISA_USED; else - acpi_irq_penalty[irq] = 0; + new_penalty = 0; + acpi_isa_irq_penalty[irq] = new_penalty; if (retval != 2) /* no next number */ break; } @@ -873,14 +873,14 @@ static int __init acpi_irq_penalty_update(char *str, int used) */ void acpi_penalize_isa_irq(int irq, int active) { - if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) - acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) + + if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty))) + acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) + active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING; } bool acpi_isa_irq_available(int irq) { - return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) || + return irq >= 0 && (irq >= ARRAY_SIZE(acpi_isa_irq_penalty) || acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS); } -- cgit v0.10.2 From 1fcb6a813c4f67a0ba189b0d057b70ba084f6e1a Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 17 Apr 2016 13:36:55 -0400 Subject: ACPI,PCI,IRQ: remove redundant code in acpi_irq_penalty_init() acpi_irq_get_penalty is now calculating the penalty on the fly now. No need to maintain global list of penalties or calculate them at the init time. Removing duplicate code in acpi_irq_penalty_init. Signed-off-by: Sinan Kaya Acked-by: Bjorn Helgaas Signed-off-by: Rafael J. Wysocki diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 3cd6983..b2a4e2a 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -396,7 +396,6 @@ int __init pci_acpi_init(void) return -ENODEV; printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n"); - acpi_irq_penalty_init(); pcibios_enable_irq = acpi_pci_irq_enable; pcibios_disable_irq = acpi_pci_irq_disable; x86_init.pci.init_irq = x86_init_noop; diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 12ea784..ab39208 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -520,42 +520,6 @@ static int acpi_irq_get_penalty(int irq) return penalty; } -int __init acpi_irq_penalty_init(void) -{ - struct acpi_pci_link *link; - int i; - - /* - * Update penalties to facilitate IRQ balancing. - */ - list_for_each_entry(link, &acpi_link_list, list) { - - /* - * reflect the possible and active irqs in the penalty table -- - * useful for breaking ties. - */ - if (link->irq.possible_count) { - int penalty = - PIRQ_PENALTY_PCI_POSSIBLE / - link->irq.possible_count; - - for (i = 0; i < link->irq.possible_count; i++) { - if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS) - acpi_isa_irq_penalty[link->irq. - possible[i]] += - penalty; - } - - } else if (link->irq.active && - (link->irq.active < ACPI_MAX_ISA_IRQS)) { - acpi_isa_irq_penalty[link->irq.active] += - PIRQ_PENALTY_PCI_POSSIBLE; - } - } - - return 0; -} - static int acpi_irq_balance = -1; /* 0: static, 1: balance */ static int acpi_pci_link_allocate(struct acpi_pci_link *link) diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index 29c6912..797ae2e 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h @@ -78,7 +78,6 @@ /* ACPI PCI Interrupt Link (pci_link.c) */ -int acpi_irq_penalty_init(void); int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering, int *polarity, char **name); int acpi_pci_link_free_irq(acpi_handle handle); -- cgit v0.10.2 From 9e5ed6d1fb87dc3ff0c2a94ed75fe82027a9f597 Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 17 Apr 2016 13:36:56 -0400 Subject: ACPI,PCI,IRQ: remove SCI penalize function Removing the SCI penalize function as the penalty is now calculated on the fly. Signed-off-by: Sinan Kaya Acked-by: Bjorn Helgaas Signed-off-by: Rafael J. Wysocki diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 8c2f1ef..edf4840 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -445,7 +445,6 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK; mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); - acpi_penalize_sci_irq(bus_irq, trigger, polarity); /* * stash over-ride to indicate we've been here diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index ab39208..8fc7323 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -848,10 +848,6 @@ bool acpi_isa_irq_available(int irq) acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS); } -void acpi_penalize_sci_irq(int irq, int trigger, int polarity) -{ -} - /* * Over-ride default table to reserve additional IRQs for use by ISA * e.g. acpi_irq_isa=5 diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 06ed7e5..0f41317 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -311,7 +311,6 @@ struct pci_dev; int acpi_pci_irq_enable (struct pci_dev *dev); void acpi_penalize_isa_irq(int irq, int active); bool acpi_isa_irq_available(int irq); -void acpi_penalize_sci_irq(int irq, int trigger, int polarity); void acpi_pci_irq_disable (struct pci_dev *dev); extern int ec_read(u8 addr, u8 *val); -- cgit v0.10.2 From f5c1e1c5a652e4b43eb9b571577ef72731f3fa8b Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 12:57:53 +0800 Subject: ACPICA: Divergence: remove unwanted spaces for typedef ACPICA commit b2294cae776f5a66a7697414b21949d307e6856f This patch removes unwanted spaces for typedef. This solution doesn't cover function types. Note that the linuxize result of this commit is very giant and should have many conflicts against the current Linux upstream. Thus it is required to modify the linuxize result of this commit and the commits around it manually in order to have them merged to the Linux upstream. Since this is very costy, we should do this only once, and if we can't ensure to do this only once, we need to revert the Linux code to the wrong indentation result before merging the linuxize result of this commit. Lv Zheng. Link: https://github.com/acpica/acpica/commit/b2294cae Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index 9e2e080..f6404ea 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h @@ -196,7 +196,7 @@ ACPI_DBR_DEPENDENT_RETURN_VOID(void acpi_walk_state *walk_state)) - acpi_status acpi_db_display_all_methods(char *display_count_arg); +acpi_status acpi_db_display_all_methods(char *display_count_arg); void acpi_db_display_arguments(void); @@ -220,7 +220,7 @@ ACPI_DBR_DEPENDENT_RETURN_VOID(void * dbexec - debugger control method execution */ void -acpi_db_execute(char *name, char **args, acpi_object_type * types, u32 flags); +acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags); void acpi_db_create_execution_threads(char *num_threads_arg, @@ -271,7 +271,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context); acpi_status acpi_db_user_commands(void); char *acpi_db_get_next_token(char *string, - char **next, acpi_object_type * return_type); + char **next, acpi_object_type *return_type); /* * dbobject diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index 17f2217..77af91c 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h @@ -72,6 +72,7 @@ acpi_status acpi_ev_init_global_lock_handler(void); ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_acquire_global_lock(u16 timeout)) ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) + acpi_status acpi_ev_remove_global_lock_handler(void); /* diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h index 8b09d28..7ead235 100644 --- a/drivers/acpi/acpica/acinterp.h +++ b/drivers/acpi/acpica/acinterp.h @@ -370,7 +370,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, acpi_status acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, union acpi_operand_object *operand, - acpi_object_type * return_type, + acpi_object_type *return_type, union acpi_operand_object **return_desc); /* diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 083b16a..166a67f 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -278,7 +278,7 @@ struct acpi_create_field_info { }; typedef -acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); +acpi_status (*acpi_internal_method) (struct acpi_walk_state * walk_state); /* * Bitmapped ACPI types. Used internally only @@ -395,11 +395,12 @@ union acpi_predefined_info { /* Return object auto-repair info */ -typedef acpi_status(*acpi_object_converter) (struct acpi_namespace_node * scope, - union acpi_operand_object - *original_object, - union acpi_operand_object - **converted_object); +typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node * + scope, + union acpi_operand_object * + original_object, + union acpi_operand_object ** + converted_object); struct acpi_simple_repair_info { char name[ACPI_NAME_SIZE]; @@ -539,10 +540,10 @@ struct acpi_gpe_device_info { struct acpi_namespace_node *gpe_device; }; -typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info * - gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block, - void *context); +typedef acpi_status (*acpi_gpe_callback) (struct acpi_gpe_xrupt_info * + gpe_xrupt_info, + struct acpi_gpe_block_info * + gpe_block, void *context); /* Information about each particular fixed event */ @@ -657,10 +658,11 @@ struct acpi_result_values { }; typedef -acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state, - union acpi_parse_object ** out_op); +acpi_status (*acpi_parse_downwards) (struct acpi_walk_state * walk_state, + union acpi_parse_object ** out_op); -typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state); +typedef +acpi_status (*acpi_parse_upwards) (struct acpi_walk_state * walk_state); /* Global handlers for AML Notifies */ @@ -700,7 +702,8 @@ union acpi_generic_state { * ****************************************************************************/ -typedef acpi_status(*acpi_execute_op) (struct acpi_walk_state * walk_state); +typedef +acpi_status (*acpi_execute_op) (struct acpi_walk_state * walk_state); /* Address Range info block */ diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h index 83e9a29..63da1e3 100644 --- a/drivers/acpi/acpica/acresrc.h +++ b/drivers/acpi/acpica/acresrc.h @@ -223,16 +223,16 @@ acpi_rs_get_aei_method_data(struct acpi_namespace_node *node, * rscalc */ acpi_status -acpi_rs_get_list_length(u8 * aml_buffer, - u32 aml_buffer_length, acpi_size * size_needed); +acpi_rs_get_list_length(u8 *aml_buffer, + u32 aml_buffer_length, acpi_size *size_needed); acpi_status acpi_rs_get_aml_length(struct acpi_resource *resource_list, - acpi_size resource_list_size, acpi_size * size_needed); + acpi_size resource_list_size, acpi_size *size_needed); acpi_status acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, - acpi_size * buffer_size_needed); + acpi_size *buffer_size_needed); acpi_status acpi_rs_convert_aml_to_resources(u8 * aml, diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 4ff971c..107f9e0 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -136,16 +136,16 @@ extern const char *acpi_gbl_pt_decode[]; #define ACPI_SMALL_VARIABLE_LENGTH 3 typedef -acpi_status(*acpi_walk_aml_callback) (u8 *aml, - u32 length, - u32 offset, - u8 resource_index, void **context); +acpi_status (*acpi_walk_aml_callback) (u8 *aml, + u32 length, + u32 offset, + u8 resource_index, void **context); typedef -acpi_status(*acpi_pkg_callback) (u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state * state, - void *context); +acpi_status (*acpi_pkg_callback) (u8 object_type, + union acpi_operand_object * source_object, + union acpi_generic_state * state, + void *context); struct acpi_pkg_info { u8 *free_space; @@ -424,7 +424,7 @@ union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size); union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size); acpi_status -acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length); +acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size *obj_length); /* * utosi - Support for the _OSI predefined control method @@ -541,9 +541,9 @@ acpi_ut_display_init_pathname(u8 type, /* * utownerid - Support for Table/Method Owner IDs */ -acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id); +acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id); -void acpi_ut_release_owner_id(acpi_owner_id * owner_id); +void acpi_ut_release_owner_id(acpi_owner_id *owner_id); /* * utresrc diff --git a/drivers/acpi/acpica/dbcmds.c b/drivers/acpi/acpica/dbcmds.c index 772178c..62bd446 100644 --- a/drivers/acpi/acpica/dbcmds.c +++ b/drivers/acpi/acpica/dbcmds.c @@ -738,9 +738,9 @@ acpi_dm_test_resource_conversion(struct acpi_namespace_node *node, char *name) original_aml = return_buffer.pointer; acpi_dm_compare_aml_resources(original_aml->buffer.pointer, - (acpi_rsdesc_size) original_aml->buffer. + (acpi_rsdesc_size)original_aml->buffer. length, new_aml.pointer, - (acpi_rsdesc_size) new_aml.length); + (acpi_rsdesc_size)new_aml.length); /* Cleanup and exit */ diff --git a/drivers/acpi/acpica/dbconvert.c b/drivers/acpi/acpica/dbconvert.c index c79c5fb..7cd07b2 100644 --- a/drivers/acpi/acpica/dbconvert.c +++ b/drivers/acpi/acpica/dbconvert.c @@ -194,7 +194,7 @@ acpi_db_convert_to_buffer(char *string, union acpi_object *object) * ******************************************************************************/ -acpi_status acpi_db_convert_to_package(char *string, union acpi_object * object) +acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object) { char *this; char *next; @@ -252,7 +252,7 @@ acpi_status acpi_db_convert_to_package(char *string, union acpi_object * object) acpi_status acpi_db_convert_to_object(acpi_object_type type, - char *string, union acpi_object * object) + char *string, union acpi_object *object) { acpi_status status = AE_OK; diff --git a/drivers/acpi/acpica/dbexec.c b/drivers/acpi/acpica/dbexec.c index c814855..12df291 100644 --- a/drivers/acpi/acpica/dbexec.c +++ b/drivers/acpi/acpica/dbexec.c @@ -361,7 +361,7 @@ acpi_db_execution_walk(acpi_handle obj_handle, ******************************************************************************/ void -acpi_db_execute(char *name, char **args, acpi_object_type * types, u32 flags) +acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags) { acpi_status status; struct acpi_buffer return_obj; diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c index f53cb30..7cd5d2e 100644 --- a/drivers/acpi/acpica/dbinput.c +++ b/drivers/acpi/acpica/dbinput.c @@ -466,7 +466,7 @@ static void acpi_db_display_help(char *command) ******************************************************************************/ char *acpi_db_get_next_token(char *string, - char **next, acpi_object_type * return_type) + char **next, acpi_object_type *return_type) { char *start; u32 depth; @@ -684,8 +684,8 @@ static u32 acpi_db_match_command(char *user_command) acpi_status acpi_db_command_dispatch(char *input_buffer, - struct acpi_walk_state * walk_state, - union acpi_parse_object * op) + struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { u32 temp; u32 command_index; diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c index 3c23b5a..4c9e59a 100644 --- a/drivers/acpi/acpica/dbnames.c +++ b/drivers/acpi/acpica/dbnames.c @@ -285,7 +285,7 @@ void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg) u32 max_depth = ACPI_UINT32_MAX; acpi_owner_id owner_id; - owner_id = (acpi_owner_id) strtoul(owner_arg, NULL, 0); + owner_id = (acpi_owner_id)strtoul(owner_arg, NULL, 0); /* Now we can check for the depth argument */ diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c index e94e0d8..124db23 100644 --- a/drivers/acpi/acpica/dbxface.c +++ b/drivers/acpi/acpica/dbxface.c @@ -162,8 +162,8 @@ void acpi_db_signal_break_point(struct acpi_walk_state *walk_state) ******************************************************************************/ acpi_status -acpi_db_single_step(struct acpi_walk_state * walk_state, - union acpi_parse_object * op, u32 opcode_class) +acpi_db_single_step(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, u32 opcode_class) { union acpi_parse_object *next; acpi_status status = AE_OK; diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c index c9a663f..4ddcbf1 100644 --- a/drivers/acpi/acpica/dscontrol.c +++ b/drivers/acpi/acpica/dscontrol.c @@ -163,8 +163,8 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, ******************************************************************************/ acpi_status -acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, - union acpi_parse_object * op) +acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { acpi_status status = AE_OK; union acpi_generic_state *control_state; diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c index 5aa1c5f..f1e6dcc 100644 --- a/drivers/acpi/acpica/dsinit.c +++ b/drivers/acpi/acpica/dsinit.c @@ -188,7 +188,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, acpi_status acpi_ds_initialize_objects(u32 table_index, - struct acpi_namespace_node * start_node) + struct acpi_namespace_node *start_node) { acpi_status status; struct acpi_init_walk_info info; diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c index 1982310..ddfec05 100644 --- a/drivers/acpi/acpica/dsmethod.c +++ b/drivers/acpi/acpica/dsmethod.c @@ -209,7 +209,7 @@ acpi_ds_detect_named_opcodes(struct acpi_walk_state *walk_state, ******************************************************************************/ acpi_status -acpi_ds_method_error(acpi_status status, struct acpi_walk_state * walk_state) +acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) { u32 aml_offset; diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index 8ca9416..f393de9 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c @@ -569,7 +569,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, /* TBD: May only be temporary */ obj_desc = - acpi_ut_create_string_object((acpi_size) name_length); + acpi_ut_create_string_object((acpi_size)name_length); strncpy(obj_desc->string.pointer, name_string, name_length); diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c index d1cedcf..fd34040 100644 --- a/drivers/acpi/acpica/dswload.c +++ b/drivers/acpi/acpica/dswload.c @@ -137,8 +137,8 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) ******************************************************************************/ acpi_status -acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, - union acpi_parse_object ** out_op) +acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op) { union acpi_parse_object *op; struct acpi_namespace_node *node; diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c index 0bac6e1..762db3f 100644 --- a/drivers/acpi/acpica/dswload2.c +++ b/drivers/acpi/acpica/dswload2.c @@ -490,8 +490,8 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) status = acpi_ds_create_index_field(op, - (acpi_handle) arg-> - common.node, walk_state); + (acpi_handle)arg->common. + node, walk_state); break; case AML_BANK_FIELD_OP: diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c index 3a26ddb..e333869 100644 --- a/drivers/acpi/acpica/dswstate.c +++ b/drivers/acpi/acpica/dswstate.c @@ -143,8 +143,8 @@ acpi_ds_result_pop(union acpi_operand_object **object, ******************************************************************************/ acpi_status -acpi_ds_result_push(union acpi_operand_object * object, - struct acpi_walk_state * walk_state) +acpi_ds_result_push(union acpi_operand_object *object, + struct acpi_walk_state *walk_state) { union acpi_generic_state *state; acpi_status status; @@ -307,7 +307,7 @@ static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state) ******************************************************************************/ acpi_status -acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) +acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state) { ACPI_FUNCTION_NAME(ds_obj_stack_push); @@ -354,7 +354,7 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) ******************************************************************************/ acpi_status -acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state) +acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state) { u32 i; @@ -411,7 +411,7 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count, return; } - for (i = (s32) pop_count - 1; i >= 0; i--) { + for (i = (s32)pop_count - 1; i >= 0; i--) { if (walk_state->num_operands == 0) { return; } diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index b47e62aaf..4b4949c 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c @@ -440,7 +440,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list) gpe_event_info = &gpe_block-> - event_info[((acpi_size) i * + event_info[((acpi_size)i * ACPI_GPE_REGISTER_WIDTH) + j]; gpe_number = j + gpe_register_info->base_gpe_number; @@ -652,7 +652,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context) * ******************************************************************************/ -acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info * gpe_event_info) +acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info) { acpi_status status; diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index 447fa1c..d54014c 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c @@ -211,7 +211,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) /* Allocate the GPE register information block */ - gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block-> + gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size)gpe_block-> register_count * sizeof(struct acpi_gpe_register_info)); @@ -225,7 +225,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) * Allocate the GPE event_info block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ - gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->gpe_count * + gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size)gpe_block->gpe_count * sizeof(struct acpi_gpe_event_info)); if (!gpe_event_info) { diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c index 66c4b5b..3f150d5 100644 --- a/drivers/acpi/acpica/evgpeutil.c +++ b/drivers/acpi/acpica/evgpeutil.c @@ -163,7 +163,7 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, acpi_status acpi_ev_get_gpe_xrupt_block(u32 interrupt_number, - struct acpi_gpe_xrupt_info ** gpe_xrupt_block) + struct acpi_gpe_xrupt_info **gpe_xrupt_block) { struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt; @@ -320,7 +320,7 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, /* Now look at the individual GPEs in this byte register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - gpe_event_info = &gpe_block->event_info[((acpi_size) i * + gpe_event_info = &gpe_block->event_info[((acpi_size)i * ACPI_GPE_REGISTER_WIDTH) + j]; diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c index 0f6be89..24768ca 100644 --- a/drivers/acpi/acpica/evhandler.c +++ b/drivers/acpi/acpica/evhandler.c @@ -359,7 +359,7 @@ union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type ******************************************************************************/ acpi_status -acpi_ev_install_space_handler(struct acpi_namespace_node * node, +acpi_ev_install_space_handler(struct acpi_namespace_node *node, acpi_adr_space_type space_id, acpi_adr_space_handler handler, acpi_adr_space_setup setup, void *context) diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index c67d78c..f51d43a 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c @@ -99,8 +99,7 @@ u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node) ******************************************************************************/ acpi_status -acpi_ev_queue_notify_request(struct acpi_namespace_node * node, - u32 notify_value) +acpi_ev_queue_notify_request(struct acpi_namespace_node *node, u32 notify_value) { union acpi_operand_object *obj_desc; union acpi_operand_object *handler_list_head = NULL; diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index 6972ab4..b6ea9c0 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c @@ -227,7 +227,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, /* Install a handler for this PCI root bridge */ - status = acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); + status = acpi_install_address_space_handler((acpi_handle)pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); if (ACPI_FAILURE(status)) { if (status == AE_SAME_HANDLER) { /* diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index 9045671..17cfef7 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c @@ -917,7 +917,7 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) * the FADT-defined gpe blocks. Otherwise, the GPE block device. * ******************************************************************************/ -acpi_status acpi_get_gpe_device(u32 index, acpi_handle * gpe_device) +acpi_status acpi_get_gpe_device(u32 index, acpi_handle *gpe_device) { struct acpi_gpe_device_info info; acpi_status status; diff --git a/drivers/acpi/acpica/exconcat.c b/drivers/acpi/acpica/exconcat.c index 553e014..2423fe0 100644 --- a/drivers/acpi/acpica/exconcat.c +++ b/drivers/acpi/acpica/exconcat.c @@ -340,7 +340,7 @@ acpi_ex_convert_to_object_type_string(union acpi_operand_object *obj_desc, type_string = acpi_ut_get_type_name(obj_desc->common.type); - return_desc = acpi_ut_create_string_object(((acpi_size) strlen(type_string) + 9)); /* 9 For "[ Object]" */ + return_desc = acpi_ut_create_string_object(((acpi_size)strlen(type_string) + 9)); /* 9 For "[ Object]" */ if (!return_desc) { return (AE_NO_MEMORY); } @@ -372,7 +372,7 @@ acpi_status acpi_ex_concat_template(union acpi_operand_object *operand0, union acpi_operand_object *operand1, union acpi_operand_object **actual_return_desc, - struct acpi_walk_state * walk_state) + struct acpi_walk_state *walk_state) { acpi_status status; union acpi_operand_object *return_desc; diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index d0d16da..b7e9b3d 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c @@ -441,7 +441,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, * Need enough space for one ASCII integer (plus null terminator) */ return_desc = - acpi_ut_create_string_object((acpi_size) string_length); + acpi_ut_create_string_object((acpi_size)string_length); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -520,7 +520,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, } return_desc = - acpi_ut_create_string_object((acpi_size) string_length); + acpi_ut_create_string_object((acpi_size)string_length); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c index bea9612..613ba6e 100644 --- a/drivers/acpi/acpica/excreate.c +++ b/drivers/acpi/acpica/excreate.c @@ -394,7 +394,7 @@ acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state) obj_desc->processor.proc_id = (u8) operand[1]->integer.value; obj_desc->processor.length = (u8) operand[3]->integer.value; obj_desc->processor.address = - (acpi_io_address) operand[2]->integer.value; + (acpi_io_address)operand[2]->integer.value; /* Install the processor object in the parent Node */ diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index d5d8020..d7d3ee3 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c @@ -126,7 +126,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length) ******************************************************************************/ acpi_status -acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state, +acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, union acpi_operand_object *obj_desc, union acpi_operand_object **ret_buffer_desc) { @@ -233,7 +233,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state, * Note: Field.length is in bits. */ length = - (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); + (acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); if (length > acpi_gbl_integer_byte_width) { diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index f0c5ed0..72f9176 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c @@ -164,7 +164,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, if (ACPI_ROUND_UP(rgn_desc->region.length, obj_desc->common_field. access_byte_width) >= - ((acpi_size) obj_desc->common_field. + ((acpi_size)obj_desc->common_field. base_byte_offset + obj_desc->common_field.access_byte_width + field_datum_byte_offset)) { diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c index 5aa21c4..69e4e26 100644 --- a/drivers/acpi/acpica/exoparg3.c +++ b/drivers/acpi/acpica/exoparg3.c @@ -184,7 +184,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) /* Get the Integer values from the objects */ index = operand[1]->integer.value; - length = (acpi_size) operand[2]->integer.value; + length = (acpi_size)operand[2]->integer.value; /* * If the index is beyond the length of the String/Buffer, or if the @@ -198,8 +198,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) else if ((index + length) > operand[0]->string.length) { length = - (acpi_size) operand[0]->string.length - - (acpi_size) index; + (acpi_size)operand[0]->string.length - + (acpi_size)index; } /* Strings always have a sub-pointer, not so for buffers */ @@ -209,7 +209,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) /* Always allocate a new buffer for the String */ - buffer = ACPI_ALLOCATE_ZEROED((acpi_size) length + 1); + buffer = ACPI_ALLOCATE_ZEROED((acpi_size)length + 1); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c index e2b6348..786d53b 100644 --- a/drivers/acpi/acpica/exoparg6.c +++ b/drivers/acpi/acpica/exoparg6.c @@ -207,7 +207,7 @@ acpi_ex_do_match(u32 match_op, * ******************************************************************************/ -acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) +acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state) { union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object *return_desc = NULL; diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c index 076074d..31b381c 100644 --- a/drivers/acpi/acpica/exregion.c +++ b/drivers/acpi/acpica/exregion.c @@ -325,15 +325,15 @@ acpi_ex_system_io_space_handler(u32 function, switch (function) { case ACPI_READ: - status = acpi_hw_read_port((acpi_io_address) address, + status = acpi_hw_read_port((acpi_io_address)address, &value32, bit_width); *value = value32; break; case ACPI_WRITE: - status = acpi_hw_write_port((acpi_io_address) address, - (u32) * value, bit_width); + status = acpi_hw_write_port((acpi_io_address)address, + (u32)*value, bit_width); break; default: diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c index c1e8bfb..a183cb7 100644 --- a/drivers/acpi/acpica/exresnte.c +++ b/drivers/acpi/acpica/exresnte.c @@ -93,7 +93,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, */ node = *object_ptr; source_desc = acpi_ns_get_attached_object(node); - entry_type = acpi_ns_get_type((acpi_handle) node); + entry_type = acpi_ns_get_type((acpi_handle)node); ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", node, source_desc, @@ -106,7 +106,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object); source_desc = acpi_ns_get_attached_object(node); - entry_type = acpi_ns_get_type((acpi_handle) node); + entry_type = acpi_ns_get_type((acpi_handle)node); *object_ptr = node; } diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c index fedacf1..e1d3878 100644 --- a/drivers/acpi/acpica/exresolv.c +++ b/drivers/acpi/acpica/exresolv.c @@ -334,7 +334,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, acpi_status acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, union acpi_operand_object *operand, - acpi_object_type * return_type, + acpi_object_type *return_type, union acpi_operand_object **return_desc) { union acpi_operand_object *obj_desc = ACPI_CAST_PTR(void, operand); diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c index cc2c26c..27b41fd 100644 --- a/drivers/acpi/acpica/exresop.c +++ b/drivers/acpi/acpica/exresop.c @@ -131,8 +131,8 @@ acpi_ex_check_object_type(acpi_object_type type_needed, acpi_status acpi_ex_resolve_operands(u16 opcode, - union acpi_operand_object ** stack_ptr, - struct acpi_walk_state * walk_state) + union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state) { union acpi_operand_object *obj_desc; acpi_status status = AE_OK; diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c index 28b7248..1dab827 100644 --- a/drivers/acpi/acpica/exstorob.c +++ b/drivers/acpi/acpica/exstorob.c @@ -188,7 +188,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, * Clear old string and copy in the new one */ memset(target_desc->string.pointer, 0, - (acpi_size) target_desc->string.length + 1); + (acpi_size)target_desc->string.length + 1); memcpy(target_desc->string.pointer, buffer, length); } else { /* @@ -204,7 +204,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, } target_desc->string.pointer = - ACPI_ALLOCATE_ZEROED((acpi_size) length + 1); + ACPI_ALLOCATE_ZEROED((acpi_size)length + 1); if (!target_desc->string.pointer) { return_ACPI_STATUS(AE_NO_MEMORY); diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index 1c4f451..bdecd5e 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c @@ -166,7 +166,7 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action) * ******************************************************************************/ -acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) +acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info) { struct acpi_gpe_register_info *gpe_register_info; acpi_status status; @@ -206,7 +206,7 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) ******************************************************************************/ acpi_status -acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, +acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, acpi_event_status *event_status) { u32 in_byte; @@ -391,7 +391,7 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, acpi_status acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info * gpe_block, + struct acpi_gpe_block_info *gpe_block, void *context) { u32 i; diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 7caaaf3..98c26ff 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -91,10 +91,9 @@ acpi_status acpi_reset(void) * compatibility with other ACPI implementations that have allowed * BIOS code with bad register width values to go unnoticed. */ - status = - acpi_os_write_port((acpi_io_address) reset_reg->address, - acpi_gbl_FADT.reset_value, - ACPI_RESET_REGISTER_WIDTH); + status = acpi_os_write_port((acpi_io_address)reset_reg->address, + acpi_gbl_FADT.reset_value, + ACPI_RESET_REGISTER_WIDTH); } else { /* Write the reset value to the reset register */ diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index 256f56c..c803bda 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c @@ -318,7 +318,7 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, ******************************************************************************/ acpi_status -acpi_ns_convert_to_unicode(struct acpi_namespace_node * scope, +acpi_ns_convert_to_unicode(struct acpi_namespace_node *scope, union acpi_operand_object *original_object, union acpi_operand_object **return_object) { @@ -385,7 +385,7 @@ acpi_ns_convert_to_unicode(struct acpi_namespace_node * scope, ******************************************************************************/ acpi_status -acpi_ns_convert_to_resource(struct acpi_namespace_node * scope, +acpi_ns_convert_to_resource(struct acpi_namespace_node *scope, union acpi_operand_object *original_object, union acpi_operand_object **return_object) { @@ -464,7 +464,7 @@ acpi_ns_convert_to_resource(struct acpi_namespace_node * scope, ******************************************************************************/ acpi_status -acpi_ns_convert_to_reference(struct acpi_namespace_node * scope, +acpi_ns_convert_to_reference(struct acpi_namespace_node *scope, union acpi_operand_object *original_object, union acpi_operand_object **return_object) { diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c index eb6e1b8..f03dd41 100644 --- a/drivers/acpi/acpica/nsnames.c +++ b/drivers/acpi/acpica/nsnames.c @@ -113,7 +113,7 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node) acpi_status acpi_ns_handle_to_pathname(acpi_handle target_handle, - struct acpi_buffer * buffer, u8 no_trailing) + struct acpi_buffer *buffer, u8 no_trailing) { acpi_status status; struct acpi_namespace_node *node; diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c index 051306f..cfa2bb7 100644 --- a/drivers/acpi/acpica/nsobject.c +++ b/drivers/acpi/acpica/nsobject.c @@ -399,7 +399,7 @@ acpi_ns_attach_data(struct acpi_namespace_node *node, ******************************************************************************/ acpi_status -acpi_ns_detach_data(struct acpi_namespace_node * node, +acpi_ns_detach_data(struct acpi_namespace_node *node, acpi_object_handler handler) { union acpi_operand_object *obj_desc; @@ -444,7 +444,7 @@ acpi_ns_detach_data(struct acpi_namespace_node * node, ******************************************************************************/ acpi_status -acpi_ns_get_attached_data(struct acpi_namespace_node * node, +acpi_ns_get_attached_data(struct acpi_namespace_node *node, acpi_object_handler handler, void **data) { union acpi_operand_object *obj_desc; diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c index 805e36d..9523d41 100644 --- a/drivers/acpi/acpica/nsrepair.c +++ b/drivers/acpi/acpica/nsrepair.c @@ -399,7 +399,7 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct ******************************************************************************/ acpi_status -acpi_ns_repair_null_element(struct acpi_evaluate_info * info, +acpi_ns_repair_null_element(struct acpi_evaluate_info *info, u32 expected_btypes, u32 package_index, union acpi_operand_object **return_object_ptr) diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c index 63edbbb..d533612 100644 --- a/drivers/acpi/acpica/nsrepair2.c +++ b/drivers/acpi/acpica/nsrepair2.c @@ -54,9 +54,9 @@ ACPI_MODULE_NAME("nsrepair2") * be repaired on a per-name basis. */ typedef -acpi_status(*acpi_repair_function) (struct acpi_evaluate_info * info, - union acpi_operand_object - **return_object_ptr); +acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info, + union acpi_operand_object ** + return_object_ptr); typedef struct acpi_repair_info { char name[ACPI_NAME_SIZE]; diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index c72cc62..784a30b 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c @@ -272,11 +272,11 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) result = &internal_name[i]; } else if (num_segments == 2) { internal_name[i] = AML_DUAL_NAME_PREFIX; - result = &internal_name[(acpi_size) i + 1]; + result = &internal_name[(acpi_size)i + 1]; } else { internal_name[i] = AML_MULTI_NAME_PREFIX_OP; - internal_name[(acpi_size) i + 1] = (char)num_segments; - result = &internal_name[(acpi_size) i + 2]; + internal_name[(acpi_size)i + 1] = (char)num_segments; + result = &internal_name[(acpi_size)i + 2]; } } @@ -456,7 +456,7 @@ acpi_ns_externalize_name(u32 internal_name_length, names_index = prefix_length + 2; num_segments = (u8) - internal_name[(acpi_size) prefix_length + 1]; + internal_name[(acpi_size)prefix_length + 1]; break; case AML_DUAL_NAME_PREFIX: diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index a7deeaa..614e4ba 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c @@ -256,7 +256,7 @@ acpi_evaluate_object(acpi_handle handle, * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) info-> + info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)info-> param_count + 1) * sizeof(void *)); if (!info->parameters) { diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c index 285b820..76a1bd4 100644 --- a/drivers/acpi/acpica/nsxfname.c +++ b/drivers/acpi/acpica/nsxfname.c @@ -78,7 +78,7 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, acpi_status acpi_get_handle(acpi_handle parent, - acpi_string pathname, acpi_handle * ret_handle) + acpi_string pathname, acpi_handle *ret_handle) { acpi_status status; struct acpi_namespace_node *node = NULL; @@ -155,7 +155,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_handle) * ******************************************************************************/ acpi_status -acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer) +acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer) { acpi_status status; struct acpi_namespace_node *node; @@ -448,7 +448,7 @@ acpi_get_object_info(acpi_handle handle, /* Point past the CID PNP_DEVICE_ID array */ next_id_string += - ((acpi_size) cid_list->count * + ((acpi_size)cid_list->count * sizeof(struct acpi_pnp_device_id)); } diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c index c312cd4..32d372b 100644 --- a/drivers/acpi/acpica/nsxfobj.c +++ b/drivers/acpi/acpica/nsxfobj.c @@ -63,7 +63,7 @@ ACPI_MODULE_NAME("nsxfobj") * DESCRIPTION: This routine returns the type associatd with a particular handle * ******************************************************************************/ -acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type) +acpi_status acpi_get_type(acpi_handle handle, acpi_object_type *ret_type) { struct acpi_namespace_node *node; acpi_status status; @@ -115,7 +115,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_type) * Handle. * ******************************************************************************/ -acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle) +acpi_status acpi_get_parent(acpi_handle handle, acpi_handle *ret_handle) { struct acpi_namespace_node *node; struct acpi_namespace_node *parent_node; @@ -183,7 +183,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_parent) acpi_status acpi_get_next_object(acpi_object_type type, acpi_handle parent, - acpi_handle child, acpi_handle * ret_handle) + acpi_handle child, acpi_handle *ret_handle) { acpi_status status; struct acpi_namespace_node *node; diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c index d48cbed..c29c930 100644 --- a/drivers/acpi/acpica/psargs.c +++ b/drivers/acpi/acpica/psargs.c @@ -87,7 +87,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) * used to encode the package length, either 0,1,2, or 3 */ byte_count = (aml[0] >> 6); - parser_state->aml += ((acpi_size) byte_count + 1); + parser_state->aml += ((acpi_size)byte_count + 1); /* Get bytes 3, 2, 1 as needed */ diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c index 8038ed2..0a23897 100644 --- a/drivers/acpi/acpica/psparse.c +++ b/drivers/acpi/acpica/psparse.c @@ -130,8 +130,8 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state) ******************************************************************************/ acpi_status -acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, - union acpi_parse_object * op) +acpi_ps_complete_this_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { union acpi_parse_object *prev; union acpi_parse_object *next; diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c index 04b37fc..cf30cd82 100644 --- a/drivers/acpi/acpica/psxface.c +++ b/drivers/acpi/acpica/psxface.c @@ -115,7 +115,7 @@ acpi_debug_trace(const char *name, u32 debug_level, u32 debug_layer, u32 flags) * ******************************************************************************/ -acpi_status acpi_ps_execute_method(struct acpi_evaluate_info * info) +acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) { acpi_status status; union acpi_parse_object *op; diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index 2b1209d..f1e83ad 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c @@ -112,7 +112,7 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) * resource_source_index (1). */ if (resource_source->string_ptr) { - return ((acpi_rs_length) (resource_source->string_length + 1)); + return ((acpi_rs_length)(resource_source->string_length + 1)); } return (0); @@ -188,7 +188,7 @@ acpi_rs_stream_option_length(u32 resource_length, acpi_status acpi_rs_get_aml_length(struct acpi_resource *resource, - acpi_size resource_list_size, acpi_size * size_needed) + acpi_size resource_list_size, acpi_size *size_needed) { acpi_size aml_size_needed = 0; struct acpi_resource *resource_end; @@ -278,11 +278,11 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, * 16-Bit Address Resource: * Add the size of the optional resource_source info */ - total_size = (acpi_rs_length) (total_size + - acpi_rs_struct_option_length - (&resource->data. - address16. - resource_source)); + total_size = (acpi_rs_length)(total_size + + acpi_rs_struct_option_length + (&resource->data. + address16. + resource_source)); break; case ACPI_RESOURCE_TYPE_ADDRESS32: @@ -290,11 +290,11 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, * 32-Bit Address Resource: * Add the size of the optional resource_source info */ - total_size = (acpi_rs_length) (total_size + - acpi_rs_struct_option_length - (&resource->data. - address32. - resource_source)); + total_size = (acpi_rs_length)(total_size + + acpi_rs_struct_option_length + (&resource->data. + address32. + resource_source)); break; case ACPI_RESOURCE_TYPE_ADDRESS64: @@ -302,11 +302,11 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, * 64-Bit Address Resource: * Add the size of the optional resource_source info */ - total_size = (acpi_rs_length) (total_size + - acpi_rs_struct_option_length - (&resource->data. - address64. - resource_source)); + total_size = (acpi_rs_length)(total_size + + acpi_rs_struct_option_length + (&resource->data. + address64. + resource_source)); break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: @@ -315,28 +315,28 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, * Add the size of each additional optional interrupt beyond the * required 1 (4 bytes for each u32 interrupt number) */ - total_size = (acpi_rs_length) (total_size + - ((resource->data. - extended_irq. - interrupt_count - - 1) * 4) + - /* Add the size of the optional resource_source info */ - acpi_rs_struct_option_length - (&resource->data. + total_size = (acpi_rs_length)(total_size + + ((resource->data. extended_irq. - resource_source)); + interrupt_count - + 1) * 4) + + /* Add the size of the optional resource_source info */ + acpi_rs_struct_option_length + (&resource->data. + extended_irq. + resource_source)); break; case ACPI_RESOURCE_TYPE_GPIO: - total_size = (acpi_rs_length) (total_size + - (resource->data.gpio. - pin_table_length * 2) + - resource->data.gpio. - resource_source. - string_length + - resource->data.gpio. - vendor_length); + total_size = (acpi_rs_length)(total_size + + (resource->data.gpio. + pin_table_length * 2) + + resource->data.gpio. + resource_source. + string_length + + resource->data.gpio. + vendor_length); break; @@ -348,14 +348,14 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, common_serial_bus. type]; - total_size = (acpi_rs_length) (total_size + - resource->data. - i2c_serial_bus. - resource_source. - string_length + - resource->data. - i2c_serial_bus. - vendor_length); + total_size = (acpi_rs_length)(total_size + + resource->data. + i2c_serial_bus. + resource_source. + string_length + + resource->data. + i2c_serial_bus. + vendor_length); break; @@ -397,8 +397,8 @@ acpi_rs_get_aml_length(struct acpi_resource *resource, ******************************************************************************/ acpi_status -acpi_rs_get_list_length(u8 * aml_buffer, - u32 aml_buffer_length, acpi_size * size_needed) +acpi_rs_get_list_length(u8 *aml_buffer, + u32 aml_buffer_length, acpi_size *size_needed) { acpi_status status; u8 *end_aml; @@ -610,7 +610,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, acpi_status acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, - acpi_size * buffer_size_needed) + acpi_size *buffer_size_needed) { u32 number_of_elements; acpi_size temp_size_needed = 0; diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index 1297889..809b61c 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c @@ -347,7 +347,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, (u8 *) output_buffer->pointer); path_buffer.pointer = user_prt->source; - status = acpi_ns_handle_to_pathname((acpi_handle) node, &path_buffer, FALSE); + status = acpi_ns_handle_to_pathname((acpi_handle)node, &path_buffer, FALSE); /* +1 to include null terminator */ diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c index ce3d0b7..25165ca 100644 --- a/drivers/acpi/acpica/rsmisc.c +++ b/drivers/acpi/acpica/rsmisc.c @@ -87,7 +87,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, return_ACPI_STATUS(AE_BAD_PARAMETER); } - if (((acpi_size) resource) & 0x3) { + if (((acpi_size)resource) & 0x3) { /* Each internal resource struct is expected to be 32-bit aligned */ diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c index e0d6023..fa491c6 100644 --- a/drivers/acpi/acpica/rsutils.c +++ b/drivers/acpi/acpica/rsutils.c @@ -338,7 +338,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, * Note: Some resource descriptors will have an additional null, so * we add 1 to the minimum length. */ - if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { + if (total_length > (acpi_rsdesc_size)(minimum_length + 1)) { /* Get the resource_source_index */ @@ -377,7 +377,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, ACPI_CAST_PTR(char, &aml_resource_source[1])); - return ((acpi_rs_length) total_length); + return ((acpi_rs_length)total_length); } /* resource_source is not present */ @@ -406,9 +406,9 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, ******************************************************************************/ acpi_rsdesc_size -acpi_rs_set_resource_source(union aml_resource * aml, +acpi_rs_set_resource_source(union aml_resource *aml, acpi_rs_length minimum_length, - struct acpi_resource_source * resource_source) + struct acpi_resource_source *resource_source) { u8 *aml_resource_source; acpi_rsdesc_size descriptor_length; @@ -466,8 +466,8 @@ acpi_rs_set_resource_source(union aml_resource * aml, ******************************************************************************/ acpi_status -acpi_rs_get_prt_method_data(struct acpi_namespace_node * node, - struct acpi_buffer * ret_buffer) +acpi_rs_get_prt_method_data(struct acpi_namespace_node *node, + struct acpi_buffer *ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c index 900933b..465ed81 100644 --- a/drivers/acpi/acpica/rsxface.c +++ b/drivers/acpi/acpica/rsxface.c @@ -433,8 +433,8 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) acpi_status acpi_get_vendor_resource(acpi_handle device_handle, char *name, - struct acpi_vendor_uuid * uuid, - struct acpi_buffer * ret_buffer) + struct acpi_vendor_uuid *uuid, + struct acpi_buffer *ret_buffer) { struct acpi_vendor_walk_info info; acpi_status status; @@ -539,7 +539,7 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) ******************************************************************************/ acpi_status -acpi_walk_resource_buffer(struct acpi_buffer * buffer, +acpi_walk_resource_buffer(struct acpi_buffer *buffer, acpi_walk_resource_callback user_function, void *context) { diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c index 7da79ce..d471df3 100644 --- a/drivers/acpi/acpica/tbdata.c +++ b/drivers/acpi/acpica/tbdata.c @@ -368,7 +368,7 @@ acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc) *****************************************************************************/ acpi_status -acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature) +acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature) { acpi_status status = AE_OK; @@ -454,7 +454,7 @@ acpi_status acpi_tb_resize_root_table_list(void) table_count = acpi_gbl_root_table_list.current_table_count; } - tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + + tables = ACPI_ALLOCATE_ZEROED(((acpi_size)table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof(struct acpi_table_desc)); if (!tables) { @@ -467,8 +467,7 @@ acpi_status acpi_tb_resize_root_table_list(void) if (acpi_gbl_root_table_list.tables) { memcpy(tables, acpi_gbl_root_table_list.tables, - (acpi_size) table_count * - sizeof(struct acpi_table_desc)); + (acpi_size)table_count * sizeof(struct acpi_table_desc)); if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { ACPI_FREE(acpi_gbl_root_table_list.tables); @@ -701,7 +700,7 @@ acpi_status acpi_tb_release_owner_id(u32 table_index) * ******************************************************************************/ -acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id) +acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id) { acpi_status status = AE_BAD_PARAMETER; diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 635d951..6208069 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -344,7 +344,7 @@ void acpi_tb_parse_fadt(void) /* Obtain the DSDT and FACS tables via their addresses within the FADT */ - acpi_tb_install_fixed_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, + acpi_tb_install_fixed_table((acpi_physical_address)acpi_gbl_FADT.Xdsdt, ACPI_SIG_DSDT, &acpi_gbl_dsdt_index); /* If Hardware Reduced flag is set, there is no FACS */ diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index 9240c76..a962a85 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -231,7 +231,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) ACPI_FORMAT_UINT64(address64))); } #endif - return ((acpi_physical_address) (address64)); + return ((acpi_physical_address)(address64)); } } @@ -287,12 +287,12 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) * the XSDT if the revision is > 1 and the XSDT pointer is present, * as per the ACPI specification. */ - address = (acpi_physical_address) rsdp->xsdt_physical_address; + address = (acpi_physical_address)rsdp->xsdt_physical_address; table_entry_size = ACPI_XSDT_ENTRY_SIZE; } else { /* Root table is an RSDT (32-bit physical addresses) */ - address = (acpi_physical_address) rsdp->rsdt_physical_address; + address = (acpi_physical_address)rsdp->rsdt_physical_address; table_entry_size = ACPI_RSDT_ENTRY_SIZE; } diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index 326df65..3ecec93 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c @@ -99,7 +99,7 @@ acpi_status acpi_allocate_root_table(u32 initial_table_count) ******************************************************************************/ acpi_status __init -acpi_initialize_tables(struct acpi_table_desc * initial_table_array, +acpi_initialize_tables(struct acpi_table_desc *initial_table_array, u32 initial_table_count, u8 allow_resize) { acpi_physical_address rsdp_address; @@ -120,7 +120,7 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array, /* Root Table Array has been statically allocated by the host */ memset(initial_table_array, 0, - (acpi_size) initial_table_count * + (acpi_size)initial_table_count * sizeof(struct acpi_table_desc)); acpi_gbl_root_table_list.tables = initial_table_array; @@ -352,7 +352,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table) * ******************************************************************************/ acpi_status -acpi_get_table_by_index(u32 table_index, struct acpi_table_header ** table) +acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table) { acpi_status status; diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c index b9a78e4..adb6cfc 100644 --- a/drivers/acpi/acpica/tbxfroot.c +++ b/drivers/acpi/acpica/tbxfroot.c @@ -90,7 +90,7 @@ u32 acpi_tb_get_rsdp_length(struct acpi_table_rsdp *rsdp) * ******************************************************************************/ -acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp * rsdp) +acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) { /* @@ -142,7 +142,7 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp * rsdp) * ******************************************************************************/ -acpi_status __init acpi_find_root_pointer(acpi_physical_address * table_address) +acpi_status __init acpi_find_root_pointer(acpi_physical_address *table_address) { u8 *table_ptr; u8 *mem_rover; @@ -201,7 +201,7 @@ acpi_status __init acpi_find_root_pointer(acpi_physical_address * table_address) (u32) ACPI_PTR_DIFF(mem_rover, table_ptr); *table_address = - (acpi_physical_address) physical_address; + (acpi_physical_address)physical_address; return_ACPI_STATUS(AE_OK); } } @@ -234,7 +234,7 @@ acpi_status __init acpi_find_root_pointer(acpi_physical_address * table_address) (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover, table_ptr)); - *table_address = (acpi_physical_address) physical_address; + *table_address = (acpi_physical_address)physical_address; return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c index 3dbdc3a..13324a2 100644 --- a/drivers/acpi/acpica/utalloc.c +++ b/drivers/acpi/acpica/utalloc.c @@ -231,7 +231,7 @@ acpi_status acpi_ut_delete_caches(void) * ******************************************************************************/ -acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) +acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer) { /* Obviously, the structure pointer must be valid */ @@ -272,8 +272,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) ******************************************************************************/ acpi_status -acpi_ut_initialize_buffer(struct acpi_buffer * buffer, - acpi_size required_length) +acpi_ut_initialize_buffer(struct acpi_buffer *buffer, acpi_size required_length) { acpi_size input_buffer_length; diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c index 0cfb2b8..bd31faf 100644 --- a/drivers/acpi/acpica/utbuffer.c +++ b/drivers/acpi/acpica/utbuffer.c @@ -106,31 +106,31 @@ void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) default: /* Default is BYTE display */ acpi_os_printf("%02X ", - buffer[(acpi_size) i + j]); + buffer[(acpi_size)i + j]); break; case DB_WORD_DISPLAY: ACPI_MOVE_16_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_os_printf("%04X ", temp32); break; case DB_DWORD_DISPLAY: ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_os_printf("%08X ", temp32); break; case DB_QWORD_DISPLAY: ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_os_printf("%08X", temp32); ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j + + &buffer[(acpi_size)i + j + 4]); acpi_os_printf("%08X ", temp32); break; @@ -158,7 +158,7 @@ void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) acpi_os_printf("// "); } - buf_char = buffer[(acpi_size) i + j]; + buf_char = buffer[(acpi_size)i + j]; if (isprint(buf_char)) { acpi_os_printf("%c", buf_char); } else { @@ -274,31 +274,31 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, default: /* Default is BYTE display */ acpi_ut_file_printf(file, "%02X ", - buffer[(acpi_size) i + j]); + buffer[(acpi_size)i + j]); break; case DB_WORD_DISPLAY: ACPI_MOVE_16_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_ut_file_printf(file, "%04X ", temp32); break; case DB_DWORD_DISPLAY: ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_ut_file_printf(file, "%08X ", temp32); break; case DB_QWORD_DISPLAY: ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j]); + &buffer[(acpi_size)i + j]); acpi_ut_file_printf(file, "%08X", temp32); ACPI_MOVE_32_TO_32(&temp32, - &buffer[(acpi_size) i + j + + &buffer[(acpi_size)i + j + 4]); acpi_ut_file_printf(file, "%08X ", temp32); break; @@ -318,7 +318,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, return; } - buf_char = buffer[(acpi_size) i + j]; + buf_char = buffer[(acpi_size)i + j]; if (isprint(buf_char)) { acpi_ut_file_printf(file, "%c", buf_char); } else { diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c index f8e9978..3b8d23e 100644 --- a/drivers/acpi/acpica/utcache.c +++ b/drivers/acpi/acpica/utcache.c @@ -105,7 +105,7 @@ acpi_os_create_cache(char *cache_name, * ******************************************************************************/ -acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) +acpi_status acpi_os_purge_cache(struct acpi_memory_list *cache) { void *next; acpi_status status; @@ -151,7 +151,7 @@ acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) * ******************************************************************************/ -acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache) +acpi_status acpi_os_delete_cache(struct acpi_memory_list *cache) { acpi_status status; @@ -184,8 +184,7 @@ acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache) * ******************************************************************************/ -acpi_status -acpi_os_release_object(struct acpi_memory_list * cache, void *object) +acpi_status acpi_os_release_object(struct acpi_memory_list *cache, void *object) { acpi_status status; diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c index 98d53e5..82f9714 100644 --- a/drivers/acpi/acpica/utcopy.c +++ b/drivers/acpi/acpica/utcopy.c @@ -53,7 +53,7 @@ ACPI_MODULE_NAME("utcopy") static acpi_status acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, union acpi_object *external_object, - u8 * data_space, acpi_size * buffer_space_used); + u8 *data_space, acpi_size *buffer_space_used); static acpi_status acpi_ut_copy_ielement_to_ielement(u8 object_type, @@ -63,7 +63,7 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, static acpi_status acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, - u8 * buffer, acpi_size * space_used); + u8 *buffer, acpi_size *space_used); static acpi_status acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj, @@ -111,7 +111,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, static acpi_status acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, union acpi_object *external_object, - u8 * data_space, acpi_size * buffer_space_used) + u8 *data_space, acpi_size *buffer_space_used) { acpi_status status = AE_OK; @@ -151,7 +151,7 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, memcpy((void *)data_space, (void *)internal_object->string.pointer, - (acpi_size) internal_object->string.length + 1); + (acpi_size)internal_object->string.length + 1); break; case ACPI_TYPE_BUFFER: @@ -331,7 +331,7 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type, static acpi_status acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, - u8 * buffer, acpi_size * space_used) + u8 *buffer, acpi_size *space_used) { union acpi_object *external_object; acpi_status status; @@ -362,7 +362,7 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, * Leave room for an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - info.length += (acpi_size) external_object->package.count * + info.length += (acpi_size)external_object->package.count * ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); info.free_space += external_object->package.count * ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); @@ -738,7 +738,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, */ if (source_desc->string.pointer) { dest_desc->string.pointer = - ACPI_ALLOCATE((acpi_size) source_desc->string. + ACPI_ALLOCATE((acpi_size)source_desc->string. length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); @@ -748,7 +748,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, memcpy(dest_desc->string.pointer, source_desc->string.pointer, - (acpi_size) source_desc->string.length + 1); + (acpi_size)source_desc->string.length + 1); } break; diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c index 6fb4ec3..f7cd2d5 100644 --- a/drivers/acpi/acpica/utids.c +++ b/drivers/acpi/acpica/utids.c @@ -95,7 +95,7 @@ acpi_ut_execute_HID(struct acpi_namespace_node *device_node, hid = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + - (acpi_size) length); + (acpi_size)length); if (!hid) { status = AE_NO_MEMORY; goto cleanup; @@ -173,7 +173,7 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node, uid = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + - (acpi_size) length); + (acpi_size)length); if (!uid) { status = AE_NO_MEMORY; goto cleanup; @@ -309,7 +309,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node, /* Area for CID strings starts after the CID PNP_DEVICE_ID array */ next_id_string = ACPI_CAST_PTR(char, cid_list->ids) + - ((acpi_size) count * sizeof(struct acpi_pnp_device_id)); + ((acpi_size)count * sizeof(struct acpi_pnp_device_id)); /* Copy/convert the CIDs to the return buffer */ @@ -413,7 +413,7 @@ acpi_ut_execute_CLS(struct acpi_namespace_node *device_node, cls = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + - (acpi_size) length); + (acpi_size)length); if (!cls) { status = AE_NO_MEMORY; goto cleanup; diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c index 6673720..2d6530e 100644 --- a/drivers/acpi/acpica/utmath.c +++ b/drivers/acpi/acpica/utmath.c @@ -236,8 +236,8 @@ acpi_ut_divide(u64 in_dividend, } remainder.full = remainder.full - dividend.full; - remainder.part.hi = (u32) - ((s32) remainder.part.hi); - remainder.part.lo = (u32) - ((s32) remainder.part.lo); + remainder.part.hi = (u32)-((s32)remainder.part.hi); + remainder.part.lo = (u32)-((s32)remainder.part.lo); if (remainder.part.lo) { remainder.part.hi--; diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c index edad3f0..72b9a06 100644 --- a/drivers/acpi/acpica/utobject.c +++ b/drivers/acpi/acpica/utobject.c @@ -51,11 +51,11 @@ ACPI_MODULE_NAME("utobject") /* Local prototypes */ static acpi_status acpi_ut_get_simple_object_size(union acpi_operand_object *obj, - acpi_size * obj_length); + acpi_size *obj_length); static acpi_status acpi_ut_get_package_object_size(union acpi_operand_object *obj, - acpi_size * obj_length); + acpi_size *obj_length); static acpi_status acpi_ut_get_element_length(u8 object_type, @@ -177,7 +177,7 @@ union acpi_operand_object *acpi_ut_create_package_object(u32 count) * Create the element array. Count+1 allows the array to be null * terminated. */ - package_elements = ACPI_ALLOCATE_ZEROED(((acpi_size) count + + package_elements = ACPI_ALLOCATE_ZEROED(((acpi_size)count + 1) * sizeof(void *)); if (!package_elements) { ACPI_FREE(package_desc); @@ -454,7 +454,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object) static acpi_status acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, - acpi_size * obj_length) + acpi_size *obj_length) { acpi_size length; acpi_size size; @@ -495,12 +495,12 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, switch (internal_object->common.type) { case ACPI_TYPE_STRING: - length += (acpi_size) internal_object->string.length + 1; + length += (acpi_size)internal_object->string.length + 1; break; case ACPI_TYPE_BUFFER: - length += (acpi_size) internal_object->buffer.length; + length += (acpi_size)internal_object->buffer.length; break; case ACPI_TYPE_INTEGER: @@ -640,7 +640,7 @@ acpi_ut_get_element_length(u8 object_type, static acpi_status acpi_ut_get_package_object_size(union acpi_operand_object *internal_object, - acpi_size * obj_length) + acpi_size *obj_length) { acpi_status status; struct acpi_pkg_info info; @@ -665,7 +665,7 @@ acpi_ut_get_package_object_size(union acpi_operand_object *internal_object, */ info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) * - (acpi_size) info.num_packages; + (acpi_size)info.num_packages; /* Return the total package length */ @@ -689,7 +689,7 @@ acpi_ut_get_package_object_size(union acpi_operand_object *internal_object, acpi_status acpi_ut_get_object_size(union acpi_operand_object *internal_object, - acpi_size * obj_length) + acpi_size *obj_length) { acpi_status status; diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c index b5cfe57..3f5fed6 100644 --- a/drivers/acpi/acpica/utosi.c +++ b/drivers/acpi/acpica/utosi.c @@ -150,7 +150,7 @@ acpi_status acpi_ut_initialize_interfaces(void) i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1); i++) { acpi_default_supported_interfaces[i].next = - &acpi_default_supported_interfaces[(acpi_size) i + 1]; + &acpi_default_supported_interfaces[(acpi_size)i + 1]; } acpi_os_release_mutex(acpi_gbl_osi_mutex); @@ -397,7 +397,7 @@ struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name) * ******************************************************************************/ -acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state) +acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) { union acpi_operand_object *string_desc; union acpi_operand_object *return_desc; diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c index 813520a..3cd573c 100644 --- a/drivers/acpi/acpica/utownerid.c +++ b/drivers/acpi/acpica/utownerid.c @@ -61,7 +61,7 @@ ACPI_MODULE_NAME("utownerid") * when the method exits or the table is unloaded. * ******************************************************************************/ -acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) +acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id) { u32 i; u32 j; @@ -122,7 +122,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) * permanently allocated (prevents +1 overflow) */ *owner_id = - (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); + (acpi_owner_id)((k + 1) + ACPI_MUL_32(j)); ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "Allocated OwnerId: %2.2X\n", @@ -167,7 +167,7 @@ exit: * ******************************************************************************/ -void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) +void acpi_ut_release_owner_id(acpi_owner_id *owner_id_ptr) { acpi_owner_id owner_id = *owner_id_ptr; acpi_status status; diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c index 208d71a..dd084cf 100644 --- a/drivers/acpi/acpica/utprint.c +++ b/drivers/acpi/acpica/utprint.c @@ -264,9 +264,9 @@ static char *acpi_ut_format_number(char *string, sign = '\0'; if (type & ACPI_FORMAT_SIGN) { - if ((s64) number < 0) { + if ((s64)number < 0) { sign = '-'; - number = -(s64) number; + number = -(s64)number; width--; } else if (type & ACPI_FORMAT_SIGN_PLUS) { sign = '+'; @@ -404,7 +404,7 @@ acpi_ut_vsnprintf(char *string, width = -1; if (isdigit((int)*format)) { format = acpi_ut_scan_number(format, &number); - width = (s32) number; + width = (s32)number; } else if (*format == '*') { ++format; width = va_arg(args, int); @@ -421,7 +421,7 @@ acpi_ut_vsnprintf(char *string, ++format; if (isdigit((int)*format)) { format = acpi_ut_scan_number(format, &number); - precision = (s32) number; + precision = (s32)number; } else if (*format == '*') { ++format; precision = va_arg(args, int); @@ -550,17 +550,17 @@ acpi_ut_vsnprintf(char *string, if (qualifier == 'L') { number = va_arg(args, u64); if (type & ACPI_FORMAT_SIGN) { - number = (s64) number; + number = (s64)number; } } else if (qualifier == 'l') { number = va_arg(args, unsigned long); if (type & ACPI_FORMAT_SIGN) { - number = (s32) number; + number = (s32)number; } } else if (qualifier == 'h') { number = (u16)va_arg(args, int); if (type & ACPI_FORMAT_SIGN) { - number = (s16) number; + number = (s16)number; } } else { number = va_arg(args, unsigned int); diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c index 0b00572..241259b 100644 --- a/drivers/acpi/acpica/utstring.c +++ b/drivers/acpi/acpica/utstring.c @@ -130,7 +130,7 @@ void acpi_ut_print_string(char *string, u16 max_length) } else { /* All others will be Hex escapes */ - acpi_os_printf("\\x%2.2X", (s32) string[i]); + acpi_os_printf("\\x%2.2X", (s32)string[i]); } break; } diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c index 68d4673..d9e6aac 100644 --- a/drivers/acpi/acpica/utxface.c +++ b/drivers/acpi/acpica/utxface.c @@ -127,7 +127,7 @@ ACPI_EXPORT_SYMBOL(acpi_subsystem_status) * and the value of out_buffer is undefined. * ******************************************************************************/ -acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer) +acpi_status acpi_get_system_info(struct acpi_buffer *out_buffer) { struct acpi_system_info *info_ptr; acpi_status status; @@ -483,7 +483,7 @@ ACPI_EXPORT_SYMBOL(acpi_check_address_range) ******************************************************************************/ acpi_status acpi_decode_pld_buffer(u8 *in_buffer, - acpi_size length, struct acpi_pld_info ** return_buffer) + acpi_size length, struct acpi_pld_info **return_buffer) { struct acpi_pld_info *pld_info; u32 *buffer = ACPI_CAST_PTR(u32, in_buffer); diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 6026308..562603d 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -108,7 +108,7 @@ acpi_os_table_override(struct acpi_table_header *existing_table, #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address * new_address, + acpi_physical_address *new_address, u32 *new_table_length); #endif @@ -203,7 +203,7 @@ void acpi_os_unmap_memory(void *logical_address, acpi_size size); #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address acpi_status acpi_os_get_physical_address(void *logical_address, - acpi_physical_address * physical_address); + acpi_physical_address *physical_address); #endif /* @@ -379,14 +379,14 @@ acpi_status acpi_os_get_table_by_name(char *signature, u32 instance, struct acpi_table_header **table, - acpi_physical_address * address); + acpi_physical_address *address); #endif #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index acpi_status acpi_os_get_table_by_index(u32 index, struct acpi_table_header **table, - u32 *instance, acpi_physical_address * address); + u32 *instance, acpi_physical_address *address); #endif #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 83583a2..fcd8119 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -484,8 +484,8 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init acpi_load_tables(void)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init acpi_reallocate_root_table(void)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init - acpi_find_root_pointer(acpi_physical_address * - rsdp_address)) + acpi_find_root_pointer(acpi_physical_address + *rsdp_address)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_table_header(acpi_string signature, u32 instance, @@ -530,7 +530,7 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_handle(acpi_handle parent, acpi_string pathname, - acpi_handle * ret_handle)) + acpi_handle *ret_handle)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_attach_data(acpi_handle object, acpi_object_handler handler, @@ -575,15 +575,15 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_next_object(acpi_object_type type, acpi_handle parent, acpi_handle child, - acpi_handle * out_handle)) + acpi_handle *out_handle)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_type(acpi_handle object, - acpi_object_type * out_type)) + acpi_object_type *out_type)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_parent(acpi_handle object, - acpi_handle * out_handle)) + acpi_handle *out_handle)) /* * Handler interfaces @@ -755,7 +755,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_gpe_device(u32 gpe_index, - acpi_handle * gpe_device)) + acpi_handle *gpe_device)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_install_gpe_block(acpi_handle gpe_device, @@ -771,8 +771,8 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status * Resource interfaces */ typedef -acpi_status(*acpi_walk_resource_callback) (struct acpi_resource * resource, - void *context); +acpi_status (*acpi_walk_resource_callback) (struct acpi_resource * resource, + void *context); ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_vendor_resource(acpi_handle device, @@ -938,7 +938,8 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(void ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1) void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)) - acpi_status acpi_initialize_debugger(void); + +acpi_status acpi_initialize_debugger(void); void acpi_terminate_debugger(void); diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index b9a8b72..cb389ef 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -893,7 +893,7 @@ typedef u8 acpi_adr_space_type; /* Sleep function dispatch */ -typedef acpi_status(*acpi_sleep_function) (u8 sleep_state); +typedef acpi_status (*acpi_sleep_function) (u8 sleep_state); struct acpi_sleep_functions { acpi_sleep_function legacy_function; @@ -1072,20 +1072,21 @@ void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context); typedef void (*acpi_object_handler) (acpi_handle object, void *data); -typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function); +typedef +acpi_status (*acpi_init_handler) (acpi_handle object, u32 function); #define ACPI_INIT_DEVICE_INI 1 typedef -acpi_status(*acpi_exception_handler) (acpi_status aml_status, - acpi_name name, - u16 opcode, - u32 aml_offset, void *context); +acpi_status (*acpi_exception_handler) (acpi_status aml_status, + acpi_name name, + u16 opcode, + u32 aml_offset, void *context); /* Table Event handler (Load, load_table, etc.) and types */ typedef -acpi_status(*acpi_table_handler) (u32 event, void *table, void *context); +acpi_status (*acpi_table_handler) (u32 event, void *table, void *context); #define ACPI_TABLE_LOAD 0x0 #define ACPI_TABLE_UNLOAD 0x1 @@ -1094,12 +1095,12 @@ acpi_status(*acpi_table_handler) (u32 event, void *table, void *context); /* Address Spaces (For Operation Regions) */ typedef -acpi_status(*acpi_adr_space_handler) (u32 function, - acpi_physical_address address, - u32 bit_width, - u64 *value, - void *handler_context, - void *region_context); +acpi_status (*acpi_adr_space_handler) (u32 function, + acpi_physical_address address, + u32 bit_width, + u64 *value, + void *handler_context, + void *region_context); #define ACPI_DEFAULT_HANDLER NULL @@ -1112,18 +1113,18 @@ struct acpi_connection_info { }; typedef -acpi_status(*acpi_adr_space_setup) (acpi_handle region_handle, - u32 function, - void *handler_context, - void **region_context); +acpi_status (*acpi_adr_space_setup) (acpi_handle region_handle, + u32 function, + void *handler_context, + void **region_context); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 typedef -acpi_status(*acpi_walk_callback) (acpi_handle object, - u32 nesting_level, - void *context, void **return_value); +acpi_status (*acpi_walk_callback) (acpi_handle object, + u32 nesting_level, + void *context, void **return_value); typedef u32 (*acpi_interface_handler) (acpi_string interface_name, u32 supported); diff --git a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c index d0e6b85..546cf4a 100644 --- a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c +++ b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c @@ -91,7 +91,7 @@ osl_get_customized_table(char *pathname, char *signature, u32 instance, struct acpi_table_header **table, - acpi_physical_address * address); + acpi_physical_address *address); static acpi_status osl_list_bios_tables(void); @@ -99,7 +99,7 @@ static acpi_status osl_get_bios_table(char *signature, u32 instance, struct acpi_table_header **table, - acpi_physical_address * address); + acpi_physical_address *address); static acpi_status osl_get_last_status(acpi_status default_status); @@ -187,7 +187,7 @@ static acpi_status osl_get_last_status(acpi_status default_status) acpi_status acpi_os_get_table_by_address(acpi_physical_address address, - struct acpi_table_header ** table) + struct acpi_table_header **table) { u32 table_length; struct acpi_table_header *mapped_table; @@ -252,8 +252,8 @@ exit: acpi_status acpi_os_get_table_by_name(char *signature, u32 instance, - struct acpi_table_header ** table, - acpi_physical_address * address) + struct acpi_table_header **table, + acpi_physical_address *address) { acpi_status status; @@ -380,8 +380,8 @@ static acpi_status osl_add_table_to_list(char *signature, u32 instance) acpi_status acpi_os_get_table_by_index(u32 index, - struct acpi_table_header ** table, - u32 *instance, acpi_physical_address * address) + struct acpi_table_header **table, + u32 *instance, acpi_physical_address *address) { struct osl_table_info *info; acpi_status status; @@ -447,7 +447,7 @@ osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword) } } - return ((acpi_physical_address) (address)); + return ((acpi_physical_address)(address)); } /****************************************************************************** @@ -751,10 +751,10 @@ static acpi_status osl_list_bios_tables(void) for (i = 0; i < number_of_tables; ++i, table_data += item_size) { if (osl_can_use_xsdt()) { table_address = - (acpi_physical_address) (*ACPI_CAST64(table_data)); + (acpi_physical_address)(*ACPI_CAST64(table_data)); } else { table_address = - (acpi_physical_address) (*ACPI_CAST32(table_data)); + (acpi_physical_address)(*ACPI_CAST32(table_data)); } /* Skip NULL entries in RSDT/XSDT */ @@ -800,7 +800,7 @@ static acpi_status osl_get_bios_table(char *signature, u32 instance, struct acpi_table_header **table, - acpi_physical_address * address) + acpi_physical_address *address) { struct acpi_table_header *local_table = NULL; struct acpi_table_header *mapped_table = NULL; @@ -833,38 +833,37 @@ osl_get_bios_table(char *signature, if ((gbl_fadt->header.length >= MIN_FADT_FOR_XDSDT) && gbl_fadt->Xdsdt) { table_address = - (acpi_physical_address) gbl_fadt->Xdsdt; + (acpi_physical_address)gbl_fadt->Xdsdt; } else if ((gbl_fadt->header.length >= MIN_FADT_FOR_DSDT) && gbl_fadt->dsdt) { table_address = - (acpi_physical_address) gbl_fadt->dsdt; + (acpi_physical_address)gbl_fadt->dsdt; } } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_FACS)) { if ((gbl_fadt->header.length >= MIN_FADT_FOR_XFACS) && gbl_fadt->Xfacs) { table_address = - (acpi_physical_address) gbl_fadt->Xfacs; + (acpi_physical_address)gbl_fadt->Xfacs; } else if ((gbl_fadt->header.length >= MIN_FADT_FOR_FACS) && gbl_fadt->facs) { table_address = - (acpi_physical_address) gbl_fadt->facs; + (acpi_physical_address)gbl_fadt->facs; } } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_XSDT)) { if (!gbl_revision) { return (AE_BAD_SIGNATURE); } table_address = - (acpi_physical_address) gbl_rsdp. + (acpi_physical_address)gbl_rsdp. xsdt_physical_address; } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_RSDT)) { table_address = - (acpi_physical_address) gbl_rsdp. + (acpi_physical_address)gbl_rsdp. rsdt_physical_address; } else { - table_address = - (acpi_physical_address) gbl_rsdp_address; + table_address = (acpi_physical_address)gbl_rsdp_address; signature = ACPI_SIG_RSDP; } @@ -904,12 +903,12 @@ osl_get_bios_table(char *signature, for (i = 0; i < number_of_tables; ++i, table_data += item_size) { if (osl_can_use_xsdt()) { table_address = - (acpi_physical_address) (*ACPI_CAST64 - (table_data)); + (acpi_physical_address)(*ACPI_CAST64 + (table_data)); } else { table_address = - (acpi_physical_address) (*ACPI_CAST32 - (table_data)); + (acpi_physical_address)(*ACPI_CAST32 + (table_data)); } /* Skip NULL entries in RSDT/XSDT */ @@ -1301,7 +1300,7 @@ osl_get_customized_table(char *pathname, char *signature, u32 instance, struct acpi_table_header **table, - acpi_physical_address * address) + acpi_physical_address *address) { void *table_dir; u32 current_instance = 0; diff --git a/tools/power/acpi/os_specific/service_layers/osunixxf.c b/tools/power/acpi/os_specific/service_layers/osunixxf.c index 08cb8b2..88aa66e 100644 --- a/tools/power/acpi/os_specific/service_layers/osunixxf.c +++ b/tools/power/acpi/os_specific/service_layers/osunixxf.c @@ -246,8 +246,8 @@ acpi_physical_address acpi_os_get_root_pointer(void) *****************************************************************************/ acpi_status -acpi_os_predefined_override(const struct acpi_predefined_names * init_val, - acpi_string * new_val) +acpi_os_predefined_override(const struct acpi_predefined_names *init_val, + acpi_string *new_val) { if (!init_val || !new_val) { @@ -274,8 +274,8 @@ acpi_os_predefined_override(const struct acpi_predefined_names * init_val, *****************************************************************************/ acpi_status -acpi_os_table_override(struct acpi_table_header * existing_table, - struct acpi_table_header ** new_table) +acpi_os_table_override(struct acpi_table_header *existing_table, + struct acpi_table_header **new_table) { if (!existing_table || !new_table) { @@ -311,8 +311,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, *****************************************************************************/ acpi_status -acpi_os_physical_table_override(struct acpi_table_header * existing_table, - acpi_physical_address * new_address, +acpi_os_physical_table_override(struct acpi_table_header *existing_table, + acpi_physical_address *new_address, u32 *new_table_length) { @@ -506,7 +506,7 @@ acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read) void *acpi_os_map_memory(acpi_physical_address where, acpi_size length) { - return (ACPI_TO_POINTER((acpi_size) where)); + return (ACPI_TO_POINTER((acpi_size)where)); } /****************************************************************************** @@ -603,9 +603,9 @@ void acpi_os_free(void *mem) acpi_status acpi_os_create_semaphore(u32 max_units, - u32 initial_units, acpi_handle * out_handle) + u32 initial_units, acpi_handle *out_handle) { - *out_handle = (acpi_handle) 1; + *out_handle = (acpi_handle)1; return (AE_OK); } @@ -640,7 +640,7 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) acpi_status acpi_os_create_semaphore(u32 max_units, - u32 initial_units, acpi_handle * out_handle) + u32 initial_units, acpi_handle *out_handle) { sem_t *sem; @@ -672,7 +672,7 @@ acpi_os_create_semaphore(u32 max_units, } #endif - *out_handle = (acpi_handle) sem; + *out_handle = (acpi_handle)sem; return (AE_OK); } @@ -1035,7 +1035,7 @@ acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, *****************************************************************************/ acpi_status -acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, +acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id, u32 pci_register, u64 value, u32 width) { diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index 9c2db0e..a39e445 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c @@ -294,7 +294,7 @@ int ap_dump_table_by_address(char *ascii_address) return (-1); } - address = (acpi_physical_address) long_address; + address = (acpi_physical_address)long_address; status = acpi_os_get_table_by_address(address, &table); if (ACPI_FAILURE(status)) { acpi_log_error("Could not get table at 0x%8.8X%8.8X, %s\n", -- cgit v0.10.2 From 7dbec55350cea5fff97162ed2663741a48893f6f Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 12:58:00 +0800 Subject: ACPICA: Refactor evaluate_object to reduce nesting ACPICA commit 599e9159f53565e4a3f3e67f6a03f81fcb10a4cf Original patch from hanjun.guo@linaro.org ACPICA BZ 1072. Link: https://github.com/acpica/acpica/commit/599e9159 Link: https://bugs.acpica.org/show_bug.cgi?id=1072 Original-by: Hanjun Guo Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 614e4ba..d2a9b4f 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c @@ -280,13 +280,12 @@ acpi_evaluate_object(acpi_handle handle, info->parameters[info->param_count] = NULL; } -#if 0 +#ifdef _FUTURE_FEATURE /* * Begin incoming argument count analysis. Check for too few args * and too many args. */ - switch (acpi_ns_get_type(info->node)) { case ACPI_TYPE_METHOD: @@ -370,68 +369,68 @@ acpi_evaluate_object(acpi_handle handle, * If we are expecting a return value, and all went well above, * copy the return value to an external object. */ - if (return_buffer) { - if (!info->return_object) { - return_buffer->length = 0; - } else { - if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) == - ACPI_DESC_TYPE_NAMED) { - /* - * If we received a NS Node as a return object, this means that - * the object we are evaluating has nothing interesting to - * return (such as a mutex, etc.) We return an error because - * these types are essentially unsupported by this interface. - * We don't check up front because this makes it easier to add - * support for various types at a later date if necessary. - */ - status = AE_TYPE; - info->return_object = NULL; /* No need to delete a NS Node */ - return_buffer->length = 0; - } + if (!return_buffer) { + goto cleanup_return_object; + } - if (ACPI_SUCCESS(status)) { + if (!info->return_object) { + return_buffer->length = 0; + goto cleanup; + } - /* Dereference Index and ref_of references */ + if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) == + ACPI_DESC_TYPE_NAMED) { + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + status = AE_TYPE; + info->return_object = NULL; /* No need to delete a NS Node */ + return_buffer->length = 0; + } - acpi_ns_resolve_references(info); + if (ACPI_FAILURE(status)) { + goto cleanup_return_object; + } - /* Get the size of the returned object */ + /* Dereference Index and ref_of references */ - status = - acpi_ut_get_object_size(info->return_object, - &buffer_space_needed); - if (ACPI_SUCCESS(status)) { - - /* Validate/Allocate/Clear caller buffer */ - - status = - acpi_ut_initialize_buffer - (return_buffer, - buffer_space_needed); - if (ACPI_FAILURE(status)) { - /* - * Caller's buffer is too small or a new one can't - * be allocated - */ - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Needed buffer size %X, %s\n", - (u32) - buffer_space_needed, - acpi_format_exception - (status))); - } else { - /* We have enough space for the object, build it */ - - status = - acpi_ut_copy_iobject_to_eobject - (info->return_object, - return_buffer); - } - } - } + acpi_ns_resolve_references(info); + + /* Get the size of the returned object */ + + status = acpi_ut_get_object_size(info->return_object, + &buffer_space_needed); + if (ACPI_SUCCESS(status)) { + + /* Validate/Allocate/Clear caller buffer */ + + status = acpi_ut_initialize_buffer(return_buffer, + buffer_space_needed); + if (ACPI_FAILURE(status)) { + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (u32)buffer_space_needed, + acpi_format_exception(status))); + } else { + /* We have enough space for the object, build it */ + + status = + acpi_ut_copy_iobject_to_eobject(info->return_object, + return_buffer); } } +cleanup_return_object: + if (info->return_object) { /* * Delete the internal return object. NOTE: Interpreter must be -- cgit v0.10.2 From 2a397a390a90ff84cd17a6cd2275c2f19478a948 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 12:58:05 +0800 Subject: ACPICA: ACPI 6.1: Support for new PCCT subtable ACPICA commit de3ea7c322b9b6bdb09aa90c2e1d420cd4dce47c Additional subspace structure was added. Link: https://github.com/acpica/acpica/commit/de3ea7c3 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index f12f4bb..ebc1f4f 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h @@ -481,7 +481,8 @@ struct acpi_table_pcct { enum acpi_pcct_type { ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, - ACPI_PCCT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 = 2, /* ACPI 6.1 */ + ACPI_PCCT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ }; /* @@ -520,6 +521,26 @@ struct acpi_pcct_hw_reduced { u16 min_turnaround_time; }; +/* 2: HW-reduced Communications Subspace Type 2 (ACPI 6.1) */ + +struct acpi_pcct_hw_reduced_type2 { + struct acpi_subtable_header header; + u32 doorbell_interrupt; + u8 flags; + u8 reserved; + u64 base_address; + u64 length; + struct acpi_generic_address doorbell_register; + u64 preserve_mask; + u64 write_mask; + u32 latency; + u32 max_access_rate; + u16 min_turnaround_time; + struct acpi_generic_address doorbell_ack_register; + u64 ack_preserve_mask; + u64 ack_write_mask; +}; + /* Values for doorbell flags above */ #define ACPI_PCCT_INTERRUPT_POLARITY (1) -- cgit v0.10.2 From 7952d40240855932de01bbe81c02bf1416ec91d8 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 12:58:12 +0800 Subject: ACPICA: ACPI 6.0: Update _BIX support for new package element ACPICA commit 3451e6d49d37919c13ec2c0019a31534b0dfc0c0 One integer was added at the end of the _BIX method, and the version number was incremented. Link: https://github.com/acpica/acpica/commit/3451e6d4 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index 4ca426b..888440b 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h @@ -129,7 +129,8 @@ enum acpi_return_package_types { ACPI_PTYPE2_REV_FIXED = 9, ACPI_PTYPE2_FIX_VAR = 10, ACPI_PTYPE2_VAR_VAR = 11, - ACPI_PTYPE2_UUID_PAIR = 12 + ACPI_PTYPE2_UUID_PAIR = 12, + ACPI_PTYPE_CUSTOM = 13 }; /* Support macros for users of the predefined info table */ @@ -340,7 +341,7 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = { {{"_BIX", METHOD_0ARGS, METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int),(4 Str) */ - PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, + PACKAGE_INFO(ACPI_PTYPE_CUSTOM, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4, 0), {{"_BLT", diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c index fde5a09..fbedc6e 100644 --- a/drivers/acpi/acpica/nsprepkg.c +++ b/drivers/acpi/acpica/nsprepkg.c @@ -62,6 +62,10 @@ acpi_ns_check_package_elements(struct acpi_evaluate_info *info, u32 count1, u8 type2, u32 count2, u32 start_index); +static acpi_status +acpi_ns_custom_package(struct acpi_evaluate_info *info, + union acpi_operand_object **elements, u32 count); + /******************************************************************************* * * FUNCTION: acpi_ns_check_package @@ -135,6 +139,11 @@ acpi_ns_check_package(struct acpi_evaluate_info *info, * PTYPE2 packages contain subpackages */ switch (package->ret_info.type) { + case ACPI_PTYPE_CUSTOM: + + status = acpi_ns_custom_package(info, elements, count); + break; + case ACPI_PTYPE1_FIXED: /* * The package count is fixed and there are no subpackages @@ -626,6 +635,83 @@ package_too_small: /******************************************************************************* * + * FUNCTION: acpi_ns_custom_package + * + * PARAMETERS: info - Method execution information block + * elements - Pointer to the package elements array + * count - Element count for the package + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + * NOTE: Currently used for the _BIX method only. When needed for two or more + * methods, probably a detect/dispatch mechanism will be required. + * + ******************************************************************************/ + +static acpi_status +acpi_ns_custom_package(struct acpi_evaluate_info *info, + union acpi_operand_object **elements, u32 count) +{ + u32 expected_count; + u32 version; + acpi_status status = AE_OK; + + ACPI_FUNCTION_NAME(ns_custom_package); + + /* Get version number, must be Integer */ + + if ((*elements)->common.type != ACPI_TYPE_INTEGER) { + ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, + info->node_flags, + "Return Package has invalid object type for version number")); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); + } + + version = (u32)(*elements)->integer.value; + expected_count = 21; /* Version 1 */ + + if (version == 0) { + expected_count = 20; /* Version 0 */ + } + + if (count < expected_count) { + ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, + info->node_flags, + "Return Package is too small - found %u elements, expected %u", + count, expected_count)); + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); + } else if (count > expected_count) { + ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + info->full_pathname, count, expected_count)); + } + + /* Validate all elements of the returned package */ + + status = acpi_ns_check_package_elements(info, elements, + ACPI_RTYPE_INTEGER, 16, + ACPI_RTYPE_STRING, 4, 0); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + /* Version 1 has a single trailing integer */ + + if (version > 0) { + status = acpi_ns_check_package_elements(info, elements + 20, + ACPI_RTYPE_INTEGER, 1, + 0, 0, 20); + } + + return_ACPI_STATUS(status); +} + +/******************************************************************************* + * * FUNCTION: acpi_ns_check_package_elements * * PARAMETERS: info - Method execution information block -- cgit v0.10.2 From 14f98579095af5697564276159e07aee1379582d Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 12:58:19 +0800 Subject: ACPICA: ACPI 6.0, tools/iasl: Add support for new resource descriptors ACPICA commit 5a0555ece4ba9917e5842b21d88469ae06b4e815 Adds full support for: i2c_serial_bus_v2 spi_serial_bus_v2 uart_serial_bus_v2 Compiler, Disassembler, Resource Manager, acpi_help. Link: https://github.com/acpica/acpica/commit/5a0555ec Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/rsdumpinfo.c b/drivers/acpi/acpica/rsdumpinfo.c index 5c34913..61e8f16 100644 --- a/drivers/acpi/acpica/rsdumpinfo.c +++ b/drivers/acpi/acpica/rsdumpinfo.c @@ -330,19 +330,20 @@ struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = { {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \ + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.connection_sharing),"ConnectionSharing", acpi_gbl_shr_decode}, \ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \ {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL}, -struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = { +struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[11] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus), "Common Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS }; -struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = { +struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[14] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus), "I2C Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, @@ -355,7 +356,7 @@ struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = { "SlaveAddress", NULL}, }; -struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = { +struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[18] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus), "Spi Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, @@ -376,7 +377,7 @@ struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = { "ConnectionSpeed", NULL}, }; -struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = { +struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[20] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus), "Uart Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG, diff --git a/drivers/acpi/acpica/rsserial.c b/drivers/acpi/acpica/rsserial.c index 8a01296..b82c061 100644 --- a/drivers/acpi/acpica/rsserial.c +++ b/drivers/acpi/acpica/rsserial.c @@ -151,7 +151,7 @@ struct acpi_rsconvert_info acpi_rs_convert_gpio[18] = { * ******************************************************************************/ -struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = { +struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[17] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus), ACPI_RSC_TABLE_SIZE(acpi_rs_convert_i2c_serial_bus)}, @@ -177,6 +177,11 @@ struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = { AML_OFFSET(common_serial_bus.flags), 1}, + {ACPI_RSC_1BITFLAG, + ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing), + AML_OFFSET(common_serial_bus.flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id), AML_OFFSET(common_serial_bus.type_revision_id), @@ -237,7 +242,7 @@ struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = { * ******************************************************************************/ -struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = { +struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[21] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE(struct acpi_resource_spi_serialbus), ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)}, @@ -263,6 +268,11 @@ struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = { AML_OFFSET(common_serial_bus.flags), 1}, + {ACPI_RSC_1BITFLAG, + ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing), + AML_OFFSET(common_serial_bus.flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id), AML_OFFSET(common_serial_bus.type_revision_id), @@ -339,7 +349,7 @@ struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = { * ******************************************************************************/ -struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = { +struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[23] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE(struct acpi_resource_uart_serialbus), ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)}, @@ -365,6 +375,11 @@ struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = { AML_OFFSET(common_serial_bus.flags), 1}, + {ACPI_RSC_1BITFLAG, + ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing), + AML_OFFSET(common_serial_bus.flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id), AML_OFFSET(common_serial_bus.type_revision_id), diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h index cf2acb8..16c1892 100644 --- a/include/acpi/acrestyp.h +++ b/include/acpi/acrestyp.h @@ -417,6 +417,7 @@ struct acpi_resource_gpio { u8 type; \ u8 producer_consumer; /* For values, see Producer/Consumer above */\ u8 slave_mode; \ + u8 connection_sharing; \ u8 type_revision_id; \ u16 type_data_length; \ u16 vendor_length; \ -- cgit v0.10.2 From 5391abfdae7fc61556af4dd115e7522985fc9998 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 12:58:25 +0800 Subject: ACPICA: Renamed some #defined flag constants for clarity ACPICA commit 438905b205e64e742f9670a0970419c426264831 Expanded a couple of cryptic names. Link: https://github.com/acpica/acpica/commit/438905b2 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 166a67f..13331d7 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -856,24 +856,24 @@ struct acpi_parse_state { /* Parse object flags */ -#define ACPI_PARSEOP_GENERIC 0x01 -#define ACPI_PARSEOP_NAMED 0x02 -#define ACPI_PARSEOP_DEFERRED 0x04 -#define ACPI_PARSEOP_BYTELIST 0x08 -#define ACPI_PARSEOP_IN_STACK 0x10 -#define ACPI_PARSEOP_TARGET 0x20 -#define ACPI_PARSEOP_IN_CACHE 0x80 +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED_OBJECT 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 /* Parse object disasm_flags */ -#define ACPI_PARSEOP_IGNORE 0x01 -#define ACPI_PARSEOP_PARAMLIST 0x02 -#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 -#define ACPI_PARSEOP_PREDEF_CHECKED 0x08 -#define ACPI_PARSEOP_CLOSING_PAREN 0x10 -#define ACPI_PARSEOP_COMPOUND 0x20 -#define ACPI_PARSEOP_ASSIGNMENT 0x40 -#define ACPI_PARSEOP_ELSEIF 0x80 +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMETER_LIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x08 +#define ACPI_PARSEOP_CLOSING_PAREN 0x10 +#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x20 +#define ACPI_PARSEOP_ASSIGNMENT 0x40 +#define ACPI_PARSEOP_ELSEIF 0x80 /***************************************************************************** * diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c index b28b0da..89cb4bf 100644 --- a/drivers/acpi/acpica/psutils.c +++ b/drivers/acpi/acpica/psutils.c @@ -128,7 +128,7 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml) if (op_info->flags & AML_DEFER) { flags = ACPI_PARSEOP_DEFERRED; } else if (op_info->flags & AML_NAMED) { - flags = ACPI_PARSEOP_NAMED; + flags = ACPI_PARSEOP_NAMED_OBJECT; } else if (opcode == AML_INT_BYTELIST_OP) { flags = ACPI_PARSEOP_BYTELIST; } -- cgit v0.10.2 From e35d75024b28083b0a84cdb73b826f8450b29d49 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 12:58:32 +0800 Subject: ACPICA: Utilities: Add ACPI_IS_ALIGNED() macro This patch introduces ACPI_IS_ALIGNED() macro. Lv Zheng. Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index 73f6653..ecbaaba 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -262,7 +262,8 @@ /* Generic (power-of-two) rounding */ -#define ACPI_IS_POWER_OF_TWO(a) (((a) & ((a) - 1)) == 0) +#define ACPI_IS_ALIGNED(a, s) (((a) & ((s) - 1)) == 0) +#define ACPI_IS_POWER_OF_TWO(a) ACPI_IS_ALIGNED(a, a) /* * Bitmask creation -- cgit v0.10.2 From b314a172ee968d45f72dffea68ab8af38aa80ded Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 12:58:39 +0800 Subject: ACPICA: Hardware: Add optimized access bit width support ACPICA commit c49a751b4dae7baec1790748a2b4b6e8ab599f51 For Access Size = 0, it actually can use user expected access bit width. This patch implements this. Besides of the ACPICA upstream commit, this patch also includes a fix fixing the issue reported by the FreeBSD community. The old register descriptors are translated in acpi_tb_init_generic_address() with access_width being filled with 0. This breaks code in acpi_hw_get_access_bit_width() when the registers are 16-bit IO ports and their bit_width fields are filled with 16. The rapid fix is meant to make code written for acpi_hw_get_access_bit_width() regression safer before the issue is correctly fixed from acpi_tb_init_generic_address(). Reported by John Baldwin , fixed by Lv Zheng , tested by Jung-uk Kim . Link: https://github.com/acpica/acpica/commit/c49a751b Reported-by: John Baldwin Tested-by Jung-uk Kim . Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 035fb52..892e677 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -51,6 +51,10 @@ ACPI_MODULE_NAME("hwregs") #if (!ACPI_REDUCED_HARDWARE) /* Local Prototypes */ +static u8 +acpi_hw_get_access_bit_width(struct acpi_generic_address *reg, + u8 max_bit_width); + static acpi_status acpi_hw_read_multiple(u32 *value, struct acpi_generic_address *register_a, @@ -65,6 +69,48 @@ acpi_hw_write_multiple(u32 value, /****************************************************************************** * + * FUNCTION: acpi_hw_get_access_bit_width + * + * PARAMETERS: reg - GAS register structure + * max_bit_width - Max bit_width supported (32 or 64) + * + * RETURN: Status + * + * DESCRIPTION: Obtain optimal access bit width + * + ******************************************************************************/ + +static u8 +acpi_hw_get_access_bit_width(struct acpi_generic_address *reg, u8 max_bit_width) +{ + u64 address; + + if (!reg->access_width) { + /* + * Detect old register descriptors where only the bit_width field + * makes senses. The target address is copied to handle possible + * alignment issues. + */ + ACPI_MOVE_64_TO_64(&address, ®->address); + if (!reg->bit_offset && reg->bit_width && + ACPI_IS_POWER_OF_TWO(reg->bit_width) && + ACPI_IS_ALIGNED(reg->bit_width, 8) && + ACPI_IS_ALIGNED(address, reg->bit_width)) { + return (reg->bit_width); + } else { + if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { + return (32); + } else { + return (max_bit_width); + } + } + } else { + return (1 << (reg->access_width + 2)); + } +} + +/****************************************************************************** + * * FUNCTION: acpi_hw_validate_register * * PARAMETERS: reg - GAS register structure @@ -122,8 +168,7 @@ acpi_hw_validate_register(struct acpi_generic_address *reg, /* Validate the bit_width, convert access_width into number of bits */ - access_width = reg->access_width ? reg->access_width : 1; - access_width = 1 << (access_width + 2); + access_width = acpi_hw_get_access_bit_width(reg, max_bit_width); bit_width = ACPI_ROUND_UP(reg->bit_offset + reg->bit_width, access_width); if (max_bit_width < bit_width) { -- cgit v0.10.2 From 9222aa8234d9f07a70e815ddd3b44a97d673aff5 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 12:58:45 +0800 Subject: ACPICA: Executer: Introduce a set of macros to handle bit width mask generation ACPICA commit c23034a3a09d5ed79f1827d51f43cfbccf68ab64 A regression was reported to the shift offset >= width of type. This patch fixes this issue. BZ 1270. This is a part of the fix because the order of the patches are modified for Linux upstream, containing the cleanups for the old code. Lv Zheng. Link: https://github.com/acpica/acpica/commit/c23034a3 Link: https://bugs.acpica.org/show_bug.cgi?id=1270 Reported-by: Sascha Wildner Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index ecbaaba..a3b9543 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -270,9 +270,21 @@ * Bit positions start at zero. * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + * MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask + * MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask + * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler + * differences with the shift operator */ #define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position)))) #define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position))) +#define ACPI_MASK_BITS_ABOVE_32(width) ((u32) ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_32(width) ((u32) ACPI_MASK_BITS_BELOW(width)) +#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + ACPI_UINT64_MAX : \ + ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + (u64) 0 : \ + ACPI_MASK_BITS_BELOW(width)) /* Bitfields within ACPI registers */ diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index 72f9176..ee76d29 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c @@ -897,17 +897,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width); - /* - * Create the bitmasks used for bit insertion. - * Note: This if/else is used to bypass compiler differences with the - * shift operator - */ - if (access_bit_width == ACPI_INTEGER_BIT_SIZE) { - width_mask = ACPI_UINT64_MAX; - } else { - width_mask = ACPI_MASK_BITS_ABOVE(access_bit_width); - } + /* Create the bitmasks used for bit insertion */ + width_mask = ACPI_MASK_BITS_ABOVE_64(access_bit_width); mask = width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset); -- cgit v0.10.2 From c3bc26d4b4e36f0dc458eea8b1f722d8a8d9addd Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 12:58:52 +0800 Subject: ACPICA: ACPI 2.0, Hardware: Add access_width/bit_offset support in acpi_hw_read() ACPICA commit 96ece052d4d073aae4f935f0ff0746646aea1174 ACPICA commit 3d8583a054e410f2ea4d73b48986facad9cfc0d4 This patch adds access_width/bit_offset support in acpi_hw_read(). This also enables GAS definition where bit_width is not a power of two. Lv Zheng. Link: https://github.com/acpica/acpica/commit/96ece052 Link: https://github.com/acpica/acpica/commit/3d8583a0 Link: https://bugs.acpica.org/show_bug.cgi?id=1240 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 892e677..6eee012 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -195,17 +195,19 @@ acpi_hw_validate_register(struct acpi_generic_address *reg, * 64-bit values is not needed. * * LIMITATIONS: - * bit_width must be exactly 8, 16, or 32. * space_ID must be system_memory or system_IO. - * bit_offset and access_width are currently ignored, as there has - * not been a need to implement these. * ******************************************************************************/ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) { u64 address; + u8 access_width; + u32 bit_width; + u8 bit_offset; u64 value64; + u32 value32; + u8 index; acpi_status status; ACPI_FUNCTION_NAME(hw_read); @@ -217,28 +219,75 @@ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) return (status); } - /* Initialize entire 32-bit return value to zero */ - + /* + * Initialize entire 32-bit return value to zero, convert access_width + * into number of bits based + */ *value = 0; + access_width = acpi_hw_get_access_bit_width(reg, 32); + bit_width = reg->bit_offset + reg->bit_width; + bit_offset = reg->bit_offset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - status = acpi_os_read_memory((acpi_physical_address) - address, &value64, reg->bit_width); + index = 0; + while (bit_width) { + if (bit_offset >= access_width) { + value32 = 0; + bit_offset -= access_width; + } else { + if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { + status = + acpi_os_read_memory((acpi_physical_address) + address + + index * + ACPI_DIV_8 + (access_width), + &value64, access_width); + value32 = (u32)value64; + } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + + status = acpi_hw_read_port((acpi_io_address) + address + + index * + ACPI_DIV_8 + (access_width), + &value32, + access_width); + } - *value = (u32)value64; - } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + /* + * Use offset style bit masks because: + * bit_offset < access_width/bit_width < access_width, and + * access_width is ensured to be less than 32-bits by + * acpi_hw_validate_register(). + */ + if (bit_offset) { + value32 &= ACPI_MASK_BITS_BELOW(bit_offset); + bit_offset = 0; + } + if (bit_width < access_width) { + value32 &= ACPI_MASK_BITS_ABOVE(bit_width); + } + } + + /* + * Use offset style bit writes because "Index * AccessWidth" is + * ensured to be less than 32-bits by acpi_hw_validate_register(). + */ + ACPI_SET_BITS(value, index * access_width, + ACPI_MASK_BITS_ABOVE_32(access_width), value32); - status = acpi_hw_read_port((acpi_io_address) - address, value, reg->bit_width); + bit_width -= + bit_width > access_width ? access_width : bit_width; + index++; } ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *value, reg->bit_width, ACPI_FORMAT_UINT64(address), + *value, access_width, ACPI_FORMAT_UINT64(address), acpi_ut_get_region_name(reg->space_id))); return (status); -- cgit v0.10.2 From 66b1ed5aa8dd253a734bf6ca4e5390385724f99c Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 5 May 2016 13:00:29 +0800 Subject: ACPICA: ACPI 2.0, Hardware: Add access_width/bit_offset support for acpi_hw_write() ACPICA commit 48eea5e7993ccb7189bd63cd726e02adafee6057 This patch adds access_width/bit_offset support in acpi_hw_write(). Lv Zheng. Link: https://github.com/acpica/acpica/commit/48eea5e7 Link: https://bugs.acpica.org/show_bug.cgi?id=1240 Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 6eee012..0f18dbc 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -311,6 +311,12 @@ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg) { u64 address; + u8 access_width; + u32 bit_width; + u8 bit_offset; + u64 value64; + u32 new_value32, old_value32; + u8 index; acpi_status status; ACPI_FUNCTION_NAME(hw_write); @@ -322,23 +328,145 @@ acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg) return (status); } + /* Convert access_width into number of bits based */ + + access_width = acpi_hw_get_access_bit_width(reg, 32); + bit_width = reg->bit_offset + reg->bit_width; + bit_offset = reg->bit_offset; + /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - status = acpi_os_write_memory((acpi_physical_address) - address, (u64)value, - reg->bit_width); - } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - - status = acpi_hw_write_port((acpi_io_address) - address, value, reg->bit_width); + index = 0; + while (bit_width) { + /* + * Use offset style bit reads because "Index * AccessWidth" is + * ensured to be less than 32-bits by acpi_hw_validate_register(). + */ + new_value32 = ACPI_GET_BITS(&value, index * access_width, + ACPI_MASK_BITS_ABOVE_32 + (access_width)); + + if (bit_offset >= access_width) { + bit_offset -= access_width; + } else { + /* + * Use offset style bit masks because access_width is ensured + * to be less than 32-bits by acpi_hw_validate_register() and + * bit_offset/bit_width is less than access_width here. + */ + if (bit_offset) { + new_value32 &= ACPI_MASK_BITS_BELOW(bit_offset); + } + if (bit_width < access_width) { + new_value32 &= ACPI_MASK_BITS_ABOVE(bit_width); + } + + if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { + if (bit_offset || bit_width < access_width) { + /* + * Read old values in order not to modify the bits that + * are beyond the register bit_width/bit_offset setting. + */ + status = + acpi_os_read_memory((acpi_physical_address) + address + + index * + ACPI_DIV_8 + (access_width), + &value64, + access_width); + old_value32 = (u32)value64; + + /* + * Use offset style bit masks because access_width is + * ensured to be less than 32-bits by + * acpi_hw_validate_register() and bit_offset/bit_width is + * less than access_width here. + */ + if (bit_offset) { + old_value32 &= + ACPI_MASK_BITS_ABOVE + (bit_offset); + bit_offset = 0; + } + if (bit_width < access_width) { + old_value32 &= + ACPI_MASK_BITS_BELOW + (bit_width); + } + + new_value32 |= old_value32; + } + + value64 = (u64)new_value32; + status = + acpi_os_write_memory((acpi_physical_address) + address + + index * + ACPI_DIV_8 + (access_width), + value64, access_width); + } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + + if (bit_offset || bit_width < access_width) { + /* + * Read old values in order not to modify the bits that + * are beyond the register bit_width/bit_offset setting. + */ + status = + acpi_hw_read_port((acpi_io_address) + address + + index * + ACPI_DIV_8 + (access_width), + &old_value32, + access_width); + + /* + * Use offset style bit masks because access_width is + * ensured to be less than 32-bits by + * acpi_hw_validate_register() and bit_offset/bit_width is + * less than access_width here. + */ + if (bit_offset) { + old_value32 &= + ACPI_MASK_BITS_ABOVE + (bit_offset); + bit_offset = 0; + } + if (bit_width < access_width) { + old_value32 &= + ACPI_MASK_BITS_BELOW + (bit_width); + } + + new_value32 |= old_value32; + } + + status = acpi_hw_write_port((acpi_io_address) + address + + index * + ACPI_DIV_8 + (access_width), + new_value32, + access_width); + } + } + + /* + * Index * access_width is ensured to be less than 32-bits by + * acpi_hw_validate_register(). + */ + bit_width -= + bit_width > access_width ? access_width : bit_width; + index++; } ACPI_DEBUG_PRINT((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - value, reg->bit_width, ACPI_FORMAT_UINT64(address), + value, access_width, ACPI_FORMAT_UINT64(address), acpi_ut_get_region_name(reg->space_id))); return (status); -- cgit v0.10.2 From 6a0df32c22fdfc414e6613c1bc911f19f39df01b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 13:00:36 +0800 Subject: ACPICA: Move all ASCII utilities to a common file ACPICA commit ba60e4500053010bf775d58f6f61febbdb94d817 New file is utascii.c Link: https://github.com/acpica/acpica/commit/ba60e450 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 188597f..227bb7b 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile @@ -150,6 +150,7 @@ acpi-y += \ acpi-y += \ utaddress.o \ utalloc.o \ + utascii.o \ utbuffer.o \ utcopy.o \ utexcep.o \ diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h index 848ad3a..cd5a135 100644 --- a/drivers/acpi/acpica/actables.h +++ b/drivers/acpi/acpica/actables.h @@ -161,8 +161,6 @@ acpi_tb_install_fixed_table(acpi_physical_address address, acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address); -u8 acpi_is_valid_signature(char *signature); - /* * tbxfload */ diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 107f9e0..a7dbb2b 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -167,6 +167,15 @@ struct acpi_pkg_info { #define DB_QWORD_DISPLAY 8 /* + * utascii - ASCII utilities + */ +u8 acpi_ut_valid_nameseg(char *signature); + +u8 acpi_ut_valid_name_char(char character, u32 position); + +void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count); + +/* * utnonansi - Non-ANSI C library functions */ void acpi_ut_strupr(char *src_string); @@ -579,10 +588,6 @@ void acpi_ut_print_string(char *string, u16 max_length); void ut_convert_backslashes(char *pathname); #endif -u8 acpi_ut_valid_acpi_name(char *name); - -u8 acpi_ut_valid_acpi_char(char character, u32 position); - void acpi_ut_repair_name(char *name); #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c index 4c9e59a..8667f14 100644 --- a/drivers/acpi/acpica/dbnames.c +++ b/drivers/acpi/acpica/dbnames.c @@ -709,7 +709,7 @@ acpi_db_integrity_walk(acpi_handle obj_handle, return (AE_OK); } - if (!acpi_ut_valid_acpi_name(node->name.ascii)) { + if (!acpi_ut_valid_nameseg(node->name.ascii)) { acpi_os_printf("Invalid AcpiName for Node %p\n", node); return (AE_OK); } diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c index 27c11ab..3d6af93 100644 --- a/drivers/acpi/acpica/exnames.c +++ b/drivers/acpi/acpica/exnames.c @@ -178,7 +178,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) for (index = 0; (index < ACPI_NAME_SIZE) - && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { + && (acpi_ut_valid_name_char(*aml_address, 0)); index++) { char_buf[index] = *aml_address++; ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); } diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c index d471df3..1388a19 100644 --- a/drivers/acpi/acpica/tbdata.c +++ b/drivers/acpi/acpica/tbdata.c @@ -401,9 +401,9 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature) ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "%4.4s 0x%8.8X%8.8X" " Attempted table install failed", - acpi_ut_valid_acpi_name(table_desc-> - signature. - ascii) ? + acpi_ut_valid_nameseg(table_desc-> + signature. + ascii) ? table_desc->signature.ascii : "????", ACPI_FORMAT_UINT64(table_desc-> address))); diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c index f2d0803..e348d61 100644 --- a/drivers/acpi/acpica/tbfind.c +++ b/drivers/acpi/acpica/tbfind.c @@ -76,7 +76,7 @@ acpi_tb_find_table(char *signature, /* Validate the input table signature */ - if (!acpi_is_valid_signature(signature)) { + if (!acpi_ut_valid_nameseg(signature)) { return_ACPI_STATUS(AE_BAD_SIGNATURE); } diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index 4dc6108..8b13052 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c @@ -299,9 +299,9 @@ acpi_tb_install_standard_table(acpi_physical_address address, ACPI_BIOS_ERROR((AE_INFO, "Table has invalid signature [%4.4s] (0x%8.8X), " "must be SSDT or OEMx", - acpi_ut_valid_acpi_name(new_table_desc. - signature. - ascii) ? + acpi_ut_valid_nameseg(new_table_desc. + signature. + ascii) ? new_table_desc.signature. ascii : "????", new_table_desc.signature.integer)); diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index a962a85..e285539 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -380,30 +380,3 @@ next_table: acpi_os_unmap_memory(table, length); return_ACPI_STATUS(AE_OK); } - -/******************************************************************************* - * - * FUNCTION: acpi_is_valid_signature - * - * PARAMETERS: signature - Sig string to be validated - * - * RETURN: TRUE if signature is has 4 valid ACPI characters - * - * DESCRIPTION: Validate an ACPI table signature. - * - ******************************************************************************/ - -u8 acpi_is_valid_signature(char *signature) -{ - u32 i; - - /* Validate each character in the signature */ - - for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (!acpi_ut_valid_acpi_char(signature[i], i)) { - return (FALSE); - } - } - - return (TRUE); -} diff --git a/drivers/acpi/acpica/utascii.c b/drivers/acpi/acpica/utascii.c new file mode 100644 index 0000000..706c1f3 --- /dev/null +++ b/drivers/acpi/acpica/utascii.c @@ -0,0 +1,140 @@ +/****************************************************************************** + * + * Module Name: utascii - Utility ascii functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include +#include "accommon.h" + +/******************************************************************************* + * + * FUNCTION: acpi_ut_valid_nameseg + * + * PARAMETERS: name - The name or table signature to be examined. + * Four characters, does not have to be a + * NULL terminated string. + * + * RETURN: TRUE if signature is has 4 valid ACPI characters + * + * DESCRIPTION: Validate an ACPI table signature. + * + ******************************************************************************/ + +u8 acpi_ut_valid_nameseg(char *name) +{ + u32 i; + + /* Validate each character in the signature */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) { + if (!acpi_ut_valid_name_char(name[i], i)) { + return (FALSE); + } + } + + return (TRUE); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_valid_name_char + * + * PARAMETERS: char - The character to be examined + * position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +u8 acpi_ut_valid_name_char(char character, u32 position) +{ + + if (!((character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9') || (character == '_'))) { + + /* Allow a '!' in the last position */ + + if (character == '!' && position == 3) { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_check_and_repair_ascii + * + * PARAMETERS: name - Ascii string + * count - Number of characters to check + * + * RETURN: None + * + * DESCRIPTION: Ensure that the requested number of characters are printable + * Ascii characters. Sets non-printable and null chars to . + * + ******************************************************************************/ + +void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count) +{ + u32 i; + + for (i = 0; i < count; i++) { + repaired_name[i] = (char)name[i]; + + if (!name[i]) { + return; + } + if (!isprint(name[i])) { + repaired_name[i] = ' '; + } + } +} diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c index 241259b..288913a 100644 --- a/drivers/acpi/acpica/utstring.c +++ b/drivers/acpi/acpica/utstring.c @@ -145,73 +145,6 @@ void acpi_ut_print_string(char *string, u16 max_length) /******************************************************************************* * - * FUNCTION: acpi_ut_valid_acpi_char - * - * PARAMETERS: char - The character to be examined - * position - Byte position (0-3) - * - * RETURN: TRUE if the character is valid, FALSE otherwise - * - * DESCRIPTION: Check for a valid ACPI character. Must be one of: - * 1) Upper case alpha - * 2) numeric - * 3) underscore - * - * We allow a '!' as the last character because of the ASF! table - * - ******************************************************************************/ - -u8 acpi_ut_valid_acpi_char(char character, u32 position) -{ - - if (!((character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9') || (character == '_'))) { - - /* Allow a '!' in the last position */ - - if (character == '!' && position == 3) { - return (TRUE); - } - - return (FALSE); - } - - return (TRUE); -} - -/******************************************************************************* - * - * FUNCTION: acpi_ut_valid_acpi_name - * - * PARAMETERS: name - The name to be examined. Does not have to - * be NULL terminated string. - * - * RETURN: TRUE if the name is valid, FALSE otherwise - * - * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: - * 1) Upper case alpha - * 2) numeric - * 3) underscore - * - ******************************************************************************/ - -u8 acpi_ut_valid_acpi_name(char *name) -{ - u32 i; - - ACPI_FUNCTION_ENTRY(); - - for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (!acpi_ut_valid_acpi_char(name[i], i)) { - return (FALSE); - } - } - - return (TRUE); -} - -/******************************************************************************* - * * FUNCTION: acpi_ut_repair_name * * PARAMETERS: name - The ACPI name to be repaired @@ -253,7 +186,7 @@ void acpi_ut_repair_name(char *name) /* Check each character in the name */ for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (acpi_ut_valid_acpi_char(name[i], i)) { + if (acpi_ut_valid_name_char(name[i], i)) { continue; } diff --git a/tools/power/acpi/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile index 8d76157..2942cdc 100644 --- a/tools/power/acpi/tools/acpidump/Makefile +++ b/tools/power/acpi/tools/acpidump/Makefile @@ -31,6 +31,7 @@ TOOL_OBJS = \ osunixxf.o\ tbprint.o\ tbxfroot.o\ + utascii.o\ utbuffer.o\ utdebug.o\ utexcep.o\ diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index a39e445..fb8f1d9 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c @@ -68,7 +68,7 @@ u8 ap_is_valid_header(struct acpi_table_header *table) /* Make sure signature is all ASCII and a valid ACPI name */ - if (!acpi_ut_valid_acpi_name(table->signature)) { + if (!acpi_ut_valid_nameseg(table->signature)) { acpi_log_error("Table signature (0x%8.8X) is invalid\n", *(u32 *)table->signature); return (FALSE); @@ -407,6 +407,12 @@ int ap_dump_table_from_file(char *pathname) return (-1); } + if (!acpi_ut_valid_nameseg(table->signature)) { + acpi_log_error + ("No valid ACPI signature was found in input file %s\n", + pathname); + } + /* File must be at least as long as the table length */ if (table->length > file_size) { -- cgit v0.10.2 From 878a872ead5d178b1947b480990de186529ff0b9 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 5 May 2016 13:00:42 +0800 Subject: ACPICA: Update version to 20160422 ACPICA commit a2327ba410e19c2aabaf34b711dbadf7d1dcf346 Version 20160422. Link: https://github.com/acpica/acpica/commit/a2327ba4 Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index fcd8119..1ff3a76 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160318 +#define ACPI_CA_VERSION 0x20160422 #include #include -- cgit v0.10.2 From f18ebc211e259d4f591e39e74b2aa2de226c9a1d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 5 May 2016 16:23:04 +0300 Subject: ACPI / sysfs: fix error code in get_status() The problem with ornamental, do-nothing gotos is that they lead to "forgot to set the error code" bugs. We should be returning -EINVAL here but we don't. It leads to an uninitalized variable in counter_show(): drivers/acpi/sysfs.c:603 counter_show() error: uninitialized symbol 'status'. Fixes: 1c8fce27e275 (ACPI: introduce drivers/acpi/sysfs.c) Signed-off-by: Dan Carpenter Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 0243d37..4b3a9e2 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -555,23 +555,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device, static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle) { - int result = 0; + int result; if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS) - goto end; + return -EINVAL; if (index < num_gpes) { result = acpi_get_gpe_device(index, handle); if (result) { ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, "Invalid GPE 0x%x", index)); - goto end; + return result; } result = acpi_get_gpe_status(*handle, index, status); } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) result = acpi_get_event_status(index - num_gpes, status); -end: return result; } -- cgit v0.10.2 From 74216699ddcca13541e8494cb2b995e6a44a04d9 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 May 2016 01:27:09 +0200 Subject: ACPI / tables: Fix DSDT override mechanism Commit 5ae74f2cc2f1 (ACPI / tables: Move table override mechanisms to tables.c) forgot to move the CONFIG_ACPI_CUSTOM_DSDT_FILE inclusion directive from osl.c to tables.c. Fix that. Fixes: 5ae74f2cc2f1 (ACPI / tables: Move table override mechanisms to tables.c) Signed-off-by: Rafael J. Wysocki Acked-by: Lv Zheng diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 0796ad9..0155f8b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -56,10 +56,6 @@ struct acpi_os_dpc { struct work_struct work; }; -#ifdef CONFIG_ACPI_CUSTOM_DSDT -#include CONFIG_ACPI_CUSTOM_DSDT_FILE -#endif - #ifdef ENABLE_DEBUGGER #include diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 08795fb..a372f9e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -36,6 +36,10 @@ #include #include "internal.h" +#ifdef CONFIG_ACPI_CUSTOM_DSDT +#include CONFIG_ACPI_CUSTOM_DSDT_FILE +#endif + #define ACPI_MAX_TABLES 128 static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; -- cgit v0.10.2 From 437014bdac9680e3b32c006635ac270b808ce476 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 9 May 2016 14:40:27 -0400 Subject: ACPI / GED: make evged.c explicitly non-modular The Makefile/Kconfig currently controlling compilation of this code is: Makefile:acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o drivers/acpi/Kconfig:config ACPI_REDUCED_HARDWARE_ONLY drivers/acpi/Kconfig: bool "Hardware-reduced ACPI support only" if EXPERT ...meaning that it currently is not being built as a module by anyone. Lets remove the couple traces of modularity so that when reading the code there is no doubt it is builtin-only. Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit. The file wasn't explicitly including the module.h file but it did already have init.h so, unlike similar changes, this one has no header changes at all. We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments. Signed-off-by: Paul Gortmaker Signed-off-by: Rafael J. Wysocki diff --git a/drivers/acpi/evged.c b/drivers/acpi/evged.c index 9c0a868..46f0603 100644 --- a/drivers/acpi/evged.c +++ b/drivers/acpi/evged.c @@ -151,6 +151,4 @@ static struct platform_driver ged_driver = { .acpi_match_table = ACPI_PTR(ged_acpi_ids), }, }; - -module_platform_driver(ged_driver); -MODULE_LICENSE("GPL v2"); +builtin_platform_driver(ged_driver); -- cgit v0.10.2 From a3c89334f06bacf7e2f23203ad64cfd6e78dbbf4 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Mon, 9 May 2016 15:54:58 +0800 Subject: Thermal / ACPI / video: add INT3406 thermal driver INT3406 ACPI device object resembles an ACPI video output device, but its _BCM is said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling. Signed-off-by: Aaron Lu Acked-by: Zhang Rui Signed-off-by: Rafael J. Wysocki diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 3c3dc4a..d89d60c 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -338,31 +338,9 @@ config INTEL_QUARK_DTS_THERMAL hot & critical. The critical trip point default value is set by underlying BIOS/Firmware. -config INT340X_THERMAL - tristate "ACPI INT340X thermal drivers" - depends on X86 && ACPI - select THERMAL_GOV_USER_SPACE - select ACPI_THERMAL_REL - select ACPI_FAN - select INTEL_SOC_DTS_IOSF_CORE - select THERMAL_WRITABLE_TRIPS - help - Newer laptops and tablets that use ACPI may have thermal sensors and - other devices with thermal control capabilities outside the core - CPU/SOC, for thermal safety reasons. - They are exposed for the OS to use via the INT3400 ACPI device object - as the master, and INT3401~INT340B ACPI device objects as the slaves. - Enable this to expose the temperature information and cooling ability - from these objects to userspace via the normal thermal framework. - This means that a wide range of applications and GUI widgets can show - the information to the user or use this information for making - decisions. For example, the Intel Thermal Daemon can use this - information to allow the user to select his laptop to run without - turning on the fans. - -config ACPI_THERMAL_REL - tristate - depends on ACPI +menu "ACPI INT340X thermal drivers" +source drivers/thermal/int340x_thermal/Kconfig +endmenu config INTEL_PCH_THERMAL tristate "Intel PCH Thermal Reporting Driver" diff --git a/drivers/thermal/int340x_thermal/Kconfig b/drivers/thermal/int340x_thermal/Kconfig new file mode 100644 index 0000000..0582bd1 --- /dev/null +++ b/drivers/thermal/int340x_thermal/Kconfig @@ -0,0 +1,42 @@ +# +# ACPI INT340x thermal drivers configuration +# + +config INT340X_THERMAL + tristate "ACPI INT340X thermal drivers" + depends on X86 && ACPI + select THERMAL_GOV_USER_SPACE + select ACPI_THERMAL_REL + select ACPI_FAN + select INTEL_SOC_DTS_IOSF_CORE + help + Newer laptops and tablets that use ACPI may have thermal sensors and + other devices with thermal control capabilities outside the core + CPU/SOC, for thermal safety reasons. + They are exposed for the OS to use via the INT3400 ACPI device object + as the master, and INT3401~INT340B ACPI device objects as the slaves. + Enable this to expose the temperature information and cooling ability + from these objects to userspace via the normal thermal framework. + This means that a wide range of applications and GUI widgets can show + the information to the user or use this information for making + decisions. For example, the Intel Thermal Daemon can use this + information to allow the user to select his laptop to run without + turning on the fans. + +config ACPI_THERMAL_REL + tristate + depends on ACPI + +if INT340X_THERMAL + +config INT3406_THERMAL + tristate "ACPI INT3406 display thermal driver" + depends on ACPI_VIDEO + help + The display thermal device represents the LED/LCD display panel + that may or may not include touch support. The main function of + the display thermal device is to allow control of the display + brightness in order to address a thermal condition or to reduce + power consumed by display device. + +endif diff --git a/drivers/thermal/int340x_thermal/Makefile b/drivers/thermal/int340x_thermal/Makefile index ba77a34..df0df05 100644 --- a/drivers/thermal/int340x_thermal/Makefile +++ b/drivers/thermal/int340x_thermal/Makefile @@ -3,4 +3,5 @@ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal_zone.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o +obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o diff --git a/drivers/thermal/int340x_thermal/int3406_thermal.c b/drivers/thermal/int340x_thermal/int3406_thermal.c new file mode 100644 index 0000000..13d431c --- /dev/null +++ b/drivers/thermal/int340x_thermal/int3406_thermal.c @@ -0,0 +1,236 @@ +/* + * INT3406 thermal driver for display participant device + * + * Copyright (C) 2016, Intel Corporation + * Authors: Aaron Lu + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include + +#define INT3406_BRIGHTNESS_LIMITS_CHANGED 0x80 + +struct int3406_thermal_data { + int upper_limit; + int upper_limit_index; + int lower_limit; + int lower_limit_index; + acpi_handle handle; + struct acpi_video_device_brightness *br; + struct backlight_device *raw_bd; + struct thermal_cooling_device *cooling_dev; +}; + +static int int3406_thermal_to_raw(int level, struct int3406_thermal_data *d) +{ + int max_level = d->br->levels[d->br->count - 1]; + int raw_max = d->raw_bd->props.max_brightness; + + return level * raw_max / max_level; +} + +static int int3406_thermal_to_acpi(int level, struct int3406_thermal_data *d) +{ + int raw_max = d->raw_bd->props.max_brightness; + int max_level = d->br->levels[d->br->count - 1]; + + return level * max_level / raw_max; +} + +static int +int3406_thermal_get_max_state(struct thermal_cooling_device *cooling_dev, + unsigned long *state) +{ + struct int3406_thermal_data *d = cooling_dev->devdata; + int index = d->lower_limit_index ? d->lower_limit_index : 2; + + *state = d->br->count - 1 - index; + return 0; +} + +static int +int3406_thermal_set_cur_state(struct thermal_cooling_device *cooling_dev, + unsigned long state) +{ + struct int3406_thermal_data *d = cooling_dev->devdata; + int level, raw_level; + + if (state > d->br->count - 3) + return -EINVAL; + + state = d->br->count - 1 - state; + level = d->br->levels[state]; + + if ((d->upper_limit && level > d->upper_limit) || + (d->lower_limit && level < d->lower_limit)) + return -EINVAL; + + raw_level = int3406_thermal_to_raw(level, d); + return backlight_device_set_brightness(d->raw_bd, raw_level); +} + +static int +int3406_thermal_get_cur_state(struct thermal_cooling_device *cooling_dev, + unsigned long *state) +{ + struct int3406_thermal_data *d = cooling_dev->devdata; + int raw_level, level, i; + int *levels = d->br->levels; + + raw_level = d->raw_bd->props.brightness; + level = int3406_thermal_to_acpi(raw_level, d); + + /* + * There is no 1:1 mapping between the firmware interface level with the + * raw interface level, we will have to find one that is close enough. + */ + for (i = 2; i < d->br->count; i++) { + if (level < levels[i]) { + if (i == 2) + break; + if ((level - levels[i - 1]) < (levels[i] - level)) + i--; + break; + } + } + + *state = d->br->count - 1 - i; + return 0; +} + +static const struct thermal_cooling_device_ops video_cooling_ops = { + .get_max_state = int3406_thermal_get_max_state, + .get_cur_state = int3406_thermal_get_cur_state, + .set_cur_state = int3406_thermal_set_cur_state, +}; + +static int int3406_thermal_get_index(int *array, int nr, int value) +{ + int i; + + for (i = 0; i < nr; i++) { + if (array[i] == value) + break; + } + return i == nr ? -ENOENT : i; +} + +static void int3406_thermal_get_limit(struct int3406_thermal_data *d) +{ + acpi_status status; + unsigned long long lower_limit, upper_limit; + int index; + + status = acpi_evaluate_integer(d->handle, "DDDL", NULL, &lower_limit); + if (ACPI_SUCCESS(status)) { + index = int3406_thermal_get_index(d->br->levels, d->br->count, + lower_limit); + if (index > 0) { + d->lower_limit = (int)lower_limit; + d->lower_limit_index = index; + } + } + + status = acpi_evaluate_integer(d->handle, "DDPC", NULL, &upper_limit); + if (ACPI_SUCCESS(status)) { + index = int3406_thermal_get_index(d->br->levels, d->br->count, + upper_limit); + if (index > 0) { + d->upper_limit = (int)upper_limit; + d->upper_limit_index = index; + } + } +} + +static void int3406_notify(acpi_handle handle, u32 event, void *data) +{ + if (event == INT3406_BRIGHTNESS_LIMITS_CHANGED) + int3406_thermal_get_limit(data); +} + +static int int3406_thermal_probe(struct platform_device *pdev) +{ + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); + struct int3406_thermal_data *d; + struct backlight_device *bd; + int ret; + + if (!ACPI_HANDLE(&pdev->dev)) + return -ENODEV; + + d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL); + if (!d) + return -ENOMEM; + d->handle = ACPI_HANDLE(&pdev->dev); + + bd = backlight_device_get_by_type(BACKLIGHT_RAW); + if (!bd) + return -ENODEV; + d->raw_bd = bd; + + ret = acpi_video_get_levels(ACPI_COMPANION(&pdev->dev), &d->br); + if (ret) + return ret; + + int3406_thermal_get_limit(d); + + d->cooling_dev = thermal_cooling_device_register(acpi_device_bid(adev), + d, &video_cooling_ops); + if (IS_ERR(d->cooling_dev)) + goto err; + + ret = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, + int3406_notify, d); + if (ret) + goto err_cdev; + + platform_set_drvdata(pdev, d); + + return 0; + +err_cdev: + thermal_cooling_device_unregister(d->cooling_dev); +err: + kfree(d->br); + return -ENODEV; +} + +static int int3406_thermal_remove(struct platform_device *pdev) +{ + struct int3406_thermal_data *d = platform_get_drvdata(pdev); + + thermal_cooling_device_unregister(d->cooling_dev); + kfree(d->br); + return 0; +} + +static const struct acpi_device_id int3406_thermal_match[] = { + {"INT3406", 0}, + {} +}; + +MODULE_DEVICE_TABLE(acpi, int3406_thermal_match); + +static struct platform_driver int3406_thermal_driver = { + .probe = int3406_thermal_probe, + .remove = int3406_thermal_remove, + .driver = { + .name = "int3406 thermal", + .owner = THIS_MODULE, + .acpi_match_table = int3406_thermal_match, + }, +}; + +module_platform_driver(int3406_thermal_driver); + +MODULE_DESCRIPTION("INT3406 Thermal driver"); +MODULE_LICENSE("GPL v2"); -- cgit v0.10.2 From e4f35c1339f0cfcf38d3f63dd6fea2b070399263 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 12 May 2016 23:00:12 +0200 Subject: ACPI / video: mark acpi_video_get_levels() inline A recent patch added a stub function for acpi_video_get_levels when CONFIG_ACPI_VIDEO is disabled. However, this is marked as 'static' and causes a warning about an unused function whereever the header gets included: In file included from ../drivers/gpu/drm/radeon/radeon_acpi.c:28:0: include/acpi/video.h:74:12: error: 'acpi_video_get_levels' defined but not used [-Werror=unused-function] This makes the declaration 'static inline', which gets rid of the warning. Signed-off-by: Arnd Bergmann Fixes: 059500940def (ACPI/video: export acpi_video_get_levels) Signed-off-by: Rafael J. Wysocki diff --git a/include/acpi/video.h b/include/acpi/video.h index a4b96c9..70a41f7 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -71,7 +71,7 @@ static inline bool acpi_video_handles_brightness_key_presses(void) { return false; } -static int acpi_video_get_levels(struct acpi_device *device, +static inline int acpi_video_get_levels(struct acpi_device *device, struct acpi_video_device_brightness **dev_br) { return -ENODEV; -- cgit v0.10.2