Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp334611imm; Thu, 28 Jun 2018 21:31:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdjEqMtTtPdlO6b3cI2WuDwtwJSutwrwhFVlNFv+4EHR4Gr8ybeZalz71WPzELNEgNw/UY8 X-Received: by 2002:a62:b20c:: with SMTP id x12-v6mr3669886pfe.64.1530246705080; Thu, 28 Jun 2018 21:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530246705; cv=none; d=google.com; s=arc-20160816; b=lnjM6W23xmubuIl8qUtERRHlEk71D2rvfEYj/GNRg92QzTtvfsf0j3k5XEAv5dS7Wu M5iI7wUxbZFRy6HQq+jBq0SgQnRAh1ipM5pBFyzkve4c14C85+OZHGWuNyGd3627qWPR wU9m+1+y+LR6MWV830K1AsVPbo6JCzfbB6cr3bkOMX4ZtUuLtdK1j37g15JEk6OYdJYI qWGkdrmqjyHXH49BR1srKz6WFIYPtJC5fRI+aDsYpBS2pwxIfz1oEHjVUHjtMtnb9Dvr axOfIu3X6u/5CAZEJrCD/jpOVbqGC9+ssoG7rv/tn/50Ren5wbOcNIh8A7nAPSXhQw89 93LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=z1ZTLfKmz3vHnS5L7yjO2kZywTol9uFchq8MdulXzK4=; b=rzBNKezgvaXlzg2q9CM5Ay1Py5fut8ZrOU+Ds6mnyfhD7Zdn74RXLQuctiqfbltl23 rHztjyZhoJlReMwDNpilKmbiBHJ1OJmj22l7H7Dq9KhPLDDbljfTdQMSyQqq/t6/vQ6Y 13PIWRxiZ8LN0sJobBOe3MPj0UtJscLV7ziGDXA6luWDqKz0b3JX7m+dPMkTVaHFwdK8 REEU6zC6EKJEpe7SS3cJUQqLoS8z+Oo7mzMSTW+AN6GP+zGtIMuu+xot3OBSe3UWooFO qjVRUL0PruEujVg7r/pVSsTAXRH4T1h4Fhbd6Pd0rSpGtGeM7rstjE879ah0Yn24WLCX Go7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=bLmLfePw; dkim=pass header.i=@codeaurora.org header.s=default header.b=HgYa5IGj; 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 u8-v6si8287232pfl.87.2018.06.28.21.31.30; Thu, 28 Jun 2018 21:31:45 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=bLmLfePw; dkim=pass header.i=@codeaurora.org header.s=default header.b=HgYa5IGj; 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 S965346AbeF1TcR (ORCPT + 99 others); Thu, 28 Jun 2018 15:32:17 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54820 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935504AbeF1Tby (ORCPT ); Thu, 28 Jun 2018 15:31:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6772160B1E; 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=1530214313; bh=7amJamHHqQHBPl05nOR2fU2RCC8Buu+5v5PZz+VwP4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLmLfePwc9n7TnoazhGCz482friyJwDt37UYAIJu+ie3Hc0Qc05/FGxAVQ1SFnACl yyH4Ebce51hdbiL5XH5ebJPzFe2kbBqI7vaVONRP24q6LNUdOw/6l/AY/yVW2vYL6B UHIHtGd5U7iXnYZ7Y5Pagidiiefw3xVHPjad9Sxw= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg , Greg Kroah-Hartman , Oza Pawandeep , Keith Busch , linux-kernel@vger.kernel.org (open list) 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 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) && -- 2.7.4