Received: by 10.192.165.148 with SMTP id m20csp541200imm; Wed, 25 Apr 2018 03:59:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hB6XGcvF1rMiGqBI/JDmWJQ3fykdP3LwOotKzrQYICXmG7e+BswaiDIaCmPoNbEpHs5Fa X-Received: by 10.98.79.12 with SMTP id d12mr15740296pfb.220.1524653976199; Wed, 25 Apr 2018 03:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653976; cv=none; d=google.com; s=arc-20160816; b=Wybq2J9W+B/TepiaofFi/tnXXuKe80EIuMK0Z8bfBeFcnCdajzVyq1STcytyPJCHa+ t4dYVbadN4BvSHjKl3vNueifHJJ7cvV4PrQAOp6ibiiTf2nQpm/wDywhHUG+XLart7JS PvSPYcxw7WZKWctM72IUO4iD5Pd59h6R+SLmhl3svbWr/Mopn9Unv7gOcTe271CZeyJZ 0bylpI+oy4pSC8AEe0sUGGSBPQug/YtEwHepNpZPf1N6M3oBoFqvz0e8aBEIVzbsaISl /oFXaPeHCQtpgDO4Pe4iDPZbSSMBDG74FOas5XZFtLVTErOXUErFifkuQ/YiOWhoyvPa PIZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=lNNU0M25LbPQAq4hTwm8hvlnE8CeUfPuy4eEVWuV10U=; b=KRXQNiGC3vCCSMXACSXBGqU3/vjTiK7gxSEAdCZJDyLgRxDvJxZfT6ag3U31JL0Baw XdTqUiqdyxE4UshceMvfC1JvxMWx3y3Uc7On5sQomnn6hd30IH7OlbosCMUJQ5TWF50G M9E5M+CRcAnGqS+awQhTbbC2ehWJ2Ct1GNpl+Hx+XGCCvOwsqb6LmSgCC5WKZ763wHOX /JAyDjD0A/WYnC6XZvQ5GZIQilKjPKpAqLy4s/1Qu5V2rqSwCSh0JtULpkbNaVr2+Uxh KSdtVEFQujp19tivDQLgfHRcN9PFhbX9Ox7UH+Iw3Uihhmmx9ZMBAPDAh3ONk3t5fDXF ekEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si13381727pgn.320.2018.04.25.03.59.21; Wed, 25 Apr 2018 03:59:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754150AbeDYKmy (ORCPT + 99 others); Wed, 25 Apr 2018 06:42:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52710 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbeDYKmj (ORCPT ); Wed, 25 Apr 2018 06:42:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 42D6F272; Wed, 25 Apr 2018 10:42:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.14 132/183] ACPI / scan: Use acpi_bus_get_status() to initialize ACPI_TYPE_DEVICE devs Date: Wed, 25 Apr 2018 12:35:52 +0200 Message-Id: <20180425103247.726638638@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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=9) 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 Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/scan.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1568,6 +1568,8 @@ void acpi_init_device_object(struct acpi 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 = 1; } void acpi_device_add_finalize(struct acpi_device *device) @@ -1591,6 +1593,14 @@ static int acpi_add_single_object(struct } 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 == ACPI_BUS_TYPE_DEVICE) + acpi_bus_get_status(device); + acpi_bus_get_power_flags(device); acpi_bus_get_wakeup_device_flags(device); @@ -1663,9 +1673,11 @@ static int acpi_bus_type_and_status(acpi return -ENODEV; *type = ACPI_BUS_TYPE_DEVICE; - status = acpi_bus_get_status_handle(handle, sta); - if (ACPI_FAILURE(status)) - *sta = 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 = 0; break; case ACPI_TYPE_PROCESSOR: *type = ACPI_BUS_TYPE_PROCESSOR; @@ -1763,6 +1775,8 @@ static void acpi_device_dep_initialize(s acpi_status status; int i; + adev->dep_unmet = 0; + if (!acpi_has_method(adev->handle, "_DEP")) return;