Lines Matching +full:device +full:- +full:handle
1 // SPDX-License-Identifier: GPL-2.0-or-later
32 struct acpi_device *device; member
44 op.u.mem_add.spfn = info->start_addr >> PAGE_SHIFT; in xen_hotadd_memory()
45 op.u.mem_add.epfn = (info->start_addr + info->length) >> PAGE_SHIFT; in xen_hotadd_memory()
51 "0x%lx -> 0x%lx, _PXM: %d, error: %d\n", in xen_hotadd_memory()
52 (unsigned long)info->start_addr, in xen_hotadd_memory()
53 (unsigned long)(info->start_addr + info->length), in xen_hotadd_memory()
66 return -EINVAL; in xen_acpi_memory_enable_device()
68 pxm = xen_acpi_get_pxm(mem_device->device->handle); in xen_acpi_memory_enable_device()
72 list_for_each_entry(info, &mem_device->res_list, list) { in xen_acpi_memory_enable_device()
73 if (info->enabled) { /* just sanity check...*/ in xen_acpi_memory_enable_device()
78 if (!info->length) in xen_acpi_memory_enable_device()
84 info->enabled = 1; in xen_acpi_memory_enable_device()
89 return -ENODEV; in xen_acpi_memory_enable_device()
107 list_for_each_entry(info, &mem_device->res_list, list) { in acpi_memory_get_resource()
108 if ((info->caching == address64.info.mem.caching) && in acpi_memory_get_resource()
109 (info->write_protect == address64.info.mem.write_protect) && in acpi_memory_get_resource()
110 (info->start_addr + info->length == address64.address.minimum)) { in acpi_memory_get_resource()
111 info->length += address64.address.address_length; in acpi_memory_get_resource()
120 INIT_LIST_HEAD(&new->list); in acpi_memory_get_resource()
121 new->caching = address64.info.mem.caching; in acpi_memory_get_resource()
122 new->write_protect = address64.info.mem.write_protect; in acpi_memory_get_resource()
123 new->start_addr = address64.address.minimum; in acpi_memory_get_resource()
124 new->length = address64.address.address_length; in acpi_memory_get_resource()
125 list_add_tail(&new->list, &mem_device->res_list); in acpi_memory_get_resource()
136 if (!list_empty(&mem_device->res_list)) in acpi_memory_get_device_resources()
139 status = acpi_walk_resources(mem_device->device->handle, in acpi_memory_get_device_resources()
143 list_for_each_entry_safe(info, n, &mem_device->res_list, list) in acpi_memory_get_device_resources()
145 INIT_LIST_HEAD(&mem_device->res_list); in acpi_memory_get_device_resources()
146 return -EINVAL; in acpi_memory_get_device_resources()
152 static int acpi_memory_get_device(acpi_handle handle, in acpi_memory_get_device() argument
155 struct acpi_device *device = NULL; in acpi_memory_get_device() local
160 acpi_bus_get_device(handle, &device); in acpi_memory_get_device()
161 if (acpi_device_enumerated(device)) in acpi_memory_get_device()
165 * Now add the notified device. This creates the acpi_device in acpi_memory_get_device()
168 result = acpi_bus_scan(handle); in acpi_memory_get_device()
171 result = -EINVAL; in acpi_memory_get_device()
174 device = NULL; in acpi_memory_get_device()
175 acpi_bus_get_device(handle, &device); in acpi_memory_get_device()
176 if (!acpi_device_enumerated(device)) { in acpi_memory_get_device()
177 pr_warn(PREFIX "Missing device object\n"); in acpi_memory_get_device()
178 result = -EINVAL; in acpi_memory_get_device()
183 *mem_device = acpi_driver_data(device); in acpi_memory_get_device()
186 result = -ENODEV; in acpi_memory_get_device()
199 /* Get device present/absent information from the _STA */ in acpi_memory_check_device()
200 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, in acpi_memory_check_device()
202 return -ENODEV; in acpi_memory_check_device()
204 * Check for device status. Device should be in acpi_memory_check_device()
210 return -ENODEV; in acpi_memory_check_device()
219 return -ENOSYS; in acpi_memory_disable_device()
222 static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) in acpi_memory_device_notify() argument
225 struct acpi_device *device; in acpi_memory_device_notify() local
231 "\nReceived BUS CHECK notification for device\n")); in acpi_memory_device_notify()
236 "\nReceived DEVICE CHECK notification for device\n")); in acpi_memory_device_notify()
238 if (acpi_memory_get_device(handle, &mem_device)) { in acpi_memory_device_notify()
248 "\nReceived EJECT REQUEST notification for device\n")); in acpi_memory_device_notify()
251 if (acpi_bus_get_device(handle, &device)) { in acpi_memory_device_notify()
253 pr_err(PREFIX "Device doesn't exist\n"); in acpi_memory_device_notify()
256 mem_device = acpi_driver_data(device); in acpi_memory_device_notify()
274 /* non-hotplug event; possibly handled by other handler */ in acpi_memory_device_notify()
278 (void) acpi_evaluate_ost(handle, event, ost_code, NULL); in acpi_memory_device_notify()
282 static int xen_acpi_memory_device_add(struct acpi_device *device) in xen_acpi_memory_device_add() argument
288 if (!device) in xen_acpi_memory_device_add()
289 return -EINVAL; in xen_acpi_memory_device_add()
293 return -ENOMEM; in xen_acpi_memory_device_add()
295 INIT_LIST_HEAD(&mem_device->res_list); in xen_acpi_memory_device_add()
296 mem_device->device = device; in xen_acpi_memory_device_add()
297 sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); in xen_acpi_memory_device_add()
298 sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); in xen_acpi_memory_device_add()
299 device->driver_data = mem_device; in xen_acpi_memory_device_add()
312 * For hot-added memory devices during runtime, it need hypercall to in xen_acpi_memory_device_add()
324 static int xen_acpi_memory_device_remove(struct acpi_device *device) in xen_acpi_memory_device_remove() argument
328 if (!device || !acpi_driver_data(device)) in xen_acpi_memory_device_remove()
329 return -EINVAL; in xen_acpi_memory_device_remove()
331 mem_device = acpi_driver_data(device); in xen_acpi_memory_device_remove()
338 * Helper function to check for memory device
340 static acpi_status is_memory_device(acpi_handle handle) in is_memory_device() argument
346 status = acpi_get_object_info(handle, &info); in is_memory_device()
350 if (!(info->valid & ACPI_VALID_HID)) { in is_memory_device()
355 hardware_id = info->hardware_id.string; in is_memory_device()
365 acpi_memory_register_notify_handler(acpi_handle handle, in acpi_memory_register_notify_handler() argument
370 status = is_memory_device(handle); in acpi_memory_register_notify_handler()
374 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, in acpi_memory_register_notify_handler()
381 acpi_memory_deregister_notify_handler(acpi_handle handle, in acpi_memory_deregister_notify_handler() argument
386 status = is_memory_device(handle); in acpi_memory_deregister_notify_handler()
390 status = acpi_remove_notify_handler(handle, in acpi_memory_deregister_notify_handler()
419 return -ENODEV; in xen_acpi_memory_device_init()
427 return -ENODEV; in xen_acpi_memory_device_init()
439 return -ENODEV; in xen_acpi_memory_device_init()
472 ACPI_MODULE_NAME("xen-acpi-memhotplug");