Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'acpi-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
"These include a usual ACPICA code update (this time to upstream
revision 20170728), a fix for a boot crash on some systems with
Thunderbolt devices connected at boot time, a rework of the handling
of PCI bridges when setting up device wakeup, new support for Apple
device properties, support for DMA configurations reported via ACPI on
ARM64, APEI-related updates, ACPI EC driver updates and assorted minor
modifications in several places.

Specifics:

- Update the ACPICA code in the kernel to upstream revision 20170728
including:
* Alias operator handling update (Bob Moore).
* Deferred resolution of reference package elements (Bob Moore).
* Support for the _DMA method in walk resources (Bob Moore).
* Tables handling update and support for deferred table
verification (Lv Zheng).
* Update of SMMU models for IORT (Robin Murphy).
* Compiler and disassembler updates (Alex James, Erik Schmauss,
Ganapatrao Kulkarni, James Morse).
* Tools updates (Erik Schmauss, Lv Zheng).
* Assorted minor fixes and cleanups (Bob Moore, Kees Cook, Lv
Zheng, Shao Ming).

- Rework the initialization of non-wakeup GPEs with method handlers
in order to address a boot crash on some systems with Thunderbolt
devices connected at boot time where we miss an early hotplug event
due to a delay in GPE enabling (Rafael Wysocki).

- Rework the handling of PCI bridges when setting up ACPI-based
device wakeup in order to avoid disabling wakeup for bridges
prematurely (Rafael Wysocki).

- Consolidate Apple DMI checks throughout the tree, add support for
Apple device properties to the device properties framework and use
these properties for the handling of I2C and SPI devices on Apple
systems (Lukas Wunner).

- Add support for _DMA to the ACPI-based device properties lookup
code and make it possible to use the information from there to
configure DMA regions on ARM64 systems (Lorenzo Pieralisi).

- Fix several issues in the APEI code, add support for exporting the
BERT error region over sysfs and update APEI MAINTAINERS entry with
reviewers information (Borislav Petkov, Dongjiu Geng, Loc Ho, Punit
Agrawal, Tony Luck, Yazen Ghannam).

- Fix a potential initialization ordering issue in the ACPI EC driver
and clean it up somewhat (Lv Zheng).

- Update the ACPI SPCR driver to extend the existing XGENE 8250
workaround in it to a new platform (m400) and to work around an
Xgene UART clock issue (Graeme Gregory).

- Add a new utility function to the ACPI core to support using ACPI
OEM ID / OEM Table ID / Revision for system identification in
blacklisting or similar and switch over the existing code already
using this information to this new interface (Toshi Kani).

- Fix an xpower PMIC issue related to GPADC reads that always return
0 without extra pin manipulations (Hans de Goede).

- Add statements to print debug messages in a couple of places in the
ACPI core for easier diagnostics (Rafael Wysocki).

- Clean up the ACPI processor driver slightly (Colin Ian King, Hanjun
Guo).

- Clean up the ACPI x86 boot code somewhat (Andy Shevchenko).

- Add a quirk for Dell OptiPlex 9020M to the ACPI backlight driver
(Alex Hung).

- Assorted fixes, cleanups and updates related to ACPI (Amitoj Kaur
Chawla, Bhumika Goyal, Frank Rowand, Jean Delvare, Punit Agrawal,
Ronald Tschalär, Sumeet Pawnikar)"

* tag 'acpi-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (75 commits)
ACPI / APEI: Suppress message if HEST not present
intel_pstate: convert to use acpi_match_platform_list()
ACPI / blacklist: add acpi_match_platform_list()
ACPI, APEI, EINJ: Subtract any matching Register Region from Trigger resources
ACPI: make device_attribute const
ACPI / sysfs: Extend ACPI sysfs to provide access to boot error region
ACPI: APEI: fix the wrong iteration of generic error status block
ACPI / processor: make function acpi_processor_check_duplicates() static
ACPI / EC: Clean up EC GPE mask flag
ACPI: EC: Fix possible issues related to EC initialization order
ACPI / PM: Add debug statements to acpi_pm_notify_handler()
ACPI: Add debug statements to acpi_global_event_handler()
ACPI / scan: Enable GPEs before scanning the namespace
ACPICA: Make it possible to enable runtime GPEs earlier
ACPICA: Dispatch active GPEs at init time
ACPI: SPCR: work around clock issue on xgene UART
ACPI: SPCR: extend XGENE 8250 workaround to m400
ACPI / LPSS: Don't abort ACPI scan on missing mem resource
mailbox: pcc: Drop uninformative output during boot
ACPI/IORT: Add IORT named component memory address limits
...

