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: 709632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tqTTs4tPCz9sfH for ; Fri, 30 Dec 2016 12:32:01 +1100 (AEDT) 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 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,