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: 10502605 X-Patchwork-Delegate: agross@codeaurora.org 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 761F460284 for ; Mon, 2 Jul 2018 22:53:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 645FF28BE1 for ; Mon, 2 Jul 2018 22:53:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 573CF28BF1; Mon, 2 Jul 2018 22:53:49 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA3328BE1 for ; Mon, 2 Jul 2018 22:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753524AbeGBWxr (ORCPT ); Mon, 2 Jul 2018 18:53:47 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34944 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753500AbeGBWxq (ORCPT ); Mon, 2 Jul 2018 18:53:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 062C960B72; Mon, 2 Jul 2018 22:53:45 +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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , Oza Pawandeep , Keith Busch , linux-kernel@vger.kernel.org (open list) 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 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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)) { /*