From patchwork Mon Oct 3 05:36:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 677611 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3snW5s49jGz9s3T for ; Mon, 3 Oct 2016 16:37:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b=j1bdZQLG+eV61WHj4GE9+4BkmSyScVh3SXSoA0XmbiSBrjlxKNqJUqI7SxDv04rWBJ5RBosj+1qaMlor3nJdfQZiOPpgFPviYrsJDt+qCYfZzjVZtXb+tKf8jECeAqrTGT1u9mXlQTzndF8J8EL/N5R/1q66d+abOMkvzGjo12c=; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b=j1bdZQLG+eV61WHj4GE9+4BkmSyScVh3SXSoA0XmbiSBrjlxKNqJUqI7SxDv04rWBJ5RBosj+1qaMlor3nJdfQZiOPpgFPviYrsJDt+qCYfZzjVZtXb+tKf8jECeAqrTGT1u9mXlQTzndF8J8EL/N5R/1q66d+abOMkvzGjo12c=; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752268AbcJCFhQ (ORCPT ); Mon, 3 Oct 2016 01:37:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35262 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752160AbcJCFhM (ORCPT ); Mon, 3 Oct 2016 01:37:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AE48461ADB; Mon, 3 Oct 2016 05:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475473031; bh=xBOImfKCRy5J7O7HzObPVT3fUC5fRE8U5+QlMtI4zvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1bdZQLG+eV61WHj4GE9+4BkmSyScVh3SXSoA0XmbiSBrjlxKNqJUqI7SxDv04rWB J5RBosj+1qaMlor3nJdfQZiOPpgFPviYrsJDt+qCYfZzjVZtXb+tKf8jECeAqrTGT1 u9mXlQTzndF8J8EL/N5R/1q66d+abOMkvzGjo12c= 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,SPF_PASS,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 EE70661AC3; Mon, 3 Oct 2016 05:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475473031; bh=xBOImfKCRy5J7O7HzObPVT3fUC5fRE8U5+QlMtI4zvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1bdZQLG+eV61WHj4GE9+4BkmSyScVh3SXSoA0XmbiSBrjlxKNqJUqI7SxDv04rWB J5RBosj+1qaMlor3nJdfQZiOPpgFPviYrsJDt+qCYfZzjVZtXb+tKf8jECeAqrTGT1 u9mXlQTzndF8J8EL/N5R/1q66d+abOMkvzGjo12c= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org EE70661AC3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org, cov@codeaurora.org, alex.williamson@redhat.com, vikrams@codeaurora.org Cc: Lorenzo.Pieralisi@arm.com, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , linux-kernel@vger.kernel.org Subject: [PATCH V3 1/2] PCI: add CRS support to error handling path Date: Mon, 3 Oct 2016 01:36:59 -0400 Message-Id: <1475473021-14251-2-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1475473021-14251-1-git-send-email-okaya@codeaurora.org> References: <1475473021-14251-1-git-send-email-okaya@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The PCIE spec allows an endpoint device to extend the initialization time beyond 1 second by issuing Configuration Request Retry Status (CRS) for a vendor ID read request. This basically means "I'm busy now, please call me back later". There are two moving parts to CRS support from the SW perspective. One part is to determine if CRS is supported or not. The second part is to set the CRS visibility register. As part of the probe, the Linux kernel sets the above two conditions in pci_enable_crs function. The kernel is also honoring the returned CRS in pci_bus_read_dev_vendor_id function if supported. The function will poll up to specified amount of time while endpoint is returning CRS response. The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR resets. The hot reset is initiated by starting a secondary bus reset. A bus/device restore follows the reset. This patch is adding vendor ID read into dev restore function to validate that the device is accessible before writing the register contents. If the device issues CRS, the code might poll up to 60 seconds. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aab9d51..c8749b9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4020,6 +4020,12 @@ static void pci_dev_save_and_disable(struct pci_dev *dev) static void pci_dev_restore(struct pci_dev *dev) { + u32 l; + + /* see if the device is accessible first */ + if (!pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &l, 60 * 1000)) + return; + pci_restore_state(dev); pci_reset_notify(dev, false); }