From owner-svn-src-head@freebsd.org Mon Mar 9 20:27:26 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D19426C0FE; Mon, 9 Mar 2020 20:27:26 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48bqXF6Hr5z3CSd; Mon, 9 Mar 2020 20:27:25 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 89B781857B; Mon, 9 Mar 2020 20:27:25 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 029KRPbx061315; Mon, 9 Mar 2020 20:27:25 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 029KRP0q061314; Mon, 9 Mar 2020 20:27:25 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <202003092027.029KRP0q061314@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Mon, 9 Mar 2020 20:27:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358818 - head/sys/dev/acpica X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: head/sys/dev/acpica X-SVN-Commit-Revision: 358818 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2020 20:27:26 -0000 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)