svn commit: r358818 - head/sys/dev/acpica
Vladimir Kondratyev
wulf at FreeBSD.org
Mon Mar 9 20:27:26 UTC 2020
Author: wulf
Date: Mon Mar 9 20:27:25 2020
New Revision: 358818
URL: https://svnweb.freebsd.org/changeset/base/358818
Log:
acpi: Fix stalled value returned by acpi_get_device() after device deletion
Newbus device reference attached to ACPI handle is not cleared when newbus
device is deleted with devctl(8) delete command. Fix that with calling of
AcpiDetachData() from "child_deleted" bus method like acpi_pci driver does.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22902
Modified:
head/sys/dev/acpica/acpi.c
Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c Mon Mar 9 19:55:13 2020 (r358817)
+++ head/sys/dev/acpica/acpi.c Mon Mar 9 20:27:25 2020 (r358818)
@@ -121,6 +121,7 @@ static device_t acpi_add_child(device_t bus, u_int ord
static int acpi_print_child(device_t bus, device_t child);
static void acpi_probe_nomatch(device_t bus, device_t child);
static void acpi_driver_added(device_t dev, driver_t *driver);
+static void acpi_child_deleted(device_t dev, device_t child);
static int acpi_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result);
static int acpi_write_ivar(device_t dev, device_t child, int index,
@@ -199,6 +200,7 @@ static device_method_t acpi_methods[] = {
DEVMETHOD(bus_print_child, acpi_print_child),
DEVMETHOD(bus_probe_nomatch, acpi_probe_nomatch),
DEVMETHOD(bus_driver_added, acpi_driver_added),
+ DEVMETHOD(bus_child_deleted, acpi_child_deleted),
DEVMETHOD(bus_read_ivar, acpi_read_ivar),
DEVMETHOD(bus_write_ivar, acpi_write_ivar),
DEVMETHOD(bus_get_resource_list, acpi_get_rlist),
@@ -907,6 +909,18 @@ acpi_child_pnpinfo_str_method(device_t cbdev, device_t
}
/*
+ * Handle device deletion.
+ */
+static void
+acpi_child_deleted(device_t dev, device_t child)
+{
+ struct acpi_device *dinfo = device_get_ivars(child);
+
+ if (acpi_get_device(dinfo->ad_handle) == child)
+ AcpiDetachData(dinfo->ad_handle, acpi_fake_objhandler);
+}
+
+/*
* Handle per-device ivars
*/
static int
@@ -1791,10 +1805,8 @@ acpi_device_scan_cb(ACPI_HANDLE h, UINT32 level, void
return (status);
/* Remove the old child and its connection to the handle. */
- if (old_dev != NULL) {
+ if (old_dev != NULL)
device_delete_child(device_get_parent(old_dev), old_dev);
- AcpiDetachData(h, acpi_fake_objhandler);
- }
/* Recreate the handle association if the user created a device. */
if (dev != NULL)
More information about the svn-src-head
mailing list