Received: by 10.192.165.148 with SMTP id m20csp2491649imm; Sun, 22 Apr 2018 08:08:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx492kQgGhh9W2yHv7/VROQc3uS71YmPTMsD8Rz8kH3VyCzOKIKkF4M3ofcIP/A+WfE1saVyM X-Received: by 2002:a17:902:aa90:: with SMTP id d16-v6mr17603560plr.189.1524409681541; Sun, 22 Apr 2018 08:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409681; cv=none; d=google.com; s=arc-20160816; b=REVQBjwJuQYUoeGnbRnRy+NQJnVnT3WwV0MBNzfE3+Vt041+xe4bAhr0thEw57Sb8u Dl5V1XEhf5p6FrJQWXW+FqkCsecUeBc6U3cFoSa7pAjtn5ASJR9ABsQXlu3yTsFVbPmx NF/Js8tKL53D7q3Ebvw3EGi/MSELn7v0cBIi1TU/xfDvj2VMD6VqKyFAYEw7xY6o0LJM oXm7YG7PfuA4L3YUQUVWTGzG1O9PhD9o344pauogrkI3HOPo0nY5BTNo41C8I6k8hD36 X2/qlmga+JXA4EVrugMVcyzrvNHBa922bT8at5pal2kMYPZ76OxDaRr5zjVnXMHzDTrs eO3g== 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=fyuxB7uASPs4V8EwrbccKdCUM8hiD6bv8oGzygKlhA0=; b=hqJMOVtd10Gqa2litqJ9/+MwqeX4tVYmvPCvRzjuKyj1VPMPB5X18NJliX0El+xfhq r4Sn8VhTwcXBnDtc47VbE96D9Kcv4973R3ZevLn8g2U8QmVNNWcf9H7EWJLxJSyAw0PW 2re8t0R61yoelGTfFYR4zsgVgi7QLEoYrwJ45Hiz3eZSLU07ZGmzqeMMo2ThasQv7lof PFAtdjCUv2h/Tg8pb6wFE707hGGXSiVAh9vXciKkxP/+5MUUTI+lvurlvuannPtx9s2N 2ZC3ziDtYmTmBPZM4S/74E6TOVLXF/9cZSDkKXIzU3uvr+tKw5ll9JmOLGsnu4MkOfQF cH+A== 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 f15-v6si9684769plr.310.2018.04.22.08.07.47; Sun, 22 Apr 2018 08:08:01 -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 S1755615AbeDVPGg (ORCPT + 99 others); Sun, 22 Apr 2018 11:06:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54448 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756052AbeDVOLf (ORCPT ); Sun, 22 Apr 2018 10:11:35 -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 4E4F8C97; Sun, 22 Apr 2018 14:11:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Lothian , Mika Westerberg , Bjorn Helgaas , "Rafael J. Wysocki" Subject: [PATCH 4.9 19/95] ACPI / hotplug / PCI: Check presence of slot itself in get_slot_status() Date: Sun, 22 Apr 2018 15:52:48 +0200 Message-Id: <20180422135211.229862795@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit 13d3047c81505cc0fb9bdae7810676e70523c8bf upstream. Mike Lothian reported that plugging in a USB-C device does not work properly in his Dell Alienware system. This system has an Intel Alpine Ridge Thunderbolt controller providing USB-C functionality. In these systems the USB controller (xHCI) is hotplugged whenever a device is connected to the port using ACPI-based hotplug. The ACPI description of the root port in question is as follows: Device (RP01) { Name (_ADR, 0x001C0000) Device (PXSX) { Name (_ADR, 0x02) Method (_RMV, 0, NotSerialized) { // ... } } Here _ADR 0x02 means device 0, function 2 on the bus under root port (RP01) but that seems to be incorrect because device 0 is the upstream port of the Alpine Ridge PCIe switch and it has no functions other than 0 (the bridge itself). When we get ACPI Notify() to the root port resulting from connecting a USB-C device, Linux tries to read PCI_VENDOR_ID from device 0, function 2 which of course always returns 0xffffffff because there is no such function and we never find the device. In Windows this works fine. Now, since we get ACPI Notify() to the root port and not to the PXSX device we should actually start our scan from there as well and not from the non-existent PXSX device. Fix this by checking presence of the slot itself (function 0) if we fail to do that otherwise. While there use pci_bus_read_dev_vendor_id() in get_slot_status(), which is the recommended way to read Device and Vendor IDs of devices on PCI buses. Link: https://bugzilla.kernel.org/show_bug.cgi?id=198557 Reported-by: Mike Lothian Signed-off-by: Mika Westerberg Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Cc: Greg Kroah-Hartman Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/acpiphp_glue.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -587,6 +587,7 @@ static unsigned int get_slot_status(stru { unsigned long long sta = 0; struct acpiphp_func *func; + u32 dvid; list_for_each_entry(func, &slot->funcs, sibling) { if (func->flags & FUNC_HAS_STA) { @@ -597,19 +598,27 @@ static unsigned int get_slot_status(stru if (ACPI_SUCCESS(status) && sta) break; } else { - u32 dvid; - - pci_bus_read_config_dword(slot->bus, - PCI_DEVFN(slot->device, - func->function), - PCI_VENDOR_ID, &dvid); - if (dvid != 0xffffffff) { + if (pci_bus_read_dev_vendor_id(slot->bus, + PCI_DEVFN(slot->device, func->function), + &dvid, 0)) { sta = ACPI_STA_ALL; break; } } } + if (!sta) { + /* + * Check for the slot itself since it may be that the + * ACPI slot is a device below PCIe upstream port so in + * that case it may not even be reachable yet. + */ + if (pci_bus_read_dev_vendor_id(slot->bus, + PCI_DEVFN(slot->device, 0), &dvid, 0)) { + sta = ACPI_STA_ALL; + } + } + return (unsigned int)sta; }