+2439 -1046
+9
MAINTAINERS
··· 301 301 F: drivers/acpi/ 302 302 F: drivers/pnp/pnpacpi/ 303 303 F: include/linux/acpi.h 304 + F: include/linux/fwnode.h 304 305 F: include/acpi/ 305 306 F: Documentation/acpi/ 306 307 F: Documentation/ABI/testing/sysfs-bus-acpi ··· 310 309 F: drivers/pci/*/*acpi* 311 310 F: drivers/pci/*/*/*acpi* 312 311 F: tools/power/acpi/ 312 + 313 + ACPI APEI 314 + M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 315 + M: Len Brown <lenb@kernel.org> 316 + L: linux-acpi@vger.kernel.org 317 + R: Tony Luck <tony.luck@intel.com> 318 + R: Borislav Petkov <bp@alien8.de> 319 + F: drivers/acpi/apei/ 313 320 314 321 ACPI COMPONENT ARCHITECTURE (ACPICA) 315 322 M: Robert Moore <robert.moore@intel.com>
+2 -2
arch/arm64/kernel/acpi.c
··· 95 95 * __acpi_map_table() will be called before page_init(), so early_ioremap() 96 96 * or early_memremap() should be called here to for ACPI table mapping. 97 97 */ 98 - char *__init __acpi_map_table(unsigned long phys, unsigned long size) 98 + void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) 99 99 { 100 100 if (!size) 101 101 return NULL; ··· 103 103 return early_memremap(phys, size); 104 104 } 105 105 106 - void __init __acpi_unmap_table(char *map, unsigned long size) 106 + void __init __acpi_unmap_table(void __iomem *map, unsigned long size) 107 107 { 108 108 if (!map || !size) 109 109 return;
+3 -3
arch/ia64/kernel/acpi.c
··· 159 159 return vector; 160 160 } 161 161 162 - char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size) 162 + void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) 163 163 { 164 - return __va(phys_addr); 164 + return __va(phys); 165 165 } 166 166 167 - void __init __acpi_unmap_table(char *map, unsigned long size) 167 + void __init __acpi_unmap_table(void __iomem *map, unsigned long size) 168 168 { 169 169 } 170 170
+1
arch/x86/include/asm/setup.h
··· 39 39 #endif 40 40 41 41 void setup_bios_corruption_check(void); 42 + void early_platform_quirks(void); 42 43 43 44 extern unsigned long saved_video_mode; 44 45
+7 -4
arch/x86/kernel/acpi/boot.c
··· 118 118 * This is just a simple wrapper around early_memremap(), 119 119 * with sanity checks for phys == 0 and size == 0. 120 120 */ 121 - char *__init __acpi_map_table(unsigned long phys, unsigned long size) 121 + void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) 122 122 { 123 123 124 124 if (!phys || !size) ··· 127 127 return early_memremap(phys, size); 128 128 } 129 129 130 - void __init __acpi_unmap_table(char *map, unsigned long size) 130 + void __init __acpi_unmap_table(void __iomem *map, unsigned long size) 131 131 { 132 132 if (!map || !size) 133 133 return; ··· 199 199 acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) 200 200 { 201 201 struct acpi_madt_local_x2apic *processor = NULL; 202 + #ifdef CONFIG_X86_X2APIC 202 203 int apic_id; 203 204 u8 enabled; 205 + #endif 204 206 205 207 processor = (struct acpi_madt_local_x2apic *)header; 206 208 ··· 211 209 212 210 acpi_table_print_madt_entry(header); 213 211 212 + #ifdef CONFIG_X86_X2APIC 214 213 apic_id = processor->local_apic_id; 215 214 enabled = processor->lapic_flags & ACPI_MADT_ENABLED; 216 - #ifdef CONFIG_X86_X2APIC 215 + 217 216 /* 218 217 * We need to register disabled CPU as well to permit 219 218 * counting disabled CPUs. This allows us to size ··· 1086 1083 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; 1087 1084 #endif 1088 1085 set_bit(MP_ISA_BUS, mp_bus_not_pci); 1089 - pr_debug("Bus #%d is ISA\n", MP_ISA_BUS); 1086 + pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs()); 1090 1087 1091 1088 /* 1092 1089 * Use the default configuration for the IRQs 0-15. Unless
+2 -2
arch/x86/kernel/early-quirks.c
··· 12 12 #include <linux/pci.h> 13 13 #include <linux/acpi.h> 14 14 #include <linux/delay.h> 15 - #include <linux/dmi.h> 16 15 #include <linux/pci_ids.h> 17 16 #include <linux/bcma/bcma.h> 18 17 #include <linux/bcma/bcma_regs.h> 18 + #include <linux/platform_data/x86/apple.h> 19 19 #include <drm/i915_drm.h> 20 20 #include <asm/pci-direct.h> 21 21 #include <asm/dma.h> ··· 594 594 u64 addr; 595 595 int i; 596 596 597 - if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) 597 + if (!x86_apple_machine) 598 598 return; 599 599 600 600 /* Card may have been put into PCI_D3hot by grub quirk */
+10
arch/x86/kernel/quirks.c
··· 1 1 /* 2 2 * This file contains work-arounds for x86 and x86_64 platform bugs. 3 3 */ 4 + #include <linux/dmi.h> 4 5 #include <linux/pci.h> 5 6 #include <linux/irq.h> 6 7 ··· 657 656 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras_cap); 658 657 #endif 659 658 #endif 659 + 660 + bool x86_apple_machine; 661 + EXPORT_SYMBOL(x86_apple_machine); 662 + 663 + void __init early_platform_quirks(void) 664 + { 665 + x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") || 666 + dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc."); 667 + }
+2
arch/x86/kernel/setup.c
··· 1216 1216 1217 1217 io_delay_init(); 1218 1218 1219 + early_platform_quirks(); 1220 + 1219 1221 /* 1220 1222 * Parse the ACPI tables for possible boot-time SMP configuration. 1221 1223 */
+1
drivers/acpi/Makefile
··· 50 50 acpi-y += sysfs.o 51 51 acpi-y += property.o 52 52 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o 53 + acpi-$(CONFIG_X86) += x86/apple.o 53 54 acpi-$(CONFIG_X86) += x86/utils.o 54 55 acpi-$(CONFIG_DEBUG_FS) += debugfs.o 55 56 acpi-$(CONFIG_ACPI_NUMA) += numa.o
+3 -3
drivers/acpi/acpi_lpat.c
··· 25 25 * @raw: the raw value, used as a key to get the temerature from the 26 26 * above mapping table 27 27 * 28 - * A positive converted temperarure value will be returned on success, 28 + * A positive converted temperature value will be returned on success, 29 29 * a negative errno will be returned in error cases. 30 30 */ 31 31 int acpi_lpat_raw_to_temp(struct acpi_lpat_conversion_table *lpat_table, ··· 55 55 * acpi_lpat_temp_to_raw(): Return raw value from temperature through 56 56 * LPAT conversion table 57 57 * 58 - * @lpat: the temperature_raw mapping table 58 + * @lpat_table: the temperature_raw mapping table 59 59 * @temp: the temperature, used as a key to get the raw value from the 60 60 * above mapping table 61 61 * 62 - * A positive converted temperature value will be returned on success, 62 + * The raw value will be returned on success, 63 63 * a negative errno will be returned in error cases. 64 64 */ 65 65 int acpi_lpat_temp_to_raw(struct acpi_lpat_conversion_table *lpat_table,
+2 -1
drivers/acpi/acpi_lpss.c
··· 465 465 acpi_dev_free_resource_list(&resource_list); 466 466 467 467 if (!pdata->mmio_base) { 468 - ret = -ENOMEM; 468 + /* Skip the device, but continue the namespace scan. */ 469 + ret = 0; 469 470 goto err_out; 470 471 } 471 472
+1 -1
drivers/acpi/acpi_processor.c
··· 670 670 671 671 } 672 672 673 - void __init acpi_processor_check_duplicates(void) 673 + static void __init acpi_processor_check_duplicates(void) 674 674 { 675 675 /* check the correctness for all processors in ACPI namespace */ 676 676 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
+1
drivers/acpi/acpica/Makefile
··· 18 18 dsmthdat.o \ 19 19 dsobject.o \ 20 20 dsopcode.o \ 21 + dspkginit.o \ 21 22 dsutils.o \ 22 23 dswexec.o \ 23 24 dswload.o \
+2
drivers/acpi/acpica/acapps.h
··· 114 114 u8 get_only_aml_tables, 115 115 struct acpi_new_table_desc **return_list_head); 116 116 117 + void ac_delete_table_list(struct acpi_new_table_desc *list_head); 118 + 117 119 u8 ac_is_file_binary(FILE * file); 118 120 119 121 acpi_status ac_validate_table_header(FILE * file, long table_offset);
+13
drivers/acpi/acpica/acdispat.h
··· 237 237 * dsobject - Parser/Interpreter interface - object initialization and conversion 238 238 */ 239 239 acpi_status 240 + acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 241 + union acpi_parse_object *op, 242 + union acpi_operand_object **obj_desc_ptr); 243 + 244 + acpi_status 240 245 acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, 241 246 union acpi_parse_object *op, 242 247 u32 buffer_length, ··· 262 257 acpi_ds_create_node(struct acpi_walk_state *walk_state, 263 258 struct acpi_namespace_node *node, 264 259 union acpi_parse_object *op); 260 + 261 + /* 262 + * dspkginit - Package object initialization 263 + */ 264 + acpi_status 265 + acpi_ds_init_package_element(u8 object_type, 266 + union acpi_operand_object *source_object, 267 + union acpi_generic_state *state, void *context); 265 268 266 269 /* 267 270 * dsutils - Parser/Interpreter interface utility routines
+4 -3
drivers/acpi/acpica/aclocal.h
··· 199 199 #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ 200 200 #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ 201 201 202 + #define IMPLICIT_EXTERNAL 0x02 /* iASL only: This object created implicitly via External */ 202 203 #define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ 203 204 #define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ 204 205 #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ ··· 605 604 * Pkg state - used to traverse nested package structures 606 605 */ 607 606 struct acpi_pkg_state { 608 - ACPI_STATE_COMMON u16 index; 607 + ACPI_STATE_COMMON u32 index; 609 608 union acpi_operand_object *source_object; 610 609 union acpi_operand_object *dest_object; 611 610 struct acpi_walk_state *walk_state; ··· 868 867 869 868 /* This version is used by the iASL compiler only */ 870 869 871 - #define ACPI_MAX_PARSEOP_NAME 20 870 + #define ACPI_MAX_PARSEOP_NAME 20 872 871 873 872 struct acpi_parse_obj_asl { 874 873 ACPI_PARSE_COMMON union acpi_parse_object *child; ··· 908 907 struct asl_comment_state { 909 908 u8 comment_type; 910 909 u32 spaces_before; 911 - union acpi_parse_object *latest_parse_node; 910 + union acpi_parse_object *latest_parse_op; 912 911 union acpi_parse_object *parsing_paren_brace_node; 913 912 u8 capture_comments; 914 913 };
+11 -4
drivers/acpi/acpica/acobject.h
··· 122 122 _type *pointer; \ 123 123 u32 length; 124 124 125 - struct acpi_object_string { /* Null terminated, ASCII characters only */ 125 + /* Null terminated, ASCII characters only */ 126 + 127 + struct acpi_object_string { 126 128 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(char) /* String in AML stream or allocated string */ 127 129 }; 128 130 ··· 213 211 union acpi_operand_object *notify_list[2]; /* Handlers for system/device notifies */\ 214 212 union acpi_operand_object *handler; /* Handler for Address space */ 215 213 216 - struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ 214 + /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ 215 + 216 + struct acpi_object_notify_common { 217 217 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO}; 218 218 219 219 struct acpi_object_device { ··· 262 258 u8 access_length; /* For serial regions/fields */ 263 259 264 260 265 - struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ 261 + /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ 262 + 263 + struct acpi_object_field_common { 266 264 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Parent Operation Region object (REGION/BANK fields only) */ 267 265 }; 268 266 ··· 339 333 struct acpi_object_reference { 340 334 ACPI_OBJECT_COMMON_HEADER u8 class; /* Reference Class */ 341 335 u8 target_type; /* Used for Index Op */ 342 - u8 reserved; 336 + u8 resolved; /* Reference has been resolved to a value */ 343 337 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */ 344 338 struct acpi_namespace_node *node; /* ref_of or Namepath */ 345 339 union acpi_operand_object **where; /* Target of Index */ 346 340 u8 *index_pointer; /* Used for Buffers and Strings */ 341 + u8 *aml; /* Used for deferred resolution of the ref */ 347 342 u32 value; /* Used for Local/Arg/Index/ddb_handle */ 348 343 }; 349 344
+4 -1
drivers/acpi/acpica/actables.h
··· 76 76 acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc); 77 77 78 78 acpi_status 79 - acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature); 79 + acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, 80 + char *signature, u32 *table_index); 80 81 81 82 u8 acpi_tb_is_table_loaded(u32 table_index); 82 83 ··· 132 131 u8 flags, u8 override, u32 *table_index); 133 132 134 133 acpi_status acpi_tb_unload_table(u32 table_index); 134 + 135 + void acpi_tb_notify_table(u32 event, void *table); 135 136 136 137 void acpi_tb_terminate(void); 137 138
+8 -1
drivers/acpi/acpica/acutils.h
··· 516 516 517 517 union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, 518 518 void *external_object, 519 - u16 index); 519 + u32 index); 520 520 521 521 acpi_status 522 522 acpi_ut_create_update_state_and_push(union acpi_operand_object *object, ··· 537 537 acpi_status 538 538 acpi_ut_short_divide(u64 in_dividend, 539 539 u32 divisor, u64 *out_quotient, u32 *out_remainder); 540 + 541 + acpi_status 542 + acpi_ut_short_multiply(u64 in_multiplicand, u32 multiplier, u64 *outproduct); 543 + 544 + acpi_status acpi_ut_short_shift_left(u64 operand, u32 count, u64 *out_result); 545 + 546 + acpi_status acpi_ut_short_shift_right(u64 operand, u32 count, u64 *out_result); 540 547 541 548 /* 542 549 * utmisc
+32 -5
drivers/acpi/acpica/dbdisply.c
··· 310 310 } 311 311 312 312 else { 313 - acpi_os_printf("Object (%p) Pathname: %s\n", 313 + acpi_os_printf("Object %p: Namespace Node - Pathname: %s\n", 314 314 node, (char *)ret_buf.pointer); 315 315 } 316 316 ··· 326 326 327 327 obj_desc = acpi_ns_get_attached_object(node); 328 328 if (obj_desc) { 329 - acpi_os_printf("\nAttached Object (%p):\n", obj_desc); 329 + acpi_os_printf("\nAttached Object %p:", obj_desc); 330 330 if (!acpi_os_readable 331 331 (obj_desc, sizeof(union acpi_operand_object))) { 332 332 acpi_os_printf ··· 335 335 return; 336 336 } 337 337 338 - acpi_ut_debug_dump_buffer((void *)obj_desc, 339 - sizeof(union acpi_operand_object), 340 - display, ACPI_UINT32_MAX); 338 + if (ACPI_GET_DESCRIPTOR_TYPE(((struct acpi_namespace_node *) 339 + obj_desc)) == 340 + ACPI_DESC_TYPE_NAMED) { 341 + acpi_os_printf(" Namespace Node - "); 342 + status = 343 + acpi_get_name((struct acpi_namespace_node *) 344 + obj_desc, 345 + ACPI_FULL_PATHNAME_NO_TRAILING, 346 + &ret_buf); 347 + if (ACPI_FAILURE(status)) { 348 + acpi_os_printf 349 + ("Could not convert name to pathname\n"); 350 + } else { 351 + acpi_os_printf("Pathname: %s", 352 + (char *)ret_buf.pointer); 353 + } 354 + 355 + acpi_os_printf("\n"); 356 + acpi_ut_debug_dump_buffer((void *)obj_desc, 357 + sizeof(struct 358 + acpi_namespace_node), 359 + display, ACPI_UINT32_MAX); 360 + } else { 361 + acpi_os_printf("\n"); 362 + acpi_ut_debug_dump_buffer((void *)obj_desc, 363 + sizeof(union 364 + acpi_operand_object), 365 + display, ACPI_UINT32_MAX); 366 + } 367 + 341 368 acpi_ex_dump_object_descriptor(obj_desc, 1); 342 369 } 343 370 }
+2
drivers/acpi/acpica/dsfield.c
··· 184 184 /* Execute flag should always be set when this function is entered */ 185 185 186 186 if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) { 187 + ACPI_ERROR((AE_INFO, "Parse execute mode is not set")); 187 188 return_ACPI_STATUS(AE_AML_INTERNAL); 188 189 } 189 190 ··· 557 556 return_ACPI_STATUS(AE_OK); 558 557 } 559 558 559 + ACPI_ERROR((AE_INFO, "Parse deferred mode is not set")); 560 560 return_ACPI_STATUS(AE_AML_INTERNAL); 561 561 } 562 562
+66 -330
drivers/acpi/acpica/dsobject.c
··· 52 52 #define _COMPONENT ACPI_DISPATCHER 53 53 ACPI_MODULE_NAME("dsobject") 54 54 55 - /* Local prototypes */ 56 - static acpi_status 57 - acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 58 - union acpi_parse_object *op, 59 - union acpi_operand_object **obj_desc_ptr); 60 - 61 55 #ifndef ACPI_NO_METHOD_EXECUTION 62 56 /******************************************************************************* 63 57 * ··· 67 73 * Simple objects are any objects other than a package object! 68 74 * 69 75 ******************************************************************************/ 70 - 71 - static acpi_status 76 + acpi_status 72 77 acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 73 78 union acpi_parse_object *op, 74 79 union acpi_operand_object **obj_desc_ptr) 75 80 { 76 81 union acpi_operand_object *obj_desc; 77 82 acpi_status status; 78 - acpi_object_type type; 79 83 80 84 ACPI_FUNCTION_TRACE(ds_build_internal_object); 81 85 ··· 81 89 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 82 90 /* 83 91 * This is a named object reference. If this name was 84 - * previously looked up in the namespace, it was stored in this op. 85 - * Otherwise, go ahead and look it up now 92 + * previously looked up in the namespace, it was stored in 93 + * this op. Otherwise, go ahead and look it up now 86 94 */ 87 95 if (!op->common.node) { 88 - status = acpi_ns_lookup(walk_state->scope_info, 89 - op->common.value.string, 90 - ACPI_TYPE_ANY, 91 - ACPI_IMODE_EXECUTE, 92 - ACPI_NS_SEARCH_PARENT | 93 - ACPI_NS_DONT_OPEN_SCOPE, NULL, 94 - ACPI_CAST_INDIRECT_PTR(struct 95 - acpi_namespace_node, 96 - &(op-> 97 - common. 98 - node))); 99 - if (ACPI_FAILURE(status)) { 100 96 101 - /* Check if we are resolving a named reference within a package */ 97 + /* Check if we are resolving a named reference within a package */ 102 98 103 - if ((status == AE_NOT_FOUND) 104 - && (acpi_gbl_enable_interpreter_slack) 105 - && 106 - ((op->common.parent->common.aml_opcode == 107 - AML_PACKAGE_OP) 108 - || (op->common.parent->common.aml_opcode == 109 - AML_VARIABLE_PACKAGE_OP))) { 110 - /* 111 - * We didn't find the target and we are populating elements 112 - * of a package - ignore if slack enabled. Some ASL code 113 - * contains dangling invalid references in packages and 114 - * expects that no exception will be issued. Leave the 115 - * element as a null element. It cannot be used, but it 116 - * can be overwritten by subsequent ASL code - this is 117 - * typically the case. 118 - */ 119 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 120 - "Ignoring unresolved reference in package [%4.4s]\n", 121 - walk_state-> 122 - scope_info->scope. 123 - node->name.ascii)); 124 - 125 - return_ACPI_STATUS(AE_OK); 126 - } else { 99 + if ((op->common.parent->common.aml_opcode == 100 + AML_PACKAGE_OP) 101 + || (op->common.parent->common.aml_opcode == 102 + AML_VARIABLE_PACKAGE_OP)) { 103 + /* 104 + * We won't resolve package elements here, we will do this 105 + * after all ACPI tables are loaded into the namespace. This 106 + * behavior supports both forward references to named objects 107 + * and external references to objects in other tables. 108 + */ 109 + goto create_new_object; 110 + } else { 111 + status = acpi_ns_lookup(walk_state->scope_info, 112 + op->common.value.string, 113 + ACPI_TYPE_ANY, 114 + ACPI_IMODE_EXECUTE, 115 + ACPI_NS_SEARCH_PARENT | 116 + ACPI_NS_DONT_OPEN_SCOPE, 117 + NULL, 118 + ACPI_CAST_INDIRECT_PTR 119 + (struct 120 + acpi_namespace_node, 121 + &(op->common.node))); 122 + if (ACPI_FAILURE(status)) { 127 123 ACPI_ERROR_NAMESPACE(op->common.value. 128 124 string, status); 125 + return_ACPI_STATUS(status); 129 126 } 130 - 131 - return_ACPI_STATUS(status); 132 - } 133 - } 134 - 135 - /* Special object resolution for elements of a package */ 136 - 137 - if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || 138 - (op->common.parent->common.aml_opcode == 139 - AML_VARIABLE_PACKAGE_OP)) { 140 - /* 141 - * Attempt to resolve the node to a value before we insert it into 142 - * the package. If this is a reference to a common data type, 143 - * resolve it immediately. According to the ACPI spec, package 144 - * elements can only be "data objects" or method references. 145 - * Attempt to resolve to an Integer, Buffer, String or Package. 146 - * If cannot, return the named reference (for things like Devices, 147 - * Methods, etc.) Buffer Fields and Fields will resolve to simple 148 - * objects (int/buf/str/pkg). 149 - * 150 - * NOTE: References to things like Devices, Methods, Mutexes, etc. 151 - * will remain as named references. This behavior is not described 152 - * in the ACPI spec, but it appears to be an oversight. 153 - */ 154 - obj_desc = 155 - ACPI_CAST_PTR(union acpi_operand_object, 156 - op->common.node); 157 - 158 - status = 159 - acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR 160 - (struct 161 - acpi_namespace_node, 162 - &obj_desc), 163 - walk_state); 164 - if (ACPI_FAILURE(status)) { 165 - return_ACPI_STATUS(status); 166 - } 167 - 168 - /* 169 - * Special handling for Alias objects. We need to setup the type 170 - * and the Op->Common.Node to point to the Alias target. Note, 171 - * Alias has at most one level of indirection internally. 172 - */ 173 - type = op->common.node->type; 174 - if (type == ACPI_TYPE_LOCAL_ALIAS) { 175 - type = obj_desc->common.type; 176 - op->common.node = 177 - ACPI_CAST_PTR(struct acpi_namespace_node, 178 - op->common.node->object); 179 - } 180 - 181 - switch (type) { 182 - /* 183 - * For these types, we need the actual node, not the subobject. 184 - * However, the subobject did not get an extra reference count above. 185 - * 186 - * TBD: should ex_resolve_node_to_value be changed to fix this? 187 - */ 188 - case ACPI_TYPE_DEVICE: 189 - case ACPI_TYPE_THERMAL: 190 - 191 - acpi_ut_add_reference(op->common.node->object); 192 - 193 - /*lint -fallthrough */ 194 - /* 195 - * For these types, we need the actual node, not the subobject. 196 - * The subobject got an extra reference count in ex_resolve_node_to_value. 197 - */ 198 - case ACPI_TYPE_MUTEX: 199 - case ACPI_TYPE_METHOD: 200 - case ACPI_TYPE_POWER: 201 - case ACPI_TYPE_PROCESSOR: 202 - case ACPI_TYPE_EVENT: 203 - case ACPI_TYPE_REGION: 204 - 205 - /* We will create a reference object for these types below */ 206 - break; 207 - 208 - default: 209 - /* 210 - * All other types - the node was resolved to an actual 211 - * object, we are done. 212 - */ 213 - goto exit; 214 127 } 215 128 } 216 129 } 130 + 131 + create_new_object: 217 132 218 133 /* Create and init a new internal ACPI object */ 219 134 ··· 139 240 return_ACPI_STATUS(status); 140 241 } 141 242 142 - exit: 243 + /* 244 + * Handling for unresolved package reference elements. 245 + * These are elements that are namepaths. 246 + */ 247 + if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || 248 + (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) { 249 + obj_desc->reference.resolved = TRUE; 250 + 251 + if ((op->common.aml_opcode == AML_INT_NAMEPATH_OP) && 252 + !obj_desc->reference.node) { 253 + /* 254 + * Name was unresolved above. 255 + * Get the prefix node for later lookup 256 + */ 257 + obj_desc->reference.node = 258 + walk_state->scope_info->scope.node; 259 + obj_desc->reference.aml = op->common.aml; 260 + obj_desc->reference.resolved = FALSE; 261 + } 262 + } 263 + 143 264 *obj_desc_ptr = obj_desc; 144 265 return_ACPI_STATUS(status); 145 266 } ··· 266 347 obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; 267 348 op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); 268 349 return_ACPI_STATUS(AE_OK); 269 - } 270 - 271 - /******************************************************************************* 272 - * 273 - * FUNCTION: acpi_ds_build_internal_package_obj 274 - * 275 - * PARAMETERS: walk_state - Current walk state 276 - * op - Parser object to be translated 277 - * element_count - Number of elements in the package - this is 278 - * the num_elements argument to Package() 279 - * obj_desc_ptr - Where the ACPI internal object is returned 280 - * 281 - * RETURN: Status 282 - * 283 - * DESCRIPTION: Translate a parser Op package object to the equivalent 284 - * namespace object 285 - * 286 - * NOTE: The number of elements in the package will be always be the num_elements 287 - * count, regardless of the number of elements in the package list. If 288 - * num_elements is smaller, only that many package list elements are used. 289 - * if num_elements is larger, the Package object is padded out with 290 - * objects of type Uninitialized (as per ACPI spec.) 291 - * 292 - * Even though the ASL compilers do not allow num_elements to be smaller 293 - * than the Package list length (for the fixed length package opcode), some 294 - * BIOS code modifies the AML on the fly to adjust the num_elements, and 295 - * this code compensates for that. This also provides compatibility with 296 - * other AML interpreters. 297 - * 298 - ******************************************************************************/ 299 - 300 - acpi_status 301 - acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, 302 - union acpi_parse_object *op, 303 - u32 element_count, 304 - union acpi_operand_object **obj_desc_ptr) 305 - { 306 - union acpi_parse_object *arg; 307 - union acpi_parse_object *parent; 308 - union acpi_operand_object *obj_desc = NULL; 309 - acpi_status status = AE_OK; 310 - u32 i; 311 - u16 index; 312 - u16 reference_count; 313 - 314 - ACPI_FUNCTION_TRACE(ds_build_internal_package_obj); 315 - 316 - /* Find the parent of a possibly nested package */ 317 - 318 - parent = op->common.parent; 319 - while ((parent->common.aml_opcode == AML_PACKAGE_OP) || 320 - (parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) { 321 - parent = parent->common.parent; 322 - } 323 - 324 - /* 325 - * If we are evaluating a Named package object "Name (xxxx, Package)", 326 - * the package object already exists, otherwise it must be created. 327 - */ 328 - obj_desc = *obj_desc_ptr; 329 - if (!obj_desc) { 330 - obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); 331 - *obj_desc_ptr = obj_desc; 332 - if (!obj_desc) { 333 - return_ACPI_STATUS(AE_NO_MEMORY); 334 - } 335 - 336 - obj_desc->package.node = parent->common.node; 337 - } 338 - 339 - /* 340 - * Allocate the element array (array of pointers to the individual 341 - * objects) based on the num_elements parameter. Add an extra pointer slot 342 - * so that the list is always null terminated. 343 - */ 344 - obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) 345 - element_count + 346 - 1) * sizeof(void *)); 347 - 348 - if (!obj_desc->package.elements) { 349 - acpi_ut_delete_object_desc(obj_desc); 350 - return_ACPI_STATUS(AE_NO_MEMORY); 351 - } 352 - 353 - obj_desc->package.count = element_count; 354 - 355 - /* 356 - * Initialize the elements of the package, up to the num_elements count. 357 - * Package is automatically padded with uninitialized (NULL) elements 358 - * if num_elements is greater than the package list length. Likewise, 359 - * Package is truncated if num_elements is less than the list length. 360 - */ 361 - arg = op->common.value.arg; 362 - arg = arg->common.next; 363 - for (i = 0; arg && (i < element_count); i++) { 364 - if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 365 - if (arg->common.node->type == ACPI_TYPE_METHOD) { 366 - /* 367 - * A method reference "looks" to the parser to be a method 368 - * invocation, so we special case it here 369 - */ 370 - arg->common.aml_opcode = AML_INT_NAMEPATH_OP; 371 - status = 372 - acpi_ds_build_internal_object(walk_state, 373 - arg, 374 - &obj_desc-> 375 - package. 376 - elements[i]); 377 - } else { 378 - /* This package element is already built, just get it */ 379 - 380 - obj_desc->package.elements[i] = 381 - ACPI_CAST_PTR(union acpi_operand_object, 382 - arg->common.node); 383 - } 384 - } else { 385 - status = 386 - acpi_ds_build_internal_object(walk_state, arg, 387 - &obj_desc->package. 388 - elements[i]); 389 - } 390 - 391 - if (*obj_desc_ptr) { 392 - 393 - /* Existing package, get existing reference count */ 394 - 395 - reference_count = 396 - (*obj_desc_ptr)->common.reference_count; 397 - if (reference_count > 1) { 398 - 399 - /* Make new element ref count match original ref count */ 400 - 401 - for (index = 0; index < (reference_count - 1); 402 - index++) { 403 - acpi_ut_add_reference((obj_desc-> 404 - package. 405 - elements[i])); 406 - } 407 - } 408 - } 409 - 410 - arg = arg->common.next; 411 - } 412 - 413 - /* Check for match between num_elements and actual length of package_list */ 414 - 415 - if (arg) { 416 - /* 417 - * num_elements was exhausted, but there are remaining elements in the 418 - * package_list. Truncate the package to num_elements. 419 - * 420 - * Note: technically, this is an error, from ACPI spec: "It is an error 421 - * for NumElements to be less than the number of elements in the 422 - * PackageList". However, we just print a message and 423 - * no exception is returned. This provides Windows compatibility. Some 424 - * BIOSs will alter the num_elements on the fly, creating this type 425 - * of ill-formed package object. 426 - */ 427 - while (arg) { 428 - /* 429 - * We must delete any package elements that were created earlier 430 - * and are not going to be used because of the package truncation. 431 - */ 432 - if (arg->common.node) { 433 - acpi_ut_remove_reference(ACPI_CAST_PTR 434 - (union 435 - acpi_operand_object, 436 - arg->common.node)); 437 - arg->common.node = NULL; 438 - } 439 - 440 - /* Find out how many elements there really are */ 441 - 442 - i++; 443 - arg = arg->common.next; 444 - } 445 - 446 - ACPI_INFO(("Actual Package length (%u) is larger than " 447 - "NumElements field (%u), truncated", 448 - i, element_count)); 449 - } else if (i < element_count) { 450 - /* 451 - * Arg list (elements) was exhausted, but we did not reach num_elements count. 452 - * Note: this is not an error, the package is padded out with NULLs. 453 - */ 454 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 455 - "Package List length (%u) smaller than NumElements " 456 - "count (%u), padded with null elements\n", 457 - i, element_count)); 458 - } 459 - 460 - obj_desc->package.flags |= AOPOBJ_DATA_VALID; 461 - op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); 462 - return_ACPI_STATUS(status); 463 350 } 464 351 465 352 /******************************************************************************* ··· 387 662 388 663 case ACPI_TYPE_PACKAGE: 389 664 /* 390 - * Defer evaluation of Package term_arg operand 665 + * Defer evaluation of Package term_arg operand and all 666 + * package elements. (01/2017): We defer the element 667 + * resolution to allow forward references from the package 668 + * in order to provide compatibility with other ACPI 669 + * implementations. 391 670 */ 392 671 obj_desc->package.node = 393 672 ACPI_CAST_PTR(struct acpi_namespace_node, 394 673 walk_state->operands[0]); 674 + 675 + if (!op->named.data) { 676 + return_ACPI_STATUS(AE_OK); 677 + } 678 + 395 679 obj_desc->package.aml_start = op->named.data; 396 680 obj_desc->package.aml_length = op->named.length; 397 681 break; ··· 552 818 /* Node was saved in Op */ 553 819 554 820 obj_desc->reference.node = op->common.node; 555 - obj_desc->reference.object = 556 - op->common.node->object; 557 821 obj_desc->reference.class = ACPI_REFCLASS_NAME; 822 + if (op->common.node) { 823 + obj_desc->reference.object = 824 + op->common.node->object; 825 + } 558 826 break; 559 827 560 828 case AML_DEBUG_OP:
+9
drivers/acpi/acpica/dsopcode.c
··· 599 599 */ 600 600 walk_state->operand_index = walk_state->num_operands; 601 601 602 + /* Ignore if child is not valid */ 603 + 604 + if (!op->common.value.arg) { 605 + ACPI_ERROR((AE_INFO, 606 + "Dispatch: Missing child while executing TermArg for %X", 607 + op->common.aml_opcode)); 608 + return_ACPI_STATUS(AE_OK); 609 + } 610 + 602 611 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); 603 612 if (ACPI_FAILURE(status)) { 604 613 return_ACPI_STATUS(status);
+496
drivers/acpi/acpica/dspkginit.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: dspkginit - Completion of deferred package initialization 4 + * 5 + *****************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2017, Intel Corp. 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include "accommon.h" 46 + #include "acnamesp.h" 47 + #include "amlcode.h" 48 + #include "acdispat.h" 49 + #include "acinterp.h" 50 + 51 + #define _COMPONENT ACPI_NAMESPACE 52 + ACPI_MODULE_NAME("dspkginit") 53 + 54 + /* Local prototypes */ 55 + static void 56 + acpi_ds_resolve_package_element(union acpi_operand_object **element); 57 + 58 + /******************************************************************************* 59 + * 60 + * FUNCTION: acpi_ds_build_internal_package_obj 61 + * 62 + * PARAMETERS: walk_state - Current walk state 63 + * op - Parser object to be translated 64 + * element_count - Number of elements in the package - this is 65 + * the num_elements argument to Package() 66 + * obj_desc_ptr - Where the ACPI internal object is returned 67 + * 68 + * RETURN: Status 69 + * 70 + * DESCRIPTION: Translate a parser Op package object to the equivalent 71 + * namespace object 72 + * 73 + * NOTE: The number of elements in the package will be always be the num_elements 74 + * count, regardless of the number of elements in the package list. If 75 + * num_elements is smaller, only that many package list elements are used. 76 + * if num_elements is larger, the Package object is padded out with 77 + * objects of type Uninitialized (as per ACPI spec.) 78 + * 79 + * Even though the ASL compilers do not allow num_elements to be smaller 80 + * than the Package list length (for the fixed length package opcode), some 81 + * BIOS code modifies the AML on the fly to adjust the num_elements, and 82 + * this code compensates for that. This also provides compatibility with 83 + * other AML interpreters. 84 + * 85 + ******************************************************************************/ 86 + 87 + acpi_status 88 + acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, 89 + union acpi_parse_object *op, 90 + u32 element_count, 91 + union acpi_operand_object **obj_desc_ptr) 92 + { 93 + union acpi_parse_object *arg; 94 + union acpi_parse_object *parent; 95 + union acpi_operand_object *obj_desc = NULL; 96 + acpi_status status = AE_OK; 97 + u16 reference_count; 98 + u32 index; 99 + u32 i; 100 + 101 + ACPI_FUNCTION_TRACE(ds_build_internal_package_obj); 102 + 103 + /* Find the parent of a possibly nested package */ 104 + 105 + parent = op->common.parent; 106 + while ((parent->common.aml_opcode == AML_PACKAGE_OP) || 107 + (parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) { 108 + parent = parent->common.parent; 109 + } 110 + 111 + /* 112 + * If we are evaluating a Named package object of the form: 113 + * Name (xxxx, Package) 114 + * the package object already exists, otherwise it must be created. 115 + */ 116 + obj_desc = *obj_desc_ptr; 117 + if (!obj_desc) { 118 + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); 119 + *obj_desc_ptr = obj_desc; 120 + if (!obj_desc) { 121 + return_ACPI_STATUS(AE_NO_MEMORY); 122 + } 123 + 124 + obj_desc->package.node = parent->common.node; 125 + } 126 + 127 + if (obj_desc->package.flags & AOPOBJ_DATA_VALID) { /* Just in case */ 128 + return_ACPI_STATUS(AE_OK); 129 + } 130 + 131 + /* 132 + * Allocate the element array (array of pointers to the individual 133 + * objects) based on the num_elements parameter. Add an extra pointer slot 134 + * so that the list is always null terminated. 135 + */ 136 + obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) 137 + element_count + 138 + 1) * sizeof(void *)); 139 + 140 + if (!obj_desc->package.elements) { 141 + acpi_ut_delete_object_desc(obj_desc); 142 + return_ACPI_STATUS(AE_NO_MEMORY); 143 + } 144 + 145 + obj_desc->package.count = element_count; 146 + arg = op->common.value.arg; 147 + arg = arg->common.next; 148 + 149 + if (arg) { 150 + obj_desc->package.flags |= AOPOBJ_DATA_VALID; 151 + } 152 + 153 + /* 154 + * Initialize the elements of the package, up to the num_elements count. 155 + * Package is automatically padded with uninitialized (NULL) elements 156 + * if num_elements is greater than the package list length. Likewise, 157 + * Package is truncated if num_elements is less than the list length. 158 + */ 159 + for (i = 0; arg && (i < element_count); i++) { 160 + if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 161 + if (arg->common.node->type == ACPI_TYPE_METHOD) { 162 + /* 163 + * A method reference "looks" to the parser to be a method 164 + * invocation, so we special case it here 165 + */ 166 + arg->common.aml_opcode = AML_INT_NAMEPATH_OP; 167 + status = 168 + acpi_ds_build_internal_object(walk_state, 169 + arg, 170 + &obj_desc-> 171 + package. 172 + elements[i]); 173 + } else { 174 + /* This package element is already built, just get it */ 175 + 176 + obj_desc->package.elements[i] = 177 + ACPI_CAST_PTR(union acpi_operand_object, 178 + arg->common.node); 179 + } 180 + } else { 181 + status = 182 + acpi_ds_build_internal_object(walk_state, arg, 183 + &obj_desc->package. 184 + elements[i]); 185 + if (status == AE_NOT_FOUND) { 186 + ACPI_ERROR((AE_INFO, "%-48s", 187 + "****DS namepath not found")); 188 + } 189 + 190 + /* 191 + * Initialize this package element. This function handles the 192 + * resolution of named references within the package. 193 + */ 194 + acpi_ds_init_package_element(0, 195 + obj_desc->package. 196 + elements[i], NULL, 197 + &obj_desc->package. 198 + elements[i]); 199 + } 200 + 201 + if (*obj_desc_ptr) { 202 + 203 + /* Existing package, get existing reference count */ 204 + 205 + reference_count = 206 + (*obj_desc_ptr)->common.reference_count; 207 + if (reference_count > 1) { 208 + 209 + /* Make new element ref count match original ref count */ 210 + /* TBD: Probably need an acpi_ut_add_references function */ 211 + 212 + for (index = 0; 213 + index < ((u32)reference_count - 1); 214 + index++) { 215 + acpi_ut_add_reference((obj_desc-> 216 + package. 217 + elements[i])); 218 + } 219 + } 220 + } 221 + 222 + arg = arg->common.next; 223 + } 224 + 225 + /* Check for match between num_elements and actual length of package_list */ 226 + 227 + if (arg) { 228 + /* 229 + * num_elements was exhausted, but there are remaining elements in 230 + * the package_list. Truncate the package to num_elements. 231 + * 232 + * Note: technically, this is an error, from ACPI spec: "It is an 233 + * error for NumElements to be less than the number of elements in 234 + * the PackageList". However, we just print a message and no 235 + * exception is returned. This provides compatibility with other 236 + * ACPI implementations. Some firmware implementations will alter 237 + * the num_elements on the fly, possibly creating this type of 238 + * ill-formed package object. 239 + */ 240 + while (arg) { 241 + /* 242 + * We must delete any package elements that were created earlier 243 + * and are not going to be used because of the package truncation. 244 + */ 245 + if (arg->common.node) { 246 + acpi_ut_remove_reference(ACPI_CAST_PTR 247 + (union 248 + acpi_operand_object, 249 + arg->common.node)); 250 + arg->common.node = NULL; 251 + } 252 + 253 + /* Find out how many elements there really are */ 254 + 255 + i++; 256 + arg = arg->common.next; 257 + } 258 + 259 + ACPI_INFO(("Actual Package length (%u) is larger than " 260 + "NumElements field (%u), truncated", 261 + i, element_count)); 262 + } else if (i < element_count) { 263 + /* 264 + * Arg list (elements) was exhausted, but we did not reach 265 + * num_elements count. 266 + * 267 + * Note: this is not an error, the package is padded out 268 + * with NULLs. 269 + */ 270 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, 271 + "Package List length (%u) smaller than NumElements " 272 + "count (%u), padded with null elements\n", 273 + i, element_count)); 274 + } 275 + 276 + obj_desc->package.flags |= AOPOBJ_DATA_VALID; 277 + op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); 278 + return_ACPI_STATUS(status); 279 + } 280 + 281 + /******************************************************************************* 282 + * 283 + * FUNCTION: acpi_ds_init_package_element 284 + * 285 + * PARAMETERS: acpi_pkg_callback 286 + * 287 + * RETURN: Status 288 + * 289 + * DESCRIPTION: Resolve a named reference element within a package object 290 + * 291 + ******************************************************************************/ 292 + 293 + acpi_status 294 + acpi_ds_init_package_element(u8 object_type, 295 + union acpi_operand_object *source_object, 296 + union acpi_generic_state *state, void *context) 297 + { 298 + union acpi_operand_object **element_ptr; 299 + 300 + if (!source_object) { 301 + return (AE_OK); 302 + } 303 + 304 + /* 305 + * The following code is a bit of a hack to workaround a (current) 306 + * limitation of the acpi_pkg_callback interface. We need a pointer 307 + * to the location within the element array because a new object 308 + * may be created and stored there. 309 + */ 310 + if (context) { 311 + 312 + /* A direct call was made to this function */ 313 + 314 + element_ptr = (union acpi_operand_object **)context; 315 + } else { 316 + /* Call came from acpi_ut_walk_package_tree */ 317 + 318 + element_ptr = state->pkg.this_target_obj; 319 + } 320 + 321 + /* We are only interested in reference objects/elements */ 322 + 323 + if (source_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 324 + 325 + /* Attempt to resolve the (named) reference to a namespace node */ 326 + 327 + acpi_ds_resolve_package_element(element_ptr); 328 + } else if (source_object->common.type == ACPI_TYPE_PACKAGE) { 329 + source_object->package.flags |= AOPOBJ_DATA_VALID; 330 + } 331 + 332 + return (AE_OK); 333 + } 334 + 335 + /******************************************************************************* 336 + * 337 + * FUNCTION: acpi_ds_resolve_package_element 338 + * 339 + * PARAMETERS: element_ptr - Pointer to a reference object 340 + * 341 + * RETURN: Possible new element is stored to the indirect element_ptr 342 + * 343 + * DESCRIPTION: Resolve a package element that is a reference to a named 344 + * object. 345 + * 346 + ******************************************************************************/ 347 + 348 + static void 349 + acpi_ds_resolve_package_element(union acpi_operand_object **element_ptr) 350 + { 351 + acpi_status status; 352 + union acpi_generic_state scope_info; 353 + union acpi_operand_object *element = *element_ptr; 354 + struct acpi_namespace_node *resolved_node; 355 + char *external_path = NULL; 356 + acpi_object_type type; 357 + 358 + ACPI_FUNCTION_TRACE(ds_resolve_package_element); 359 + 360 + /* Check if reference element is already resolved */ 361 + 362 + if (element->reference.resolved) { 363 + return_VOID; 364 + } 365 + 366 + /* Element must be a reference object of correct type */ 367 + 368 + scope_info.scope.node = element->reference.node; /* Prefix node */ 369 + 370 + status = acpi_ns_lookup(&scope_info, (char *)element->reference.aml, /* Pointer to AML path */ 371 + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 372 + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 373 + NULL, &resolved_node); 374 + if (ACPI_FAILURE(status)) { 375 + status = acpi_ns_externalize_name(ACPI_UINT32_MAX, 376 + (char *)element->reference. 377 + aml, NULL, &external_path); 378 + 379 + ACPI_EXCEPTION((AE_INFO, status, 380 + "Could not find/resolve named package element: %s", 381 + external_path)); 382 + 383 + ACPI_FREE(external_path); 384 + *element_ptr = NULL; 385 + return_VOID; 386 + } else if (resolved_node->type == ACPI_TYPE_ANY) { 387 + 388 + /* Named reference not resolved, return a NULL package element */ 389 + 390 + ACPI_ERROR((AE_INFO, 391 + "Could not resolve named package element [%4.4s] in [%4.4s]", 392 + resolved_node->name.ascii, 393 + scope_info.scope.node->name.ascii)); 394 + *element_ptr = NULL; 395 + return_VOID; 396 + } 397 + #if 0 398 + else if (resolved_node->flags & ANOBJ_TEMPORARY) { 399 + /* 400 + * A temporary node found here indicates that the reference is 401 + * to a node that was created within this method. We are not 402 + * going to allow it (especially if the package is returned 403 + * from the method) -- the temporary node will be deleted out 404 + * from under the method. (05/2017). 405 + */ 406 + ACPI_ERROR((AE_INFO, 407 + "Package element refers to a temporary name [%4.4s], " 408 + "inserting a NULL element", 409 + resolved_node->name.ascii)); 410 + *element_ptr = NULL; 411 + return_VOID; 412 + } 413 + #endif 414 + 415 + /* 416 + * Special handling for Alias objects. We need resolved_node to point 417 + * to the Alias target. This effectively "resolves" the alias. 418 + */ 419 + if (resolved_node->type == ACPI_TYPE_LOCAL_ALIAS) { 420 + resolved_node = ACPI_CAST_PTR(struct acpi_namespace_node, 421 + resolved_node->object); 422 + } 423 + 424 + /* Update the reference object */ 425 + 426 + element->reference.resolved = TRUE; 427 + element->reference.node = resolved_node; 428 + type = element->reference.node->type; 429 + 430 + /* 431 + * Attempt to resolve the node to a value before we insert it into 432 + * the package. If this is a reference to a common data type, 433 + * resolve it immediately. According to the ACPI spec, package 434 + * elements can only be "data objects" or method references. 435 + * Attempt to resolve to an Integer, Buffer, String or Package. 436 + * If cannot, return the named reference (for things like Devices, 437 + * Methods, etc.) Buffer Fields and Fields will resolve to simple 438 + * objects (int/buf/str/pkg). 439 + * 440 + * NOTE: References to things like Devices, Methods, Mutexes, etc. 441 + * will remain as named references. This behavior is not described 442 + * in the ACPI spec, but it appears to be an oversight. 443 + */ 444 + status = acpi_ex_resolve_node_to_value(&resolved_node, NULL); 445 + if (ACPI_FAILURE(status)) { 446 + return_VOID; 447 + } 448 + #if 0 449 + /* TBD - alias support */ 450 + /* 451 + * Special handling for Alias objects. We need to setup the type 452 + * and the Op->Common.Node to point to the Alias target. Note, 453 + * Alias has at most one level of indirection internally. 454 + */ 455 + type = op->common.node->type; 456 + if (type == ACPI_TYPE_LOCAL_ALIAS) { 457 + type = obj_desc->common.type; 458 + op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, 459 + op->common.node->object); 460 + } 461 + #endif 462 + 463 + switch (type) { 464 + /* 465 + * These object types are a result of named references, so we will 466 + * leave them as reference objects. In other words, these types 467 + * have no intrinsic "value". 468 + */ 469 + case ACPI_TYPE_DEVICE: 470 + case ACPI_TYPE_THERMAL: 471 + 472 + /* TBD: This may not be necesssary */ 473 + 474 + acpi_ut_add_reference(resolved_node->object); 475 + break; 476 + 477 + case ACPI_TYPE_MUTEX: 478 + case ACPI_TYPE_METHOD: 479 + case ACPI_TYPE_POWER: 480 + case ACPI_TYPE_PROCESSOR: 481 + case ACPI_TYPE_EVENT: 482 + case ACPI_TYPE_REGION: 483 + 484 + break; 485 + 486 + default: 487 + /* 488 + * For all other types - the node was resolved to an actual 489 + * operand object with a value, return the object 490 + */ 491 + *element_ptr = (union acpi_operand_object *)resolved_node; 492 + break; 493 + } 494 + 495 + return_VOID; 496 + }
+21 -9
drivers/acpi/acpica/evgpeblk.c
··· 440 440 void *ignored) 441 441 { 442 442 acpi_status status; 443 + acpi_event_status event_status; 443 444 struct acpi_gpe_event_info *gpe_event_info; 444 445 u32 gpe_enabled_count; 445 446 u32 gpe_index; 447 + u32 gpe_number; 446 448 u32 i; 447 449 u32 j; 448 450 ··· 472 470 473 471 gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j; 474 472 gpe_event_info = &gpe_block->event_info[gpe_index]; 473 + gpe_number = gpe_block->block_base_number + gpe_index; 475 474 476 475 /* 477 476 * Ignore GPEs that have no corresponding _Lxx/_Exx method 478 - * and GPEs that are used to wake the system 477 + * and GPEs that are used for wakeup 479 478 */ 480 - if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 481 - ACPI_GPE_DISPATCH_NONE) 482 - || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 483 - ACPI_GPE_DISPATCH_HANDLER) 484 - || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 485 - ACPI_GPE_DISPATCH_RAW_HANDLER) 479 + if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != 480 + ACPI_GPE_DISPATCH_METHOD) 486 481 || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { 487 482 continue; 488 483 } 484 + 485 + event_status = 0; 486 + (void)acpi_hw_get_gpe_status(gpe_event_info, 487 + &event_status); 489 488 490 489 status = acpi_ev_add_gpe_reference(gpe_event_info); 491 490 if (ACPI_FAILURE(status)) { 492 491 ACPI_EXCEPTION((AE_INFO, status, 493 492 "Could not enable GPE 0x%02X", 494 - gpe_index + 495 - gpe_block->block_base_number)); 493 + gpe_number)); 496 494 continue; 495 + } 496 + 497 + gpe_event_info->flags |= ACPI_GPE_AUTO_ENABLED; 498 + 499 + if (event_status & ACPI_EVENT_FLAG_STATUS_SET) { 500 + ACPI_INFO(("GPE 0x%02X active on init", 501 + gpe_number)); 502 + (void)acpi_ev_gpe_dispatch(gpe_block->node, 503 + gpe_event_info, 504 + gpe_number); 497 505 } 498 506 499 507 gpe_enabled_count++;
+8
drivers/acpi/acpica/evxfgpe.c
··· 435 435 */ 436 436 gpe_event_info->flags = 437 437 (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED); 438 + } else if (gpe_event_info->flags & ACPI_GPE_AUTO_ENABLED) { 439 + /* 440 + * A reference to this GPE has been added during the GPE block 441 + * initialization, so drop it now to prevent the GPE from being 442 + * permanently enabled and clear its ACPI_GPE_AUTO_ENABLED flag. 443 + */ 444 + (void)acpi_ev_remove_gpe_reference(gpe_event_info); 445 + gpe_event_info->flags &= ~ACPI_GPE_AUTO_ENABLED; 438 446 } 439 447 440 448 /*
+19 -47
drivers/acpi/acpica/excreate.c
··· 87 87 target_node->object); 88 88 } 89 89 90 - /* 91 - * For objects that can never change (i.e., the NS node will 92 - * permanently point to the same object), we can simply attach 93 - * the object to the new NS node. For other objects (such as 94 - * Integers, buffers, etc.), we have to point the Alias node 95 - * to the original Node. 96 - */ 90 + /* Ensure that the target node is valid */ 91 + 92 + if (!target_node) { 93 + return_ACPI_STATUS(AE_NULL_OBJECT); 94 + } 95 + 96 + /* Construct the alias object (a namespace node) */ 97 + 97 98 switch (target_node->type) { 98 - 99 - /* For these types, the sub-object can change dynamically via a Store */ 100 - 101 - case ACPI_TYPE_INTEGER: 102 - case ACPI_TYPE_STRING: 103 - case ACPI_TYPE_BUFFER: 104 - case ACPI_TYPE_PACKAGE: 105 - case ACPI_TYPE_BUFFER_FIELD: 99 + case ACPI_TYPE_METHOD: 106 100 /* 107 - * These types open a new scope, so we need the NS node in order to access 108 - * any children. 101 + * Control method aliases need to be differentiated with 102 + * a special type 109 103 */ 110 - case ACPI_TYPE_DEVICE: 111 - case ACPI_TYPE_POWER: 112 - case ACPI_TYPE_PROCESSOR: 113 - case ACPI_TYPE_THERMAL: 114 - case ACPI_TYPE_LOCAL_SCOPE: 104 + alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 105 + break; 106 + 107 + default: 115 108 /* 109 + * All other object types. 110 + * 116 111 * The new alias has the type ALIAS and points to the original 117 112 * NS node, not the object itself. 118 113 */ ··· 115 120 alias_node->object = 116 121 ACPI_CAST_PTR(union acpi_operand_object, target_node); 117 122 break; 118 - 119 - case ACPI_TYPE_METHOD: 120 - /* 121 - * Control method aliases need to be differentiated 122 - */ 123 - alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 124 - alias_node->object = 125 - ACPI_CAST_PTR(union acpi_operand_object, target_node); 126 - break; 127 - 128 - default: 129 - 130 - /* Attach the original source object to the new Alias Node */ 131 - 132 - /* 133 - * The new alias assumes the type of the target, and it points 134 - * to the same object. The reference count of the object has an 135 - * additional reference to prevent deletion out from under either the 136 - * target node or the alias Node 137 - */ 138 - status = acpi_ns_attach_object(alias_node, 139 - acpi_ns_get_attached_object 140 - (target_node), 141 - target_node->type); 142 - break; 143 123 } 144 124 145 125 /* Since both operands are Nodes, we don't need to delete them */ 146 126 127 + alias_node->object = 128 + ACPI_CAST_PTR(union acpi_operand_object, target_node); 147 129 return_ACPI_STATUS(status); 148 130 } 149 131
+26 -8
drivers/acpi/acpica/exdump.c
··· 102 102 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL}, 103 103 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(package.node), "Parent Node"}, 104 104 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"}, 105 - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"}, 105 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Element Count"}, 106 106 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"}, 107 107 {ACPI_EXD_PACKAGE, 0, NULL} 108 108 }; ··· 384 384 count = info->offset; 385 385 386 386 while (count) { 387 + if (!obj_desc) { 388 + return; 389 + } 390 + 387 391 target = ACPI_ADD_PTR(u8, obj_desc, info->offset); 388 392 name = info->name; 389 393 ··· 473 469 start = *ACPI_CAST_PTR(void *, target); 474 470 next = start; 475 471 476 - acpi_os_printf("%20s : %p", name, next); 472 + acpi_os_printf("%20s : %p ", name, next); 477 473 if (next) { 478 - acpi_os_printf("(%s %2.2X)", 474 + acpi_os_printf("%s (Type %2.2X)", 479 475 acpi_ut_get_object_type_name 480 476 (next), next->common.type); 481 477 ··· 497 493 break; 498 494 } 499 495 } 496 + } else { 497 + acpi_os_printf("- No attached objects"); 500 498 } 501 499 502 500 acpi_os_printf("\n"); ··· 1135 1129 1136 1130 default: 1137 1131 1138 - acpi_os_printf("[Unknown Type] %X\n", obj_desc->common.type); 1132 + acpi_os_printf("[%s] Type: %2.2X\n", 1133 + acpi_ut_get_type_name(obj_desc->common.type), 1134 + obj_desc->common.type); 1139 1135 break; 1140 1136 } 1141 1137 } ··· 1175 1167 acpi_ex_dump_namespace_node((struct acpi_namespace_node *) 1176 1168 obj_desc, flags); 1177 1169 1178 - acpi_os_printf("\nAttached Object (%p):\n", 1179 - ((struct acpi_namespace_node *)obj_desc)-> 1180 - object); 1181 - 1182 1170 obj_desc = ((struct acpi_namespace_node *)obj_desc)->object; 1171 + if (!obj_desc) { 1172 + return_VOID; 1173 + } 1174 + 1175 + acpi_os_printf("\nAttached Object %p", obj_desc); 1176 + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { 1177 + acpi_os_printf(" - Namespace Node"); 1178 + } 1179 + 1180 + acpi_os_printf(":\n"); 1183 1181 goto dump_object; 1184 1182 } 1185 1183 ··· 1204 1190 } 1205 1191 1206 1192 dump_object: 1193 + 1194 + if (!obj_desc) { 1195 + return_VOID; 1196 + } 1207 1197 1208 1198 /* Common Fields */ 1209 1199
+9
drivers/acpi/acpica/exmisc.c
··· 265 265 266 266 default: 267 267 268 + ACPI_ERROR((AE_INFO, 269 + "Invalid numeric logical opcode: %X", opcode)); 268 270 status = AE_AML_INTERNAL; 269 271 break; 270 272 } ··· 347 345 348 346 default: 349 347 348 + ACPI_ERROR((AE_INFO, 349 + "Invalid object type for logical operator: %X", 350 + operand0->common.type)); 350 351 status = AE_AML_INTERNAL; 351 352 break; 352 353 } ··· 393 388 394 389 default: 395 390 391 + ACPI_ERROR((AE_INFO, 392 + "Invalid comparison opcode: %X", opcode)); 396 393 status = AE_AML_INTERNAL; 397 394 break; 398 395 } ··· 463 456 464 457 default: 465 458 459 + ACPI_ERROR((AE_INFO, 460 + "Invalid comparison opcode: %X", opcode)); 466 461 status = AE_AML_INTERNAL; 467 462 break; 468 463 }
+3
drivers/acpi/acpica/exoparg2.c
··· 414 414 415 415 default: 416 416 417 + ACPI_ERROR((AE_INFO, 418 + "Invalid object type: %X", 419 + (operand[0])->common.type)); 417 420 status = AE_AML_INTERNAL; 418 421 goto cleanup; 419 422 }
+1 -1
drivers/acpi/acpica/hwregs.c
··· 107 107 ACPI_IS_ALIGNED(reg->bit_width, 8)) { 108 108 access_bit_width = reg->bit_width; 109 109 } else if (reg->access_width) { 110 - access_bit_width = (1 << (reg->access_width + 2)); 110 + access_bit_width = ACPI_ACCESS_BIT_WIDTH(reg->access_width); 111 111 } else { 112 112 access_bit_width = 113 113 ACPI_ROUND_UP_POWER_OF_TWO_8(reg->bit_offset +
+6 -3
drivers/acpi/acpica/hwxfsleep.c
··· 72 72 static struct acpi_sleep_functions acpi_sleep_dispatch[] = { 73 73 {ACPI_STRUCT_INIT(legacy_function, 74 74 ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep)), 75 - ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_sleep) }, 75 + ACPI_STRUCT_INIT(extended_function, 76 + acpi_hw_extended_sleep)}, 76 77 {ACPI_STRUCT_INIT(legacy_function, 77 78 ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep)), 78 - ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake_prep) }, 79 + ACPI_STRUCT_INIT(extended_function, 80 + acpi_hw_extended_wake_prep)}, 79 81 {ACPI_STRUCT_INIT(legacy_function, 80 82 ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake)), 81 - ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake) } 83 + ACPI_STRUCT_INIT(extended_function, 84 + acpi_hw_extended_wake)} 82 85 }; 83 86 84 87 /*
+21 -5
drivers/acpi/acpica/nsaccess.c
··· 292 292 { 293 293 acpi_status status; 294 294 char *path = pathname; 295 + char *external_path; 295 296 struct acpi_namespace_node *prefix_node; 296 297 struct acpi_namespace_node *current_node = NULL; 297 298 struct acpi_namespace_node *this_node = NULL; ··· 428 427 num_carats++; 429 428 this_node = this_node->parent; 430 429 if (!this_node) { 430 + /* 431 + * Current scope has no parent scope. Externalize 432 + * the internal path for error message. 433 + */ 434 + status = 435 + acpi_ns_externalize_name 436 + (ACPI_UINT32_MAX, pathname, NULL, 437 + &external_path); 438 + if (ACPI_SUCCESS(status)) { 439 + ACPI_ERROR((AE_INFO, 440 + "%s: Path has too many parent prefixes (^)", 441 + external_path)); 431 442 432 - /* Current scope has no parent scope */ 443 + ACPI_FREE(external_path); 444 + } 433 445 434 - ACPI_ERROR((AE_INFO, 435 - "%s: Path has too many parent prefixes (^) " 436 - "- reached beyond root node", 437 - pathname)); 438 446 return_ACPI_STATUS(AE_NOT_FOUND); 439 447 } 440 448 } ··· 644 634 this_node->object; 645 635 } 646 636 } 637 + #ifdef ACPI_ASL_COMPILER 638 + if (!acpi_gbl_disasm_flag && 639 + (this_node->flags & ANOBJ_IS_EXTERNAL)) { 640 + this_node->flags |= IMPLICIT_EXTERNAL; 641 + } 642 + #endif 647 643 } 648 644 649 645 /* Special handling for the last segment (num_segments == 0) */
+17 -4
drivers/acpi/acpica/nsarguments.c
··· 69 69 u8 user_arg_type; 70 70 u32 i; 71 71 72 - /* If not a predefined name, cannot typecheck args */ 73 - 74 - if (!info->predefined) { 72 + /* 73 + * If not a predefined name, cannot typecheck args, because 74 + * we have no idea what argument types are expected. 75 + * Also, ignore typecheck if warnings/errors if this method 76 + * has already been evaluated at least once -- in order 77 + * to suppress repetitive messages. 78 + */ 79 + if (!info->predefined || (info->node->flags & ANOBJ_EVALUATED)) { 75 80 return; 76 81 } 77 82 ··· 98 93 acpi_ut_get_type_name 99 94 (user_arg_type), 100 95 acpi_ut_get_type_name(arg_type))); 96 + 97 + /* Prevent any additional typechecking for this method */ 98 + 99 + info->node->flags |= ANOBJ_EVALUATED; 101 100 } 102 101 } 103 102 } ··· 130 121 u32 aml_param_count; 131 122 u32 required_param_count; 132 123 133 - if (!predefined) { 124 + if (!predefined || (node->flags & ANOBJ_EVALUATED)) { 134 125 return; 135 126 } 136 127 ··· 223 214 { 224 215 u32 aml_param_count; 225 216 u32 required_param_count; 217 + 218 + if (node->flags & ANOBJ_EVALUATED) { 219 + return; 220 + } 226 221 227 222 if (!predefined) { 228 223 /*
+14
drivers/acpi/acpica/nsinit.c
··· 396 396 397 397 info->package_init++; 398 398 status = acpi_ds_get_package_arguments(obj_desc); 399 + if (ACPI_FAILURE(status)) { 400 + break; 401 + } 402 + 403 + /* 404 + * Resolve all named references in package objects (and all 405 + * sub-packages). This action has been deferred until the entire 406 + * namespace has been loaded, in order to support external and 407 + * forward references from individual package elements (05/2017). 408 + */ 409 + status = acpi_ut_walk_package_tree(obj_desc, NULL, 410 + acpi_ds_init_package_element, 411 + NULL); 412 + obj_desc->package.flags |= AOPOBJ_DATA_VALID; 399 413 break; 400 414 401 415 default:
+8 -1
drivers/acpi/acpica/nsnames.c
··· 89 89 { 90 90 acpi_size size; 91 91 92 - ACPI_FUNCTION_ENTRY(); 92 + /* Validate the Node */ 93 + 94 + if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { 95 + ACPI_ERROR((AE_INFO, 96 + "Invalid/cached reference target node: %p, descriptor type %d", 97 + node, ACPI_GET_DESCRIPTOR_TYPE(node))); 98 + return (0); 99 + } 93 100 94 101 size = acpi_ns_build_normalized_path(node, NULL, 0, FALSE); 95 102 return (size);
+2
drivers/acpi/acpica/nsprepkg.c
··· 614 614 615 615 default: /* Should not get here, type was validated by caller */ 616 616 617 + ACPI_ERROR((AE_INFO, "Invalid Package type: %X", 618 + package->ret_info.type)); 617 619 return (AE_AML_INTERNAL); 618 620 } 619 621
+14
drivers/acpi/acpica/psloop.c
··· 164 164 INCREMENT_ARG_LIST(walk_state->arg_types); 165 165 } 166 166 167 + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 168 + "Final argument count: %u pass %u\n", 169 + walk_state->arg_count, 170 + walk_state->pass_number)); 171 + 167 172 /* 168 173 * Handle executable code at "module-level". This refers to 169 174 * executable opcodes that appear outside of any control method. ··· 282 277 AML_NAME_OP) 283 278 && (walk_state->pass_number <= 284 279 ACPI_IMODE_LOAD_PASS2)) { 280 + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 281 + "Setup Package/Buffer: Pass %u, AML Ptr: %p\n", 282 + walk_state->pass_number, 283 + aml_op_start)); 284 + 285 285 /* 286 286 * Skip parsing of Buffers and Packages because we don't have 287 287 * enough info in the first pass to parse them correctly. ··· 579 569 } 580 570 581 571 /* Check for arguments that need to be processed */ 572 + 573 + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 574 + "Parseloop: argument count: %u\n", 575 + walk_state->arg_count)); 582 576 583 577 if (walk_state->arg_count) { 584 578 /*
+26
drivers/acpi/acpica/psobject.c
··· 359 359 acpi_ps_build_named_op(walk_state, aml_op_start, op, 360 360 &named_op); 361 361 acpi_ps_free_op(op); 362 + 363 + #ifdef ACPI_ASL_COMPILER 364 + if (acpi_gbl_disasm_flag 365 + && walk_state->opcode == AML_EXTERNAL_OP 366 + && status == AE_NOT_FOUND) { 367 + /* 368 + * If parsing of AML_EXTERNAL_OP's name path fails, then skip 369 + * past this opcode and keep parsing. This is a much better 370 + * alternative than to abort the entire disassembler. At this 371 + * point, the parser_state is at the end of the namepath of the 372 + * external declaration opcode. Setting walk_state->Aml to 373 + * walk_state->parser_state.Aml + 2 moves increments the 374 + * walk_state->Aml past the object type and the paramcount of the 375 + * external opcode. For the error message, only print the AML 376 + * offset. We could attempt to print the name but this may cause 377 + * a segmentation fault when printing the namepath because the 378 + * AML may be incorrect. 379 + */ 380 + acpi_os_printf 381 + ("// Invalid external declaration at AML offset 0x%x.\n", 382 + walk_state->aml - 383 + walk_state->parser_state.aml_start); 384 + walk_state->aml = walk_state->parser_state.aml + 2; 385 + return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); 386 + } 387 + #endif 362 388 if (ACPI_FAILURE(status)) { 363 389 return_ACPI_STATUS(status); 364 390 }
+4 -3
drivers/acpi/acpica/rsxface.c
··· 615 615 * device we are querying 616 616 * name - Method name of the resources we want. 617 617 * (METHOD_NAME__CRS, METHOD_NAME__PRS, or 618 - * METHOD_NAME__AEI) 618 + * METHOD_NAME__AEI or METHOD_NAME__DMA) 619 619 * user_function - Called for each resource 620 620 * context - Passed to user_function 621 621 * ··· 641 641 if (!device_handle || !user_function || !name || 642 642 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && 643 643 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) && 644 - !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) { 644 + !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI) && 645 + !ACPI_COMPARE_NAME(name, METHOD_NAME__DMA))) { 645 646 return_ACPI_STATUS(AE_BAD_PARAMETER); 646 647 } 647 648 648 - /* Get the _CRS/_PRS/_AEI resource list */ 649 + /* Get the _CRS/_PRS/_AEI/_DMA resource list */ 649 650 650 651 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 651 652 status = acpi_rs_get_method_data(device_handle, name, &buffer);
+205 -25
drivers/acpi/acpica/tbdata.c
··· 50 50 #define _COMPONENT ACPI_TABLES 51 51 ACPI_MODULE_NAME("tbdata") 52 52 53 + /* Local prototypes */ 54 + static acpi_status 55 + acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index); 56 + 57 + static u8 58 + acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index); 59 + 60 + /******************************************************************************* 61 + * 62 + * FUNCTION: acpi_tb_compare_tables 63 + * 64 + * PARAMETERS: table_desc - Table 1 descriptor to be compared 65 + * table_index - Index of table 2 to be compared 66 + * 67 + * RETURN: TRUE if both tables are identical. 68 + * 69 + * DESCRIPTION: This function compares a table with another table that has 70 + * already been installed in the root table list. 71 + * 72 + ******************************************************************************/ 73 + 74 + static u8 75 + acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index) 76 + { 77 + acpi_status status = AE_OK; 78 + u8 is_identical; 79 + struct acpi_table_header *table; 80 + u32 table_length; 81 + u8 table_flags; 82 + 83 + status = 84 + acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index], 85 + &table, &table_length, &table_flags); 86 + if (ACPI_FAILURE(status)) { 87 + return (FALSE); 88 + } 89 + 90 + /* 91 + * Check for a table match on the entire table length, 92 + * not just the header. 93 + */ 94 + is_identical = (u8)((table_desc->length != table_length || 95 + memcmp(table_desc->pointer, table, table_length)) ? 96 + FALSE : TRUE); 97 + 98 + /* Release the acquired table */ 99 + 100 + acpi_tb_release_table(table, table_length, table_flags); 101 + return (is_identical); 102 + } 103 + 53 104 /******************************************************************************* 54 105 * 55 106 * FUNCTION: acpi_tb_init_table_descriptor ··· 115 64 * DESCRIPTION: Initialize a new table descriptor 116 65 * 117 66 ******************************************************************************/ 67 + 118 68 void 119 69 acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc, 120 70 acpi_physical_address address, ··· 390 338 acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc) 391 339 { 392 340 393 - if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) { 341 + if (!table_desc->pointer && !acpi_gbl_enable_table_validation) { 394 342 /* 395 343 * Only validates the header of the table. 396 344 * Note that Length contains the size of the mapping after invoking ··· 406 354 return (acpi_tb_validate_table(table_desc)); 407 355 } 408 356 357 + /******************************************************************************* 358 + * 359 + * FUNCTION: acpi_tb_check_duplication 360 + * 361 + * PARAMETERS: table_desc - Table descriptor 362 + * table_index - Where the table index is returned 363 + * 364 + * RETURN: Status 365 + * 366 + * DESCRIPTION: Avoid installing duplicated tables. However table override and 367 + * user aided dynamic table load is allowed, thus comparing the 368 + * address of the table is not sufficient, and checking the entire 369 + * table content is required. 370 + * 371 + ******************************************************************************/ 372 + 373 + static acpi_status 374 + acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index) 375 + { 376 + u32 i; 377 + 378 + ACPI_FUNCTION_TRACE(tb_check_duplication); 379 + 380 + /* Check if table is already registered */ 381 + 382 + for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { 383 + 384 + /* Do not compare with unverified tables */ 385 + 386 + if (! 387 + (acpi_gbl_root_table_list.tables[i]. 388 + flags & ACPI_TABLE_IS_VERIFIED)) { 389 + continue; 390 + } 391 + 392 + /* 393 + * Check for a table match on the entire table length, 394 + * not just the header. 395 + */ 396 + if (!acpi_tb_compare_tables(table_desc, i)) { 397 + continue; 398 + } 399 + 400 + /* 401 + * Note: the current mechanism does not unregister a table if it is 402 + * dynamically unloaded. The related namespace entries are deleted, 403 + * but the table remains in the root table list. 404 + * 405 + * The assumption here is that the number of different tables that 406 + * will be loaded is actually small, and there is minimal overhead 407 + * in just keeping the table in case it is needed again. 408 + * 409 + * If this assumption changes in the future (perhaps on large 410 + * machines with many table load/unload operations), tables will 411 + * need to be unregistered when they are unloaded, and slots in the 412 + * root table list should be reused when empty. 413 + */ 414 + if (acpi_gbl_root_table_list.tables[i].flags & 415 + ACPI_TABLE_IS_LOADED) { 416 + 417 + /* Table is still loaded, this is an error */ 418 + 419 + return_ACPI_STATUS(AE_ALREADY_EXISTS); 420 + } else { 421 + *table_index = i; 422 + return_ACPI_STATUS(AE_CTRL_TERMINATE); 423 + } 424 + } 425 + 426 + /* Indicate no duplication to the caller */ 427 + 428 + return_ACPI_STATUS(AE_OK); 429 + } 430 + 409 431 /****************************************************************************** 410 432 * 411 433 * FUNCTION: acpi_tb_verify_temp_table 412 434 * 413 435 * PARAMETERS: table_desc - Table descriptor 414 436 * signature - Table signature to verify 437 + * table_index - Where the table index is returned 415 438 * 416 439 * RETURN: Status 417 440 * 418 441 * DESCRIPTION: This function is called to validate and verify the table, the 419 442 * returned table descriptor is in "VALIDATED" state. 443 + * Note that 'TableIndex' is required to be set to !NULL to 444 + * enable duplication check. 420 445 * 421 446 *****************************************************************************/ 422 447 423 448 acpi_status 424 - acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature) 449 + acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, 450 + char *signature, u32 *table_index) 425 451 { 426 452 acpi_status status = AE_OK; 427 453 ··· 522 392 goto invalidate_and_exit; 523 393 } 524 394 525 - /* Verify the checksum */ 395 + if (acpi_gbl_enable_table_validation) { 526 396 527 - if (acpi_gbl_verify_table_checksum) { 397 + /* Verify the checksum */ 398 + 528 399 status = 529 400 acpi_tb_verify_checksum(table_desc->pointer, 530 401 table_desc->length); ··· 542 411 543 412 goto invalidate_and_exit; 544 413 } 414 + 415 + /* Avoid duplications */ 416 + 417 + if (table_index) { 418 + status = 419 + acpi_tb_check_duplication(table_desc, table_index); 420 + if (ACPI_FAILURE(status)) { 421 + if (status != AE_CTRL_TERMINATE) { 422 + ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, 423 + "%4.4s 0x%8.8X%8.8X" 424 + " Table is duplicated", 425 + acpi_ut_valid_nameseg 426 + (table_desc->signature. 427 + ascii) ? table_desc-> 428 + signature. 429 + ascii : "????", 430 + ACPI_FORMAT_UINT64 431 + (table_desc->address))); 432 + } 433 + 434 + goto invalidate_and_exit; 435 + } 436 + } 437 + 438 + table_desc->flags |= ACPI_TABLE_IS_VERIFIED; 545 439 } 546 440 547 - return_ACPI_STATUS(AE_OK); 441 + return_ACPI_STATUS(status); 548 442 549 443 invalidate_and_exit: 550 444 acpi_tb_invalidate_table(table_desc); ··· 592 436 { 593 437 struct acpi_table_desc *tables; 594 438 u32 table_count; 439 + u32 current_table_count, max_table_count; 440 + u32 i; 595 441 596 442 ACPI_FUNCTION_TRACE(tb_resize_root_table_list); 597 443 ··· 613 455 table_count = acpi_gbl_root_table_list.current_table_count; 614 456 } 615 457 616 - tables = ACPI_ALLOCATE_ZEROED(((acpi_size)table_count + 617 - ACPI_ROOT_TABLE_SIZE_INCREMENT) * 458 + max_table_count = table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; 459 + tables = ACPI_ALLOCATE_ZEROED(((acpi_size)max_table_count) * 618 460 sizeof(struct acpi_table_desc)); 619 461 if (!tables) { 620 462 ACPI_ERROR((AE_INFO, ··· 624 466 625 467 /* Copy and free the previous table array */ 626 468 469 + current_table_count = 0; 627 470 if (acpi_gbl_root_table_list.tables) { 628 - memcpy(tables, acpi_gbl_root_table_list.tables, 629 - (acpi_size)table_count * sizeof(struct acpi_table_desc)); 471 + for (i = 0; i < table_count; i++) { 472 + if (acpi_gbl_root_table_list.tables[i].address) { 473 + memcpy(tables + current_table_count, 474 + acpi_gbl_root_table_list.tables + i, 475 + sizeof(struct acpi_table_desc)); 476 + current_table_count++; 477 + } 478 + } 630 479 631 480 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 632 481 ACPI_FREE(acpi_gbl_root_table_list.tables); ··· 641 476 } 642 477 643 478 acpi_gbl_root_table_list.tables = tables; 644 - acpi_gbl_root_table_list.max_table_count = 645 - table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; 479 + acpi_gbl_root_table_list.max_table_count = max_table_count; 480 + acpi_gbl_root_table_list.current_table_count = current_table_count; 646 481 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 647 482 648 483 return_ACPI_STATUS(AE_OK); ··· 983 818 acpi_ev_update_gpes(owner_id); 984 819 } 985 820 986 - /* Invoke table handler if present */ 821 + /* Invoke table handler */ 987 822 988 - if (acpi_gbl_table_handler) { 989 - (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_LOAD, table, 990 - acpi_gbl_table_handler_context); 991 - } 992 - 823 + acpi_tb_notify_table(ACPI_TABLE_EVENT_LOAD, table); 993 824 return_ACPI_STATUS(status); 994 825 } 995 826 ··· 1055 894 return_ACPI_STATUS(AE_NOT_EXIST); 1056 895 } 1057 896 1058 - /* Invoke table handler if present */ 897 + /* Invoke table handler */ 1059 898 1060 - if (acpi_gbl_table_handler) { 1061 - status = acpi_get_table_by_index(table_index, &table); 1062 - if (ACPI_SUCCESS(status)) { 1063 - (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD, 1064 - table, 1065 - acpi_gbl_table_handler_context); 1066 - } 899 + status = acpi_get_table_by_index(table_index, &table); 900 + if (ACPI_SUCCESS(status)) { 901 + acpi_tb_notify_table(ACPI_TABLE_EVENT_UNLOAD, table); 1067 902 } 1068 903 1069 904 /* Delete the portion of the namespace owned by this table */ ··· 1075 918 } 1076 919 1077 920 ACPI_EXPORT_SYMBOL(acpi_tb_unload_table) 921 + 922 + /******************************************************************************* 923 + * 924 + * FUNCTION: acpi_tb_notify_table 925 + * 926 + * PARAMETERS: event - Table event 927 + * table - Validated table pointer 928 + * 929 + * RETURN: None 930 + * 931 + * DESCRIPTION: Notify a table event to the users. 932 + * 933 + ******************************************************************************/ 934 + 935 + void acpi_tb_notify_table(u32 event, void *table) 936 + { 937 + /* Invoke table handler if present */ 938 + 939 + if (acpi_gbl_table_handler) { 940 + (void)acpi_gbl_table_handler(event, table, 941 + acpi_gbl_table_handler_context); 942 + } 943 + }
+22 -139
drivers/acpi/acpica/tbinstal.c
··· 48 48 #define _COMPONENT ACPI_TABLES 49 49 ACPI_MODULE_NAME("tbinstal") 50 50 51 - /* Local prototypes */ 52 - static u8 53 - acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index); 54 - 55 - /******************************************************************************* 56 - * 57 - * FUNCTION: acpi_tb_compare_tables 58 - * 59 - * PARAMETERS: table_desc - Table 1 descriptor to be compared 60 - * table_index - Index of table 2 to be compared 61 - * 62 - * RETURN: TRUE if both tables are identical. 63 - * 64 - * DESCRIPTION: This function compares a table with another table that has 65 - * already been installed in the root table list. 66 - * 67 - ******************************************************************************/ 68 - 69 - static u8 70 - acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index) 71 - { 72 - acpi_status status = AE_OK; 73 - u8 is_identical; 74 - struct acpi_table_header *table; 75 - u32 table_length; 76 - u8 table_flags; 77 - 78 - status = 79 - acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index], 80 - &table, &table_length, &table_flags); 81 - if (ACPI_FAILURE(status)) { 82 - return (FALSE); 83 - } 84 - 85 - /* 86 - * Check for a table match on the entire table length, 87 - * not just the header. 88 - */ 89 - is_identical = (u8)((table_desc->length != table_length || 90 - memcmp(table_desc->pointer, table, table_length)) ? 91 - FALSE : TRUE); 92 - 93 - /* Release the acquired table */ 94 - 95 - acpi_tb_release_table(table, table_length, table_flags); 96 - return (is_identical); 97 - } 98 - 99 51 /******************************************************************************* 100 52 * 101 53 * FUNCTION: acpi_tb_install_table_with_override ··· 64 112 * table array. 65 113 * 66 114 ******************************************************************************/ 67 - 68 115 void 69 116 acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc, 70 117 u8 override, u32 *table_index) ··· 161 210 goto release_and_exit; 162 211 } 163 212 164 - /* Validate and verify a table before installation */ 165 - 166 - status = acpi_tb_verify_temp_table(&new_table_desc, NULL); 167 - if (ACPI_FAILURE(status)) { 168 - goto release_and_exit; 169 - } 170 - 171 213 /* Acquire the table lock */ 172 214 173 215 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 174 216 175 - if (reload) { 176 - /* 177 - * Validate the incoming table signature. 178 - * 179 - * 1) Originally, we checked the table signature for "SSDT" or "PSDT". 180 - * 2) We added support for OEMx tables, signature "OEM". 181 - * 3) Valid tables were encountered with a null signature, so we just 182 - * gave up on validating the signature, (05/2008). 183 - * 4) We encountered non-AML tables such as the MADT, which caused 184 - * interpreter errors and kernel faults. So now, we once again allow 185 - * only "SSDT", "OEMx", and now, also a null signature. (05/2011). 186 - */ 187 - if ((new_table_desc.signature.ascii[0] != 0x00) && 188 - (!ACPI_COMPARE_NAME 189 - (&new_table_desc.signature, ACPI_SIG_SSDT)) 190 - && (strncmp(new_table_desc.signature.ascii, "OEM", 3))) { 191 - ACPI_BIOS_ERROR((AE_INFO, 192 - "Table has invalid signature [%4.4s] (0x%8.8X), " 193 - "must be SSDT or OEMx", 194 - acpi_ut_valid_nameseg(new_table_desc. 195 - signature. 196 - ascii) ? 197 - new_table_desc.signature. 198 - ascii : "????", 199 - new_table_desc.signature.integer)); 217 + /* Validate and verify a table before installation */ 200 218 201 - status = AE_BAD_SIGNATURE; 202 - goto unlock_and_exit; 203 - } 204 - 205 - /* Check if table is already registered */ 206 - 207 - for (i = 0; i < acpi_gbl_root_table_list.current_table_count; 208 - ++i) { 219 + status = acpi_tb_verify_temp_table(&new_table_desc, NULL, &i); 220 + if (ACPI_FAILURE(status)) { 221 + if (status == AE_CTRL_TERMINATE) { 209 222 /* 210 - * Check for a table match on the entire table length, 211 - * not just the header. 223 + * Table was unloaded, allow it to be reloaded. 224 + * As we are going to return AE_OK to the caller, we should 225 + * take the responsibility of freeing the input descriptor. 226 + * Refill the input descriptor to ensure 227 + * acpi_tb_install_table_with_override() can be called again to 228 + * indicate the re-installation. 212 229 */ 213 - if (!acpi_tb_compare_tables(&new_table_desc, i)) { 214 - continue; 215 - } 216 - 217 - /* 218 - * Note: the current mechanism does not unregister a table if it is 219 - * dynamically unloaded. The related namespace entries are deleted, 220 - * but the table remains in the root table list. 221 - * 222 - * The assumption here is that the number of different tables that 223 - * will be loaded is actually small, and there is minimal overhead 224 - * in just keeping the table in case it is needed again. 225 - * 226 - * If this assumption changes in the future (perhaps on large 227 - * machines with many table load/unload operations), tables will 228 - * need to be unregistered when they are unloaded, and slots in the 229 - * root table list should be reused when empty. 230 - */ 231 - if (acpi_gbl_root_table_list.tables[i].flags & 232 - ACPI_TABLE_IS_LOADED) { 233 - 234 - /* Table is still loaded, this is an error */ 235 - 236 - status = AE_ALREADY_EXISTS; 237 - goto unlock_and_exit; 238 - } else { 239 - /* 240 - * Table was unloaded, allow it to be reloaded. 241 - * As we are going to return AE_OK to the caller, we should 242 - * take the responsibility of freeing the input descriptor. 243 - * Refill the input descriptor to ensure 244 - * acpi_tb_install_table_with_override() can be called again to 245 - * indicate the re-installation. 246 - */ 247 - acpi_tb_uninstall_table(&new_table_desc); 248 - (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 249 - *table_index = i; 250 - return_ACPI_STATUS(AE_OK); 251 - } 230 + acpi_tb_uninstall_table(&new_table_desc); 231 + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 232 + *table_index = i; 233 + return_ACPI_STATUS(AE_OK); 252 234 } 235 + goto unlock_and_exit; 253 236 } 254 237 255 238 /* Add the table to the global root table list */ ··· 191 306 acpi_tb_install_table_with_override(&new_table_desc, override, 192 307 table_index); 193 308 194 - /* Invoke table handler if present */ 309 + /* Invoke table handler */ 195 310 196 311 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 197 - if (acpi_gbl_table_handler) { 198 - (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_INSTALL, 199 - new_table_desc.pointer, 200 - acpi_gbl_table_handler_context); 201 - } 312 + acpi_tb_notify_table(ACPI_TABLE_EVENT_INSTALL, new_table_desc.pointer); 202 313 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 203 314 204 315 unlock_and_exit: ··· 263 382 264 383 finish_override: 265 384 266 - /* Validate and verify a table before overriding */ 267 - 268 - status = acpi_tb_verify_temp_table(&new_table_desc, NULL); 385 + /* 386 + * Validate and verify a table before overriding, no nested table 387 + * duplication check as it's too complicated and unnecessary. 388 + */ 389 + status = acpi_tb_verify_temp_table(&new_table_desc, NULL, NULL); 269 390 if (ACPI_FAILURE(status)) { 270 391 return; 271 392 }
+34 -5
drivers/acpi/acpica/tbxface.c
··· 167 167 acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void) 168 168 { 169 169 acpi_status status; 170 - u32 i; 170 + struct acpi_table_desc *table_desc; 171 + u32 i, j; 171 172 172 173 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); 173 174 ··· 180 179 return_ACPI_STATUS(AE_SUPPORT); 181 180 } 182 181 182 + (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 183 + 183 184 /* 184 185 * Ensure OS early boot logic, which is required by some hosts. If the 185 186 * table state is reported to be wrong, developers should fix the ··· 189 186 * early stage. 190 187 */ 191 188 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { 192 - if (acpi_gbl_root_table_list.tables[i].pointer) { 189 + table_desc = &acpi_gbl_root_table_list.tables[i]; 190 + if (table_desc->pointer) { 193 191 ACPI_ERROR((AE_INFO, 194 192 "Table [%4.4s] is not invalidated during early boot stage", 195 - acpi_gbl_root_table_list.tables[i]. 196 - signature.ascii)); 193 + table_desc->signature.ascii)); 194 + } 195 + } 196 + 197 + if (!acpi_gbl_enable_table_validation) { 198 + /* 199 + * Now it's safe to do full table validation. We can do deferred 200 + * table initilization here once the flag is set. 201 + */ 202 + acpi_gbl_enable_table_validation = TRUE; 203 + for (i = 0; i < acpi_gbl_root_table_list.current_table_count; 204 + ++i) { 205 + table_desc = &acpi_gbl_root_table_list.tables[i]; 206 + if (!(table_desc->flags & ACPI_TABLE_IS_VERIFIED)) { 207 + status = 208 + acpi_tb_verify_temp_table(table_desc, NULL, 209 + &j); 210 + if (ACPI_FAILURE(status)) { 211 + acpi_tb_uninstall_table(table_desc); 212 + } 213 + } 197 214 } 198 215 } 199 216 200 217 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE; 201 - 202 218 status = acpi_tb_resize_root_table_list(); 219 + acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 220 + 221 + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 203 222 return_ACPI_STATUS(status); 204 223 } 205 224 ··· 393 368 struct acpi_table_desc *table_desc; 394 369 395 370 ACPI_FUNCTION_TRACE(acpi_put_table); 371 + 372 + if (!table) { 373 + return_VOID; 374 + } 396 375 397 376 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 398 377
+1 -1
drivers/acpi/acpica/tbxfload.c
··· 206 206 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { 207 207 table = &acpi_gbl_root_table_list.tables[i]; 208 208 209 - if (!acpi_gbl_root_table_list.tables[i].address || 209 + if (!table->address || 210 210 (!ACPI_COMPARE_NAME(table->signature.ascii, ACPI_SIG_SSDT) 211 211 && !ACPI_COMPARE_NAME(table->signature.ascii, 212 212 ACPI_SIG_PSDT)
+3 -1
drivers/acpi/acpica/uthex.c
··· 69 69 70 70 char acpi_ut_hex_to_ascii_char(u64 integer, u32 position) 71 71 { 72 + u64 index; 72 73 73 - return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 74 + acpi_ut_short_shift_right(integer, position, &index); 75 + return (acpi_gbl_hex_to_ascii[index & 0xF]); 74 76 } 75 77 76 78 /*******************************************************************************
+213 -9
drivers/acpi/acpica/utmath.c
··· 47 47 #define _COMPONENT ACPI_UTILITIES 48 48 ACPI_MODULE_NAME("utmath") 49 49 50 - /* 51 - * Optional support for 64-bit double-precision integer divide. This code 52 - * is configurable and is implemented in order to support 32-bit kernel 53 - * environments where a 64-bit double-precision math library is not available. 54 - * 55 - * Support for a more normal 64-bit divide/modulo (with check for a divide- 56 - * by-zero) appears after this optional section of code. 57 - */ 58 - #ifndef ACPI_USE_NATIVE_DIVIDE 59 50 /* Structures used only for 64-bit divide */ 60 51 typedef struct uint64_struct { 61 52 u32 lo; ··· 59 68 struct uint64_struct part; 60 69 61 70 } uint64_overlay; 71 + 72 + /* 73 + * Optional support for 64-bit double-precision integer multiply and shift. 74 + * This code is configurable and is implemented in order to support 32-bit 75 + * kernel environments where a 64-bit double-precision math library is not 76 + * available. 77 + */ 78 + #ifndef ACPI_USE_NATIVE_MATH64 79 + 80 + /******************************************************************************* 81 + * 82 + * FUNCTION: acpi_ut_short_multiply 83 + * 84 + * PARAMETERS: multiplicand - 64-bit multiplicand 85 + * multiplier - 32-bit multiplier 86 + * out_product - Pointer to where the product is returned 87 + * 88 + * DESCRIPTION: Perform a short multiply. 89 + * 90 + ******************************************************************************/ 91 + 92 + acpi_status 93 + acpi_ut_short_multiply(u64 multiplicand, u32 multiplier, u64 *out_product) 94 + { 95 + union uint64_overlay multiplicand_ovl; 96 + union uint64_overlay product; 97 + u32 carry32; 98 + 99 + ACPI_FUNCTION_TRACE(ut_short_multiply); 100 + 101 + multiplicand_ovl.full = multiplicand; 102 + 103 + /* 104 + * The Product is 64 bits, the carry is always 32 bits, 105 + * and is generated by the second multiply. 106 + */ 107 + ACPI_MUL_64_BY_32(0, multiplicand_ovl.part.hi, multiplier, 108 + product.part.hi, carry32); 109 + 110 + ACPI_MUL_64_BY_32(0, multiplicand_ovl.part.lo, multiplier, 111 + product.part.lo, carry32); 112 + 113 + product.part.hi += carry32; 114 + 115 + /* Return only what was requested */ 116 + 117 + if (out_product) { 118 + *out_product = product.full; 119 + } 120 + 121 + return_ACPI_STATUS(AE_OK); 122 + } 123 + 124 + /******************************************************************************* 125 + * 126 + * FUNCTION: acpi_ut_short_shift_left 127 + * 128 + * PARAMETERS: operand - 64-bit shift operand 129 + * count - 32-bit shift count 130 + * out_result - Pointer to where the result is returned 131 + * 132 + * DESCRIPTION: Perform a short left shift. 133 + * 134 + ******************************************************************************/ 135 + 136 + acpi_status acpi_ut_short_shift_left(u64 operand, u32 count, u64 *out_result) 137 + { 138 + union uint64_overlay operand_ovl; 139 + 140 + ACPI_FUNCTION_TRACE(ut_short_shift_left); 141 + 142 + operand_ovl.full = operand; 143 + 144 + if ((count & 63) >= 32) { 145 + operand_ovl.part.hi = operand_ovl.part.lo; 146 + operand_ovl.part.lo ^= operand_ovl.part.lo; 147 + count = (count & 63) - 32; 148 + } 149 + ACPI_SHIFT_LEFT_64_BY_32(operand_ovl.part.hi, 150 + operand_ovl.part.lo, count); 151 + 152 + /* Return only what was requested */ 153 + 154 + if (out_result) { 155 + *out_result = operand_ovl.full; 156 + } 157 + 158 + return_ACPI_STATUS(AE_OK); 159 + } 160 + 161 + /******************************************************************************* 162 + * 163 + * FUNCTION: acpi_ut_short_shift_right 164 + * 165 + * PARAMETERS: operand - 64-bit shift operand 166 + * count - 32-bit shift count 167 + * out_result - Pointer to where the result is returned 168 + * 169 + * DESCRIPTION: Perform a short right shift. 170 + * 171 + ******************************************************************************/ 172 + 173 + acpi_status acpi_ut_short_shift_right(u64 operand, u32 count, u64 *out_result) 174 + { 175 + union uint64_overlay operand_ovl; 176 + 177 + ACPI_FUNCTION_TRACE(ut_short_shift_right); 178 + 179 + operand_ovl.full = operand; 180 + 181 + if ((count & 63) >= 32) { 182 + operand_ovl.part.lo = operand_ovl.part.hi; 183 + operand_ovl.part.hi ^= operand_ovl.part.hi; 184 + count = (count & 63) - 32; 185 + } 186 + ACPI_SHIFT_RIGHT_64_BY_32(operand_ovl.part.hi, 187 + operand_ovl.part.lo, count); 188 + 189 + /* Return only what was requested */ 190 + 191 + if (out_result) { 192 + *out_result = operand_ovl.full; 193 + } 194 + 195 + return_ACPI_STATUS(AE_OK); 196 + } 197 + #else 198 + 199 + /******************************************************************************* 200 + * 201 + * FUNCTION: acpi_ut_short_multiply 202 + * 203 + * PARAMETERS: See function headers above 204 + * 205 + * DESCRIPTION: Native version of the ut_short_multiply function. 206 + * 207 + ******************************************************************************/ 208 + 209 + acpi_status 210 + acpi_ut_short_multiply(u64 multiplicand, u32 multiplier, u64 *out_product) 211 + { 212 + 213 + ACPI_FUNCTION_TRACE(ut_short_multiply); 214 + 215 + /* Return only what was requested */ 216 + 217 + if (out_product) { 218 + *out_product = multiplicand * multiplier; 219 + } 220 + 221 + return_ACPI_STATUS(AE_OK); 222 + } 223 + 224 + /******************************************************************************* 225 + * 226 + * FUNCTION: acpi_ut_short_shift_left 227 + * 228 + * PARAMETERS: See function headers above 229 + * 230 + * DESCRIPTION: Native version of the ut_short_shift_left function. 231 + * 232 + ******************************************************************************/ 233 + 234 + acpi_status acpi_ut_short_shift_left(u64 operand, u32 count, u64 *out_result) 235 + { 236 + 237 + ACPI_FUNCTION_TRACE(ut_short_shift_left); 238 + 239 + /* Return only what was requested */ 240 + 241 + if (out_result) { 242 + *out_result = operand << count; 243 + } 244 + 245 + return_ACPI_STATUS(AE_OK); 246 + } 247 + 248 + /******************************************************************************* 249 + * 250 + * FUNCTION: acpi_ut_short_shift_right 251 + * 252 + * PARAMETERS: See function headers above 253 + * 254 + * DESCRIPTION: Native version of the ut_short_shift_right function. 255 + * 256 + ******************************************************************************/ 257 + 258 + acpi_status acpi_ut_short_shift_right(u64 operand, u32 count, u64 *out_result) 259 + { 260 + 261 + ACPI_FUNCTION_TRACE(ut_short_shift_right); 262 + 263 + /* Return only what was requested */ 264 + 265 + if (out_result) { 266 + *out_result = operand >> count; 267 + } 268 + 269 + return_ACPI_STATUS(AE_OK); 270 + } 271 + #endif 272 + 273 + /* 274 + * Optional support for 64-bit double-precision integer divide. This code 275 + * is configurable and is implemented in order to support 32-bit kernel 276 + * environments where a 64-bit double-precision math library is not available. 277 + * 278 + * Support for a more normal 64-bit divide/modulo (with check for a divide- 279 + * by-zero) appears after this optional section of code. 280 + */ 281 + #ifndef ACPI_USE_NATIVE_DIVIDE 62 282 63 283 /******************************************************************************* 64 284 * ··· 460 258 } 461 259 462 260 #else 261 + 463 262 /******************************************************************************* 464 263 * 465 264 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide ··· 475 272 * perform the divide. 476 273 * 477 274 ******************************************************************************/ 275 + 478 276 acpi_status 479 277 acpi_ut_short_divide(u64 in_dividend, 480 278 u32 divisor, u64 *out_quotient, u32 *out_remainder)
+7 -3
drivers/acpi/acpica/utmisc.c
··· 224 224 * 225 225 * RETURN: Status 226 226 * 227 - * DESCRIPTION: Walk through a package 227 + * DESCRIPTION: Walk through a package, including subpackages 228 228 * 229 229 ******************************************************************************/ 230 230 ··· 236 236 acpi_status status = AE_OK; 237 237 union acpi_generic_state *state_list = NULL; 238 238 union acpi_generic_state *state; 239 - u32 this_index; 240 239 union acpi_operand_object *this_source_obj; 240 + u32 this_index; 241 241 242 242 ACPI_FUNCTION_TRACE(ut_walk_package_tree); 243 243 ··· 251 251 /* Get one element of the package */ 252 252 253 253 this_index = state->pkg.index; 254 - this_source_obj = (union acpi_operand_object *) 254 + this_source_obj = 255 255 state->pkg.source_object->package.elements[this_index]; 256 + state->pkg.this_target_obj = 257 + &state->pkg.source_object->package.elements[this_index]; 256 258 257 259 /* 258 260 * Check for: ··· 340 338 } 341 339 342 340 /* We should never get here */ 341 + 342 + ACPI_ERROR((AE_INFO, "State list did not terminate correctly")); 343 343 344 344 return_ACPI_STATUS(AE_AML_INTERNAL); 345 345 }
+5
drivers/acpi/acpica/utobject.c
··· 483 483 484 484 /* A namespace node should never get here */ 485 485 486 + ACPI_ERROR((AE_INFO, 487 + "Received a namespace node [%4.4s] " 488 + "where an operand object is required", 489 + ACPI_CAST_PTR(struct acpi_namespace_node, 490 + internal_object)->name.ascii)); 486 491 return_ACPI_STATUS(AE_AML_INTERNAL); 487 492 } 488 493
+4 -4
drivers/acpi/acpica/utprint.c
··· 176 176 u64 number = 0; 177 177 178 178 while (isdigit((int)*string)) { 179 - number *= 10; 179 + acpi_ut_short_multiply(number, 10, &number); 180 180 number += *(string++) - '0'; 181 181 } 182 182 ··· 286 286 /* Generate full string in reverse order */ 287 287 288 288 pos = acpi_ut_put_number(reversed_string, number, base, upper); 289 - i = ACPI_PTR_DIFF(pos, reversed_string); 289 + i = (s32)ACPI_PTR_DIFF(pos, reversed_string); 290 290 291 291 /* Printing 100 using %2d gives "100", not "00" */ 292 292 ··· 475 475 if (!s) { 476 476 s = "<NULL>"; 477 477 } 478 - length = acpi_ut_bound_string_length(s, precision); 478 + length = (s32)acpi_ut_bound_string_length(s, precision); 479 479 if (!(type & ACPI_FORMAT_LEFT)) { 480 480 while (length < width--) { 481 481 pos = ··· 579 579 } 580 580 } 581 581 582 - return (ACPI_PTR_DIFF(pos, string)); 582 + return ((int)ACPI_PTR_DIFF(pos, string)); 583 583 } 584 584 585 585 /*******************************************************************************
+7
drivers/acpi/acpica/utresrc.c
··· 237 237 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 238 238 } 239 239 240 + /* 241 + * Don't attempt to perform any validation on the 2nd byte. 242 + * Although all known ASL compilers insert a zero for the 2nd 243 + * byte, it can also be a checksum (as per the ACPI spec), 244 + * and this is occasionally seen in the field. July 2017. 245 + */ 246 + 240 247 /* Return the pointer to the end_tag if requested */ 241 248 242 249 if (!user_function) {
+1 -1
drivers/acpi/acpica/utstate.c
··· 226 226 227 227 union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, 228 228 void *external_object, 229 - u16 index) 229 + u32 index) 230 230 { 231 231 union acpi_generic_state *state; 232 232
+4 -5
drivers/acpi/acpica/utstrtoul64.c
··· 276 276 277 277 /* Convert and insert (add) the decimal digit */ 278 278 279 - next_value = 280 - (return_value * 10) + (ascii_digit - ACPI_ASCII_ZERO); 279 + acpi_ut_short_multiply(return_value, 10, &next_value); 280 + next_value += (ascii_digit - ACPI_ASCII_ZERO); 281 281 282 282 /* Check for overflow (32 or 64 bit) - return current converted value */ 283 283 ··· 335 335 336 336 /* Convert and insert the hex digit */ 337 337 338 - return_value = 339 - (return_value << 4) | 340 - acpi_ut_ascii_char_to_hex(ascii_digit); 338 + acpi_ut_short_shift_left(return_value, 4, &return_value); 339 + return_value |= acpi_ut_ascii_char_to_hex(ascii_digit); 341 340 342 341 string++; 343 342 valid_digits++;
+7 -2
drivers/acpi/acpica/uttrack.c
··· 591 591 return_VOID; 592 592 } 593 593 594 + if (!acpi_gbl_global_list) { 595 + goto exit; 596 + } 597 + 594 598 element = acpi_gbl_global_list->list_head; 595 599 while (element) { 596 600 if ((element->component & component) && ··· 606 602 607 603 if (element->size < 608 604 sizeof(struct acpi_common_descriptor)) { 609 - acpi_os_printf("%p Length 0x%04X %9.9s-%u " 605 + acpi_os_printf("%p Length 0x%04X %9.9s-%4.4u " 610 606 "[Not a Descriptor - too small]\n", 611 607 descriptor, element->size, 612 608 element->module, element->line); ··· 616 612 if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) != 617 613 ACPI_DESC_TYPE_CACHED) { 618 614 acpi_os_printf 619 - ("%p Length 0x%04X %9.9s-%u [%s] ", 615 + ("%p Length 0x%04X %9.9s-%4.4u [%s] ", 620 616 descriptor, element->size, 621 617 element->module, element->line, 622 618 acpi_ut_get_descriptor_name ··· 709 705 element = element->next; 710 706 } 711 707 708 + exit: 712 709 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY); 713 710 714 711 /* Print summary */
-5
drivers/acpi/apei/apei-internal.h
··· 120 120 struct dentry; 121 121 struct dentry *apei_get_debugfs_dir(void); 122 122 123 - #define apei_estatus_for_each_section(estatus, section) \ 124 - for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ 125 - (void *)section - (void *)estatus < estatus->data_length; \ 126 - section = (void *)(section+1) + section->error_data_length) 127 - 128 123 static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus) 129 124 { 130 125 if (estatus->raw_data_length)
+1 -1
drivers/acpi/apei/einj.c
··· 281 281 ((char *)trigger_tab + sizeof(struct acpi_einj_trigger)); 282 282 for (i = 0; i < trigger_tab->entry_count; i++) { 283 283 if (entry->action == ACPI_EINJ_TRIGGER_ERROR && 284 - entry->instruction == ACPI_EINJ_WRITE_REGISTER_VALUE && 284 + entry->instruction <= ACPI_EINJ_WRITE_REGISTER_VALUE && 285 285 entry->register_region.space_id == 286 286 ACPI_ADR_SPACE_SYSTEM_MEMORY && 287 287 (entry->register_region.address & param2) == (param1 & param2))
+8 -2
drivers/acpi/apei/ghes.c
··· 1157 1157 generic->header.source_id); 1158 1158 goto err_edac_unreg; 1159 1159 } 1160 - rc = request_irq(ghes->irq, ghes_irq_func, 0, "GHES IRQ", ghes); 1160 + rc = request_irq(ghes->irq, ghes_irq_func, IRQF_SHARED, 1161 + "GHES IRQ", ghes); 1161 1162 if (rc) { 1162 1163 pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n", 1163 1164 generic->header.source_id); ··· 1266 1265 if (acpi_disabled) 1267 1266 return -ENODEV; 1268 1267 1269 - if (hest_disable) { 1268 + switch (hest_disable) { 1269 + case HEST_NOT_FOUND: 1270 + return -ENODEV; 1271 + case HEST_DISABLED: 1270 1272 pr_info(GHES_PFX "HEST is not enabled!\n"); 1271 1273 return -EINVAL; 1274 + default: 1275 + break; 1272 1276 } 1273 1277 1274 1278 if (ghes_disable) {
+7 -6
drivers/acpi/apei/hest.c
··· 37 37 38 38 #define HEST_PFX "HEST: " 39 39 40 - bool hest_disable; 40 + int hest_disable; 41 41 EXPORT_SYMBOL_GPL(hest_disable); 42 42 43 43 /* HEST table parsing */ ··· 213 213 214 214 static int __init setup_hest_disable(char *str) 215 215 { 216 - hest_disable = 1; 216 + hest_disable = HEST_DISABLED; 217 217 return 0; 218 218 } 219 219 ··· 232 232 233 233 status = acpi_get_table(ACPI_SIG_HEST, 0, 234 234 (struct acpi_table_header **)&hest_tab); 235 - if (status == AE_NOT_FOUND) 236 - goto err; 237 - else if (ACPI_FAILURE(status)) { 235 + if (status == AE_NOT_FOUND) { 236 + hest_disable = HEST_NOT_FOUND; 237 + return; 238 + } else if (ACPI_FAILURE(status)) { 238 239 const char *msg = acpi_format_exception(status); 239 240 pr_err(HEST_PFX "Failed to get table, %s\n", msg); 240 241 rc = -EINVAL; ··· 258 257 pr_info(HEST_PFX "Table parsing has been initialized.\n"); 259 258 return; 260 259 err: 261 - hest_disable = 1; 260 + hest_disable = HEST_DISABLED; 262 261 }
+55 -2
drivers/acpi/arm64/iort.c
··· 693 693 return iort_iommu_xlate(info->dev, parent, streamid); 694 694 } 695 695 696 + static int nc_dma_get_range(struct device *dev, u64 *size) 697 + { 698 + struct acpi_iort_node *node; 699 + struct acpi_iort_named_component *ncomp; 700 + 701 + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, 702 + iort_match_node_callback, dev); 703 + if (!node) 704 + return -ENODEV; 705 + 706 + ncomp = (struct acpi_iort_named_component *)node->node_data; 707 + 708 + *size = ncomp->memory_address_limit >= 64 ? U64_MAX : 709 + 1ULL<<ncomp->memory_address_limit; 710 + 711 + return 0; 712 + } 713 + 696 714 /** 697 - * iort_set_dma_mask - Set-up dma mask for a device. 715 + * iort_dma_setup() - Set-up device DMA parameters. 698 716 * 699 717 * @dev: device to configure 718 + * @dma_addr: device DMA address result pointer 719 + * @size: DMA range size result pointer 700 720 */ 701 - void iort_set_dma_mask(struct device *dev) 721 + void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) 702 722 { 723 + u64 mask, dmaaddr = 0, size = 0, offset = 0; 724 + int ret, msb; 725 + 703 726 /* 704 727 * Set default coherent_dma_mask to 32 bit. Drivers are expected to 705 728 * setup the correct supported mask. ··· 736 713 */ 737 714 if (!dev->dma_mask) 738 715 dev->dma_mask = &dev->coherent_dma_mask; 716 + 717 + size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); 718 + 719 + if (dev_is_pci(dev)) 720 + ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); 721 + else 722 + ret = nc_dma_get_range(dev, &size); 723 + 724 + if (!ret) { 725 + msb = fls64(dmaaddr + size - 1); 726 + /* 727 + * Round-up to the power-of-two mask or set 728 + * the mask to the whole 64-bit address space 729 + * in case the DMA region covers the full 730 + * memory window. 731 + */ 732 + mask = msb == 64 ? U64_MAX : (1ULL << msb) - 1; 733 + /* 734 + * Limit coherent and dma mask based on size 735 + * retrieved from firmware. 736 + */ 737 + dev->coherent_dma_mask = mask; 738 + *dev->dma_mask = mask; 739 + } 740 + 741 + *dma_addr = dmaaddr; 742 + *dma_size = size; 743 + 744 + dev->dma_pfn_offset = PFN_DOWN(offset); 745 + dev_dbg(dev, "dma_pfn_offset(%#08llx)\n", offset); 739 746 } 740 747 741 748 /**
+1 -1
drivers/acpi/battery.c
··· 620 620 return count; 621 621 } 622 622 623 - static struct device_attribute alarm_attr = { 623 + static const struct device_attribute alarm_attr = { 624 624 .attr = {.name = "alarm", .mode = 0644}, 625 625 .show = acpi_battery_alarm_show, 626 626 .store = acpi_battery_alarm_store,
+14 -69
drivers/acpi/blacklist.c
··· 30 30 31 31 #include "internal.h" 32 32 33 - enum acpi_blacklist_predicates { 34 - all_versions, 35 - less_than_or_equal, 36 - equal, 37 - greater_than_or_equal, 38 - }; 39 - 40 - struct acpi_blacklist_item { 41 - char oem_id[7]; 42 - char oem_table_id[9]; 43 - u32 oem_revision; 44 - char *table; 45 - enum acpi_blacklist_predicates oem_revision_predicate; 46 - char *reason; 47 - u32 is_critical_error; 48 - }; 49 - 50 33 static struct dmi_system_id acpi_rev_dmi_table[] __initdata; 51 34 52 35 /* 53 36 * POLICY: If *anything* doesn't work, put it on the blacklist. 54 37 * If they are critical errors, mark it critical, and abort driver load. 55 38 */ 56 - static struct acpi_blacklist_item acpi_blacklist[] __initdata = { 39 + static struct acpi_platform_list acpi_blacklist[] __initdata = { 57 40 /* Compaq Presario 1700 */ 58 41 {"PTLTD ", " DSDT ", 0x06040000, ACPI_SIG_DSDT, less_than_or_equal, 59 42 "Multiple problems", 1}, ··· 50 67 {"IBM ", "TP600E ", 0x00000105, ACPI_SIG_DSDT, less_than_or_equal, 51 68 "Incorrect _ADR", 1}, 52 69 53 - {""} 70 + { } 54 71 }; 55 72 56 73 int __init acpi_blacklisted(void) 57 74 { 58 - int i = 0; 75 + int i; 59 76 int blacklisted = 0; 60 - struct acpi_table_header table_header; 61 77 62 - while (acpi_blacklist[i].oem_id[0] != '\0') { 63 - if (acpi_get_table_header(acpi_blacklist[i].table, 0, &table_header)) { 64 - i++; 65 - continue; 66 - } 78 + i = acpi_match_platform_list(acpi_blacklist); 79 + if (i >= 0) { 80 + pr_err(PREFIX "Vendor \"%6.6s\" System \"%8.8s\" Revision 0x%x has a known ACPI BIOS problem.\n", 81 + acpi_blacklist[i].oem_id, 82 + acpi_blacklist[i].oem_table_id, 83 + acpi_blacklist[i].oem_revision); 67 84 68 - if (strncmp(acpi_blacklist[i].oem_id, table_header.oem_id, 6)) { 69 - i++; 70 - continue; 71 - } 85 + pr_err(PREFIX "Reason: %s. This is a %s error\n", 86 + acpi_blacklist[i].reason, 87 + (acpi_blacklist[i].data ? 88 + "non-recoverable" : "recoverable")); 72 89 73 - if (strncmp 74 - (acpi_blacklist[i].oem_table_id, table_header.oem_table_id, 75 - 8)) { 76 - i++; 77 - continue; 78 - } 79 - 80 - if ((acpi_blacklist[i].oem_revision_predicate == all_versions) 81 - || (acpi_blacklist[i].oem_revision_predicate == 82 - less_than_or_equal 83 - && table_header.oem_revision <= 84 - acpi_blacklist[i].oem_revision) 85 - || (acpi_blacklist[i].oem_revision_predicate == 86 - greater_than_or_equal 87 - && table_header.oem_revision >= 88 - acpi_blacklist[i].oem_revision) 89 - || (acpi_blacklist[i].oem_revision_predicate == equal 90 - && table_header.oem_revision == 91 - acpi_blacklist[i].oem_revision)) { 92 - 93 - printk(KERN_ERR PREFIX 94 - "Vendor \"%6.6s\" System \"%8.8s\" " 95 - "Revision 0x%x has a known ACPI BIOS problem.\n", 96 - acpi_blacklist[i].oem_id, 97 - acpi_blacklist[i].oem_table_id, 98 - acpi_blacklist[i].oem_revision); 99 - 100 - printk(KERN_ERR PREFIX 101 - "Reason: %s. This is a %s error\n", 102 - acpi_blacklist[i].reason, 103 - (acpi_blacklist[i]. 104 - is_critical_error ? "non-recoverable" : 105 - "recoverable")); 106 - 107 - blacklisted = acpi_blacklist[i].is_critical_error; 108 - break; 109 - } else { 110 - i++; 111 - } 90 + blacklisted = acpi_blacklist[i].data; 112 91 } 113 92 114 93 (void)early_acpi_osi_init();
-3
drivers/acpi/bus.c
··· 995 995 996 996 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); 997 997 998 - /* It's safe to verify table checksums during late stage */ 999 - acpi_gbl_verify_table_checksum = TRUE; 1000 - 1001 998 /* enable workarounds, unless strict ACPI spec. compliance */ 1002 999 if (!acpi_strict) 1003 1000 acpi_gbl_enable_interpreter_slack = TRUE;
+126 -55
drivers/acpi/device_pm.c
··· 401 401 if (val != ACPI_NOTIFY_DEVICE_WAKE) 402 402 return; 403 403 404 + acpi_handle_debug(handle, "Wake notify\n"); 405 + 404 406 adev = acpi_bus_get_acpi_device(handle); 405 407 if (!adev) 406 408 return; ··· 411 409 412 410 if (adev->wakeup.flags.notifier_present) { 413 411 pm_wakeup_ws_event(adev->wakeup.ws, 0, acpi_s2idle_wakeup()); 414 - if (adev->wakeup.context.func) 412 + if (adev->wakeup.context.func) { 413 + acpi_handle_debug(handle, "Running %pF for %s\n", 414 + adev->wakeup.context.func, 415 + dev_name(adev->wakeup.context.dev)); 415 416 adev->wakeup.context.func(&adev->wakeup.context); 417 + } 416 418 } 417 419 418 420 mutex_unlock(&acpi_pm_notifier_lock); ··· 688 682 } 689 683 } 690 684 685 + static DEFINE_MUTEX(acpi_wakeup_lock); 686 + 687 + static int __acpi_device_wakeup_enable(struct acpi_device *adev, 688 + u32 target_state, int max_count) 689 + { 690 + struct acpi_device_wakeup *wakeup = &adev->wakeup; 691 + acpi_status status; 692 + int error = 0; 693 + 694 + mutex_lock(&acpi_wakeup_lock); 695 + 696 + if (wakeup->enable_count >= max_count) 697 + goto out; 698 + 699 + if (wakeup->enable_count > 0) 700 + goto inc; 701 + 702 + error = acpi_enable_wakeup_device_power(adev, target_state); 703 + if (error) 704 + goto out; 705 + 706 + status = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); 707 + if (ACPI_FAILURE(status)) { 708 + acpi_disable_wakeup_device_power(adev); 709 + error = -EIO; 710 + goto out; 711 + } 712 + 713 + inc: 714 + wakeup->enable_count++; 715 + 716 + out: 717 + mutex_unlock(&acpi_wakeup_lock); 718 + return error; 719 + } 720 + 691 721 /** 692 - * acpi_device_wakeup - Enable/disable wakeup functionality for device. 693 - * @adev: ACPI device to enable/disable wakeup functionality for. 722 + * acpi_device_wakeup_enable - Enable wakeup functionality for device. 723 + * @adev: ACPI device to enable wakeup functionality for. 694 724 * @target_state: State the system is transitioning into. 695 - * @enable: Whether to enable or disable the wakeup functionality. 696 725 * 697 - * Enable/disable the GPE associated with @adev so that it can generate 698 - * wakeup signals for the device in response to external (remote) events and 699 - * enable/disable device wakeup power. 726 + * Enable the GPE associated with @adev so that it can generate wakeup signals 727 + * for the device in response to external (remote) events and enable wakeup 728 + * power for it. 700 729 * 701 730 * Callers must ensure that @adev is a valid ACPI device node before executing 702 731 * this function. 703 732 */ 704 - static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, 705 - bool enable) 733 + static int acpi_device_wakeup_enable(struct acpi_device *adev, u32 target_state) 706 734 { 707 - struct acpi_device_wakeup *wakeup = &adev->wakeup; 708 - 709 - if (enable) { 710 - acpi_status res; 711 - int error; 712 - 713 - if (adev->wakeup.flags.enabled) 714 - return 0; 715 - 716 - error = acpi_enable_wakeup_device_power(adev, target_state); 717 - if (error) 718 - return error; 719 - 720 - res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); 721 - if (ACPI_FAILURE(res)) { 722 - acpi_disable_wakeup_device_power(adev); 723 - return -EIO; 724 - } 725 - adev->wakeup.flags.enabled = 1; 726 - } else if (adev->wakeup.flags.enabled) { 727 - acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); 728 - acpi_disable_wakeup_device_power(adev); 729 - adev->wakeup.flags.enabled = 0; 730 - } 731 - return 0; 735 + return __acpi_device_wakeup_enable(adev, target_state, 1); 732 736 } 733 737 734 738 /** 735 - * acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device. 736 - * @dev: Device to enable/disable to generate wakeup events. 737 - * @enable: Whether to enable or disable the wakeup functionality. 739 + * acpi_device_wakeup_disable - Disable wakeup functionality for device. 740 + * @adev: ACPI device to disable wakeup functionality for. 741 + * 742 + * Disable the GPE associated with @adev and disable wakeup power for it. 743 + * 744 + * Callers must ensure that @adev is a valid ACPI device node before executing 745 + * this function. 738 746 */ 739 - int acpi_pm_set_device_wakeup(struct device *dev, bool enable) 747 + static void acpi_device_wakeup_disable(struct acpi_device *adev) 748 + { 749 + struct acpi_device_wakeup *wakeup = &adev->wakeup; 750 + 751 + mutex_lock(&acpi_wakeup_lock); 752 + 753 + if (!wakeup->enable_count) 754 + goto out; 755 + 756 + acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); 757 + acpi_disable_wakeup_device_power(adev); 758 + 759 + wakeup->enable_count--; 760 + 761 + out: 762 + mutex_unlock(&acpi_wakeup_lock); 763 + } 764 + 765 + static int __acpi_pm_set_device_wakeup(struct device *dev, bool enable, 766 + int max_count) 740 767 { 741 768 struct acpi_device *adev; 742 769 int error; ··· 783 744 if (!acpi_device_can_wakeup(adev)) 784 745 return -EINVAL; 785 746 786 - error = acpi_device_wakeup(adev, acpi_target_system_state(), enable); 747 + if (!enable) { 748 + acpi_device_wakeup_disable(adev); 749 + dev_dbg(dev, "Wakeup disabled by ACPI\n"); 750 + return 0; 751 + } 752 + 753 + error = __acpi_device_wakeup_enable(adev, acpi_target_system_state(), 754 + max_count); 787 755 if (!error) 788 - dev_dbg(dev, "Wakeup %s by ACPI\n", enable ? "enabled" : "disabled"); 756 + dev_dbg(dev, "Wakeup enabled by ACPI\n"); 789 757 790 758 return error; 791 759 } 792 - EXPORT_SYMBOL(acpi_pm_set_device_wakeup); 760 + 761 + /** 762 + * acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device. 763 + * @dev: Device to enable/disable to generate wakeup events. 764 + * @enable: Whether to enable or disable the wakeup functionality. 765 + */ 766 + int acpi_pm_set_device_wakeup(struct device *dev, bool enable) 767 + { 768 + return __acpi_pm_set_device_wakeup(dev, enable, 1); 769 + } 770 + EXPORT_SYMBOL_GPL(acpi_pm_set_device_wakeup); 771 + 772 + /** 773 + * acpi_pm_set_bridge_wakeup - Enable/disable remote wakeup for given bridge. 774 + * @dev: Bridge device to enable/disable to generate wakeup events. 775 + * @enable: Whether to enable or disable the wakeup functionality. 776 + */ 777 + int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable) 778 + { 779 + return __acpi_pm_set_device_wakeup(dev, enable, INT_MAX); 780 + } 781 + EXPORT_SYMBOL_GPL(acpi_pm_set_bridge_wakeup); 793 782 794 783 /** 795 784 * acpi_dev_pm_low_power - Put ACPI device into a low-power state. ··· 867 800 868 801 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) > 869 802 PM_QOS_FLAGS_NONE; 870 - error = acpi_device_wakeup(adev, ACPI_STATE_S0, remote_wakeup); 871 - if (remote_wakeup && error) 872 - return -EAGAIN; 803 + if (remote_wakeup) { 804 + error = acpi_device_wakeup_enable(adev, ACPI_STATE_S0); 805 + if (error) 806 + return -EAGAIN; 807 + } 873 808 874 809 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 875 - if (error) 876 - acpi_device_wakeup(adev, ACPI_STATE_S0, false); 810 + if (error && remote_wakeup) 811 + acpi_device_wakeup_disable(adev); 877 812 878 813 return error; 879 814 } ··· 898 829 return 0; 899 830 900 831 error = acpi_dev_pm_full_power(adev); 901 - acpi_device_wakeup(adev, ACPI_STATE_S0, false); 832 + acpi_device_wakeup_disable(adev); 902 833 return error; 903 834 } 904 835 EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); ··· 953 884 954 885 target_state = acpi_target_system_state(); 955 886 wakeup = device_may_wakeup(dev) && acpi_device_can_wakeup(adev); 956 - error = acpi_device_wakeup(adev, target_state, wakeup); 957 - if (wakeup && error) 958 - return error; 887 + if (wakeup) { 888 + error = acpi_device_wakeup_enable(adev, target_state); 889 + if (error) 890 + return error; 891 + } 959 892 960 893 error = acpi_dev_pm_low_power(dev, adev, target_state); 961 - if (error) 962 - acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); 894 + if (error && wakeup) 895 + acpi_device_wakeup_disable(adev); 963 896 964 897 return error; 965 898 } ··· 984 913 return 0; 985 914 986 915 error = acpi_dev_pm_full_power(adev); 987 - acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); 916 + acpi_device_wakeup_disable(adev); 988 917 return error; 989 918 } 990 919 EXPORT_SYMBOL_GPL(acpi_dev_resume_early); ··· 1127 1056 */ 1128 1057 dev_pm_qos_hide_latency_limit(dev); 1129 1058 dev_pm_qos_hide_flags(dev); 1130 - acpi_device_wakeup(adev, ACPI_STATE_S0, false); 1059 + acpi_device_wakeup_disable(adev); 1131 1060 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 1132 1061 } 1133 1062 } ··· 1171 1100 dev_pm_domain_set(dev, &acpi_general_pm_domain); 1172 1101 if (power_on) { 1173 1102 acpi_dev_pm_full_power(adev); 1174 - acpi_device_wakeup(adev, ACPI_STATE_S0, false); 1103 + acpi_device_wakeup_disable(adev); 1175 1104 } 1176 1105 1177 1106 dev->pm_domain->detach = acpi_dev_pm_detach;
+1 -1
drivers/acpi/dock.c
··· 585 585 NULL 586 586 }; 587 587 588 - static struct attribute_group dock_attribute_group = { 588 + static const struct attribute_group dock_attribute_group = { 589 589 .attrs = dock_attributes 590 590 }; 591 591
+27 -21
drivers/acpi/ec.c
··· 112 112 EC_FLAGS_EVT_HANDLER_INSTALLED, /* _Qxx handlers installed */ 113 113 EC_FLAGS_STARTED, /* Driver is started */ 114 114 EC_FLAGS_STOPPED, /* Driver is stopped */ 115 - EC_FLAGS_COMMAND_STORM, /* GPE storms occurred to the 116 - * current command processing */ 115 + EC_FLAGS_GPE_MASKED, /* GPE masked */ 117 116 }; 118 117 119 118 #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ ··· 424 425 wake_up(&ec->wait); 425 426 } 426 427 427 - static void acpi_ec_set_storm(struct acpi_ec *ec, u8 flag) 428 + static void acpi_ec_mask_gpe(struct acpi_ec *ec) 428 429 { 429 - if (!test_bit(flag, &ec->flags)) { 430 + if (!test_bit(EC_FLAGS_GPE_MASKED, &ec->flags)) { 430 431 acpi_ec_disable_gpe(ec, false); 431 432 ec_dbg_drv("Polling enabled"); 432 - set_bit(flag, &ec->flags); 433 + set_bit(EC_FLAGS_GPE_MASKED, &ec->flags); 433 434 } 434 435 } 435 436 436 - static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag) 437 + static void acpi_ec_unmask_gpe(struct acpi_ec *ec) 437 438 { 438 - if (test_bit(flag, &ec->flags)) { 439 - clear_bit(flag, &ec->flags); 439 + if (test_bit(EC_FLAGS_GPE_MASKED, &ec->flags)) { 440 + clear_bit(EC_FLAGS_GPE_MASKED, &ec->flags); 440 441 acpi_ec_enable_gpe(ec, false); 441 442 ec_dbg_drv("Polling disabled"); 442 443 } ··· 463 464 464 465 static void acpi_ec_submit_query(struct acpi_ec *ec) 465 466 { 466 - acpi_ec_set_storm(ec, EC_FLAGS_COMMAND_STORM); 467 + acpi_ec_mask_gpe(ec); 467 468 if (!acpi_ec_event_enabled(ec)) 468 469 return; 469 470 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { ··· 479 480 if (test_and_clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) 480 481 ec_dbg_evt("Command(%s) unblocked", 481 482 acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY)); 482 - acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 483 + acpi_ec_unmask_gpe(ec); 483 484 } 484 485 485 486 static inline void __acpi_ec_enable_event(struct acpi_ec *ec) ··· 699 700 ++t->irq_count; 700 701 /* Allow triggering on 0 threshold */ 701 702 if (t->irq_count == ec_storm_threshold) 702 - acpi_ec_set_storm(ec, EC_FLAGS_COMMAND_STORM); 703 + acpi_ec_mask_gpe(ec); 703 704 } 704 705 } 705 706 out: ··· 797 798 798 799 spin_lock_irqsave(&ec->lock, tmp); 799 800 if (t->irq_count == ec_storm_threshold) 800 - acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 801 + acpi_ec_unmask_gpe(ec); 801 802 ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command)); 802 803 ec->curr = NULL; 803 804 /* Disable GPE for command processing (IBF=0/OBF=1) */ ··· 1585 1586 { 1586 1587 if (!boot_ec) 1587 1588 return false; 1588 - if (ec->handle == boot_ec->handle && 1589 - ec->gpe == boot_ec->gpe && 1590 - ec->command_addr == boot_ec->command_addr && 1589 + if (ec->command_addr == boot_ec->command_addr && 1591 1590 ec->data_addr == boot_ec->data_addr) 1592 1591 return true; 1593 1592 return false; ··· 1610 1613 1611 1614 if (acpi_is_boot_ec(ec)) { 1612 1615 boot_ec_is_ecdt = false; 1616 + /* 1617 + * Trust PNP0C09 namespace location rather than ECDT ID. 1618 + * 1619 + * But trust ECDT GPE rather than _GPE because of ASUS quirks, 1620 + * so do not change boot_ec->gpe to ec->gpe. 1621 + */ 1622 + boot_ec->handle = ec->handle; 1613 1623 acpi_handle_debug(ec->handle, "duplicated.\n"); 1614 1624 acpi_ec_free(ec); 1615 1625 ec = boot_ec; ··· 1751 1747 1752 1748 if (!boot_ec) 1753 1749 return -ENODEV; 1754 - /* 1755 - * The DSDT EC should have already been started in 1756 - * acpi_ec_add(). 1757 - */ 1750 + /* In case acpi_ec_ecdt_start() is called after acpi_ec_add() */ 1758 1751 if (!boot_ec_is_ecdt) 1759 1752 return -ENODEV; 1760 1753 1761 1754 /* 1762 1755 * At this point, the namespace and the GPE is initialized, so 1763 1756 * start to find the namespace objects and handle the events. 1757 + * 1758 + * Note: ec->handle can be valid if this function is called after 1759 + * acpi_ec_add(), hence the fast path. 1764 1760 */ 1765 - if (!acpi_ec_ecdt_get_handle(&handle)) 1761 + if (boot_ec->handle != ACPI_ROOT_OBJECT) 1762 + handle = boot_ec->handle; 1763 + else if (!acpi_ec_ecdt_get_handle(&handle)) 1766 1764 return -ENODEV; 1767 1765 return acpi_config_boot_ec(boot_ec, handle, true, true); 1768 1766 } ··· 2017 2011 return result; 2018 2012 2019 2013 /* Drivers must be started after acpi_ec_query_init() */ 2020 - ecdt_fail = acpi_ec_ecdt_start(); 2021 2014 dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver); 2015 + ecdt_fail = acpi_ec_ecdt_start(); 2022 2016 return ecdt_fail && dsdt_fail ? -ENODEV : 0; 2023 2017 } 2024 2018
+6
drivers/acpi/internal.h
··· 232 232 void acpi_init_properties(struct acpi_device *adev); 233 233 void acpi_free_properties(struct acpi_device *adev); 234 234 235 + #ifdef CONFIG_X86 236 + void acpi_extract_apple_properties(struct acpi_device *adev); 237 + #else 238 + static inline void acpi_extract_apple_properties(struct acpi_device *adev) {} 239 + #endif 240 + 235 241 /*-------------------------------------------------------------------------- 236 242 Watchdog 237 243 -------------------------------------------------------------------------- */
+8 -29
drivers/acpi/osi.c
··· 27 27 #include <linux/kernel.h> 28 28 #include <linux/acpi.h> 29 29 #include <linux/dmi.h> 30 + #include <linux/platform_data/x86/apple.h> 30 31 31 32 #include "internal.h" 32 33 ··· 258 257 } 259 258 EXPORT_SYMBOL(acpi_osi_is_win8); 260 259 261 - static void __init acpi_osi_dmi_darwin(bool enable, 262 - const struct dmi_system_id *d) 260 + static void __init acpi_osi_dmi_darwin(void) 263 261 { 264 - pr_notice("DMI detected to setup _OSI(\"Darwin\"): %s\n", d->ident); 262 + pr_notice("DMI detected to setup _OSI(\"Darwin\"): Apple hardware\n"); 265 263 osi_config.darwin_dmi = 1; 266 - __acpi_osi_setup_darwin(enable); 264 + __acpi_osi_setup_darwin(true); 267 265 } 268 266 269 267 static void __init acpi_osi_dmi_linux(bool enable, ··· 271 271 pr_notice("DMI detected to setup _OSI(\"Linux\"): %s\n", d->ident); 272 272 osi_config.linux_dmi = 1; 273 273 __acpi_osi_setup_linux(enable); 274 - } 275 - 276 - static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d) 277 - { 278 - acpi_osi_dmi_darwin(true, d); 279 - 280 - return 0; 281 274 } 282 275 283 276 static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) ··· 474 481 DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"), 475 482 }, 476 483 }, 477 - 478 - /* 479 - * Enable _OSI("Darwin") for all apple platforms. 480 - */ 481 - { 482 - .callback = dmi_enable_osi_darwin, 483 - .ident = "Apple hardware", 484 - .matches = { 485 - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 486 - }, 487 - }, 488 - { 489 - .callback = dmi_enable_osi_darwin, 490 - .ident = "Apple hardware", 491 - .matches = { 492 - DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), 493 - }, 494 - }, 495 484 {} 496 485 }; 497 486 498 487 static __init void acpi_osi_dmi_blacklisted(void) 499 488 { 500 489 dmi_check_system(acpi_osi_dmi_table); 490 + 491 + /* Enable _OSI("Darwin") for Apple platforms. */ 492 + if (x86_apple_machine) 493 + acpi_osi_dmi_darwin(); 501 494 } 502 495 503 496 int __init early_acpi_osi_init(void)
+2 -2
drivers/acpi/pci_root.c
··· 33 33 #include <linux/acpi.h> 34 34 #include <linux/slab.h> 35 35 #include <linux/dmi.h> 36 + #include <linux/platform_data/x86/apple.h> 36 37 #include <acpi/apei.h> /* for acpi_hest_init() */ 37 38 38 39 #include "internal.h" ··· 432 431 * been called successfully. We know the feature set supported by the 433 432 * platform, so avoid calling _OSC at all 434 433 */ 435 - 436 - if (dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) { 434 + if (x86_apple_machine) { 437 435 root->osc_control_set = ~OSC_PCI_EXPRESS_PME_CONTROL; 438 436 decode_osc_control(root, "OS assumes control of", 439 437 root->osc_control_set);
+18 -3
drivers/acpi/pmic/intel_pmic_xpower.c
··· 27 27 #define GPI1_LDO_ON (3 << 0) 28 28 #define GPI1_LDO_OFF (4 << 0) 29 29 30 + #define AXP288_ADC_TS_PIN_GPADC 0xf2 31 + #define AXP288_ADC_TS_PIN_ON 0xf3 32 + 30 33 static struct pmic_table power_table[] = { 31 34 { 32 35 .address = 0x00, ··· 212 209 static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) 213 210 { 214 211 u8 buf[2]; 212 + int ret; 215 213 216 - if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2)) 217 - return -EIO; 214 + ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, 215 + AXP288_ADC_TS_PIN_GPADC); 216 + if (ret) 217 + return ret; 218 218 219 - return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F); 219 + /* After switching to the GPADC pin give things some time to settle */ 220 + usleep_range(6000, 10000); 221 + 222 + ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); 223 + if (ret == 0) 224 + ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); 225 + 226 + regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON); 227 + 228 + return ret; 220 229 } 221 230 222 231 static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
+1 -1
drivers/acpi/processor_driver.c
··· 237 237 238 238 result = acpi_cppc_processor_probe(pr); 239 239 if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS)) 240 - dev_warn(&device->dev, "CPPC data invalid or not present\n"); 240 + dev_dbg(&device->dev, "CPPC data invalid or not present\n"); 241 241 242 242 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) 243 243 acpi_processor_power_init(pr);
+6
drivers/acpi/property.c
··· 339 339 340 340 INIT_LIST_HEAD(&adev->data.subnodes); 341 341 342 + if (!adev->handle) 343 + return; 344 + 342 345 /* 343 346 * Check if ACPI_DT_NAMESPACE_HID is present and inthat case we fill in 344 347 * Device Tree compatible properties for this device. ··· 376 373 if (acpi_of && !adev->flags.of_compatible_ok) 377 374 acpi_handle_info(adev->handle, 378 375 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n"); 376 + 377 + if (!adev->data.pointer) 378 + acpi_extract_apple_properties(adev); 379 379 } 380 380 381 381 static void acpi_destroy_nondev_subnodes(struct list_head *list)
+66 -22
drivers/acpi/resource.c
··· 573 573 return AE_OK; 574 574 } 575 575 576 + static int __acpi_dev_get_resources(struct acpi_device *adev, 577 + struct list_head *list, 578 + int (*preproc)(struct acpi_resource *, void *), 579 + void *preproc_data, char *method) 580 + { 581 + struct res_proc_context c; 582 + acpi_status status; 583 + 584 + if (!adev || !adev->handle || !list_empty(list)) 585 + return -EINVAL; 586 + 587 + if (!acpi_has_method(adev->handle, method)) 588 + return 0; 589 + 590 + c.list = list; 591 + c.preproc = preproc; 592 + c.preproc_data = preproc_data; 593 + c.count = 0; 594 + c.error = 0; 595 + status = acpi_walk_resources(adev->handle, method, 596 + acpi_dev_process_resource, &c); 597 + if (ACPI_FAILURE(status)) { 598 + acpi_dev_free_resource_list(list); 599 + return c.error ? c.error : -EIO; 600 + } 601 + 602 + return c.count; 603 + } 604 + 576 605 /** 577 606 * acpi_dev_get_resources - Get current resources of a device. 578 607 * @adev: ACPI device node to get the resources for. ··· 630 601 int (*preproc)(struct acpi_resource *, void *), 631 602 void *preproc_data) 632 603 { 633 - struct res_proc_context c; 634 - acpi_status status; 635 - 636 - if (!adev || !adev->handle || !list_empty(list)) 637 - return -EINVAL; 638 - 639 - if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) 640 - return 0; 641 - 642 - c.list = list; 643 - c.preproc = preproc; 644 - c.preproc_data = preproc_data; 645 - c.count = 0; 646 - c.error = 0; 647 - status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, 648 - acpi_dev_process_resource, &c); 649 - if (ACPI_FAILURE(status)) { 650 - acpi_dev_free_resource_list(list); 651 - return c.error ? c.error : -EIO; 652 - } 653 - 654 - return c.count; 604 + return __acpi_dev_get_resources(adev, list, preproc, preproc_data, 605 + METHOD_NAME__CRS); 655 606 } 656 607 EXPORT_SYMBOL_GPL(acpi_dev_get_resources); 608 + 609 + static int is_memory(struct acpi_resource *ares, void *not_used) 610 + { 611 + struct resource_win win; 612 + struct resource *res = &win.res; 613 + 614 + memset(&win, 0, sizeof(win)); 615 + 616 + return !(acpi_dev_resource_memory(ares, res) 617 + || acpi_dev_resource_address_space(ares, &win) 618 + || acpi_dev_resource_ext_address_space(ares, &win)); 619 + } 620 + 621 + /** 622 + * acpi_dev_get_dma_resources - Get current DMA resources of a device. 623 + * @adev: ACPI device node to get the resources for. 624 + * @list: Head of the resultant list of resources (must be empty). 625 + * 626 + * Evaluate the _DMA method for the given device node and process its 627 + * output. 628 + * 629 + * The resultant struct resource objects are put on the list pointed to 630 + * by @list, that must be empty initially, as members of struct 631 + * resource_entry objects. Callers of this routine should use 632 + * %acpi_dev_free_resource_list() to free that list. 633 + * 634 + * The number of resources in the output list is returned on success, 635 + * an error code reflecting the error condition is returned otherwise. 636 + */ 637 + int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list) 638 + { 639 + return __acpi_dev_get_resources(adev, list, is_memory, NULL, 640 + METHOD_NAME__DMA); 641 + } 642 + EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources); 657 643 658 644 /** 659 645 * acpi_dev_filter_resource_type - Filter ACPI resource according to resource
+3 -24
drivers/acpi/sbs.c
··· 31 31 #include <linux/jiffies.h> 32 32 #include <linux/delay.h> 33 33 #include <linux/power_supply.h> 34 - #include <linux/dmi.h> 34 + #include <linux/platform_data/x86/apple.h> 35 35 36 36 #include "sbshc.h" 37 37 #include "battery.h" ··· 57 57 static unsigned int cache_time = 1000; 58 58 module_param(cache_time, uint, 0644); 59 59 MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 60 - 61 - static bool sbs_manager_broken; 62 60 63 61 #define MAX_SBS_BAT 4 64 62 #define ACPI_SBS_BLOCK_MAX 32 ··· 474 476 return count; 475 477 } 476 478 477 - static struct device_attribute alarm_attr = { 479 + static const struct device_attribute alarm_attr = { 478 480 .attr = {.name = "alarm", .mode = 0644}, 479 481 .show = acpi_battery_alarm_show, 480 482 .store = acpi_battery_alarm_store, ··· 630 632 } 631 633 } 632 634 633 - static int disable_sbs_manager(const struct dmi_system_id *d) 634 - { 635 - sbs_manager_broken = true; 636 - return 0; 637 - } 638 - 639 - static struct dmi_system_id acpi_sbs_dmi_table[] = { 640 - { 641 - .callback = disable_sbs_manager, 642 - .ident = "Apple", 643 - .matches = { 644 - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc.") 645 - }, 646 - }, 647 - { }, 648 - }; 649 - 650 635 static int acpi_sbs_add(struct acpi_device *device) 651 636 { 652 637 struct acpi_sbs *sbs; 653 638 int result = 0; 654 639 int id; 655 - 656 - dmi_check_system(acpi_sbs_dmi_table); 657 640 658 641 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); 659 642 if (!sbs) { ··· 656 677 657 678 result = 0; 658 679 659 - if (!sbs_manager_broken) { 680 + if (!x86_apple_machine) { 660 681 result = acpi_manager_get_info(sbs); 661 682 if (!result) { 662 683 sbs->manager_present = 1;
+93 -11
drivers/acpi/scan.c
··· 13 13 #include <linux/dmi.h> 14 14 #include <linux/nls.h> 15 15 #include <linux/dma-mapping.h> 16 + #include <linux/platform_data/x86/apple.h> 16 17 17 18 #include <asm/pgtable.h> 18 19 ··· 1361 1360 } 1362 1361 1363 1362 /** 1363 + * acpi_dma_get_range() - Get device DMA parameters. 1364 + * 1365 + * @dev: device to configure 1366 + * @dma_addr: pointer device DMA address result 1367 + * @offset: pointer to the DMA offset result 1368 + * @size: pointer to DMA range size result 1369 + * 1370 + * Evaluate DMA regions and return respectively DMA region start, offset 1371 + * and size in dma_addr, offset and size on parsing success; it does not 1372 + * update the passed in values on failure. 1373 + * 1374 + * Return 0 on success, < 0 on failure. 1375 + */ 1376 + int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset, 1377 + u64 *size) 1378 + { 1379 + struct acpi_device *adev; 1380 + LIST_HEAD(list); 1381 + struct resource_entry *rentry; 1382 + int ret; 1383 + struct device *dma_dev = dev; 1384 + u64 len, dma_start = U64_MAX, dma_end = 0, dma_offset = 0; 1385 + 1386 + /* 1387 + * Walk the device tree chasing an ACPI companion with a _DMA 1388 + * object while we go. Stop if we find a device with an ACPI 1389 + * companion containing a _DMA method. 1390 + */ 1391 + do { 1392 + adev = ACPI_COMPANION(dma_dev); 1393 + if (adev && acpi_has_method(adev->handle, METHOD_NAME__DMA)) 1394 + break; 1395 + 1396 + dma_dev = dma_dev->parent; 1397 + } while (dma_dev); 1398 + 1399 + if (!dma_dev) 1400 + return -ENODEV; 1401 + 1402 + if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) { 1403 + acpi_handle_warn(adev->handle, "_DMA is valid only if _CRS is present\n"); 1404 + return -EINVAL; 1405 + } 1406 + 1407 + ret = acpi_dev_get_dma_resources(adev, &list); 1408 + if (ret > 0) { 1409 + list_for_each_entry(rentry, &list, node) { 1410 + if (dma_offset && rentry->offset != dma_offset) { 1411 + ret = -EINVAL; 1412 + dev_warn(dma_dev, "Can't handle multiple windows with different offsets\n"); 1413 + goto out; 1414 + } 1415 + dma_offset = rentry->offset; 1416 + 1417 + /* Take lower and upper limits */ 1418 + if (rentry->res->start < dma_start) 1419 + dma_start = rentry->res->start; 1420 + if (rentry->res->end > dma_end) 1421 + dma_end = rentry->res->end; 1422 + } 1423 + 1424 + if (dma_start >= dma_end) { 1425 + ret = -EINVAL; 1426 + dev_dbg(dma_dev, "Invalid DMA regions configuration\n"); 1427 + goto out; 1428 + } 1429 + 1430 + *dma_addr = dma_start - dma_offset; 1431 + len = dma_end - dma_start; 1432 + *size = max(len, len + 1); 1433 + *offset = dma_offset; 1434 + } 1435 + out: 1436 + acpi_dev_free_resource_list(&list); 1437 + 1438 + return ret >= 0 ? 0 : ret; 1439 + } 1440 + 1441 + /** 1364 1442 * acpi_dma_configure - Set-up DMA configuration for the device. 1365 1443 * @dev: The pointer to the device 1366 1444 * @attr: device dma attributes ··· 1447 1367 int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr) 1448 1368 { 1449 1369 const struct iommu_ops *iommu; 1450 - u64 size; 1370 + u64 dma_addr = 0, size = 0; 1451 1371 1452 - iort_set_dma_mask(dev); 1372 + iort_dma_setup(dev, &dma_addr, &size); 1453 1373 1454 1374 iommu = iort_iommu_configure(dev); 1455 1375 if (IS_ERR(iommu) && PTR_ERR(iommu) == -EPROBE_DEFER) 1456 1376 return -EPROBE_DEFER; 1457 1377 1458 - size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); 1459 - /* 1460 - * Assume dma valid range starts at 0 and covers the whole 1461 - * coherent_dma_mask. 1462 - */ 1463 - arch_setup_dma_ops(dev, 0, size, iommu, attr == DEV_DMA_COHERENT); 1378 + arch_setup_dma_ops(dev, dma_addr, size, 1379 + iommu, attr == DEV_DMA_COHERENT); 1464 1380 1465 1381 return 0; 1466 1382 } ··· 1527 1451 { 1528 1452 struct list_head resource_list; 1529 1453 bool is_spi_i2c_slave = false; 1454 + 1455 + /* Macs use device properties in lieu of _CRS resources */ 1456 + if (x86_apple_machine && 1457 + (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || 1458 + fwnode_property_present(&device->fwnode, "i2cAddress"))) 1459 + return true; 1530 1460 1531 1461 INIT_LIST_HEAD(&resource_list); 1532 1462 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave, ··· 2140 2058 acpi_get_spcr_uart_addr(); 2141 2059 } 2142 2060 2061 + acpi_gpe_apply_masked_gpes(); 2062 + acpi_update_all_gpes(); 2063 + 2143 2064 mutex_lock(&acpi_scan_lock); 2144 2065 /* 2145 2066 * Enumerate devices in the ACPI namespace. ··· 2166 2081 goto out; 2167 2082 } 2168 2083 } 2169 - 2170 - acpi_gpe_apply_masked_gpes(); 2171 - acpi_update_all_gpes(); 2172 2084 2173 2085 acpi_scan_initialized = true; 2174 2086
+1 -1
drivers/acpi/sleep.c
··· 1044 1044 .resume = acpi_restore_bm_rld, 1045 1045 }; 1046 1046 1047 - void acpi_sleep_syscore_init(void) 1047 + static void acpi_sleep_syscore_init(void) 1048 1048 { 1049 1049 register_syscore_ops(&acpi_sleep_syscore_ops); 1050 1050 }
+26 -10
drivers/acpi/spcr.c
··· 53 53 */ 54 54 static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb) 55 55 { 56 + bool xgene_8250 = false; 57 + 56 58 if (tb->interface_type != ACPI_DBG2_16550_COMPATIBLE) 57 59 return false; 58 60 59 - if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE)) 61 + if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) && 62 + memcmp(tb->header.oem_id, "HPE ", ACPI_OEM_ID_SIZE)) 60 63 return false; 61 64 62 65 if (!memcmp(tb->header.oem_table_id, "XGENESPC", 63 66 ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0) 64 - return true; 67 + xgene_8250 = true; 65 68 66 - return false; 69 + if (!memcmp(tb->header.oem_table_id, "ProLiant", 70 + ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1) 71 + xgene_8250 = true; 72 + 73 + return xgene_8250; 67 74 } 68 75 69 76 /** ··· 112 105 } 113 106 114 107 if (table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 115 - switch (table->serial_port.access_width) { 108 + switch (ACPI_ACCESS_BIT_WIDTH(( 109 + table->serial_port.access_width))) { 116 110 default: 117 111 pr_err("Unexpected SPCR Access Width. Defaulting to byte size\n"); 118 - case ACPI_ACCESS_SIZE_BYTE: 112 + case 8: 119 113 iotype = "mmio"; 120 114 break; 121 - case ACPI_ACCESS_SIZE_WORD: 115 + case 16: 122 116 iotype = "mmio16"; 123 117 break; 124 - case ACPI_ACCESS_SIZE_DWORD: 118 + case 32: 125 119 iotype = "mmio32"; 126 120 break; 127 121 } ··· 189 181 uart = "qdf2400_e44"; 190 182 } 191 183 192 - if (xgene_8250_erratum_present(table)) 184 + if (xgene_8250_erratum_present(table)) { 193 185 iotype = "mmio32"; 194 186 195 - snprintf(opts, sizeof(opts), "%s,%s,0x%llx,%d", uart, iotype, 196 - table->serial_port.address, baud_rate); 187 + /* for xgene v1 and v2 we don't know the clock rate of the 188 + * UART so don't attempt to change to the baud rate state 189 + * in the table because driver cannot calculate the dividers 190 + */ 191 + snprintf(opts, sizeof(opts), "%s,%s,0x%llx", uart, iotype, 192 + table->serial_port.address); 193 + } else { 194 + snprintf(opts, sizeof(opts), "%s,%s,0x%llx,%d", uart, iotype, 195 + table->serial_port.address, baud_rate); 196 + } 197 197 198 198 pr_info("console: %s\n", opts); 199 199
+88 -3
drivers/acpi/sysfs.c
··· 2 2 * sysfs.c - ACPI sysfs interface to userspace. 3 3 */ 4 4 5 + #define pr_fmt(fmt) "ACPI: " fmt 6 + 5 7 #include <linux/init.h> 6 8 #include <linux/kernel.h> 7 9 #include <linux/moduleparam.h> ··· 308 306 /* 309 307 * ACPI table sysfs I/F: 310 308 * /sys/firmware/acpi/tables/ 309 + * /sys/firmware/acpi/tables/data/ 311 310 * /sys/firmware/acpi/tables/dynamic/ 312 311 */ 313 312 314 313 static LIST_HEAD(acpi_table_attr_list); 315 314 static struct kobject *tables_kobj; 315 + static struct kobject *tables_data_kobj; 316 316 static struct kobject *dynamic_tables_kobj; 317 317 static struct kobject *hotplug_kobj; 318 318 ··· 327 323 int instance; 328 324 char filename[ACPI_NAME_SIZE+ACPI_INST_SIZE]; 329 325 struct list_head node; 326 + }; 327 + 328 + struct acpi_data_attr { 329 + struct bin_attribute attr; 330 + u64 addr; 330 331 }; 331 332 332 333 static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj, ··· 429 420 return AE_OK; 430 421 } 431 422 423 + static ssize_t acpi_data_show(struct file *filp, struct kobject *kobj, 424 + struct bin_attribute *bin_attr, char *buf, 425 + loff_t offset, size_t count) 426 + { 427 + struct acpi_data_attr *data_attr; 428 + void __iomem *base; 429 + ssize_t rc; 430 + 431 + data_attr = container_of(bin_attr, struct acpi_data_attr, attr); 432 + 433 + base = acpi_os_map_memory(data_attr->addr, data_attr->attr.size); 434 + if (!base) 435 + return -ENOMEM; 436 + rc = memory_read_from_buffer(buf, count, &offset, base, 437 + data_attr->attr.size); 438 + acpi_os_unmap_memory(base, data_attr->attr.size); 439 + 440 + return rc; 441 + } 442 + 443 + static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr) 444 + { 445 + struct acpi_table_bert *bert = th; 446 + 447 + if (bert->header.length < sizeof(struct acpi_table_bert) || 448 + bert->region_length < sizeof(struct acpi_hest_generic_status)) { 449 + kfree(data_attr); 450 + return -EINVAL; 451 + } 452 + data_attr->addr = bert->address; 453 + data_attr->attr.size = bert->region_length; 454 + data_attr->attr.attr.name = "BERT"; 455 + 456 + return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr); 457 + } 458 + 459 + static struct acpi_data_obj { 460 + char *name; 461 + int (*fn)(void *, struct acpi_data_attr *); 462 + } acpi_data_objs[] = { 463 + { ACPI_SIG_BERT, acpi_bert_data_init }, 464 + }; 465 + 466 + #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs) 467 + 468 + static int acpi_table_data_init(struct acpi_table_header *th) 469 + { 470 + struct acpi_data_attr *data_attr; 471 + int i; 472 + 473 + for (i = 0; i < NUM_ACPI_DATA_OBJS; i++) { 474 + if (ACPI_COMPARE_NAME(th->signature, acpi_data_objs[i].name)) { 475 + data_attr = kzalloc(sizeof(*data_attr), GFP_KERNEL); 476 + if (!data_attr) 477 + return -ENOMEM; 478 + sysfs_attr_init(&data_attr->attr.attr); 479 + data_attr->attr.read = acpi_data_show; 480 + data_attr->attr.attr.mode = 0400; 481 + return acpi_data_objs[i].fn(th, data_attr); 482 + } 483 + } 484 + return 0; 485 + } 486 + 432 487 static int acpi_tables_sysfs_init(void) 433 488 { 434 489 struct acpi_table_attr *table_attr; ··· 504 431 tables_kobj = kobject_create_and_add("tables", acpi_kobj); 505 432 if (!tables_kobj) 506 433 goto err; 434 + 435 + tables_data_kobj = kobject_create_and_add("data", tables_kobj); 436 + if (!tables_data_kobj) 437 + goto err_tables_data; 507 438 508 439 dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj); 509 440 if (!dynamic_tables_kobj) ··· 533 456 return ret; 534 457 } 535 458 list_add_tail(&table_attr->node, &acpi_table_attr_list); 459 + acpi_table_data_init(table_header); 536 460 } 537 461 538 462 kobject_uevent(tables_kobj, KOBJ_ADD); 463 + kobject_uevent(tables_data_kobj, KOBJ_ADD); 539 464 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); 540 465 541 466 return 0; 542 467 err_dynamic_tables: 468 + kobject_put(tables_data_kobj); 469 + err_tables_data: 543 470 kobject_put(tables_kobj); 544 471 err: 545 472 return -ENOMEM; ··· 633 552 static void acpi_global_event_handler(u32 event_type, acpi_handle device, 634 553 u32 event_number, void *context) 635 554 { 636 - if (event_type == ACPI_EVENT_TYPE_GPE) 555 + if (event_type == ACPI_EVENT_TYPE_GPE) { 637 556 gpe_count(event_number); 638 - 639 - if (event_type == ACPI_EVENT_TYPE_FIXED) 557 + pr_debug("GPE event 0x%02x\n", event_number); 558 + } else if (event_type == ACPI_EVENT_TYPE_FIXED) { 640 559 fixed_event_count(event_number); 560 + pr_debug("Fixed event 0x%02x\n", event_number); 561 + } else { 562 + pr_debug("Other event 0x%02x\n", event_number); 563 + } 641 564 } 642 565 643 566 static int get_status(u32 index, acpi_event_status *status,
+2 -2
drivers/acpi/tables.c
··· 740 740 741 741 if (acpi_verify_table_checksum) { 742 742 pr_info("Early table checksum verification enabled\n"); 743 - acpi_gbl_verify_table_checksum = TRUE; 743 + acpi_gbl_enable_table_validation = TRUE; 744 744 } else { 745 745 pr_info("Early table checksum verification disabled\n"); 746 - acpi_gbl_verify_table_checksum = FALSE; 746 + acpi_gbl_enable_table_validation = FALSE; 747 747 } 748 748 749 749 status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
+36
drivers/acpi/utils.c
··· 816 816 return 1; 817 817 } 818 818 __setup("acpi_backlight=", acpi_backlight); 819 + 820 + /** 821 + * acpi_match_platform_list - Check if the system matches with a given list 822 + * @plat: pointer to acpi_platform_list table terminated by a NULL entry 823 + * 824 + * Return the matched index if the system is found in the platform list. 825 + * Otherwise, return a negative error code. 826 + */ 827 + int acpi_match_platform_list(const struct acpi_platform_list *plat) 828 + { 829 + struct acpi_table_header hdr; 830 + int idx = 0; 831 + 832 + if (acpi_disabled) 833 + return -ENODEV; 834 + 835 + for (; plat->oem_id[0]; plat++, idx++) { 836 + if (ACPI_FAILURE(acpi_get_table_header(plat->table, 0, &hdr))) 837 + continue; 838 + 839 + if (strncmp(plat->oem_id, hdr.oem_id, ACPI_OEM_ID_SIZE)) 840 + continue; 841 + 842 + if (strncmp(plat->oem_table_id, hdr.oem_table_id, ACPI_OEM_TABLE_ID_SIZE)) 843 + continue; 844 + 845 + if ((plat->pred == all_versions) || 846 + (plat->pred == less_than_or_equal && hdr.oem_revision <= plat->oem_revision) || 847 + (plat->pred == greater_than_or_equal && hdr.oem_revision >= plat->oem_revision) || 848 + (plat->pred == equal && hdr.oem_revision == plat->oem_revision)) 849 + return idx; 850 + } 851 + 852 + return -ENODEV; 853 + } 854 + EXPORT_SYMBOL(acpi_match_platform_list);
+14
drivers/acpi/video_detect.c
··· 103 103 return 0; 104 104 } 105 105 106 + static int video_detect_force_none(const struct dmi_system_id *d) 107 + { 108 + acpi_backlight_dmi = acpi_backlight_none; 109 + return 0; 110 + } 111 + 106 112 static const struct dmi_system_id video_detect_dmi_table[] = { 107 113 /* On Samsung X360, the BIOS will set a flag (VDRV) if generic 108 114 * ACPI backlight device is used. This flag will definitively break ··· 317 311 .matches = { 318 312 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 319 313 DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), 314 + }, 315 + }, 316 + { 317 + .callback = video_detect_force_none, 318 + .ident = "Dell OptiPlex 9020M", 319 + .matches = { 320 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 321 + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), 320 322 }, 321 323 }, 322 324 { },
+141
drivers/acpi/x86/apple.c
··· 1 + /* 2 + * apple.c - Apple ACPI quirks 3 + * Copyright (C) 2017 Lukas Wunner <lukas@wunner.de> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License (version 2) as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #include <linux/acpi.h> 11 + #include <linux/bitmap.h> 12 + #include <linux/platform_data/x86/apple.h> 13 + #include <linux/uuid.h> 14 + 15 + /* Apple _DSM device properties GUID */ 16 + static const guid_t apple_prp_guid = 17 + GUID_INIT(0xa0b5b7c6, 0x1318, 0x441c, 18 + 0xb0, 0xc9, 0xfe, 0x69, 0x5e, 0xaf, 0x94, 0x9b); 19 + 20 + /** 21 + * acpi_extract_apple_properties - retrieve and convert Apple _DSM properties 22 + * @adev: ACPI device for which to retrieve the properties 23 + * 24 + * Invoke Apple's custom _DSM once to check the protocol version and once more 25 + * to retrieve the properties. They are marshalled up in a single package as 26 + * alternating key/value elements, unlike _DSD which stores them as a package 27 + * of 2-element packages. Convert to _DSD format and make them available under 28 + * the primary fwnode. 29 + */ 30 + void acpi_extract_apple_properties(struct acpi_device *adev) 31 + { 32 + unsigned int i, j = 0, newsize = 0, numprops, numvalid; 33 + union acpi_object *props, *newprops; 34 + unsigned long *valid = NULL; 35 + void *free_space; 36 + 37 + if (!x86_apple_machine) 38 + return; 39 + 40 + props = acpi_evaluate_dsm_typed(adev->handle, &apple_prp_guid, 1, 0, 41 + NULL, ACPI_TYPE_BUFFER); 42 + if (!props) 43 + return; 44 + 45 + if (!props->buffer.length) 46 + goto out_free; 47 + 48 + if (props->buffer.pointer[0] != 3) { 49 + acpi_handle_info(adev->handle, FW_INFO 50 + "unsupported properties version %*ph\n", 51 + props->buffer.length, props->buffer.pointer); 52 + goto out_free; 53 + } 54 + 55 + ACPI_FREE(props); 56 + props = acpi_evaluate_dsm_typed(adev->handle, &apple_prp_guid, 1, 1, 57 + NULL, ACPI_TYPE_PACKAGE); 58 + if (!props) 59 + return; 60 + 61 + numprops = props->package.count / 2; 62 + if (!numprops) 63 + goto out_free; 64 + 65 + valid = kcalloc(BITS_TO_LONGS(numprops), sizeof(long), GFP_KERNEL); 66 + if (!valid) 67 + goto out_free; 68 + 69 + /* newsize = key length + value length of each tuple */ 70 + for (i = 0; i < numprops; i++) { 71 + union acpi_object *key = &props->package.elements[i * 2]; 72 + union acpi_object *val = &props->package.elements[i * 2 + 1]; 73 + 74 + if ( key->type != ACPI_TYPE_STRING || 75 + (val->type != ACPI_TYPE_INTEGER && 76 + val->type != ACPI_TYPE_BUFFER)) 77 + continue; /* skip invalid properties */ 78 + 79 + __set_bit(i, valid); 80 + newsize += key->string.length + 1; 81 + if ( val->type == ACPI_TYPE_BUFFER) 82 + newsize += val->buffer.length; 83 + } 84 + 85 + numvalid = bitmap_weight(valid, numprops); 86 + if (numprops > numvalid) 87 + acpi_handle_info(adev->handle, FW_INFO 88 + "skipped %u properties: wrong type\n", 89 + numprops - numvalid); 90 + if (numvalid == 0) 91 + goto out_free; 92 + 93 + /* newsize += top-level package + 3 objects for each key/value tuple */ 94 + newsize += (1 + 3 * numvalid) * sizeof(union acpi_object); 95 + newprops = ACPI_ALLOCATE_ZEROED(newsize); 96 + if (!newprops) 97 + goto out_free; 98 + 99 + /* layout: top-level package | packages | key/value tuples | strings */ 100 + newprops->type = ACPI_TYPE_PACKAGE; 101 + newprops->package.count = numvalid; 102 + newprops->package.elements = &newprops[1]; 103 + free_space = &newprops[1 + 3 * numvalid]; 104 + 105 + for_each_set_bit(i, valid, numprops) { 106 + union acpi_object *key = &props->package.elements[i * 2]; 107 + union acpi_object *val = &props->package.elements[i * 2 + 1]; 108 + unsigned int k = 1 + numvalid + j * 2; /* index into newprops */ 109 + unsigned int v = k + 1; 110 + 111 + newprops[1 + j].type = ACPI_TYPE_PACKAGE; 112 + newprops[1 + j].package.count = 2; 113 + newprops[1 + j].package.elements = &newprops[k]; 114 + 115 + newprops[k].type = ACPI_TYPE_STRING; 116 + newprops[k].string.length = key->string.length; 117 + newprops[k].string.pointer = free_space; 118 + memcpy(free_space, key->string.pointer, key->string.length); 119 + free_space += key->string.length + 1; 120 + 121 + newprops[v].type = val->type; 122 + if (val->type == ACPI_TYPE_INTEGER) { 123 + newprops[v].integer.value = val->integer.value; 124 + } else { 125 + newprops[v].buffer.length = val->buffer.length; 126 + newprops[v].buffer.pointer = free_space; 127 + memcpy(free_space, val->buffer.pointer, 128 + val->buffer.length); 129 + free_space += val->buffer.length; 130 + } 131 + j++; /* count valid properties */ 132 + } 133 + WARN_ON(free_space != (void *)newprops + newsize); 134 + 135 + adev->data.properties = newprops; 136 + adev->data.pointer = newprops; 137 + 138 + out_free: 139 + ACPI_FREE(props); 140 + kfree(valid); 141 + }
+25 -39
drivers/cpufreq/intel_pstate.c
··· 2194 2194 PPC, 2195 2195 }; 2196 2196 2197 - struct hw_vendor_info { 2198 - u16 valid; 2199 - char oem_id[ACPI_OEM_ID_SIZE]; 2200 - char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; 2201 - int oem_pwr_table; 2202 - }; 2203 - 2204 2197 /* Hardware vendor-specific info that has its own power management modes */ 2205 - static struct hw_vendor_info vendor_info[] __initdata = { 2206 - {1, "HP ", "ProLiant", PSS}, 2207 - {1, "ORACLE", "X4-2 ", PPC}, 2208 - {1, "ORACLE", "X4-2L ", PPC}, 2209 - {1, "ORACLE", "X4-2B ", PPC}, 2210 - {1, "ORACLE", "X3-2 ", PPC}, 2211 - {1, "ORACLE", "X3-2L ", PPC}, 2212 - {1, "ORACLE", "X3-2B ", PPC}, 2213 - {1, "ORACLE", "X4470M2 ", PPC}, 2214 - {1, "ORACLE", "X4270M3 ", PPC}, 2215 - {1, "ORACLE", "X4270M2 ", PPC}, 2216 - {1, "ORACLE", "X4170M2 ", PPC}, 2217 - {1, "ORACLE", "X4170 M3", PPC}, 2218 - {1, "ORACLE", "X4275 M3", PPC}, 2219 - {1, "ORACLE", "X6-2 ", PPC}, 2220 - {1, "ORACLE", "Sudbury ", PPC}, 2221 - {0, "", ""}, 2198 + static struct acpi_platform_list plat_info[] __initdata = { 2199 + {"HP ", "ProLiant", 0, ACPI_SIG_FADT, all_versions, 0, PSS}, 2200 + {"ORACLE", "X4-2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2201 + {"ORACLE", "X4-2L ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2202 + {"ORACLE", "X4-2B ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2203 + {"ORACLE", "X3-2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2204 + {"ORACLE", "X3-2L ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2205 + {"ORACLE", "X3-2B ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2206 + {"ORACLE", "X4470M2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2207 + {"ORACLE", "X4270M3 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2208 + {"ORACLE", "X4270M2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2209 + {"ORACLE", "X4170M2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2210 + {"ORACLE", "X4170 M3", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2211 + {"ORACLE", "X4275 M3", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2212 + {"ORACLE", "X6-2 ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2213 + {"ORACLE", "Sudbury ", 0, ACPI_SIG_FADT, all_versions, 0, PPC}, 2214 + { } /* End */ 2222 2215 }; 2223 2216 2224 2217 static bool __init intel_pstate_platform_pwr_mgmt_exists(void) 2225 2218 { 2226 - struct acpi_table_header hdr; 2227 - struct hw_vendor_info *v_info; 2228 2219 const struct x86_cpu_id *id; 2229 2220 u64 misc_pwr; 2221 + int idx; 2230 2222 2231 2223 id = x86_match_cpu(intel_pstate_cpu_oob_ids); 2232 2224 if (id) { ··· 2227 2235 return true; 2228 2236 } 2229 2237 2230 - if (acpi_disabled || 2231 - ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) 2238 + idx = acpi_match_platform_list(plat_info); 2239 + if (idx < 0) 2232 2240 return false; 2233 2241 2234 - for (v_info = vendor_info; v_info->valid; v_info++) { 2235 - if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) && 2236 - !strncmp(hdr.oem_table_id, v_info->oem_table_id, 2237 - ACPI_OEM_TABLE_ID_SIZE)) 2238 - switch (v_info->oem_pwr_table) { 2239 - case PSS: 2240 - return intel_pstate_no_acpi_pss(); 2241 - case PPC: 2242 - return intel_pstate_has_acpi_ppc() && 2243 - (!force_load); 2244 - } 2242 + switch (plat_info[idx].data) { 2243 + case PSS: 2244 + return intel_pstate_no_acpi_pss(); 2245 + case PPC: 2246 + return intel_pstate_has_acpi_ppc() && !force_load; 2245 2247 } 2246 2248 2247 2249 return false;
+2 -3
drivers/firmware/efi/apple-properties.c
··· 18 18 #define pr_fmt(fmt) "apple-properties: " fmt 19 19 20 20 #include <linux/bootmem.h> 21 - #include <linux/dmi.h> 22 21 #include <linux/efi.h> 22 + #include <linux/platform_data/x86/apple.h> 23 23 #include <linux/property.h> 24 24 #include <linux/slab.h> 25 25 #include <linux/ucs2_string.h> ··· 191 191 u64 pa_data; 192 192 int ret; 193 193 194 - if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc.") && 195 - !dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.")) 194 + if (!x86_apple_machine) 196 195 return 0; 197 196 198 197 pa_data = boot_params.hdr.setup_data;
+2 -10
drivers/firmware/efi/cper.c
··· 606 606 const struct acpi_hest_generic_status *estatus) 607 607 { 608 608 struct acpi_hest_generic_data *gdata; 609 - unsigned int data_len; 610 609 int sec_no = 0; 611 610 char newpfx[64]; 612 611 __u16 severity; ··· 616 617 "It has been corrected by h/w " 617 618 "and requires no further action"); 618 619 printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); 619 - data_len = estatus->data_length; 620 - gdata = (struct acpi_hest_generic_data *)(estatus + 1); 621 620 snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); 622 621 623 - while (data_len >= acpi_hest_get_size(gdata)) { 622 + apei_estatus_for_each_section(estatus, gdata) { 624 623 cper_estatus_print_section(newpfx, gdata, sec_no); 625 - data_len -= acpi_hest_get_record_size(gdata); 626 - gdata = acpi_hest_get_next(gdata); 627 624 sec_no++; 628 625 } 629 626 } ··· 648 653 if (rc) 649 654 return rc; 650 655 data_len = estatus->data_length; 651 - gdata = (struct acpi_hest_generic_data *)(estatus + 1); 652 656 653 - while (data_len >= acpi_hest_get_size(gdata)) { 657 + apei_estatus_for_each_section(estatus, gdata) { 654 658 gedata_len = acpi_hest_get_error_length(gdata); 655 659 if (gedata_len > data_len - acpi_hest_get_size(gdata)) 656 660 return -EINVAL; 657 - 658 661 data_len -= acpi_hest_get_record_size(gdata); 659 - gdata = acpi_hest_get_next(gdata); 660 662 } 661 663 if (data_len) 662 664 return -EINVAL;
+1 -3
drivers/mailbox/pcc.c
··· 457 457 /* Search for PCCT */ 458 458 status = acpi_get_table(ACPI_SIG_PCCT, 0, &pcct_tbl); 459 459 460 - if (ACPI_FAILURE(status) || !pcct_tbl) { 461 - pr_warn("PCCT header not found.\n"); 460 + if (ACPI_FAILURE(status) || !pcct_tbl) 462 461 return -ENODEV; 463 - } 464 462 465 463 count = acpi_table_parse_entries(ACPI_SIG_PCCT, 466 464 sizeof(struct acpi_table_pcct),
+2 -2
drivers/pci/pci-acpi.c
··· 573 573 { 574 574 while (bus->parent) { 575 575 if (acpi_pm_device_can_wakeup(&bus->self->dev)) 576 - return acpi_pm_set_device_wakeup(&bus->self->dev, enable); 576 + return acpi_pm_set_bridge_wakeup(&bus->self->dev, enable); 577 577 578 578 bus = bus->parent; 579 579 } ··· 581 581 /* We have reached the root bus. */ 582 582 if (bus->bridge) { 583 583 if (acpi_pm_device_can_wakeup(bus->bridge)) 584 - return acpi_pm_set_device_wakeup(bus->bridge, enable); 584 + return acpi_pm_set_bridge_wakeup(bus->bridge, enable); 585 585 } 586 586 return 0; 587 587 }
+1 -3
drivers/pci/pci-driver.c
··· 647 647 static void pci_pm_default_resume(struct pci_dev *pci_dev) 648 648 { 649 649 pci_fixup_device(pci_fixup_resume, pci_dev); 650 - 651 - if (!pci_has_subordinate(pci_dev)) 652 - pci_enable_wake(pci_dev, PCI_D0, false); 650 + pci_enable_wake(pci_dev, PCI_D0, false); 653 651 } 654 652 655 653 static void pci_pm_default_suspend(struct pci_dev *pci_dev)
+7
drivers/pci/pci.c
··· 1912 1912 { 1913 1913 int ret = 0; 1914 1914 1915 + /* 1916 + * Bridges can only signal wakeup on behalf of subordinate devices, 1917 + * but that is set up elsewhere, so skip them. 1918 + */ 1919 + if (pci_has_subordinate(dev)) 1920 + return 0; 1921 + 1915 1922 /* Don't do the same thing twice in a row for one device. */ 1916 1923 if (!!enable == !!dev->wakeup_prepared) 1917 1924 return 0;
+3 -2
drivers/pci/quirks.c
··· 25 25 #include <linux/sched.h> 26 26 #include <linux/ktime.h> 27 27 #include <linux/mm.h> 28 + #include <linux/platform_data/x86/apple.h> 28 29 #include <asm/dma.h> /* isa_dma_bridge_buggy */ 29 30 #include "pci.h" 30 31 ··· 3448 3447 { 3449 3448 acpi_handle bridge, SXIO, SXFP, SXLV; 3450 3449 3451 - if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.")) 3450 + if (!x86_apple_machine) 3452 3451 return; 3453 3452 if (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) 3454 3453 return; ··· 3493 3492 struct pci_dev *sibling = NULL; 3494 3493 struct pci_dev *nhi = NULL; 3495 3494 3496 - if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.")) 3495 + if (!x86_apple_machine) 3497 3496 return; 3498 3497 if (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM) 3499 3498 return;
+32
drivers/spi/spi.c
··· 41 41 #include <linux/acpi.h> 42 42 #include <linux/highmem.h> 43 43 #include <linux/idr.h> 44 + #include <linux/platform_data/x86/apple.h> 44 45 45 46 #define CREATE_TRACE_POINTS 46 47 #include <trace/events/spi.h> ··· 1693 1692 #endif 1694 1693 1695 1694 #ifdef CONFIG_ACPI 1695 + static void acpi_spi_parse_apple_properties(struct spi_device *spi) 1696 + { 1697 + struct acpi_device *dev = ACPI_COMPANION(&spi->dev); 1698 + const union acpi_object *obj; 1699 + 1700 + if (!x86_apple_machine) 1701 + return; 1702 + 1703 + if (!acpi_dev_get_property(dev, "spiSclkPeriod", ACPI_TYPE_BUFFER, &obj) 1704 + && obj->buffer.length >= 4) 1705 + spi->max_speed_hz = NSEC_PER_SEC / *(u32 *)obj->buffer.pointer; 1706 + 1707 + if (!acpi_dev_get_property(dev, "spiWordSize", ACPI_TYPE_BUFFER, &obj) 1708 + && obj->buffer.length == 8) 1709 + spi->bits_per_word = *(u64 *)obj->buffer.pointer; 1710 + 1711 + if (!acpi_dev_get_property(dev, "spiBitOrder", ACPI_TYPE_BUFFER, &obj) 1712 + && obj->buffer.length == 8 && !*(u64 *)obj->buffer.pointer) 1713 + spi->mode |= SPI_LSB_FIRST; 1714 + 1715 + if (!acpi_dev_get_property(dev, "spiSPO", ACPI_TYPE_BUFFER, &obj) 1716 + && obj->buffer.length == 8 && *(u64 *)obj->buffer.pointer) 1717 + spi->mode |= SPI_CPOL; 1718 + 1719 + if (!acpi_dev_get_property(dev, "spiSPH", ACPI_TYPE_BUFFER, &obj) 1720 + && obj->buffer.length == 8 && *(u64 *)obj->buffer.pointer) 1721 + spi->mode |= SPI_CPHA; 1722 + } 1723 + 1696 1724 static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) 1697 1725 { 1698 1726 struct spi_device *spi = data; ··· 1794 1764 ret = acpi_dev_get_resources(adev, &resource_list, 1795 1765 acpi_spi_add_resource, spi); 1796 1766 acpi_dev_free_resource_list(&resource_list); 1767 + 1768 + acpi_spi_parse_apple_properties(spi); 1797 1769 1798 1770 if (ret < 0 || !spi->max_speed_hz) { 1799 1771 spi_dev_put(spi);
+4 -9
drivers/thunderbolt/icm.c
··· 13 13 */ 14 14 15 15 #include <linux/delay.h> 16 - #include <linux/dmi.h> 17 16 #include <linux/mutex.h> 18 17 #include <linux/pci.h> 18 + #include <linux/platform_data/x86/apple.h> 19 19 #include <linux/sizes.h> 20 20 #include <linux/slab.h> 21 21 #include <linux/workqueue.h> ··· 102 102 return (u64)route_hi << 32 | route_lo; 103 103 } 104 104 105 - static inline bool is_apple(void) 106 - { 107 - return dmi_match(DMI_BOARD_VENDOR, "Apple Inc."); 108 - } 109 - 110 105 static bool icm_match(const struct tb_cfg_request *req, 111 106 const struct ctl_pkg *pkg) 112 107 { ··· 171 176 172 177 static bool icm_fr_is_supported(struct tb *tb) 173 178 { 174 - return !is_apple(); 179 + return !x86_apple_machine; 175 180 } 176 181 177 182 static inline int icm_fr_get_switch_index(u32 port) ··· 512 517 * Starting from Alpine Ridge we can use ICM on Apple machines 513 518 * as well. We just need to reset and re-enable it first. 514 519 */ 515 - if (!is_apple()) 520 + if (!x86_apple_machine) 516 521 return true; 517 522 518 523 /* ··· 1006 1011 * don't provide images publicly either. To be on the safe side 1007 1012 * prevent root switch NVM upgrade on Macs for now. 1008 1013 */ 1009 - tb->root_switch->no_nvm_upgrade = is_apple(); 1014 + tb->root_switch->no_nvm_upgrade = x86_apple_machine; 1010 1015 1011 1016 ret = tb_switch_add(tb->root_switch); 1012 1017 if (ret)
+2 -2
drivers/thunderbolt/tb.c
··· 7 7 #include <linux/slab.h> 8 8 #include <linux/errno.h> 9 9 #include <linux/delay.h> 10 - #include <linux/dmi.h> 10 + #include <linux/platform_data/x86/apple.h> 11 11 12 12 #include "tb.h" 13 13 #include "tb_regs.h" ··· 453 453 struct tb_cm *tcm; 454 454 struct tb *tb; 455 455 456 - if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.")) 456 + if (!x86_apple_machine) 457 457 return NULL; 458 458 459 459 tb = tb_domain_alloc(nhi, sizeof(*tcm));
+1
include/acpi/acnames.h
··· 54 54 #define METHOD_NAME__CLS "_CLS" 55 55 #define METHOD_NAME__CRS "_CRS" 56 56 #define METHOD_NAME__DDN "_DDN" 57 + #define METHOD_NAME__DMA "_DMA" 57 58 #define METHOD_NAME__HID "_HID" 58 59 #define METHOD_NAME__INI "_INI" 59 60 #define METHOD_NAME__PLD "_PLD"
+2 -2
include/acpi/acpi.h
··· 58 58 #include <acpi/actypes.h> /* ACPICA data types and structures */ 59 59 #include <acpi/acexcep.h> /* ACPICA exceptions */ 60 60 #include <acpi/actbl.h> /* ACPI table definitions */ 61 - #include <acpi/acoutput.h> /* Error output and Debug macros */ 62 61 #include <acpi/acrestyp.h> /* Resource Descriptor structs */ 62 + #include <acpi/platform/acenvex.h> /* Extra environment-specific items */ 63 + #include <acpi/acoutput.h> /* Error output and Debug macros */ 63 64 #include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */ 64 65 #include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */ 65 - #include <acpi/platform/acenvex.h> /* Extra environment-specific items */ 66 66 67 67 #endif /* __ACPI_H__ */
+8 -1
include/acpi/acpi_bus.h
··· 316 316 struct acpi_device_wakeup_flags { 317 317 u8 valid:1; /* Can successfully enable wakeup? */ 318 318 u8 notifier_present:1; /* Wake-up notify handler has been installed */ 319 - u8 enabled:1; /* Enabled for wakeup */ 320 319 }; 321 320 322 321 struct acpi_device_wakeup_context { ··· 332 333 struct acpi_device_wakeup_context context; 333 334 struct wakeup_source *ws; 334 335 int prepare_count; 336 + int enable_count; 335 337 }; 336 338 337 339 struct acpi_device_physical_node { ··· 578 578 579 579 bool acpi_dma_supported(struct acpi_device *adev); 580 580 enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev); 581 + int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset, 582 + u64 *size); 581 583 int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr); 582 584 void acpi_dma_deconfigure(struct device *dev); 583 585 ··· 608 606 bool acpi_pm_device_can_wakeup(struct device *dev); 609 607 int acpi_pm_device_sleep_state(struct device *, int *, int); 610 608 int acpi_pm_set_device_wakeup(struct device *dev, bool enable); 609 + int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable); 611 610 #else 612 611 static inline void acpi_pm_wakeup_event(struct device *dev) 613 612 { ··· 636 633 m : ACPI_STATE_D0; 637 634 } 638 635 static inline int acpi_pm_set_device_wakeup(struct device *dev, bool enable) 636 + { 637 + return -ENODEV; 638 + } 639 + static inline int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable) 639 640 { 640 641 return -ENODEV; 641 642 }
+8 -7
include/acpi/acpixf.h
··· 46 46 47 47 /* Current ACPICA subsystem version in YYYYMMDD format */ 48 48 49 - #define ACPI_CA_VERSION 0x20170531 49 + #define ACPI_CA_VERSION 0x20170728 50 50 51 51 #include <acpi/acconfig.h> 52 52 #include <acpi/actypes.h> ··· 160 160 ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE); 161 161 162 162 /* 163 - * Whether or not to verify the table checksum before installation. Set 164 - * this to TRUE to verify the table checksum before install it to the table 165 - * manager. Note that enabling this option causes errors to happen in some 166 - * OSPMs during early initialization stages. Default behavior is to do such 167 - * verification. 163 + * Whether or not to validate (map) an entire table to verify 164 + * checksum/duplication in early stage before install. Set this to TRUE to 165 + * allow early table validation before install it to the table manager. 166 + * Note that enabling this option causes errors to happen in some OSPMs 167 + * during early initialization stages. Default behavior is to allow such 168 + * validation. 168 169 */ 169 - ACPI_INIT_GLOBAL(u8, acpi_gbl_verify_table_checksum, TRUE); 170 + ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_table_validation, TRUE); 170 171 171 172 /* 172 173 * Optionally enable output from the AML Debug Object.
-7
include/acpi/acrestyp.h
··· 377 377 u64 address; 378 378 }; 379 379 380 - /* Generic Address Space Access Sizes */ 381 - #define ACPI_ACCESS_SIZE_UNDEFINED 0 382 - #define ACPI_ACCESS_SIZE_BYTE 1 383 - #define ACPI_ACCESS_SIZE_WORD 2 384 - #define ACPI_ACCESS_SIZE_DWORD 3 385 - #define ACPI_ACCESS_SIZE_QWORD 4 386 - 387 380 struct acpi_resource_gpio { 388 381 u8 revision_id; 389 382 u8 connection_type;
+1
include/acpi/actbl.h
··· 394 394 #define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1) /* Physical address, internally mapped */ 395 395 #define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL (2) /* Virtual address, internallly allocated */ 396 396 #define ACPI_TABLE_ORIGIN_MASK (3) 397 + #define ACPI_TABLE_IS_VERIFIED (4) 397 398 #define ACPI_TABLE_IS_LOADED (8) 398 399 399 400 /*
+28 -2
include/acpi/actbl2.h
··· 76 76 #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ 77 77 #define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ 78 78 #define ACPI_SIG_MTMR "MTMR" /* MID Timer table */ 79 + #define ACPI_SIG_SDEI "SDEI" /* Software Delegated Exception Interface Table */ 79 80 #define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ 80 81 #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ 81 82 #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ ··· 665 664 * IORT - IO Remapping Table 666 665 * 667 666 * Conforms to "IO Remapping Table System Software on ARM Platforms", 668 - * Document number: ARM DEN 0049B, October 2015 667 + * Document number: ARM DEN 0049C, May 2017 669 668 * 670 669 ******************************************************************************/ 671 670 ··· 780 779 #define ACPI_IORT_SMMU_V2 0x00000001 /* Generic SMMUv2 */ 781 780 #define ACPI_IORT_SMMU_CORELINK_MMU400 0x00000002 /* ARM Corelink MMU-400 */ 782 781 #define ACPI_IORT_SMMU_CORELINK_MMU500 0x00000003 /* ARM Corelink MMU-500 */ 782 + #define ACPI_IORT_SMMU_CORELINK_MMU401 0x00000004 /* ARM Corelink MMU-401 */ 783 + #define ACPI_IORT_SMMU_CAVIUM_THUNDERX 0x00000005 /* Cavium thunder_x SMMUv2 */ 783 784 784 785 /* Masks for Flags field above */ 785 786 ··· 802 799 u32 flags; 803 800 u32 reserved; 804 801 u64 vatos_address; 805 - u32 model; /* O: generic SMMUv3 */ 802 + u32 model; 806 803 u32 event_gsiv; 807 804 u32 pri_gsiv; 808 805 u32 gerr_gsiv; 809 806 u32 sync_gsiv; 807 + u8 pxm; 808 + u8 reserved1; 809 + u16 reserved2; 810 810 }; 811 + 812 + /* Values for Model field above */ 813 + 814 + #define ACPI_IORT_SMMU_V3_GENERIC 0x00000000 /* Generic SMMUv3 */ 815 + #define ACPI_IORT_SMMU_V3_HISILICON_HI161X 0x00000001 /* hi_silicon Hi161x SMMUv3 */ 816 + #define ACPI_IORT_SMMU_V3_CAVIUM_CN99XX 0x00000002 /* Cavium CN99xx SMMUv3 */ 811 817 812 818 /* Masks for Flags field above */ 813 819 814 820 #define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE (1) 815 821 #define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE (1<<1) 822 + #define ACPI_IORT_SMMU_V3_PXM_VALID (1<<3) 816 823 817 824 /******************************************************************************* 818 825 * ··· 1131 1118 struct acpi_generic_address physical_address; 1132 1119 u32 frequency; 1133 1120 u32 irq; 1121 + }; 1122 + 1123 + /******************************************************************************* 1124 + * 1125 + * SDEI - Software Delegated Exception Interface Descriptor Table 1126 + * 1127 + * Conforms to "Software Delegated Exception Interface (SDEI)" ARM DEN0054A, 1128 + * May 8th, 2017. Copyright 2017 ARM Ltd. 1129 + * 1130 + ******************************************************************************/ 1131 + 1132 + struct acpi_table_sdei { 1133 + struct acpi_table_header header; /* Common ACPI table header */ 1134 1134 }; 1135 1135 1136 1136 /*******************************************************************************
+10 -1
include/acpi/actypes.h
··· 166 166 #define ACPI_SIZE_MAX ACPI_UINT64_MAX 167 167 168 168 #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ 169 + #define ACPI_USE_NATIVE_MATH64 /* Has native 64-bit integer support */ 169 170 170 171 /* 171 172 * In the case of the Itanium Processor Family (IPF), the hardware does not ··· 555 554 #define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8)) 556 555 #define ACPI_MAKE_RSDP_SIG(dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8)) 557 556 557 + /* 558 + * Algorithm to obtain access bit width. 559 + * Can be used with access_width of struct acpi_generic_address and access_size of 560 + * struct acpi_resource_generic_register. 561 + */ 562 + #define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + 2)) 563 + 558 564 /******************************************************************************* 559 565 * 560 566 * Miscellaneous constants ··· 783 775 * | | | | +-- Type of dispatch:to method, handler, notify, or none 784 776 * | | | +----- Interrupt type: edge or level triggered 785 777 * | | +------- Is a Wake GPE 786 - * | +--------- Is GPE masked by the software GPE masking mechanism 778 + * | +--------- Has been enabled automatically at init time 787 779 * +------------ <Reserved> 788 780 */ 789 781 #define ACPI_GPE_DISPATCH_NONE (u8) 0x00 ··· 799 791 #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x08 800 792 801 793 #define ACPI_GPE_CAN_WAKE (u8) 0x10 794 + #define ACPI_GPE_AUTO_ENABLED (u8) 0x20 802 795 803 796 /* 804 797 * Flags for GPE and Lock interfaces
+7 -1
include/acpi/apei.h
··· 16 16 17 17 #ifdef __KERNEL__ 18 18 19 - extern bool hest_disable; 19 + enum hest_status { 20 + HEST_ENABLED, 21 + HEST_DISABLED, 22 + HEST_NOT_FOUND, 23 + }; 24 + 25 + extern int hest_disable; 20 26 extern int erst_disable; 21 27 #ifdef CONFIG_ACPI_APEI_GHES 22 28 extern bool ghes_disable;
+5
include/acpi/ghes.h
··· 113 113 return (void *)(gdata) + acpi_hest_get_record_size(gdata); 114 114 } 115 115 116 + #define apei_estatus_for_each_section(estatus, section) \ 117 + for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ 118 + (void *)section - (void *)(estatus + 1) < estatus->data_length; \ 119 + section = acpi_hest_get_next(section)) 120 + 116 121 int ghes_notify_sea(void); 117 122 118 123 #endif /* GHES_H */
+5 -4
include/acpi/platform/acenv.h
··· 288 288 #define ACPI_INLINE 289 289 #endif 290 290 291 + /* Use ordered initialization if compiler doesn't support designated. */ 292 + #ifndef ACPI_STRUCT_INIT 293 + #define ACPI_STRUCT_INIT(field, value) value 294 + #endif 295 + 291 296 /* 292 297 * Configurable calling conventions: 293 298 * ··· 385 380 386 381 #ifndef ACPI_INIT_FUNCTION 387 382 #define ACPI_INIT_FUNCTION 388 - #endif 389 - 390 - #ifndef ACPI_STRUCT_INIT 391 - #define ACPI_STRUCT_INIT(field, value) value 392 383 #endif 393 384 394 385 #endif /* __ACENV_H__ */
+4
include/acpi/platform/acgcc.h
··· 84 84 85 85 #define COMPILER_VA_MACRO 1 86 86 87 + /* GCC supports native multiply/shift on 32-bit platforms */ 88 + 89 + #define ACPI_USE_NATIVE_MATH64 90 + 87 91 #endif /* __ACGCC_H__ */
+5
include/acpi/platform/aclinux.h
··· 128 128 /* Host-dependent types and defines for in-kernel ACPICA */ 129 129 130 130 #define ACPI_MACHINE_WIDTH BITS_PER_LONG 131 + #define ACPI_USE_NATIVE_MATH64 131 132 #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); 132 133 #define strtoul simple_strtoul 133 134 ··· 179 178 #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): " 180 179 #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): " 181 180 181 + /* 182 + * Linux wants to use designated initializers for function pointer structs. 183 + */ 182 184 #define ACPI_STRUCT_INIT(field, value) .field = value 183 185 184 186 #else /* !__KERNEL__ */ ··· 217 213 #define COMPILER_DEPENDENT_INT64 long long 218 214 #define COMPILER_DEPENDENT_UINT64 unsigned long long 219 215 #define ACPI_USE_NATIVE_DIVIDE 216 + #define ACPI_USE_NATIVE_MATH64 220 217 #endif 221 218 222 219 #ifndef __cdecl
+29 -2
include/linux/acpi.h
··· 228 228 int count; 229 229 }; 230 230 231 - char * __acpi_map_table (unsigned long phys_addr, unsigned long size); 232 - void __acpi_unmap_table(char *map, unsigned long size); 231 + void __iomem *__acpi_map_table(unsigned long phys, unsigned long size); 232 + void __acpi_unmap_table(void __iomem *map, unsigned long size); 233 233 int early_acpi_boot_init(void); 234 234 int acpi_boot_init (void); 235 235 void acpi_boot_table_init (void); ··· 427 427 int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, 428 428 int (*preproc)(struct acpi_resource *, void *), 429 429 void *preproc_data); 430 + int acpi_dev_get_dma_resources(struct acpi_device *adev, 431 + struct list_head *list); 430 432 int acpi_dev_filter_resource_type(struct acpi_resource *ares, 431 433 unsigned long types); 432 434 ··· 557 555 #define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80 558 556 #define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81 559 557 #define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82 558 + 559 + enum acpi_predicate { 560 + all_versions, 561 + less_than_or_equal, 562 + equal, 563 + greater_than_or_equal, 564 + }; 565 + 566 + /* Table must be terminted by a NULL entry */ 567 + struct acpi_platform_list { 568 + char oem_id[ACPI_OEM_ID_SIZE+1]; 569 + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1]; 570 + u32 oem_revision; 571 + char *table; 572 + enum acpi_predicate pred; 573 + char *reason; 574 + u32 data; 575 + }; 576 + int acpi_match_platform_list(const struct acpi_platform_list *plat); 560 577 561 578 extern void acpi_early_init(void); 562 579 extern void acpi_subsystem_init(void); ··· 793 772 static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) 794 773 { 795 774 return DEV_DMA_NOT_SUPPORTED; 775 + } 776 + 777 + static inline int acpi_dma_get_range(struct device *dev, u64 *dma_addr, 778 + u64 *offset, u64 *size) 779 + { 780 + return -ENODEV; 796 781 } 797 782 798 783 static inline int acpi_dma_configure(struct device *dev,
+3 -2
include/linux/acpi_iort.h
··· 36 36 void acpi_configure_pmsi_domain(struct device *dev); 37 37 int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id); 38 38 /* IOMMU interface */ 39 - void iort_set_dma_mask(struct device *dev); 39 + void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *size); 40 40 const struct iommu_ops *iort_iommu_configure(struct device *dev); 41 41 #else 42 42 static inline void acpi_iort_init(void) { } ··· 47 47 { return NULL; } 48 48 static inline void acpi_configure_pmsi_domain(struct device *dev) { } 49 49 /* IOMMU interface */ 50 - static inline void iort_set_dma_mask(struct device *dev) { } 50 + static inline void iort_dma_setup(struct device *dev, u64 *dma_addr, 51 + u64 *size) { } 51 52 static inline 52 53 const struct iommu_ops *iort_iommu_configure(struct device *dev) 53 54 { return NULL; }
+13
include/linux/platform_data/x86/apple.h
··· 1 + #ifndef PLATFORM_DATA_X86_APPLE_H 2 + #define PLATFORM_DATA_X86_APPLE_H 3 + 4 + #ifdef CONFIG_X86 5 + /** 6 + * x86_apple_machine - whether the machine is an x86 Apple Macintosh 7 + */ 8 + extern bool x86_apple_machine; 9 + #else 10 + #define x86_apple_machine false 11 + #endif 12 + 13 + #endif
+73 -32
tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
··· 759 759 760 760 /* Skip NULL entries in RSDT/XSDT */ 761 761 762 - if (!table_address) { 762 + if (table_address == 0) { 763 763 continue; 764 764 } 765 765 ··· 808 808 u8 number_of_tables; 809 809 u8 item_size; 810 810 u32 current_instance = 0; 811 - acpi_physical_address table_address = 0; 811 + acpi_physical_address table_address; 812 + acpi_physical_address first_table_address = 0; 812 813 u32 table_length = 0; 813 814 acpi_status status = AE_OK; 814 815 u32 i; ··· 821 820 ACPI_COMPARE_NAME(signature, ACPI_SIG_XSDT) || 822 821 ACPI_COMPARE_NAME(signature, ACPI_SIG_DSDT) || 823 822 ACPI_COMPARE_NAME(signature, ACPI_SIG_FACS)) { 824 - if (instance > 0) { 825 - return (AE_LIMIT); 826 - } 823 + 824 + find_next_instance: 825 + 826 + table_address = 0; 827 827 828 828 /* 829 829 * Get the appropriate address, either 32-bit or 64-bit. Be very ··· 832 830 * Note: The 64-bit addresses have priority. 833 831 */ 834 832 if (ACPI_COMPARE_NAME(signature, ACPI_SIG_DSDT)) { 835 - if ((gbl_fadt->header.length >= MIN_FADT_FOR_XDSDT) && 836 - gbl_fadt->Xdsdt) { 837 - table_address = 838 - (acpi_physical_address)gbl_fadt->Xdsdt; 839 - } else 840 - if ((gbl_fadt->header.length >= MIN_FADT_FOR_DSDT) 841 - && gbl_fadt->dsdt) { 842 - table_address = 843 - (acpi_physical_address)gbl_fadt->dsdt; 833 + if (current_instance < 2) { 834 + if ((gbl_fadt->header.length >= 835 + MIN_FADT_FOR_XDSDT) && gbl_fadt->Xdsdt 836 + && current_instance == 0) { 837 + table_address = 838 + (acpi_physical_address)gbl_fadt-> 839 + Xdsdt; 840 + } else 841 + if ((gbl_fadt->header.length >= 842 + MIN_FADT_FOR_DSDT) 843 + && gbl_fadt->dsdt != 844 + first_table_address) { 845 + table_address = 846 + (acpi_physical_address)gbl_fadt-> 847 + dsdt; 848 + } 844 849 } 845 850 } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_FACS)) { 846 - if ((gbl_fadt->header.length >= MIN_FADT_FOR_XFACS) && 847 - gbl_fadt->Xfacs) { 848 - table_address = 849 - (acpi_physical_address)gbl_fadt->Xfacs; 850 - } else 851 - if ((gbl_fadt->header.length >= MIN_FADT_FOR_FACS) 852 - && gbl_fadt->facs) { 853 - table_address = 854 - (acpi_physical_address)gbl_fadt->facs; 851 + if (current_instance < 2) { 852 + if ((gbl_fadt->header.length >= 853 + MIN_FADT_FOR_XFACS) && gbl_fadt->Xfacs 854 + && current_instance == 0) { 855 + table_address = 856 + (acpi_physical_address)gbl_fadt-> 857 + Xfacs; 858 + } else 859 + if ((gbl_fadt->header.length >= 860 + MIN_FADT_FOR_FACS) 861 + && gbl_fadt->facs != 862 + first_table_address) { 863 + table_address = 864 + (acpi_physical_address)gbl_fadt-> 865 + facs; 866 + } 855 867 } 856 868 } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_XSDT)) { 857 869 if (!gbl_revision) { 858 870 return (AE_BAD_SIGNATURE); 859 871 } 860 - table_address = 861 - (acpi_physical_address)gbl_rsdp. 862 - xsdt_physical_address; 872 + if (current_instance == 0) { 873 + table_address = 874 + (acpi_physical_address)gbl_rsdp. 875 + xsdt_physical_address; 876 + } 863 877 } else if (ACPI_COMPARE_NAME(signature, ACPI_SIG_RSDT)) { 864 - table_address = 865 - (acpi_physical_address)gbl_rsdp. 866 - rsdt_physical_address; 878 + if (current_instance == 0) { 879 + table_address = 880 + (acpi_physical_address)gbl_rsdp. 881 + rsdt_physical_address; 882 + } 867 883 } else { 868 - table_address = (acpi_physical_address)gbl_rsdp_address; 869 - signature = ACPI_SIG_RSDP; 884 + if (current_instance == 0) { 885 + table_address = 886 + (acpi_physical_address)gbl_rsdp_address; 887 + signature = ACPI_SIG_RSDP; 888 + } 889 + } 890 + 891 + if (table_address == 0) { 892 + goto exit_find_table; 870 893 } 871 894 872 895 /* Now we can get the requested special table */ ··· 902 875 } 903 876 904 877 table_length = ap_get_table_length(mapped_table); 878 + if (first_table_address == 0) { 879 + first_table_address = table_address; 880 + } 881 + 882 + /* Match table instance */ 883 + 884 + if (current_instance != instance) { 885 + osl_unmap_table(mapped_table); 886 + mapped_table = NULL; 887 + current_instance++; 888 + goto find_next_instance; 889 + } 905 890 } else { /* Case for a normal ACPI table */ 906 891 907 892 if (osl_can_use_xsdt()) { ··· 952 913 953 914 /* Skip NULL entries in RSDT/XSDT */ 954 915 955 - if (!table_address) { 916 + if (table_address == 0) { 956 917 continue; 957 918 } 958 919 ··· 984 945 break; 985 946 } 986 947 } 948 + 949 + exit_find_table: 987 950 988 951 if (!mapped_table) { 989 952 return (AE_LIMIT);
+1 -1
tools/power/acpi/tools/acpidump/apfiles.c
··· 61 61 62 62 static int ap_is_existing_file(char *pathname) 63 63 { 64 - #ifndef _GNU_EFI 64 + #if !defined(_GNU_EFI) && !defined(_EDK2_EFI) 65 65 struct stat stat_info; 66 66 67 67 if (!stat(pathname, &stat_info)) {
+1 -1
tools/power/acpi/tools/acpidump/apmain.c
··· 300 300 * 301 301 ******************************************************************************/ 302 302 303 - #ifndef _GNU_EFI 303 + #if !defined(_GNU_EFI) && !defined(_EDK2_EFI) 304 304 int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) 305 305 #else 306 306 int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])