From patchwork Fri Dec 30 01:27:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9491687 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 705EC62ABB for ; Fri, 30 Dec 2016 01:32:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EA0E20700 for ; Fri, 30 Dec 2016 01:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 535E7252D5; Fri, 30 Dec 2016 01:32:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C77ED20952 for ; Fri, 30 Dec 2016 01:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbcL3Bb7 (ORCPT ); Thu, 29 Dec 2016 20:31:59 -0500 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:64334 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbcL3Bb6 (ORCPT ); Thu, 29 Dec 2016 20:31:58 -0500 Received: from adkt146.ipv4.supernova.orange.pl (79.184.253.146) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.81.1) id 5d49b2d5a21ea391; Fri, 30 Dec 2016 02:31:37 +0100 From: "Rafael J. Wysocki" To: Mika Westerberg , Hans de Goede Cc: Len Brown , Adrian Hunter , Ulf Hansson , ACPI Devel Maling List , linux-mmc@vger.kernel.org, Andy Shevchenko , Linux PCI Subject: [PATCH] ACPI / scan: Prefer devices without _HID/_CID for _ADR matching Date: Fri, 30 Dec 2016 02:27:31 +0100 Message-ID: <2022116.4lq1KAmrJA@aspire.rjw.lan> User-Agent: KMail/4.14.10 (Linux/4.10.0-rc1+; KDE/4.14.9; x86_64; ; ) In-Reply-To: <20161229084135.GC1460@lahna.fi.intel.com> References: <20161225102148.7706-1-hdegoede@redhat.com> <20161229084135.GC1460@lahna.fi.intel.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki The way acpi_find_child_device() works currently is that, if there are two (or more) devices with the same _ADR value in the same namespace scope (which is not specifically allowed by the spec and the OS behavior in that case is not defined), the first one of them found to be present (with the help of _STA) will be returned. This covers the majority of cases, but is not sufficient if some of the devices in question have a _HID (or _CID) returning some valid ACPI/PNP device IDs (which is disallowed by the spec) and the ASL writers' expectation appears to be that the OS will match devices without a valid ACPI/PNP device ID against a given bus address first. To cover this special case as well, modify find_child_checks() to prefer devices without ACPI/PNP device IDs over devices that have them. Suggested-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki Tested-by: Hans de Goede --- I'm not actually sure if this is sufficient to fix the original 80860F14 uid "2" sd-controller problem on CherryTrail. Hans, can you please check? If it is not sufficient, we may need to fail find_child_checks() right away for devices with non-empty pnp.ids lists. Thanks, Rafael --- drivers/acpi/glue.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/drivers/acpi/glue.c =================================================================== --- linux-pm.orig/drivers/acpi/glue.c +++ linux-pm/drivers/acpi/glue.c @@ -98,7 +98,15 @@ static int find_child_checks(struct acpi if (check_children && list_empty(&adev->children)) return -ENODEV; - return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; + /* + * If the device has a _HID (or _CID) returning a valid ACPI/PNP + * device ID, it is better to make it look less attractive here, so that + * the other device with the same _ADR value (that may not have a valid + * device ID) can be matched going forward. [This means a second spec + * violation in a row, so whatever we do here is best effort anyway.] + */ + return sta_present && list_empty(&adev->pnp.ids) ? + FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; } struct acpi_device *acpi_find_child_device(struct acpi_device *parent,