From patchwork Thu Jun 28 19:31:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10494971 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 3166B6022E for ; Thu, 28 Jun 2018 19:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 324CD29AFC for ; Thu, 28 Jun 2018 19:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2621029B3E; Thu, 28 Jun 2018 19:35:23 +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 B864329AFC for ; Thu, 28 Jun 2018 19:35:22 +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=hzqZ2I4rbrfhGPLx3cp8YADYnFmOFWB3seeFDsNkuLg=; b=rkM7D9whDCLDhI ZDbZi+gWw/+ww8txlAaZUOTvIciM+fTjkpfI5/D5CdF4k6oN3HWM5HuWrXJWoITRUZ3g00ct5QH/q UpIutfhH9i1n3moTYV6iWZt25dTjNyGw30o9avlB8GfDgEUs7qrVv2FZLTdosJiXGrb2GWdw4cl77 t8FUkGq8e/t0rWNTu+X3vDciSucF2HWbnWSysilKYbv0houKfeRBL4XeNihydcHU/0egOHTfAXig3 tR9iOTBD5hDbUkbGHu1b04B+7T4dX/EOhnTalp/iaiyUAhqQh4Kk8qz4H4oMOhbJmknLK7G5nujMi YlHucpituoASFlOqCsEA==; 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 1fYchE-00058p-O5; Thu, 28 Jun 2018 19:35:12 +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 1fYceA-0002y3-0R for linux-arm-kernel@lists.infradead.org; Thu, 28 Jun 2018 19:32:09 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 20C52605A5; Thu, 28 Jun 2018 19:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530214311; bh=7amJamHHqQHBPl05nOR2fU2RCC8Buu+5v5PZz+VwP4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=df1QGRZdZjBaXOo8qc1TLsjBQNLDQJ16d9mcgQ83Cotc6/1qnXgGMHgg2yTjTTkod 18QPvCP30+dbVo7Xo2JxsbKYWyDxmdNh6XKeZnOs20okyZvoZjfVNY+W1tG7gH4rxW cU0LHi4AdPQGagrHA47NWYR8UCBgBFjivevdzdMU= 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 2D37F60B25; Thu, 28 Jun 2018 19:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530214308; bh=7amJamHHqQHBPl05nOR2fU2RCC8Buu+5v5PZz+VwP4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HgYa5IGjboxsvQskRf0JHx9v6HJHGHSTWfZpihDHV5E1iM4j3KHNggpRkK7zT6Wlo cHFKmDAuBoTE3GiejNlgd3FZFo5irWS1Khu3lYLgV2y29v7hiJxdOniMbobXFbv/++ 4wtO+LVAoTRuZML5XuNrCT730ZsVadUi1gDXfFjM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2D37F60B25 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 V4 7/7] PCI: Handle link reset via hotplug if supported Date: Thu, 28 Jun 2018 15:31:05 -0400 Message-Id: <1530214274-21139-7-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530214274-21139-1-git-send-email-okaya@codeaurora.org> References: <1530214274-21139-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-20180628_123202_295641_5D43A95D X-CRM114-Status: GOOD ( 15.73 ) 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 , Greg Kroah-Hartman , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg , 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, bounce the error handling to the hotplug driver so that hotplug driver can mask link up/down interrupts while performing a secondary bus reset. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp_core.c | 20 ++++++++++++++++++++ drivers/pci/pcie/err.c | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 44a6a63..43a49cc 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -299,6 +299,24 @@ static int pciehp_resume(struct pcie_device *dev) } #endif /* PM */ +static pci_ers_result_t pciehp_reset_link(struct pci_dev *pdev) +{ + struct pcie_device *pciedev; + struct controller *ctrl; + struct device *devhp; + struct slot *slot; + int rc; + + devhp = pcie_port_find_device(pdev, PCIE_PORT_SERVICE_HP); + pciedev = to_pcie_device(devhp); + ctrl = get_service_data(pciedev); + slot = ctrl->slot; + + rc = reset_slot(slot->hotplug_slot, 0); + + return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; +} + static struct pcie_port_service_driver hpdriver_portdrv = { .name = PCIE_MODULE_NAME, .port_type = PCIE_ANY_PORT, @@ -311,6 +329,8 @@ static struct pcie_port_service_driver hpdriver_portdrv = { .suspend = pciehp_suspend, .resume = pciehp_resume, #endif /* PM */ + + .reset_link = pciehp_reset_link, }; static int __init pcied_init(void) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index a3a26f1..0b66779 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -308,6 +308,11 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) pci_dev_put(pdev); } + /* handle link reset via hotplug driver if supported */ + if (dev->is_hotplug_bridge && + pcie_port_find_device(dev, PCIE_PORT_SERVICE_HP)) + service = PCIE_PORT_SERVICE_HP; + result = reset_link(udev, service); if ((service == PCIE_PORT_SERVICE_AER) &&