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: 9360047 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 508426075E for ; Mon, 3 Oct 2016 05:39:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41A3D2899F for ; Mon, 3 Oct 2016 05:39:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36231289FE; Mon, 3 Oct 2016 05:39:16 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E4E7A2899F for ; Mon, 3 Oct 2016 05:39:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bqvx3-00014o-MW; Mon, 03 Oct 2016 05:38:09 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bqvwQ-0000wR-9W for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2016 05:37:33 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C497061AC6; 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161002_223730_454434_E24B1308 X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sinan Kaya , linux-arm-msm@vger.kernel.org, Lorenzo.Pieralisi@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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); }