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

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

Pull ACPI updates from Rafael Wysocki:
"These update ACPICA to upstream revision 20170831, fix APEI to use the
fixmap instead of ioremap_page_range(), add an operation region driver
for TI PMIC TPS68470, add support for PCC subspace IDs to the ACPI
CPPC driver, fix a few assorted issues and clean up some code.

Specifics:

- Update the ACPICA code to upstream revision 20170831 including
* PDTT table header support (Bob Moore).
* Cleanup and extension of internal string-to-integer conversion
functions (Bob Moore).
* Support for 64-bit hardware accesses (Lv Zheng).
* ACPI PM Timer code adjustment to deal with 64-bit return values
of acpi_hw_read() (Bob Moore).
* Support for deferred table verification in acpiexec (Lv Zheng).

- Fix APEI to use the fixmap instead of ioremap_page_range() which
cannot work correctly the way the code in there attempted to use it
and drop some code that's not necessary any more after that change
(James Morse).

- Clean up the APEI support code and make it use 64-bit timestamps
(Arnd Bergmann, Dongjiu Geng, Jan Beulich).

- Add operation region driver for TI PMIC TPS68470 (Rajmohan Mani).

- Add support for PCC subspace IDs to the ACPI CPPC driver (George
Cherian).

- Fix an ACPI EC driver regression related to the handling of EC
events during the "noirq" phases of system suspend/resume (Lv
Zheng).

- Delay the initialization of the lid state in the ACPI button driver
to fix issues appearing on some systems (Hans de Goede).

- Extend the KIOX000A "device always present" quirk to cover all
affected BIOS versions (Hans de Goede).

- Clean up some code in the ACPI core and drivers (Colin Ian King,
Gustavo Silva)"

* tag 'acpi-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (24 commits)
ACPI: Mark expected switch fall-throughs
ACPI / LPSS: Remove redundant initialization of clk
ACPI / CPPC: Make CPPC ACPI driver aware of PCC subspace IDs
mailbox: PCC: Move the MAX_PCC_SUBSPACES definition to header file
ACPI / sysfs: Make function param_set_trace_method_name() static
ACPI / button: Delay acpi_lid_initialize_state() until first user space open
ACPI / EC: Fix regression related to triggering source of EC event handling
APEI / ERST: use 64-bit timestamps
ACPI / APEI: Remove arch_apei_flush_tlb_one()
arm64: mm: Remove arch_apei_flush_tlb_one()
ACPI / APEI: Remove ghes_ioremap_area
ACPI / APEI: Replace ioremap_page_range() with fixmap
ACPI / APEI: remove the unused dead-code for SEA/NMI notification type
ACPI / x86: Extend KIOX000A quirk to cover all affected BIOS versions
ACPI / APEI: adjust a local variable type in ghes_ioremap_pfn_irq()
ACPICA: Update version to 20170831
ACPICA: Update acpi_get_timer for 64-bit interface to acpi_hw_read
ACPICA: String conversions: Update to add new behaviors
ACPICA: String conversions: Cleanup/format comments. No functional changes
ACPICA: Restructure/cleanup all string-to-integer conversion functions
...

