From patchwork Mon Jan 4 23:02:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 11997705 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9D7AC43219 for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B484E207BC for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727209AbhADXDr (ORCPT ); Mon, 4 Jan 2021 18:03:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:52492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbhADXDr (ORCPT ); Mon, 4 Jan 2021 18:03:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75EA72255F; Mon, 4 Jan 2021 23:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609801386; bh=Rh2aHJURwBC2xknvbCANoE2Rg4qvZj7EUZ6MjeOJbe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcWt3mM5LkhWGoqGNXSbCvi4D7+qcTjyW2wPuvKPEEI+C24zqyBB+JSUKajDx6E+K eRpaIezYVLOEWrgn80MwBtfqK9YlobwbAmXlkfAxIOLiAtJ16IWU7k/quWvx0V+ETE iAgEPk6Qeu2hqGnZnKd+PzE8NyqNi5Hf1q56qjw2DI+wbm/Q5eqAmXEG/TCa5dgO95 NhPUozq9y1ZXPFdDIr4USaawMT38wIPvl3tmapj03xe3r/Zaairi0wRkB0ghEzgNjc DI13pjkmtmp9NuMZIQ6ghr2qyrh9mJZ0Qj29ocRkIDEhngbiB01eZVotWHfKwLDoai +5o17cxIrZkwA== From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch , Sean V Kelley Subject: [PATCHv2 1/5] PCI/ERR: Clear status of the reporting device Date: Mon, 4 Jan 2021 15:02:56 -0800 Message-Id: <20210104230300.1277180-2-kbusch@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210104230300.1277180-1-kbusch@kernel.org> References: <20210104230300.1277180-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Error handling operates on the first downstream port above the detected error, but the error may have been reported by a downstream device. Clear the AER status of the device that reported the error rather than the first downstream port. Acked-by: Sean V Kelley Signed-off-by: Keith Busch --- drivers/pci/pcie/err.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 510f31f0ef6d..a84f0bf4c1e2 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -231,15 +231,14 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, pci_walk_bridge(bridge, report_resume, &status); /* - * If we have native control of AER, clear error status in the Root - * Port or Downstream Port that signaled the error. If the - * platform retained control of AER, it is responsible for clearing - * this status. In that case, the signaling device may not even be - * visible to the OS. + * If we have native control of AER, clear error status in the device + * that detected the error. If the platform retained control of AER, + * it is responsible for clearing this status. In that case, the + * signaling device may not even be visible to the OS. */ if (host->native_aer || pcie_ports_native) { - pcie_clear_device_status(bridge); - pci_aer_clear_nonfatal_status(bridge); + pcie_clear_device_status(dev); + pci_aer_clear_nonfatal_status(dev); } pci_info(bridge, "device recovery successful\n"); return status; From patchwork Mon Jan 4 23:02:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 11997701 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A3BC43332 for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B5F72256F for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbhADXDv (ORCPT ); Mon, 4 Jan 2021 18:03:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:52506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbhADXDr (ORCPT ); Mon, 4 Jan 2021 18:03:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C42322581; Mon, 4 Jan 2021 23:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609801387; bh=NXwP1ErKyVJODnA/aF275bllkVjGP9RBRQ1wzKV26FM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amu7uWsHmLuJzrq+ON928FZE2SqIcsShInYhnf8uGlJCXlWXSgV5aUVhoPGtGAxBa pgNNhIp4xqzYjF/kX74xhTxrc6FYRpNK6xC/U0BnkvhPBmBgS4TC/fdAv52KvYlxqh +Z0l9iXoxMQb9CBuqVx2+GzjRmPoI/jiTevrjAnIfgHNadaqoig4nlovXVQS8OhdO6 cocT7NoPleBWi1s8GoVafQmf5GQI2PPU28RG6eq0b3UI1MbShz5xifARhOXo5vivS1 JbRbpPPd1Ina5UwapYEKCHCi1P5I7m55KWvePXfKvz/g1/kuqVoJ4ds76gsW6rmx02 kZX4IfFmd8L8w== From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch , Sean V Kelley Subject: [PATCHv2 2/5] PCI/AER: Actually get the root port Date: Mon, 4 Jan 2021 15:02:57 -0800 Message-Id: <20210104230300.1277180-3-kbusch@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210104230300.1277180-1-kbusch@kernel.org> References: <20210104230300.1277180-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The pci_dev parameter given to aer_root_reset() may be a downstream port rather than the root port. Get the root port from the provided device in order to clear the root's aer status. Acked-by: Sean V Kelley Signed-off-by: Keith Busch --- drivers/pci/pcie/aer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 77b0f2c45bc0..3fd4aaaa627e 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1388,7 +1388,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) if (type == PCI_EXP_TYPE_RC_END) root = dev->rcec; else - root = dev; + root = pcie_find_root_port(dev); /* * If the platform retained control of AER, an RCiEP may not have From patchwork Mon Jan 4 23:02:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 11997703 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA75AC432C3 for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82493207BC for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbhADXDv (ORCPT ); Mon, 4 Jan 2021 18:03:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:52514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727234AbhADXDs (ORCPT ); Mon, 4 Jan 2021 18:03:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95A0B22583; Mon, 4 Jan 2021 23:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609801388; bh=Rk+0p05fTxUh6B0JyVhxlzcGbXRv8aBfkyR+1TUo9FE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7r12fkR/8diSMYYSDPqctIad2jXUPe6PjL0oBU8MSXKjutta2SH+Cb0tvHhy6EPn u8PS9uQDcKK/DJQ1KRPLcsaPX9gc76g/Mvx2ycP3WjT9scUhmRm7PQSeh6aAVtlH9l /v+8XtbKrykr8GU3M4o1a0bdny34V6/6rBN1JJ+fOmGpkkQy+1ZjRwbclZ9DIJO/Cf eqdhaOPcH0apalyRdCZGpMOhcAfu9E+PAPy3gtA0Rr9nZ+qAVS6OofeGkhRC7/mGk9 x/8zXjSlAcpcHJ/cWiITC0UOXRngZ98K/tuNDWiyvh89Kzjw+HMu5yX5EHU16LKRyQ nM5T6yKKNulgg== From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch , Hinko Kocevar , Sean V Kelley Subject: [PATCHv2 3/5] PCI/ERR: Retain status from error notification Date: Mon, 4 Jan 2021 15:02:58 -0800 Message-Id: <20210104230300.1277180-4-kbusch@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210104230300.1277180-1-kbusch@kernel.org> References: <20210104230300.1277180-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Overwriting the frozen detected status with the result of the link reset loses the NEED_RESET result that drivers are depending on for error handling to report the .slot_reset() callback. Retain this status so that subsequent error handling has the correct flow. Reported-by: Hinko Kocevar Acked-by: Sean V Kelley Signed-off-by: Keith Busch Reviewed-by: Kuppuswamy Sathyanarayanan --- drivers/pci/pcie/err.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index a84f0bf4c1e2..b576aa890c76 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -198,8 +198,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, pci_dbg(bridge, "broadcast error_detected message\n"); if (state == pci_channel_io_frozen) { pci_walk_bridge(bridge, report_frozen_detected, &status); - status = reset_subordinates(bridge); - if (status != PCI_ERS_RESULT_RECOVERED) { + if (reset_subordinates(bridge) != PCI_ERS_RESULT_RECOVERED) { pci_warn(bridge, "subordinate device reset failed\n"); goto failed; } From patchwork Mon Jan 4 23:02:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 11997707 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C58A7C43333 for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C0C52253D for ; Mon, 4 Jan 2021 23:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbhADXDv (ORCPT ); Mon, 4 Jan 2021 18:03:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:52544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727235AbhADXDt (ORCPT ); Mon, 4 Jan 2021 18:03:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4432B2256F; Mon, 4 Jan 2021 23:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609801388; bh=9moplLCuNdRgj7FDWgkL0dHt82jL3U/8g1Dx74XzJxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9A3bkfjGS7zTx6wvTgq343bVxrJvSE3QwgkloVoG0j1GAxHzLLTCnij3KR7AtNMw q1vHgaPbDuYpr0HYjxpZtj5fufb3LqxaGiAsPI9KmQJoWLmiZ33+IwWSTHFVnmJ3AC rQsC46kji8bakUWUAQ11xvOt+CroKYDlgIe4sU4bEk42lYBtgx0cjggrp6SBDsa1SK OG3+d51BQCVqkMGaLrkt+GLIsPibOwqanRdJoJdxtc/DtE3CISbzgaS6rDs0Ayo2Sl Ce/o7FsFKuMrx2UI0f02hYESUpUe7z3gfWaJUfLOYPbuRvo53mFALI9Ppxo2pk4EyK BObHi61xXldQQ== From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch Subject: [PATCHv2 4/5] PCI/AER: Specify the type of port that was reset Date: Mon, 4 Jan 2021 15:02:59 -0800 Message-Id: <20210104230300.1277180-5-kbusch@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210104230300.1277180-1-kbusch@kernel.org> References: <20210104230300.1277180-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The AER driver may be called upon to reset either a downstream or a root port. Check which type it is to properly identify it when logging that the reset occured. Signed-off-by: Keith Busch --- drivers/pci/pcie/aer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 3fd4aaaa627e..ba22388342d1 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1414,7 +1414,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) } } else { rc = pci_bus_error_reset(dev); - pci_info(dev, "Root Port link has been reset (%d)\n", rc); + pci_info(dev, "%s Port link has been reset (%d)\n", + pci_is_root_bus(dev->bus) ? "Root" : "Downstream", rc); } if ((host->native_aer || pcie_ports_native) && aer) { From patchwork Mon Jan 4 23:03:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 11997711 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64601C43333 for ; Mon, 4 Jan 2021 23:04:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4222253D for ; Mon, 4 Jan 2021 23:04:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbhADXE1 (ORCPT ); Mon, 4 Jan 2021 18:04:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:52646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726333AbhADXE1 (ORCPT ); Mon, 4 Jan 2021 18:04:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4DEC22795; Mon, 4 Jan 2021 23:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609801389; bh=utzC49E4z7mpZXi2qCX/fLaIrr9rys9rA/mzLO41B20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vNWgeGqROopzVPiVH/PE3reyE/6ZRkHA0GGNFU92zz2rc6DOl0ktqZuvcqOdkWYAF yazfpJrfjirXvip6ajyfoHyzmKCIoUchnD3MFgjv5cAW2KGgkca8GfXMdtSWmAuehN iHy1umhmtz7/YZqkreGyM6BfqCjGN8xi5oAJP3HnLn3fVHuFGMEvrM/VNI5+0SPfH1 Z1dAEgFHFA0m7+PpxZ465fCBDzOF37NG/JdUeOzjtn0XHr3TGN/43EujQwd30fWa7d ckqcJ3UTKpH7ZFM4SFLg/pRYLKHuZsXgs24ynojpu0MgKE20mNpN3W2/xqHfXLPClN /Mn0qOoBuQTHg== From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch Subject: [PATCHv2 5/5] PCI/portdrv: Report reset for frozen channel Date: Mon, 4 Jan 2021 15:03:00 -0800 Message-Id: <20210104230300.1277180-6-kbusch@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210104230300.1277180-1-kbusch@kernel.org> References: <20210104230300.1277180-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The PCI error recovery always resets the link for a frozen state, so the port driver should return that a reset is required for its result. This will get the .slot_reset() callback invoked, which is necessary to restore the port's config space. Without this, the driver had been relying on downstream drivers to return this status. Signed-off-by: Keith Busch --- drivers/pci/pcie/portdrv_pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 0b250bc5f405..de141bfb0bc2 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -153,7 +153,8 @@ static void pcie_portdrv_remove(struct pci_dev *dev) static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev, pci_channel_state_t error) { - /* Root Port has no impact. Always recovers. */ + if (error == pci_channel_io_frozen) + return PCI_ERS_RESULT_NEED_RESET; return PCI_ERS_RESULT_CAN_RECOVER; }