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: 9360037 X-Patchwork-Delegate: bhelgaas@google.com 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 73FD06075E for ; Mon, 3 Oct 2016 05:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65032289FF for ; Mon, 3 Oct 2016 05:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5976628A00; Mon, 3 Oct 2016 05:37:29 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C91A82899F for ; Mon, 3 Oct 2016 05:37:28 +0000 (UTC) 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= 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 X-Virus-Scanned: ClamAV using ClamSMTP 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); }