Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1645673pxu; Sat, 12 Dec 2020 21:53:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxchE0c2igI3p6sL3dpct0wpQBnLBoZPx6QzY2oBC9jQOm0Ck4JiA1sOVjbQSw3aIZ07E4T X-Received: by 2002:a50:e3cc:: with SMTP id c12mr330074edm.83.1607838802458; Sat, 12 Dec 2020 21:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607838802; cv=none; d=google.com; s=arc-20160816; b=RvYrgNKQifj8RKL6vskgaaZnOQ9194wyO3VjjOi8NusmSoyx9uYLP7IZm4JnUwoIPX 6lqywvyjzcQ4WHJptmdKI3gPRtbTkgcyZ4UDquxlyNiMi20m++wqlF2kEDO7SjPNKt5M Lu3hsLoFw/oTxpw5u86xz4LPNpDxE3Jeva2IJ2V3KBm+jEFWUj55GVXpm4cdRKJ6a1HX w2PXxlOa39f9IVEERYIa95+YVF+4EkZju8mQR7J23BMy5xJmCSEPlTQ4v8FlqVtC4Hqe aRZJvubGQwCOO4vM9Ruxe3wflwI745Wve1FhgaHWduDJm1ZfsZFVPts0WLUNTNWkDazy 3suw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:dkim-signature:date; bh=n0lDIwmHJ2JlTY3WrmSGY1F4iz4gNcHupBGnB7Ik3bU=; b=SFbBbe1McFA4XjcYOXxZfwbvvmUpPbVxknXnICtqR5luG+Nilyy7hMmPZPDX90ju2p z6BQJXEwRi9SO+7AMZx3O4ZJ4Gjm7r0Dg5q1t7atuGpATT1U2NEdBqwM4eNhLubZ8PrP RK7mO+h3bhPLY3apiPkLv2VwpgCl9PEH1c7YprAtJV/TnS59/pimIeLmSERpmmugJcaw W0t1jRFX4d9ZfqN8YhmkcogqTBIt5uBpnbzD5QuW1UtAzidsmGQkL1yxJu4FhFtQo8s5 KE4rkwkJSGbxMj0NfKuwcWbj99L5vC0Dh9VrZhHvbnyOH+CYZaiYlmBwu5MVvdR4LaDb ylyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=czQZgMhu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si7775623edx.538.2020.12.12.21.52.59; Sat, 12 Dec 2020 21:53:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=czQZgMhu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407118AbgLKXWi (ORCPT + 99 others); Fri, 11 Dec 2020 18:22:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:43842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733131AbgLKXWL (ORCPT ); Fri, 11 Dec 2020 18:22:11 -0500 Date: Fri, 11 Dec 2020 17:21:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607728890; bh=3VgLDCACXpJY6wxWW9+nWtwWslnzlCni0gtSsYXLq1o=; h=From:To:Cc:Subject:In-Reply-To:From; b=czQZgMhuwEPebAeGGCrIUMfWC9yOp5H6gu6xzPUiAlDmGF/gyoEzbGgagLrbZMebo VF3nKPxApMb6KKA3vv6IR5t53oFW/DipTC2WdkkrTwos9JG2XlQNAWyZhpNnfkVoFW AvoGryB/40junWu2tn892WOnYojJRfPPzXgS+PqkKOhMm4bg28zjOQxy23CFQ7THsw dpCtGwOGDpOHLIB9MeyG6E2ccQWYeEWwrizclhjmv8Xxzo5/MJe8i84Nu+Wjbsdzz1 +UT1KMsB/vaqrBmTQLQk06ZdT+Ajg1mlx4ofTN/4elzV9HtbMlrlGIut97ABAWHamn nnfMVwtfFfbJw== From: Bjorn Helgaas To: "Rafael J. Wysocki" Cc: Linux PCI , Daniel Scally , LKML , Linux ACPI Subject: Re: [PATCH] PCI: ACPI: Fix up ACPI companion lookup for device 0 on the root bus Message-ID: <20201211232129.GA118451@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4673285.9aE2nYKHPr@kreacher> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 09:17:35PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > In some cases acpi_pci_find_companion() returns an incorrect device > object as the ACPI companion for device 0 on the root bus (bus 0). > > On the affected systems that device is the PCI interface to the > host bridge and the "ACPI companion" returned for it corresponds > to a non-PCI device located in the SoC (e.g. a sensor on an I2C > bus). As a result of this, the ACPI device object "attached" > to PCI device 00:00.0 cannot be used for enumerating the device > that is really represented by it which (of course) is problematic. > > Address that issue by preventing acpi_pci_find_companion() from > returning a device object with a valid _HID (which by the spec > should not be present uder ACPI device objects corresponding to > PCI devices) for PCI device 00:00.0. > > Link: https://lore.kernel.org/linux-acpi/1409ba0c-1580-dc09-e6fe-a0c9bcda6462@gmail.com/ > Reported-by: Daniel Scally > Signed-off-by: Rafael J. Wysocki Applied with Daniel's Tested-by and Reviewed-by to pci/enumeration for v5.11, thanks! > --- > drivers/pci/pci-acpi.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > Index: linux-pm/drivers/pci/pci-acpi.c > =================================================================== > --- linux-pm.orig/drivers/pci/pci-acpi.c > +++ linux-pm/drivers/pci/pci-acpi.c > @@ -1162,14 +1162,32 @@ void acpi_pci_remove_bus(struct pci_bus > static struct acpi_device *acpi_pci_find_companion(struct device *dev) > { > struct pci_dev *pci_dev = to_pci_dev(dev); > + struct acpi_device *adev; > bool check_children; > u64 addr; > > check_children = pci_is_bridge(pci_dev); > /* Please ref to ACPI spec for the syntax of _ADR */ > addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); > - return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr, > + adev = acpi_find_child_device(ACPI_COMPANION(dev->parent), addr, > check_children); > + /* > + * There may be ACPI device objects in the ACPI namespace that are > + * children of the device object representing the host bridge, but don't > + * represent PCI devices. Both _HID and _ADR may be present for them, > + * even though that is against the specification (for example, see > + * Section 6.1 of ACPI 6.3), but in many cases the _ADR returns 0 which > + * appears to indicate that they should not be taken into consideration > + * as potential companions of PCI devices on the root bus. > + * > + * To catch this special case, disregard the returned device object if > + * it has a valid _HID, addr is 0 and the PCI device at hand is on the > + * root bus. > + */ > + if (adev && adev->pnp.type.platform_id && !addr && !pci_dev->bus->parent) > + return NULL; > + > + return adev; > } > > /** > > >