From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bl2nam02on0118.outbound.protection.outlook.com ([104.47.38.118]:14317 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932258AbeDIAei (ORCPT ); Sun, 8 Apr 2018 20:34:38 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Hans de Goede , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 271/293] ACPI / scan: Use acpi_bus_get_status() to initialize ACPI_TYPE_DEVICE devs Date: Mon, 9 Apr 2018 00:26:27 +0000 Message-ID: <20180409002239.163177-271-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Hans de Goede [ Upstream commit 63347db0affadcbccd5613116ea8431c70139b3e ] The acpi_get_bus_status wrapper for acpi_bus_get_status_handle has some code to handle certain device quirks, in some cases we also need this quirk handling for the initial _STA call. Specifically on some devices calling _STA before all _DEP dependencies are met results in errors like these: [ 0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c) [GenericSerialBus] (20170831/evregion-166) [ 0.123601] ACPI Error: Region GenericSerialBus (ID=3D9) has no handler (20170831/exfldio-299) [ 0.123618] ACPI Error: Method parse/execution failed \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550) acpi_get_bus_status already has code to avoid this, so by using it we also silence these errors from the initial _STA call. Note that in order for the acpi_get_bus_status handling for this to work, we initialize dep_unmet to 1 until acpi_device_dep_initialize gets called, this means that battery devices will be instantiated with an initial status of 0. This is not a problem, acpi_bus_attach will get called soon after the instantiation anyways and it will update the status as first point of order. Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/scan.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index cf725d581cae..145dcf293c6f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1422,6 +1422,8 @@ void acpi_init_device_object(struct acpi_device *devi= ce, acpi_handle handle, device_initialize(&device->dev); dev_set_uevent_suppress(&device->dev, true); acpi_init_coherency(device); + /* Assume there are unmet deps until acpi_device_dep_initialize() runs */ + device->dep_unmet =3D 1; } =20 void acpi_device_add_finalize(struct acpi_device *device) @@ -1445,6 +1447,14 @@ static int acpi_add_single_object(struct acpi_device= **child, } =20 acpi_init_device_object(device, handle, type, sta); + /* + * For ACPI_BUS_TYPE_DEVICE getting the status is delayed till here so + * that we can call acpi_bus_get_status() and use its quirk handling. + * Note this must be done before the get power-/wakeup_dev-flags calls. + */ + if (type =3D=3D ACPI_BUS_TYPE_DEVICE) + acpi_bus_get_status(device); + acpi_bus_get_power_flags(device); acpi_bus_get_wakeup_device_flags(device); =20 @@ -1517,9 +1527,11 @@ static int acpi_bus_type_and_status(acpi_handle hand= le, int *type, return -ENODEV; =20 *type =3D ACPI_BUS_TYPE_DEVICE; - status =3D acpi_bus_get_status_handle(handle, sta); - if (ACPI_FAILURE(status)) - *sta =3D 0; + /* + * acpi_add_single_object updates this once we've an acpi_device + * so that acpi_bus_get_status' quirk handling can be used. + */ + *sta =3D 0; break; case ACPI_TYPE_PROCESSOR: *type =3D ACPI_BUS_TYPE_PROCESSOR; @@ -1621,6 +1633,8 @@ static void acpi_device_dep_initialize(struct acpi_de= vice *adev) acpi_status status; int i; =20 + adev->dep_unmet =3D 0; + if (!acpi_has_method(adev->handle, "_DEP")) return; =20 --=20 2.15.1