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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'acpi-bus'

Merge ACPI support updates related to _OSC evaluation, the handling of
"system resource" device objects, and ACPI-based device enumeration
for 6.20-rc1/7.0-rc1:

- Fix handling of _OSC errors in acpi_run_osc() to avoid failures on
systems where _OSC error bits are set even though the _OSC return
buffer contains acknowledged feature bits (Rafael Wysocki)

- Clean up and rearrange \_SB._OSC handling for general platform
features and USB4 features to avoid code duplication and unnecessary
memory management overhead (Rafael Wysocki)

- Make the ACPI core device enumeration code handle PNP0C01 and PNP0C02
("system resource") device objects directly instead of letting the
legacy PNP system driver handle them to avoid device enumeration
issues on systems where PNP0C02 is present in the _CID list under
ACPI device objects with a _HID matching a proper device driver in
Linux (Rafael Wysocki)

- Drop workarounds for the known device enumeration issues related to
_CID lists containing PNP0C02 (Rafael Wysocki)

- Drop outdated comment regarding removed function in the ACPI-based
device enumeration code (Julia Lawall)

- Make PRP0001 device matching work as expected for ACPI device objects
using it as a _HID for board development and similar purposes (Kartik
Rajput)

- Use async schedule function in acpi_scan_clear_dep_fn() to avoid
races with user space initialization on some systems (Yicong Yang)

* acpi-bus:
ACPI: scan: Use async schedule function in acpi_scan_clear_dep_fn()
ACPI: bus: Align acpi_device_get_match_data() with driver match order
ACPI: scan: Drop outdated comment regarding removed function
ACPI: scan: Use resource_type() for resource type checking
ACPI: bus: Fix typo under sizeof() in acpi_run_osc()
ACPI: bus: Adjust acpi_osc_handshake() parameter list
ACPI: bus: Rework the handling of \_SB._OSC USB4 features
ACPI: bus: Adjust feature mask creation for \_SB._OSC
ACPI: bus: Rework the handling of \_SB._OSC platform features
ACPI: bus: Rename label and use ACPI_FREE() in acpi_run_osc()
ACPI: bus: Split _OSC error processing out of acpi_run_osc()
ACPI: bus: Split _OSC evaluation out of acpi_run_osc()
ACPI: bus: Rework printing debug messages on _OSC errors
ACPI: bus: Fix handling of _OSC errors in acpi_run_osc()
ACPI: PNP: Drop acpi_nonpnp_device_ids[]
platform/x86/intel/vbtn: Stop creating a platform device
platform/x86/intel/hid: Stop creating a platform device
ACPI: PNP: Drop PNP0C01 and PNP0C02 from acpi_pnp_device_ids[]

