From patchwork Thu Jun 28 18:28:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10494819 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 2B97260532 for ; Thu, 28 Jun 2018 19:06:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE652A414 for ; Thu, 28 Jun 2018 19:06:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22FBA2A421; Thu, 28 Jun 2018 19:06:13 +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 C34B12A418 for ; Thu, 28 Jun 2018 19:06:12 +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=oouTmzCIh+L4js GcGdM/mhGWng5VlXDhC+7Bvvz27T5sUI9bq+elmHC4fM6ZkLJilJ/SaELITO7OzllTKLlo2abqCZE osRJezjoLWBIAzm8B8EhbKoxxM9a8IUv67unWjo8226I9zyT2q+thVmZ3CMOJJ96R7kcOKW4rNAP8 CYAiIdv48HJJRf3LfnmSCGCYigFLzjhds+mEZpMLFPwEebjpWjdmJcPUMJ6X8iiTkwHQm9khq9xOR ZU0MvtusMCkrnP/K2QYiXb9fvrslNEhJ7DIhgSgbftTNm1/1Ikaya/A7pzmP7+2U+0yx1uXYheg6J wZ0+O8ofKAk4LDIj4oiw==; 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 1fYcF4-0000cf-ND; Thu, 28 Jun 2018 19:06:06 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYcES-000091-Pp for linux-arm-kernel@bombadil.infradead.org; Thu, 28 Jun 2018 19:05:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=z1ZTLfKmz3vHnS5L7yjO2kZywTol9uFchq8MdulXzK4=; b=zqXPooXtzMmsfYMq3M7M04RYgo GSB84K6nLcfJC1ikmCEzQ+lAWjZZDScWEDQA9duEvja4FoI9JoE7cwAh/G6zx7HvO/xuLVKJnTIK/ GjHbolYL1cg+PGVKjXUaj068yrKwkvMhe2sL04PRupN05Ln8S82uIPO9X38p5HT1iKEWiiWdsDJaC ggmXkKj6e9SVtNbu22wYVNM+zJ1NVFA9R/A0jcG9k6HLCBmb8iGP0zxF4TSwrmqCJd62SYYYwkvI4 xI7dA/u4PAP7wDXeHRs/uxjRDv6I2F8LwzIFK8X3AyyRbiItktEHg/HKPa8T3ZmxEyOJVH1in+EZj yR2NgR0g==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYbgi-0000Jq-HC for linux-arm-kernel@lists.infradead.org; Thu, 28 Jun 2018 18:30:37 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E9C2D60BEE; Thu, 28 Jun 2018 18:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530210622; bh=7amJamHHqQHBPl05nOR2fU2RCC8Buu+5v5PZz+VwP4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/BQk9+/rI7iaCqBwwfxjCnm+7rP72kq2fKWCqnQq98bxdrS0S84ADzS6Si38YtVa We+wZjxZz5BEDLWa0CIVb5oEFBhCBzEjMzeJ4KWjtF+lDlvZr1fW1VvximkPTjYJTD KkH7I7YMgecbbg1cEfnil4jLN/rLxQSwPkclzM+I= 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 7968660BDF; Thu, 28 Jun 2018 18:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530210597; bh=7amJamHHqQHBPl05nOR2fU2RCC8Buu+5v5PZz+VwP4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPJa63y0fIMoOh8Ulcg3TAj1eM9HwMli2q/SOB6ofJpZjlujl2bpjPqu/VLu89ZVZ 97CGfL3Rde++q2sNKFPs2hMd08+Fbpviy4KwZhbXRYIZTJne6JGKE+RxjrDXGnFaMy 3u6R/eetFjZJKGLkirFSgBsnT3KJN80fpGbvtNQg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7968660BDF 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 V3 6/6] PCI: Handle link reset via hotplug if supported Date: Thu, 28 Jun 2018 14:28:26 -0400 Message-Id: <1530210507-9287-6-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530210507-9287-1-git-send-email-okaya@codeaurora.org> References: <1530210507-9287-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_143036_746006_6981790D X-CRM114-Status: GOOD ( 18.76 ) 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, "Rafael J. Wysocki" , 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) &&