Lines Matching +full:lock +full:- +full:detect +full:- +full:function +full:- +full:integer +full:- +full:n +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-only
3 * scan.c - support for transforming the ACPI namespace into individual objects
19 #include <linux/dma-map-ops.h>
23 #include <linux/dma-direct.h>
47 * special-casing. Everything else is covered by ACPI namespace paths in STAO
79 hp->notify = notify; in acpi_initialize_hp_context()
80 hp->uevent = uevent; in acpi_initialize_hp_context()
89 return -EINVAL; in acpi_scan_add_handler()
91 list_add_tail(&handler->list_node, &acpi_scan_handlers_list); in acpi_scan_add_handler()
104 acpi_sysfs_add_hotplug_profile(&handler->hotplug, hotplug_profile_name); in acpi_scan_add_handler_with_hotplug()
116 * children under the container's physical_node_lock lock. in acpi_scan_is_offline()
118 mutex_lock_nested(&adev->physical_node_lock, SINGLE_DEPTH_NESTING); in acpi_scan_is_offline()
120 list_for_each_entry(pn, &adev->physical_node_list, node) in acpi_scan_is_offline()
121 if (device_supports_offline(pn->dev) && !pn->dev->offline) { in acpi_scan_is_offline()
123 kobject_uevent_env(&pn->dev->kobj, KOBJ_CHANGE, envp); in acpi_scan_is_offline()
129 mutex_unlock(&adev->physical_node_lock); in acpi_scan_is_offline()
144 if (device->handler && !device->handler->hotplug.enabled) { in acpi_bus_offline()
145 *ret_p = &device->dev; in acpi_bus_offline()
149 mutex_lock(&device->physical_node_lock); in acpi_bus_offline()
151 list_for_each_entry(pn, &device->physical_node_list, node) { in acpi_bus_offline()
156 if (pn->put_online) in acpi_bus_offline()
159 pn->put_online = false; in acpi_bus_offline()
161 ret = device_offline(pn->dev); in acpi_bus_offline()
163 pn->put_online = !ret; in acpi_bus_offline()
165 *ret_p = pn->dev; in acpi_bus_offline()
173 mutex_unlock(&device->physical_node_lock); in acpi_bus_offline()
187 mutex_lock(&device->physical_node_lock); in acpi_bus_online()
189 list_for_each_entry(pn, &device->physical_node_list, node) in acpi_bus_online()
190 if (pn->put_online) { in acpi_bus_online()
191 device_online(pn->dev); in acpi_bus_online()
192 pn->put_online = false; in acpi_bus_online()
195 mutex_unlock(&device->physical_node_lock); in acpi_bus_online()
202 acpi_handle handle = device->handle; in acpi_scan_try_to_offline()
219 dev_warn(errdev, "Offline disabled.\n"); in acpi_scan_try_to_offline()
222 return -EPERM; in acpi_scan_try_to_offline()
235 dev_warn(errdev, "Offline failed.\n"); in acpi_scan_try_to_offline()
240 return -EBUSY; in acpi_scan_try_to_offline()
251 struct acpi_scan_handler *handler = adev->handler; in acpi_scan_check_and_detach()
267 dev_dbg(&adev->dev, "Still not enumerated\n"); in acpi_scan_check_and_detach()
272 adev->flags.match_driver = false; in acpi_scan_check_and_detach()
274 if (handler->detach) in acpi_scan_check_and_detach()
275 handler->detach(adev); in acpi_scan_check_and_detach()
277 device_release_driver(&adev->dev); in acpi_scan_check_and_detach()
284 adev->flags.initialized = false; in acpi_scan_check_and_detach()
288 adev->handler = NULL; in acpi_scan_check_and_detach()
296 struct acpi_scan_handler *handler = adev->handler; in acpi_bus_post_eject()
301 if (handler->post_eject) in acpi_bus_post_eject()
302 handler->post_eject(adev); in acpi_bus_post_eject()
304 adev->handler = NULL; in acpi_bus_post_eject()
321 acpi_handle handle = device->handle; in acpi_scan_hot_remove()
326 if (device->handler && device->handler->hotplug.demand_offline) { in acpi_scan_hot_remove()
328 return -EBUSY; in acpi_scan_hot_remove()
335 acpi_handle_debug(handle, "Ejecting\n"); in acpi_scan_hot_remove()
345 return -ENODEV; in acpi_scan_hot_remove()
347 return -EIO; in acpi_scan_hot_remove()
356 "Status check after eject failed (0x%x)\n", status); in acpi_scan_hot_remove()
359 "Eject incomplete - status 0x%llx\n", sta); in acpi_scan_hot_remove()
369 struct acpi_scan_handler *handler = adev->handler; in acpi_scan_rescan_bus()
372 if (handler && handler->hotplug.scan_dependent) in acpi_scan_rescan_bus()
373 ret = handler->hotplug.scan_dependent(adev); in acpi_scan_rescan_bus()
375 ret = acpi_bus_scan(adev->handle); in acpi_scan_rescan_bus()
378 dev_info(&adev->dev, "Namespace scan failure\n"); in acpi_scan_rescan_bus()
393 * This function is only called for device objects for which matching in acpi_scan_device_check()
399 if (adev->handler) { in acpi_scan_device_check()
400 dev_dbg(&adev->dev, "Already enumerated\n"); in acpi_scan_device_check()
427 if (adev->handler && !adev->handler->hotplug.enabled) { in acpi_generic_hotplug_event()
428 dev_info(&adev->dev, "Eject disabled\n"); in acpi_generic_hotplug_event()
429 return -EPERM; in acpi_generic_hotplug_event()
431 acpi_evaluate_ost(adev->handle, ACPI_NOTIFY_EJECT_REQUEST, in acpi_generic_hotplug_event()
435 return -EINVAL; in acpi_generic_hotplug_event()
441 int error = -ENODEV; in acpi_device_hotplug()
449 * that lock was acquired. in acpi_device_hotplug()
451 if (adev->handle == INVALID_ACPI_HANDLE) in acpi_device_hotplug()
454 if (adev->flags.is_dock_station) { in acpi_device_hotplug()
456 } else if (adev->flags.hotplug_notify) { in acpi_device_hotplug()
462 notify = adev->hp ? adev->hp->notify : NULL; in acpi_device_hotplug()
477 case -EPERM: in acpi_device_hotplug()
480 case -EBUSY: in acpi_device_hotplug()
489 acpi_evaluate_ost(adev->handle, src, ost_code, NULL); in acpi_device_hotplug()
501 if (device->wakeup.flags.valid) in acpi_free_power_resources_lists()
502 acpi_power_resources_list_free(&device->wakeup.resources); in acpi_free_power_resources_lists()
504 if (!device->power.flags.power_resources) in acpi_free_power_resources_lists()
508 struct acpi_device_power_state *ps = &device->power.states[i]; in acpi_free_power_resources_lists()
509 acpi_power_resources_list_free(&ps->resources); in acpi_free_power_resources_lists()
518 acpi_free_pnp_ids(&acpi_dev->pnp); in acpi_device_release()
530 if (!strcmp(acpi_device_bus_id->bus_id, in acpi_device_del()
532 ida_free(&acpi_device_bus_id->instance_ida, in acpi_device_del()
533 device->pnp.instance_no); in acpi_device_del()
534 if (ida_is_empty(&acpi_device_bus_id->instance_ida)) { in acpi_device_del()
535 list_del(&acpi_device_bus_id->node); in acpi_device_del()
536 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_del()
542 list_del(&device->wakeup_list); in acpi_device_del()
548 if (device->remove) in acpi_device_del()
549 device->remove(device); in acpi_device_del()
551 device_del(&device->dev); in acpi_device_del()
572 list_del(&adev->del_list); in acpi_device_del_work_fn()
590 * acpi_scan_drop_device - Drop an ACPI device object.
622 list_add_tail(&adev->del_list, &acpi_device_del_list); in acpi_scan_drop_device()
624 adev->handle = INVALID_ACPI_HANDLE; in acpi_scan_drop_device()
638 acpi_handle_debug(handle, "No context!\n"); in handle_to_device()
645 * acpi_fetch_acpi_dev - Retrieve ACPI device object.
663 * acpi_get_acpi_dev - Retrieve ACPI device object and reference count it.
667 * up that object's reference counter (under the ACPI Namespace lock), if
670 * The ACPI device object reference acquired by this function needs to be
685 if (!strcmp(acpi_device_bus_id->bus_id, dev_id)) in acpi_device_bus_id_match()
694 struct ida *instance_ida = &acpi_device_bus_id->instance_ida; in acpi_device_set_name()
701 device->pnp.instance_no = result; in acpi_device_set_name()
702 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result); in acpi_device_set_name()
708 acpi_handle handle = adev->handle; in acpi_tie_acpi_dev()
716 acpi_handle_err(handle, "Unable to attach device data\n"); in acpi_tie_acpi_dev()
717 return -ENODEV; in acpi_tie_acpi_dev()
728 status = acpi_get_physical_device_location(adev->handle, &pld); in acpi_store_pld_crc()
732 adev->pld_crc = crc32(~0, pld, sizeof(*pld)); in acpi_store_pld_crc()
743 * ------- in acpi_device_add()
746 INIT_LIST_HEAD(&device->wakeup_list); in acpi_device_add()
747 INIT_LIST_HEAD(&device->physical_node_list); in acpi_device_add()
748 INIT_LIST_HEAD(&device->del_list); in acpi_device_add()
749 mutex_init(&device->physical_node_lock); in acpi_device_add()
762 result = -ENOMEM; in acpi_device_add()
765 acpi_device_bus_id->bus_id = in acpi_device_add()
767 if (!acpi_device_bus_id->bus_id) { in acpi_device_add()
769 result = -ENOMEM; in acpi_device_add()
773 ida_init(&acpi_device_bus_id->instance_ida); in acpi_device_add()
777 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_add()
782 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); in acpi_device_add()
785 if (device->wakeup.flags.valid) in acpi_device_add()
786 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); in acpi_device_add()
792 result = device_add(&device->dev); in acpi_device_add()
794 dev_err(&device->dev, "Error registering device\n"); in acpi_device_add()
805 list_del(&device->wakeup_list); in acpi_device_add()
810 acpi_detach_data(device->handle, acpi_scan_drop_device); in acpi_device_add()
815 /* --------------------------------------------------------------------------
817 -------------------------------------------------------------------------- */
824 if (!(info->valid & ACPI_VALID_HID)) in acpi_info_matches_ids()
827 index = match_string(ids, -1, info->hardware_id.string); in acpi_info_matches_ids()
831 if (info->valid & ACPI_VALID_CID) in acpi_info_matches_ids()
832 cid_list = &info->compatible_id_list; in acpi_info_matches_ids()
837 for (i = 0; i < cid_list->count; i++) { in acpi_info_matches_ids()
838 index = match_string(ids, -1, cid_list->ids[i].string); in acpi_info_matches_ids()
848 "PNP0D80", /* Windows-compatible System Power Management Controller */
861 "RSCV0001", /* RISC-V PLIC */
862 "RSCV0002", /* RISC-V APLIC */
909 status = acpi_get_handle(ACPI_ROOT_OBJECT, obj->string.pointer, in acpi_bus_get_ejd()
919 acpi_handle handle = dev->handle; in acpi_bus_extract_wakeup_device_power_package()
920 struct acpi_device_wakeup *wakeup = &dev->wakeup; in acpi_bus_extract_wakeup_device_power_package()
925 int err = -ENODATA; in acpi_bus_extract_wakeup_device_power_package()
927 INIT_LIST_HEAD(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
932 acpi_handle_info(handle, "_PRW evaluation failed: %s\n", in acpi_bus_extract_wakeup_device_power_package()
939 if (!package || package->package.count < 2) in acpi_bus_extract_wakeup_device_power_package()
942 element = &(package->package.elements[0]); in acpi_bus_extract_wakeup_device_power_package()
946 if (element->type == ACPI_TYPE_PACKAGE) { in acpi_bus_extract_wakeup_device_power_package()
947 if ((element->package.count < 2) || in acpi_bus_extract_wakeup_device_power_package()
948 (element->package.elements[0].type != in acpi_bus_extract_wakeup_device_power_package()
950 || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) in acpi_bus_extract_wakeup_device_power_package()
953 wakeup->gpe_device = in acpi_bus_extract_wakeup_device_power_package()
954 element->package.elements[0].reference.handle; in acpi_bus_extract_wakeup_device_power_package()
955 wakeup->gpe_number = in acpi_bus_extract_wakeup_device_power_package()
956 (u32) element->package.elements[1].integer.value; in acpi_bus_extract_wakeup_device_power_package()
957 } else if (element->type == ACPI_TYPE_INTEGER) { in acpi_bus_extract_wakeup_device_power_package()
958 wakeup->gpe_device = NULL; in acpi_bus_extract_wakeup_device_power_package()
959 wakeup->gpe_number = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
964 element = &(package->package.elements[1]); in acpi_bus_extract_wakeup_device_power_package()
965 if (element->type != ACPI_TYPE_INTEGER) in acpi_bus_extract_wakeup_device_power_package()
968 wakeup->sleep_state = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
970 err = acpi_extract_power_resources(package, 2, &wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
974 if (!list_empty(&wakeup->resources)) { in acpi_bus_extract_wakeup_device_power_package()
977 err = acpi_power_wakeup_list_init(&wakeup->resources, in acpi_bus_extract_wakeup_device_power_package()
981 "of wakeup power resources failed\n"); in acpi_bus_extract_wakeup_device_power_package()
982 acpi_power_resources_list_free(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
985 if (sleep_state < wakeup->sleep_state) { in acpi_bus_extract_wakeup_device_power_package()
987 "(S%d) by S%d from power resources\n", in acpi_bus_extract_wakeup_device_power_package()
988 (int)wakeup->sleep_state, sleep_state); in acpi_bus_extract_wakeup_device_power_package()
989 wakeup->sleep_state = sleep_state; in acpi_bus_extract_wakeup_device_power_package()
1009 struct acpi_device_wakeup *wakeup = &device->wakeup; in acpi_wakeup_gpe_init()
1013 wakeup->flags.notifier_present = 0; in acpi_wakeup_gpe_init()
1015 /* Power button, Lid switch always enable wakeup */ in acpi_wakeup_gpe_init()
1018 if ((match->driver_data & ACPI_AVOID_WAKE_FROM_S5) && in acpi_wakeup_gpe_init()
1019 wakeup->sleep_state == ACPI_STATE_S5) in acpi_wakeup_gpe_init()
1020 wakeup->sleep_state = ACPI_STATE_S4; in acpi_wakeup_gpe_init()
1021 acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number); in acpi_wakeup_gpe_init()
1022 device_set_wakeup_capable(&device->dev, true); in acpi_wakeup_gpe_init()
1026 status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device, in acpi_wakeup_gpe_init()
1027 wakeup->gpe_number); in acpi_wakeup_gpe_init()
1036 if (!acpi_has_method(device->handle, "_PRW")) in acpi_bus_get_wakeup_device_flags()
1041 dev_err(&device->dev, "Unable to extract wakeup power resources"); in acpi_bus_get_wakeup_device_flags()
1045 device->wakeup.flags.valid = acpi_wakeup_gpe_init(device); in acpi_bus_get_wakeup_device_flags()
1046 device->wakeup.prepare_count = 0; in acpi_bus_get_wakeup_device_flags()
1056 pr_debug("error in _DSW or _PSW evaluation\n"); in acpi_bus_get_wakeup_device_flags()
1061 struct acpi_device_power_state *ps = &device->power.states[state]; in acpi_bus_init_power_state()
1066 INIT_LIST_HEAD(&ps->resources); in acpi_bus_init_power_state()
1069 status = acpi_evaluate_object(device->handle, pathname, NULL, &buffer); in acpi_bus_init_power_state()
1074 && package->type == ACPI_TYPE_PACKAGE in acpi_bus_init_power_state()
1075 && package->package.count) in acpi_bus_init_power_state()
1076 acpi_extract_power_resources(package, 0, &ps->resources); in acpi_bus_init_power_state()
1083 if (acpi_has_method(device->handle, pathname)) in acpi_bus_init_power_state()
1084 ps->flags.explicit_set = 1; in acpi_bus_init_power_state()
1087 if (!list_empty(&ps->resources) || ps->flags.explicit_set) in acpi_bus_init_power_state()
1088 ps->flags.valid = 1; in acpi_bus_init_power_state()
1090 ps->power = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
1091 ps->latency = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
1100 if (!acpi_has_method(device->handle, "_PS0") && in acpi_bus_get_power_flags()
1101 !acpi_has_method(device->handle, "_PR0")) in acpi_bus_get_power_flags()
1104 device->flags.power_manageable = 1; in acpi_bus_get_power_flags()
1109 if (acpi_has_method(device->handle, "_PSC")) in acpi_bus_get_power_flags()
1110 device->power.flags.explicit_get = 1; in acpi_bus_get_power_flags()
1112 if (acpi_has_method(device->handle, "_IRC")) in acpi_bus_get_power_flags()
1113 device->power.flags.inrush_current = 1; in acpi_bus_get_power_flags()
1115 if (acpi_has_method(device->handle, "_DSW")) in acpi_bus_get_power_flags()
1116 device->power.flags.dsw_present = 1; in acpi_bus_get_power_flags()
1118 acpi_evaluate_integer(device->handle, "_DSC", NULL, &dsc); in acpi_bus_get_power_flags()
1119 device->power.state_for_enumeration = dsc; in acpi_bus_get_power_flags()
1127 INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); in acpi_bus_get_power_flags()
1130 device->power.states[ACPI_STATE_D0].flags.valid = 1; in acpi_bus_get_power_flags()
1131 device->power.states[ACPI_STATE_D0].power = 100; in acpi_bus_get_power_flags()
1132 device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1; in acpi_bus_get_power_flags()
1139 if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) { in acpi_bus_get_power_flags()
1140 device->power.flags.power_resources = 1; in acpi_bus_get_power_flags()
1145 if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources)) in acpi_bus_get_power_flags()
1146 device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; in acpi_bus_get_power_flags()
1150 device->flags.power_manageable = 0; in acpi_bus_get_power_flags()
1156 if (acpi_has_method(device->handle, "_STA")) in acpi_bus_get_flags()
1157 device->flags.dynamic_status = 1; in acpi_bus_get_flags()
1160 if (acpi_has_method(device->handle, "_RMV")) in acpi_bus_get_flags()
1161 device->flags.removable = 1; in acpi_bus_get_flags()
1164 if (acpi_has_method(device->handle, "_EJD") || in acpi_bus_get_flags()
1165 acpi_has_method(device->handle, "_EJ0")) in acpi_bus_get_flags()
1166 device->flags.ejectable = 1; in acpi_bus_get_flags()
1177 * ------ in acpi_device_get_busid()
1182 strscpy(device->pnp.bus_id, "ACPI"); in acpi_device_get_busid()
1186 switch (device->device_type) { in acpi_device_get_busid()
1188 strscpy(device->pnp.bus_id, "PWRF"); in acpi_device_get_busid()
1191 strscpy(device->pnp.bus_id, "SLPF"); in acpi_device_get_busid()
1194 strscpy(device->pnp.bus_id, "ECDT"); in acpi_device_get_busid()
1197 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer); in acpi_device_get_busid()
1199 for (i = 3; i > 1; i--) { in acpi_device_get_busid()
1205 strscpy(device->pnp.bus_id, bus_id); in acpi_device_get_busid()
1211 * acpi_ata_match - see if an acpi object is an ATA device
1225 * acpi_bay_match - see if an acpi object is an ejectable driver bay
1248 list_for_each_entry(hwid, &adev->pnp.ids, list) in acpi_device_is_battery()
1249 if (!strcmp("PNP0C0A", hwid->id)) in acpi_device_is_battery()
1257 acpi_handle handle = adev->handle; in is_ejectable_bay()
1266 * acpi_dock_match - see if an acpi object has a _DCK method
1281 acpi_handle_debug(handle, "Found generic backlight support\n"); in acpi_backlight_cap_match()
1294 * Use acpi_video_get_capabilities() to detect general ACPI video
1329 hid = list_first_entry_or_null(&device->pnp.ids, struct acpi_hardware_id, list); in acpi_device_hid()
1333 return hid->id; in acpi_device_hid()
1345 id->id = kstrdup_const(dev_id, GFP_KERNEL); in acpi_add_id()
1346 if (!id->id) { in acpi_add_id()
1351 list_add_tail(&id->list, &pnp->ids); in acpi_add_id()
1352 pnp->type.hardware_id = 1; in acpi_add_id()
1412 pr_err("%s: Error reading device info\n", __func__); in acpi_set_pnp_ids()
1416 if (info->valid & ACPI_VALID_HID) { in acpi_set_pnp_ids()
1417 acpi_add_id(pnp, info->hardware_id.string); in acpi_set_pnp_ids()
1418 pnp->type.platform_id = 1; in acpi_set_pnp_ids()
1420 if (info->valid & ACPI_VALID_CID) { in acpi_set_pnp_ids()
1421 cid_list = &info->compatible_id_list; in acpi_set_pnp_ids()
1422 for (i = 0; i < cid_list->count; i++) in acpi_set_pnp_ids()
1423 acpi_add_id(pnp, cid_list->ids[i].string); in acpi_set_pnp_ids()
1425 if (info->valid & ACPI_VALID_ADR) { in acpi_set_pnp_ids()
1426 pnp->bus_address = info->address; in acpi_set_pnp_ids()
1427 pnp->type.bus_address = 1; in acpi_set_pnp_ids()
1429 if (info->valid & ACPI_VALID_UID) in acpi_set_pnp_ids()
1430 pnp->unique_id = kstrdup(info->unique_id.string, in acpi_set_pnp_ids()
1432 if (info->valid & ACPI_VALID_CLS) in acpi_set_pnp_ids()
1433 acpi_add_id(pnp, info->class_code.string); in acpi_set_pnp_ids()
1443 pnp->type.backlight = 1; in acpi_set_pnp_ids()
1452 else if (list_empty(&pnp->ids) && in acpi_set_pnp_ids()
1456 strscpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); in acpi_set_pnp_ids()
1457 strscpy(pnp->device_class, ACPI_BUS_CLASS); in acpi_set_pnp_ids()
1486 list_for_each_entry_safe(id, tmp, &pnp->ids, list) { in acpi_free_pnp_ids()
1487 kfree_const(id->id); in acpi_free_pnp_ids()
1490 kfree(pnp->unique_id); in acpi_free_pnp_ids()
1494 * acpi_dma_supported - Check DMA support for the specified device.
1504 if (adev->flags.cca_seen) in acpi_dma_supported()
1508 * Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent in acpi_dma_supported()
1519 * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
1529 if (adev->flags.coherent_dma) in acpi_get_dma_attr()
1536 * acpi_dma_get_range() - Get device DMA parameters.
1562 if (adev && acpi_has_method(adev->handle, METHOD_NAME__DMA)) in acpi_dma_get_range()
1565 dma_dev = dma_dev->parent; in acpi_dma_get_range()
1569 return -ENODEV; in acpi_dma_get_range()
1571 if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) { in acpi_dma_get_range()
1572 acpi_handle_warn(adev->handle, "_DMA is valid only if _CRS is present\n"); in acpi_dma_get_range()
1573 return -EINVAL; in acpi_dma_get_range()
1580 ret = -ENOMEM; in acpi_dma_get_range()
1587 if (rentry->res->start >= rentry->res->end) { in acpi_dma_get_range()
1590 ret = -EINVAL; in acpi_dma_get_range()
1591 dev_dbg(dma_dev, "Invalid DMA regions configuration\n"); in acpi_dma_get_range()
1595 r->cpu_start = rentry->res->start; in acpi_dma_get_range()
1596 r->dma_start = rentry->res->start - rentry->offset; in acpi_dma_get_range()
1597 r->size = resource_size(rentry->res); in acpi_dma_get_range()
1624 /* Serialise to make dev->iommu stable under our potential fwspec */ in acpi_iommu_configure_id()
1633 if (err && err != -EPROBE_DEFER) in acpi_iommu_configure_id()
1641 if (!err && dev->bus) in acpi_iommu_configure_id()
1652 return -ENODEV; in acpi_iommu_fwspec_init()
1657 return -ENODEV; in acpi_iommu_configure_id()
1663 * acpi_dma_configure_id - Set-up DMA configuration for the device.
1682 if (ret == -EPROBE_DEFER) in acpi_dma_configure_id()
1683 return -EPROBE_DEFER; in acpi_dma_configure_id()
1685 dev_dbg(dev, "Adding to IOMMU failed: %d\n", ret); in acpi_dma_configure_id()
1699 if (parent && parent->flags.cca_seen) { in acpi_init_coherency()
1704 adev->flags.cca_seen = 1; in acpi_init_coherency()
1705 cca = parent->flags.coherent_dma; in acpi_init_coherency()
1707 status = acpi_evaluate_integer(adev->handle, "_CCA", in acpi_init_coherency()
1710 adev->flags.cca_seen = 1; in acpi_init_coherency()
1714 * required for DMA-able devices (e.g. x86), in acpi_init_coherency()
1719 acpi_handle_debug(adev->handle, in acpi_init_coherency()
1720 "ACPI device is missing _CCA.\n"); in acpi_init_coherency()
1723 adev->flags.coherent_dma = cca; in acpi_init_coherency()
1730 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) in acpi_check_serial_bus_slave()
1736 return -1; in acpi_check_serial_bus_slave()
1761 * by the drivers/platform/x86/serial-multi-instantiate.c driver, which in acpi_device_enumeration_by_parent()
1772 /* Non-conforming _HID for Cirrus Logic already released */ in acpi_device_enumeration_by_parent()
1785 * such as the rfkill-gpio driver. in acpi_device_enumeration_by_parent()
1797 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || in acpi_device_enumeration_by_parent()
1798 fwnode_property_present(&device->fwnode, "i2cAddress") || in acpi_device_enumeration_by_parent()
1799 fwnode_property_present(&device->fwnode, "baud"))) in acpi_device_enumeration_by_parent()
1819 INIT_LIST_HEAD(&device->pnp.ids); in acpi_init_device_object()
1820 device->device_type = type; in acpi_init_device_object()
1821 device->handle = handle; in acpi_init_device_object()
1822 device->dev.parent = parent ? &parent->dev : NULL; in acpi_init_device_object()
1823 device->dev.release = release; in acpi_init_device_object()
1824 device->dev.bus = &acpi_bus_type; in acpi_init_device_object()
1825 device->dev.groups = acpi_groups; in acpi_init_device_object()
1826 fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); in acpi_init_device_object()
1829 acpi_set_pnp_ids(handle, &device->pnp, type); in acpi_init_device_object()
1832 device->flags.match_driver = false; in acpi_init_device_object()
1833 device->flags.initialized = true; in acpi_init_device_object()
1834 device->flags.enumeration_by_parent = in acpi_init_device_object()
1837 device_initialize(&device->dev); in acpi_init_device_object()
1838 dev_set_uevent_suppress(&device->dev, true); in acpi_init_device_object()
1847 if (dep->consumer == adev->handle) { in acpi_scan_dep_init()
1848 if (dep->honor_dep) in acpi_scan_dep_init()
1849 adev->flags.honor_deps = 1; in acpi_scan_dep_init()
1851 if (!dep->met) in acpi_scan_dep_init()
1852 adev->dep_unmet++; in acpi_scan_dep_init()
1859 dev_set_uevent_suppress(&device->dev, false); in acpi_device_add_finalize()
1860 kobject_uevent(&device->dev.kobj, KOBJ_ADD); in acpi_device_add_finalize()
1878 return -ENOMEM; in acpi_add_single_object()
1884 * this must be done before the get power-/wakeup_dev-flags calls. in acpi_add_single_object()
1890 * Hold the lock until the acpi_tie_acpi_dev() call in acpi_add_single_object()
1913 acpi_device_release(&device->dev); in acpi_add_single_object()
1920 acpi_handle_debug(handle, "Added as %s, parent %s\n", in acpi_add_single_object()
1921 dev_name(&device->dev), device->dev.parent ? in acpi_add_single_object()
1922 dev_name(device->dev.parent) : "(null)"); in acpi_add_single_object()
1957 acpi_handle_info(handle, "The UART device @%pa in SPCR table will be hidden\n", in acpi_device_should_be_hidden()
1965 return adev->status.present || adev->status.functional; in acpi_device_is_present()
1970 return adev->status.enabled; in acpi_device_is_enabled()
1979 if (handler->match) in acpi_scan_handler_matching()
1980 return handler->match(idstr, matchid); in acpi_scan_handler_matching()
1982 for (devid = handler->ids; devid->id[0]; devid++) in acpi_scan_handler_matching()
1983 if (!strcmp((char *)devid->id, idstr)) { in acpi_scan_handler_matching()
2007 if (!!hotplug->enabled == !!val) in acpi_scan_hotplug_enabled()
2012 hotplug->enabled = val; in acpi_scan_hotplug_enabled()
2022 for (count = 0, i = 0; i < dep_devices->count; i++) { in acpi_scan_add_dep()
2028 status = acpi_get_object_info(dep_devices->handles[i], &info); in acpi_scan_add_dep()
2030 acpi_handle_debug(handle, "Error reading _DEP device info\n"); in acpi_scan_add_dep()
2047 dep->supplier = dep_devices->handles[i]; in acpi_scan_add_dep()
2048 dep->consumer = handle; in acpi_scan_add_dep()
2049 dep->honor_dep = honor_dep; in acpi_scan_add_dep()
2052 list_add_tail(&dep->node, &acpi_dep_list); in acpi_scan_add_dep()
2064 if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) { in acpi_scan_init_hotplug()
2068 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_scan_init_hotplug()
2071 handler = acpi_scan_match_handler(hwid->id, NULL); in acpi_scan_init_hotplug()
2073 adev->flags.hotplug_notify = true; in acpi_scan_init_hotplug()
2087 * Some architectures like RISC-V need to add dependencies for in acpi_scan_check_dep()
2090 * Instead of mandating _DEP on all the devices, detect the in acpi_scan_check_dep()
2105 acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); in acpi_scan_check_dep()
2143 * The entire CSI-2 connection graph needs to be in acpi_bus_check_add()
2146 * _CRS CSI-2 resource descriptors for all in acpi_bus_check_add()
2212 if (!device->flags.enumeration_by_parent) { in acpi_default_enumeration()
2233 if (adev->data.of_compatible) in acpi_generic_device_attach()
2249 list_for_each_entry(hwid, &device->pnp.ids, list) { in acpi_scan_attach_handler()
2253 handler = acpi_scan_match_handler(hwid->id, &devid); in acpi_scan_attach_handler()
2255 if (!handler->attach) { in acpi_scan_attach_handler()
2256 device->pnp.type.platform_id = 0; in acpi_scan_attach_handler()
2259 device->handler = handler; in acpi_scan_attach_handler()
2260 ret = handler->attach(device, devid); in acpi_scan_attach_handler()
2264 device->handler = NULL; in acpi_scan_attach_handler()
2275 bool skip = !first_pass && device->flags.visited; in acpi_bus_attach()
2282 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd))) in acpi_bus_attach()
2288 device->flags.initialized = false; in acpi_bus_attach()
2290 device->flags.power_manageable = 0; in acpi_bus_attach()
2293 if (device->handler) in acpi_bus_attach()
2298 if (!device->flags.initialized) { in acpi_bus_attach()
2299 device->flags.power_manageable = in acpi_bus_attach()
2300 device->power.states[ACPI_STATE_D0].flags.valid; in acpi_bus_attach()
2302 device->flags.power_manageable = 0; in acpi_bus_attach()
2304 device->flags.initialized = true; in acpi_bus_attach()
2305 } else if (device->flags.visited) { in acpi_bus_attach()
2313 device->flags.match_driver = true; in acpi_bus_attach()
2314 if (ret > 0 && !device->flags.enumeration_by_parent) { in acpi_bus_attach()
2319 ret = device_attach(&device->dev); in acpi_bus_attach()
2323 if (device->pnp.type.platform_id || device->flags.enumeration_by_parent) in acpi_bus_attach()
2331 if (!skip && device->handler && device->handler->hotplug.notify_online) in acpi_bus_attach()
2332 device->handler->hotplug.notify_online(device); in acpi_bus_attach()
2348 if (dep->consumer == adev->handle) in acpi_dev_get_next_consumer_dev_cb()
2354 adev = acpi_get_acpi_dev(dep->consumer); in acpi_dev_get_next_consumer_dev_cb()
2375 acpi_bus_attach(cdw->adev, (void *)true); in acpi_scan_clear_dep_fn()
2378 acpi_dev_put(cdw->adev); in acpi_scan_clear_dep_fn()
2386 if (adev->dep_unmet) in acpi_scan_clear_dep_queue()
2393 cdw->adev = adev; in acpi_scan_clear_dep_queue()
2394 INIT_WORK(&cdw->work, acpi_scan_clear_dep_fn); in acpi_scan_clear_dep_queue()
2396 * Since the work function may block on the lock until the entire in acpi_scan_clear_dep_queue()
2400 queue_work(system_unbound_wq, &cdw->work); in acpi_scan_clear_dep_queue()
2407 list_del(&dep->node); in acpi_scan_delete_dep_data()
2413 struct acpi_device *adev = acpi_get_acpi_dev(dep->consumer); in acpi_scan_clear_dep()
2416 adev->dep_unmet--; in acpi_scan_clear_dep()
2421 if (dep->free_when_met) in acpi_scan_clear_dep()
2424 dep->met = true; in acpi_scan_clear_dep()
2430 * acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list
2432 * @callback: Pointer to the callback function to apply
2435 * The return value of the callback determines this function's behaviour. If 0
2437 * is returned then the loop is broken but this function returns 0. If a
2450 if (dep->supplier == handle) { in acpi_walk_dep_device_list()
2462 * acpi_dev_clear_dependencies - Inform consumers that the device is now active
2469 acpi_walk_dep_device_list(supplier->handle, acpi_scan_clear_dep, NULL); in acpi_dev_clear_dependencies()
2474 * acpi_dev_ready_for_enumeration - Check if the ACPI device is ready for enumeration
2483 if (device->flags.honor_deps && device->dep_unmet) in acpi_dev_ready_for_enumeration()
2491 * acpi_dev_get_next_consumer_dev - Return the next adev dependent on @supplier
2498 * If the returned adev is not passed as @start to this function, the caller is
2506 acpi_walk_dep_device_list(supplier->handle, in acpi_dev_get_next_consumer_dev()
2529 * Populate the ACPI _CRS CSI-2 software nodes for the ACPI devices that in acpi_scan_postponed_branch()
2544 acpi_handle handle = dep->consumer; in acpi_scan_postponed()
2553 * Even though the lock is released here, tmp is in acpi_scan_postponed()
2565 if (dep->met) in acpi_scan_postponed()
2568 dep->free_when_met = true; in acpi_scan_postponed()
2575 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
2578 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
2581 * If no devices were found, -ENODEV is returned, but it does not mean that
2600 return -ENODEV; in acpi_bus_scan()
2603 * Set up ACPI _CRS CSI-2 software nodes using information extracted in acpi_bus_scan()
2604 * from the _CRS CSI-2 resource descriptors during the ACPI namespace in acpi_bus_scan()
2623 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
2645 device->flags.match_driver = true; in acpi_bus_register_early_device()
2646 return device_attach(&device->dev); in acpi_bus_register_early_device()
2658 adev->flags.match_driver = true; in acpi_bus_scan_fixed()
2659 if (device_attach(&adev->dev) >= 0) in acpi_bus_scan_fixed()
2660 device_init_wakeup(&adev->dev, true); in acpi_bus_scan_fixed()
2662 dev_dbg(&adev->dev, "No driver\n"); in acpi_bus_scan_fixed()
2672 adev->flags.match_driver = true; in acpi_bus_scan_fixed()
2673 if (device_attach(&adev->dev) < 0) in acpi_bus_scan_fixed()
2674 dev_dbg(&adev->dev, "No driver\n"); in acpi_bus_scan_fixed()
2687 pr_warn("STAO table present, but SPCR is missing\n"); in acpi_get_spcr_uart_addr()
2691 spcr_uart_addr = spcr_ptr->serial_port.address; in acpi_get_spcr_uart_addr()
2725 if (stao_ptr->header.length > sizeof(struct acpi_table_stao)) in acpi_scan_init()
2726 pr_info("STAO Name List not yet supported.\n"); in acpi_scan_init()
2728 if (stao_ptr->ignore_uart) in acpi_scan_init()
2754 /* Fixed feature devices do not exist on HW-reduced platform */ in acpi_scan_init()
2773 if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape)) in acpi_match_madt()
2774 if (!ape->probe_subtbl(header, end)) in acpi_match_madt()
2791 for (ape = ap_head; nr; ape++, nr--) { in __acpi_probe_device_table()
2792 if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { in __acpi_probe_device_table()
2794 acpi_table_parse_madt(ape->type, acpi_match_madt, 0); in __acpi_probe_device_table()
2798 res = acpi_table_parse(ape->id, ape->probe_table); in __acpi_probe_device_table()