+399 -333
+1 -18
drivers/acpi/acpi_pnp.c
··· 125 125 {"PNP0401"}, /* ECP Printer Port */ 126 126 /* apple-gmux */ 127 127 {"APP000B"}, 128 - /* system */ 129 - {"PNP0c02"}, /* General ID for reserving resources */ 130 - {"PNP0c01"}, /* memory controller */ 131 128 /* rtc_cmos */ 132 129 {"PNP0b00"}, 133 130 {"PNP0b01"}, ··· 343 346 return false; 344 347 } 345 348 346 - /* 347 - * If one of the device IDs below is present in the list of device IDs of a 348 - * given ACPI device object, the PNP scan handler will not attach to that 349 - * object, because there is a proper non-PNP driver in the kernel for the 350 - * device represented by it. 351 - */ 352 - static const struct acpi_device_id acpi_nonpnp_device_ids[] = { 353 - {"INT3F0D"}, 354 - {"INTC1080"}, 355 - {"INTC1081"}, 356 - {"INTC1099"}, 357 - {""}, 358 - }; 359 - 360 349 static int acpi_pnp_attach(struct acpi_device *adev, 361 350 const struct acpi_device_id *id) 362 351 { 363 - return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids); 352 + return true; 364 353 } 365 354 366 355 static struct acpi_scan_handler acpi_pnp_handler = {
+265 -214
drivers/acpi/bus.c
··· 180 180 } 181 181 EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data); 182 182 183 - static void acpi_print_osc_error(acpi_handle handle, 184 - struct acpi_osc_context *context, char *error) 183 + static void acpi_dump_osc_data(acpi_handle handle, const guid_t *guid, int rev, 184 + struct acpi_buffer *cap) 185 185 { 186 + u32 *capbuf = cap->pointer; 186 187 int i; 187 188 188 - acpi_handle_debug(handle, "(%s): %s\n", context->uuid_str, error); 189 + acpi_handle_debug(handle, "_OSC: UUID: %pUL, rev: %d\n", guid, rev); 190 + for (i = 0; i < cap->length / sizeof(u32); i++) 191 + acpi_handle_debug(handle, "_OSC: capabilities DWORD %i: [%08x]\n", 192 + i, capbuf[i]); 193 + } 189 194 190 - pr_debug("_OSC request data:"); 191 - for (i = 0; i < context->cap.length; i += sizeof(u32)) 192 - pr_debug(" %x", *((u32 *)(context->cap.pointer + i))); 195 + #define OSC_ERROR_MASK (OSC_REQUEST_ERROR | OSC_INVALID_UUID_ERROR | \ 196 + OSC_INVALID_REVISION_ERROR | \ 197 + OSC_CAPABILITIES_MASK_ERROR) 193 198 194 - pr_debug("\n"); 199 + static int acpi_eval_osc(acpi_handle handle, guid_t *guid, int rev, 200 + struct acpi_buffer *cap, 201 + union acpi_object in_params[at_least 4], 202 + struct acpi_buffer *output) 203 + { 204 + struct acpi_object_list input; 205 + union acpi_object *out_obj; 206 + acpi_status status; 207 + 208 + in_params[0].type = ACPI_TYPE_BUFFER; 209 + in_params[0].buffer.length = sizeof(*guid); 210 + in_params[0].buffer.pointer = (u8 *)guid; 211 + in_params[1].type = ACPI_TYPE_INTEGER; 212 + in_params[1].integer.value = rev; 213 + in_params[2].type = ACPI_TYPE_INTEGER; 214 + in_params[2].integer.value = cap->length / sizeof(u32); 215 + in_params[3].type = ACPI_TYPE_BUFFER; 216 + in_params[3].buffer.length = cap->length; 217 + in_params[3].buffer.pointer = cap->pointer; 218 + input.pointer = in_params; 219 + input.count = 4; 220 + 221 + output->length = ACPI_ALLOCATE_BUFFER; 222 + output->pointer = NULL; 223 + 224 + status = acpi_evaluate_object(handle, "_OSC", &input, output); 225 + if (ACPI_FAILURE(status) || !output->length) 226 + return -ENODATA; 227 + 228 + out_obj = output->pointer; 229 + if (out_obj->type != ACPI_TYPE_BUFFER || 230 + out_obj->buffer.length != cap->length) { 231 + acpi_handle_debug(handle, "Invalid _OSC return buffer\n"); 232 + acpi_dump_osc_data(handle, guid, rev, cap); 233 + ACPI_FREE(out_obj); 234 + return -ENODATA; 235 + } 236 + 237 + return 0; 238 + } 239 + 240 + static bool acpi_osc_error_check(acpi_handle handle, guid_t *guid, int rev, 241 + struct acpi_buffer *cap, u32 *retbuf) 242 + { 243 + /* Only take defined error bits into account. */ 244 + u32 errors = retbuf[OSC_QUERY_DWORD] & OSC_ERROR_MASK; 245 + u32 *capbuf = cap->pointer; 246 + bool fail; 247 + 248 + /* 249 + * If OSC_QUERY_ENABLE is set, ignore the "capabilities masked" 250 + * bit because it merely means that some features have not been 251 + * acknowledged which is not unexpected. 252 + */ 253 + if (capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE) 254 + errors &= ~OSC_CAPABILITIES_MASK_ERROR; 255 + 256 + if (!errors) 257 + return false; 258 + 259 + acpi_dump_osc_data(handle, guid, rev, cap); 260 + /* 261 + * As a rule, fail only if OSC_QUERY_ENABLE is set because otherwise the 262 + * acknowledged features need to be controlled. 263 + */ 264 + fail = !!(capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE); 265 + 266 + if (errors & OSC_REQUEST_ERROR) 267 + acpi_handle_debug(handle, "_OSC: request failed\n"); 268 + 269 + if (errors & OSC_INVALID_UUID_ERROR) { 270 + acpi_handle_debug(handle, "_OSC: invalid UUID\n"); 271 + /* 272 + * Always fail if this bit is set because it means that the 273 + * request could not be processed. 274 + */ 275 + fail = true; 276 + } 277 + 278 + if (errors & OSC_INVALID_REVISION_ERROR) 279 + acpi_handle_debug(handle, "_OSC: invalid revision\n"); 280 + 281 + if (errors & OSC_CAPABILITIES_MASK_ERROR) 282 + acpi_handle_debug(handle, "_OSC: capability bits masked\n"); 283 + 284 + return fail; 195 285 } 196 286 197 287 acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) 198 288 { 199 - acpi_status status; 200 - struct acpi_object_list input; 201 - union acpi_object in_params[4]; 202 - union acpi_object *out_obj; 289 + union acpi_object in_params[4], *out_obj; 290 + struct acpi_buffer output; 291 + acpi_status status = AE_OK; 203 292 guid_t guid; 204 - u32 errors; 205 - struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 293 + u32 *retbuf; 294 + int ret; 206 295 207 - if (!context) 296 + if (!context || !context->cap.pointer || 297 + context->cap.length < 2 * sizeof(u32) || 298 + guid_parse(context->uuid_str, &guid)) 299 + return AE_BAD_PARAMETER; 300 + 301 + ret = acpi_eval_osc(handle, &guid, context->rev, &context->cap, 302 + in_params, &output); 303 + if (ret) 208 304 return AE_ERROR; 209 - if (guid_parse(context->uuid_str, &guid)) 210 - return AE_ERROR; 211 - context->ret.length = ACPI_ALLOCATE_BUFFER; 212 - context->ret.pointer = NULL; 213 - 214 - /* Setting up input parameters */ 215 - input.count = 4; 216 - input.pointer = in_params; 217 - in_params[0].type = ACPI_TYPE_BUFFER; 218 - in_params[0].buffer.length = 16; 219 - in_params[0].buffer.pointer = (u8 *)&guid; 220 - in_params[1].type = ACPI_TYPE_INTEGER; 221 - in_params[1].integer.value = context->rev; 222 - in_params[2].type = ACPI_TYPE_INTEGER; 223 - in_params[2].integer.value = context->cap.length/sizeof(u32); 224 - in_params[3].type = ACPI_TYPE_BUFFER; 225 - in_params[3].buffer.length = context->cap.length; 226 - in_params[3].buffer.pointer = context->cap.pointer; 227 - 228 - status = acpi_evaluate_object(handle, "_OSC", &input, &output); 229 - if (ACPI_FAILURE(status)) 230 - return status; 231 - 232 - if (!output.length) 233 - return AE_NULL_OBJECT; 234 305 235 306 out_obj = output.pointer; 236 - if (out_obj->type != ACPI_TYPE_BUFFER 237 - || out_obj->buffer.length != context->cap.length) { 238 - acpi_print_osc_error(handle, context, 239 - "_OSC evaluation returned wrong type"); 240 - status = AE_TYPE; 241 - goto out_kfree; 242 - } 243 - /* Need to ignore the bit0 in result code */ 244 - errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0); 245 - if (errors) { 246 - if (errors & OSC_REQUEST_ERROR) 247 - acpi_print_osc_error(handle, context, 248 - "_OSC request failed"); 249 - if (errors & OSC_INVALID_UUID_ERROR) 250 - acpi_print_osc_error(handle, context, 251 - "_OSC invalid UUID"); 252 - if (errors & OSC_INVALID_REVISION_ERROR) 253 - acpi_print_osc_error(handle, context, 254 - "_OSC invalid revision"); 255 - if (errors & OSC_CAPABILITIES_MASK_ERROR) { 256 - if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD] 257 - & OSC_QUERY_ENABLE) 258 - goto out_success; 259 - status = AE_SUPPORT; 260 - goto out_kfree; 261 - } 307 + retbuf = (u32 *)out_obj->buffer.pointer; 308 + 309 + if (acpi_osc_error_check(handle, &guid, context->rev, &context->cap, retbuf)) { 262 310 status = AE_ERROR; 263 - goto out_kfree; 311 + goto out; 264 312 } 265 - out_success: 313 + 266 314 context->ret.length = out_obj->buffer.length; 267 - context->ret.pointer = kmemdup(out_obj->buffer.pointer, 268 - context->ret.length, GFP_KERNEL); 315 + context->ret.pointer = kmemdup(retbuf, context->ret.length, GFP_KERNEL); 269 316 if (!context->ret.pointer) { 270 317 status = AE_NO_MEMORY; 271 - goto out_kfree; 318 + goto out; 272 319 } 273 320 status = AE_OK; 274 321 275 - out_kfree: 276 - kfree(output.pointer); 322 + out: 323 + ACPI_FREE(out_obj); 277 324 return status; 278 325 } 279 326 EXPORT_SYMBOL(acpi_run_osc); 327 + 328 + static int acpi_osc_handshake(acpi_handle handle, const char *uuid_str, 329 + int rev, u32 *capbuf, size_t bufsize) 330 + { 331 + union acpi_object in_params[4], *out_obj; 332 + struct acpi_object_list input; 333 + struct acpi_buffer cap = { 334 + .pointer = capbuf, 335 + .length = bufsize * sizeof(u32), 336 + }; 337 + struct acpi_buffer output; 338 + u32 *retbuf, test; 339 + guid_t guid; 340 + int ret, i; 341 + 342 + if (!capbuf || bufsize < 2 || guid_parse(uuid_str, &guid)) 343 + return -EINVAL; 344 + 345 + /* First evaluate _OSC with OSC_QUERY_ENABLE set. */ 346 + capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 347 + 348 + ret = acpi_eval_osc(handle, &guid, rev, &cap, in_params, &output); 349 + if (ret) 350 + return ret; 351 + 352 + out_obj = output.pointer; 353 + retbuf = (u32 *)out_obj->buffer.pointer; 354 + 355 + if (acpi_osc_error_check(handle, &guid, rev, &cap, retbuf)) { 356 + ret = -ENODATA; 357 + goto out; 358 + } 359 + 360 + /* 361 + * Clear the feature bits in the capabilities buffer that have not been 362 + * acknowledged and clear the return buffer. 363 + */ 364 + for (i = OSC_QUERY_DWORD + 1, test = 0; i < bufsize; i++) { 365 + capbuf[i] &= retbuf[i]; 366 + test |= capbuf[i]; 367 + retbuf[i] = 0; 368 + } 369 + /* 370 + * If none of the feature bits have been acknowledged, there's nothing 371 + * more to do. capbuf[] contains a feature mask of all zeros. 372 + */ 373 + if (!test) 374 + goto out; 375 + 376 + retbuf[OSC_QUERY_DWORD] = 0; 377 + /* 378 + * Now evaluate _OSC again (directly) with OSC_QUERY_ENABLE clear and 379 + * the updated input and output buffers used before. Since the feature 380 + * bits that were clear in the return buffer from the previous _OSC 381 + * evaluation are also clear in the capabilities buffer now, this _OSC 382 + * evaluation is not expected to fail. 383 + */ 384 + capbuf[OSC_QUERY_DWORD] = 0; 385 + /* Reuse in_params[] populated by acpi_eval_osc(). */ 386 + input.pointer = in_params; 387 + input.count = 4; 388 + 389 + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_OSC", &input, &output))) { 390 + ret = -ENODATA; 391 + goto out; 392 + } 393 + 394 + /* 395 + * Clear the feature bits in capbuf[] that have not been acknowledged. 396 + * After that, capbuf[] contains the resultant feature mask. 397 + */ 398 + for (i = OSC_QUERY_DWORD + 1; i < bufsize; i++) 399 + capbuf[i] &= retbuf[i]; 400 + 401 + if (retbuf[OSC_QUERY_DWORD] & OSC_ERROR_MASK) { 402 + /* 403 + * Complain about the unexpected errors and print diagnostic 404 + * information related to them. 405 + */ 406 + acpi_handle_err(handle, "_OSC: errors while processing control request\n"); 407 + acpi_handle_err(handle, "_OSC: some features may be missing\n"); 408 + acpi_osc_error_check(handle, &guid, rev, &cap, retbuf); 409 + } 410 + 411 + out: 412 + ACPI_FREE(out_obj); 413 + return ret; 414 + } 280 415 281 416 bool osc_sb_apei_support_acked; 282 417 ··· 444 309 445 310 bool osc_sb_cppc2_support_acked; 446 311 447 - static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; 448 312 static void acpi_bus_osc_negotiate_platform_control(void) 449 313 { 450 - u32 capbuf[2], *capbuf_ret; 451 - struct acpi_osc_context context = { 452 - .uuid_str = sb_uuid_str, 453 - .rev = 1, 454 - .cap.length = 8, 455 - .cap.pointer = capbuf, 456 - }; 314 + static const u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; 315 + u32 capbuf[2], feature_mask; 457 316 acpi_handle handle; 458 317 459 - capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 460 - capbuf[OSC_SUPPORT_DWORD] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */ 318 + feature_mask = OSC_SB_PR3_SUPPORT | OSC_SB_HOTPLUG_OST_SUPPORT | 319 + OSC_SB_PCLPI_SUPPORT | OSC_SB_OVER_16_PSTATES_SUPPORT | 320 + OSC_SB_GED_SUPPORT | OSC_SB_IRQ_RESOURCE_SOURCE_SUPPORT; 321 + 322 + if (IS_ENABLED(CONFIG_ARM64) || IS_ENABLED(CONFIG_X86)) 323 + feature_mask |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 324 + 325 + if (IS_ENABLED(CONFIG_ACPI_CPPC_LIB)) { 326 + feature_mask |= OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT | 327 + OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 328 + if (IS_ENABLED(CONFIG_SCHED_MC_PRIO)) 329 + feature_mask |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT; 330 + } 331 + 461 332 if (IS_ENABLED(CONFIG_ACPI_PROCESSOR_AGGREGATOR)) 462 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PAD_SUPPORT; 333 + feature_mask |= OSC_SB_PAD_SUPPORT; 334 + 463 335 if (IS_ENABLED(CONFIG_ACPI_PROCESSOR)) 464 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT; 336 + feature_mask |= OSC_SB_PPC_OST_SUPPORT; 337 + 465 338 if (IS_ENABLED(CONFIG_ACPI_THERMAL)) 466 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT; 339 + feature_mask |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT; 340 + 467 341 if (IS_ENABLED(CONFIG_ACPI_BATTERY)) 468 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT; 342 + feature_mask |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT; 469 343 470 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT; 471 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PCLPI_SUPPORT; 472 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_OVER_16_PSTATES_SUPPORT; 473 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GED_SUPPORT; 474 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_IRQ_RESOURCE_SOURCE_SUPPORT; 475 344 if (IS_ENABLED(CONFIG_ACPI_PRMT)) 476 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PRM_SUPPORT; 345 + feature_mask |= OSC_SB_PRM_SUPPORT; 346 + 477 347 if (IS_ENABLED(CONFIG_ACPI_FFH)) 478 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FFH_OPR_SUPPORT; 479 - 480 - #ifdef CONFIG_ARM64 481 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 482 - #endif 483 - #ifdef CONFIG_X86 484 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 485 - #endif 486 - 487 - #ifdef CONFIG_ACPI_CPPC_LIB 488 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_SUPPORT; 489 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPCV2_SUPPORT; 490 - #endif 491 - 492 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 493 - 494 - if (IS_ENABLED(CONFIG_SCHED_MC_PRIO)) 495 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT; 348 + feature_mask |= OSC_SB_FFH_OPR_SUPPORT; 496 349 497 350 if (IS_ENABLED(CONFIG_USB4)) 498 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_NATIVE_USB4_SUPPORT; 351 + feature_mask |= OSC_SB_NATIVE_USB4_SUPPORT; 499 352 500 353 if (!ghes_disable) 501 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT; 354 + feature_mask |= OSC_SB_APEI_SUPPORT; 355 + 502 356 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) 503 357 return; 504 358 505 - if (ACPI_FAILURE(acpi_run_osc(handle, &context))) 359 + capbuf[OSC_SUPPORT_DWORD] = feature_mask; 360 + 361 + acpi_handle_info(handle, "platform _OSC: OS support mask [%08x]\n", feature_mask); 362 + 363 + if (acpi_osc_handshake(handle, sb_uuid_str, 1, capbuf, ARRAY_SIZE(capbuf))) 506 364 return; 507 365 508 - capbuf_ret = context.ret.pointer; 509 - if (context.ret.length <= OSC_SUPPORT_DWORD) { 510 - kfree(context.ret.pointer); 511 - return; 512 - } 366 + feature_mask = capbuf[OSC_SUPPORT_DWORD]; 513 367 514 - /* 515 - * Now run _OSC again with query flag clear and with the caps 516 - * supported by both the OS and the platform. 517 - */ 518 - capbuf[OSC_QUERY_DWORD] = 0; 519 - capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD]; 520 - kfree(context.ret.pointer); 368 + acpi_handle_info(handle, "platform _OSC: OS control mask [%08x]\n", feature_mask); 521 369 522 - if (ACPI_FAILURE(acpi_run_osc(handle, &context))) 523 - return; 524 - 525 - capbuf_ret = context.ret.pointer; 526 - if (context.ret.length > OSC_SUPPORT_DWORD) { 527 - #ifdef CONFIG_ACPI_CPPC_LIB 528 - osc_sb_cppc2_support_acked = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPCV2_SUPPORT; 529 - #endif 530 - 531 - osc_sb_apei_support_acked = 532 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; 533 - osc_pc_lpi_support_confirmed = 534 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; 535 - osc_sb_native_usb4_support_confirmed = 536 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; 537 - osc_cpc_flexible_adr_space_confirmed = 538 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 539 - } 540 - 541 - kfree(context.ret.pointer); 370 + osc_sb_cppc2_support_acked = feature_mask & OSC_SB_CPCV2_SUPPORT; 371 + osc_sb_apei_support_acked = feature_mask & OSC_SB_APEI_SUPPORT; 372 + osc_pc_lpi_support_confirmed = feature_mask & OSC_SB_PCLPI_SUPPORT; 373 + osc_sb_native_usb4_support_confirmed = feature_mask & OSC_SB_NATIVE_USB4_SUPPORT; 374 + osc_cpc_flexible_adr_space_confirmed = feature_mask & OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 542 375 } 543 376 544 377 /* ··· 526 423 (bits & OSC_USB_XDOMAIN) ? '+' : '-'); 527 424 } 528 425 529 - static u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A"; 530 426 static void acpi_bus_osc_negotiate_usb_control(void) 531 427 { 532 - u32 capbuf[3], *capbuf_ret; 533 - struct acpi_osc_context context = { 534 - .uuid_str = sb_usb_uuid_str, 535 - .rev = 1, 536 - .cap.length = sizeof(capbuf), 537 - .cap.pointer = capbuf, 538 - }; 428 + static const u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A"; 429 + u32 capbuf[3], control; 539 430 acpi_handle handle; 540 - acpi_status status; 541 - u32 control; 542 431 543 432 if (!osc_sb_native_usb4_support_confirmed) 544 433 return; ··· 541 446 control = OSC_USB_USB3_TUNNELING | OSC_USB_DP_TUNNELING | 542 447 OSC_USB_PCIE_TUNNELING | OSC_USB_XDOMAIN; 543 448 544 - /* 545 - * Run _OSC first with query bit set, trying to get control over 546 - * all tunneling. The platform can then clear out bits in the 547 - * control dword that it does not want to grant to the OS. 548 - */ 549 - capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 550 449 capbuf[OSC_SUPPORT_DWORD] = 0; 551 450 capbuf[OSC_CONTROL_DWORD] = control; 552 451 553 - status = acpi_run_osc(handle, &context); 554 - if (ACPI_FAILURE(status)) 452 + if (acpi_osc_handshake(handle, sb_usb_uuid_str, 1, capbuf, ARRAY_SIZE(capbuf))) 555 453 return; 556 454 557 - if (context.ret.length != sizeof(capbuf)) { 558 - pr_info("USB4 _OSC: returned invalid length buffer\n"); 559 - goto out_free; 560 - } 561 - 562 - /* 563 - * Run _OSC again now with query bit clear and the control dword 564 - * matching what the platform granted (which may not have all 565 - * the control bits set). 566 - */ 567 - capbuf_ret = context.ret.pointer; 568 - 569 - capbuf[OSC_QUERY_DWORD] = 0; 570 - capbuf[OSC_CONTROL_DWORD] = capbuf_ret[OSC_CONTROL_DWORD]; 571 - 572 - kfree(context.ret.pointer); 573 - 574 - status = acpi_run_osc(handle, &context); 575 - if (ACPI_FAILURE(status)) 576 - return; 577 - 578 - if (context.ret.length != sizeof(capbuf)) { 579 - pr_info("USB4 _OSC: returned invalid length buffer\n"); 580 - goto out_free; 581 - } 582 - 583 - osc_sb_native_usb4_control = 584 - control & acpi_osc_ctx_get_pci_control(&context); 455 + osc_sb_native_usb4_control = capbuf[OSC_CONTROL_DWORD]; 585 456 586 457 acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control); 587 - acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", 588 - osc_sb_native_usb4_control); 589 - 590 - out_free: 591 - kfree(context.ret.pointer); 458 + acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", osc_sb_native_usb4_control); 592 459 } 593 460 594 461 /* -------------------------------------------------------------------------- ··· 1013 956 } 1014 957 EXPORT_SYMBOL_GPL(acpi_match_device); 1015 958 1016 - static const void *acpi_of_device_get_match_data(const struct device *dev) 1017 - { 1018 - struct acpi_device *adev = ACPI_COMPANION(dev); 1019 - const struct of_device_id *match = NULL; 1020 - 1021 - if (!acpi_of_match_device(adev, dev->driver->of_match_table, &match)) 1022 - return NULL; 1023 - 1024 - return match->data; 1025 - } 1026 - 1027 959 const void *acpi_device_get_match_data(const struct device *dev) 1028 960 { 1029 961 const struct acpi_device_id *acpi_ids = dev->driver->acpi_match_table; 1030 - const struct acpi_device_id *match; 962 + const struct of_device_id *of_ids = dev->driver->of_match_table; 963 + const struct acpi_device *adev = acpi_companion_match(dev); 964 + const struct acpi_device_id *acpi_id = NULL; 965 + const struct of_device_id *of_id = NULL; 1031 966 1032 - if (!acpi_ids) 1033 - return acpi_of_device_get_match_data(dev); 1034 - 1035 - match = acpi_match_device(acpi_ids, dev); 1036 - if (!match) 967 + if (!__acpi_match_device(adev, acpi_ids, of_ids, &acpi_id, &of_id)) 1037 968 return NULL; 1038 969 1039 - return (const void *)match->driver_data; 970 + if (acpi_id) 971 + return (const void *)acpi_id->driver_data; 972 + 973 + if (of_id) 974 + return of_id->data; 975 + 976 + return NULL; 1040 977 } 1041 978 EXPORT_SYMBOL_GPL(acpi_device_get_match_data); 1042 979
+131 -32
drivers/acpi/scan.c
··· 5 5 6 6 #define pr_fmt(fmt) "ACPI: " fmt 7 7 8 + #include <linux/async.h> 8 9 #include <linux/module.h> 9 10 #include <linux/init.h> 10 11 #include <linux/slab.h> ··· 43 42 DEFINE_MUTEX(acpi_device_lock); 44 43 LIST_HEAD(acpi_wakeup_device_list); 45 44 static DEFINE_MUTEX(acpi_hp_context_lock); 45 + static LIST_HEAD(acpi_scan_system_dev_list); 46 46 47 47 /* 48 48 * The UART device described by the SPCR table is the only object which needs ··· 1296 1294 * The device will get a Linux specific CID added in scan.c to 1297 1295 * identify the device as an ACPI graphics device 1298 1296 * Be aware that the graphics device may not be physically present 1299 - * Use acpi_video_get_capabilities() to detect general ACPI video 1300 - * capabilities of present cards 1301 1297 */ 1302 1298 long acpi_is_video_device(acpi_handle handle) 1303 1299 { ··· 2203 2203 return acpi_bus_check_add(handle, false, (struct acpi_device **)ret_p); 2204 2204 } 2205 2205 2206 + struct acpi_scan_system_dev { 2207 + struct list_head node; 2208 + struct acpi_device *adev; 2209 + }; 2210 + 2211 + static const char * const acpi_system_dev_ids[] = { 2212 + "PNP0C01", /* Memory controller */ 2213 + "PNP0C02", /* Motherboard resource */ 2214 + NULL 2215 + }; 2216 + 2206 2217 static void acpi_default_enumeration(struct acpi_device *device) 2207 2218 { 2208 2219 /* 2209 2220 * Do not enumerate devices with enumeration_by_parent flag set as 2210 2221 * they will be enumerated by their respective parents. 2211 2222 */ 2212 - if (!device->flags.enumeration_by_parent) { 2213 - acpi_create_platform_device(device, NULL); 2214 - acpi_device_set_enumerated(device); 2215 - } else { 2223 + if (device->flags.enumeration_by_parent) { 2216 2224 blocking_notifier_call_chain(&acpi_reconfig_chain, 2217 2225 ACPI_RECONFIG_DEVICE_ADD, device); 2226 + return; 2218 2227 } 2228 + if (match_string(acpi_system_dev_ids, -1, acpi_device_hid(device)) >= 0) { 2229 + struct acpi_scan_system_dev *sd; 2230 + 2231 + /* 2232 + * This is a generic system device, so there is no need to 2233 + * create a platform device for it, but its resources need to be 2234 + * reserved. However, that needs to be done after all of the 2235 + * other device objects have been processed and PCI has claimed 2236 + * BARs in case there are resource conflicts. 2237 + */ 2238 + sd = kmalloc(sizeof(*sd), GFP_KERNEL); 2239 + if (sd) { 2240 + sd->adev = device; 2241 + list_add_tail(&sd->node, &acpi_scan_system_dev_list); 2242 + } 2243 + } else { 2244 + /* For a regular device object, create a platform device. */ 2245 + acpi_create_platform_device(device, NULL); 2246 + } 2247 + acpi_device_set_enumerated(device); 2219 2248 } 2220 2249 2221 2250 static const struct acpi_device_id generic_device_ids[] = { ··· 2389 2360 return 0; 2390 2361 } 2391 2362 2392 - struct acpi_scan_clear_dep_work { 2393 - struct work_struct work; 2394 - struct acpi_device *adev; 2395 - }; 2396 - 2397 - static void acpi_scan_clear_dep_fn(struct work_struct *work) 2363 + static void acpi_scan_clear_dep_fn(void *dev, async_cookie_t cookie) 2398 2364 { 2399 - struct acpi_scan_clear_dep_work *cdw; 2400 - 2401 - cdw = container_of(work, struct acpi_scan_clear_dep_work, work); 2365 + struct acpi_device *adev = to_acpi_device(dev); 2402 2366 2403 2367 acpi_scan_lock_acquire(); 2404 - acpi_bus_attach(cdw->adev, (void *)true); 2368 + acpi_bus_attach(adev, (void *)true); 2405 2369 acpi_scan_lock_release(); 2406 2370 2407 - acpi_dev_put(cdw->adev); 2408 - kfree(cdw); 2371 + acpi_dev_put(adev); 2409 2372 } 2410 2373 2411 2374 static bool acpi_scan_clear_dep_queue(struct acpi_device *adev) 2412 2375 { 2413 - struct acpi_scan_clear_dep_work *cdw; 2414 - 2415 2376 if (adev->dep_unmet) 2416 2377 return false; 2417 2378 2418 - cdw = kmalloc(sizeof(*cdw), GFP_KERNEL); 2419 - if (!cdw) 2420 - return false; 2421 - 2422 - cdw->adev = adev; 2423 - INIT_WORK(&cdw->work, acpi_scan_clear_dep_fn); 2424 2379 /* 2425 - * Since the work function may block on the lock until the entire 2426 - * initial enumeration of devices is complete, put it into the unbound 2427 - * workqueue. 2380 + * Async schedule the deferred acpi_scan_clear_dep_fn() since: 2381 + * - acpi_bus_attach() needs to hold acpi_scan_lock which cannot 2382 + * be acquired under acpi_dep_list_lock (held here) 2383 + * - the deferred work at boot stage is ensured to be finished 2384 + * before userspace init task by the async_synchronize_full() 2385 + * barrier 2386 + * 2387 + * Use _nocall variant since it'll return on failure instead of 2388 + * run the function synchronously. 2428 2389 */ 2429 - queue_work(system_dfl_wq, &cdw->work); 2430 - 2431 - return true; 2390 + return async_schedule_dev_nocall(acpi_scan_clear_dep_fn, &adev->dev); 2432 2391 } 2433 2392 2434 2393 static void acpi_scan_delete_dep_data(struct acpi_dep_data *dep) ··· 2587 2570 2588 2571 mutex_unlock(&acpi_dep_list_lock); 2589 2572 } 2573 + 2574 + static void acpi_scan_claim_resources(struct acpi_device *adev) 2575 + { 2576 + struct list_head resource_list = LIST_HEAD_INIT(resource_list); 2577 + struct resource_entry *rentry; 2578 + unsigned int count = 0; 2579 + const char *regionid; 2580 + 2581 + if (acpi_dev_get_resources(adev, &resource_list, NULL, NULL) <= 0) 2582 + return; 2583 + 2584 + regionid = kstrdup(dev_name(&adev->dev), GFP_KERNEL); 2585 + if (!regionid) 2586 + goto exit; 2587 + 2588 + list_for_each_entry(rentry, &resource_list, node) { 2589 + struct resource *res = rentry->res; 2590 + struct resource *r; 2591 + 2592 + /* Skip disabled and invalid resources. */ 2593 + if ((res->flags & IORESOURCE_DISABLED) || res->end < res->start) 2594 + continue; 2595 + 2596 + if (resource_type(res) == IORESOURCE_IO) { 2597 + /* 2598 + * Follow the PNP system driver and on x86 skip I/O 2599 + * resources that start below 0x100 (the "standard PC 2600 + * hardware" boundary). 2601 + */ 2602 + if (IS_ENABLED(CONFIG_X86) && res->start < 0x100) { 2603 + dev_info(&adev->dev, "Skipped %pR\n", res); 2604 + continue; 2605 + } 2606 + r = request_region(res->start, resource_size(res), regionid); 2607 + } else if (resource_type(res) == IORESOURCE_MEM) { 2608 + r = request_mem_region(res->start, resource_size(res), regionid); 2609 + } else { 2610 + continue; 2611 + } 2612 + 2613 + if (r) { 2614 + r->flags &= ~IORESOURCE_BUSY; 2615 + dev_info(&adev->dev, "Reserved %pR\n", r); 2616 + count++; 2617 + } else { 2618 + /* 2619 + * Failures at this point are usually harmless. PCI 2620 + * quirks, for example, reserve resources they know 2621 + * about too, so there may well be double reservations. 2622 + */ 2623 + dev_info(&adev->dev, "Could not reserve %pR\n", res); 2624 + } 2625 + } 2626 + 2627 + if (!count) 2628 + kfree(regionid); 2629 + 2630 + exit: 2631 + acpi_dev_free_resource_list(&resource_list); 2632 + } 2633 + 2634 + 2635 + static int __init acpi_reserve_motherboard_resources(void) 2636 + { 2637 + struct acpi_scan_system_dev *sd, *tmp; 2638 + 2639 + guard(mutex)(&acpi_scan_lock); 2640 + 2641 + list_for_each_entry_safe(sd, tmp, &acpi_scan_system_dev_list, node) { 2642 + acpi_scan_claim_resources(sd->adev); 2643 + list_del(&sd->node); 2644 + kfree(sd); 2645 + } 2646 + 2647 + return 0; 2648 + } 2649 + 2650 + /* 2651 + * Reserve motherboard resources after PCI claims BARs, but before PCI assigns 2652 + * resources for uninitialized PCI devices. 2653 + */ 2654 + fs_initcall(acpi_reserve_motherboard_resources); 2590 2655 2591 2656 /** 2592 2657 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
+1 -40
drivers/platform/x86/intel/hid.c
··· 779 779 .remove = intel_hid_remove, 780 780 }; 781 781 782 - /* 783 - * Unfortunately, some laptops provide a _HID="INT33D5" device with 784 - * _CID="PNP0C02". This causes the pnpacpi scan driver to claim the 785 - * ACPI node, so no platform device will be created. The pnpacpi 786 - * driver rejects this device in subsequent processing, so no physical 787 - * node is created at all. 788 - * 789 - * As a workaround until the ACPI core figures out how to handle 790 - * this corner case, manually ask the ACPI platform device code to 791 - * claim the ACPI node. 792 - */ 793 - static acpi_status __init 794 - check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv) 795 - { 796 - const struct acpi_device_id *ids = context; 797 - struct acpi_device *dev = acpi_fetch_acpi_dev(handle); 798 - 799 - if (dev && acpi_match_device_ids(dev, ids) == 0) 800 - if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL))) 801 - dev_info(&dev->dev, 802 - "intel-hid: created platform device\n"); 803 - 804 - return AE_OK; 805 - } 806 - 807 - static int __init intel_hid_init(void) 808 - { 809 - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 810 - ACPI_UINT32_MAX, check_acpi_dev, NULL, 811 - (void *)intel_hid_ids, NULL); 812 - 813 - return platform_driver_register(&intel_hid_pl_driver); 814 - } 815 - module_init(intel_hid_init); 816 - 817 - static void __exit intel_hid_exit(void) 818 - { 819 - platform_driver_unregister(&intel_hid_pl_driver); 820 - } 821 - module_exit(intel_hid_exit); 782 + module_platform_driver(intel_hid_pl_driver);
+1 -29
drivers/platform/x86/intel/vbtn.c
··· 390 390 .remove = intel_vbtn_remove, 391 391 }; 392 392 393 - static acpi_status __init 394 - check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv) 395 - { 396 - const struct acpi_device_id *ids = context; 397 - struct acpi_device *dev = acpi_fetch_acpi_dev(handle); 398 - 399 - if (dev && acpi_match_device_ids(dev, ids) == 0) 400 - if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL))) 401 - dev_info(&dev->dev, 402 - "intel-vbtn: created platform device\n"); 403 - 404 - return AE_OK; 405 - } 406 - 407 - static int __init intel_vbtn_init(void) 408 - { 409 - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 410 - ACPI_UINT32_MAX, check_acpi_dev, NULL, 411 - (void *)intel_vbtn_ids, NULL); 412 - 413 - return platform_driver_register(&intel_vbtn_pl_driver); 414 - } 415 - module_init(intel_vbtn_init); 416 - 417 - static void __exit intel_vbtn_exit(void) 418 - { 419 - platform_driver_unregister(&intel_vbtn_pl_driver); 420 - } 421 - module_exit(intel_vbtn_exit); 393 + module_platform_driver(intel_vbtn_pl_driver);