Received: by 10.192.165.148 with SMTP id m20csp2536417imm; Sun, 22 Apr 2018 09:04:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+X+Zdj7Tdhgc3eUvHUkMq/iUbxoM6fXdbYhdDqssf/Rm8tWvTB9/fJXOUspZeb56BOg557 X-Received: by 2002:a17:902:8606:: with SMTP id f6-v6mr17784092plo.258.1524413091965; Sun, 22 Apr 2018 09:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413091; cv=none; d=google.com; s=arc-20160816; b=o4ZgTFPa/PnksF1h8ykp4jciPG66UYOWfKWZflY3OuHaQLBqUE+nUbXNsMCcCjof2M qyIDeXE9/XshHjWWCJLtUZ4L64tSbbprziP7kYk8+s6+8eZ6YyY1NhhR+ljiFbqRXYae oPwGlNZ3qbIYIXAXac/wVRgVhtXAo6ibwJ10d92YFaouwDbYW5MI99l9jOf2Zwijc/S+ IsFjStYGfIBe0JgLCOn6R7CATSg40xd018PHYQJtkyME2/MDdi1gAhehgCn5nwnquggQ gfrMKXqXrHxuPMmhBuMTPeSjJ4BEwEORe+Spk4rcG99ZmZGJonmgKvPGDe4KwnwEJHP1 45Tw== 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=jESWZSwxqujIGmDOjD+Nm9l4zcf4sK9Na5k+WOURsew=; b=ny6Gdt0zdsW5zvk7QuNmhuTdM3YSE/2ungmZwH/E5+TZ8e36Sx/YTYSfSs0rzFTHwx 92qHclywika6QnUPdbvsLz88RjS5KdUNklqdjV1lpwo+YlAV6ACO/IPFiSDpTX8HoEPh afYBTUIto5TSmoo1s3ehcGxdC00+cczMvMc6zeai7M5dPF3WL1QTCKMUBD9GB3XFrZFX RUcAEytCaENKG6HVhu/Z8wmuCH1FUS8WeZ4bvRdyJRfojpQR4O6ziGOfS7tM3VY6gCYu et98oiQY49Pe8y7QmJtrTPwabsS5Y0nF1hNerI8B5YCNal5DkykcSWk67g3o1Bx40Hyi NAEA== 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 o69si9587240pfi.322.2018.04.22.09.04.37; Sun, 22 Apr 2018 09:04:51 -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 S1754046AbeDVN5x (ORCPT + 99 others); Sun, 22 Apr 2018 09:57:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45908 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753578AbeDVN5r (ORCPT ); Sun, 22 Apr 2018 09:57:47 -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 C1BC8CD5; Sun, 22 Apr 2018 13:57:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Andy Shevchenko , Bjorn Helgaas Subject: [PATCH 4.16 076/196] thunderbolt: Serialize PCIe tunnel creation with PCI rescan Date: Sun, 22 Apr 2018 15:51:36 +0200 Message-Id: <20180422135108.176958731@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit a03e828915c00ed0ea5aa40647c81472cfa7a984 upstream. We need to make sure a new PCIe tunnel is not created in a middle of previous PCI rescan because otherwise the rescan code might find too much and fail to reconfigure devices properly. This is important when native PCIe hotplug is used. In BIOS assisted hotplug there should be no such issue. Fixes: f67cf491175a ("thunderbolt: Add support for Internal Connection Manager (ICM)") Signed-off-by: Mika Westerberg Reviewed-by: Andy Shevchenko Cc: Bjorn Helgaas Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/switch.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -716,6 +716,13 @@ static int tb_switch_set_authorized(stru if (sw->authorized) goto unlock; + /* + * Make sure there is no PCIe rescan ongoing when a new PCIe + * tunnel is created. Otherwise the PCIe rescan code might find + * the new tunnel too early. + */ + pci_lock_rescan_remove(); + switch (val) { /* Approve switch */ case 1: @@ -735,6 +742,8 @@ static int tb_switch_set_authorized(stru break; } + pci_unlock_rescan_remove(); + if (!ret) { sw->authorized = val; /* Notify status change to the userspace */