Received: by 10.192.165.148 with SMTP id m20csp3553778imm; Mon, 23 Apr 2018 08:26:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx48xMb91lfA8k8SC+eBXAqkIMAhOCQKdfbmKZ+o+lVmKmPBJDPUXGTqduld7GlHGOiRPsQzY X-Received: by 10.101.91.7 with SMTP id y7mr17196881pgq.396.1524497187256; Mon, 23 Apr 2018 08:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524497187; cv=none; d=google.com; s=arc-20160816; b=hchcd07DO8OjGALoUQ8C5b2wETtISPnghyVLQsaKuphyr9tWKEmEpRt7iSaTWw+lZZ 7W0+h0ic1WWWSHqtxSIfEa3OlnY85X41e3Mb94hHDYFtIsqmB2NvdLcoaVfJiBNpOlYN Ra4FyYnDZEB0mCVXgx3qg+9dwMKB5Qg+2RggCNAC3cSjOs20+zF3XRn/RQtw7c+fRvaW iB31qSC6UWBMyPL0Y0W94GMtWv3bueoFyrBwqG80SiTaQzoueSu/ehrv1vZ1ypmwc/Fg lfVGQyj5400QHwsis8wKhLkLdAqNfwQdHdzePBB/eC1hBBKnAXVi6jn0kti7tnIBUC5H qjbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OvkEQNX205JhPq6FDbC6ZuWiDN96z+fZ4aDp1J3GQpw=; b=rquDuHV9dEtQp7rWc+Bwke4QMFE1+UH6XbdmxiG5XLaYElm2wTGicdsCFdk5A1wWOy lLhQ4JfnS6NnAWz5rrxivsZiWKD9ZZS8VmMydk+5z6KcNNSoph9SLOw0ZGbj0DjUHfjt O23tED6UR05k6JEkxaexTI3eLEJpMXI7h87XNqACHGL4CJr2bLm99gUa+EI7NkdcT+J4 YkExwYqoOGpmCvjBbUBFkveezmQCFSwYCWcPVp3VWK0NYz3e9ZdZ67tLBdjYpcwN+jyq A4znoG4uoJQ2N4VRIYASbxlP2Ds+YUYkSQDzsI6tEZADUqXFzIDGC3g+7tIGJQC+OHmT pokg== ARC-Authentication-Results: i=1; mx.google.com; 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 z17si6184174pge.271.2018.04.23.08.26.12; Mon, 23 Apr 2018 08:26:27 -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; 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 S1755885AbeDWPYe (ORCPT + 99 others); Mon, 23 Apr 2018 11:24:34 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:40330 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755747AbeDWPXS (ORCPT ); Mon, 23 Apr 2018 11:23:18 -0400 X-IronPort-AV: E=Sophos;i="5.49,318,1520924400"; d="scan'208";a="337205362" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by wolverine01.qualcomm.com with ESMTP; 23 Apr 2018 08:23:17 -0700 Received: from westreach.qualcomm.com ([10.228.196.125]) by ironmsg02-sd.qualcomm.com with ESMTP; 23 Apr 2018 08:23:15 -0700 Received: by westreach.qualcomm.com (Postfix, from userid 467151) id A41151F0D; Mon, 23 Apr 2018 11:23:14 -0400 (EDT) From: Oza Pawandeep To: Bjorn Helgaas , Philippe Ombredanne , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Dongdong Liu , Keith Busch , Wei Zhang , Sinan Kaya , Timur Tabi Cc: Oza Pawandeep Subject: [PATCH v14 8/9] PCI/AER/DPC: Align FATAL error handling for AER and DPC Date: Mon, 23 Apr 2018 11:23:12 -0400 Message-Id: <1524496993-29799-9-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524496993-29799-1-git-send-email-poza@codeaurora.org> References: <1524496993-29799-1-git-send-email-poza@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there is a DPC support in the switch then ERR_FATAL and ERR_NONFATAL should be handled in a same way with respect to DPC. This patch alters the behavior of handling of ERR_FATAL, where removal of devices is initiated, followed by reset link, followed by re-enumeration, and it is applicable to both AER and DPC, so that we have unified error handling from error agents (SW) point of view. Signed-off-by: Oza Pawandeep diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index da8331f..b2eaa3f 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c @@ -334,6 +334,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); + aer_error_resume(dev); + return PCI_ERS_RESULT_RECOVERED; } diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index d02e029..99d52a0 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -273,6 +273,44 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, return result_data.result; } +pci_ers_result_t pcie_do_fatal_recovery(struct pci_dev *dev, int severity) +{ + struct pci_dev *udev; + struct pci_bus *parent; + struct pci_dev *pdev, *temp; + pci_ers_result_t result = PCI_ERS_RESULT_RECOVERED; + + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) + udev = dev; + else + udev = dev->bus->self; + + if (severity == AER_FATAL) + pci_cleanup_aer_uncorrect_error_status(dev); + + parent = udev->subordinate; + pci_lock_rescan_remove(); + list_for_each_entry_safe_reverse(pdev, temp, &parent->devices, + bus_list) { + pci_dev_get(pdev); + pci_dev_set_disconnected(pdev, NULL); + if (pci_has_subordinate(pdev)) + pci_walk_bus(pdev->subordinate, + pci_dev_set_disconnected, NULL); + pci_stop_and_remove_bus_device(pdev); + pci_dev_put(pdev); + } + + result = reset_link(udev, severity); + + if (pcie_wait_for_link(udev, true)) + pci_rescan_bus(udev->bus); + + pci_unlock_rescan_remove(); + + return result; +} + /** * pcie_do_recovery - handle nonfatal/fatal error recovery process * @dev: pointer to a pci_dev data structure of agent detecting an error @@ -284,12 +322,16 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, */ void pcie_do_recovery(struct pci_dev *dev, int severity) { - pci_ers_result_t status, result = PCI_ERS_RESULT_RECOVERED; + pci_ers_result_t status; enum pci_channel_state state; if ((severity == AER_FATAL) || - (severity == DPC_FATAL)) - state = pci_channel_io_frozen; + (severity == DPC_FATAL)) { + status = pcie_do_fatal_recovery(dev, severity); + if (status != PCI_ERS_RESULT_RECOVERED) + goto failed; + return; + } else state = pci_channel_io_normal; @@ -298,13 +340,6 @@ void pcie_do_recovery(struct pci_dev *dev, int severity) "error_detected", report_error_detected); - if ((severity == AER_FATAL) || - (severity == DPC_FATAL)) { - result = reset_link(dev, severity); - if (result != PCI_ERS_RESULT_RECOVERED) - goto failed; - } - if (status == PCI_ERS_RESULT_CAN_RECOVER) status = broadcast_error_message(dev, state, diff --git a/drivers/pci/pcie/pcie-dpc.c b/drivers/pci/pcie/pcie-dpc.c index cd15862..a3e9b25 100644 --- a/drivers/pci/pcie/pcie-dpc.c +++ b/drivers/pci/pcie/pcie-dpc.c @@ -81,8 +81,6 @@ static void dpc_wait_link_inactive(struct dpc_dev *dpc) */ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev) { - struct pci_bus *parent = pdev->subordinate; - struct pci_dev *dev, *temp; struct dpc_dev *dpc; struct pcie_device *pciedev; struct device *devdpc; @@ -93,19 +91,6 @@ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev) dpc = get_service_data(pciedev); cap = dpc->cap_pos; - pci_lock_rescan_remove(); - list_for_each_entry_safe_reverse(dev, temp, &parent->devices, - bus_list) { - pci_dev_get(dev); - pci_dev_set_disconnected(dev, NULL); - if (pci_has_subordinate(dev)) - pci_walk_bus(dev->subordinate, - pci_dev_set_disconnected, NULL); - pci_stop_and_remove_bus_device(dev); - pci_dev_put(dev); - } - pci_unlock_rescan_remove(); - dpc_wait_link_inactive(dpc); if (dpc->rp_extensions && dpc_wait_rp_inactive(dpc)) return PCI_ERS_RESULT_DISCONNECT; -- 2.7.4