+1555 -633
-12
arch/arm64/include/asm/acpi.h
··· 126 126 */ 127 127 #define acpi_disable_cmcff 1 128 128 pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr); 129 - 130 - /* 131 - * Despite its name, this function must still broadcast the TLB 132 - * invalidation in order to ensure other CPUs don't end up with junk 133 - * entries as a result of speculation. Unusually, its also called in 134 - * IRQ context (ghes_iounmap_irq) so if we ever need to use IPIs for 135 - * TLB broadcasting, then we're in trouble here. 136 - */ 137 - static inline void arch_apei_flush_tlb_one(unsigned long addr) 138 - { 139 - flush_tlb_kernel_range(addr, addr + PAGE_SIZE); 140 - } 141 129 #endif /* CONFIG_ACPI_APEI */ 142 130 143 131 #ifdef CONFIG_ACPI_NUMA
+7
arch/arm64/include/asm/fixmap.h
··· 51 51 52 52 FIX_EARLYCON_MEM_BASE, 53 53 FIX_TEXT_POKE0, 54 + 55 + #ifdef CONFIG_ACPI_APEI_GHES 56 + /* Used for GHES mapping from assorted contexts */ 57 + FIX_APEI_GHES_IRQ, 58 + FIX_APEI_GHES_NMI, 59 + #endif /* CONFIG_ACPI_APEI_GHES */ 60 + 54 61 __end_of_permanent_fixed_addresses, 55 62 56 63 /*
+4
arch/arm64/mm/mmu.c
··· 778 778 } 779 779 } 780 780 781 + /* 782 + * Unusually, this is also called in IRQ context (ghes_iounmap_irq) so if we 783 + * ever need to use IPIs for TLB broadcasting, then we're in trouble here. 784 + */ 781 785 void __set_fixmap(enum fixed_addresses idx, 782 786 phys_addr_t phys, pgprot_t flags) 783 787 {
+6
arch/x86/include/asm/fixmap.h
··· 104 104 FIX_GDT_REMAP_BEGIN, 105 105 FIX_GDT_REMAP_END = FIX_GDT_REMAP_BEGIN + NR_CPUS - 1, 106 106 107 + #ifdef CONFIG_ACPI_APEI_GHES 108 + /* Used for GHES mapping from assorted contexts */ 109 + FIX_APEI_GHES_IRQ, 110 + FIX_APEI_GHES_NMI, 111 + #endif 112 + 107 113 __end_of_permanent_fixed_addresses, 108 114 109 115 /*
-5
arch/x86/kernel/acpi/apei.c
··· 52 52 apei_mce_report_mem_error(sev, mem_err); 53 53 #endif 54 54 } 55 - 56 - void arch_apei_flush_tlb_one(unsigned long addr) 57 - { 58 - __flush_tlb_one(addr); 59 - }
+16
drivers/acpi/Kconfig
··· 541 541 source "drivers/acpi/arm64/Kconfig" 542 542 endif 543 543 544 + config TPS68470_PMIC_OPREGION 545 + bool "ACPI operation region support for TPS68470 PMIC" 546 + depends on MFD_TPS68470 547 + help 548 + This config adds ACPI operation region support for TI TPS68470 PMIC. 549 + TPS68470 device is an advanced power management unit that powers 550 + a Compact Camera Module (CCM), generates clocks for image sensors, 551 + drives a dual LED for flash and incorporates two LED drivers for 552 + general purpose indicators. 553 + This driver enables ACPI operation region support control voltage 554 + regulators and clocks. 555 + 556 + This option is a bool as it provides an ACPI operation 557 + region, which must be available before any of the devices 558 + using this, are probed. 559 + 544 560 endif # ACPI
+2
drivers/acpi/Makefile
··· 109 109 110 110 obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o 111 111 112 + obj-$(CONFIG_TPS68470_PMIC_OPREGION) += pmic/tps68470_pmic.o 113 + 112 114 video-objs += acpi_video.o video_detect.o 113 115 obj-y += dptf/ 114 116
+1
drivers/acpi/ac.c
··· 265 265 default: 266 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 267 267 "Unsupported event [0x%x]\n", event)); 268 + /* fall through */ 268 269 case ACPI_AC_NOTIFY_STATUS: 269 270 case ACPI_NOTIFY_BUS_CHECK: 270 271 case ACPI_NOTIFY_DEVICE_CHECK:
+1 -1
drivers/acpi/acpi_lpss.c
··· 362 362 { 363 363 const struct lpss_device_desc *dev_desc = pdata->dev_desc; 364 364 const char *devname = dev_name(&adev->dev); 365 - struct clk *clk = ERR_PTR(-ENODEV); 365 + struct clk *clk; 366 366 struct lpss_clk_data *clk_data; 367 367 const char *parent, *clk_name; 368 368 void __iomem *prv_base;
+1
drivers/acpi/acpi_processor.c
··· 82 82 * PIIX4 models. 83 83 */ 84 84 errata.piix4.throttle = 1; 85 + /* fall through*/ 85 86 86 87 case 2: /* PIIX4E */ 87 88 case 3: /* PIIX4M */
+1
drivers/acpi/acpica/Makefile
··· 178 178 utresrc.o \ 179 179 utstate.o \ 180 180 utstring.o \ 181 + utstrsuppt.o \ 181 182 utstrtoul64.o \ 182 183 utxface.o \ 183 184 utxfinit.o \
+2 -2
drivers/acpi/acpica/achware.h
··· 66 66 acpi_hw_validate_register(struct acpi_generic_address *reg, 67 67 u8 max_bit_width, u64 *address); 68 68 69 - acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg); 69 + acpi_status acpi_hw_read(u64 *value, struct acpi_generic_address *reg); 70 70 71 - acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg); 71 + acpi_status acpi_hw_write(u64 value, struct acpi_generic_address *reg); 72 72 73 73 struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id); 74 74
+2 -4
drivers/acpi/acpica/acinterp.h
··· 101 101 */ 102 102 acpi_status 103 103 acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, 104 - union acpi_operand_object **result_desc, u32 flags); 104 + union acpi_operand_object **result_desc, 105 + u32 implicit_conversion); 105 106 106 107 acpi_status 107 108 acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, ··· 424 423 struct acpi_namespace_node *node, 425 424 struct acpi_walk_state *walk_state, 426 425 u8 implicit_conversion); 427 - 428 - #define ACPI_IMPLICIT_CONVERSION TRUE 429 - #define ACPI_NO_IMPLICIT_CONVERSION FALSE 430 426 431 427 /* 432 428 * exstoren - resolve/store object
+27 -6
drivers/acpi/acpica/acutils.h
··· 141 141 #define ACPI_MSG_SUFFIX \ 142 142 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number) 143 143 144 + /* Flags to indicate implicit or explicit string-to-integer conversion */ 145 + 146 + #define ACPI_IMPLICIT_CONVERSION TRUE 147 + #define ACPI_NO_IMPLICIT_CONVERSION FALSE 148 + 144 149 /* Types for Resource descriptor entries */ 145 150 146 151 #define ACPI_INVALID_RESOURCE 0 ··· 202 197 203 198 int acpi_ut_stricmp(char *string1, char *string2); 204 199 205 - acpi_status acpi_ut_strtoul64(char *string, u32 flags, u64 *ret_integer); 200 + /* 201 + * utstrsuppt - string-to-integer conversion support functions 202 + */ 203 + acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value); 204 + 205 + acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr); 206 + 207 + acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr); 208 + 209 + char acpi_ut_remove_whitespace(char **string); 210 + 211 + char acpi_ut_remove_leading_zeros(char **string); 212 + 213 + u8 acpi_ut_detect_hex_prefix(char **string); 214 + 215 + u8 acpi_ut_detect_octal_prefix(char **string); 206 216 207 217 /* 208 - * Values for Flags above 209 - * Note: LIMIT values correspond to acpi_gbl_integer_byte_width values (4/8) 218 + * utstrtoul64 - string-to-integer conversion functions 210 219 */ 211 - #define ACPI_STRTOUL_32BIT 0x04 /* 4 bytes */ 212 - #define ACPI_STRTOUL_64BIT 0x08 /* 8 bytes */ 213 - #define ACPI_STRTOUL_BASE16 0x10 /* Default: Base10/16 */ 220 + acpi_status acpi_ut_strtoul64(char *string, u64 *ret_integer); 221 + 222 + u64 acpi_ut_explicit_strtoul64(char *string); 223 + 224 + u64 acpi_ut_implicit_strtoul64(char *string); 214 225 215 226 /* 216 227 * utglobal - Global data structures and procedures
+1 -4
drivers/acpi/acpica/dbconvert.c
··· 277 277 default: 278 278 279 279 object->type = ACPI_TYPE_INTEGER; 280 - status = acpi_ut_strtoul64(string, 281 - (acpi_gbl_integer_byte_width | 282 - ACPI_STRTOUL_BASE16), 283 - &object->integer.value); 280 + status = acpi_ut_strtoul64(string, &object->integer.value); 284 281 break; 285 282 } 286 283
+1 -1
drivers/acpi/acpica/dswexec.c
··· 134 134 * object. Implicitly convert the argument if necessary. 135 135 */ 136 136 status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 137 - ACPI_STRTOUL_BASE16); 137 + ACPI_IMPLICIT_CONVERSION); 138 138 if (ACPI_FAILURE(status)) { 139 139 goto cleanup; 140 140 }
+3 -3
drivers/acpi/acpica/evgpe.c
··· 390 390 struct acpi_gpe_handler_info *gpe_handler_info; 391 391 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 392 392 u8 enabled_status_byte; 393 - u32 status_reg; 394 - u32 enable_reg; 393 + u64 status_reg; 394 + u64 enable_reg; 395 395 acpi_cpu_flags flags; 396 396 u32 i; 397 397 u32 j; ··· 472 472 gpe_register_info->base_gpe_number, 473 473 gpe_register_info->base_gpe_number + 474 474 (ACPI_GPE_REGISTER_WIDTH - 1), 475 - status_reg, enable_reg, 475 + (u32)status_reg, (u32)enable_reg, 476 476 gpe_register_info->enable_for_run, 477 477 gpe_register_info->enable_for_wake)); 478 478
+1 -1
drivers/acpi/acpica/exconcat.c
··· 156 156 157 157 status = 158 158 acpi_ex_convert_to_integer(local_operand1, &temp_operand1, 159 - ACPI_STRTOUL_BASE16); 159 + ACPI_IMPLICIT_CONVERSION); 160 160 break; 161 161 162 162 case ACPI_TYPE_BUFFER:
+18 -12
drivers/acpi/acpica/exconvrt.c
··· 57 57 * 58 58 * FUNCTION: acpi_ex_convert_to_integer 59 59 * 60 - * PARAMETERS: obj_desc - Object to be converted. Must be an 61 - * Integer, Buffer, or String 62 - * result_desc - Where the new Integer object is returned 63 - * flags - Used for string conversion 60 + * PARAMETERS: obj_desc - Object to be converted. Must be an 61 + * Integer, Buffer, or String 62 + * result_desc - Where the new Integer object is returned 63 + * implicit_conversion - Used for string conversion 64 64 * 65 65 * RETURN: Status 66 66 * ··· 70 70 71 71 acpi_status 72 72 acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, 73 - union acpi_operand_object **result_desc, u32 flags) 73 + union acpi_operand_object **result_desc, 74 + u32 implicit_conversion) 74 75 { 75 76 union acpi_operand_object *return_desc; 76 77 u8 *pointer; 77 78 u64 result; 78 79 u32 i; 79 80 u32 count; 80 - acpi_status status; 81 81 82 82 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc); 83 83 ··· 123 123 * hexadecimal as per the ACPI specification. The only exception (as 124 124 * of ACPI 3.0) is that the to_integer() operator allows both decimal 125 125 * and hexadecimal strings (hex prefixed with "0x"). 126 + * 127 + * Explicit conversion is used only by to_integer. 128 + * All other string-to-integer conversions are implicit conversions. 126 129 */ 127 - status = acpi_ut_strtoul64(ACPI_CAST_PTR(char, pointer), 128 - (acpi_gbl_integer_byte_width | 129 - flags), &result); 130 - if (ACPI_FAILURE(status)) { 131 - return_ACPI_STATUS(status); 130 + if (implicit_conversion) { 131 + result = 132 + acpi_ut_implicit_strtoul64(ACPI_CAST_PTR 133 + (char, pointer)); 134 + } else { 135 + result = 136 + acpi_ut_explicit_strtoul64(ACPI_CAST_PTR 137 + (char, pointer)); 132 138 } 133 139 break; 134 140 ··· 637 631 */ 638 632 status = 639 633 acpi_ex_convert_to_integer(source_desc, result_desc, 640 - ACPI_STRTOUL_BASE16); 634 + ACPI_IMPLICIT_CONVERSION); 641 635 break; 642 636 643 637 case ACPI_TYPE_STRING:
+1 -1
drivers/acpi/acpica/exmisc.c
··· 330 330 case ACPI_TYPE_INTEGER: 331 331 332 332 status = acpi_ex_convert_to_integer(operand1, &local_operand1, 333 - ACPI_STRTOUL_BASE16); 333 + ACPI_IMPLICIT_CONVERSION); 334 334 break; 335 335 336 336 case ACPI_TYPE_STRING:
+1 -1
drivers/acpi/acpica/exresop.c
··· 415 415 * Known as "Implicit Source Operand Conversion" 416 416 */ 417 417 status = acpi_ex_convert_to_integer(obj_desc, stack_ptr, 418 - ACPI_STRTOUL_BASE16); 418 + ACPI_IMPLICIT_CONVERSION); 419 419 if (ACPI_FAILURE(status)) { 420 420 if (status == AE_TYPE) { 421 421 ACPI_ERROR((AE_INFO,
+2 -2
drivers/acpi/acpica/hwgpe.c
··· 99 99 { 100 100 struct acpi_gpe_register_info *gpe_register_info; 101 101 acpi_status status = AE_OK; 102 - u32 enable_mask; 102 + u64 enable_mask; 103 103 u32 register_bit; 104 104 105 105 ACPI_FUNCTION_ENTRY(); ··· 214 214 acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, 215 215 acpi_event_status *event_status) 216 216 { 217 - u32 in_byte; 217 + u64 in_byte; 218 218 u32 register_bit; 219 219 struct acpi_gpe_register_info *gpe_register_info; 220 220 acpi_event_status local_event_status = 0;
+39 -33
drivers/acpi/acpica/hwregs.c
··· 220 220 * 221 221 * RETURN: Status 222 222 * 223 - * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max 224 - * version of acpi_read, used internally since the overhead of 225 - * 64-bit values is not needed. 223 + * DESCRIPTION: Read from either memory or IO space. This is a 64-bit max 224 + * version of acpi_read. 226 225 * 227 226 * LIMITATIONS: <These limitations also apply to acpi_hw_write> 228 227 * space_ID must be system_memory or system_IO. 229 228 * 230 229 ******************************************************************************/ 231 230 232 - acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) 231 + acpi_status acpi_hw_read(u64 *value, struct acpi_generic_address *reg) 233 232 { 234 233 u64 address; 235 234 u8 access_width; ··· 243 244 244 245 /* Validate contents of the GAS register */ 245 246 246 - status = acpi_hw_validate_register(reg, 32, &address); 247 + status = acpi_hw_validate_register(reg, 64, &address); 247 248 if (ACPI_FAILURE(status)) { 248 249 return (status); 249 250 } 250 251 251 252 /* 252 - * Initialize entire 32-bit return value to zero, convert access_width 253 + * Initialize entire 64-bit return value to zero, convert access_width 253 254 * into number of bits based 254 255 */ 255 256 *value = 0; 256 - access_width = acpi_hw_get_access_bit_width(address, reg, 32); 257 + access_width = acpi_hw_get_access_bit_width(address, reg, 64); 257 258 bit_width = reg->bit_offset + reg->bit_width; 258 259 bit_offset = reg->bit_offset; 259 260 ··· 264 265 index = 0; 265 266 while (bit_width) { 266 267 if (bit_offset >= access_width) { 267 - value32 = 0; 268 + value64 = 0; 268 269 bit_offset -= access_width; 269 270 } else { 270 271 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { ··· 275 276 ACPI_DIV_8 276 277 (access_width), 277 278 &value64, access_width); 278 - value32 = (u32)value64; 279 279 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 280 280 281 281 status = acpi_hw_read_port((acpi_io_address) ··· 284 286 (access_width), 285 287 &value32, 286 288 access_width); 289 + value64 = (u64)value32; 287 290 } 288 291 } 289 292 290 293 /* 291 294 * Use offset style bit writes because "Index * AccessWidth" is 292 - * ensured to be less than 32-bits by acpi_hw_validate_register(). 295 + * ensured to be less than 64-bits by acpi_hw_validate_register(). 293 296 */ 294 297 ACPI_SET_BITS(value, index * access_width, 295 - ACPI_MASK_BITS_ABOVE_32(access_width), value32); 298 + ACPI_MASK_BITS_ABOVE_64(access_width), value64); 296 299 297 300 bit_width -= 298 301 bit_width > access_width ? access_width : bit_width; ··· 301 302 } 302 303 303 304 ACPI_DEBUG_PRINT((ACPI_DB_IO, 304 - "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 305 - *value, access_width, ACPI_FORMAT_UINT64(address), 305 + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", 306 + ACPI_FORMAT_UINT64(*value), access_width, 307 + ACPI_FORMAT_UINT64(address), 306 308 acpi_ut_get_region_name(reg->space_id))); 307 309 308 310 return (status); ··· 318 318 * 319 319 * RETURN: Status 320 320 * 321 - * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max 322 - * version of acpi_write, used internally since the overhead of 323 - * 64-bit values is not needed. 321 + * DESCRIPTION: Write to either memory or IO space. This is a 64-bit max 322 + * version of acpi_write. 324 323 * 325 324 ******************************************************************************/ 326 325 327 - acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg) 326 + acpi_status acpi_hw_write(u64 value, struct acpi_generic_address *reg) 328 327 { 329 328 u64 address; 330 329 u8 access_width; 331 330 u32 bit_width; 332 331 u8 bit_offset; 333 332 u64 value64; 334 - u32 value32; 335 333 u8 index; 336 334 acpi_status status; 337 335 ··· 337 339 338 340 /* Validate contents of the GAS register */ 339 341 340 - status = acpi_hw_validate_register(reg, 32, &address); 342 + status = acpi_hw_validate_register(reg, 64, &address); 341 343 if (ACPI_FAILURE(status)) { 342 344 return (status); 343 345 } 344 346 345 347 /* Convert access_width into number of bits based */ 346 348 347 - access_width = acpi_hw_get_access_bit_width(address, reg, 32); 349 + access_width = acpi_hw_get_access_bit_width(address, reg, 64); 348 350 bit_width = reg->bit_offset + reg->bit_width; 349 351 bit_offset = reg->bit_offset; 350 352 ··· 356 358 while (bit_width) { 357 359 /* 358 360 * Use offset style bit reads because "Index * AccessWidth" is 359 - * ensured to be less than 32-bits by acpi_hw_validate_register(). 361 + * ensured to be less than 64-bits by acpi_hw_validate_register(). 360 362 */ 361 - value32 = ACPI_GET_BITS(&value, index * access_width, 362 - ACPI_MASK_BITS_ABOVE_32(access_width)); 363 + value64 = ACPI_GET_BITS(&value, index * access_width, 364 + ACPI_MASK_BITS_ABOVE_64(access_width)); 363 365 364 366 if (bit_offset >= access_width) { 365 367 bit_offset -= access_width; 366 368 } else { 367 369 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 368 - value64 = (u64)value32; 369 370 status = 370 371 acpi_os_write_memory((acpi_physical_address) 371 372 address + ··· 379 382 index * 380 383 ACPI_DIV_8 381 384 (access_width), 382 - value32, 385 + (u32)value64, 383 386 access_width); 384 387 } 385 388 } ··· 394 397 } 395 398 396 399 ACPI_DEBUG_PRINT((ACPI_DB_IO, 397 - "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 398 - value, access_width, ACPI_FORMAT_UINT64(address), 400 + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", 401 + ACPI_FORMAT_UINT64(value), access_width, 402 + ACPI_FORMAT_UINT64(address), 399 403 acpi_ut_get_region_name(reg->space_id))); 400 404 401 405 return (status); ··· 524 526 acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value) 525 527 { 526 528 u32 value = 0; 529 + u64 value64; 527 530 acpi_status status; 528 531 529 532 ACPI_FUNCTION_TRACE(hw_register_read); ··· 563 564 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 564 565 565 566 status = 566 - acpi_hw_read(&value, &acpi_gbl_FADT.xpm2_control_block); 567 + acpi_hw_read(&value64, &acpi_gbl_FADT.xpm2_control_block); 568 + value = (u32)value64; 567 569 break; 568 570 569 571 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 570 572 571 - status = acpi_hw_read(&value, &acpi_gbl_FADT.xpm_timer_block); 573 + status = acpi_hw_read(&value64, &acpi_gbl_FADT.xpm_timer_block); 574 + value = (u32)value64; 572 575 break; 573 576 574 577 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ ··· 587 586 } 588 587 589 588 if (ACPI_SUCCESS(status)) { 590 - *return_value = value; 589 + *return_value = (u32)value; 591 590 } 592 591 593 592 return_ACPI_STATUS(status); ··· 623 622 { 624 623 acpi_status status; 625 624 u32 read_value; 625 + u64 read_value64; 626 626 627 627 ACPI_FUNCTION_TRACE(hw_register_write); 628 628 ··· 687 685 * as per the ACPI spec. 688 686 */ 689 687 status = 690 - acpi_hw_read(&read_value, 688 + acpi_hw_read(&read_value64, 691 689 &acpi_gbl_FADT.xpm2_control_block); 692 690 if (ACPI_FAILURE(status)) { 693 691 goto exit; 694 692 } 693 + read_value = (u32)read_value64; 695 694 696 695 /* Insert the bits to be preserved */ 697 696 ··· 748 745 { 749 746 u32 value_a = 0; 750 747 u32 value_b = 0; 748 + u64 value64; 751 749 acpi_status status; 752 750 753 751 /* The first register is always required */ 754 752 755 - status = acpi_hw_read(&value_a, register_a); 753 + status = acpi_hw_read(&value64, register_a); 756 754 if (ACPI_FAILURE(status)) { 757 755 return (status); 758 756 } 757 + value_a = (u32)value64; 759 758 760 759 /* Second register is optional */ 761 760 762 761 if (register_b->address) { 763 - status = acpi_hw_read(&value_b, register_b); 762 + status = acpi_hw_read(&value64, register_b); 764 763 if (ACPI_FAILURE(status)) { 765 764 return (status); 766 765 } 766 + value_b = (u32)value64; 767 767 } 768 768 769 769 /*
+9 -1
drivers/acpi/acpica/hwtimer.c
··· 94 94 acpi_status acpi_get_timer(u32 * ticks) 95 95 { 96 96 acpi_status status; 97 + u64 timer_value; 97 98 98 99 ACPI_FUNCTION_TRACE(acpi_get_timer); 99 100 ··· 108 107 return_ACPI_STATUS(AE_SUPPORT); 109 108 } 110 109 111 - status = acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block); 110 + status = acpi_hw_read(&timer_value, &acpi_gbl_FADT.xpm_timer_block); 111 + if (ACPI_SUCCESS(status)) { 112 + 113 + /* ACPI PM Timer is defined to be 32 bits (PM_TMR_LEN) */ 114 + 115 + *ticks = (u32)timer_value; 116 + } 117 + 112 118 return_ACPI_STATUS(status); 113 119 } 114 120
+3 -115
drivers/acpi/acpica/hwxface.c
··· 125 125 ******************************************************************************/ 126 126 acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg) 127 127 { 128 - u32 value_lo; 129 - u32 value_hi; 130 - u32 width; 131 - u64 address; 132 128 acpi_status status; 133 129 134 130 ACPI_FUNCTION_NAME(acpi_read); 135 131 136 - if (!return_value) { 137 - return (AE_BAD_PARAMETER); 138 - } 139 - 140 - /* Validate contents of the GAS register. Allow 64-bit transfers */ 141 - 142 - status = acpi_hw_validate_register(reg, 64, &address); 143 - if (ACPI_FAILURE(status)) { 144 - return (status); 145 - } 146 - 147 - /* 148 - * Two address spaces supported: Memory or I/O. PCI_Config is 149 - * not supported here because the GAS structure is insufficient 150 - */ 151 - if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 152 - status = acpi_os_read_memory((acpi_physical_address) 153 - address, return_value, 154 - reg->bit_width); 155 - if (ACPI_FAILURE(status)) { 156 - return (status); 157 - } 158 - } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 159 - 160 - value_lo = 0; 161 - value_hi = 0; 162 - 163 - width = reg->bit_width; 164 - if (width == 64) { 165 - width = 32; /* Break into two 32-bit transfers */ 166 - } 167 - 168 - status = acpi_hw_read_port((acpi_io_address) 169 - address, &value_lo, width); 170 - if (ACPI_FAILURE(status)) { 171 - return (status); 172 - } 173 - 174 - if (reg->bit_width == 64) { 175 - 176 - /* Read the top 32 bits */ 177 - 178 - status = acpi_hw_read_port((acpi_io_address) 179 - (address + 4), &value_hi, 180 - 32); 181 - if (ACPI_FAILURE(status)) { 182 - return (status); 183 - } 184 - } 185 - 186 - /* Set the return value only if status is AE_OK */ 187 - 188 - *return_value = (value_lo | ((u64)value_hi << 32)); 189 - } 190 - 191 - ACPI_DEBUG_PRINT((ACPI_DB_IO, 192 - "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", 193 - ACPI_FORMAT_UINT64(*return_value), reg->bit_width, 194 - ACPI_FORMAT_UINT64(address), 195 - acpi_ut_get_region_name(reg->space_id))); 196 - 197 - return (AE_OK); 132 + status = acpi_hw_read(return_value, reg); 133 + return (status); 198 134 } 199 135 200 136 ACPI_EXPORT_SYMBOL(acpi_read) ··· 149 213 ******************************************************************************/ 150 214 acpi_status acpi_write(u64 value, struct acpi_generic_address *reg) 151 215 { 152 - u32 width; 153 - u64 address; 154 216 acpi_status status; 155 217 156 218 ACPI_FUNCTION_NAME(acpi_write); 157 219 158 - /* Validate contents of the GAS register. Allow 64-bit transfers */ 159 - 160 - status = acpi_hw_validate_register(reg, 64, &address); 161 - if (ACPI_FAILURE(status)) { 162 - return (status); 163 - } 164 - 165 - /* 166 - * Two address spaces supported: Memory or IO. PCI_Config is 167 - * not supported here because the GAS structure is insufficient 168 - */ 169 - if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 170 - status = acpi_os_write_memory((acpi_physical_address) 171 - address, value, reg->bit_width); 172 - if (ACPI_FAILURE(status)) { 173 - return (status); 174 - } 175 - } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 176 - 177 - width = reg->bit_width; 178 - if (width == 64) { 179 - width = 32; /* Break into two 32-bit transfers */ 180 - } 181 - 182 - status = acpi_hw_write_port((acpi_io_address) 183 - address, ACPI_LODWORD(value), 184 - width); 185 - if (ACPI_FAILURE(status)) { 186 - return (status); 187 - } 188 - 189 - if (reg->bit_width == 64) { 190 - status = acpi_hw_write_port((acpi_io_address) 191 - (address + 4), 192 - ACPI_HIDWORD(value), 32); 193 - if (ACPI_FAILURE(status)) { 194 - return (status); 195 - } 196 - } 197 - } 198 - 199 - ACPI_DEBUG_PRINT((ACPI_DB_IO, 200 - "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", 201 - ACPI_FORMAT_UINT64(value), reg->bit_width, 202 - ACPI_FORMAT_UINT64(address), 203 - acpi_ut_get_region_name(reg->space_id))); 204 - 220 + status = acpi_hw_write(value, reg); 205 221 return (status); 206 222 } 207 223
+2 -2
drivers/acpi/acpica/nsconvert.c
··· 78 78 79 79 /* String-to-Integer conversion */ 80 80 81 - status = acpi_ut_strtoul64(original_object->string.pointer, 82 - acpi_gbl_integer_byte_width, &value); 81 + status = 82 + acpi_ut_strtoul64(original_object->string.pointer, &value); 83 83 if (ACPI_FAILURE(status)) { 84 84 return (status); 85 85 }
+6 -3
drivers/acpi/acpica/tbxface.c
··· 173 173 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); 174 174 175 175 /* 176 - * Only reallocate the root table if the host provided a static buffer 177 - * for the table array in the call to acpi_initialize_tables. 176 + * If there are tables unverified, it is required to reallocate the 177 + * root table list to clean up invalid table entries. Otherwise only 178 + * reallocate the root table list if the host provided a static buffer 179 + * for the table array in the call to acpi_initialize_tables(). 178 180 */ 179 - if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 181 + if ((acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) && 182 + acpi_gbl_enable_table_validation) { 180 183 return_ACPI_STATUS(AE_SUPPORT); 181 184 } 182 185
+438
drivers/acpi/acpica/utstrsuppt.c
··· 1 + /******************************************************************************* 2 + * 3 + * Module Name: utstrsuppt - Support functions for string-to-integer conversion 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 + 47 + #define _COMPONENT ACPI_UTILITIES 48 + ACPI_MODULE_NAME("utstrsuppt") 49 + 50 + /* Local prototypes */ 51 + static acpi_status 52 + acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit); 53 + 54 + static acpi_status 55 + acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product); 56 + 57 + static acpi_status 58 + acpi_ut_strtoul_add64(u64 addend1, u64 addend2, u64 *out_sum); 59 + 60 + /******************************************************************************* 61 + * 62 + * FUNCTION: acpi_ut_convert_octal_string 63 + * 64 + * PARAMETERS: string - Null terminated input string 65 + * return_value_ptr - Where the converted value is returned 66 + * 67 + * RETURN: Status and 64-bit converted integer 68 + * 69 + * DESCRIPTION: Performs a base 8 conversion of the input string to an 70 + * integer value, either 32 or 64 bits. 71 + * 72 + * NOTE: Maximum 64-bit unsigned octal value is 01777777777777777777777 73 + * Maximum 32-bit unsigned octal value is 037777777777 74 + * 75 + ******************************************************************************/ 76 + 77 + acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value_ptr) 78 + { 79 + u64 accumulated_value = 0; 80 + acpi_status status = AE_OK; 81 + 82 + /* Convert each ASCII byte in the input string */ 83 + 84 + while (*string) { 85 + 86 + /* Character must be ASCII 0-7, otherwise terminate with no error */ 87 + 88 + if (!(ACPI_IS_OCTAL_DIGIT(*string))) { 89 + break; 90 + } 91 + 92 + /* Convert and insert this octal digit into the accumulator */ 93 + 94 + status = acpi_ut_insert_digit(&accumulated_value, 8, *string); 95 + if (ACPI_FAILURE(status)) { 96 + status = AE_OCTAL_OVERFLOW; 97 + break; 98 + } 99 + 100 + string++; 101 + } 102 + 103 + /* Always return the value that has been accumulated */ 104 + 105 + *return_value_ptr = accumulated_value; 106 + return (status); 107 + } 108 + 109 + /******************************************************************************* 110 + * 111 + * FUNCTION: acpi_ut_convert_decimal_string 112 + * 113 + * PARAMETERS: string - Null terminated input string 114 + * return_value_ptr - Where the converted value is returned 115 + * 116 + * RETURN: Status and 64-bit converted integer 117 + * 118 + * DESCRIPTION: Performs a base 10 conversion of the input string to an 119 + * integer value, either 32 or 64 bits. 120 + * 121 + * NOTE: Maximum 64-bit unsigned decimal value is 18446744073709551615 122 + * Maximum 32-bit unsigned decimal value is 4294967295 123 + * 124 + ******************************************************************************/ 125 + 126 + acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr) 127 + { 128 + u64 accumulated_value = 0; 129 + acpi_status status = AE_OK; 130 + 131 + /* Convert each ASCII byte in the input string */ 132 + 133 + while (*string) { 134 + 135 + /* Character must be ASCII 0-9, otherwise terminate with no error */ 136 + 137 + if (!isdigit(*string)) { 138 + break; 139 + } 140 + 141 + /* Convert and insert this decimal digit into the accumulator */ 142 + 143 + status = acpi_ut_insert_digit(&accumulated_value, 10, *string); 144 + if (ACPI_FAILURE(status)) { 145 + status = AE_DECIMAL_OVERFLOW; 146 + break; 147 + } 148 + 149 + string++; 150 + } 151 + 152 + /* Always return the value that has been accumulated */ 153 + 154 + *return_value_ptr = accumulated_value; 155 + return (status); 156 + } 157 + 158 + /******************************************************************************* 159 + * 160 + * FUNCTION: acpi_ut_convert_hex_string 161 + * 162 + * PARAMETERS: string - Null terminated input string 163 + * return_value_ptr - Where the converted value is returned 164 + * 165 + * RETURN: Status and 64-bit converted integer 166 + * 167 + * DESCRIPTION: Performs a base 16 conversion of the input string to an 168 + * integer value, either 32 or 64 bits. 169 + * 170 + * NOTE: Maximum 64-bit unsigned hex value is 0xFFFFFFFFFFFFFFFF 171 + * Maximum 32-bit unsigned hex value is 0xFFFFFFFF 172 + * 173 + ******************************************************************************/ 174 + 175 + acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr) 176 + { 177 + u64 accumulated_value = 0; 178 + acpi_status status = AE_OK; 179 + 180 + /* Convert each ASCII byte in the input string */ 181 + 182 + while (*string) { 183 + 184 + /* Must be ASCII A-F, a-f, or 0-9, otherwise terminate with no error */ 185 + 186 + if (!isxdigit(*string)) { 187 + break; 188 + } 189 + 190 + /* Convert and insert this hex digit into the accumulator */ 191 + 192 + status = acpi_ut_insert_digit(&accumulated_value, 16, *string); 193 + if (ACPI_FAILURE(status)) { 194 + status = AE_HEX_OVERFLOW; 195 + break; 196 + } 197 + 198 + string++; 199 + } 200 + 201 + /* Always return the value that has been accumulated */ 202 + 203 + *return_value_ptr = accumulated_value; 204 + return (status); 205 + } 206 + 207 + /******************************************************************************* 208 + * 209 + * FUNCTION: acpi_ut_remove_leading_zeros 210 + * 211 + * PARAMETERS: string - Pointer to input ASCII string 212 + * 213 + * RETURN: Next character after any leading zeros. This character may be 214 + * used by the caller to detect end-of-string. 215 + * 216 + * DESCRIPTION: Remove any leading zeros in the input string. Return the 217 + * next character after the final ASCII zero to enable the caller 218 + * to check for the end of the string (NULL terminator). 219 + * 220 + ******************************************************************************/ 221 + 222 + char acpi_ut_remove_leading_zeros(char **string) 223 + { 224 + 225 + while (**string == ACPI_ASCII_ZERO) { 226 + *string += 1; 227 + } 228 + 229 + return (**string); 230 + } 231 + 232 + /******************************************************************************* 233 + * 234 + * FUNCTION: acpi_ut_remove_whitespace 235 + * 236 + * PARAMETERS: string - Pointer to input ASCII string 237 + * 238 + * RETURN: Next character after any whitespace. This character may be 239 + * used by the caller to detect end-of-string. 240 + * 241 + * DESCRIPTION: Remove any leading whitespace in the input string. Return the 242 + * next character after the final ASCII zero to enable the caller 243 + * to check for the end of the string (NULL terminator). 244 + * 245 + ******************************************************************************/ 246 + 247 + char acpi_ut_remove_whitespace(char **string) 248 + { 249 + 250 + while (isspace((u8)**string)) { 251 + *string += 1; 252 + } 253 + 254 + return (**string); 255 + } 256 + 257 + /******************************************************************************* 258 + * 259 + * FUNCTION: acpi_ut_detect_hex_prefix 260 + * 261 + * PARAMETERS: string - Pointer to input ASCII string 262 + * 263 + * RETURN: TRUE if a "0x" prefix was found at the start of the string 264 + * 265 + * DESCRIPTION: Detect and remove a hex "0x" prefix 266 + * 267 + ******************************************************************************/ 268 + 269 + u8 acpi_ut_detect_hex_prefix(char **string) 270 + { 271 + 272 + if ((**string == ACPI_ASCII_ZERO) && 273 + (tolower((int)*(*string + 1)) == 'x')) { 274 + *string += 2; /* Go past the leading 0x */ 275 + return (TRUE); 276 + } 277 + 278 + return (FALSE); /* Not a hex string */ 279 + } 280 + 281 + /******************************************************************************* 282 + * 283 + * FUNCTION: acpi_ut_detect_octal_prefix 284 + * 285 + * PARAMETERS: string - Pointer to input ASCII string 286 + * 287 + * RETURN: True if an octal "0" prefix was found at the start of the 288 + * string 289 + * 290 + * DESCRIPTION: Detect and remove an octal prefix (zero) 291 + * 292 + ******************************************************************************/ 293 + 294 + u8 acpi_ut_detect_octal_prefix(char **string) 295 + { 296 + 297 + if (**string == ACPI_ASCII_ZERO) { 298 + *string += 1; /* Go past the leading 0 */ 299 + return (TRUE); 300 + } 301 + 302 + return (FALSE); /* Not an octal string */ 303 + } 304 + 305 + /******************************************************************************* 306 + * 307 + * FUNCTION: acpi_ut_insert_digit 308 + * 309 + * PARAMETERS: accumulated_value - Current value of the integer value 310 + * accumulator. The new value is 311 + * returned here. 312 + * base - Radix, either 8/10/16 313 + * ascii_digit - ASCII single digit to be inserted 314 + * 315 + * RETURN: Status and result of the convert/insert operation. The only 316 + * possible returned exception code is numeric overflow of 317 + * either the multiply or add conversion operations. 318 + * 319 + * DESCRIPTION: Generic conversion and insertion function for all bases: 320 + * 321 + * 1) Multiply the current accumulated/converted value by the 322 + * base in order to make room for the new character. 323 + * 324 + * 2) Convert the new character to binary and add it to the 325 + * current accumulated value. 326 + * 327 + * Note: The only possible exception indicates an integer 328 + * overflow (AE_NUMERIC_OVERFLOW) 329 + * 330 + ******************************************************************************/ 331 + 332 + static acpi_status 333 + acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit) 334 + { 335 + acpi_status status; 336 + u64 product; 337 + 338 + /* Make room in the accumulated value for the incoming digit */ 339 + 340 + status = acpi_ut_strtoul_multiply64(*accumulated_value, base, &product); 341 + if (ACPI_FAILURE(status)) { 342 + return (status); 343 + } 344 + 345 + /* Add in the new digit, and store the sum to the accumulated value */ 346 + 347 + status = 348 + acpi_ut_strtoul_add64(product, 349 + acpi_ut_ascii_char_to_hex(ascii_digit), 350 + accumulated_value); 351 + 352 + return (status); 353 + } 354 + 355 + /******************************************************************************* 356 + * 357 + * FUNCTION: acpi_ut_strtoul_multiply64 358 + * 359 + * PARAMETERS: multiplicand - Current accumulated converted integer 360 + * multiplier - Base/Radix 361 + * out_product - Where the product is returned 362 + * 363 + * RETURN: Status and 64-bit product 364 + * 365 + * DESCRIPTION: Multiply two 64-bit values, with checking for 64-bit overflow as 366 + * well as 32-bit overflow if necessary (if the current global 367 + * integer width is 32). 368 + * 369 + ******************************************************************************/ 370 + 371 + static acpi_status 372 + acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product) 373 + { 374 + u64 val; 375 + 376 + /* Exit if either operand is zero */ 377 + 378 + *out_product = 0; 379 + if (!multiplicand || !multiplier) { 380 + return (AE_OK); 381 + } 382 + 383 + /* Check for 64-bit overflow before the actual multiplication */ 384 + 385 + acpi_ut_short_divide(ACPI_UINT64_MAX, (u32)multiplier, &val, NULL); 386 + if (multiplicand > val) { 387 + return (AE_NUMERIC_OVERFLOW); 388 + } 389 + 390 + val = multiplicand * multiplier; 391 + 392 + /* Check for 32-bit overflow if necessary */ 393 + 394 + if ((acpi_gbl_integer_bit_width == 32) && (val > ACPI_UINT32_MAX)) { 395 + return (AE_NUMERIC_OVERFLOW); 396 + } 397 + 398 + *out_product = val; 399 + return (AE_OK); 400 + } 401 + 402 + /******************************************************************************* 403 + * 404 + * FUNCTION: acpi_ut_strtoul_add64 405 + * 406 + * PARAMETERS: addend1 - Current accumulated converted integer 407 + * addend2 - New hex value/char 408 + * out_sum - Where sum is returned (Accumulator) 409 + * 410 + * RETURN: Status and 64-bit sum 411 + * 412 + * DESCRIPTION: Add two 64-bit values, with checking for 64-bit overflow as 413 + * well as 32-bit overflow if necessary (if the current global 414 + * integer width is 32). 415 + * 416 + ******************************************************************************/ 417 + 418 + static acpi_status acpi_ut_strtoul_add64(u64 addend1, u64 addend2, u64 *out_sum) 419 + { 420 + u64 sum; 421 + 422 + /* Check for 64-bit overflow before the actual addition */ 423 + 424 + if ((addend1 > 0) && (addend2 > (ACPI_UINT64_MAX - addend1))) { 425 + return (AE_NUMERIC_OVERFLOW); 426 + } 427 + 428 + sum = addend1 + addend2; 429 + 430 + /* Check for 32-bit overflow if necessary */ 431 + 432 + if ((acpi_gbl_integer_bit_width == 32) && (sum > ACPI_UINT32_MAX)) { 433 + return (AE_NUMERIC_OVERFLOW); 434 + } 435 + 436 + *out_sum = sum; 437 + return (AE_OK); 438 + }
+234 -218
drivers/acpi/acpica/utstrtoul64.c
··· 1 1 /******************************************************************************* 2 2 * 3 - * Module Name: utstrtoul64 - string to 64-bit integer support 3 + * Module Name: utstrtoul64 - String-to-integer conversion support for both 4 + * 64-bit and 32-bit integers 4 5 * 5 6 ******************************************************************************/ 6 7 ··· 45 44 #include <acpi/acpi.h> 46 45 #include "accommon.h" 47 46 48 - /******************************************************************************* 49 - * 50 - * The functions in this module satisfy the need for 64-bit string-to-integer 51 - * conversions on both 32-bit and 64-bit platforms. 52 - * 53 - ******************************************************************************/ 54 - 55 47 #define _COMPONENT ACPI_UTILITIES 56 48 ACPI_MODULE_NAME("utstrtoul64") 57 49 58 - /* Local prototypes */ 59 - static u64 acpi_ut_strtoul_base10(char *string, u32 flags); 60 - 61 - static u64 acpi_ut_strtoul_base16(char *string, u32 flags); 62 - 63 50 /******************************************************************************* 64 51 * 65 - * String conversion rules as written in the ACPI specification. The error 66 - * conditions and behavior are different depending on the type of conversion. 52 + * This module contains the top-level string to 64/32-bit unsigned integer 53 + * conversion functions: 67 54 * 55 + * 1) A standard strtoul() function that supports 64-bit integers, base 56 + * 8/10/16, with integer overflow support. This is used mainly by the 57 + * iASL compiler, which implements tighter constraints on integer 58 + * constants than the runtime (interpreter) integer-to-string conversions. 59 + * 2) Runtime "Explicit conversion" as defined in the ACPI specification. 60 + * 3) Runtime "Implicit conversion" as defined in the ACPI specification. 68 61 * 69 - * Implicit data type conversion: string-to-integer 70 - * -------------------------------------------------- 62 + * Current users of this module: 71 63 * 72 - * Base is always 16. This is the ACPI_STRTOUL_BASE16 case. 64 + * iASL - Preprocessor (constants and math expressions) 65 + * iASL - Main parser, conversion of constants to integers 66 + * iASL - Data Table Compiler parser (constants and math expressions) 67 + * interpreter - Implicit and explicit conversions, GPE method names 68 + * interpreter - Repair code for return values from predefined names 69 + * debugger - Command line input string conversion 70 + * acpi_dump - ACPI table physical addresses 71 + * acpi_exec - Support for namespace overrides 73 72 * 74 - * Example: 75 - * Add ("BA98", Arg0, Local0) 73 + * Notes concerning users of these interfaces: 76 74 * 77 - * The integer is initialized to the value zero. 78 - * The ASCII string is interpreted as a hexadecimal constant. 75 + * acpi_gbl_integer_byte_width is used to set the 32/64 bit limit for explicit 76 + * and implicit conversions. This global must be set to the proper width. 77 + * For the core ACPICA code, the width depends on the DSDT version. For the 78 + * acpi_ut_strtoul64 interface, all conversions are 64 bits. This interface is 79 + * used primarily for iASL, where the default width is 64 bits for all parsers, 80 + * but error checking is performed later to flag cases where a 64-bit constant 81 + * is wrongly defined in a 32-bit DSDT/SSDT. 79 82 * 80 - * 1) A "0x" prefix is not allowed. However, ACPICA allows this for 81 - * compatibility with previous ACPICA. (NO ERROR) 82 - * 83 - * 2) Terminates when the size of an integer is reached (32 or 64 bits). 84 - * (NO ERROR) 85 - * 86 - * 3) The first non-hex character terminates the conversion without error. 87 - * (NO ERROR) 88 - * 89 - * 4) Conversion of a null (zero-length) string to an integer is not 90 - * allowed. However, ACPICA allows this for compatibility with previous 91 - * ACPICA. This conversion returns the value 0. (NO ERROR) 92 - * 93 - * 94 - * Explicit data type conversion: to_integer() with string operand 95 - * --------------------------------------------------------------- 96 - * 97 - * Base is either 10 (default) or 16 (with 0x prefix) 98 - * 99 - * Examples: 100 - * to_integer ("1000") 101 - * to_integer ("0xABCD") 102 - * 103 - * 1) Can be (must be) either a decimal or hexadecimal numeric string. 104 - * A hex value must be prefixed by "0x" or it is interpreted as a decimal. 105 - * 106 - * 2) The value must not exceed the maximum of an integer value. ACPI spec 107 - * states the behavior is "unpredictable", so ACPICA matches the behavior 108 - * of the implicit conversion case.(NO ERROR) 109 - * 110 - * 3) Behavior on the first non-hex character is not specified by the ACPI 111 - * spec, so ACPICA matches the behavior of the implicit conversion case 112 - * and terminates. (NO ERROR) 113 - * 114 - * 4) A null (zero-length) string is illegal. 115 - * However, ACPICA allows this for compatibility with previous ACPICA. 116 - * This conversion returns the value 0. (NO ERROR) 83 + * In ACPI, the only place where octal numbers are supported is within 84 + * the ASL language itself. This is implemented via the main acpi_ut_strtoul64 85 + * interface. According the ACPI specification, there is no ACPI runtime 86 + * support (explicit/implicit) for octal string conversions. 117 87 * 118 88 ******************************************************************************/ 119 - 120 89 /******************************************************************************* 121 90 * 122 91 * FUNCTION: acpi_ut_strtoul64 123 92 * 124 - * PARAMETERS: string - Null terminated input string 125 - * flags - Conversion info, see below 93 + * PARAMETERS: string - Null terminated input string, 94 + * must be a valid pointer 126 95 * return_value - Where the converted integer is 127 - * returned 96 + * returned. Must be a valid pointer 128 97 * 129 - * RETURN: Status and Converted value 98 + * RETURN: Status and converted integer. Returns an exception on a 99 + * 64-bit numeric overflow 130 100 * 131 - * DESCRIPTION: Convert a string into an unsigned value. Performs either a 132 - * 32-bit or 64-bit conversion, depending on the input integer 133 - * size in Flags (often the current mode of the interpreter). 101 + * DESCRIPTION: Convert a string into an unsigned integer. Always performs a 102 + * full 64-bit conversion, regardless of the current global 103 + * integer width. Supports Decimal, Hex, and Octal strings. 134 104 * 135 - * Values for Flags: 136 - * ACPI_STRTOUL_32BIT - Max integer value is 32 bits 137 - * ACPI_STRTOUL_64BIT - Max integer value is 64 bits 138 - * ACPI_STRTOUL_BASE16 - Input string is hexadecimal. Default 139 - * is 10/16 based on string prefix (0x). 105 + * Current users of this function: 140 106 * 141 - * NOTES: 142 - * Negative numbers are not supported, as they are not supported by ACPI. 143 - * 144 - * Supports only base 16 or base 10 strings/values. Does not 145 - * support Octal strings, as these are not supported by ACPI. 146 - * 147 - * Current users of this support: 148 - * 149 - * interpreter - Implicit and explicit conversions, GPE method names 150 - * debugger - Command line input string conversion 151 - * iASL - Main parser, conversion of constants to integers 152 - * iASL - Data Table Compiler parser (constant math expressions) 153 - * iASL - Preprocessor (constant math expressions) 154 - * acpi_dump - Input table addresses 155 - * acpi_exec - Testing of the acpi_ut_strtoul64 function 156 - * 157 - * Note concerning callers: 158 - * acpi_gbl_integer_byte_width can be used to set the 32/64 limit. If used, 159 - * this global should be set to the proper width. For the core ACPICA code, 160 - * this width depends on the DSDT version. For iASL, the default byte 161 - * width is always 8 for the parser, but error checking is performed later 162 - * to flag cases where a 64-bit constant is defined in a 32-bit DSDT/SSDT. 107 + * iASL - Preprocessor (constants and math expressions) 108 + * iASL - Main ASL parser, conversion of ASL constants to integers 109 + * iASL - Data Table Compiler parser (constants and math expressions) 110 + * interpreter - Repair code for return values from predefined names 111 + * acpi_dump - ACPI table physical addresses 112 + * acpi_exec - Support for namespace overrides 163 113 * 164 114 ******************************************************************************/ 165 - 166 - acpi_status acpi_ut_strtoul64(char *string, u32 flags, u64 *return_value) 115 + acpi_status acpi_ut_strtoul64(char *string, u64 *return_value) 167 116 { 168 117 acpi_status status = AE_OK; 169 - u32 base; 118 + u8 original_bit_width; 119 + u32 base = 10; /* Default is decimal */ 170 120 171 121 ACPI_FUNCTION_TRACE_STR(ut_strtoul64, string); 172 122 173 - /* Parameter validation */ 174 - 175 - if (!string || !return_value) { 176 - return_ACPI_STATUS(AE_BAD_PARAMETER); 177 - } 178 - 179 123 *return_value = 0; 180 124 181 - /* Check for zero-length string, returns 0 */ 125 + /* A NULL return string returns a value of zero */ 182 126 183 127 if (*string == 0) { 184 128 return_ACPI_STATUS(AE_OK); 185 129 } 186 130 187 - /* Skip over any white space at start of string */ 188 - 189 - while (isspace((int)*string)) { 190 - string++; 191 - } 192 - 193 - /* End of string? return 0 */ 194 - 195 - if (*string == 0) { 131 + if (!acpi_ut_remove_whitespace(&string)) { 196 132 return_ACPI_STATUS(AE_OK); 197 133 } 198 134 199 135 /* 200 - * 1) The "0x" prefix indicates base 16. Per the ACPI specification, 201 - * the "0x" prefix is only allowed for implicit (non-strict) conversions. 202 - * However, we always allow it for compatibility with older ACPICA. 136 + * 1) Check for a hex constant. A "0x" prefix indicates base 16. 203 137 */ 204 - if ((*string == ACPI_ASCII_ZERO) && 205 - (tolower((int)*(string + 1)) == 'x')) { 206 - string += 2; /* Go past the 0x */ 207 - if (*string == 0) { 208 - return_ACPI_STATUS(AE_OK); /* Return value 0 */ 209 - } 210 - 138 + if (acpi_ut_detect_hex_prefix(&string)) { 211 139 base = 16; 212 140 } 213 141 214 - /* 2) Force to base 16 (implicit conversion case) */ 215 - 216 - else if (flags & ACPI_STRTOUL_BASE16) { 217 - base = 16; 142 + /* 143 + * 2) Check for an octal constant, defined to be a leading zero 144 + * followed by sequence of octal digits (0-7) 145 + */ 146 + else if (acpi_ut_detect_octal_prefix(&string)) { 147 + base = 8; 218 148 } 219 149 220 - /* 3) Default fallback is to Base 10 */ 221 - 222 - else { 223 - base = 10; 150 + if (!acpi_ut_remove_leading_zeros(&string)) { 151 + return_ACPI_STATUS(AE_OK); /* Return value 0 */ 224 152 } 225 153 226 - /* Skip all leading zeros */ 154 + /* 155 + * Force a full 64-bit conversion. The caller (usually iASL) must 156 + * check for a 32-bit overflow later as necessary (If current mode 157 + * is 32-bit, meaning a 32-bit DSDT). 158 + */ 159 + original_bit_width = acpi_gbl_integer_bit_width; 160 + acpi_gbl_integer_bit_width = 64; 227 161 228 - while (*string == ACPI_ASCII_ZERO) { 229 - string++; 230 - if (*string == 0) { 231 - return_ACPI_STATUS(AE_OK); /* Return value 0 */ 232 - } 162 + /* 163 + * Perform the base 8, 10, or 16 conversion. A 64-bit numeric overflow 164 + * will return an exception (to allow iASL to flag the statement). 165 + */ 166 + switch (base) { 167 + case 8: 168 + status = acpi_ut_convert_octal_string(string, return_value); 169 + break; 170 + 171 + case 10: 172 + status = acpi_ut_convert_decimal_string(string, return_value); 173 + break; 174 + 175 + case 16: 176 + default: 177 + status = acpi_ut_convert_hex_string(string, return_value); 178 + break; 233 179 } 234 180 235 - /* Perform the base 16 or 10 conversion */ 181 + /* Only possible exception from above is a 64-bit overflow */ 236 182 237 - if (base == 16) { 238 - *return_value = acpi_ut_strtoul_base16(string, flags); 239 - } else { 240 - *return_value = acpi_ut_strtoul_base10(string, flags); 241 - } 242 - 183 + acpi_gbl_integer_bit_width = original_bit_width; 243 184 return_ACPI_STATUS(status); 244 185 } 245 186 246 187 /******************************************************************************* 247 188 * 248 - * FUNCTION: acpi_ut_strtoul_base10 189 + * FUNCTION: acpi_ut_implicit_strtoul64 249 190 * 250 - * PARAMETERS: string - Null terminated input string 251 - * flags - Conversion info 191 + * PARAMETERS: string - Null terminated input string, 192 + * must be a valid pointer 252 193 * 253 - * RETURN: 64-bit converted integer 194 + * RETURN: Converted integer 254 195 * 255 - * DESCRIPTION: Performs a base 10 conversion of the input string to an 256 - * integer value, either 32 or 64 bits. 257 - * Note: String must be valid and non-null. 196 + * DESCRIPTION: Perform a 64-bit conversion with restrictions placed upon 197 + * an "implicit conversion" by the ACPI specification. Used by 198 + * many ASL operators that require an integer operand, and support 199 + * an automatic (implicit) conversion from a string operand 200 + * to the final integer operand. The major restriction is that 201 + * only hex strings are supported. 202 + * 203 + * ----------------------------------------------------------------------------- 204 + * 205 + * Base is always 16, either with or without the 0x prefix. Decimal and 206 + * Octal strings are not supported, as per the ACPI specification. 207 + * 208 + * Examples (both are hex values): 209 + * Add ("BA98", Arg0, Local0) 210 + * Subtract ("0x12345678", Arg1, Local1) 211 + * 212 + * Conversion rules as extracted from the ACPI specification: 213 + * 214 + * The converted integer is initialized to the value zero. 215 + * The ASCII string is always interpreted as a hexadecimal constant. 216 + * 217 + * 1) According to the ACPI specification, a "0x" prefix is not allowed. 218 + * However, ACPICA allows this as an ACPI extension on general 219 + * principle. (NO ERROR) 220 + * 221 + * 2) The conversion terminates when the size of an integer is reached 222 + * (32 or 64 bits). There are no numeric overflow conditions. (NO ERROR) 223 + * 224 + * 3) The first non-hex character terminates the conversion and returns 225 + * the current accumulated value of the converted integer (NO ERROR). 226 + * 227 + * 4) Conversion of a null (zero-length) string to an integer is 228 + * technically not allowed. However, ACPICA allows this as an ACPI 229 + * extension. The conversion returns the value 0. (NO ERROR) 230 + * 231 + * NOTE: There are no error conditions returned by this function. At 232 + * the minimum, a value of zero is returned. 233 + * 234 + * Current users of this function: 235 + * 236 + * interpreter - All runtime implicit conversions, as per ACPI specification 237 + * iASL - Data Table Compiler parser (constants and math expressions) 258 238 * 259 239 ******************************************************************************/ 260 240 261 - static u64 acpi_ut_strtoul_base10(char *string, u32 flags) 241 + u64 acpi_ut_implicit_strtoul64(char *string) 262 242 { 263 - int ascii_digit; 264 - u64 next_value; 265 - u64 return_value = 0; 243 + u64 converted_integer = 0; 266 244 267 - /* Main loop: convert each ASCII byte in the input string */ 245 + ACPI_FUNCTION_TRACE_STR(ut_implicit_strtoul64, string); 268 246 269 - while (*string) { 270 - ascii_digit = *string; 271 - if (!isdigit(ascii_digit)) { 272 - 273 - /* Not ASCII 0-9, terminate */ 274 - 275 - goto exit; 276 - } 277 - 278 - /* Convert and insert (add) the decimal digit */ 279 - 280 - acpi_ut_short_multiply(return_value, 10, &next_value); 281 - next_value += (ascii_digit - ACPI_ASCII_ZERO); 282 - 283 - /* Check for overflow (32 or 64 bit) - return current converted value */ 284 - 285 - if (((flags & ACPI_STRTOUL_32BIT) && (next_value > ACPI_UINT32_MAX)) || (next_value < return_value)) { /* 64-bit overflow case */ 286 - goto exit; 287 - } 288 - 289 - return_value = next_value; 290 - string++; 247 + if (!acpi_ut_remove_whitespace(&string)) { 248 + return_VALUE(0); 291 249 } 292 250 293 - exit: 294 - return (return_value); 251 + /* 252 + * Per the ACPI specification, only hexadecimal is supported for 253 + * implicit conversions, and the "0x" prefix is "not allowed". 254 + * However, allow a "0x" prefix as an ACPI extension. 255 + */ 256 + acpi_ut_detect_hex_prefix(&string); 257 + 258 + if (!acpi_ut_remove_leading_zeros(&string)) { 259 + return_VALUE(0); 260 + } 261 + 262 + /* 263 + * Ignore overflow as per the ACPI specification. This is implemented by 264 + * ignoring the return status from the conversion function called below. 265 + * On overflow, the input string is simply truncated. 266 + */ 267 + acpi_ut_convert_hex_string(string, &converted_integer); 268 + return_VALUE(converted_integer); 295 269 } 296 270 297 271 /******************************************************************************* 298 272 * 299 - * FUNCTION: acpi_ut_strtoul_base16 273 + * FUNCTION: acpi_ut_explicit_strtoul64 300 274 * 301 - * PARAMETERS: string - Null terminated input string 302 - * flags - conversion info 275 + * PARAMETERS: string - Null terminated input string, 276 + * must be a valid pointer 303 277 * 304 - * RETURN: 64-bit converted integer 278 + * RETURN: Converted integer 305 279 * 306 - * DESCRIPTION: Performs a base 16 conversion of the input string to an 307 - * integer value, either 32 or 64 bits. 308 - * Note: String must be valid and non-null. 280 + * DESCRIPTION: Perform a 64-bit conversion with the restrictions placed upon 281 + * an "explicit conversion" by the ACPI specification. The 282 + * main restriction is that only hex and decimal are supported. 283 + * 284 + * ----------------------------------------------------------------------------- 285 + * 286 + * Base is either 10 (default) or 16 (with 0x prefix). Octal (base 8) strings 287 + * are not supported, as per the ACPI specification. 288 + * 289 + * Examples: 290 + * to_integer ("1000") Decimal 291 + * to_integer ("0xABCD") Hex 292 + * 293 + * Conversion rules as extracted from the ACPI specification: 294 + * 295 + * 1) The input string is either a decimal or hexadecimal numeric string. 296 + * A hex value must be prefixed by "0x" or it is interpreted as decimal. 297 + * 298 + * 2) The value must not exceed the maximum of an integer value 299 + * (32 or 64 bits). The ACPI specification states the behavior is 300 + * "unpredictable", so ACPICA matches the behavior of the implicit 301 + * conversion case. There are no numeric overflow conditions. (NO ERROR) 302 + * 303 + * 3) Behavior on the first non-hex character is not defined by the ACPI 304 + * specification (for the to_integer operator), so ACPICA matches the 305 + * behavior of the implicit conversion case. It terminates the 306 + * conversion and returns the current accumulated value of the converted 307 + * integer. (NO ERROR) 308 + * 309 + * 4) Conversion of a null (zero-length) string to an integer is 310 + * technically not allowed. However, ACPICA allows this as an ACPI 311 + * extension. The conversion returns the value 0. (NO ERROR) 312 + * 313 + * NOTE: There are no error conditions returned by this function. At the 314 + * minimum, a value of zero is returned. 315 + * 316 + * Current users of this function: 317 + * 318 + * interpreter - Runtime ASL to_integer operator, as per the ACPI specification 309 319 * 310 320 ******************************************************************************/ 311 321 312 - static u64 acpi_ut_strtoul_base16(char *string, u32 flags) 322 + u64 acpi_ut_explicit_strtoul64(char *string) 313 323 { 314 - int ascii_digit; 315 - u32 valid_digits = 1; 316 - u64 return_value = 0; 324 + u64 converted_integer = 0; 325 + u32 base = 10; /* Default is decimal */ 317 326 318 - /* Main loop: convert each ASCII byte in the input string */ 327 + ACPI_FUNCTION_TRACE_STR(ut_explicit_strtoul64, string); 319 328 320 - while (*string) { 321 - 322 - /* Check for overflow (32 or 64 bit) - return current converted value */ 323 - 324 - if ((valid_digits > 16) || 325 - ((valid_digits > 8) && (flags & ACPI_STRTOUL_32BIT))) { 326 - goto exit; 327 - } 328 - 329 - ascii_digit = *string; 330 - if (!isxdigit(ascii_digit)) { 331 - 332 - /* Not Hex ASCII A-F, a-f, or 0-9, terminate */ 333 - 334 - goto exit; 335 - } 336 - 337 - /* Convert and insert the hex digit */ 338 - 339 - acpi_ut_short_shift_left(return_value, 4, &return_value); 340 - return_value |= acpi_ut_ascii_char_to_hex(ascii_digit); 341 - 342 - string++; 343 - valid_digits++; 329 + if (!acpi_ut_remove_whitespace(&string)) { 330 + return_VALUE(0); 344 331 } 345 332 346 - exit: 347 - return (return_value); 333 + /* 334 + * Only Hex and Decimal are supported, as per the ACPI specification. 335 + * A "0x" prefix indicates hex; otherwise decimal is assumed. 336 + */ 337 + if (acpi_ut_detect_hex_prefix(&string)) { 338 + base = 16; 339 + } 340 + 341 + if (!acpi_ut_remove_leading_zeros(&string)) { 342 + return_VALUE(0); 343 + } 344 + 345 + /* 346 + * Ignore overflow as per the ACPI specification. This is implemented by 347 + * ignoring the return status from the conversion functions called below. 348 + * On overflow, the input string is simply truncated. 349 + */ 350 + switch (base) { 351 + case 10: 352 + default: 353 + acpi_ut_convert_decimal_string(string, &converted_integer); 354 + break; 355 + 356 + case 16: 357 + acpi_ut_convert_hex_string(string, &converted_integer); 358 + break; 359 + } 360 + 361 + return_VALUE(converted_integer); 348 362 }
+1 -1
drivers/acpi/apei/erst.c
··· 1061 1061 rcd->hdr.error_severity = CPER_SEV_FATAL; 1062 1062 /* timestamp valid. platform_id, partition_id are invalid */ 1063 1063 rcd->hdr.validation_bits = CPER_VALID_TIMESTAMP; 1064 - rcd->hdr.timestamp = get_seconds(); 1064 + rcd->hdr.timestamp = ktime_get_real_seconds(); 1065 1065 rcd->hdr.record_length = sizeof(*rcd) + record->size; 1066 1066 rcd->hdr.creator_id = CPER_CREATOR_PSTORE; 1067 1067 rcd->hdr.notification_type = CPER_NOTIFY_MCE;
+22 -95
drivers/acpi/apei/ghes.c
··· 51 51 #include <acpi/actbl1.h> 52 52 #include <acpi/ghes.h> 53 53 #include <acpi/apei.h> 54 + #include <asm/fixmap.h> 54 55 #include <asm/tlbflush.h> 55 56 #include <ras/ras_event.h> 56 57 ··· 113 112 * Because the memory area used to transfer hardware error information 114 113 * from BIOS to Linux can be determined only in NMI, IRQ or timer 115 114 * handler, but general ioremap can not be used in atomic context, so 116 - * a special version of atomic ioremap is implemented for that. 117 - */ 118 - 119 - /* 120 - * Two virtual pages are used, one for IRQ/PROCESS context, the other for 121 - * NMI context (optionally). 122 - */ 123 - #define GHES_IOREMAP_PAGES 2 124 - #define GHES_IOREMAP_IRQ_PAGE(base) (base) 125 - #define GHES_IOREMAP_NMI_PAGE(base) ((base) + PAGE_SIZE) 126 - 127 - /* virtual memory area for atomic ioremap */ 128 - static struct vm_struct *ghes_ioremap_area; 129 - /* 130 - * These 2 spinlock is used to prevent atomic ioremap virtual memory 131 - * area from being mapped simultaneously. 115 + * the fixmap is used instead. 116 + * 117 + * These 2 spinlocks are used to prevent the fixmap entries from being used 118 + * simultaneously. 132 119 */ 133 120 static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi); 134 121 static DEFINE_SPINLOCK(ghes_ioremap_lock_irq); ··· 129 140 130 141 static int ghes_panic_timeout __read_mostly = 30; 131 142 132 - static int ghes_ioremap_init(void) 133 - { 134 - ghes_ioremap_area = __get_vm_area(PAGE_SIZE * GHES_IOREMAP_PAGES, 135 - VM_IOREMAP, VMALLOC_START, VMALLOC_END); 136 - if (!ghes_ioremap_area) { 137 - pr_err(GHES_PFX "Failed to allocate virtual memory area for atomic ioremap.\n"); 138 - return -ENOMEM; 139 - } 140 - 141 - return 0; 142 - } 143 - 144 - static void ghes_ioremap_exit(void) 145 - { 146 - free_vm_area(ghes_ioremap_area); 147 - } 148 - 149 143 static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn) 150 144 { 151 - unsigned long vaddr; 152 145 phys_addr_t paddr; 153 146 pgprot_t prot; 154 147 155 - vaddr = (unsigned long)GHES_IOREMAP_NMI_PAGE(ghes_ioremap_area->addr); 156 - 157 148 paddr = pfn << PAGE_SHIFT; 158 149 prot = arch_apei_get_mem_attribute(paddr); 159 - ioremap_page_range(vaddr, vaddr + PAGE_SIZE, paddr, prot); 150 + __set_fixmap(FIX_APEI_GHES_NMI, paddr, prot); 160 151 161 - return (void __iomem *)vaddr; 152 + return (void __iomem *) fix_to_virt(FIX_APEI_GHES_NMI); 162 153 } 163 154 164 155 static void __iomem *ghes_ioremap_pfn_irq(u64 pfn) 165 156 { 166 - unsigned long vaddr, paddr; 157 + phys_addr_t paddr; 167 158 pgprot_t prot; 168 - 169 - vaddr = (unsigned long)GHES_IOREMAP_IRQ_PAGE(ghes_ioremap_area->addr); 170 159 171 160 paddr = pfn << PAGE_SHIFT; 172 161 prot = arch_apei_get_mem_attribute(paddr); 162 + __set_fixmap(FIX_APEI_GHES_IRQ, paddr, prot); 173 163 174 - ioremap_page_range(vaddr, vaddr + PAGE_SIZE, paddr, prot); 175 - 176 - return (void __iomem *)vaddr; 164 + return (void __iomem *) fix_to_virt(FIX_APEI_GHES_IRQ); 177 165 } 178 166 179 - static void ghes_iounmap_nmi(void __iomem *vaddr_ptr) 167 + static void ghes_iounmap_nmi(void) 180 168 { 181 - unsigned long vaddr = (unsigned long __force)vaddr_ptr; 182 - void *base = ghes_ioremap_area->addr; 183 - 184 - BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_NMI_PAGE(base)); 185 - unmap_kernel_range_noflush(vaddr, PAGE_SIZE); 186 - arch_apei_flush_tlb_one(vaddr); 169 + clear_fixmap(FIX_APEI_GHES_NMI); 187 170 } 188 171 189 - static void ghes_iounmap_irq(void __iomem *vaddr_ptr) 172 + static void ghes_iounmap_irq(void) 190 173 { 191 - unsigned long vaddr = (unsigned long __force)vaddr_ptr; 192 - void *base = ghes_ioremap_area->addr; 193 - 194 - BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_IRQ_PAGE(base)); 195 - unmap_kernel_range_noflush(vaddr, PAGE_SIZE); 196 - arch_apei_flush_tlb_one(vaddr); 174 + clear_fixmap(FIX_APEI_GHES_IRQ); 197 175 } 198 176 199 177 static int ghes_estatus_pool_init(void) ··· 316 360 paddr += trunk; 317 361 buffer += trunk; 318 362 if (in_nmi) { 319 - ghes_iounmap_nmi(vaddr); 363 + ghes_iounmap_nmi(); 320 364 raw_spin_unlock(&ghes_ioremap_lock_nmi); 321 365 } else { 322 - ghes_iounmap_irq(vaddr); 366 + ghes_iounmap_irq(); 323 367 spin_unlock_irqrestore(&ghes_ioremap_lock_irq, flags); 324 368 } 325 369 } ··· 807 851 synchronize_rcu(); 808 852 } 809 853 #else /* CONFIG_ACPI_APEI_SEA */ 810 - static inline void ghes_sea_add(struct ghes *ghes) 811 - { 812 - pr_err(GHES_PFX "ID: %d, trying to add SEA notification which is not supported\n", 813 - ghes->generic->header.source_id); 814 - } 815 - 816 - static inline void ghes_sea_remove(struct ghes *ghes) 817 - { 818 - pr_err(GHES_PFX "ID: %d, trying to remove SEA notification which is not supported\n", 819 - ghes->generic->header.source_id); 820 - } 854 + static inline void ghes_sea_add(struct ghes *ghes) { } 855 + static inline void ghes_sea_remove(struct ghes *ghes) { } 821 856 #endif /* CONFIG_ACPI_APEI_SEA */ 822 857 823 858 #ifdef CONFIG_HAVE_ACPI_APEI_NMI ··· 1010 1063 init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq); 1011 1064 } 1012 1065 #else /* CONFIG_HAVE_ACPI_APEI_NMI */ 1013 - static inline void ghes_nmi_add(struct ghes *ghes) 1014 - { 1015 - pr_err(GHES_PFX "ID: %d, trying to add NMI notification which is not supported!\n", 1016 - ghes->generic->header.source_id); 1017 - BUG(); 1018 - } 1019 - 1020 - static inline void ghes_nmi_remove(struct ghes *ghes) 1021 - { 1022 - pr_err(GHES_PFX "ID: %d, trying to remove NMI notification which is not supported!\n", 1023 - ghes->generic->header.source_id); 1024 - BUG(); 1025 - } 1026 - 1027 - static inline void ghes_nmi_init_cxt(void) 1028 - { 1029 - } 1066 + static inline void ghes_nmi_add(struct ghes *ghes) { } 1067 + static inline void ghes_nmi_remove(struct ghes *ghes) { } 1068 + static inline void ghes_nmi_init_cxt(void) { } 1030 1069 #endif /* CONFIG_HAVE_ACPI_APEI_NMI */ 1031 1070 1032 1071 static int ghes_probe(struct platform_device *ghes_dev) ··· 1217 1284 1218 1285 ghes_nmi_init_cxt(); 1219 1286 1220 - rc = ghes_ioremap_init(); 1221 - if (rc) 1222 - goto err; 1223 - 1224 1287 rc = ghes_estatus_pool_init(); 1225 1288 if (rc) 1226 - goto err_ioremap_exit; 1289 + goto err; 1227 1290 1228 1291 rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * 1229 1292 GHES_ESTATUS_CACHE_ALLOCED_MAX); ··· 1243 1314 return 0; 1244 1315 err_pool_exit: 1245 1316 ghes_estatus_pool_exit(); 1246 - err_ioremap_exit: 1247 - ghes_ioremap_exit(); 1248 1317 err: 1249 1318 return rc; 1250 1319 }
+21 -5
drivers/acpi/button.c
··· 390 390 { 391 391 struct acpi_button *button = acpi_driver_data(device); 392 392 struct input_dev *input; 393 + int users; 393 394 394 395 switch (event) { 395 396 case ACPI_FIXED_HARDWARE_EVENT: ··· 399 398 case ACPI_BUTTON_NOTIFY_STATUS: 400 399 input = button->input; 401 400 if (button->type == ACPI_BUTTON_TYPE_LID) { 402 - acpi_lid_update_state(device); 401 + mutex_lock(&button->input->mutex); 402 + users = button->input->users; 403 + mutex_unlock(&button->input->mutex); 404 + if (users) 405 + acpi_lid_update_state(device); 403 406 } else { 404 407 int keycode; 405 408 ··· 447 442 struct acpi_button *button = acpi_driver_data(device); 448 443 449 444 button->suspended = false; 450 - if (button->type == ACPI_BUTTON_TYPE_LID) 445 + if (button->type == ACPI_BUTTON_TYPE_LID && button->input->users) 451 446 acpi_lid_initialize_state(device); 452 447 return 0; 453 448 } 454 449 #endif 450 + 451 + static int acpi_lid_input_open(struct input_dev *input) 452 + { 453 + struct acpi_device *device = input_get_drvdata(input); 454 + struct acpi_button *button = acpi_driver_data(device); 455 + 456 + button->last_state = !!acpi_lid_evaluate_state(device); 457 + button->last_time = ktime_get(); 458 + acpi_lid_initialize_state(device); 459 + 460 + return 0; 461 + } 455 462 456 463 static int acpi_button_add(struct acpi_device *device) 457 464 { ··· 505 488 strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID); 506 489 sprintf(class, "%s/%s", 507 490 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); 508 - button->last_state = !!acpi_lid_evaluate_state(device); 509 - button->last_time = ktime_get(); 491 + input->open = acpi_lid_input_open; 510 492 } else { 511 493 printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", hid); 512 494 error = -ENODEV; ··· 538 522 break; 539 523 } 540 524 525 + input_set_drvdata(input, device); 541 526 error = input_register_device(input); 542 527 if (error) 543 528 goto err_remove_fs; 544 529 if (button->type == ACPI_BUTTON_TYPE_LID) { 545 - acpi_lid_initialize_state(device); 546 530 /* 547 531 * This assumes there's only one lid device, or if there are 548 532 * more we only care about the last one...
+150 -88
drivers/acpi/cppc_acpi.c
··· 48 48 struct cppc_pcc_data { 49 49 struct mbox_chan *pcc_channel; 50 50 void __iomem *pcc_comm_addr; 51 - int pcc_subspace_idx; 52 51 bool pcc_channel_acquired; 53 52 ktime_t deadline; 54 53 unsigned int pcc_mpar, pcc_mrtt, pcc_nominal; ··· 74 75 75 76 /* Wait queue for CPUs whose requests were batched */ 76 77 wait_queue_head_t pcc_write_wait_q; 78 + ktime_t last_cmd_cmpl_time; 79 + ktime_t last_mpar_reset; 80 + int mpar_count; 81 + int refcount; 77 82 }; 78 83 79 - /* Structure to represent the single PCC channel */ 80 - static struct cppc_pcc_data pcc_data = { 81 - .pcc_subspace_idx = -1, 82 - .platform_owns_pcc = true, 83 - }; 84 + /* Array to represent the PCC channel per subspace id */ 85 + static struct cppc_pcc_data *pcc_data[MAX_PCC_SUBSPACES]; 86 + /* The cpu_pcc_subspace_idx containsper CPU subspace id */ 87 + static DEFINE_PER_CPU(int, cpu_pcc_subspace_idx); 84 88 85 89 /* 86 90 * The cpc_desc structure contains the ACPI register details ··· 95 93 static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); 96 94 97 95 /* pcc mapped address + header size + offset within PCC subspace */ 98 - #define GET_PCC_VADDR(offs) (pcc_data.pcc_comm_addr + 0x8 + (offs)) 96 + #define GET_PCC_VADDR(offs, pcc_ss_id) (pcc_data[pcc_ss_id]->pcc_comm_addr + \ 97 + 0x8 + (offs)) 99 98 100 99 /* Check if a CPC register is in PCC */ 101 100 #define CPC_IN_PCC(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \ ··· 191 188 .default_attrs = cppc_attrs, 192 189 }; 193 190 194 - static int check_pcc_chan(bool chk_err_bit) 191 + static int check_pcc_chan(int pcc_ss_id, bool chk_err_bit) 195 192 { 196 193 int ret = -EIO, status = 0; 197 - struct acpi_pcct_shared_memory __iomem *generic_comm_base = pcc_data.pcc_comm_addr; 198 - ktime_t next_deadline = ktime_add(ktime_get(), pcc_data.deadline); 194 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 195 + struct acpi_pcct_shared_memory __iomem *generic_comm_base = 196 + pcc_ss_data->pcc_comm_addr; 197 + ktime_t next_deadline = ktime_add(ktime_get(), 198 + pcc_ss_data->deadline); 199 199 200 - if (!pcc_data.platform_owns_pcc) 200 + if (!pcc_ss_data->platform_owns_pcc) 201 201 return 0; 202 202 203 203 /* Retry in case the remote processor was too slow to catch up. */ ··· 225 219 } 226 220 227 221 if (likely(!ret)) 228 - pcc_data.platform_owns_pcc = false; 222 + pcc_ss_data->platform_owns_pcc = false; 229 223 else 230 224 pr_err("PCC check channel failed. Status=%x\n", status); 231 225 ··· 236 230 * This function transfers the ownership of the PCC to the platform 237 231 * So it must be called while holding write_lock(pcc_lock) 238 232 */ 239 - static int send_pcc_cmd(u16 cmd) 233 + static int send_pcc_cmd(int pcc_ss_id, u16 cmd) 240 234 { 241 235 int ret = -EIO, i; 236 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 242 237 struct acpi_pcct_shared_memory *generic_comm_base = 243 - (struct acpi_pcct_shared_memory *) pcc_data.pcc_comm_addr; 244 - static ktime_t last_cmd_cmpl_time, last_mpar_reset; 245 - static int mpar_count; 238 + (struct acpi_pcct_shared_memory *)pcc_ss_data->pcc_comm_addr; 246 239 unsigned int time_delta; 247 240 248 241 /* ··· 254 249 * before write completion, so first send a WRITE command to 255 250 * platform 256 251 */ 257 - if (pcc_data.pending_pcc_write_cmd) 258 - send_pcc_cmd(CMD_WRITE); 252 + if (pcc_ss_data->pending_pcc_write_cmd) 253 + send_pcc_cmd(pcc_ss_id, CMD_WRITE); 259 254 260 - ret = check_pcc_chan(false); 255 + ret = check_pcc_chan(pcc_ss_id, false); 261 256 if (ret) 262 257 goto end; 263 258 } else /* CMD_WRITE */ 264 - pcc_data.pending_pcc_write_cmd = FALSE; 259 + pcc_ss_data->pending_pcc_write_cmd = FALSE; 265 260 266 261 /* 267 262 * Handle the Minimum Request Turnaround Time(MRTT) 268 263 * "The minimum amount of time that OSPM must wait after the completion 269 264 * of a command before issuing the next command, in microseconds" 270 265 */ 271 - if (pcc_data.pcc_mrtt) { 272 - time_delta = ktime_us_delta(ktime_get(), last_cmd_cmpl_time); 273 - if (pcc_data.pcc_mrtt > time_delta) 274 - udelay(pcc_data.pcc_mrtt - time_delta); 266 + if (pcc_ss_data->pcc_mrtt) { 267 + time_delta = ktime_us_delta(ktime_get(), 268 + pcc_ss_data->last_cmd_cmpl_time); 269 + if (pcc_ss_data->pcc_mrtt > time_delta) 270 + udelay(pcc_ss_data->pcc_mrtt - time_delta); 275 271 } 276 272 277 273 /* ··· 286 280 * not send the request to the platform after hitting the MPAR limit in 287 281 * any 60s window 288 282 */ 289 - if (pcc_data.pcc_mpar) { 290 - if (mpar_count == 0) { 291 - time_delta = ktime_ms_delta(ktime_get(), last_mpar_reset); 292 - if (time_delta < 60 * MSEC_PER_SEC) { 283 + if (pcc_ss_data->pcc_mpar) { 284 + if (pcc_ss_data->mpar_count == 0) { 285 + time_delta = ktime_ms_delta(ktime_get(), 286 + pcc_ss_data->last_mpar_reset); 287 + if ((time_delta < 60 * MSEC_PER_SEC) && pcc_ss_data->last_mpar_reset) { 293 288 pr_debug("PCC cmd not sent due to MPAR limit"); 294 289 ret = -EIO; 295 290 goto end; 296 291 } 297 - last_mpar_reset = ktime_get(); 298 - mpar_count = pcc_data.pcc_mpar; 292 + pcc_ss_data->last_mpar_reset = ktime_get(); 293 + pcc_ss_data->mpar_count = pcc_ss_data->pcc_mpar; 299 294 } 300 - mpar_count--; 295 + pcc_ss_data->mpar_count--; 301 296 } 302 297 303 298 /* Write to the shared comm region. */ ··· 307 300 /* Flip CMD COMPLETE bit */ 308 301 writew_relaxed(0, &generic_comm_base->status); 309 302 310 - pcc_data.platform_owns_pcc = true; 303 + pcc_ss_data->platform_owns_pcc = true; 311 304 312 305 /* Ring doorbell */ 313 - ret = mbox_send_message(pcc_data.pcc_channel, &cmd); 306 + ret = mbox_send_message(pcc_ss_data->pcc_channel, &cmd); 314 307 if (ret < 0) { 315 308 pr_err("Err sending PCC mbox message. cmd:%d, ret:%d\n", 316 309 cmd, ret); ··· 318 311 } 319 312 320 313 /* wait for completion and check for PCC errro bit */ 321 - ret = check_pcc_chan(true); 314 + ret = check_pcc_chan(pcc_ss_id, true); 322 315 323 - if (pcc_data.pcc_mrtt) 324 - last_cmd_cmpl_time = ktime_get(); 316 + if (pcc_ss_data->pcc_mrtt) 317 + pcc_ss_data->last_cmd_cmpl_time = ktime_get(); 325 318 326 - if (pcc_data.pcc_channel->mbox->txdone_irq) 327 - mbox_chan_txdone(pcc_data.pcc_channel, ret); 319 + if (pcc_ss_data->pcc_channel->mbox->txdone_irq) 320 + mbox_chan_txdone(pcc_ss_data->pcc_channel, ret); 328 321 else 329 - mbox_client_txdone(pcc_data.pcc_channel, ret); 322 + mbox_client_txdone(pcc_ss_data->pcc_channel, ret); 330 323 331 324 end: 332 325 if (cmd == CMD_WRITE) { ··· 336 329 if (!desc) 337 330 continue; 338 331 339 - if (desc->write_cmd_id == pcc_data.pcc_write_cnt) 332 + if (desc->write_cmd_id == pcc_ss_data->pcc_write_cnt) 340 333 desc->write_cmd_status = ret; 341 334 } 342 335 } 343 - pcc_data.pcc_write_cnt++; 344 - wake_up_all(&pcc_data.pcc_write_wait_q); 336 + pcc_ss_data->pcc_write_cnt++; 337 + wake_up_all(&pcc_ss_data->pcc_write_wait_q); 345 338 } 346 339 347 340 return ret; ··· 543 536 } 544 537 EXPORT_SYMBOL_GPL(acpi_get_psd_map); 545 538 546 - static int register_pcc_channel(int pcc_subspace_idx) 539 + static int register_pcc_channel(int pcc_ss_idx) 547 540 { 548 541 struct acpi_pcct_hw_reduced *cppc_ss; 549 542 u64 usecs_lat; 550 543 551 - if (pcc_subspace_idx >= 0) { 552 - pcc_data.pcc_channel = pcc_mbox_request_channel(&cppc_mbox_cl, 553 - pcc_subspace_idx); 544 + if (pcc_ss_idx >= 0) { 545 + pcc_data[pcc_ss_idx]->pcc_channel = 546 + pcc_mbox_request_channel(&cppc_mbox_cl, pcc_ss_idx); 554 547 555 - if (IS_ERR(pcc_data.pcc_channel)) { 548 + if (IS_ERR(pcc_data[pcc_ss_idx]->pcc_channel)) { 556 549 pr_err("Failed to find PCC communication channel\n"); 557 550 return -ENODEV; 558 551 } ··· 563 556 * PCC channels) and stored pointers to the 564 557 * subspace communication region in con_priv. 565 558 */ 566 - cppc_ss = (pcc_data.pcc_channel)->con_priv; 559 + cppc_ss = (pcc_data[pcc_ss_idx]->pcc_channel)->con_priv; 567 560 568 561 if (!cppc_ss) { 569 562 pr_err("No PCC subspace found for CPPC\n"); ··· 576 569 * So add an arbitrary amount of wait on top of Nominal. 577 570 */ 578 571 usecs_lat = NUM_RETRIES * cppc_ss->latency; 579 - pcc_data.deadline = ns_to_ktime(usecs_lat * NSEC_PER_USEC); 580 - pcc_data.pcc_mrtt = cppc_ss->min_turnaround_time; 581 - pcc_data.pcc_mpar = cppc_ss->max_access_rate; 582 - pcc_data.pcc_nominal = cppc_ss->latency; 572 + pcc_data[pcc_ss_idx]->deadline = ns_to_ktime(usecs_lat * NSEC_PER_USEC); 573 + pcc_data[pcc_ss_idx]->pcc_mrtt = cppc_ss->min_turnaround_time; 574 + pcc_data[pcc_ss_idx]->pcc_mpar = cppc_ss->max_access_rate; 575 + pcc_data[pcc_ss_idx]->pcc_nominal = cppc_ss->latency; 583 576 584 - pcc_data.pcc_comm_addr = acpi_os_ioremap(cppc_ss->base_address, cppc_ss->length); 585 - if (!pcc_data.pcc_comm_addr) { 577 + pcc_data[pcc_ss_idx]->pcc_comm_addr = 578 + acpi_os_ioremap(cppc_ss->base_address, cppc_ss->length); 579 + if (!pcc_data[pcc_ss_idx]->pcc_comm_addr) { 586 580 pr_err("Failed to ioremap PCC comm region mem\n"); 587 581 return -ENOMEM; 588 582 } 589 583 590 584 /* Set flag so that we dont come here for each CPU. */ 591 - pcc_data.pcc_channel_acquired = true; 585 + pcc_data[pcc_ss_idx]->pcc_channel_acquired = true; 592 586 } 593 587 594 588 return 0; ··· 608 600 return false; 609 601 } 610 602 603 + 604 + /** 605 + * pcc_data_alloc() - Allocate the pcc_data memory for pcc subspace 606 + * 607 + * Check and allocate the cppc_pcc_data memory. 608 + * In some processor configurations it is possible that same subspace 609 + * is shared between multiple CPU's. This is seen especially in CPU's 610 + * with hardware multi-threading support. 611 + * 612 + * Return: 0 for success, errno for failure 613 + */ 614 + int pcc_data_alloc(int pcc_ss_id) 615 + { 616 + if (pcc_ss_id < 0 || pcc_ss_id >= MAX_PCC_SUBSPACES) 617 + return -EINVAL; 618 + 619 + if (pcc_data[pcc_ss_id]) { 620 + pcc_data[pcc_ss_id]->refcount++; 621 + } else { 622 + pcc_data[pcc_ss_id] = kzalloc(sizeof(struct cppc_pcc_data), 623 + GFP_KERNEL); 624 + if (!pcc_data[pcc_ss_id]) 625 + return -ENOMEM; 626 + pcc_data[pcc_ss_id]->refcount++; 627 + } 628 + 629 + return 0; 630 + } 611 631 /* 612 632 * An example CPC table looks like the following. 613 633 * ··· 697 661 struct device *cpu_dev; 698 662 acpi_handle handle = pr->handle; 699 663 unsigned int num_ent, i, cpc_rev; 664 + int pcc_subspace_id = -1; 700 665 acpi_status status; 701 666 int ret = -EFAULT; 702 667 ··· 770 733 * so extract it only once. 771 734 */ 772 735 if (gas_t->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) { 773 - if (pcc_data.pcc_subspace_idx < 0) 774 - pcc_data.pcc_subspace_idx = gas_t->access_width; 775 - else if (pcc_data.pcc_subspace_idx != gas_t->access_width) { 736 + if (pcc_subspace_id < 0) { 737 + pcc_subspace_id = gas_t->access_width; 738 + if (pcc_data_alloc(pcc_subspace_id)) 739 + goto out_free; 740 + } else if (pcc_subspace_id != gas_t->access_width) { 776 741 pr_debug("Mismatched PCC ids.\n"); 777 742 goto out_free; 778 743 } ··· 802 763 goto out_free; 803 764 } 804 765 } 766 + per_cpu(cpu_pcc_subspace_idx, pr->id) = pcc_subspace_id; 805 767 /* Store CPU Logical ID */ 806 768 cpc_ptr->cpu_id = pr->id; 807 769 ··· 811 771 if (ret) 812 772 goto out_free; 813 773 814 - /* Register PCC channel once for all CPUs. */ 815 - if (!pcc_data.pcc_channel_acquired) { 816 - ret = register_pcc_channel(pcc_data.pcc_subspace_idx); 774 + /* Register PCC channel once for all PCC subspace id. */ 775 + if (pcc_subspace_id >= 0 && !pcc_data[pcc_subspace_id]->pcc_channel_acquired) { 776 + ret = register_pcc_channel(pcc_subspace_id); 817 777 if (ret) 818 778 goto out_free; 819 779 820 - init_rwsem(&pcc_data.pcc_lock); 821 - init_waitqueue_head(&pcc_data.pcc_write_wait_q); 780 + init_rwsem(&pcc_data[pcc_subspace_id]->pcc_lock); 781 + init_waitqueue_head(&pcc_data[pcc_subspace_id]->pcc_write_wait_q); 822 782 } 823 783 824 784 /* Everything looks okay */ ··· 871 831 struct cpc_desc *cpc_ptr; 872 832 unsigned int i; 873 833 void __iomem *addr; 834 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id); 835 + 836 + if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) { 837 + if (pcc_data[pcc_ss_id]->pcc_channel_acquired) { 838 + pcc_data[pcc_ss_id]->refcount--; 839 + if (!pcc_data[pcc_ss_id]->refcount) { 840 + pcc_mbox_free_channel(pcc_data[pcc_ss_id]->pcc_channel); 841 + pcc_data[pcc_ss_id]->pcc_channel_acquired = 0; 842 + kfree(pcc_data[pcc_ss_id]); 843 + } 844 + } 845 + } 874 846 875 847 cpc_ptr = per_cpu(cpc_desc_ptr, pr->id); 876 848 if (!cpc_ptr) ··· 940 888 { 941 889 int ret_val = 0; 942 890 void __iomem *vaddr = 0; 891 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); 943 892 struct cpc_reg *reg = &reg_res->cpc_entry.reg; 944 893 945 894 if (reg_res->type == ACPI_TYPE_INTEGER) { ··· 950 897 951 898 *val = 0; 952 899 if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) 953 - vaddr = GET_PCC_VADDR(reg->address); 900 + vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); 954 901 else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 955 902 vaddr = reg_res->sys_mem_vaddr; 956 903 else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ··· 985 932 { 986 933 int ret_val = 0; 987 934 void __iomem *vaddr = 0; 935 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); 988 936 struct cpc_reg *reg = &reg_res->cpc_entry.reg; 989 937 990 938 if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) 991 - vaddr = GET_PCC_VADDR(reg->address); 939 + vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); 992 940 else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 993 941 vaddr = reg_res->sys_mem_vaddr; 994 942 else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ··· 1034 980 struct cpc_register_resource *highest_reg, *lowest_reg, 1035 981 *lowest_non_linear_reg, *nominal_reg; 1036 982 u64 high, low, nom, min_nonlinear; 983 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); 984 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 1037 985 int ret = 0, regs_in_pcc = 0; 1038 986 1039 987 if (!cpc_desc) { ··· 1052 996 if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) || 1053 997 CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg)) { 1054 998 regs_in_pcc = 1; 1055 - down_write(&pcc_data.pcc_lock); 999 + down_write(&pcc_ss_data->pcc_lock); 1056 1000 /* Ring doorbell once to update PCC subspace */ 1057 - if (send_pcc_cmd(CMD_READ) < 0) { 1001 + if (send_pcc_cmd(pcc_ss_id, CMD_READ) < 0) { 1058 1002 ret = -EIO; 1059 1003 goto out_err; 1060 1004 } ··· 1077 1021 1078 1022 out_err: 1079 1023 if (regs_in_pcc) 1080 - up_write(&pcc_data.pcc_lock); 1024 + up_write(&pcc_ss_data->pcc_lock); 1081 1025 return ret; 1082 1026 } 1083 1027 EXPORT_SYMBOL_GPL(cppc_get_perf_caps); ··· 1094 1038 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); 1095 1039 struct cpc_register_resource *delivered_reg, *reference_reg, 1096 1040 *ref_perf_reg, *ctr_wrap_reg; 1041 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); 1042 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 1097 1043 u64 delivered, reference, ref_perf, ctr_wrap_time; 1098 1044 int ret = 0, regs_in_pcc = 0; 1099 1045 ··· 1119 1061 /* Are any of the regs PCC ?*/ 1120 1062 if (CPC_IN_PCC(delivered_reg) || CPC_IN_PCC(reference_reg) || 1121 1063 CPC_IN_PCC(ctr_wrap_reg) || CPC_IN_PCC(ref_perf_reg)) { 1122 - down_write(&pcc_data.pcc_lock); 1064 + down_write(&pcc_ss_data->pcc_lock); 1123 1065 regs_in_pcc = 1; 1124 1066 /* Ring doorbell once to update PCC subspace */ 1125 - if (send_pcc_cmd(CMD_READ) < 0) { 1067 + if (send_pcc_cmd(pcc_ss_id, CMD_READ) < 0) { 1126 1068 ret = -EIO; 1127 1069 goto out_err; 1128 1070 } ··· 1152 1094 perf_fb_ctrs->wraparound_time = ctr_wrap_time; 1153 1095 out_err: 1154 1096 if (regs_in_pcc) 1155 - up_write(&pcc_data.pcc_lock); 1097 + up_write(&pcc_ss_data->pcc_lock); 1156 1098 return ret; 1157 1099 } 1158 1100 EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); ··· 1168 1110 { 1169 1111 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); 1170 1112 struct cpc_register_resource *desired_reg; 1113 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); 1114 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 1171 1115 int ret = 0; 1172 1116 1173 1117 if (!cpc_desc) { ··· 1187 1127 * achieve that goal here 1188 1128 */ 1189 1129 if (CPC_IN_PCC(desired_reg)) { 1190 - down_read(&pcc_data.pcc_lock); /* BEGIN Phase-I */ 1191 - if (pcc_data.platform_owns_pcc) { 1192 - ret = check_pcc_chan(false); 1130 + down_read(&pcc_ss_data->pcc_lock); /* BEGIN Phase-I */ 1131 + if (pcc_ss_data->platform_owns_pcc) { 1132 + ret = check_pcc_chan(pcc_ss_id, false); 1193 1133 if (ret) { 1194 - up_read(&pcc_data.pcc_lock); 1134 + up_read(&pcc_ss_data->pcc_lock); 1195 1135 return ret; 1196 1136 } 1197 1137 } ··· 1199 1139 * Update the pending_write to make sure a PCC CMD_READ will not 1200 1140 * arrive and steal the channel during the switch to write lock 1201 1141 */ 1202 - pcc_data.pending_pcc_write_cmd = true; 1203 - cpc_desc->write_cmd_id = pcc_data.pcc_write_cnt; 1142 + pcc_ss_data->pending_pcc_write_cmd = true; 1143 + cpc_desc->write_cmd_id = pcc_ss_data->pcc_write_cnt; 1204 1144 cpc_desc->write_cmd_status = 0; 1205 1145 } 1206 1146 ··· 1211 1151 cpc_write(cpu, desired_reg, perf_ctrls->desired_perf); 1212 1152 1213 1153 if (CPC_IN_PCC(desired_reg)) 1214 - up_read(&pcc_data.pcc_lock); /* END Phase-I */ 1154 + up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ 1215 1155 /* 1216 1156 * This is Phase-II where we transfer the ownership of PCC to Platform 1217 1157 * ··· 1259 1199 * the write command before servicing the read command 1260 1200 */ 1261 1201 if (CPC_IN_PCC(desired_reg)) { 1262 - if (down_write_trylock(&pcc_data.pcc_lock)) { /* BEGIN Phase-II */ 1202 + if (down_write_trylock(&pcc_ss_data->pcc_lock)) {/* BEGIN Phase-II */ 1263 1203 /* Update only if there are pending write commands */ 1264 - if (pcc_data.pending_pcc_write_cmd) 1265 - send_pcc_cmd(CMD_WRITE); 1266 - up_write(&pcc_data.pcc_lock); /* END Phase-II */ 1204 + if (pcc_ss_data->pending_pcc_write_cmd) 1205 + send_pcc_cmd(pcc_ss_id, CMD_WRITE); 1206 + up_write(&pcc_ss_data->pcc_lock); /* END Phase-II */ 1267 1207 } else 1268 1208 /* Wait until pcc_write_cnt is updated by send_pcc_cmd */ 1269 - wait_event(pcc_data.pcc_write_wait_q, 1270 - cpc_desc->write_cmd_id != pcc_data.pcc_write_cnt); 1209 + wait_event(pcc_ss_data->pcc_write_wait_q, 1210 + cpc_desc->write_cmd_id != pcc_ss_data->pcc_write_cnt); 1271 1211 1272 1212 /* send_pcc_cmd updates the status in case of failure */ 1273 1213 ret = cpc_desc->write_cmd_status; ··· 1300 1240 unsigned int latency_ns = 0; 1301 1241 struct cpc_desc *cpc_desc; 1302 1242 struct cpc_register_resource *desired_reg; 1243 + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu_num); 1244 + struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; 1303 1245 1304 1246 cpc_desc = per_cpu(cpc_desc_ptr, cpu_num); 1305 1247 if (!cpc_desc) ··· 1311 1249 if (!CPC_IN_PCC(desired_reg)) 1312 1250 return CPUFREQ_ETERNAL; 1313 1251 1314 - if (pcc_data.pcc_mpar) 1315 - latency_ns = 60 * (1000 * 1000 * 1000 / pcc_data.pcc_mpar); 1252 + if (pcc_ss_data->pcc_mpar) 1253 + latency_ns = 60 * (1000 * 1000 * 1000 / pcc_ss_data->pcc_mpar); 1316 1254 1317 - latency_ns = max(latency_ns, pcc_data.pcc_nominal * 1000); 1318 - latency_ns = max(latency_ns, pcc_data.pcc_mrtt * 1000); 1255 + latency_ns = max(latency_ns, pcc_ss_data->pcc_nominal * 1000); 1256 + latency_ns = max(latency_ns, pcc_ss_data->pcc_mrtt * 1000); 1319 1257 1320 1258 return latency_ns; 1321 1259 }
+1
drivers/acpi/dock.c
··· 482 482 surprise_removal = 1; 483 483 event = ACPI_NOTIFY_EJECT_REQUEST; 484 484 /* Fall back */ 485 + /* fall through */ 485 486 case ACPI_NOTIFY_EJECT_REQUEST: 486 487 begin_undock(ds); 487 488 if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
+7 -5
drivers/acpi/ec.c
··· 486 486 { 487 487 if (!test_and_set_bit(EC_FLAGS_QUERY_ENABLED, &ec->flags)) 488 488 ec_log_drv("event unblocked"); 489 - if (!test_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) 490 - advance_transaction(ec); 489 + /* 490 + * Unconditionally invoke this once after enabling the event 491 + * handling mechanism to detect the pending events. 492 + */ 493 + advance_transaction(ec); 491 494 } 492 495 493 496 static inline void __acpi_ec_disable_event(struct acpi_ec *ec) ··· 1459 1456 if (test_bit(EC_FLAGS_STARTED, &ec->flags) && 1460 1457 ec->reference_count >= 1) 1461 1458 acpi_ec_enable_gpe(ec, true); 1462 - 1463 - /* EC is fully operational, allow queries */ 1464 - acpi_ec_enable_event(ec); 1465 1459 } 1466 1460 } 1461 + /* EC is fully operational, allow queries */ 1462 + acpi_ec_enable_event(ec); 1467 1463 1468 1464 return 0; 1469 1465 }
+455
drivers/acpi/pmic/tps68470_pmic.c
··· 1 + /* 2 + * TI TPS68470 PMIC operation region driver 3 + * 4 + * Copyright (C) 2017 Intel Corporation. All rights reserved. 5 + * 6 + * Author: Rajmohan Mani <rajmohan.mani@intel.com> 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License version 10 + * 2 as published by the Free Software Foundation. 11 + * 12 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 13 + * kind, whether express or implied; without even the implied warranty 14 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * Based on drivers/acpi/pmic/intel_pmic* drivers 18 + */ 19 + 20 + #include <linux/acpi.h> 21 + #include <linux/mfd/tps68470.h> 22 + #include <linux/init.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/regmap.h> 25 + 26 + struct tps68470_pmic_table { 27 + u32 address; /* operation region address */ 28 + u32 reg; /* corresponding register */ 29 + u32 bitmask; /* bit mask for power, clock */ 30 + }; 31 + 32 + #define TI_PMIC_POWER_OPREGION_ID 0xB0 33 + #define TI_PMIC_VR_VAL_OPREGION_ID 0xB1 34 + #define TI_PMIC_CLOCK_OPREGION_ID 0xB2 35 + #define TI_PMIC_CLKFREQ_OPREGION_ID 0xB3 36 + 37 + struct tps68470_pmic_opregion { 38 + struct mutex lock; 39 + struct regmap *regmap; 40 + }; 41 + 42 + #define S_IO_I2C_EN (BIT(0) | BIT(1)) 43 + 44 + static const struct tps68470_pmic_table power_table[] = { 45 + { 46 + .address = 0x00, 47 + .reg = TPS68470_REG_S_I2C_CTL, 48 + .bitmask = S_IO_I2C_EN, 49 + /* S_I2C_CTL */ 50 + }, 51 + { 52 + .address = 0x04, 53 + .reg = TPS68470_REG_VCMCTL, 54 + .bitmask = BIT(0), 55 + /* VCMCTL */ 56 + }, 57 + { 58 + .address = 0x08, 59 + .reg = TPS68470_REG_VAUX1CTL, 60 + .bitmask = BIT(0), 61 + /* VAUX1_CTL */ 62 + }, 63 + { 64 + .address = 0x0C, 65 + .reg = TPS68470_REG_VAUX2CTL, 66 + .bitmask = BIT(0), 67 + /* VAUX2CTL */ 68 + }, 69 + { 70 + .address = 0x10, 71 + .reg = TPS68470_REG_VACTL, 72 + .bitmask = BIT(0), 73 + /* VACTL */ 74 + }, 75 + { 76 + .address = 0x14, 77 + .reg = TPS68470_REG_VDCTL, 78 + .bitmask = BIT(0), 79 + /* VDCTL */ 80 + }, 81 + }; 82 + 83 + /* Table to set voltage regulator value */ 84 + static const struct tps68470_pmic_table vr_val_table[] = { 85 + { 86 + .address = 0x00, 87 + .reg = TPS68470_REG_VSIOVAL, 88 + .bitmask = TPS68470_VSIOVAL_IOVOLT_MASK, 89 + /* TPS68470_REG_VSIOVAL */ 90 + }, 91 + { 92 + .address = 0x04, 93 + .reg = TPS68470_REG_VIOVAL, 94 + .bitmask = TPS68470_VIOVAL_IOVOLT_MASK, 95 + /* TPS68470_REG_VIOVAL */ 96 + }, 97 + { 98 + .address = 0x08, 99 + .reg = TPS68470_REG_VCMVAL, 100 + .bitmask = TPS68470_VCMVAL_VCVOLT_MASK, 101 + /* TPS68470_REG_VCMVAL */ 102 + }, 103 + { 104 + .address = 0x0C, 105 + .reg = TPS68470_REG_VAUX1VAL, 106 + .bitmask = TPS68470_VAUX1VAL_AUX1VOLT_MASK, 107 + /* TPS68470_REG_VAUX1VAL */ 108 + }, 109 + { 110 + .address = 0x10, 111 + .reg = TPS68470_REG_VAUX2VAL, 112 + .bitmask = TPS68470_VAUX2VAL_AUX2VOLT_MASK, 113 + /* TPS68470_REG_VAUX2VAL */ 114 + }, 115 + { 116 + .address = 0x14, 117 + .reg = TPS68470_REG_VAVAL, 118 + .bitmask = TPS68470_VAVAL_AVOLT_MASK, 119 + /* TPS68470_REG_VAVAL */ 120 + }, 121 + { 122 + .address = 0x18, 123 + .reg = TPS68470_REG_VDVAL, 124 + .bitmask = TPS68470_VDVAL_DVOLT_MASK, 125 + /* TPS68470_REG_VDVAL */ 126 + }, 127 + }; 128 + 129 + /* Table to configure clock frequency */ 130 + static const struct tps68470_pmic_table clk_freq_table[] = { 131 + { 132 + .address = 0x00, 133 + .reg = TPS68470_REG_POSTDIV2, 134 + .bitmask = BIT(0) | BIT(1), 135 + /* TPS68470_REG_POSTDIV2 */ 136 + }, 137 + { 138 + .address = 0x04, 139 + .reg = TPS68470_REG_BOOSTDIV, 140 + .bitmask = 0x1F, 141 + /* TPS68470_REG_BOOSTDIV */ 142 + }, 143 + { 144 + .address = 0x08, 145 + .reg = TPS68470_REG_BUCKDIV, 146 + .bitmask = 0x0F, 147 + /* TPS68470_REG_BUCKDIV */ 148 + }, 149 + { 150 + .address = 0x0C, 151 + .reg = TPS68470_REG_PLLSWR, 152 + .bitmask = 0x13, 153 + /* TPS68470_REG_PLLSWR */ 154 + }, 155 + { 156 + .address = 0x10, 157 + .reg = TPS68470_REG_XTALDIV, 158 + .bitmask = 0xFF, 159 + /* TPS68470_REG_XTALDIV */ 160 + }, 161 + { 162 + .address = 0x14, 163 + .reg = TPS68470_REG_PLLDIV, 164 + .bitmask = 0xFF, 165 + /* TPS68470_REG_PLLDIV */ 166 + }, 167 + { 168 + .address = 0x18, 169 + .reg = TPS68470_REG_POSTDIV, 170 + .bitmask = 0x83, 171 + /* TPS68470_REG_POSTDIV */ 172 + }, 173 + }; 174 + 175 + /* Table to configure and enable clocks */ 176 + static const struct tps68470_pmic_table clk_table[] = { 177 + { 178 + .address = 0x00, 179 + .reg = TPS68470_REG_PLLCTL, 180 + .bitmask = 0xF5, 181 + /* TPS68470_REG_PLLCTL */ 182 + }, 183 + { 184 + .address = 0x04, 185 + .reg = TPS68470_REG_PLLCTL2, 186 + .bitmask = BIT(0), 187 + /* TPS68470_REG_PLLCTL2 */ 188 + }, 189 + { 190 + .address = 0x08, 191 + .reg = TPS68470_REG_CLKCFG1, 192 + .bitmask = TPS68470_CLKCFG1_MODE_A_MASK | 193 + TPS68470_CLKCFG1_MODE_B_MASK, 194 + /* TPS68470_REG_CLKCFG1 */ 195 + }, 196 + { 197 + .address = 0x0C, 198 + .reg = TPS68470_REG_CLKCFG2, 199 + .bitmask = TPS68470_CLKCFG1_MODE_A_MASK | 200 + TPS68470_CLKCFG1_MODE_B_MASK, 201 + /* TPS68470_REG_CLKCFG2 */ 202 + }, 203 + }; 204 + 205 + static int pmic_get_reg_bit(u64 address, 206 + const struct tps68470_pmic_table *table, 207 + const unsigned int table_size, int *reg, 208 + int *bitmask) 209 + { 210 + u64 i; 211 + 212 + i = address / 4; 213 + if (i >= table_size) 214 + return -ENOENT; 215 + 216 + if (!reg || !bitmask) 217 + return -EINVAL; 218 + 219 + *reg = table[i].reg; 220 + *bitmask = table[i].bitmask; 221 + 222 + return 0; 223 + } 224 + 225 + static int tps68470_pmic_get_power(struct regmap *regmap, int reg, 226 + int bitmask, u64 *value) 227 + { 228 + unsigned int data; 229 + 230 + if (regmap_read(regmap, reg, &data)) 231 + return -EIO; 232 + 233 + *value = (data & bitmask) ? 1 : 0; 234 + return 0; 235 + } 236 + 237 + static int tps68470_pmic_get_vr_val(struct regmap *regmap, int reg, 238 + int bitmask, u64 *value) 239 + { 240 + unsigned int data; 241 + 242 + if (regmap_read(regmap, reg, &data)) 243 + return -EIO; 244 + 245 + *value = data & bitmask; 246 + return 0; 247 + } 248 + 249 + static int tps68470_pmic_get_clk(struct regmap *regmap, int reg, 250 + int bitmask, u64 *value) 251 + { 252 + unsigned int data; 253 + 254 + if (regmap_read(regmap, reg, &data)) 255 + return -EIO; 256 + 257 + *value = (data & bitmask) ? 1 : 0; 258 + return 0; 259 + } 260 + 261 + static int tps68470_pmic_get_clk_freq(struct regmap *regmap, int reg, 262 + int bitmask, u64 *value) 263 + { 264 + unsigned int data; 265 + 266 + if (regmap_read(regmap, reg, &data)) 267 + return -EIO; 268 + 269 + *value = data & bitmask; 270 + return 0; 271 + } 272 + 273 + static int ti_tps68470_regmap_update_bits(struct regmap *regmap, int reg, 274 + int bitmask, u64 value) 275 + { 276 + return regmap_update_bits(regmap, reg, bitmask, value); 277 + } 278 + 279 + static acpi_status tps68470_pmic_common_handler(u32 function, 280 + acpi_physical_address address, 281 + u32 bits, u64 *value, 282 + void *region_context, 283 + int (*get)(struct regmap *, 284 + int, int, u64 *), 285 + int (*update)(struct regmap *, 286 + int, int, u64), 287 + const struct tps68470_pmic_table *tbl, 288 + unsigned int tbl_size) 289 + { 290 + struct tps68470_pmic_opregion *opregion = region_context; 291 + struct regmap *regmap = opregion->regmap; 292 + int reg, ret, bitmask; 293 + 294 + if (bits != 32) 295 + return AE_BAD_PARAMETER; 296 + 297 + ret = pmic_get_reg_bit(address, tbl, tbl_size, &reg, &bitmask); 298 + if (ret < 0) 299 + return AE_BAD_PARAMETER; 300 + 301 + if (function == ACPI_WRITE && *value > bitmask) 302 + return AE_BAD_PARAMETER; 303 + 304 + mutex_lock(&opregion->lock); 305 + 306 + ret = (function == ACPI_READ) ? 307 + get(regmap, reg, bitmask, value) : 308 + update(regmap, reg, bitmask, *value); 309 + 310 + mutex_unlock(&opregion->lock); 311 + 312 + return ret ? AE_ERROR : AE_OK; 313 + } 314 + 315 + static acpi_status tps68470_pmic_cfreq_handler(u32 function, 316 + acpi_physical_address address, 317 + u32 bits, u64 *value, 318 + void *handler_context, 319 + void *region_context) 320 + { 321 + return tps68470_pmic_common_handler(function, address, bits, value, 322 + region_context, 323 + tps68470_pmic_get_clk_freq, 324 + ti_tps68470_regmap_update_bits, 325 + clk_freq_table, 326 + ARRAY_SIZE(clk_freq_table)); 327 + } 328 + 329 + static acpi_status tps68470_pmic_clk_handler(u32 function, 330 + acpi_physical_address address, u32 bits, 331 + u64 *value, void *handler_context, 332 + void *region_context) 333 + { 334 + return tps68470_pmic_common_handler(function, address, bits, value, 335 + region_context, 336 + tps68470_pmic_get_clk, 337 + ti_tps68470_regmap_update_bits, 338 + clk_table, 339 + ARRAY_SIZE(clk_table)); 340 + } 341 + 342 + static acpi_status tps68470_pmic_vrval_handler(u32 function, 343 + acpi_physical_address address, 344 + u32 bits, u64 *value, 345 + void *handler_context, 346 + void *region_context) 347 + { 348 + return tps68470_pmic_common_handler(function, address, bits, value, 349 + region_context, 350 + tps68470_pmic_get_vr_val, 351 + ti_tps68470_regmap_update_bits, 352 + vr_val_table, 353 + ARRAY_SIZE(vr_val_table)); 354 + } 355 + 356 + static acpi_status tps68470_pmic_pwr_handler(u32 function, 357 + acpi_physical_address address, 358 + u32 bits, u64 *value, 359 + void *handler_context, 360 + void *region_context) 361 + { 362 + if (bits != 32) 363 + return AE_BAD_PARAMETER; 364 + 365 + /* set/clear for bit 0, bits 0 and 1 together */ 366 + if (function == ACPI_WRITE && 367 + !(*value == 0 || *value == 1 || *value == 3)) { 368 + return AE_BAD_PARAMETER; 369 + } 370 + 371 + return tps68470_pmic_common_handler(function, address, bits, value, 372 + region_context, 373 + tps68470_pmic_get_power, 374 + ti_tps68470_regmap_update_bits, 375 + power_table, 376 + ARRAY_SIZE(power_table)); 377 + } 378 + 379 + static int tps68470_pmic_opregion_probe(struct platform_device *pdev) 380 + { 381 + struct regmap *tps68470_regmap = dev_get_drvdata(pdev->dev.parent); 382 + acpi_handle handle = ACPI_HANDLE(pdev->dev.parent); 383 + struct device *dev = &pdev->dev; 384 + struct tps68470_pmic_opregion *opregion; 385 + acpi_status status; 386 + 387 + if (!dev || !tps68470_regmap) { 388 + dev_warn(dev, "dev or regmap is NULL\n"); 389 + return -EINVAL; 390 + } 391 + 392 + if (!handle) { 393 + dev_warn(dev, "acpi handle is NULL\n"); 394 + return -ENODEV; 395 + } 396 + 397 + opregion = devm_kzalloc(dev, sizeof(*opregion), GFP_KERNEL); 398 + if (!opregion) 399 + return -ENOMEM; 400 + 401 + mutex_init(&opregion->lock); 402 + opregion->regmap = tps68470_regmap; 403 + 404 + status = acpi_install_address_space_handler(handle, 405 + TI_PMIC_POWER_OPREGION_ID, 406 + tps68470_pmic_pwr_handler, 407 + NULL, opregion); 408 + if (ACPI_FAILURE(status)) 409 + goto out_mutex_destroy; 410 + 411 + status = acpi_install_address_space_handler(handle, 412 + TI_PMIC_VR_VAL_OPREGION_ID, 413 + tps68470_pmic_vrval_handler, 414 + NULL, opregion); 415 + if (ACPI_FAILURE(status)) 416 + goto out_remove_power_handler; 417 + 418 + status = acpi_install_address_space_handler(handle, 419 + TI_PMIC_CLOCK_OPREGION_ID, 420 + tps68470_pmic_clk_handler, 421 + NULL, opregion); 422 + if (ACPI_FAILURE(status)) 423 + goto out_remove_vr_val_handler; 424 + 425 + status = acpi_install_address_space_handler(handle, 426 + TI_PMIC_CLKFREQ_OPREGION_ID, 427 + tps68470_pmic_cfreq_handler, 428 + NULL, opregion); 429 + if (ACPI_FAILURE(status)) 430 + goto out_remove_clk_handler; 431 + 432 + return 0; 433 + 434 + out_remove_clk_handler: 435 + acpi_remove_address_space_handler(handle, TI_PMIC_CLOCK_OPREGION_ID, 436 + tps68470_pmic_clk_handler); 437 + out_remove_vr_val_handler: 438 + acpi_remove_address_space_handler(handle, TI_PMIC_VR_VAL_OPREGION_ID, 439 + tps68470_pmic_vrval_handler); 440 + out_remove_power_handler: 441 + acpi_remove_address_space_handler(handle, TI_PMIC_POWER_OPREGION_ID, 442 + tps68470_pmic_pwr_handler); 443 + out_mutex_destroy: 444 + mutex_destroy(&opregion->lock); 445 + return -ENODEV; 446 + } 447 + 448 + static struct platform_driver tps68470_pmic_opregion_driver = { 449 + .probe = tps68470_pmic_opregion_probe, 450 + .driver = { 451 + .name = "tps68470_pmic_opregion", 452 + }, 453 + }; 454 + 455 + builtin_platform_driver(tps68470_pmic_opregion_driver)
+1
drivers/acpi/resource.c
··· 381 381 case ACPI_ACTIVE_BOTH: 382 382 if (triggering == ACPI_EDGE_SENSITIVE) 383 383 return IRQ_TYPE_EDGE_BOTH; 384 + /* fall through */ 384 385 default: 385 386 return IRQ_TYPE_NONE; 386 387 }
+2 -1
drivers/acpi/sysfs.c
··· 169 169 170 170 static char trace_method_name[1024]; 171 171 172 - int param_set_trace_method_name(const char *val, const struct kernel_param *kp) 172 + static int param_set_trace_method_name(const char *val, 173 + const struct kernel_param *kp) 173 174 { 174 175 u32 saved_flags = 0; 175 176 bool is_abs_path = true;
+17 -1
drivers/acpi/x86/utils.c
··· 71 71 DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), 72 72 }), 73 73 /* 74 - * The GPD win BIOS dated 20170320 has disabled the accelerometer, the 74 + * The GPD win BIOS dated 20170221 has disabled the accelerometer, the 75 75 * drivers sometimes cause crashes under Windows and this is how the 76 76 * manufacturer has solved this :| Note that the the DMI data is less 77 77 * generic then it seems, a board_vendor of "AMI Corporation" is quite 78 78 * rare and a board_name of "Default String" also is rare. 79 + * 80 + * Unfortunately the GPD pocket also uses these strings and its BIOS 81 + * was copy-pasted from the GPD win, so it has a disabled KIOX000A 82 + * node which we should not enable, thus we also check the BIOS date. 79 83 */ 80 84 ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { 81 85 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 82 86 DMI_MATCH(DMI_BOARD_NAME, "Default string"), 83 87 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 88 + DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") 89 + }), 90 + ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { 91 + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 92 + DMI_MATCH(DMI_BOARD_NAME, "Default string"), 93 + DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 84 94 DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") 95 + }), 96 + ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { 97 + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 98 + DMI_MATCH(DMI_BOARD_NAME, "Default string"), 99 + DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 100 + DMI_MATCH(DMI_BIOS_DATE, "05/25/2017") 85 101 }), 86 102 }; 87 103
-1
drivers/mailbox/pcc.c
··· 69 69 70 70 #include "mailbox.h" 71 71 72 - #define MAX_PCC_SUBSPACES 256 73 72 #define MBOX_IRQ_NAME "pcc-mbox" 74 73 75 74 static struct mbox_chan *pcc_mbox_channels;
+14 -2
include/acpi/acexcep.h
··· 126 126 #define AE_NOT_CONFIGURED EXCEP_ENV (0x001C) 127 127 #define AE_ACCESS EXCEP_ENV (0x001D) 128 128 #define AE_IO_ERROR EXCEP_ENV (0x001E) 129 + #define AE_NUMERIC_OVERFLOW EXCEP_ENV (0x001F) 130 + #define AE_HEX_OVERFLOW EXCEP_ENV (0x0020) 131 + #define AE_DECIMAL_OVERFLOW EXCEP_ENV (0x0021) 132 + #define AE_OCTAL_OVERFLOW EXCEP_ENV (0x0022) 129 133 130 - #define AE_CODE_ENV_MAX 0x001E 134 + #define AE_CODE_ENV_MAX 0x0022 131 135 132 136 /* 133 137 * Programmer exceptions ··· 267 263 EXCEP_TXT("AE_NOT_CONFIGURED", 268 264 "The interface is not part of the current subsystem configuration"), 269 265 EXCEP_TXT("AE_ACCESS", "Permission denied for the requested operation"), 270 - EXCEP_TXT("AE_IO_ERROR", "An I/O error occurred") 266 + EXCEP_TXT("AE_IO_ERROR", "An I/O error occurred"), 267 + EXCEP_TXT("AE_NUMERIC_OVERFLOW", 268 + "Overflow during string-to-integer conversion"), 269 + EXCEP_TXT("AE_HEX_OVERFLOW", 270 + "Overflow during ASCII hex-to-binary conversion"), 271 + EXCEP_TXT("AE_DECIMAL_OVERFLOW", 272 + "Overflow during ASCII decimal-to-binary conversion"), 273 + EXCEP_TXT("AE_OCTAL_OVERFLOW", 274 + "Overflow during ASCII octal-to-binary conversion") 271 275 }; 272 276 273 277 static const struct acpi_exception_info acpi_gbl_exception_names_pgm[] = {
+1 -1
include/acpi/acpixf.h
··· 46 46 47 47 /* Current ACPICA subsystem version in YYYYMMDD format */ 48 48 49 - #define ACPI_CA_VERSION 0x20170728 49 + #define ACPI_CA_VERSION 0x20170831 50 50 51 51 #include <acpi/acconfig.h> 52 52 #include <acpi/actypes.h>
+30
include/acpi/actbl1.h
··· 69 69 #define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ 70 70 #define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ 71 71 #define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ 72 + #define ACPI_SIG_PDTT "PDTT" /* Processor Debug Trigger Table */ 72 73 #define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Table */ 73 74 #define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ 74 75 #define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ ··· 1280 1279 u8 reserved[6]; /* Reserved, must be zero */ 1281 1280 u64 hint_address[1]; /* Variable length */ 1282 1281 }; 1282 + 1283 + /******************************************************************************* 1284 + * 1285 + * PDTT - Processor Debug Trigger Table (ACPI 6.2) 1286 + * Version 0 1287 + * 1288 + ******************************************************************************/ 1289 + 1290 + struct acpi_table_pdtt { 1291 + struct acpi_table_header header; /* Common ACPI table header */ 1292 + u8 trigger_count; 1293 + u8 reserved[3]; 1294 + u32 array_offset; 1295 + }; 1296 + 1297 + /* 1298 + * PDTT Communication Channel Identifier Structure. 1299 + * The number of these structures is defined by trigger_count above, 1300 + * starting at array_offset. 1301 + */ 1302 + struct acpi_pdtt_channel { 1303 + u16 sub_channel_id; 1304 + }; 1305 + 1306 + /* Mask and Flags for above */ 1307 + 1308 + #define ACPI_PDTT_SUBCHANNEL_ID_MASK 0x00FF 1309 + #define ACPI_PDTT_RUNTIME_TRIGGER (1<<8) 1310 + #define ACPI_PPTT_WAIT_COMPLETION (1<<9) 1283 1311 1284 1312 /******************************************************************************* 1285 1313 *
-1
include/acpi/apei.h
··· 51 51 52 52 int arch_apei_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data); 53 53 void arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err); 54 - void arch_apei_flush_tlb_one(unsigned long addr); 55 54 56 55 #endif 57 56 #endif
+1
include/acpi/pcc.h
··· 13 13 #include <linux/mailbox_controller.h> 14 14 #include <linux/mailbox_client.h> 15 15 16 + #define MAX_PCC_SUBSPACES 256 16 17 #ifdef CONFIG_PCC 17 18 extern struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, 18 19 int subspace_id);
+1
tools/power/acpi/tools/acpidump/Makefile
··· 39 39 utnonansi.o\ 40 40 utprint.o\ 41 41 utstring.o\ 42 + utstrsuppt.o\ 42 43 utstrtoul64.o\ 43 44 utxferror.o\ 44 45 oslinuxtbl.o\
+1 -2
tools/power/acpi/tools/acpidump/apdump.c
··· 287 287 288 288 /* Convert argument to an integer physical address */ 289 289 290 - status = acpi_ut_strtoul64(ascii_address, ACPI_STRTOUL_64BIT, 291 - &long_address); 290 + status = acpi_ut_strtoul64(ascii_address, &long_address); 292 291 if (ACPI_FAILURE(status)) { 293 292 fprintf(stderr, "%s: Could not convert to a physical address\n", 294 293 ascii_address);
+1 -3
tools/power/acpi/tools/acpidump/apmain.c
··· 208 208 case 'r': /* Dump tables from specified RSDP */ 209 209 210 210 status = 211 - acpi_ut_strtoul64(acpi_gbl_optarg, 212 - ACPI_STRTOUL_64BIT, 213 - &gbl_rsdp_base); 211 + acpi_ut_strtoul64(acpi_gbl_optarg, &gbl_rsdp_base); 214 212 if (ACPI_FAILURE(status)) { 215 213 fprintf(stderr, 216 214 "%s: Could not convert to a physical address\n",