From patchwork Mon Jul 2 22:52:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10502613 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 CB59360362 for ; Mon, 2 Jul 2018 22:54:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9CF028BE0 for ; Mon, 2 Jul 2018 22:54:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADC8B28BE7; Mon, 2 Jul 2018 22:54:34 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5BA1228BE0 for ; Mon, 2 Jul 2018 22:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+uHYNWYXCW2uCmKjZ9fY5sGCc/u0bs58MF+q/36HPZo=; b=W2VqT8kgX3e56z yG6LouLhHcKK35KCQ0XDLX3DtTBu1mxhUcHMkdALlQFkCBA/EK/9cqacZtVGvVTWzNsG98KZJqusL AyNIYuENYfAjwzsffyHgN/3JHRQgKomIVSK+FM4pjHN2HeqKKFNjH4zMTps5o02BbigqvTJjv2TvS lppZ3Wjeo5eb8yrE7JyQsk8BJNxJPLRZ5l78Tj+6qhKZTmiGI2OTRTOEyOIaaqTdG1MJ3gKHqJ9w6 Dj9nKWA9CkGKPi7ccPOUNhIF9BetzZXQER4faMTOh5iuzDKK75RhbQZgtBDgXFuV6tXPlS/apdmnj fRL306gFhIHH7fCz/E9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fa7iI-00052a-2L; Mon, 02 Jul 2018 22:54:30 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fa7hl-0004en-25 for linux-arm-kernel@lists.infradead.org; Mon, 02 Jul 2018 22:54:27 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A469360B81; Mon, 2 Jul 2018 22:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530572026; bh=pYHQTxnahFexmpL0lQMGi2zFFobmcYwl9fUxyeMG0/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=obNYgi+69uFQK8/CA/GVTO9zgspjE6gW3YlRZHFOje6DZoNAJpKUjMkKGb9d3Aa+P MwtvhW88bih6XY2AHenyg+kl5LJLQGmhpLQeyJRh9C6wB9gboksmZogVvARuVdw3+M ubGEpGtkPxBvU9UeUxqj/9fdZX0VNFbtFijtoAiU= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7692260B7E; Mon, 2 Jul 2018 22:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530572025; bh=pYHQTxnahFexmpL0lQMGi2zFFobmcYwl9fUxyeMG0/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtC4njDKHyVHGvive42vHZS2h2QVXs+5smq5x9HQBtLyvoejuO27wQCn3EB/qolPT vG1pf2X5tXL9ArF6sh5s/8zhu/F0cDUbUiXqdNKCG5kwv048YwaAQx5mgQdgzmr60k uVQ1KHt28JUBFBQ6iMfhGVYPPDN+M33Bm1XKg17M= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7692260B7E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org Subject: [PATCH V5 3/3] PCI: Mask and unmask hotplug interrupts during reset Date: Mon, 2 Jul 2018 18:52:47 -0400 Message-Id: <1530571967-19099-4-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530571967-19099-1-git-send-email-okaya@codeaurora.org> References: <1530571967-19099-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180702_155358_043801_B755B124 X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Oza Pawandeep , linux-arm-msm@vger.kernel.org, open list , Sinan Kaya , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If a bridge supports hotplug and observes a PCIe fatal error, the following events happen: 1. AER driver removes the devices from PCI tree on fatal error 2. AER driver brings down the link by issuing a secondary bus reset waits for the link to come up. 3. Hotplug driver observes a link down interrupt 4. Hotplug driver tries to remove the devices waiting for the rescan lock but devices are already removed by the AER driver and AER driver is waiting for the link to come back up. 5. AER driver tries to re-enumerate devices after polling for the link state to go up. 6. Hotplug driver obtains the lock and tries to remove the devices again. If a bridge is a hotplug capable bridge, mask hotplug interrupts before the reset and unmask afterwards. Signed-off-by: Sinan Kaya --- drivers/pci/pcie/err.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index ae72f88..5a2d410 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -285,10 +285,12 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, */ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) { + struct pcie_port_service_driver *hpsvc; struct pci_dev *udev; struct pci_bus *parent; struct pci_dev *pdev, *temp; pci_ers_result_t result; + struct device *hpdev; if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) udev = dev; @@ -308,8 +310,17 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) pci_dev_put(pdev); } + hpsvc = pcie_port_find_service(udev, PCIE_PORT_SERVICE_HP); + hpdev = pcie_port_find_device(udev, PCIE_PORT_SERVICE_HP); + + if (hpdev && hpsvc) + hpsvc->mask_irq(to_pcie_device(hpdev)); + result = reset_link(udev, service); + if (hpdev && hpsvc) + hpsvc->unmask_irq(to_pcie_device(hpdev)); + if ((service == PCIE_PORT_SERVICE_AER) && (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) { /*